Date: 2019-12-26 00:07:19 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 15517 rows and 60 columns.
#> Top rows are extracted by 'SD, CV, MAD, ATC' methods.
#> Subgroups are detected by 'hclust, kmeans, skmeans, pam, mclust, NMF' method.
#> Number of partitions are tried for k = 2, 3, 4, 5, 6.
#> Performed in total 30000 partitions by row resampling.
#>
#> Following methods can be applied to this 'ConsensusPartitionList' object:
#> [1] "cola_report" "collect_classes" "collect_plots" "collect_stats"
#> [5] "colnames" "functional_enrichment" "get_anno_col" "get_anno"
#> [9] "get_classes" "get_matrix" "get_membership" "get_stats"
#> [13] "is_best_k" "is_stable_k" "ncol" "nrow"
#> [17] "rownames" "show" "suggest_best_k" "test_to_known_factors"
#> [21] "top_rows_heatmap" "top_rows_overlap"
#>
#> You can get result for a single method by, e.g. object["SD", "hclust"] or object["SD:hclust"]
#> or a subset of methods by object[c("SD", "CV")], c("hclust", "kmeans")]
The call of run_all_consensus_partition_methods()
was:
#> run_all_consensus_partition_methods(data = mat, mc.cores = 4)
Dimension of the input matrix:
mat = get_matrix(res_list)
dim(mat)
#> [1] 15517 60
The density distribution for each sample is visualized as in one column in the following heatmap. The clustering is based on the distance which is the Kolmogorov-Smirnov statistic between two distributions.
library(ComplexHeatmap)
densityHeatmap(mat, ylab = "value", cluster_columns = TRUE, show_column_names = FALSE,
mc.cores = 4)
Folowing table shows the best k
(number of partitions) for each combination
of top-value methods and partition methods. Clicking on the method name in
the table goes to the section for a single combination of methods.
The cola vignette explains the definition of the metrics used for determining the best number of partitions.
suggest_best_k(res_list)
The best k | 1-PAC | Mean silhouette | Concordance | Optional k | ||
---|---|---|---|---|---|---|
SD:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
SD:skmeans | 4 | 1.000 | 0.998 | 0.996 | ** | 2 |
SD:pam | 5 | 1.000 | 0.951 | 0.983 | ** | 2,3,4 |
SD:mclust | 2 | 1.000 | 1.000 | 1.000 | ** | |
CV:NMF | 4 | 1.000 | 0.981 | 0.992 | ** | 2,3 |
MAD:hclust | 5 | 1.000 | 0.983 | 1.000 | ** | 2,3 |
MAD:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
MAD:skmeans | 4 | 1.000 | 0.997 | 0.995 | ** | 2 |
MAD:mclust | 2 | 1.000 | 1.000 | 1.000 | ** | |
ATC:hclust | 5 | 1.000 | 0.983 | 1.000 | ** | 2,4 |
ATC:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
ATC:skmeans | 4 | 1.000 | 0.998 | 0.996 | ** | 2,3 |
ATC:NMF | 2 | 1.000 | 1.000 | 1.000 | ** | |
SD:NMF | 3 | 0.980 | 0.950 | 0.975 | ** | 2 |
MAD:NMF | 3 | 0.979 | 0.931 | 0.970 | ** | 2 |
CV:pam | 6 | 0.976 | 0.956 | 0.962 | ** | 2,3,4,5 |
CV:hclust | 4 | 0.954 | 0.950 | 0.972 | ** | |
ATC:mclust | 3 | 0.952 | 0.979 | 0.982 | ** | 2 |
MAD:pam | 6 | 0.939 | 0.902 | 0.956 | * | 2,3,5 |
ATC:pam | 6 | 0.939 | 0.906 | 0.944 | * | 2,4 |
CV:mclust | 5 | 0.934 | 0.899 | 0.949 | * | 3,4 |
CV:skmeans | 6 | 0.927 | 0.950 | 0.951 | * | 2,3,4,5 |
SD:hclust | 3 | 0.902 | 0.988 | 0.962 | * | 2 |
CV:kmeans | 3 | 0.837 | 0.936 | 0.923 |
**: 1-PAC > 0.95, *: 1-PAC > 0.9
Cumulative distribution function curves of consensus matrix for all methods.
collect_plots(res_list, fun = plot_ecdf)
Consensus heatmaps for all methods. (What is a consensus heatmap?)
collect_plots(res_list, k = 2, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = consensus_heatmap, mc.cores = 4)
Membership heatmaps for all methods. (What is a membership heatmap?)
collect_plots(res_list, k = 2, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = membership_heatmap, mc.cores = 4)
Signature heatmaps for all methods. (What is a signature heatmap?)
Note in following heatmaps, rows are scaled.
collect_plots(res_list, k = 2, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 3, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 4, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 5, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 6, fun = get_signatures, mc.cores = 4)
The statistics used for measuring the stability of consensus partitioning. (How are they defined?)
get_stats(res_list, k = 2)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 2 1.000 1.000 1.000 0.509 0.492 0.492
#> CV:NMF 2 1.000 1.000 1.000 0.509 0.492 0.492
#> MAD:NMF 2 1.000 1.000 1.000 0.509 0.492 0.492
#> ATC:NMF 2 1.000 1.000 1.000 0.509 0.492 0.492
#> SD:skmeans 2 1.000 1.000 1.000 0.509 0.492 0.492
#> CV:skmeans 2 1.000 1.000 1.000 0.509 0.492 0.492
#> MAD:skmeans 2 1.000 1.000 1.000 0.509 0.492 0.492
#> ATC:skmeans 2 1.000 1.000 1.000 0.509 0.492 0.492
#> SD:mclust 2 1.000 1.000 1.000 0.509 0.492 0.492
#> CV:mclust 2 0.817 0.879 0.952 0.498 0.512 0.512
#> MAD:mclust 2 1.000 1.000 1.000 0.509 0.492 0.492
#> ATC:mclust 2 1.000 1.000 1.000 0.509 0.492 0.492
#> SD:kmeans 2 1.000 1.000 1.000 0.509 0.492 0.492
#> CV:kmeans 2 0.512 0.926 0.876 0.414 0.492 0.492
#> MAD:kmeans 2 1.000 1.000 1.000 0.509 0.492 0.492
#> ATC:kmeans 2 1.000 1.000 1.000 0.509 0.492 0.492
#> SD:pam 2 1.000 1.000 1.000 0.509 0.492 0.492
#> CV:pam 2 1.000 1.000 1.000 0.509 0.492 0.492
#> MAD:pam 2 1.000 1.000 1.000 0.509 0.492 0.492
#> ATC:pam 2 1.000 1.000 1.000 0.509 0.492 0.492
#> SD:hclust 2 1.000 1.000 1.000 0.509 0.492 0.492
#> CV:hclust 2 0.512 0.957 0.915 0.440 0.492 0.492
#> MAD:hclust 2 1.000 1.000 1.000 0.509 0.492 0.492
#> ATC:hclust 2 1.000 1.000 1.000 0.509 0.492 0.492
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 0.980 0.950 0.975 0.1956 0.880 0.760
#> CV:NMF 3 1.000 0.978 0.991 0.2184 0.863 0.726
#> MAD:NMF 3 0.979 0.931 0.970 0.1715 0.905 0.809
#> ATC:NMF 3 0.924 0.913 0.964 0.0786 0.984 0.967
#> SD:skmeans 3 0.812 0.958 0.950 0.1696 0.919 0.834
#> CV:skmeans 3 1.000 1.000 1.000 0.1852 0.899 0.796
#> MAD:skmeans 3 0.812 0.928 0.917 0.1762 0.919 0.834
#> ATC:skmeans 3 1.000 0.997 0.996 0.2086 0.893 0.783
#> SD:mclust 3 0.799 0.837 0.917 0.2252 0.893 0.783
#> CV:mclust 3 0.944 0.946 0.976 0.3195 0.837 0.682
#> MAD:mclust 3 0.875 0.881 0.906 0.2043 0.893 0.783
#> ATC:mclust 3 0.952 0.979 0.982 0.1971 0.893 0.783
#> SD:kmeans 3 0.812 0.897 0.881 0.1834 0.919 0.834
#> CV:kmeans 3 0.837 0.936 0.923 0.4243 0.919 0.834
#> MAD:kmeans 3 0.812 0.922 0.878 0.1852 0.893 0.783
#> ATC:kmeans 3 0.824 0.897 0.881 0.1830 0.919 0.834
#> SD:pam 3 1.000 1.000 1.000 0.1597 0.919 0.834
#> CV:pam 3 1.000 0.982 0.993 0.1700 0.919 0.834
#> MAD:pam 3 1.000 1.000 1.000 0.1597 0.919 0.834
#> ATC:pam 3 0.812 0.969 0.963 0.1670 0.919 0.834
#> SD:hclust 3 0.902 0.988 0.962 0.1593 0.893 0.783
#> CV:hclust 3 0.593 0.953 0.915 0.2236 0.919 0.834
#> MAD:hclust 3 0.902 0.992 0.973 0.1742 0.893 0.783
#> ATC:hclust 3 1.000 0.978 0.996 0.0370 0.984 0.967
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.885 0.912 0.943 0.1247 0.902 0.751
#> CV:NMF 4 1.000 0.981 0.992 0.1164 0.919 0.789
#> MAD:NMF 4 0.823 0.872 0.915 0.1291 0.877 0.705
#> ATC:NMF 4 0.820 0.929 0.892 0.1558 0.819 0.623
#> SD:skmeans 4 1.000 0.998 0.996 0.1697 0.893 0.740
#> CV:skmeans 4 1.000 0.953 0.983 0.1307 0.906 0.765
#> MAD:skmeans 4 1.000 0.997 0.995 0.1631 0.893 0.740
#> ATC:skmeans 4 1.000 0.998 0.996 0.1298 0.919 0.789
#> SD:mclust 4 0.831 0.831 0.868 0.1030 0.911 0.770
#> CV:mclust 4 0.927 0.922 0.960 0.0465 0.980 0.942
#> MAD:mclust 4 0.844 0.346 0.655 0.1169 0.751 0.449
#> ATC:mclust 4 0.865 0.938 0.945 0.1393 0.919 0.789
#> SD:kmeans 4 0.688 0.905 0.874 0.1195 0.893 0.740
#> CV:kmeans 4 0.699 0.930 0.907 0.1197 0.919 0.802
#> MAD:kmeans 4 0.649 0.552 0.660 0.1160 0.893 0.722
#> ATC:kmeans 4 0.672 0.898 0.853 0.1059 0.893 0.740
#> SD:pam 4 1.000 0.988 0.994 0.1899 0.887 0.725
#> CV:pam 4 1.000 0.995 0.998 0.1299 0.919 0.802
#> MAD:pam 4 0.875 0.774 0.891 0.1963 0.893 0.740
#> ATC:pam 4 1.000 1.000 1.000 0.1733 0.893 0.740
#> SD:hclust 4 0.818 0.988 0.938 0.1327 0.919 0.789
#> CV:hclust 4 0.954 0.950 0.972 0.2089 0.919 0.802
#> MAD:hclust 4 0.818 0.901 0.935 0.0683 0.995 0.988
#> ATC:hclust 4 1.000 0.983 1.000 0.1750 0.905 0.800
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 0.845 0.827 0.924 0.0480 0.995 0.985
#> CV:NMF 5 0.877 0.832 0.909 0.0511 0.954 0.855
#> MAD:NMF 5 0.773 0.853 0.907 0.0526 0.992 0.974
#> ATC:NMF 5 0.739 0.874 0.922 0.0936 0.995 0.985
#> SD:skmeans 5 0.856 0.869 0.904 0.0662 1.000 1.000
#> CV:skmeans 5 0.971 0.934 0.963 0.0624 0.968 0.899
#> MAD:skmeans 5 0.880 0.872 0.915 0.0642 1.000 1.000
#> ATC:skmeans 5 0.935 0.973 0.979 0.0228 0.992 0.974
#> SD:mclust 5 0.727 0.619 0.747 0.0740 0.947 0.827
#> CV:mclust 5 0.934 0.899 0.949 0.0867 0.919 0.753
#> MAD:mclust 5 0.787 0.850 0.833 0.1005 0.801 0.441
#> ATC:mclust 5 0.726 0.502 0.743 0.0604 0.836 0.514
#> SD:kmeans 5 0.652 0.810 0.799 0.0823 1.000 1.000
#> CV:kmeans 5 0.644 0.842 0.860 0.0811 1.000 1.000
#> MAD:kmeans 5 0.653 0.806 0.832 0.0846 0.873 0.641
#> ATC:kmeans 5 0.602 0.843 0.833 0.0874 1.000 1.000
#> SD:pam 5 1.000 0.951 0.983 0.0692 0.944 0.814
#> CV:pam 5 1.000 0.981 0.993 0.0771 0.946 0.837
#> MAD:pam 5 1.000 0.971 0.988 0.0616 0.934 0.789
#> ATC:pam 5 0.841 0.696 0.792 0.0873 0.932 0.780
#> SD:hclust 5 1.000 0.983 1.000 0.0495 0.995 0.985
#> CV:hclust 5 1.000 0.950 0.985 0.0371 0.997 0.991
#> MAD:hclust 5 1.000 0.983 1.000 0.0986 0.919 0.786
#> ATC:hclust 5 1.000 0.983 1.000 0.1311 0.919 0.786
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 0.813 0.783 0.885 0.04385 0.972 0.906
#> CV:NMF 6 0.862 0.768 0.896 0.04199 0.967 0.883
#> MAD:NMF 6 0.756 0.750 0.876 0.03966 0.995 0.985
#> ATC:NMF 6 0.785 0.839 0.893 0.05571 0.995 0.985
#> SD:skmeans 6 0.828 0.826 0.855 0.05662 0.873 0.592
#> CV:skmeans 6 0.927 0.950 0.951 0.04393 0.971 0.898
#> MAD:skmeans 6 0.831 0.883 0.888 0.05557 0.880 0.610
#> ATC:skmeans 6 0.840 0.782 0.900 0.06028 0.964 0.880
#> SD:mclust 6 0.800 0.756 0.861 0.09610 0.896 0.630
#> CV:mclust 6 0.929 0.864 0.900 0.01295 0.995 0.979
#> MAD:mclust 6 0.841 0.821 0.895 0.07477 0.955 0.815
#> ATC:mclust 6 0.756 0.587 0.782 0.07921 0.827 0.415
#> SD:kmeans 6 0.783 0.725 0.772 0.05196 0.949 0.832
#> CV:kmeans 6 0.788 0.722 0.812 0.05839 0.946 0.837
#> MAD:kmeans 6 0.807 0.785 0.789 0.05985 0.924 0.749
#> ATC:kmeans 6 0.675 0.768 0.785 0.05488 0.939 0.799
#> SD:pam 6 0.897 0.894 0.930 0.07369 0.933 0.729
#> CV:pam 6 0.976 0.956 0.962 0.02016 0.977 0.918
#> MAD:pam 6 0.939 0.902 0.956 0.08749 0.933 0.733
#> ATC:pam 6 0.939 0.906 0.944 0.07658 0.868 0.531
#> SD:hclust 6 0.939 0.944 0.965 0.02628 0.992 0.972
#> CV:hclust 6 1.000 0.972 0.993 0.00746 0.997 0.990
#> MAD:hclust 6 0.939 0.933 0.955 0.03011 0.992 0.972
#> ATC:hclust 6 1.000 0.983 1.000 0.01206 0.992 0.972
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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5090 0.492 0.492
#> 3 3 0.902 0.988 0.962 0.1593 0.893 0.783
#> 4 4 0.818 0.988 0.938 0.1327 0.919 0.789
#> 5 5 1.000 0.983 1.000 0.0495 0.995 0.985
#> 6 6 0.939 0.944 0.965 0.0263 0.992 0.972
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.000 1.000 0 1.000 0.000
#> SRR1223542 2 0.000 1.000 0 1.000 0.000
#> SRR1223543 2 0.000 1.000 0 1.000 0.000
#> SRR1223544 2 0.000 1.000 0 1.000 0.000
#> SRR1223545 2 0.000 1.000 0 1.000 0.000
#> SRR1223546 1 0.000 1.000 1 0.000 0.000
#> SRR1223547 1 0.000 1.000 1 0.000 0.000
#> SRR1223548 1 0.000 1.000 1 0.000 0.000
#> SRR1223549 1 0.000 1.000 1 0.000 0.000
#> SRR1223550 1 0.000 1.000 1 0.000 0.000
#> SRR1223551 2 0.000 1.000 0 1.000 0.000
#> SRR1223552 3 0.543 0.950 0 0.284 0.716
#> SRR1223553 2 0.000 1.000 0 1.000 0.000
#> SRR1223554 3 0.543 0.950 0 0.284 0.716
#> SRR1223555 3 0.543 0.950 0 0.284 0.716
#> SRR1223556 1 0.000 1.000 1 0.000 0.000
#> SRR1223557 1 0.000 1.000 1 0.000 0.000
#> SRR1223558 1 0.000 1.000 1 0.000 0.000
#> SRR1223559 1 0.000 1.000 1 0.000 0.000
#> SRR1223560 1 0.000 1.000 1 0.000 0.000
#> SRR1223561 2 0.000 1.000 0 1.000 0.000
#> SRR1223562 2 0.000 1.000 0 1.000 0.000
#> SRR1223563 2 0.000 1.000 0 1.000 0.000
#> SRR1223564 2 0.000 1.000 0 1.000 0.000
#> SRR1223565 2 0.000 1.000 0 1.000 0.000
#> SRR1223566 1 0.000 1.000 1 0.000 0.000
#> SRR1223567 1 0.000 1.000 1 0.000 0.000
#> SRR1223568 1 0.000 1.000 1 0.000 0.000
#> SRR1223569 1 0.000 1.000 1 0.000 0.000
#> SRR1223570 1 0.000 1.000 1 0.000 0.000
#> SRR1223571 2 0.000 1.000 0 1.000 0.000
#> SRR1223572 3 0.543 0.950 0 0.284 0.716
#> SRR1223573 2 0.000 1.000 0 1.000 0.000
#> SRR1223574 3 0.000 0.679 0 0.000 1.000
#> SRR1223575 3 0.543 0.950 0 0.284 0.716
#> SRR1223576 1 0.000 1.000 1 0.000 0.000
#> SRR1223577 1 0.000 1.000 1 0.000 0.000
#> SRR1223578 1 0.000 1.000 1 0.000 0.000
#> SRR1223579 1 0.000 1.000 1 0.000 0.000
#> SRR1223580 1 0.000 1.000 1 0.000 0.000
#> SRR1223581 2 0.000 1.000 0 1.000 0.000
#> SRR1223582 2 0.000 1.000 0 1.000 0.000
#> SRR1223583 2 0.000 1.000 0 1.000 0.000
#> SRR1223584 2 0.000 1.000 0 1.000 0.000
#> SRR1223585 2 0.000 1.000 0 1.000 0.000
#> SRR1223586 1 0.000 1.000 1 0.000 0.000
#> SRR1223587 1 0.000 1.000 1 0.000 0.000
#> SRR1223588 1 0.000 1.000 1 0.000 0.000
#> SRR1223589 1 0.000 1.000 1 0.000 0.000
#> SRR1223590 1 0.000 1.000 1 0.000 0.000
#> SRR1223591 2 0.000 1.000 0 1.000 0.000
#> SRR1223592 3 0.543 0.950 0 0.284 0.716
#> SRR1223593 2 0.000 1.000 0 1.000 0.000
#> SRR1223594 3 0.543 0.950 0 0.284 0.716
#> SRR1223595 3 0.543 0.950 0 0.284 0.716
#> SRR1223596 1 0.000 1.000 1 0.000 0.000
#> SRR1223597 1 0.000 1.000 1 0.000 0.000
#> SRR1223598 1 0.000 1.000 1 0.000 0.000
#> SRR1223599 1 0.000 1.000 1 0.000 0.000
#> SRR1223600 1 0.000 1.000 1 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223542 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223543 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223544 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223545 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223546 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223547 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223548 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223549 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223550 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223551 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223552 4 0.327 0.959 0.000 0.168 0.000 0.832
#> SRR1223553 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223554 4 0.327 0.959 0.000 0.168 0.000 0.832
#> SRR1223555 4 0.327 0.959 0.000 0.168 0.000 0.832
#> SRR1223556 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223557 3 0.336 1.000 0.176 0.000 0.824 0.000
#> SRR1223558 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223559 3 0.336 1.000 0.176 0.000 0.824 0.000
#> SRR1223560 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223561 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223562 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223563 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223564 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223565 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223566 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223567 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223568 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223569 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223570 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223571 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223572 4 0.327 0.959 0.000 0.168 0.000 0.832
#> SRR1223573 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223574 4 0.336 0.615 0.000 0.000 0.176 0.824
#> SRR1223575 4 0.327 0.959 0.000 0.168 0.000 0.832
#> SRR1223576 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223577 3 0.336 1.000 0.176 0.000 0.824 0.000
#> SRR1223578 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223579 3 0.336 1.000 0.176 0.000 0.824 0.000
#> SRR1223580 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223581 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223582 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223583 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223584 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223585 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223586 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223587 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223588 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223589 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223590 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223591 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223592 4 0.327 0.959 0.000 0.168 0.000 0.832
#> SRR1223593 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223594 4 0.327 0.959 0.000 0.168 0.000 0.832
#> SRR1223595 4 0.327 0.959 0.000 0.168 0.000 0.832
#> SRR1223596 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223597 3 0.336 1.000 0.176 0.000 0.824 0.000
#> SRR1223598 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR1223599 3 0.336 1.000 0.176 0.000 0.824 0.000
#> SRR1223600 1 0.000 1.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223542 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223543 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223544 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223545 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223546 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223547 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223548 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223549 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223550 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223551 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223552 4 0.0000 0.999 0 0 0 1.000 0.000
#> SRR1223553 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223554 4 0.0162 0.997 0 0 0 0.996 0.004
#> SRR1223555 4 0.0000 0.999 0 0 0 1.000 0.000
#> SRR1223556 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0 0 1 0.000 0.000
#> SRR1223558 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223559 3 0.0000 1.000 0 0 1 0.000 0.000
#> SRR1223560 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223561 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223562 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223563 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223564 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223565 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223566 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223567 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223568 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223569 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223570 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223571 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223572 4 0.0162 0.997 0 0 0 0.996 0.004
#> SRR1223573 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223574 5 0.0000 0.000 0 0 0 0.000 1.000
#> SRR1223575 4 0.0000 0.999 0 0 0 1.000 0.000
#> SRR1223576 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0 0 1 0.000 0.000
#> SRR1223578 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223579 3 0.0000 1.000 0 0 1 0.000 0.000
#> SRR1223580 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223581 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223582 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223583 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223584 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223585 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223586 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223587 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223588 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223589 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223590 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223591 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223592 4 0.0000 0.999 0 0 0 1.000 0.000
#> SRR1223593 2 0.0000 1.000 0 1 0 0.000 0.000
#> SRR1223594 4 0.0000 0.999 0 0 0 1.000 0.000
#> SRR1223595 4 0.0000 0.999 0 0 0 1.000 0.000
#> SRR1223596 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0 0 1 0.000 0.000
#> SRR1223598 1 0.0000 1.000 1 0 0 0.000 0.000
#> SRR1223599 3 0.0000 1.000 0 0 1 0.000 0.000
#> SRR1223600 1 0.0000 1.000 1 0 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
#> SRR1223541 2 0.0000 0.927 0 1.000 0 0.000 0.000 0.000
#> SRR1223542 2 0.3050 0.796 0 0.764 0 0.000 0.236 0.000
#> SRR1223543 2 0.0000 0.927 0 1.000 0 0.000 0.000 0.000
#> SRR1223544 2 0.3050 0.796 0 0.764 0 0.000 0.236 0.000
#> SRR1223545 2 0.0000 0.927 0 1.000 0 0.000 0.000 0.000
#> SRR1223546 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223547 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223548 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223549 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223550 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223551 2 0.0000 0.927 0 1.000 0 0.000 0.000 0.000
#> SRR1223552 4 0.0000 0.997 0 0.000 0 1.000 0.000 0.000
#> SRR1223553 2 0.0000 0.927 0 1.000 0 0.000 0.000 0.000
#> SRR1223554 4 0.0146 0.996 0 0.000 0 0.996 0.000 0.004
#> SRR1223555 5 0.3050 1.000 0 0.000 0 0.236 0.764 0.000
#> SRR1223556 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223558 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223559 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223560 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223561 2 0.0000 0.927 0 1.000 0 0.000 0.000 0.000
#> SRR1223562 2 0.3050 0.796 0 0.764 0 0.000 0.236 0.000
#> SRR1223563 2 0.0000 0.927 0 1.000 0 0.000 0.000 0.000
#> SRR1223564 2 0.3050 0.796 0 0.764 0 0.000 0.236 0.000
#> SRR1223565 2 0.0000 0.927 0 1.000 0 0.000 0.000 0.000
#> SRR1223566 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223567 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223568 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223569 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223570 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223571 2 0.0000 0.927 0 1.000 0 0.000 0.000 0.000
#> SRR1223572 4 0.0146 0.996 0 0.000 0 0.996 0.000 0.004
#> SRR1223573 2 0.0000 0.927 0 1.000 0 0.000 0.000 0.000
#> SRR1223574 6 0.0000 0.000 0 0.000 0 0.000 0.000 1.000
#> SRR1223575 5 0.3050 1.000 0 0.000 0 0.236 0.764 0.000
#> SRR1223576 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223578 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223579 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223580 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223581 2 0.0000 0.927 0 1.000 0 0.000 0.000 0.000
#> SRR1223582 2 0.3050 0.796 0 0.764 0 0.000 0.236 0.000
#> SRR1223583 2 0.0000 0.927 0 1.000 0 0.000 0.000 0.000
#> SRR1223584 2 0.3050 0.796 0 0.764 0 0.000 0.236 0.000
#> SRR1223585 2 0.0000 0.927 0 1.000 0 0.000 0.000 0.000
#> SRR1223586 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223587 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223588 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223589 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223590 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223591 2 0.0000 0.927 0 1.000 0 0.000 0.000 0.000
#> SRR1223592 4 0.0000 0.997 0 0.000 0 1.000 0.000 0.000
#> SRR1223593 2 0.0000 0.927 0 1.000 0 0.000 0.000 0.000
#> SRR1223594 4 0.0000 0.997 0 0.000 0 1.000 0.000 0.000
#> SRR1223595 5 0.3050 1.000 0 0.000 0 0.236 0.764 0.000
#> SRR1223596 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223598 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223599 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223600 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "kmeans"]
# you can also extract it by
# res = res_list["SD:kmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.5090 0.492 0.492
#> 3 3 0.812 0.897 0.881 0.1834 0.919 0.834
#> 4 4 0.688 0.905 0.874 0.1195 0.893 0.740
#> 5 5 0.652 0.810 0.799 0.0823 1.000 1.000
#> 6 6 0.783 0.725 0.772 0.0520 0.949 0.832
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
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223542 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223543 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223544 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223545 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223546 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223547 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223548 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223549 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223550 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223551 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223552 2 0.63 0.631 0.000 0.524 0.476
#> SRR1223553 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223554 2 0.63 0.631 0.000 0.524 0.476
#> SRR1223555 2 0.63 0.631 0.000 0.524 0.476
#> SRR1223556 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223557 3 0.63 1.000 0.476 0.000 0.524
#> SRR1223558 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223559 3 0.63 1.000 0.476 0.000 0.524
#> SRR1223560 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223561 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223562 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223563 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223564 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223565 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223566 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223567 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223568 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223569 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223570 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223571 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223572 2 0.63 0.631 0.000 0.524 0.476
#> SRR1223573 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223574 2 0.63 0.631 0.000 0.524 0.476
#> SRR1223575 2 0.63 0.631 0.000 0.524 0.476
#> SRR1223576 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223577 3 0.63 1.000 0.476 0.000 0.524
#> SRR1223578 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223579 3 0.63 1.000 0.476 0.000 0.524
#> SRR1223580 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223581 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223582 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223583 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223584 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223585 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223586 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223587 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223588 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223589 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223590 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223591 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223592 2 0.63 0.631 0.000 0.524 0.476
#> SRR1223593 2 0.00 0.863 0.000 1.000 0.000
#> SRR1223594 2 0.63 0.631 0.000 0.524 0.476
#> SRR1223595 2 0.63 0.631 0.000 0.524 0.476
#> SRR1223596 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223597 3 0.63 1.000 0.476 0.000 0.524
#> SRR1223598 1 0.00 1.000 1.000 0.000 0.000
#> SRR1223599 3 0.63 1.000 0.476 0.000 0.524
#> SRR1223600 1 0.00 1.000 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.4304 0.928 0.000 0.716 0.000 0.284
#> SRR1223542 2 0.7118 0.858 0.000 0.548 0.168 0.284
#> SRR1223543 2 0.4304 0.928 0.000 0.716 0.000 0.284
#> SRR1223544 2 0.7118 0.858 0.000 0.548 0.168 0.284
#> SRR1223545 2 0.6285 0.904 0.000 0.624 0.092 0.284
#> SRR1223546 1 0.0000 0.900 1.000 0.000 0.000 0.000
#> SRR1223547 1 0.3942 0.774 0.764 0.236 0.000 0.000
#> SRR1223548 1 0.0469 0.896 0.988 0.012 0.000 0.000
#> SRR1223549 1 0.4040 0.767 0.752 0.248 0.000 0.000
#> SRR1223550 1 0.0188 0.900 0.996 0.004 0.000 0.000
#> SRR1223551 2 0.4621 0.926 0.000 0.708 0.008 0.284
#> SRR1223552 4 0.0469 0.971 0.000 0.000 0.012 0.988
#> SRR1223553 2 0.4621 0.926 0.000 0.708 0.008 0.284
#> SRR1223554 4 0.1867 0.947 0.000 0.000 0.072 0.928
#> SRR1223555 4 0.0592 0.971 0.000 0.000 0.016 0.984
#> SRR1223556 1 0.0000 0.900 1.000 0.000 0.000 0.000
#> SRR1223557 3 0.4599 0.991 0.248 0.016 0.736 0.000
#> SRR1223558 1 0.0000 0.900 1.000 0.000 0.000 0.000
#> SRR1223559 3 0.4599 0.991 0.248 0.016 0.736 0.000
#> SRR1223560 1 0.2921 0.844 0.860 0.140 0.000 0.000
#> SRR1223561 2 0.4304 0.928 0.000 0.716 0.000 0.284
#> SRR1223562 2 0.7118 0.858 0.000 0.548 0.168 0.284
#> SRR1223563 2 0.4304 0.928 0.000 0.716 0.000 0.284
#> SRR1223564 2 0.7118 0.858 0.000 0.548 0.168 0.284
#> SRR1223565 2 0.6285 0.904 0.000 0.624 0.092 0.284
#> SRR1223566 1 0.0000 0.900 1.000 0.000 0.000 0.000
#> SRR1223567 1 0.3942 0.774 0.764 0.236 0.000 0.000
#> SRR1223568 1 0.0469 0.896 0.988 0.012 0.000 0.000
#> SRR1223569 1 0.4040 0.767 0.752 0.248 0.000 0.000
#> SRR1223570 1 0.0188 0.900 0.996 0.004 0.000 0.000
#> SRR1223571 2 0.4621 0.926 0.000 0.708 0.008 0.284
#> SRR1223572 4 0.1302 0.965 0.000 0.000 0.044 0.956
#> SRR1223573 2 0.4621 0.926 0.000 0.708 0.008 0.284
#> SRR1223574 4 0.1867 0.947 0.000 0.000 0.072 0.928
#> SRR1223575 4 0.0592 0.971 0.000 0.000 0.016 0.984
#> SRR1223576 1 0.0000 0.900 1.000 0.000 0.000 0.000
#> SRR1223577 3 0.4040 0.995 0.248 0.000 0.752 0.000
#> SRR1223578 1 0.0000 0.900 1.000 0.000 0.000 0.000
#> SRR1223579 3 0.4040 0.995 0.248 0.000 0.752 0.000
#> SRR1223580 1 0.2921 0.844 0.860 0.140 0.000 0.000
#> SRR1223581 2 0.4304 0.928 0.000 0.716 0.000 0.284
#> SRR1223582 2 0.6773 0.883 0.000 0.584 0.132 0.284
#> SRR1223583 2 0.4304 0.928 0.000 0.716 0.000 0.284
#> SRR1223584 2 0.6773 0.883 0.000 0.584 0.132 0.284
#> SRR1223585 2 0.5990 0.911 0.000 0.644 0.072 0.284
#> SRR1223586 1 0.0000 0.900 1.000 0.000 0.000 0.000
#> SRR1223587 1 0.3942 0.774 0.764 0.236 0.000 0.000
#> SRR1223588 1 0.0469 0.896 0.988 0.012 0.000 0.000
#> SRR1223589 1 0.4040 0.767 0.752 0.248 0.000 0.000
#> SRR1223590 1 0.0188 0.900 0.996 0.004 0.000 0.000
#> SRR1223591 2 0.4621 0.926 0.000 0.708 0.008 0.284
#> SRR1223592 4 0.0707 0.970 0.000 0.000 0.020 0.980
#> SRR1223593 2 0.4621 0.926 0.000 0.708 0.008 0.284
#> SRR1223594 4 0.0707 0.970 0.000 0.000 0.020 0.980
#> SRR1223595 4 0.0592 0.971 0.000 0.000 0.016 0.984
#> SRR1223596 1 0.0000 0.900 1.000 0.000 0.000 0.000
#> SRR1223597 3 0.4220 0.994 0.248 0.004 0.748 0.000
#> SRR1223598 1 0.0000 0.900 1.000 0.000 0.000 0.000
#> SRR1223599 3 0.4220 0.994 0.248 0.004 0.748 0.000
#> SRR1223600 1 0.2921 0.844 0.860 0.140 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.0000 0.812 0.000 1.000 0.000 0.000 0.000
#> SRR1223542 2 0.4219 0.695 0.000 0.584 0.000 0.000 0.416
#> SRR1223543 2 0.0510 0.811 0.000 0.984 0.016 0.000 0.000
#> SRR1223544 2 0.4359 0.697 0.000 0.584 0.004 0.000 0.412
#> SRR1223545 2 0.4465 0.741 0.000 0.672 0.024 0.000 0.304
#> SRR1223546 1 0.0000 0.830 1.000 0.000 0.000 0.000 0.000
#> SRR1223547 1 0.4268 0.574 0.556 0.000 0.000 0.000 0.444
#> SRR1223548 1 0.1270 0.820 0.948 0.000 0.000 0.052 0.000
#> SRR1223549 1 0.4610 0.573 0.556 0.000 0.000 0.012 0.432
#> SRR1223550 1 0.0671 0.829 0.980 0.000 0.000 0.004 0.016
#> SRR1223551 2 0.1205 0.809 0.000 0.956 0.040 0.004 0.000
#> SRR1223552 4 0.3011 0.950 0.000 0.140 0.016 0.844 0.000
#> SRR1223553 2 0.1282 0.810 0.000 0.952 0.044 0.004 0.000
#> SRR1223554 4 0.5710 0.901 0.000 0.140 0.068 0.704 0.088
#> SRR1223555 4 0.3477 0.946 0.000 0.140 0.008 0.828 0.024
#> SRR1223556 1 0.0000 0.830 1.000 0.000 0.000 0.000 0.000
#> SRR1223557 3 0.3516 0.985 0.164 0.000 0.812 0.004 0.020
#> SRR1223558 1 0.0000 0.830 1.000 0.000 0.000 0.000 0.000
#> SRR1223559 3 0.3516 0.985 0.164 0.000 0.812 0.004 0.020
#> SRR1223560 1 0.4317 0.738 0.764 0.000 0.000 0.076 0.160
#> SRR1223561 2 0.0000 0.812 0.000 1.000 0.000 0.000 0.000
#> SRR1223562 2 0.4235 0.689 0.000 0.576 0.000 0.000 0.424
#> SRR1223563 2 0.0510 0.811 0.000 0.984 0.016 0.000 0.000
#> SRR1223564 2 0.4235 0.689 0.000 0.576 0.000 0.000 0.424
#> SRR1223565 2 0.4465 0.741 0.000 0.672 0.024 0.000 0.304
#> SRR1223566 1 0.0162 0.830 0.996 0.000 0.000 0.004 0.000
#> SRR1223567 1 0.4410 0.574 0.556 0.000 0.000 0.004 0.440
#> SRR1223568 1 0.1341 0.819 0.944 0.000 0.000 0.056 0.000
#> SRR1223569 1 0.4696 0.573 0.556 0.000 0.000 0.016 0.428
#> SRR1223570 1 0.0798 0.829 0.976 0.000 0.000 0.008 0.016
#> SRR1223571 2 0.1205 0.809 0.000 0.956 0.040 0.004 0.000
#> SRR1223572 4 0.4978 0.926 0.000 0.140 0.068 0.752 0.040
#> SRR1223573 2 0.1205 0.809 0.000 0.956 0.040 0.004 0.000
#> SRR1223574 4 0.5710 0.901 0.000 0.140 0.068 0.704 0.088
#> SRR1223575 4 0.3354 0.947 0.000 0.140 0.004 0.832 0.024
#> SRR1223576 1 0.0162 0.830 0.996 0.000 0.000 0.004 0.000
#> SRR1223577 3 0.2773 0.990 0.164 0.000 0.836 0.000 0.000
#> SRR1223578 1 0.0162 0.830 0.996 0.000 0.000 0.004 0.000
#> SRR1223579 3 0.2773 0.990 0.164 0.000 0.836 0.000 0.000
#> SRR1223580 1 0.4317 0.738 0.764 0.000 0.000 0.076 0.160
#> SRR1223581 2 0.0000 0.812 0.000 1.000 0.000 0.000 0.000
#> SRR1223582 2 0.4088 0.725 0.000 0.632 0.000 0.000 0.368
#> SRR1223583 2 0.0510 0.811 0.000 0.984 0.016 0.000 0.000
#> SRR1223584 2 0.4238 0.724 0.000 0.628 0.004 0.000 0.368
#> SRR1223585 2 0.4382 0.745 0.000 0.688 0.024 0.000 0.288
#> SRR1223586 1 0.0000 0.830 1.000 0.000 0.000 0.000 0.000
#> SRR1223587 1 0.4268 0.574 0.556 0.000 0.000 0.000 0.444
#> SRR1223588 1 0.1270 0.820 0.948 0.000 0.000 0.052 0.000
#> SRR1223589 1 0.4610 0.573 0.556 0.000 0.000 0.012 0.432
#> SRR1223590 1 0.0671 0.829 0.980 0.000 0.000 0.004 0.016
#> SRR1223591 2 0.1205 0.809 0.000 0.956 0.040 0.004 0.000
#> SRR1223592 4 0.3011 0.950 0.000 0.140 0.016 0.844 0.000
#> SRR1223593 2 0.1205 0.809 0.000 0.956 0.040 0.004 0.000
#> SRR1223594 4 0.3011 0.950 0.000 0.140 0.016 0.844 0.000
#> SRR1223595 4 0.3477 0.946 0.000 0.140 0.008 0.828 0.024
#> SRR1223596 1 0.0000 0.830 1.000 0.000 0.000 0.000 0.000
#> SRR1223597 3 0.3320 0.987 0.164 0.000 0.820 0.004 0.012
#> SRR1223598 1 0.0000 0.830 1.000 0.000 0.000 0.000 0.000
#> SRR1223599 3 0.3320 0.987 0.164 0.000 0.820 0.004 0.012
#> SRR1223600 1 0.4317 0.738 0.764 0.000 0.000 0.076 0.160
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.0260 0.781 0.000 0.992 0.000 0.000 NA 0.000
#> SRR1223542 6 0.4172 0.942 0.000 0.424 0.004 0.008 NA 0.564
#> SRR1223543 2 0.1151 0.767 0.000 0.956 0.012 0.000 NA 0.000
#> SRR1223544 6 0.3817 0.940 0.000 0.432 0.000 0.000 NA 0.568
#> SRR1223545 2 0.5369 -0.449 0.000 0.572 0.028 0.000 NA 0.336
#> SRR1223546 1 0.0000 0.771 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223547 1 0.6084 0.515 0.436 0.000 0.000 0.008 NA 0.200
#> SRR1223548 1 0.2924 0.750 0.868 0.000 0.000 0.040 NA 0.068
#> SRR1223549 1 0.5983 0.511 0.432 0.000 0.000 0.000 NA 0.244
#> SRR1223550 1 0.2101 0.764 0.912 0.000 0.000 0.028 NA 0.008
#> SRR1223551 2 0.1647 0.780 0.000 0.940 0.016 0.008 NA 0.004
#> SRR1223552 4 0.2555 0.885 0.000 0.096 0.000 0.876 NA 0.008
#> SRR1223553 2 0.1624 0.780 0.000 0.936 0.020 0.000 NA 0.004
#> SRR1223554 4 0.5756 0.796 0.000 0.096 0.000 0.608 NA 0.056
#> SRR1223555 4 0.3798 0.880 0.000 0.096 0.024 0.816 NA 0.056
#> SRR1223556 1 0.0000 0.771 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223557 3 0.3560 0.952 0.084 0.000 0.836 0.012 NA 0.044
#> SRR1223558 1 0.0000 0.771 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223559 3 0.3560 0.952 0.084 0.000 0.836 0.012 NA 0.044
#> SRR1223560 1 0.3810 0.613 0.572 0.000 0.000 0.000 NA 0.000
#> SRR1223561 2 0.0260 0.781 0.000 0.992 0.000 0.000 NA 0.000
#> SRR1223562 6 0.4172 0.942 0.000 0.424 0.004 0.008 NA 0.564
#> SRR1223563 2 0.1151 0.767 0.000 0.956 0.012 0.000 NA 0.000
#> SRR1223564 6 0.4039 0.941 0.000 0.424 0.000 0.008 NA 0.568
#> SRR1223565 2 0.5369 -0.449 0.000 0.572 0.028 0.000 NA 0.336
#> SRR1223566 1 0.0000 0.771 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223567 1 0.6151 0.515 0.436 0.000 0.000 0.012 NA 0.196
#> SRR1223568 1 0.2924 0.750 0.868 0.000 0.000 0.040 NA 0.068
#> SRR1223569 1 0.6089 0.510 0.432 0.000 0.000 0.004 NA 0.236
#> SRR1223570 1 0.2101 0.764 0.912 0.000 0.000 0.028 NA 0.008
#> SRR1223571 2 0.1647 0.780 0.000 0.940 0.016 0.008 NA 0.004
#> SRR1223572 4 0.4992 0.834 0.000 0.096 0.000 0.676 NA 0.020
#> SRR1223573 2 0.1647 0.780 0.000 0.940 0.016 0.008 NA 0.004
#> SRR1223574 4 0.5777 0.794 0.000 0.096 0.000 0.604 NA 0.056
#> SRR1223575 4 0.3798 0.880 0.000 0.096 0.024 0.816 NA 0.056
#> SRR1223576 1 0.0146 0.771 0.996 0.000 0.000 0.004 NA 0.000
#> SRR1223577 3 0.1610 0.971 0.084 0.000 0.916 0.000 NA 0.000
#> SRR1223578 1 0.0146 0.771 0.996 0.000 0.000 0.004 NA 0.000
#> SRR1223579 3 0.1610 0.971 0.084 0.000 0.916 0.000 NA 0.000
#> SRR1223580 1 0.3810 0.613 0.572 0.000 0.000 0.000 NA 0.000
#> SRR1223581 2 0.0260 0.781 0.000 0.992 0.000 0.000 NA 0.000
#> SRR1223582 6 0.3997 0.886 0.000 0.488 0.004 0.000 NA 0.508
#> SRR1223583 2 0.1151 0.767 0.000 0.956 0.012 0.000 NA 0.000
#> SRR1223584 6 0.3867 0.886 0.000 0.488 0.000 0.000 NA 0.512
#> SRR1223585 2 0.5240 -0.375 0.000 0.600 0.028 0.000 NA 0.312
#> SRR1223586 1 0.0000 0.771 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223587 1 0.6084 0.515 0.436 0.000 0.000 0.008 NA 0.200
#> SRR1223588 1 0.2924 0.750 0.868 0.000 0.000 0.040 NA 0.068
#> SRR1223589 1 0.5983 0.511 0.432 0.000 0.000 0.000 NA 0.244
#> SRR1223590 1 0.2101 0.764 0.912 0.000 0.000 0.028 NA 0.008
#> SRR1223591 2 0.1647 0.780 0.000 0.940 0.016 0.008 NA 0.004
#> SRR1223592 4 0.2791 0.883 0.000 0.096 0.000 0.864 NA 0.008
#> SRR1223593 2 0.1647 0.780 0.000 0.940 0.016 0.008 NA 0.004
#> SRR1223594 4 0.2791 0.883 0.000 0.096 0.000 0.864 NA 0.008
#> SRR1223595 4 0.3798 0.880 0.000 0.096 0.024 0.816 NA 0.056
#> SRR1223596 1 0.0146 0.771 0.996 0.000 0.000 0.004 NA 0.000
#> SRR1223597 3 0.2402 0.967 0.084 0.000 0.888 0.008 NA 0.020
#> SRR1223598 1 0.0146 0.771 0.996 0.000 0.000 0.004 NA 0.000
#> SRR1223599 3 0.2402 0.967 0.084 0.000 0.888 0.008 NA 0.020
#> SRR1223600 1 0.3810 0.613 0.572 0.000 0.000 0.000 NA 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.5090 0.492 0.492
#> 3 3 0.812 0.958 0.950 0.1696 0.919 0.834
#> 4 4 1.000 0.998 0.996 0.1697 0.893 0.740
#> 5 5 0.856 0.869 0.904 0.0662 1.000 1.000
#> 6 6 0.828 0.826 0.855 0.0566 0.873 0.592
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
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223542 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223543 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223544 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223545 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223546 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223547 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223548 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223549 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223550 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223551 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223552 2 0.455 0.854 0.0 0.8 0.2
#> SRR1223553 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223554 2 0.455 0.854 0.0 0.8 0.2
#> SRR1223555 2 0.455 0.854 0.0 0.8 0.2
#> SRR1223556 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223557 3 0.455 1.000 0.2 0.0 0.8
#> SRR1223558 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223559 3 0.455 1.000 0.2 0.0 0.8
#> SRR1223560 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223561 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223562 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223563 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223564 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223565 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223566 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223567 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223568 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223569 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223570 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223571 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223572 2 0.455 0.854 0.0 0.8 0.2
#> SRR1223573 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223574 2 0.455 0.854 0.0 0.8 0.2
#> SRR1223575 2 0.455 0.854 0.0 0.8 0.2
#> SRR1223576 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223577 3 0.455 1.000 0.2 0.0 0.8
#> SRR1223578 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223579 3 0.455 1.000 0.2 0.0 0.8
#> SRR1223580 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223581 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223582 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223583 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223584 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223585 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223586 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223587 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223588 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223589 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223590 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223591 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223592 2 0.455 0.854 0.0 0.8 0.2
#> SRR1223593 2 0.000 0.941 0.0 1.0 0.0
#> SRR1223594 2 0.455 0.854 0.0 0.8 0.2
#> SRR1223595 2 0.455 0.854 0.0 0.8 0.2
#> SRR1223596 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223597 3 0.455 1.000 0.2 0.0 0.8
#> SRR1223598 1 0.000 1.000 1.0 0.0 0.0
#> SRR1223599 3 0.455 1.000 0.2 0.0 0.8
#> SRR1223600 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
#> SRR1223541 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223542 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223543 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223544 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223545 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223546 1 0.0000 0.996 1.000 0.000 0 0.000
#> SRR1223547 1 0.0592 0.990 0.984 0.000 0 0.016
#> SRR1223548 1 0.0000 0.996 1.000 0.000 0 0.000
#> SRR1223549 1 0.0592 0.990 0.984 0.000 0 0.016
#> SRR1223550 1 0.0000 0.996 1.000 0.000 0 0.000
#> SRR1223551 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223552 4 0.0592 1.000 0.000 0.016 0 0.984
#> SRR1223553 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223554 4 0.0592 1.000 0.000 0.016 0 0.984
#> SRR1223555 4 0.0592 1.000 0.000 0.016 0 0.984
#> SRR1223556 1 0.0000 0.996 1.000 0.000 0 0.000
#> SRR1223557 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR1223558 1 0.0000 0.996 1.000 0.000 0 0.000
#> SRR1223559 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR1223560 1 0.0336 0.993 0.992 0.000 0 0.008
#> SRR1223561 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223562 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223563 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223564 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223565 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223566 1 0.0000 0.996 1.000 0.000 0 0.000
#> SRR1223567 1 0.0592 0.990 0.984 0.000 0 0.016
#> SRR1223568 1 0.0000 0.996 1.000 0.000 0 0.000
#> SRR1223569 1 0.0592 0.990 0.984 0.000 0 0.016
#> SRR1223570 1 0.0000 0.996 1.000 0.000 0 0.000
#> SRR1223571 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223572 4 0.0592 1.000 0.000 0.016 0 0.984
#> SRR1223573 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223574 4 0.0592 1.000 0.000 0.016 0 0.984
#> SRR1223575 4 0.0592 1.000 0.000 0.016 0 0.984
#> SRR1223576 1 0.0000 0.996 1.000 0.000 0 0.000
#> SRR1223577 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR1223578 1 0.0000 0.996 1.000 0.000 0 0.000
#> SRR1223579 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR1223580 1 0.0336 0.993 0.992 0.000 0 0.008
#> SRR1223581 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223582 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223583 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223584 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223585 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223586 1 0.0000 0.996 1.000 0.000 0 0.000
#> SRR1223587 1 0.0592 0.990 0.984 0.000 0 0.016
#> SRR1223588 1 0.0000 0.996 1.000 0.000 0 0.000
#> SRR1223589 1 0.0592 0.990 0.984 0.000 0 0.016
#> SRR1223590 1 0.0000 0.996 1.000 0.000 0 0.000
#> SRR1223591 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223592 4 0.0592 1.000 0.000 0.016 0 0.984
#> SRR1223593 2 0.0000 1.000 0.000 1.000 0 0.000
#> SRR1223594 4 0.0592 1.000 0.000 0.016 0 0.984
#> SRR1223595 4 0.0592 1.000 0.000 0.016 0 0.984
#> SRR1223596 1 0.0000 0.996 1.000 0.000 0 0.000
#> SRR1223597 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR1223598 1 0.0000 0.996 1.000 0.000 0 0.000
#> SRR1223599 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR1223600 1 0.0336 0.993 0.992 0.000 0 0.008
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.000 0.876 0.000 1.000 0 0.000 NA
#> SRR1223542 2 0.407 0.759 0.000 0.636 0 0.000 NA
#> SRR1223543 2 0.000 0.876 0.000 1.000 0 0.000 NA
#> SRR1223544 2 0.407 0.759 0.000 0.636 0 0.000 NA
#> SRR1223545 2 0.304 0.834 0.000 0.808 0 0.000 NA
#> SRR1223546 1 0.000 0.907 1.000 0.000 0 0.000 NA
#> SRR1223547 1 0.406 0.703 0.640 0.000 0 0.000 NA
#> SRR1223548 1 0.000 0.907 1.000 0.000 0 0.000 NA
#> SRR1223549 1 0.406 0.703 0.640 0.000 0 0.000 NA
#> SRR1223550 1 0.000 0.907 1.000 0.000 0 0.000 NA
#> SRR1223551 2 0.000 0.876 0.000 1.000 0 0.000 NA
#> SRR1223552 4 0.000 0.931 0.000 0.000 0 1.000 NA
#> SRR1223553 2 0.000 0.876 0.000 1.000 0 0.000 NA
#> SRR1223554 4 0.366 0.818 0.000 0.000 0 0.724 NA
#> SRR1223555 4 0.000 0.931 0.000 0.000 0 1.000 NA
#> SRR1223556 1 0.000 0.907 1.000 0.000 0 0.000 NA
#> SRR1223557 3 0.000 1.000 0.000 0.000 1 0.000 NA
#> SRR1223558 1 0.000 0.907 1.000 0.000 0 0.000 NA
#> SRR1223559 3 0.000 1.000 0.000 0.000 1 0.000 NA
#> SRR1223560 1 0.120 0.891 0.952 0.000 0 0.000 NA
#> SRR1223561 2 0.000 0.876 0.000 1.000 0 0.000 NA
#> SRR1223562 2 0.407 0.759 0.000 0.636 0 0.000 NA
#> SRR1223563 2 0.000 0.876 0.000 1.000 0 0.000 NA
#> SRR1223564 2 0.407 0.759 0.000 0.636 0 0.000 NA
#> SRR1223565 2 0.304 0.834 0.000 0.808 0 0.000 NA
#> SRR1223566 1 0.000 0.907 1.000 0.000 0 0.000 NA
#> SRR1223567 1 0.406 0.703 0.640 0.000 0 0.000 NA
#> SRR1223568 1 0.000 0.907 1.000 0.000 0 0.000 NA
#> SRR1223569 1 0.406 0.703 0.640 0.000 0 0.000 NA
#> SRR1223570 1 0.000 0.907 1.000 0.000 0 0.000 NA
#> SRR1223571 2 0.000 0.876 0.000 1.000 0 0.000 NA
#> SRR1223572 4 0.273 0.875 0.000 0.000 0 0.840 NA
#> SRR1223573 2 0.000 0.876 0.000 1.000 0 0.000 NA
#> SRR1223574 4 0.366 0.818 0.000 0.000 0 0.724 NA
#> SRR1223575 4 0.000 0.931 0.000 0.000 0 1.000 NA
#> SRR1223576 1 0.000 0.907 1.000 0.000 0 0.000 NA
#> SRR1223577 3 0.000 1.000 0.000 0.000 1 0.000 NA
#> SRR1223578 1 0.000 0.907 1.000 0.000 0 0.000 NA
#> SRR1223579 3 0.000 1.000 0.000 0.000 1 0.000 NA
#> SRR1223580 1 0.120 0.891 0.952 0.000 0 0.000 NA
#> SRR1223581 2 0.000 0.876 0.000 1.000 0 0.000 NA
#> SRR1223582 2 0.406 0.761 0.000 0.640 0 0.000 NA
#> SRR1223583 2 0.000 0.876 0.000 1.000 0 0.000 NA
#> SRR1223584 2 0.406 0.761 0.000 0.640 0 0.000 NA
#> SRR1223585 2 0.293 0.837 0.000 0.820 0 0.000 NA
#> SRR1223586 1 0.000 0.907 1.000 0.000 0 0.000 NA
#> SRR1223587 1 0.406 0.703 0.640 0.000 0 0.000 NA
#> SRR1223588 1 0.000 0.907 1.000 0.000 0 0.000 NA
#> SRR1223589 1 0.406 0.703 0.640 0.000 0 0.000 NA
#> SRR1223590 1 0.000 0.907 1.000 0.000 0 0.000 NA
#> SRR1223591 2 0.000 0.876 0.000 1.000 0 0.000 NA
#> SRR1223592 4 0.000 0.931 0.000 0.000 0 1.000 NA
#> SRR1223593 2 0.000 0.876 0.000 1.000 0 0.000 NA
#> SRR1223594 4 0.000 0.931 0.000 0.000 0 1.000 NA
#> SRR1223595 4 0.000 0.931 0.000 0.000 0 1.000 NA
#> SRR1223596 1 0.000 0.907 1.000 0.000 0 0.000 NA
#> SRR1223597 3 0.000 1.000 0.000 0.000 1 0.000 NA
#> SRR1223598 1 0.000 0.907 1.000 0.000 0 0.000 NA
#> SRR1223599 3 0.000 1.000 0.000 0.000 1 0.000 NA
#> SRR1223600 1 0.120 0.891 0.952 0.000 0 0.000 NA
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223542 6 0.5942 0.680 0.000 0.220 0 0.000 0.356 0.424
#> SRR1223543 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223544 6 0.5942 0.680 0.000 0.220 0 0.000 0.356 0.424
#> SRR1223545 2 0.4952 0.393 0.000 0.632 0 0.000 0.252 0.116
#> SRR1223546 1 0.0000 0.950 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223547 5 0.3774 1.000 0.408 0.000 0 0.000 0.592 0.000
#> SRR1223548 1 0.0000 0.950 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223549 5 0.3774 1.000 0.408 0.000 0 0.000 0.592 0.000
#> SRR1223550 1 0.0000 0.950 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223551 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223552 4 0.0000 0.920 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223553 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223554 6 0.3789 -0.482 0.000 0.000 0 0.416 0.000 0.584
#> SRR1223555 4 0.0937 0.919 0.000 0.000 0 0.960 0.040 0.000
#> SRR1223556 1 0.0000 0.950 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223558 1 0.0000 0.950 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223559 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223560 1 0.2416 0.683 0.844 0.000 0 0.000 0.156 0.000
#> SRR1223561 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223562 6 0.5942 0.680 0.000 0.220 0 0.000 0.356 0.424
#> SRR1223563 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223564 6 0.5942 0.680 0.000 0.220 0 0.000 0.356 0.424
#> SRR1223565 2 0.4952 0.393 0.000 0.632 0 0.000 0.252 0.116
#> SRR1223566 1 0.0000 0.950 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223567 5 0.3774 1.000 0.408 0.000 0 0.000 0.592 0.000
#> SRR1223568 1 0.0000 0.950 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223569 5 0.3774 1.000 0.408 0.000 0 0.000 0.592 0.000
#> SRR1223570 1 0.0000 0.950 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223571 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223572 4 0.3774 0.542 0.000 0.000 0 0.592 0.000 0.408
#> SRR1223573 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223574 6 0.3782 -0.479 0.000 0.000 0 0.412 0.000 0.588
#> SRR1223575 4 0.0937 0.919 0.000 0.000 0 0.960 0.040 0.000
#> SRR1223576 1 0.0000 0.950 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223578 1 0.0000 0.950 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223579 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223580 1 0.2454 0.673 0.840 0.000 0 0.000 0.160 0.000
#> SRR1223581 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223582 6 0.6001 0.663 0.000 0.240 0 0.000 0.348 0.412
#> SRR1223583 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223584 6 0.6001 0.663 0.000 0.240 0 0.000 0.348 0.412
#> SRR1223585 2 0.4526 0.484 0.000 0.676 0 0.000 0.244 0.080
#> SRR1223586 1 0.0000 0.950 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223587 5 0.3774 1.000 0.408 0.000 0 0.000 0.592 0.000
#> SRR1223588 1 0.0000 0.950 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223589 5 0.3774 1.000 0.408 0.000 0 0.000 0.592 0.000
#> SRR1223590 1 0.0000 0.950 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223591 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223592 4 0.0000 0.920 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223593 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223594 4 0.0000 0.920 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223595 4 0.0937 0.919 0.000 0.000 0 0.960 0.040 0.000
#> SRR1223596 1 0.0000 0.950 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223598 1 0.0000 0.950 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223599 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223600 1 0.2454 0.673 0.840 0.000 0 0.000 0.160 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "pam"]
# you can also extract it by
# res = res_list["SD:pam"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.5090 0.492 0.492
#> 3 3 1.000 1.000 1.000 0.1597 0.919 0.834
#> 4 4 1.000 0.988 0.994 0.1899 0.887 0.725
#> 5 5 1.000 0.951 0.983 0.0692 0.944 0.814
#> 6 6 0.897 0.894 0.930 0.0737 0.933 0.729
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 2 3 4
There is also optional best \(k\) = 2 3 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0 1 0 1 0
#> SRR1223542 2 0 1 0 1 0
#> SRR1223543 2 0 1 0 1 0
#> SRR1223544 2 0 1 0 1 0
#> SRR1223545 2 0 1 0 1 0
#> SRR1223546 1 0 1 1 0 0
#> SRR1223547 1 0 1 1 0 0
#> SRR1223548 1 0 1 1 0 0
#> SRR1223549 1 0 1 1 0 0
#> SRR1223550 1 0 1 1 0 0
#> SRR1223551 2 0 1 0 1 0
#> SRR1223552 2 0 1 0 1 0
#> SRR1223553 2 0 1 0 1 0
#> SRR1223554 2 0 1 0 1 0
#> SRR1223555 2 0 1 0 1 0
#> SRR1223556 1 0 1 1 0 0
#> SRR1223557 3 0 1 0 0 1
#> SRR1223558 1 0 1 1 0 0
#> SRR1223559 3 0 1 0 0 1
#> SRR1223560 1 0 1 1 0 0
#> SRR1223561 2 0 1 0 1 0
#> SRR1223562 2 0 1 0 1 0
#> SRR1223563 2 0 1 0 1 0
#> SRR1223564 2 0 1 0 1 0
#> SRR1223565 2 0 1 0 1 0
#> SRR1223566 1 0 1 1 0 0
#> SRR1223567 1 0 1 1 0 0
#> SRR1223568 1 0 1 1 0 0
#> SRR1223569 1 0 1 1 0 0
#> SRR1223570 1 0 1 1 0 0
#> SRR1223571 2 0 1 0 1 0
#> SRR1223572 2 0 1 0 1 0
#> SRR1223573 2 0 1 0 1 0
#> SRR1223574 2 0 1 0 1 0
#> SRR1223575 2 0 1 0 1 0
#> SRR1223576 1 0 1 1 0 0
#> SRR1223577 3 0 1 0 0 1
#> SRR1223578 1 0 1 1 0 0
#> SRR1223579 3 0 1 0 0 1
#> SRR1223580 1 0 1 1 0 0
#> SRR1223581 2 0 1 0 1 0
#> SRR1223582 2 0 1 0 1 0
#> SRR1223583 2 0 1 0 1 0
#> SRR1223584 2 0 1 0 1 0
#> SRR1223585 2 0 1 0 1 0
#> SRR1223586 1 0 1 1 0 0
#> SRR1223587 1 0 1 1 0 0
#> SRR1223588 1 0 1 1 0 0
#> SRR1223589 1 0 1 1 0 0
#> SRR1223590 1 0 1 1 0 0
#> SRR1223591 2 0 1 0 1 0
#> SRR1223592 2 0 1 0 1 0
#> SRR1223593 2 0 1 0 1 0
#> SRR1223594 2 0 1 0 1 0
#> SRR1223595 2 0 1 0 1 0
#> SRR1223596 1 0 1 1 0 0
#> SRR1223597 3 0 1 0 0 1
#> SRR1223598 1 0 1 1 0 0
#> SRR1223599 3 0 1 0 0 1
#> SRR1223600 1 0 1 1 0 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.0000 0.994 0 1.000 0 0.000
#> SRR1223542 2 0.0592 0.988 0 0.984 0 0.016
#> SRR1223543 2 0.0000 0.994 0 1.000 0 0.000
#> SRR1223544 2 0.0592 0.988 0 0.984 0 0.016
#> SRR1223545 2 0.0592 0.988 0 0.984 0 0.016
#> SRR1223546 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223547 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223548 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223549 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223550 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223551 2 0.0000 0.994 0 1.000 0 0.000
#> SRR1223552 4 0.0469 0.966 0 0.012 0 0.988
#> SRR1223553 2 0.0000 0.994 0 1.000 0 0.000
#> SRR1223554 4 0.0000 0.964 0 0.000 0 1.000
#> SRR1223555 4 0.0592 0.966 0 0.016 0 0.984
#> SRR1223556 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223557 3 0.0000 1.000 0 0.000 1 0.000
#> SRR1223558 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223559 3 0.0000 1.000 0 0.000 1 0.000
#> SRR1223560 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223561 2 0.0000 0.994 0 1.000 0 0.000
#> SRR1223562 4 0.3123 0.771 0 0.156 0 0.844
#> SRR1223563 2 0.0000 0.994 0 1.000 0 0.000
#> SRR1223564 2 0.0592 0.988 0 0.984 0 0.016
#> SRR1223565 2 0.0592 0.988 0 0.984 0 0.016
#> SRR1223566 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223567 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223568 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223569 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223570 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223571 2 0.0000 0.994 0 1.000 0 0.000
#> SRR1223572 4 0.0000 0.964 0 0.000 0 1.000
#> SRR1223573 2 0.0000 0.994 0 1.000 0 0.000
#> SRR1223574 4 0.0000 0.964 0 0.000 0 1.000
#> SRR1223575 4 0.0000 0.964 0 0.000 0 1.000
#> SRR1223576 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223577 3 0.0000 1.000 0 0.000 1 0.000
#> SRR1223578 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223579 3 0.0000 1.000 0 0.000 1 0.000
#> SRR1223580 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223581 2 0.0000 0.994 0 1.000 0 0.000
#> SRR1223582 2 0.0592 0.988 0 0.984 0 0.016
#> SRR1223583 2 0.0000 0.994 0 1.000 0 0.000
#> SRR1223584 2 0.0592 0.988 0 0.984 0 0.016
#> SRR1223585 2 0.0000 0.994 0 1.000 0 0.000
#> SRR1223586 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223587 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223588 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223589 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223590 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223591 2 0.0000 0.994 0 1.000 0 0.000
#> SRR1223592 4 0.0592 0.966 0 0.016 0 0.984
#> SRR1223593 2 0.0000 0.994 0 1.000 0 0.000
#> SRR1223594 4 0.0592 0.966 0 0.016 0 0.984
#> SRR1223595 4 0.0592 0.966 0 0.016 0 0.984
#> SRR1223596 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223597 3 0.0000 1.000 0 0.000 1 0.000
#> SRR1223598 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223599 3 0.0000 1.000 0 0.000 1 0.000
#> SRR1223600 1 0.0000 1.000 1 0.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.0000 0.973 0 1.000 0 0.000 0.000
#> SRR1223542 5 0.0000 0.880 0 0.000 0 0.000 1.000
#> SRR1223543 2 0.0000 0.973 0 1.000 0 0.000 0.000
#> SRR1223544 5 0.0000 0.880 0 0.000 0 0.000 1.000
#> SRR1223545 2 0.3837 0.491 0 0.692 0 0.000 0.308
#> SRR1223546 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223547 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223548 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223549 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223550 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223551 2 0.0000 0.973 0 1.000 0 0.000 0.000
#> SRR1223552 4 0.0000 0.975 0 0.000 0 1.000 0.000
#> SRR1223553 2 0.0000 0.973 0 1.000 0 0.000 0.000
#> SRR1223554 4 0.0000 0.975 0 0.000 0 1.000 0.000
#> SRR1223555 4 0.0000 0.975 0 0.000 0 1.000 0.000
#> SRR1223556 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR1223558 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223559 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR1223560 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223561 2 0.0000 0.973 0 1.000 0 0.000 0.000
#> SRR1223562 5 0.0000 0.880 0 0.000 0 0.000 1.000
#> SRR1223563 2 0.0000 0.973 0 1.000 0 0.000 0.000
#> SRR1223564 5 0.0000 0.880 0 0.000 0 0.000 1.000
#> SRR1223565 5 0.4278 0.132 0 0.452 0 0.000 0.548
#> SRR1223566 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223567 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223568 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223569 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223570 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223571 2 0.0000 0.973 0 1.000 0 0.000 0.000
#> SRR1223572 4 0.0000 0.975 0 0.000 0 1.000 0.000
#> SRR1223573 2 0.0000 0.973 0 1.000 0 0.000 0.000
#> SRR1223574 4 0.3039 0.758 0 0.000 0 0.808 0.192
#> SRR1223575 4 0.0000 0.975 0 0.000 0 1.000 0.000
#> SRR1223576 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR1223578 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223579 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR1223580 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223581 2 0.0000 0.973 0 1.000 0 0.000 0.000
#> SRR1223582 5 0.1908 0.811 0 0.092 0 0.000 0.908
#> SRR1223583 2 0.0000 0.973 0 1.000 0 0.000 0.000
#> SRR1223584 5 0.0162 0.879 0 0.004 0 0.000 0.996
#> SRR1223585 2 0.0000 0.973 0 1.000 0 0.000 0.000
#> SRR1223586 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223587 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223588 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223589 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223590 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223591 2 0.0000 0.973 0 1.000 0 0.000 0.000
#> SRR1223592 4 0.0000 0.975 0 0.000 0 1.000 0.000
#> SRR1223593 2 0.0000 0.973 0 1.000 0 0.000 0.000
#> SRR1223594 4 0.0000 0.975 0 0.000 0 1.000 0.000
#> SRR1223595 4 0.0000 0.975 0 0.000 0 1.000 0.000
#> SRR1223596 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR1223598 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223599 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR1223600 1 0.0000 1.000 1 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
#> SRR1223541 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223542 6 0.0000 0.885 0.000 0.000 0 0.000 0.000 1.000
#> SRR1223543 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223544 6 0.0000 0.885 0.000 0.000 0 0.000 0.000 1.000
#> SRR1223545 2 0.3499 0.464 0.000 0.680 0 0.000 0.000 0.320
#> SRR1223546 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223547 5 0.2969 0.936 0.224 0.000 0 0.000 0.776 0.000
#> SRR1223548 1 0.3126 0.512 0.752 0.000 0 0.000 0.248 0.000
#> SRR1223549 5 0.2969 0.936 0.224 0.000 0 0.000 0.776 0.000
#> SRR1223550 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223551 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223552 4 0.0000 0.913 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223553 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223554 4 0.0000 0.913 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223555 4 0.2969 0.868 0.000 0.000 0 0.776 0.224 0.000
#> SRR1223556 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223558 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223559 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223560 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223561 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223562 6 0.0000 0.885 0.000 0.000 0 0.000 0.000 1.000
#> SRR1223563 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223564 6 0.0000 0.885 0.000 0.000 0 0.000 0.000 1.000
#> SRR1223565 6 0.3843 0.128 0.000 0.452 0 0.000 0.000 0.548
#> SRR1223566 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223567 5 0.2969 0.936 0.224 0.000 0 0.000 0.776 0.000
#> SRR1223568 1 0.3515 0.262 0.676 0.000 0 0.000 0.324 0.000
#> SRR1223569 5 0.2969 0.936 0.224 0.000 0 0.000 0.776 0.000
#> SRR1223570 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223571 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223572 4 0.0000 0.913 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223573 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223574 4 0.3408 0.809 0.000 0.000 0 0.800 0.048 0.152
#> SRR1223575 4 0.2969 0.868 0.000 0.000 0 0.776 0.224 0.000
#> SRR1223576 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223578 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223579 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223580 5 0.3634 0.810 0.356 0.000 0 0.000 0.644 0.000
#> SRR1223581 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223582 6 0.1444 0.831 0.000 0.072 0 0.000 0.000 0.928
#> SRR1223583 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223584 6 0.0146 0.884 0.000 0.004 0 0.000 0.000 0.996
#> SRR1223585 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223586 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223587 5 0.3634 0.810 0.356 0.000 0 0.000 0.644 0.000
#> SRR1223588 1 0.0458 0.930 0.984 0.000 0 0.000 0.016 0.000
#> SRR1223589 5 0.2969 0.936 0.224 0.000 0 0.000 0.776 0.000
#> SRR1223590 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223591 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223592 4 0.0000 0.913 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223593 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223594 4 0.0000 0.913 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223595 4 0.2969 0.868 0.000 0.000 0 0.776 0.224 0.000
#> SRR1223596 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223598 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223599 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223600 1 0.0865 0.907 0.964 0.000 0 0.000 0.036 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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.5090 0.492 0.492
#> 3 3 0.799 0.837 0.917 0.2252 0.893 0.783
#> 4 4 0.831 0.831 0.868 0.1030 0.911 0.770
#> 5 5 0.727 0.619 0.747 0.0740 0.947 0.827
#> 6 6 0.800 0.756 0.861 0.0961 0.896 0.630
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
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.6140 0.834 0.000 0.596 0.404
#> SRR1223542 2 0.0000 0.467 0.000 1.000 0.000
#> SRR1223543 2 0.6140 0.834 0.000 0.596 0.404
#> SRR1223544 2 0.0237 0.471 0.000 0.996 0.004
#> SRR1223545 2 0.6140 0.834 0.000 0.596 0.404
#> SRR1223546 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223547 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223548 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223549 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223550 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223551 2 0.6140 0.834 0.000 0.596 0.404
#> SRR1223552 3 0.5968 0.782 0.000 0.364 0.636
#> SRR1223553 2 0.6140 0.834 0.000 0.596 0.404
#> SRR1223554 3 0.6252 0.750 0.000 0.444 0.556
#> SRR1223555 3 0.1529 0.516 0.000 0.040 0.960
#> SRR1223556 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223557 1 0.3412 0.889 0.876 0.000 0.124
#> SRR1223558 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223559 1 0.3412 0.889 0.876 0.000 0.124
#> SRR1223560 1 0.0237 0.972 0.996 0.000 0.004
#> SRR1223561 2 0.6140 0.834 0.000 0.596 0.404
#> SRR1223562 2 0.0000 0.467 0.000 1.000 0.000
#> SRR1223563 2 0.6140 0.834 0.000 0.596 0.404
#> SRR1223564 2 0.0000 0.467 0.000 1.000 0.000
#> SRR1223565 2 0.6140 0.834 0.000 0.596 0.404
#> SRR1223566 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223567 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223568 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223569 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223570 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223571 2 0.6140 0.834 0.000 0.596 0.404
#> SRR1223572 3 0.6215 0.761 0.000 0.428 0.572
#> SRR1223573 2 0.6140 0.834 0.000 0.596 0.404
#> SRR1223574 3 0.6252 0.750 0.000 0.444 0.556
#> SRR1223575 3 0.1163 0.524 0.000 0.028 0.972
#> SRR1223576 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223577 1 0.3412 0.889 0.876 0.000 0.124
#> SRR1223578 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223579 1 0.3412 0.889 0.876 0.000 0.124
#> SRR1223580 1 0.0237 0.972 0.996 0.000 0.004
#> SRR1223581 2 0.6140 0.834 0.000 0.596 0.404
#> SRR1223582 2 0.0424 0.475 0.000 0.992 0.008
#> SRR1223583 2 0.6140 0.834 0.000 0.596 0.404
#> SRR1223584 2 0.0424 0.475 0.000 0.992 0.008
#> SRR1223585 2 0.6140 0.834 0.000 0.596 0.404
#> SRR1223586 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223587 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223588 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223589 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223590 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223591 2 0.6140 0.834 0.000 0.596 0.404
#> SRR1223592 3 0.5968 0.782 0.000 0.364 0.636
#> SRR1223593 2 0.6140 0.834 0.000 0.596 0.404
#> SRR1223594 3 0.5968 0.782 0.000 0.364 0.636
#> SRR1223595 3 0.1529 0.516 0.000 0.040 0.960
#> SRR1223596 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223597 1 0.3412 0.889 0.876 0.000 0.124
#> SRR1223598 1 0.0000 0.974 1.000 0.000 0.000
#> SRR1223599 1 0.3412 0.889 0.876 0.000 0.124
#> SRR1223600 1 0.0237 0.972 0.996 0.000 0.004
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.0000 0.852 0.000 1.000 0.000 0.000
#> SRR1223542 2 0.4830 0.618 0.000 0.608 0.000 0.392
#> SRR1223543 2 0.0000 0.852 0.000 1.000 0.000 0.000
#> SRR1223544 2 0.4804 0.624 0.000 0.616 0.000 0.384
#> SRR1223545 2 0.0592 0.850 0.000 0.984 0.000 0.016
#> SRR1223546 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> SRR1223547 1 0.1474 0.964 0.948 0.000 0.000 0.052
#> SRR1223548 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> SRR1223549 1 0.1474 0.964 0.948 0.000 0.000 0.052
#> SRR1223550 1 0.1474 0.964 0.948 0.000 0.000 0.052
#> SRR1223551 2 0.1716 0.832 0.000 0.936 0.000 0.064
#> SRR1223552 4 0.6090 0.864 0.000 0.052 0.384 0.564
#> SRR1223553 2 0.1716 0.832 0.000 0.936 0.000 0.064
#> SRR1223554 4 0.3674 0.557 0.000 0.036 0.116 0.848
#> SRR1223555 4 0.6090 0.864 0.000 0.052 0.384 0.564
#> SRR1223556 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> SRR1223557 3 0.4746 0.814 0.368 0.000 0.632 0.000
#> SRR1223558 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> SRR1223559 3 0.4746 0.814 0.368 0.000 0.632 0.000
#> SRR1223560 1 0.1474 0.964 0.948 0.000 0.000 0.052
#> SRR1223561 2 0.0000 0.852 0.000 1.000 0.000 0.000
#> SRR1223562 2 0.4830 0.618 0.000 0.608 0.000 0.392
#> SRR1223563 2 0.0000 0.852 0.000 1.000 0.000 0.000
#> SRR1223564 2 0.4830 0.618 0.000 0.608 0.000 0.392
#> SRR1223565 2 0.0592 0.850 0.000 0.984 0.000 0.016
#> SRR1223566 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> SRR1223567 1 0.1474 0.964 0.948 0.000 0.000 0.052
#> SRR1223568 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> SRR1223569 1 0.1474 0.964 0.948 0.000 0.000 0.052
#> SRR1223570 1 0.1474 0.964 0.948 0.000 0.000 0.052
#> SRR1223571 2 0.1716 0.832 0.000 0.936 0.000 0.064
#> SRR1223572 3 0.6081 -0.818 0.000 0.044 0.484 0.472
#> SRR1223573 2 0.1716 0.832 0.000 0.936 0.000 0.064
#> SRR1223574 4 0.3674 0.557 0.000 0.036 0.116 0.848
#> SRR1223575 4 0.6090 0.864 0.000 0.052 0.384 0.564
#> SRR1223576 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> SRR1223577 3 0.4746 0.814 0.368 0.000 0.632 0.000
#> SRR1223578 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> SRR1223579 3 0.4746 0.814 0.368 0.000 0.632 0.000
#> SRR1223580 1 0.1474 0.964 0.948 0.000 0.000 0.052
#> SRR1223581 2 0.0000 0.852 0.000 1.000 0.000 0.000
#> SRR1223582 2 0.4776 0.631 0.000 0.624 0.000 0.376
#> SRR1223583 2 0.0000 0.852 0.000 1.000 0.000 0.000
#> SRR1223584 2 0.4776 0.631 0.000 0.624 0.000 0.376
#> SRR1223585 2 0.0336 0.851 0.000 0.992 0.000 0.008
#> SRR1223586 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> SRR1223587 1 0.1474 0.964 0.948 0.000 0.000 0.052
#> SRR1223588 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> SRR1223589 1 0.1474 0.964 0.948 0.000 0.000 0.052
#> SRR1223590 1 0.1474 0.964 0.948 0.000 0.000 0.052
#> SRR1223591 2 0.1716 0.832 0.000 0.936 0.000 0.064
#> SRR1223592 4 0.6090 0.864 0.000 0.052 0.384 0.564
#> SRR1223593 2 0.1716 0.832 0.000 0.936 0.000 0.064
#> SRR1223594 4 0.6090 0.864 0.000 0.052 0.384 0.564
#> SRR1223595 4 0.6090 0.864 0.000 0.052 0.384 0.564
#> SRR1223596 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> SRR1223597 3 0.4746 0.814 0.368 0.000 0.632 0.000
#> SRR1223598 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> SRR1223599 3 0.4746 0.814 0.368 0.000 0.632 0.000
#> SRR1223600 1 0.1474 0.964 0.948 0.000 0.000 0.052
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.4219 -0.591 0.000 0.584 0.000 0.000 0.416
#> SRR1223542 2 0.1168 0.484 0.000 0.960 0.000 0.032 0.008
#> SRR1223543 2 0.4182 -0.543 0.000 0.600 0.000 0.000 0.400
#> SRR1223544 2 0.1082 0.485 0.000 0.964 0.000 0.028 0.008
#> SRR1223545 2 0.3193 0.429 0.000 0.840 0.000 0.028 0.132
#> SRR1223546 1 0.3339 0.881 0.836 0.000 0.040 0.000 0.124
#> SRR1223547 1 0.2104 0.844 0.916 0.000 0.024 0.000 0.060
#> SRR1223548 1 0.3339 0.881 0.836 0.000 0.040 0.000 0.124
#> SRR1223549 1 0.2104 0.844 0.916 0.000 0.024 0.000 0.060
#> SRR1223550 1 0.0290 0.872 0.992 0.000 0.000 0.000 0.008
#> SRR1223551 5 0.4452 1.000 0.000 0.496 0.000 0.004 0.500
#> SRR1223552 4 0.3969 0.758 0.000 0.000 0.004 0.692 0.304
#> SRR1223553 2 0.4449 -0.941 0.000 0.512 0.000 0.004 0.484
#> SRR1223554 4 0.5492 0.361 0.000 0.004 0.340 0.588 0.068
#> SRR1223555 4 0.3816 0.759 0.000 0.000 0.000 0.696 0.304
#> SRR1223556 1 0.3339 0.881 0.836 0.000 0.040 0.000 0.124
#> SRR1223557 3 0.3192 1.000 0.112 0.000 0.848 0.040 0.000
#> SRR1223558 1 0.3339 0.881 0.836 0.000 0.040 0.000 0.124
#> SRR1223559 3 0.3192 1.000 0.112 0.000 0.848 0.040 0.000
#> SRR1223560 1 0.1579 0.855 0.944 0.000 0.024 0.000 0.032
#> SRR1223561 2 0.4201 -0.579 0.000 0.592 0.000 0.000 0.408
#> SRR1223562 2 0.1168 0.484 0.000 0.960 0.000 0.032 0.008
#> SRR1223563 2 0.4219 -0.591 0.000 0.584 0.000 0.000 0.416
#> SRR1223564 2 0.1168 0.484 0.000 0.960 0.000 0.032 0.008
#> SRR1223565 2 0.3193 0.429 0.000 0.840 0.000 0.028 0.132
#> SRR1223566 1 0.3386 0.881 0.832 0.000 0.040 0.000 0.128
#> SRR1223567 1 0.2104 0.844 0.916 0.000 0.024 0.000 0.060
#> SRR1223568 1 0.3386 0.881 0.832 0.000 0.040 0.000 0.128
#> SRR1223569 1 0.2104 0.844 0.916 0.000 0.024 0.000 0.060
#> SRR1223570 1 0.0162 0.871 0.996 0.000 0.000 0.000 0.004
#> SRR1223571 5 0.4452 1.000 0.000 0.496 0.000 0.004 0.500
#> SRR1223572 4 0.3707 0.495 0.000 0.004 0.220 0.768 0.008
#> SRR1223573 5 0.4452 1.000 0.000 0.496 0.000 0.004 0.500
#> SRR1223574 4 0.5506 0.354 0.000 0.004 0.344 0.584 0.068
#> SRR1223575 4 0.1571 0.689 0.000 0.004 0.000 0.936 0.060
#> SRR1223576 1 0.3339 0.881 0.836 0.000 0.040 0.000 0.124
#> SRR1223577 3 0.3192 1.000 0.112 0.000 0.848 0.040 0.000
#> SRR1223578 1 0.3339 0.881 0.836 0.000 0.040 0.000 0.124
#> SRR1223579 3 0.3192 1.000 0.112 0.000 0.848 0.040 0.000
#> SRR1223580 1 0.2654 0.808 0.884 0.000 0.084 0.000 0.032
#> SRR1223581 2 0.4219 -0.591 0.000 0.584 0.000 0.000 0.416
#> SRR1223582 2 0.0510 0.482 0.000 0.984 0.000 0.000 0.016
#> SRR1223583 2 0.4219 -0.591 0.000 0.584 0.000 0.000 0.416
#> SRR1223584 2 0.0510 0.482 0.000 0.984 0.000 0.000 0.016
#> SRR1223585 2 0.2806 0.378 0.000 0.844 0.000 0.004 0.152
#> SRR1223586 1 0.3291 0.882 0.840 0.000 0.040 0.000 0.120
#> SRR1223587 1 0.1251 0.860 0.956 0.000 0.008 0.000 0.036
#> SRR1223588 1 0.3339 0.881 0.836 0.000 0.040 0.000 0.124
#> SRR1223589 1 0.1469 0.857 0.948 0.000 0.016 0.000 0.036
#> SRR1223590 1 0.0162 0.871 0.996 0.000 0.000 0.000 0.004
#> SRR1223591 5 0.4452 1.000 0.000 0.496 0.000 0.004 0.500
#> SRR1223592 4 0.3816 0.759 0.000 0.000 0.000 0.696 0.304
#> SRR1223593 5 0.4452 1.000 0.000 0.496 0.000 0.004 0.500
#> SRR1223594 4 0.3816 0.759 0.000 0.000 0.000 0.696 0.304
#> SRR1223595 4 0.3816 0.759 0.000 0.000 0.000 0.696 0.304
#> SRR1223596 1 0.3339 0.881 0.836 0.000 0.040 0.000 0.124
#> SRR1223597 3 0.3192 1.000 0.112 0.000 0.848 0.040 0.000
#> SRR1223598 1 0.3339 0.881 0.836 0.000 0.040 0.000 0.124
#> SRR1223599 3 0.3192 1.000 0.112 0.000 0.848 0.040 0.000
#> SRR1223600 1 0.2654 0.808 0.884 0.000 0.084 0.000 0.032
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.2491 0.845 0.000 0.836 0.000 0.000 0.000 0.164
#> SRR1223542 6 0.0000 0.859 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1223543 2 0.2823 0.807 0.000 0.796 0.000 0.000 0.000 0.204
#> SRR1223544 6 0.0000 0.859 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1223545 6 0.2605 0.827 0.000 0.108 0.000 0.028 0.000 0.864
#> SRR1223546 1 0.0146 0.732 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1223547 5 0.2814 0.983 0.172 0.000 0.008 0.000 0.820 0.000
#> SRR1223548 1 0.0146 0.733 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1223549 5 0.2948 0.980 0.188 0.000 0.008 0.000 0.804 0.000
#> SRR1223550 1 0.3727 0.406 0.612 0.000 0.000 0.000 0.388 0.000
#> SRR1223551 2 0.0405 0.837 0.000 0.988 0.000 0.004 0.008 0.000
#> SRR1223552 4 0.0000 0.911 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1223553 2 0.1411 0.846 0.000 0.936 0.000 0.004 0.000 0.060
#> SRR1223554 4 0.4658 0.774 0.000 0.000 0.128 0.700 0.168 0.004
#> SRR1223555 4 0.0291 0.911 0.000 0.004 0.000 0.992 0.000 0.004
#> SRR1223556 1 0.0146 0.732 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1223557 3 0.0146 0.994 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1223558 1 0.0000 0.733 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223559 3 0.0547 0.985 0.000 0.000 0.980 0.000 0.020 0.000
#> SRR1223560 1 0.5284 0.252 0.508 0.000 0.104 0.000 0.388 0.000
#> SRR1223561 2 0.2491 0.845 0.000 0.836 0.000 0.000 0.000 0.164
#> SRR1223562 6 0.0000 0.859 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1223563 2 0.2562 0.840 0.000 0.828 0.000 0.000 0.000 0.172
#> SRR1223564 6 0.0000 0.859 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1223565 6 0.2605 0.827 0.000 0.108 0.000 0.028 0.000 0.864
#> SRR1223566 1 0.1501 0.706 0.924 0.000 0.000 0.000 0.076 0.000
#> SRR1223567 5 0.2912 0.984 0.172 0.000 0.012 0.000 0.816 0.000
#> SRR1223568 1 0.0790 0.720 0.968 0.000 0.000 0.000 0.032 0.000
#> SRR1223569 5 0.2980 0.984 0.180 0.000 0.012 0.000 0.808 0.000
#> SRR1223570 1 0.3747 0.394 0.604 0.000 0.000 0.000 0.396 0.000
#> SRR1223571 2 0.0405 0.837 0.000 0.988 0.000 0.004 0.008 0.000
#> SRR1223572 4 0.3791 0.822 0.000 0.000 0.116 0.788 0.092 0.004
#> SRR1223573 2 0.0405 0.837 0.000 0.988 0.000 0.004 0.008 0.000
#> SRR1223574 4 0.4658 0.774 0.000 0.000 0.128 0.700 0.168 0.004
#> SRR1223575 4 0.0508 0.910 0.000 0.000 0.000 0.984 0.012 0.004
#> SRR1223576 1 0.0000 0.733 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223577 3 0.0000 0.995 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1223578 1 0.0000 0.733 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223579 3 0.0000 0.995 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1223580 1 0.5474 0.215 0.488 0.000 0.128 0.000 0.384 0.000
#> SRR1223581 2 0.2491 0.845 0.000 0.836 0.000 0.000 0.000 0.164
#> SRR1223582 6 0.3371 0.574 0.000 0.292 0.000 0.000 0.000 0.708
#> SRR1223583 2 0.2527 0.843 0.000 0.832 0.000 0.000 0.000 0.168
#> SRR1223584 6 0.3371 0.574 0.000 0.292 0.000 0.000 0.000 0.708
#> SRR1223585 2 0.3854 0.108 0.000 0.536 0.000 0.000 0.000 0.464
#> SRR1223586 1 0.1556 0.705 0.920 0.000 0.000 0.000 0.080 0.000
#> SRR1223587 1 0.3797 0.325 0.580 0.000 0.000 0.000 0.420 0.000
#> SRR1223588 1 0.0146 0.732 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1223589 1 0.4039 0.301 0.568 0.000 0.008 0.000 0.424 0.000
#> SRR1223590 1 0.3747 0.394 0.604 0.000 0.000 0.000 0.396 0.000
#> SRR1223591 2 0.0405 0.837 0.000 0.988 0.000 0.004 0.008 0.000
#> SRR1223592 4 0.0000 0.911 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1223593 2 0.0405 0.837 0.000 0.988 0.000 0.004 0.008 0.000
#> SRR1223594 4 0.0000 0.911 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1223595 4 0.0291 0.911 0.000 0.004 0.000 0.992 0.000 0.004
#> SRR1223596 1 0.0000 0.733 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223597 3 0.0000 0.995 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1223598 1 0.0146 0.731 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1223599 3 0.0146 0.994 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1223600 1 0.5474 0.215 0.488 0.000 0.128 0.000 0.384 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "NMF"]
# you can also extract it by
# res = res_list["SD:NMF"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5090 0.492 0.492
#> 3 3 0.980 0.950 0.975 0.1956 0.880 0.760
#> 4 4 0.885 0.912 0.943 0.1247 0.902 0.751
#> 5 5 0.845 0.827 0.924 0.0480 0.995 0.985
#> 6 6 0.813 0.783 0.885 0.0438 0.972 0.906
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223542 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223543 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223544 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223545 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223546 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223547 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223548 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223549 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223550 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223551 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223552 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223553 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223554 3 0.4452 0.7223 0.000 0.192 0.808
#> SRR1223555 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223556 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223557 3 0.2066 0.8856 0.060 0.000 0.940
#> SRR1223558 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223559 3 0.1860 0.8877 0.052 0.000 0.948
#> SRR1223560 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223561 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223562 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223563 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223564 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223565 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223566 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223567 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223568 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223569 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223570 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223571 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223572 2 0.6307 -0.0252 0.000 0.512 0.488
#> SRR1223573 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223574 3 0.1860 0.8543 0.000 0.052 0.948
#> SRR1223575 2 0.0424 0.9726 0.000 0.992 0.008
#> SRR1223576 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223577 3 0.1860 0.8877 0.052 0.000 0.948
#> SRR1223578 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223579 3 0.1860 0.8877 0.052 0.000 0.948
#> SRR1223580 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223581 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223582 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223583 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223584 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223585 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223586 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223587 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223588 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223589 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223590 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223591 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223592 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223593 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223594 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223595 2 0.0000 0.9804 0.000 1.000 0.000
#> SRR1223596 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223597 3 0.5397 0.7064 0.280 0.000 0.720
#> SRR1223598 1 0.0000 1.0000 1.000 0.000 0.000
#> SRR1223599 3 0.5363 0.7121 0.276 0.000 0.724
#> SRR1223600 1 0.0000 1.0000 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> SRR1223542 2 0.1867 0.900 0.000 0.928 0.000 0.072
#> SRR1223543 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> SRR1223544 2 0.0592 0.952 0.000 0.984 0.000 0.016
#> SRR1223545 2 0.0469 0.955 0.000 0.988 0.000 0.012
#> SRR1223546 1 0.0000 0.991 1.000 0.000 0.000 0.000
#> SRR1223547 1 0.0376 0.989 0.992 0.000 0.004 0.004
#> SRR1223548 1 0.0000 0.991 1.000 0.000 0.000 0.000
#> SRR1223549 1 0.0524 0.987 0.988 0.000 0.008 0.004
#> SRR1223550 1 0.0188 0.990 0.996 0.000 0.004 0.000
#> SRR1223551 2 0.0188 0.961 0.000 0.996 0.000 0.004
#> SRR1223552 4 0.3873 0.823 0.000 0.228 0.000 0.772
#> SRR1223553 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> SRR1223554 4 0.3751 0.607 0.000 0.004 0.196 0.800
#> SRR1223555 4 0.4103 0.824 0.000 0.256 0.000 0.744
#> SRR1223556 1 0.0000 0.991 1.000 0.000 0.000 0.000
#> SRR1223557 3 0.0188 0.951 0.004 0.000 0.996 0.000
#> SRR1223558 1 0.0000 0.991 1.000 0.000 0.000 0.000
#> SRR1223559 3 0.0188 0.951 0.004 0.000 0.996 0.000
#> SRR1223560 1 0.0336 0.989 0.992 0.000 0.008 0.000
#> SRR1223561 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> SRR1223562 2 0.4830 0.140 0.000 0.608 0.000 0.392
#> SRR1223563 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> SRR1223564 2 0.2530 0.860 0.000 0.888 0.000 0.112
#> SRR1223565 2 0.0469 0.955 0.000 0.988 0.000 0.012
#> SRR1223566 1 0.0000 0.991 1.000 0.000 0.000 0.000
#> SRR1223567 1 0.0895 0.977 0.976 0.000 0.020 0.004
#> SRR1223568 1 0.0000 0.991 1.000 0.000 0.000 0.000
#> SRR1223569 1 0.3032 0.855 0.868 0.000 0.124 0.008
#> SRR1223570 1 0.0188 0.990 0.996 0.000 0.004 0.000
#> SRR1223571 2 0.0188 0.961 0.000 0.996 0.000 0.004
#> SRR1223572 4 0.4706 0.711 0.000 0.072 0.140 0.788
#> SRR1223573 2 0.0188 0.961 0.000 0.996 0.000 0.004
#> SRR1223574 4 0.5161 0.101 0.000 0.004 0.476 0.520
#> SRR1223575 4 0.4578 0.796 0.000 0.160 0.052 0.788
#> SRR1223576 1 0.0000 0.991 1.000 0.000 0.000 0.000
#> SRR1223577 3 0.0188 0.951 0.004 0.000 0.996 0.000
#> SRR1223578 1 0.0000 0.991 1.000 0.000 0.000 0.000
#> SRR1223579 3 0.0188 0.951 0.004 0.000 0.996 0.000
#> SRR1223580 1 0.0336 0.989 0.992 0.000 0.008 0.000
#> SRR1223581 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> SRR1223582 2 0.0188 0.960 0.000 0.996 0.000 0.004
#> SRR1223583 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> SRR1223584 2 0.0188 0.960 0.000 0.996 0.000 0.004
#> SRR1223585 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> SRR1223586 1 0.0000 0.991 1.000 0.000 0.000 0.000
#> SRR1223587 1 0.0376 0.989 0.992 0.000 0.004 0.004
#> SRR1223588 1 0.0000 0.991 1.000 0.000 0.000 0.000
#> SRR1223589 1 0.0376 0.989 0.992 0.000 0.004 0.004
#> SRR1223590 1 0.0188 0.990 0.996 0.000 0.004 0.000
#> SRR1223591 2 0.0188 0.961 0.000 0.996 0.000 0.004
#> SRR1223592 4 0.4164 0.818 0.000 0.264 0.000 0.736
#> SRR1223593 2 0.0188 0.961 0.000 0.996 0.000 0.004
#> SRR1223594 4 0.4134 0.821 0.000 0.260 0.000 0.740
#> SRR1223595 4 0.4103 0.824 0.000 0.256 0.000 0.744
#> SRR1223596 1 0.0000 0.991 1.000 0.000 0.000 0.000
#> SRR1223597 3 0.2011 0.898 0.080 0.000 0.920 0.000
#> SRR1223598 1 0.0000 0.991 1.000 0.000 0.000 0.000
#> SRR1223599 3 0.1940 0.903 0.076 0.000 0.924 0.000
#> SRR1223600 1 0.0336 0.989 0.992 0.000 0.008 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.0000 0.9123 0.000 1.000 0.000 0.000 0.000
#> SRR1223542 2 0.5179 0.4813 0.000 0.640 0.000 0.072 0.288
#> SRR1223543 2 0.0000 0.9123 0.000 1.000 0.000 0.000 0.000
#> SRR1223544 2 0.2763 0.7926 0.000 0.848 0.000 0.004 0.148
#> SRR1223545 2 0.0510 0.9057 0.000 0.984 0.000 0.000 0.016
#> SRR1223546 1 0.0000 0.9561 1.000 0.000 0.000 0.000 0.000
#> SRR1223547 1 0.1211 0.9404 0.960 0.000 0.024 0.000 0.016
#> SRR1223548 1 0.0000 0.9561 1.000 0.000 0.000 0.000 0.000
#> SRR1223549 1 0.1386 0.9355 0.952 0.000 0.032 0.000 0.016
#> SRR1223550 1 0.0000 0.9561 1.000 0.000 0.000 0.000 0.000
#> SRR1223551 2 0.0794 0.8966 0.000 0.972 0.000 0.028 0.000
#> SRR1223552 4 0.2179 0.7809 0.000 0.112 0.000 0.888 0.000
#> SRR1223553 2 0.0162 0.9115 0.000 0.996 0.000 0.004 0.000
#> SRR1223554 4 0.5760 -0.4042 0.000 0.000 0.096 0.536 0.368
#> SRR1223555 4 0.1952 0.7791 0.000 0.084 0.000 0.912 0.004
#> SRR1223556 1 0.0000 0.9561 1.000 0.000 0.000 0.000 0.000
#> SRR1223557 3 0.0162 0.9872 0.000 0.000 0.996 0.000 0.004
#> SRR1223558 1 0.0000 0.9561 1.000 0.000 0.000 0.000 0.000
#> SRR1223559 3 0.0290 0.9861 0.000 0.000 0.992 0.000 0.008
#> SRR1223560 1 0.3086 0.8100 0.816 0.000 0.180 0.000 0.004
#> SRR1223561 2 0.0000 0.9123 0.000 1.000 0.000 0.000 0.000
#> SRR1223562 2 0.6021 0.0798 0.000 0.476 0.000 0.116 0.408
#> SRR1223563 2 0.0000 0.9123 0.000 1.000 0.000 0.000 0.000
#> SRR1223564 2 0.5884 0.1034 0.000 0.480 0.000 0.100 0.420
#> SRR1223565 2 0.1168 0.8920 0.000 0.960 0.000 0.008 0.032
#> SRR1223566 1 0.0000 0.9561 1.000 0.000 0.000 0.000 0.000
#> SRR1223567 1 0.2511 0.8954 0.892 0.000 0.080 0.000 0.028
#> SRR1223568 1 0.0000 0.9561 1.000 0.000 0.000 0.000 0.000
#> SRR1223569 1 0.3616 0.8084 0.804 0.000 0.164 0.000 0.032
#> SRR1223570 1 0.0162 0.9549 0.996 0.000 0.000 0.000 0.004
#> SRR1223571 2 0.0162 0.9115 0.000 0.996 0.000 0.004 0.000
#> SRR1223572 4 0.4986 0.3956 0.000 0.024 0.064 0.732 0.180
#> SRR1223573 2 0.0510 0.9050 0.000 0.984 0.000 0.016 0.000
#> SRR1223574 5 0.6085 0.0000 0.000 0.000 0.164 0.280 0.556
#> SRR1223575 4 0.2217 0.6981 0.000 0.024 0.044 0.920 0.012
#> SRR1223576 1 0.0000 0.9561 1.000 0.000 0.000 0.000 0.000
#> SRR1223577 3 0.0162 0.9880 0.000 0.000 0.996 0.000 0.004
#> SRR1223578 1 0.0000 0.9561 1.000 0.000 0.000 0.000 0.000
#> SRR1223579 3 0.0162 0.9880 0.000 0.000 0.996 0.000 0.004
#> SRR1223580 1 0.3266 0.7893 0.796 0.000 0.200 0.000 0.004
#> SRR1223581 2 0.0000 0.9123 0.000 1.000 0.000 0.000 0.000
#> SRR1223582 2 0.0162 0.9110 0.000 0.996 0.000 0.000 0.004
#> SRR1223583 2 0.0000 0.9123 0.000 1.000 0.000 0.000 0.000
#> SRR1223584 2 0.0162 0.9110 0.000 0.996 0.000 0.000 0.004
#> SRR1223585 2 0.0000 0.9123 0.000 1.000 0.000 0.000 0.000
#> SRR1223586 1 0.0000 0.9561 1.000 0.000 0.000 0.000 0.000
#> SRR1223587 1 0.0510 0.9499 0.984 0.000 0.000 0.000 0.016
#> SRR1223588 1 0.0000 0.9561 1.000 0.000 0.000 0.000 0.000
#> SRR1223589 1 0.0510 0.9499 0.984 0.000 0.000 0.000 0.016
#> SRR1223590 1 0.0162 0.9549 0.996 0.000 0.000 0.000 0.004
#> SRR1223591 2 0.0290 0.9097 0.000 0.992 0.000 0.008 0.000
#> SRR1223592 4 0.2230 0.7754 0.000 0.116 0.000 0.884 0.000
#> SRR1223593 2 0.0162 0.9115 0.000 0.996 0.000 0.004 0.000
#> SRR1223594 4 0.2179 0.7809 0.000 0.112 0.000 0.888 0.000
#> SRR1223595 4 0.2293 0.7746 0.000 0.084 0.000 0.900 0.016
#> SRR1223596 1 0.0000 0.9561 1.000 0.000 0.000 0.000 0.000
#> SRR1223597 3 0.0451 0.9802 0.008 0.000 0.988 0.000 0.004
#> SRR1223598 1 0.0000 0.9561 1.000 0.000 0.000 0.000 0.000
#> SRR1223599 3 0.0451 0.9802 0.008 0.000 0.988 0.000 0.004
#> SRR1223600 1 0.3266 0.7893 0.796 0.000 0.200 0.000 0.004
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.0000 0.8963 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1223542 2 0.4550 -0.0456 0.000 0.544 0.000 0.036 NA 0.420
#> SRR1223543 2 0.0405 0.8951 0.000 0.988 0.000 0.000 NA 0.004
#> SRR1223544 2 0.4199 0.2935 0.000 0.620 0.000 0.016 NA 0.360
#> SRR1223545 2 0.2525 0.8204 0.000 0.876 0.000 0.012 NA 0.100
#> SRR1223546 1 0.0146 0.8704 0.996 0.000 0.000 0.000 NA 0.000
#> SRR1223547 1 0.5015 0.6242 0.640 0.000 0.208 0.000 NA 0.000
#> SRR1223548 1 0.0363 0.8701 0.988 0.000 0.000 0.000 NA 0.000
#> SRR1223549 1 0.5053 0.6235 0.636 0.000 0.204 0.000 NA 0.000
#> SRR1223550 1 0.0260 0.8702 0.992 0.000 0.000 0.000 NA 0.000
#> SRR1223551 2 0.0935 0.8739 0.000 0.964 0.000 0.032 NA 0.004
#> SRR1223552 4 0.2063 0.9007 0.000 0.060 0.000 0.912 NA 0.020
#> SRR1223553 2 0.0000 0.8963 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1223554 6 0.5567 0.2183 0.000 0.004 0.080 0.344 NA 0.552
#> SRR1223555 4 0.0508 0.9069 0.000 0.012 0.000 0.984 NA 0.004
#> SRR1223556 1 0.0000 0.8699 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223557 3 0.0000 0.9945 0.000 0.000 1.000 0.000 NA 0.000
#> SRR1223558 1 0.0363 0.8701 0.988 0.000 0.000 0.000 NA 0.000
#> SRR1223559 3 0.0000 0.9945 0.000 0.000 1.000 0.000 NA 0.000
#> SRR1223560 1 0.3848 0.7070 0.752 0.000 0.204 0.000 NA 0.004
#> SRR1223561 2 0.0000 0.8963 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1223562 6 0.4470 0.4401 0.000 0.356 0.000 0.040 NA 0.604
#> SRR1223563 2 0.0405 0.8951 0.000 0.988 0.000 0.000 NA 0.004
#> SRR1223564 6 0.4428 0.3701 0.000 0.388 0.000 0.032 NA 0.580
#> SRR1223565 2 0.3748 0.6372 0.000 0.748 0.000 0.012 NA 0.224
#> SRR1223566 1 0.0000 0.8699 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223567 1 0.6083 0.4355 0.516 0.000 0.304 0.000 NA 0.028
#> SRR1223568 1 0.0260 0.8703 0.992 0.000 0.000 0.000 NA 0.000
#> SRR1223569 1 0.6558 0.3279 0.456 0.000 0.308 0.000 NA 0.044
#> SRR1223570 1 0.0260 0.8696 0.992 0.000 0.000 0.000 NA 0.000
#> SRR1223571 2 0.0363 0.8923 0.000 0.988 0.000 0.012 NA 0.000
#> SRR1223572 4 0.3629 0.7581 0.000 0.004 0.032 0.800 NA 0.152
#> SRR1223573 2 0.0458 0.8897 0.000 0.984 0.000 0.016 NA 0.000
#> SRR1223574 6 0.5436 0.3180 0.000 0.000 0.104 0.244 NA 0.624
#> SRR1223575 4 0.0748 0.8977 0.000 0.004 0.000 0.976 NA 0.016
#> SRR1223576 1 0.0000 0.8699 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223577 3 0.0000 0.9945 0.000 0.000 1.000 0.000 NA 0.000
#> SRR1223578 1 0.0603 0.8668 0.980 0.000 0.000 0.000 NA 0.004
#> SRR1223579 3 0.0000 0.9945 0.000 0.000 1.000 0.000 NA 0.000
#> SRR1223580 1 0.4601 0.5325 0.616 0.000 0.336 0.000 NA 0.004
#> SRR1223581 2 0.0000 0.8963 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1223582 2 0.1524 0.8645 0.000 0.932 0.000 0.008 NA 0.060
#> SRR1223583 2 0.0405 0.8951 0.000 0.988 0.000 0.000 NA 0.004
#> SRR1223584 2 0.1674 0.8601 0.000 0.924 0.000 0.004 NA 0.068
#> SRR1223585 2 0.1049 0.8835 0.000 0.960 0.000 0.000 NA 0.032
#> SRR1223586 1 0.0363 0.8685 0.988 0.000 0.000 0.000 NA 0.000
#> SRR1223587 1 0.2482 0.8019 0.848 0.000 0.004 0.000 NA 0.000
#> SRR1223588 1 0.0260 0.8701 0.992 0.000 0.000 0.000 NA 0.000
#> SRR1223589 1 0.3210 0.7807 0.812 0.000 0.036 0.000 NA 0.000
#> SRR1223590 1 0.0260 0.8696 0.992 0.000 0.000 0.000 NA 0.000
#> SRR1223591 2 0.0363 0.8923 0.000 0.988 0.000 0.012 NA 0.000
#> SRR1223592 4 0.1967 0.8867 0.000 0.084 0.000 0.904 NA 0.012
#> SRR1223593 2 0.0146 0.8955 0.000 0.996 0.000 0.004 NA 0.000
#> SRR1223594 4 0.1812 0.8916 0.000 0.080 0.000 0.912 NA 0.008
#> SRR1223595 4 0.0508 0.9069 0.000 0.012 0.000 0.984 NA 0.004
#> SRR1223596 1 0.0363 0.8685 0.988 0.000 0.000 0.000 NA 0.000
#> SRR1223597 3 0.0363 0.9889 0.000 0.000 0.988 0.000 NA 0.000
#> SRR1223598 1 0.0692 0.8655 0.976 0.000 0.000 0.000 NA 0.004
#> SRR1223599 3 0.0363 0.9889 0.000 0.000 0.988 0.000 NA 0.000
#> SRR1223600 1 0.4260 0.6496 0.700 0.000 0.248 0.000 NA 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["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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 4.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.512 0.957 0.915 0.44023 0.492 0.492
#> 3 3 0.593 0.953 0.915 0.22365 0.919 0.834
#> 4 4 0.954 0.950 0.972 0.20890 0.919 0.802
#> 5 5 1.000 0.950 0.985 0.03707 0.997 0.991
#> 6 6 1.000 0.972 0.993 0.00746 0.997 0.990
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1223541 2 0.000 1.000 0.000 1.000
#> SRR1223542 2 0.000 1.000 0.000 1.000
#> SRR1223543 2 0.000 1.000 0.000 1.000
#> SRR1223544 2 0.000 1.000 0.000 1.000
#> SRR1223545 2 0.000 1.000 0.000 1.000
#> SRR1223546 1 0.745 0.944 0.788 0.212
#> SRR1223547 1 0.745 0.944 0.788 0.212
#> SRR1223548 1 0.745 0.944 0.788 0.212
#> SRR1223549 1 0.745 0.944 0.788 0.212
#> SRR1223550 1 0.745 0.944 0.788 0.212
#> SRR1223551 2 0.000 1.000 0.000 1.000
#> SRR1223552 2 0.000 1.000 0.000 1.000
#> SRR1223553 2 0.000 1.000 0.000 1.000
#> SRR1223554 2 0.000 1.000 0.000 1.000
#> SRR1223555 2 0.000 1.000 0.000 1.000
#> SRR1223556 1 0.745 0.944 0.788 0.212
#> SRR1223557 1 0.000 0.795 1.000 0.000
#> SRR1223558 1 0.745 0.944 0.788 0.212
#> SRR1223559 1 0.000 0.795 1.000 0.000
#> SRR1223560 1 0.745 0.944 0.788 0.212
#> SRR1223561 2 0.000 1.000 0.000 1.000
#> SRR1223562 2 0.000 1.000 0.000 1.000
#> SRR1223563 2 0.000 1.000 0.000 1.000
#> SRR1223564 2 0.000 1.000 0.000 1.000
#> SRR1223565 2 0.000 1.000 0.000 1.000
#> SRR1223566 1 0.745 0.944 0.788 0.212
#> SRR1223567 1 0.745 0.944 0.788 0.212
#> SRR1223568 1 0.745 0.944 0.788 0.212
#> SRR1223569 1 0.745 0.944 0.788 0.212
#> SRR1223570 1 0.745 0.944 0.788 0.212
#> SRR1223571 2 0.000 1.000 0.000 1.000
#> SRR1223572 2 0.000 1.000 0.000 1.000
#> SRR1223573 2 0.000 1.000 0.000 1.000
#> SRR1223574 2 0.000 1.000 0.000 1.000
#> SRR1223575 2 0.000 1.000 0.000 1.000
#> SRR1223576 1 0.745 0.944 0.788 0.212
#> SRR1223577 1 0.000 0.795 1.000 0.000
#> SRR1223578 1 0.745 0.944 0.788 0.212
#> SRR1223579 1 0.000 0.795 1.000 0.000
#> SRR1223580 1 0.745 0.944 0.788 0.212
#> SRR1223581 2 0.000 1.000 0.000 1.000
#> SRR1223582 2 0.000 1.000 0.000 1.000
#> SRR1223583 2 0.000 1.000 0.000 1.000
#> SRR1223584 2 0.000 1.000 0.000 1.000
#> SRR1223585 2 0.000 1.000 0.000 1.000
#> SRR1223586 1 0.745 0.944 0.788 0.212
#> SRR1223587 1 0.745 0.944 0.788 0.212
#> SRR1223588 1 0.745 0.944 0.788 0.212
#> SRR1223589 1 0.745 0.944 0.788 0.212
#> SRR1223590 1 0.745 0.944 0.788 0.212
#> SRR1223591 2 0.000 1.000 0.000 1.000
#> SRR1223592 2 0.000 1.000 0.000 1.000
#> SRR1223593 2 0.000 1.000 0.000 1.000
#> SRR1223594 2 0.000 1.000 0.000 1.000
#> SRR1223595 2 0.000 1.000 0.000 1.000
#> SRR1223596 1 0.745 0.944 0.788 0.212
#> SRR1223597 1 0.000 0.795 1.000 0.000
#> SRR1223598 1 0.745 0.944 0.788 0.212
#> SRR1223599 1 0.000 0.795 1.000 0.000
#> SRR1223600 1 0.745 0.944 0.788 0.212
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.47 0.944 0.212 0.788 0
#> SRR1223542 2 0.47 0.944 0.212 0.788 0
#> SRR1223543 2 0.47 0.944 0.212 0.788 0
#> SRR1223544 2 0.47 0.944 0.212 0.788 0
#> SRR1223545 2 0.47 0.944 0.212 0.788 0
#> SRR1223546 1 0.00 1.000 1.000 0.000 0
#> SRR1223547 1 0.00 1.000 1.000 0.000 0
#> SRR1223548 1 0.00 1.000 1.000 0.000 0
#> SRR1223549 1 0.00 1.000 1.000 0.000 0
#> SRR1223550 1 0.00 1.000 1.000 0.000 0
#> SRR1223551 2 0.47 0.944 0.212 0.788 0
#> SRR1223552 2 0.00 0.751 0.000 1.000 0
#> SRR1223553 2 0.47 0.944 0.212 0.788 0
#> SRR1223554 2 0.00 0.751 0.000 1.000 0
#> SRR1223555 2 0.47 0.944 0.212 0.788 0
#> SRR1223556 1 0.00 1.000 1.000 0.000 0
#> SRR1223557 3 0.00 1.000 0.000 0.000 1
#> SRR1223558 1 0.00 1.000 1.000 0.000 0
#> SRR1223559 3 0.00 1.000 0.000 0.000 1
#> SRR1223560 1 0.00 1.000 1.000 0.000 0
#> SRR1223561 2 0.47 0.944 0.212 0.788 0
#> SRR1223562 2 0.47 0.944 0.212 0.788 0
#> SRR1223563 2 0.47 0.944 0.212 0.788 0
#> SRR1223564 2 0.47 0.944 0.212 0.788 0
#> SRR1223565 2 0.47 0.944 0.212 0.788 0
#> SRR1223566 1 0.00 1.000 1.000 0.000 0
#> SRR1223567 1 0.00 1.000 1.000 0.000 0
#> SRR1223568 1 0.00 1.000 1.000 0.000 0
#> SRR1223569 1 0.00 1.000 1.000 0.000 0
#> SRR1223570 1 0.00 1.000 1.000 0.000 0
#> SRR1223571 2 0.47 0.944 0.212 0.788 0
#> SRR1223572 2 0.00 0.751 0.000 1.000 0
#> SRR1223573 2 0.47 0.944 0.212 0.788 0
#> SRR1223574 2 0.00 0.751 0.000 1.000 0
#> SRR1223575 2 0.47 0.944 0.212 0.788 0
#> SRR1223576 1 0.00 1.000 1.000 0.000 0
#> SRR1223577 3 0.00 1.000 0.000 0.000 1
#> SRR1223578 1 0.00 1.000 1.000 0.000 0
#> SRR1223579 3 0.00 1.000 0.000 0.000 1
#> SRR1223580 1 0.00 1.000 1.000 0.000 0
#> SRR1223581 2 0.47 0.944 0.212 0.788 0
#> SRR1223582 2 0.47 0.944 0.212 0.788 0
#> SRR1223583 2 0.47 0.944 0.212 0.788 0
#> SRR1223584 2 0.47 0.944 0.212 0.788 0
#> SRR1223585 2 0.47 0.944 0.212 0.788 0
#> SRR1223586 1 0.00 1.000 1.000 0.000 0
#> SRR1223587 1 0.00 1.000 1.000 0.000 0
#> SRR1223588 1 0.00 1.000 1.000 0.000 0
#> SRR1223589 1 0.00 1.000 1.000 0.000 0
#> SRR1223590 1 0.00 1.000 1.000 0.000 0
#> SRR1223591 2 0.47 0.944 0.212 0.788 0
#> SRR1223592 2 0.00 0.751 0.000 1.000 0
#> SRR1223593 2 0.47 0.944 0.212 0.788 0
#> SRR1223594 2 0.00 0.751 0.000 1.000 0
#> SRR1223595 2 0.47 0.944 0.212 0.788 0
#> SRR1223596 1 0.00 1.000 1.000 0.000 0
#> SRR1223597 3 0.00 1.000 0.000 0.000 1
#> SRR1223598 1 0.00 1.000 1.000 0.000 0
#> SRR1223599 3 0.00 1.000 0.000 0.000 1
#> SRR1223600 1 0.00 1.000 1.000 0.000 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223542 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223543 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223544 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223545 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223546 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223547 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223548 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223549 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223550 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223551 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223552 4 0.500 0.499 0 0.492 0 0.508
#> SRR1223553 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223554 4 0.228 0.558 0 0.096 0 0.904
#> SRR1223555 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223556 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223557 3 0.000 1.000 0 0.000 1 0.000
#> SRR1223558 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223559 3 0.000 1.000 0 0.000 1 0.000
#> SRR1223560 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223561 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223562 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223563 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223564 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223565 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223566 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223567 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223568 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223569 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223570 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223571 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223572 4 0.228 0.558 0 0.096 0 0.904
#> SRR1223573 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223574 4 0.000 0.415 0 0.000 0 1.000
#> SRR1223575 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223576 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223577 3 0.000 1.000 0 0.000 1 0.000
#> SRR1223578 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223579 3 0.000 1.000 0 0.000 1 0.000
#> SRR1223580 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223581 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223582 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223583 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223584 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223585 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223586 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223587 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223588 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223589 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223590 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223591 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223592 4 0.500 0.499 0 0.492 0 0.508
#> SRR1223593 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223594 4 0.500 0.499 0 0.492 0 0.508
#> SRR1223595 2 0.000 1.000 0 1.000 0 0.000
#> SRR1223596 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223597 3 0.000 1.000 0 0.000 1 0.000
#> SRR1223598 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223599 3 0.000 1.000 0 0.000 1 0.000
#> SRR1223600 1 0.000 1.000 1 0.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223542 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223543 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223544 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223545 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223546 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223547 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223548 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223549 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223550 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223551 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223552 4 0.000 0.741 0 0 0 1.000 0.000
#> SRR1223553 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223554 4 0.430 0.313 0 0 0 0.524 0.476
#> SRR1223555 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223556 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223557 3 0.000 1.000 0 0 1 0.000 0.000
#> SRR1223558 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223559 3 0.000 1.000 0 0 1 0.000 0.000
#> SRR1223560 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223561 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223562 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223563 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223564 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223565 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223566 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223567 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223568 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223569 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223570 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223571 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223572 4 0.417 0.454 0 0 0 0.604 0.396
#> SRR1223573 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223574 5 0.000 0.000 0 0 0 0.000 1.000
#> SRR1223575 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223576 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223577 3 0.000 1.000 0 0 1 0.000 0.000
#> SRR1223578 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223579 3 0.000 1.000 0 0 1 0.000 0.000
#> SRR1223580 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223581 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223582 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223583 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223584 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223585 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223586 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223587 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223588 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223589 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223590 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223591 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223592 4 0.000 0.741 0 0 0 1.000 0.000
#> SRR1223593 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223594 4 0.000 0.741 0 0 0 1.000 0.000
#> SRR1223595 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1223596 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223597 3 0.000 1.000 0 0 1 0.000 0.000
#> SRR1223598 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1223599 3 0.000 1.000 0 0 1 0.000 0.000
#> SRR1223600 1 0.000 1.000 1 0 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
#> SRR1223541 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223542 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223543 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223544 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223545 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223546 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223547 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223548 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223549 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223550 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223551 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223552 4 0.000 1.000 0 0.00 0 1.00 0.00 0.00
#> SRR1223553 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223554 5 0.156 0.877 0 0.00 0 0.00 0.92 0.08
#> SRR1223555 2 0.156 0.923 0 0.92 0 0.00 0.08 0.00
#> SRR1223556 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223557 3 0.000 1.000 0 0.00 1 0.00 0.00 0.00
#> SRR1223558 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223559 3 0.000 1.000 0 0.00 1 0.00 0.00 0.00
#> SRR1223560 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223561 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223562 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223563 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223564 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223565 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223566 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223567 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223568 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223569 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223570 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223571 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223572 5 0.156 0.881 0 0.00 0 0.08 0.92 0.00
#> SRR1223573 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223574 6 0.000 0.000 0 0.00 0 0.00 0.00 1.00
#> SRR1223575 2 0.156 0.923 0 0.92 0 0.00 0.08 0.00
#> SRR1223576 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223577 3 0.000 1.000 0 0.00 1 0.00 0.00 0.00
#> SRR1223578 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223579 3 0.000 1.000 0 0.00 1 0.00 0.00 0.00
#> SRR1223580 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223581 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223582 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223583 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223584 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223585 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223586 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223587 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223588 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223589 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223590 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223591 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223592 4 0.000 1.000 0 0.00 0 1.00 0.00 0.00
#> SRR1223593 2 0.000 0.990 0 1.00 0 0.00 0.00 0.00
#> SRR1223594 4 0.000 1.000 0 0.00 0 1.00 0.00 0.00
#> SRR1223595 2 0.156 0.923 0 0.92 0 0.00 0.08 0.00
#> SRR1223596 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223597 3 0.000 1.000 0 0.00 1 0.00 0.00 0.00
#> SRR1223598 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
#> SRR1223599 3 0.000 1.000 0 0.00 1 0.00 0.00 0.00
#> SRR1223600 1 0.000 1.000 1 0.00 0 0.00 0.00 0.00
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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.512 0.926 0.876 0.4144 0.492 0.492
#> 3 3 0.837 0.936 0.923 0.4243 0.919 0.834
#> 4 4 0.699 0.930 0.907 0.1197 0.919 0.802
#> 5 5 0.644 0.842 0.860 0.0811 1.000 1.000
#> 6 6 0.788 0.722 0.812 0.0584 0.946 0.837
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1223541 2 0.000 0.992 0.000 1.000
#> SRR1223542 2 0.000 0.992 0.000 1.000
#> SRR1223543 2 0.000 0.992 0.000 1.000
#> SRR1223544 2 0.000 0.992 0.000 1.000
#> SRR1223545 2 0.000 0.992 0.000 1.000
#> SRR1223546 1 0.886 0.911 0.696 0.304
#> SRR1223547 1 0.886 0.911 0.696 0.304
#> SRR1223548 1 0.886 0.911 0.696 0.304
#> SRR1223549 1 0.886 0.911 0.696 0.304
#> SRR1223550 1 0.886 0.911 0.696 0.304
#> SRR1223551 2 0.000 0.992 0.000 1.000
#> SRR1223552 2 0.000 0.992 0.000 1.000
#> SRR1223553 2 0.000 0.992 0.000 1.000
#> SRR1223554 2 0.295 0.932 0.052 0.948
#> SRR1223555 2 0.000 0.992 0.000 1.000
#> SRR1223556 1 0.886 0.911 0.696 0.304
#> SRR1223557 1 0.000 0.692 1.000 0.000
#> SRR1223558 1 0.886 0.911 0.696 0.304
#> SRR1223559 1 0.000 0.692 1.000 0.000
#> SRR1223560 1 0.886 0.911 0.696 0.304
#> SRR1223561 2 0.000 0.992 0.000 1.000
#> SRR1223562 2 0.000 0.992 0.000 1.000
#> SRR1223563 2 0.000 0.992 0.000 1.000
#> SRR1223564 2 0.000 0.992 0.000 1.000
#> SRR1223565 2 0.000 0.992 0.000 1.000
#> SRR1223566 1 0.886 0.911 0.696 0.304
#> SRR1223567 1 0.886 0.911 0.696 0.304
#> SRR1223568 1 0.886 0.911 0.696 0.304
#> SRR1223569 1 0.886 0.911 0.696 0.304
#> SRR1223570 1 0.886 0.911 0.696 0.304
#> SRR1223571 2 0.000 0.992 0.000 1.000
#> SRR1223572 2 0.295 0.932 0.052 0.948
#> SRR1223573 2 0.000 0.992 0.000 1.000
#> SRR1223574 2 0.327 0.921 0.060 0.940
#> SRR1223575 2 0.000 0.992 0.000 1.000
#> SRR1223576 1 0.886 0.911 0.696 0.304
#> SRR1223577 1 0.000 0.692 1.000 0.000
#> SRR1223578 1 0.886 0.911 0.696 0.304
#> SRR1223579 1 0.000 0.692 1.000 0.000
#> SRR1223580 1 0.886 0.911 0.696 0.304
#> SRR1223581 2 0.000 0.992 0.000 1.000
#> SRR1223582 2 0.000 0.992 0.000 1.000
#> SRR1223583 2 0.000 0.992 0.000 1.000
#> SRR1223584 2 0.000 0.992 0.000 1.000
#> SRR1223585 2 0.000 0.992 0.000 1.000
#> SRR1223586 1 0.886 0.911 0.696 0.304
#> SRR1223587 1 0.886 0.911 0.696 0.304
#> SRR1223588 1 0.886 0.911 0.696 0.304
#> SRR1223589 1 0.886 0.911 0.696 0.304
#> SRR1223590 1 0.886 0.911 0.696 0.304
#> SRR1223591 2 0.000 0.992 0.000 1.000
#> SRR1223592 2 0.000 0.992 0.000 1.000
#> SRR1223593 2 0.000 0.992 0.000 1.000
#> SRR1223594 2 0.000 0.992 0.000 1.000
#> SRR1223595 2 0.000 0.992 0.000 1.000
#> SRR1223596 1 0.886 0.911 0.696 0.304
#> SRR1223597 1 0.000 0.692 1.000 0.000
#> SRR1223598 1 0.886 0.911 0.696 0.304
#> SRR1223599 1 0.000 0.692 1.000 0.000
#> SRR1223600 1 0.886 0.911 0.696 0.304
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223542 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223543 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223544 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223545 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223546 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223547 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223548 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223549 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223550 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223551 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223552 2 0.606 0.649 0.000 0.616 0.384
#> SRR1223553 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223554 2 0.606 0.649 0.000 0.616 0.384
#> SRR1223555 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223556 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223557 3 0.606 1.000 0.384 0.000 0.616
#> SRR1223558 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223559 3 0.606 1.000 0.384 0.000 0.616
#> SRR1223560 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223561 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223562 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223563 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223564 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223565 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223566 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223567 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223568 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223569 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223570 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223571 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223572 2 0.606 0.649 0.000 0.616 0.384
#> SRR1223573 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223574 2 0.606 0.649 0.000 0.616 0.384
#> SRR1223575 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223576 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223577 3 0.606 1.000 0.384 0.000 0.616
#> SRR1223578 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223579 3 0.606 1.000 0.384 0.000 0.616
#> SRR1223580 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223581 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223582 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223583 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223584 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223585 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223586 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223587 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223588 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223589 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223590 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223591 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223592 2 0.606 0.649 0.000 0.616 0.384
#> SRR1223593 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223594 2 0.606 0.649 0.000 0.616 0.384
#> SRR1223595 2 0.000 0.927 0.000 1.000 0.000
#> SRR1223596 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223597 3 0.606 1.000 0.384 0.000 0.616
#> SRR1223598 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223599 3 0.606 1.000 0.384 0.000 0.616
#> SRR1223600 1 0.000 1.000 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.0000 0.949 0.000 1.000 0.000 0.000
#> SRR1223542 2 0.2589 0.882 0.000 0.884 0.116 0.000
#> SRR1223543 2 0.0000 0.949 0.000 1.000 0.000 0.000
#> SRR1223544 2 0.2281 0.898 0.000 0.904 0.096 0.000
#> SRR1223545 2 0.0336 0.949 0.000 0.992 0.008 0.000
#> SRR1223546 1 0.0000 0.927 1.000 0.000 0.000 0.000
#> SRR1223547 1 0.3400 0.855 0.820 0.000 0.000 0.180
#> SRR1223548 1 0.1716 0.913 0.936 0.000 0.000 0.064
#> SRR1223549 1 0.3486 0.849 0.812 0.000 0.000 0.188
#> SRR1223550 1 0.0000 0.927 1.000 0.000 0.000 0.000
#> SRR1223551 2 0.1022 0.941 0.000 0.968 0.032 0.000
#> SRR1223552 4 0.5227 0.981 0.000 0.256 0.040 0.704
#> SRR1223553 2 0.1118 0.939 0.000 0.964 0.036 0.000
#> SRR1223554 4 0.4103 0.981 0.000 0.256 0.000 0.744
#> SRR1223555 2 0.2814 0.882 0.000 0.868 0.132 0.000
#> SRR1223556 1 0.0000 0.927 1.000 0.000 0.000 0.000
#> SRR1223557 3 0.3528 0.997 0.192 0.000 0.808 0.000
#> SRR1223558 1 0.0000 0.927 1.000 0.000 0.000 0.000
#> SRR1223559 3 0.3528 0.997 0.192 0.000 0.808 0.000
#> SRR1223560 1 0.1867 0.906 0.928 0.000 0.000 0.072
#> SRR1223561 2 0.0000 0.949 0.000 1.000 0.000 0.000
#> SRR1223562 2 0.2589 0.882 0.000 0.884 0.116 0.000
#> SRR1223563 2 0.0000 0.949 0.000 1.000 0.000 0.000
#> SRR1223564 2 0.2589 0.882 0.000 0.884 0.116 0.000
#> SRR1223565 2 0.0336 0.949 0.000 0.992 0.008 0.000
#> SRR1223566 1 0.0000 0.927 1.000 0.000 0.000 0.000
#> SRR1223567 1 0.3400 0.855 0.820 0.000 0.000 0.180
#> SRR1223568 1 0.1716 0.913 0.936 0.000 0.000 0.064
#> SRR1223569 1 0.3486 0.849 0.812 0.000 0.000 0.188
#> SRR1223570 1 0.0000 0.927 1.000 0.000 0.000 0.000
#> SRR1223571 2 0.0469 0.948 0.000 0.988 0.012 0.000
#> SRR1223572 4 0.4103 0.981 0.000 0.256 0.000 0.744
#> SRR1223573 2 0.1118 0.939 0.000 0.964 0.036 0.000
#> SRR1223574 4 0.4103 0.981 0.000 0.256 0.000 0.744
#> SRR1223575 2 0.2814 0.882 0.000 0.868 0.132 0.000
#> SRR1223576 1 0.0000 0.927 1.000 0.000 0.000 0.000
#> SRR1223577 3 0.3528 0.997 0.192 0.000 0.808 0.000
#> SRR1223578 1 0.0469 0.926 0.988 0.000 0.000 0.012
#> SRR1223579 3 0.3528 0.997 0.192 0.000 0.808 0.000
#> SRR1223580 1 0.2868 0.884 0.864 0.000 0.000 0.136
#> SRR1223581 2 0.0000 0.949 0.000 1.000 0.000 0.000
#> SRR1223582 2 0.0469 0.947 0.000 0.988 0.012 0.000
#> SRR1223583 2 0.0000 0.949 0.000 1.000 0.000 0.000
#> SRR1223584 2 0.0469 0.947 0.000 0.988 0.012 0.000
#> SRR1223585 2 0.0336 0.949 0.000 0.992 0.008 0.000
#> SRR1223586 1 0.0469 0.926 0.988 0.000 0.000 0.012
#> SRR1223587 1 0.2760 0.886 0.872 0.000 0.000 0.128
#> SRR1223588 1 0.1940 0.914 0.924 0.000 0.000 0.076
#> SRR1223589 1 0.3610 0.848 0.800 0.000 0.000 0.200
#> SRR1223590 1 0.0469 0.926 0.988 0.000 0.000 0.012
#> SRR1223591 2 0.0469 0.948 0.000 0.988 0.012 0.000
#> SRR1223592 4 0.5227 0.981 0.000 0.256 0.040 0.704
#> SRR1223593 2 0.1118 0.939 0.000 0.964 0.036 0.000
#> SRR1223594 4 0.5227 0.981 0.000 0.256 0.040 0.704
#> SRR1223595 2 0.2814 0.882 0.000 0.868 0.132 0.000
#> SRR1223596 1 0.0469 0.926 0.988 0.000 0.000 0.012
#> SRR1223597 3 0.3978 0.994 0.192 0.000 0.796 0.012
#> SRR1223598 1 0.0469 0.926 0.988 0.000 0.000 0.012
#> SRR1223599 3 0.3978 0.994 0.192 0.000 0.796 0.012
#> SRR1223600 1 0.2868 0.884 0.864 0.000 0.000 0.136
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.0162 0.876 0.000 0.996 0.000 0.000 0.004
#> SRR1223542 2 0.3774 0.700 0.000 0.704 0.000 0.000 0.296
#> SRR1223543 2 0.0162 0.876 0.000 0.996 0.000 0.000 0.004
#> SRR1223544 2 0.3612 0.726 0.000 0.732 0.000 0.000 0.268
#> SRR1223545 2 0.1750 0.866 0.000 0.936 0.028 0.000 0.036
#> SRR1223546 1 0.0000 0.850 1.000 0.000 0.000 0.000 0.000
#> SRR1223547 1 0.4418 0.719 0.652 0.000 0.000 0.016 0.332
#> SRR1223548 1 0.3343 0.803 0.812 0.000 0.000 0.016 0.172
#> SRR1223549 1 0.4150 0.693 0.612 0.000 0.000 0.000 0.388
#> SRR1223550 1 0.0000 0.850 1.000 0.000 0.000 0.000 0.000
#> SRR1223551 2 0.1774 0.869 0.000 0.932 0.016 0.000 0.052
#> SRR1223552 4 0.4515 0.946 0.000 0.124 0.020 0.780 0.076
#> SRR1223553 2 0.2124 0.865 0.000 0.916 0.028 0.000 0.056
#> SRR1223554 4 0.3339 0.937 0.000 0.124 0.000 0.836 0.040
#> SRR1223555 2 0.5136 0.701 0.000 0.660 0.080 0.000 0.260
#> SRR1223556 1 0.0000 0.850 1.000 0.000 0.000 0.000 0.000
#> SRR1223557 3 0.2338 0.993 0.112 0.000 0.884 0.000 0.004
#> SRR1223558 1 0.0162 0.851 0.996 0.000 0.000 0.004 0.000
#> SRR1223559 3 0.2338 0.993 0.112 0.000 0.884 0.000 0.004
#> SRR1223560 1 0.4123 0.786 0.788 0.000 0.000 0.108 0.104
#> SRR1223561 2 0.0162 0.876 0.000 0.996 0.000 0.000 0.004
#> SRR1223562 2 0.3774 0.700 0.000 0.704 0.000 0.000 0.296
#> SRR1223563 2 0.0162 0.876 0.000 0.996 0.000 0.000 0.004
#> SRR1223564 2 0.3774 0.700 0.000 0.704 0.000 0.000 0.296
#> SRR1223565 2 0.1750 0.866 0.000 0.936 0.028 0.000 0.036
#> SRR1223566 1 0.0000 0.850 1.000 0.000 0.000 0.000 0.000
#> SRR1223567 1 0.4418 0.719 0.652 0.000 0.000 0.016 0.332
#> SRR1223568 1 0.3343 0.803 0.812 0.000 0.000 0.016 0.172
#> SRR1223569 1 0.4288 0.693 0.612 0.000 0.000 0.004 0.384
#> SRR1223570 1 0.0000 0.850 1.000 0.000 0.000 0.000 0.000
#> SRR1223571 2 0.1626 0.871 0.000 0.940 0.016 0.000 0.044
#> SRR1223572 4 0.2329 0.944 0.000 0.124 0.000 0.876 0.000
#> SRR1223573 2 0.2124 0.865 0.000 0.916 0.028 0.000 0.056
#> SRR1223574 4 0.3339 0.937 0.000 0.124 0.000 0.836 0.040
#> SRR1223575 2 0.5136 0.701 0.000 0.660 0.080 0.000 0.260
#> SRR1223576 1 0.0000 0.850 1.000 0.000 0.000 0.000 0.000
#> SRR1223577 3 0.2338 0.993 0.112 0.000 0.884 0.000 0.004
#> SRR1223578 1 0.0865 0.847 0.972 0.000 0.000 0.004 0.024
#> SRR1223579 3 0.2338 0.993 0.112 0.000 0.884 0.000 0.004
#> SRR1223580 1 0.5045 0.749 0.696 0.000 0.000 0.108 0.196
#> SRR1223581 2 0.0162 0.876 0.000 0.996 0.000 0.000 0.004
#> SRR1223582 2 0.0703 0.874 0.000 0.976 0.000 0.000 0.024
#> SRR1223583 2 0.0162 0.876 0.000 0.996 0.000 0.000 0.004
#> SRR1223584 2 0.0703 0.874 0.000 0.976 0.000 0.000 0.024
#> SRR1223585 2 0.1750 0.866 0.000 0.936 0.028 0.000 0.036
#> SRR1223586 1 0.0865 0.847 0.972 0.000 0.000 0.004 0.024
#> SRR1223587 1 0.3812 0.789 0.772 0.000 0.000 0.024 0.204
#> SRR1223588 1 0.3656 0.805 0.784 0.000 0.000 0.020 0.196
#> SRR1223589 1 0.4547 0.693 0.588 0.000 0.000 0.012 0.400
#> SRR1223590 1 0.1493 0.846 0.948 0.000 0.000 0.028 0.024
#> SRR1223591 2 0.1626 0.871 0.000 0.940 0.016 0.000 0.044
#> SRR1223592 4 0.4515 0.946 0.000 0.124 0.020 0.780 0.076
#> SRR1223593 2 0.2124 0.865 0.000 0.916 0.028 0.000 0.056
#> SRR1223594 4 0.4546 0.946 0.000 0.124 0.024 0.780 0.072
#> SRR1223595 2 0.5136 0.701 0.000 0.660 0.080 0.000 0.260
#> SRR1223596 1 0.0865 0.847 0.972 0.000 0.000 0.004 0.024
#> SRR1223597 3 0.2733 0.990 0.112 0.000 0.872 0.004 0.012
#> SRR1223598 1 0.1493 0.846 0.948 0.000 0.000 0.028 0.024
#> SRR1223599 3 0.2733 0.990 0.112 0.000 0.872 0.004 0.012
#> SRR1223600 1 0.5045 0.749 0.696 0.000 0.000 0.108 0.196
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.0000 0.8287 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1223542 2 0.3867 0.5099 0.000 0.512 0.000 0.000 NA 0.000
#> SRR1223543 2 0.0146 0.8287 0.000 0.996 0.000 0.000 NA 0.004
#> SRR1223544 2 0.3817 0.5716 0.000 0.568 0.000 0.000 NA 0.000
#> SRR1223545 2 0.2016 0.8133 0.000 0.920 0.016 0.000 NA 0.040
#> SRR1223546 1 0.0000 0.7451 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223547 6 0.4780 0.8780 0.472 0.000 0.000 0.004 NA 0.484
#> SRR1223548 1 0.4324 0.4241 0.752 0.000 0.000 0.032 NA 0.164
#> SRR1223549 6 0.3810 0.8981 0.428 0.000 0.000 0.000 NA 0.572
#> SRR1223550 1 0.0405 0.7420 0.988 0.000 0.000 0.000 NA 0.004
#> SRR1223551 2 0.1820 0.8233 0.000 0.924 0.008 0.000 NA 0.056
#> SRR1223552 4 0.4419 0.8936 0.000 0.048 0.012 0.780 NA 0.060
#> SRR1223553 2 0.2195 0.8186 0.000 0.904 0.012 0.000 NA 0.068
#> SRR1223554 4 0.3181 0.8665 0.000 0.048 0.000 0.856 NA 0.044
#> SRR1223555 2 0.5764 0.5256 0.000 0.508 0.000 0.000 NA 0.264
#> SRR1223556 1 0.0000 0.7451 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223557 3 0.1196 0.9735 0.040 0.000 0.952 0.000 NA 0.000
#> SRR1223558 1 0.0363 0.7446 0.988 0.000 0.000 0.000 NA 0.000
#> SRR1223559 3 0.1196 0.9735 0.040 0.000 0.952 0.000 NA 0.000
#> SRR1223560 1 0.4380 0.4185 0.700 0.000 0.000 0.000 NA 0.080
#> SRR1223561 2 0.0000 0.8287 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1223562 2 0.3867 0.5099 0.000 0.512 0.000 0.000 NA 0.000
#> SRR1223563 2 0.0146 0.8287 0.000 0.996 0.000 0.000 NA 0.004
#> SRR1223564 2 0.3867 0.5099 0.000 0.512 0.000 0.000 NA 0.000
#> SRR1223565 2 0.2016 0.8133 0.000 0.920 0.016 0.000 NA 0.040
#> SRR1223566 1 0.0405 0.7420 0.988 0.000 0.000 0.000 NA 0.004
#> SRR1223567 6 0.4780 0.8780 0.472 0.000 0.000 0.004 NA 0.484
#> SRR1223568 1 0.4324 0.4241 0.752 0.000 0.000 0.032 NA 0.164
#> SRR1223569 6 0.4350 0.9034 0.428 0.000 0.000 0.004 NA 0.552
#> SRR1223570 1 0.0405 0.7420 0.988 0.000 0.000 0.000 NA 0.004
#> SRR1223571 2 0.1590 0.8257 0.000 0.936 0.008 0.000 NA 0.048
#> SRR1223572 4 0.1219 0.8851 0.000 0.048 0.000 0.948 NA 0.004
#> SRR1223573 2 0.2195 0.8186 0.000 0.904 0.012 0.000 NA 0.068
#> SRR1223574 4 0.3176 0.8664 0.000 0.048 0.000 0.856 NA 0.040
#> SRR1223575 2 0.5764 0.5256 0.000 0.508 0.000 0.000 NA 0.264
#> SRR1223576 1 0.0000 0.7451 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223577 3 0.1196 0.9740 0.040 0.000 0.952 0.000 NA 0.008
#> SRR1223578 1 0.1528 0.7368 0.944 0.000 0.000 0.012 NA 0.028
#> SRR1223579 3 0.1196 0.9740 0.040 0.000 0.952 0.000 NA 0.008
#> SRR1223580 1 0.5591 -0.0491 0.548 0.000 0.000 0.000 NA 0.224
#> SRR1223581 2 0.0000 0.8287 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1223582 2 0.1141 0.8225 0.000 0.948 0.000 0.000 NA 0.000
#> SRR1223583 2 0.0146 0.8287 0.000 0.996 0.000 0.000 NA 0.004
#> SRR1223584 2 0.1141 0.8225 0.000 0.948 0.000 0.000 NA 0.000
#> SRR1223585 2 0.2016 0.8133 0.000 0.920 0.016 0.000 NA 0.040
#> SRR1223586 1 0.1218 0.7393 0.956 0.000 0.000 0.004 NA 0.028
#> SRR1223587 1 0.4582 -0.3131 0.612 0.000 0.000 0.012 NA 0.348
#> SRR1223588 1 0.4789 0.4258 0.712 0.000 0.000 0.040 NA 0.184
#> SRR1223589 6 0.4502 0.8595 0.404 0.000 0.000 0.012 NA 0.568
#> SRR1223590 1 0.1906 0.7263 0.924 0.000 0.000 0.008 NA 0.032
#> SRR1223591 2 0.1590 0.8257 0.000 0.936 0.008 0.000 NA 0.048
#> SRR1223592 4 0.4419 0.8936 0.000 0.048 0.012 0.780 NA 0.060
#> SRR1223593 2 0.2195 0.8186 0.000 0.904 0.012 0.000 NA 0.068
#> SRR1223594 4 0.4419 0.8936 0.000 0.048 0.012 0.780 NA 0.060
#> SRR1223595 2 0.5764 0.5256 0.000 0.508 0.000 0.000 NA 0.264
#> SRR1223596 1 0.1218 0.7393 0.956 0.000 0.000 0.004 NA 0.028
#> SRR1223597 3 0.2577 0.9551 0.040 0.000 0.888 0.000 NA 0.016
#> SRR1223598 1 0.2213 0.7216 0.908 0.000 0.000 0.012 NA 0.032
#> SRR1223599 3 0.2577 0.9551 0.040 0.000 0.888 0.000 NA 0.016
#> SRR1223600 1 0.5591 -0.0491 0.548 0.000 0.000 0.000 NA 0.224
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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5090 0.492 0.492
#> 3 3 1.000 1.000 1.000 0.1852 0.899 0.796
#> 4 4 1.000 0.953 0.983 0.1307 0.906 0.765
#> 5 5 0.971 0.934 0.963 0.0624 0.968 0.899
#> 6 6 0.927 0.950 0.951 0.0439 0.971 0.898
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 4 5
There is also optional best \(k\) = 2 3 4 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0 1 0 1 0
#> SRR1223542 2 0 1 0 1 0
#> SRR1223543 2 0 1 0 1 0
#> SRR1223544 2 0 1 0 1 0
#> SRR1223545 2 0 1 0 1 0
#> SRR1223546 1 0 1 1 0 0
#> SRR1223547 1 0 1 1 0 0
#> SRR1223548 1 0 1 1 0 0
#> SRR1223549 1 0 1 1 0 0
#> SRR1223550 1 0 1 1 0 0
#> SRR1223551 2 0 1 0 1 0
#> SRR1223552 2 0 1 0 1 0
#> SRR1223553 2 0 1 0 1 0
#> SRR1223554 2 0 1 0 1 0
#> SRR1223555 2 0 1 0 1 0
#> SRR1223556 1 0 1 1 0 0
#> SRR1223557 3 0 1 0 0 1
#> SRR1223558 1 0 1 1 0 0
#> SRR1223559 3 0 1 0 0 1
#> SRR1223560 1 0 1 1 0 0
#> SRR1223561 2 0 1 0 1 0
#> SRR1223562 2 0 1 0 1 0
#> SRR1223563 2 0 1 0 1 0
#> SRR1223564 2 0 1 0 1 0
#> SRR1223565 2 0 1 0 1 0
#> SRR1223566 1 0 1 1 0 0
#> SRR1223567 1 0 1 1 0 0
#> SRR1223568 1 0 1 1 0 0
#> SRR1223569 1 0 1 1 0 0
#> SRR1223570 1 0 1 1 0 0
#> SRR1223571 2 0 1 0 1 0
#> SRR1223572 2 0 1 0 1 0
#> SRR1223573 2 0 1 0 1 0
#> SRR1223574 3 0 1 0 0 1
#> SRR1223575 2 0 1 0 1 0
#> SRR1223576 1 0 1 1 0 0
#> SRR1223577 3 0 1 0 0 1
#> SRR1223578 1 0 1 1 0 0
#> SRR1223579 3 0 1 0 0 1
#> SRR1223580 1 0 1 1 0 0
#> SRR1223581 2 0 1 0 1 0
#> SRR1223582 2 0 1 0 1 0
#> SRR1223583 2 0 1 0 1 0
#> SRR1223584 2 0 1 0 1 0
#> SRR1223585 2 0 1 0 1 0
#> SRR1223586 1 0 1 1 0 0
#> SRR1223587 1 0 1 1 0 0
#> SRR1223588 1 0 1 1 0 0
#> SRR1223589 1 0 1 1 0 0
#> SRR1223590 1 0 1 1 0 0
#> SRR1223591 2 0 1 0 1 0
#> SRR1223592 2 0 1 0 1 0
#> SRR1223593 2 0 1 0 1 0
#> SRR1223594 2 0 1 0 1 0
#> SRR1223595 2 0 1 0 1 0
#> SRR1223596 1 0 1 1 0 0
#> SRR1223597 3 0 1 0 0 1
#> SRR1223598 1 0 1 1 0 0
#> SRR1223599 3 0 1 0 0 1
#> SRR1223600 1 0 1 1 0 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223542 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223543 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223544 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223545 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223546 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223547 1 0.0188 0.997 0.996 0.000 0.000 0.004
#> SRR1223548 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223549 1 0.0188 0.997 0.996 0.000 0.000 0.004
#> SRR1223550 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223551 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223552 4 0.0188 0.805 0.000 0.004 0.000 0.996
#> SRR1223553 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223554 4 0.0188 0.805 0.000 0.004 0.000 0.996
#> SRR1223555 2 0.0817 0.974 0.000 0.976 0.000 0.024
#> SRR1223556 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1223558 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223559 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1223560 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223561 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223562 4 0.4888 0.386 0.000 0.412 0.000 0.588
#> SRR1223563 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223564 4 0.4998 0.179 0.000 0.488 0.000 0.512
#> SRR1223565 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223566 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223567 1 0.0188 0.997 0.996 0.000 0.000 0.004
#> SRR1223568 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223569 1 0.0188 0.997 0.996 0.000 0.000 0.004
#> SRR1223570 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223571 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223572 4 0.0188 0.805 0.000 0.004 0.000 0.996
#> SRR1223573 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223574 4 0.0188 0.800 0.000 0.000 0.004 0.996
#> SRR1223575 2 0.0817 0.974 0.000 0.976 0.000 0.024
#> SRR1223576 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1223578 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223579 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1223580 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223581 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223582 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223583 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223584 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223585 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223586 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223587 1 0.0188 0.997 0.996 0.000 0.000 0.004
#> SRR1223588 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223589 1 0.0188 0.997 0.996 0.000 0.000 0.004
#> SRR1223590 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223591 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223592 4 0.0188 0.805 0.000 0.004 0.000 0.996
#> SRR1223593 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR1223594 4 0.0188 0.805 0.000 0.004 0.000 0.996
#> SRR1223595 2 0.0817 0.974 0.000 0.976 0.000 0.024
#> SRR1223596 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1223598 1 0.0000 0.999 1.000 0.000 0.000 0.000
#> SRR1223599 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1223600 1 0.0000 0.999 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
#> SRR1223541 2 0.0000 0.911 0.000 1.000 0 0.000 0.000
#> SRR1223542 5 0.2377 0.964 0.000 0.128 0 0.000 0.872
#> SRR1223543 2 0.0000 0.911 0.000 1.000 0 0.000 0.000
#> SRR1223544 5 0.2377 0.964 0.000 0.128 0 0.000 0.872
#> SRR1223545 2 0.0162 0.911 0.000 0.996 0 0.000 0.004
#> SRR1223546 1 0.0000 0.995 1.000 0.000 0 0.000 0.000
#> SRR1223547 1 0.0510 0.989 0.984 0.000 0 0.000 0.016
#> SRR1223548 1 0.0162 0.994 0.996 0.000 0 0.000 0.004
#> SRR1223549 1 0.0609 0.988 0.980 0.000 0 0.000 0.020
#> SRR1223550 1 0.0000 0.995 1.000 0.000 0 0.000 0.000
#> SRR1223551 2 0.0703 0.909 0.000 0.976 0 0.000 0.024
#> SRR1223552 4 0.0162 0.997 0.000 0.000 0 0.996 0.004
#> SRR1223553 2 0.0703 0.909 0.000 0.976 0 0.000 0.024
#> SRR1223554 4 0.0000 0.997 0.000 0.000 0 1.000 0.000
#> SRR1223555 2 0.4924 0.314 0.000 0.552 0 0.028 0.420
#> SRR1223556 1 0.0000 0.995 1.000 0.000 0 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1223558 1 0.0000 0.995 1.000 0.000 0 0.000 0.000
#> SRR1223559 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1223560 1 0.0000 0.995 1.000 0.000 0 0.000 0.000
#> SRR1223561 2 0.0000 0.911 0.000 1.000 0 0.000 0.000
#> SRR1223562 5 0.2850 0.958 0.000 0.092 0 0.036 0.872
#> SRR1223563 2 0.0000 0.911 0.000 1.000 0 0.000 0.000
#> SRR1223564 5 0.2824 0.962 0.000 0.096 0 0.032 0.872
#> SRR1223565 2 0.0162 0.911 0.000 0.996 0 0.000 0.004
#> SRR1223566 1 0.0000 0.995 1.000 0.000 0 0.000 0.000
#> SRR1223567 1 0.0510 0.989 0.984 0.000 0 0.000 0.016
#> SRR1223568 1 0.0162 0.994 0.996 0.000 0 0.000 0.004
#> SRR1223569 1 0.0609 0.988 0.980 0.000 0 0.000 0.020
#> SRR1223570 1 0.0000 0.995 1.000 0.000 0 0.000 0.000
#> SRR1223571 2 0.0609 0.910 0.000 0.980 0 0.000 0.020
#> SRR1223572 4 0.0000 0.997 0.000 0.000 0 1.000 0.000
#> SRR1223573 2 0.0703 0.909 0.000 0.976 0 0.000 0.024
#> SRR1223574 4 0.0000 0.997 0.000 0.000 0 1.000 0.000
#> SRR1223575 2 0.4942 0.282 0.000 0.540 0 0.028 0.432
#> SRR1223576 1 0.0000 0.995 1.000 0.000 0 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1223578 1 0.0000 0.995 1.000 0.000 0 0.000 0.000
#> SRR1223579 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1223580 1 0.0290 0.993 0.992 0.000 0 0.000 0.008
#> SRR1223581 2 0.0000 0.911 0.000 1.000 0 0.000 0.000
#> SRR1223582 2 0.0703 0.906 0.000 0.976 0 0.000 0.024
#> SRR1223583 2 0.0000 0.911 0.000 1.000 0 0.000 0.000
#> SRR1223584 2 0.0703 0.906 0.000 0.976 0 0.000 0.024
#> SRR1223585 2 0.0162 0.911 0.000 0.996 0 0.000 0.004
#> SRR1223586 1 0.0000 0.995 1.000 0.000 0 0.000 0.000
#> SRR1223587 1 0.0404 0.991 0.988 0.000 0 0.000 0.012
#> SRR1223588 1 0.0162 0.994 0.996 0.000 0 0.000 0.004
#> SRR1223589 1 0.0609 0.988 0.980 0.000 0 0.000 0.020
#> SRR1223590 1 0.0000 0.995 1.000 0.000 0 0.000 0.000
#> SRR1223591 2 0.0510 0.910 0.000 0.984 0 0.000 0.016
#> SRR1223592 4 0.0162 0.997 0.000 0.000 0 0.996 0.004
#> SRR1223593 2 0.0703 0.909 0.000 0.976 0 0.000 0.024
#> SRR1223594 4 0.0162 0.997 0.000 0.000 0 0.996 0.004
#> SRR1223595 2 0.4924 0.314 0.000 0.552 0 0.028 0.420
#> SRR1223596 1 0.0000 0.995 1.000 0.000 0 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1223598 1 0.0000 0.995 1.000 0.000 0 0.000 0.000
#> SRR1223599 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1223600 1 0.0290 0.993 0.992 0.000 0 0.000 0.008
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.0000 0.959 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223542 6 0.0632 1.000 0.000 0.024 0 0.000 0.000 0.976
#> SRR1223543 2 0.0000 0.959 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223544 6 0.0632 1.000 0.000 0.024 0 0.000 0.000 0.976
#> SRR1223545 2 0.0858 0.947 0.000 0.968 0 0.000 0.028 0.004
#> SRR1223546 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223547 1 0.3134 0.857 0.808 0.000 0 0.000 0.168 0.024
#> SRR1223548 1 0.0632 0.941 0.976 0.000 0 0.000 0.024 0.000
#> SRR1223549 1 0.3236 0.853 0.796 0.000 0 0.000 0.180 0.024
#> SRR1223550 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223551 2 0.1471 0.939 0.000 0.932 0 0.000 0.064 0.004
#> SRR1223552 4 0.0692 0.968 0.000 0.000 0 0.976 0.020 0.004
#> SRR1223553 2 0.1644 0.931 0.000 0.920 0 0.000 0.076 0.004
#> SRR1223554 4 0.0865 0.968 0.000 0.000 0 0.964 0.036 0.000
#> SRR1223555 5 0.3956 1.000 0.000 0.136 0 0.008 0.776 0.080
#> SRR1223556 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223558 1 0.0146 0.945 0.996 0.000 0 0.000 0.004 0.000
#> SRR1223559 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223560 1 0.0363 0.944 0.988 0.000 0 0.000 0.012 0.000
#> SRR1223561 2 0.0000 0.959 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223562 6 0.0632 1.000 0.000 0.024 0 0.000 0.000 0.976
#> SRR1223563 2 0.0000 0.959 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223564 6 0.0632 1.000 0.000 0.024 0 0.000 0.000 0.976
#> SRR1223565 2 0.0858 0.947 0.000 0.968 0 0.000 0.028 0.004
#> SRR1223566 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223567 1 0.3134 0.857 0.808 0.000 0 0.000 0.168 0.024
#> SRR1223568 1 0.0632 0.941 0.976 0.000 0 0.000 0.024 0.000
#> SRR1223569 1 0.3236 0.853 0.796 0.000 0 0.000 0.180 0.024
#> SRR1223570 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223571 2 0.1219 0.948 0.000 0.948 0 0.000 0.048 0.004
#> SRR1223572 4 0.0865 0.968 0.000 0.000 0 0.964 0.036 0.000
#> SRR1223573 2 0.1644 0.931 0.000 0.920 0 0.000 0.076 0.004
#> SRR1223574 4 0.0865 0.968 0.000 0.000 0 0.964 0.036 0.000
#> SRR1223575 5 0.3956 1.000 0.000 0.136 0 0.008 0.776 0.080
#> SRR1223576 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223578 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223579 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223580 1 0.1779 0.920 0.920 0.000 0 0.000 0.064 0.016
#> SRR1223581 2 0.0000 0.959 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223582 2 0.1007 0.943 0.000 0.956 0 0.000 0.000 0.044
#> SRR1223583 2 0.0000 0.959 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223584 2 0.1007 0.943 0.000 0.956 0 0.000 0.000 0.044
#> SRR1223585 2 0.0713 0.949 0.000 0.972 0 0.000 0.028 0.000
#> SRR1223586 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223587 1 0.2790 0.877 0.844 0.000 0 0.000 0.132 0.024
#> SRR1223588 1 0.0632 0.941 0.976 0.000 0 0.000 0.024 0.000
#> SRR1223589 1 0.3202 0.856 0.800 0.000 0 0.000 0.176 0.024
#> SRR1223590 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223591 2 0.1152 0.949 0.000 0.952 0 0.000 0.044 0.004
#> SRR1223592 4 0.0777 0.967 0.000 0.000 0 0.972 0.024 0.004
#> SRR1223593 2 0.1644 0.931 0.000 0.920 0 0.000 0.076 0.004
#> SRR1223594 4 0.0777 0.967 0.000 0.000 0 0.972 0.024 0.004
#> SRR1223595 5 0.3956 1.000 0.000 0.136 0 0.008 0.776 0.080
#> SRR1223596 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223598 1 0.0000 0.945 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223599 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223600 1 0.1779 0.920 0.920 0.000 0 0.000 0.064 0.016
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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5090 0.492 0.492
#> 3 3 1.000 0.982 0.993 0.1700 0.919 0.834
#> 4 4 1.000 0.995 0.998 0.1299 0.919 0.802
#> 5 5 1.000 0.981 0.993 0.0771 0.946 0.837
#> 6 6 0.976 0.956 0.962 0.0202 0.977 0.918
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 4 5
There is also optional best \(k\) = 2 3 4 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.000 0.986 0 1.000 0.000
#> SRR1223542 2 0.000 0.986 0 1.000 0.000
#> SRR1223543 2 0.000 0.986 0 1.000 0.000
#> SRR1223544 2 0.000 0.986 0 1.000 0.000
#> SRR1223545 2 0.000 0.986 0 1.000 0.000
#> SRR1223546 1 0.000 1.000 1 0.000 0.000
#> SRR1223547 1 0.000 1.000 1 0.000 0.000
#> SRR1223548 1 0.000 1.000 1 0.000 0.000
#> SRR1223549 1 0.000 1.000 1 0.000 0.000
#> SRR1223550 1 0.000 1.000 1 0.000 0.000
#> SRR1223551 2 0.000 0.986 0 1.000 0.000
#> SRR1223552 2 0.000 0.986 0 1.000 0.000
#> SRR1223553 2 0.000 0.986 0 1.000 0.000
#> SRR1223554 2 0.000 0.986 0 1.000 0.000
#> SRR1223555 2 0.000 0.986 0 1.000 0.000
#> SRR1223556 1 0.000 1.000 1 0.000 0.000
#> SRR1223557 3 0.000 1.000 0 0.000 1.000
#> SRR1223558 1 0.000 1.000 1 0.000 0.000
#> SRR1223559 3 0.000 1.000 0 0.000 1.000
#> SRR1223560 1 0.000 1.000 1 0.000 0.000
#> SRR1223561 2 0.000 0.986 0 1.000 0.000
#> SRR1223562 2 0.000 0.986 0 1.000 0.000
#> SRR1223563 2 0.000 0.986 0 1.000 0.000
#> SRR1223564 2 0.000 0.986 0 1.000 0.000
#> SRR1223565 2 0.000 0.986 0 1.000 0.000
#> SRR1223566 1 0.000 1.000 1 0.000 0.000
#> SRR1223567 1 0.000 1.000 1 0.000 0.000
#> SRR1223568 1 0.000 1.000 1 0.000 0.000
#> SRR1223569 1 0.000 1.000 1 0.000 0.000
#> SRR1223570 1 0.000 1.000 1 0.000 0.000
#> SRR1223571 2 0.000 0.986 0 1.000 0.000
#> SRR1223572 2 0.000 0.986 0 1.000 0.000
#> SRR1223573 2 0.000 0.986 0 1.000 0.000
#> SRR1223574 2 0.614 0.322 0 0.596 0.404
#> SRR1223575 2 0.000 0.986 0 1.000 0.000
#> SRR1223576 1 0.000 1.000 1 0.000 0.000
#> SRR1223577 3 0.000 1.000 0 0.000 1.000
#> SRR1223578 1 0.000 1.000 1 0.000 0.000
#> SRR1223579 3 0.000 1.000 0 0.000 1.000
#> SRR1223580 1 0.000 1.000 1 0.000 0.000
#> SRR1223581 2 0.000 0.986 0 1.000 0.000
#> SRR1223582 2 0.000 0.986 0 1.000 0.000
#> SRR1223583 2 0.000 0.986 0 1.000 0.000
#> SRR1223584 2 0.000 0.986 0 1.000 0.000
#> SRR1223585 2 0.000 0.986 0 1.000 0.000
#> SRR1223586 1 0.000 1.000 1 0.000 0.000
#> SRR1223587 1 0.000 1.000 1 0.000 0.000
#> SRR1223588 1 0.000 1.000 1 0.000 0.000
#> SRR1223589 1 0.000 1.000 1 0.000 0.000
#> SRR1223590 1 0.000 1.000 1 0.000 0.000
#> SRR1223591 2 0.000 0.986 0 1.000 0.000
#> SRR1223592 2 0.000 0.986 0 1.000 0.000
#> SRR1223593 2 0.000 0.986 0 1.000 0.000
#> SRR1223594 2 0.000 0.986 0 1.000 0.000
#> SRR1223595 2 0.000 0.986 0 1.000 0.000
#> SRR1223596 1 0.000 1.000 1 0.000 0.000
#> SRR1223597 3 0.000 1.000 0 0.000 1.000
#> SRR1223598 1 0.000 1.000 1 0.000 0.000
#> SRR1223599 3 0.000 1.000 0 0.000 1.000
#> SRR1223600 1 0.000 1.000 1 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223542 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223543 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223544 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223545 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223546 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223547 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223548 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223549 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223550 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223551 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223552 4 0.000 1.000 0 0.00 0 1.00
#> SRR1223553 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223554 4 0.000 1.000 0 0.00 0 1.00
#> SRR1223555 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223556 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223557 3 0.000 1.000 0 0.00 1 0.00
#> SRR1223558 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223559 3 0.000 1.000 0 0.00 1 0.00
#> SRR1223560 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223561 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223562 2 0.292 0.837 0 0.86 0 0.14
#> SRR1223563 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223564 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223565 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223566 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223567 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223568 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223569 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223570 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223571 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223572 4 0.000 1.000 0 0.00 0 1.00
#> SRR1223573 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223574 4 0.000 1.000 0 0.00 0 1.00
#> SRR1223575 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223576 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223577 3 0.000 1.000 0 0.00 1 0.00
#> SRR1223578 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223579 3 0.000 1.000 0 0.00 1 0.00
#> SRR1223580 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223581 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223582 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223583 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223584 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223585 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223586 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223587 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223588 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223589 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223590 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223591 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223592 4 0.000 1.000 0 0.00 0 1.00
#> SRR1223593 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223594 4 0.000 1.000 0 0.00 0 1.00
#> SRR1223595 2 0.000 0.994 0 1.00 0 0.00
#> SRR1223596 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223597 3 0.000 1.000 0 0.00 1 0.00
#> SRR1223598 1 0.000 1.000 1 0.00 0 0.00
#> SRR1223599 3 0.000 1.000 0 0.00 1 0.00
#> SRR1223600 1 0.000 1.000 1 0.00 0 0.00
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223542 5 0.0162 0.921 0 0.004 0 0.00 0.996
#> SRR1223543 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223544 5 0.0162 0.921 0 0.004 0 0.00 0.996
#> SRR1223545 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223546 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223547 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223548 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223549 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223550 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223551 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223552 4 0.0000 0.996 0 0.000 0 1.00 0.000
#> SRR1223553 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223554 4 0.0000 0.996 0 0.000 0 1.00 0.000
#> SRR1223555 2 0.0162 0.985 0 0.996 0 0.00 0.004
#> SRR1223556 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223557 3 0.0000 1.000 0 0.000 1 0.00 0.000
#> SRR1223558 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223559 3 0.0000 1.000 0 0.000 1 0.00 0.000
#> SRR1223560 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223561 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223562 5 0.0162 0.921 0 0.004 0 0.00 0.996
#> SRR1223563 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223564 5 0.0162 0.921 0 0.004 0 0.00 0.996
#> SRR1223565 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223566 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223567 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223568 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223569 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223570 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223571 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223572 4 0.0000 0.996 0 0.000 0 1.00 0.000
#> SRR1223573 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223574 4 0.0609 0.980 0 0.000 0 0.98 0.020
#> SRR1223575 5 0.3210 0.680 0 0.212 0 0.00 0.788
#> SRR1223576 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223577 3 0.0000 1.000 0 0.000 1 0.00 0.000
#> SRR1223578 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223579 3 0.0000 1.000 0 0.000 1 0.00 0.000
#> SRR1223580 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223581 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223582 2 0.3039 0.745 0 0.808 0 0.00 0.192
#> SRR1223583 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223584 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223585 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223586 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223587 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223588 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223589 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223590 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223591 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223592 4 0.0000 0.996 0 0.000 0 1.00 0.000
#> SRR1223593 2 0.0000 0.988 0 1.000 0 0.00 0.000
#> SRR1223594 4 0.0000 0.996 0 0.000 0 1.00 0.000
#> SRR1223595 2 0.0162 0.985 0 0.996 0 0.00 0.004
#> SRR1223596 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223597 3 0.0000 1.000 0 0.000 1 0.00 0.000
#> SRR1223598 1 0.0000 1.000 1 0.000 0 0.00 0.000
#> SRR1223599 3 0.0000 1.000 0 0.000 1 0.00 0.000
#> SRR1223600 1 0.0000 1.000 1 0.000 0 0.00 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.0000 0.981 0 1.000 0 0.000 0.000 0.000
#> SRR1223542 6 0.0000 1.000 0 0.000 0 0.000 0.000 1.000
#> SRR1223543 2 0.0000 0.981 0 1.000 0 0.000 0.000 0.000
#> SRR1223544 6 0.0000 1.000 0 0.000 0 0.000 0.000 1.000
#> SRR1223545 2 0.0000 0.981 0 1.000 0 0.000 0.000 0.000
#> SRR1223546 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223547 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223548 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223549 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223550 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223551 2 0.0000 0.981 0 1.000 0 0.000 0.000 0.000
#> SRR1223552 4 0.3706 0.852 0 0.000 0 0.620 0.380 0.000
#> SRR1223553 2 0.0000 0.981 0 1.000 0 0.000 0.000 0.000
#> SRR1223554 4 0.0000 0.745 0 0.000 0 1.000 0.000 0.000
#> SRR1223555 5 0.3706 0.822 0 0.380 0 0.000 0.620 0.000
#> SRR1223556 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223558 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223559 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223560 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223561 2 0.0000 0.981 0 1.000 0 0.000 0.000 0.000
#> SRR1223562 6 0.0000 1.000 0 0.000 0 0.000 0.000 1.000
#> SRR1223563 2 0.0000 0.981 0 1.000 0 0.000 0.000 0.000
#> SRR1223564 6 0.0000 1.000 0 0.000 0 0.000 0.000 1.000
#> SRR1223565 2 0.0000 0.981 0 1.000 0 0.000 0.000 0.000
#> SRR1223566 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223567 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223568 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223569 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223570 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223571 2 0.0000 0.981 0 1.000 0 0.000 0.000 0.000
#> SRR1223572 4 0.3221 0.840 0 0.000 0 0.736 0.264 0.000
#> SRR1223573 2 0.0000 0.981 0 1.000 0 0.000 0.000 0.000
#> SRR1223574 4 0.1556 0.679 0 0.000 0 0.920 0.000 0.080
#> SRR1223575 5 0.5175 0.574 0 0.184 0 0.000 0.620 0.196
#> SRR1223576 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223578 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223579 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223580 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223581 2 0.0000 0.981 0 1.000 0 0.000 0.000 0.000
#> SRR1223582 2 0.2664 0.652 0 0.816 0 0.000 0.000 0.184
#> SRR1223583 2 0.0000 0.981 0 1.000 0 0.000 0.000 0.000
#> SRR1223584 2 0.0363 0.966 0 0.988 0 0.000 0.000 0.012
#> SRR1223585 2 0.0000 0.981 0 1.000 0 0.000 0.000 0.000
#> SRR1223586 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223587 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223588 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223589 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223590 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223591 2 0.0000 0.981 0 1.000 0 0.000 0.000 0.000
#> SRR1223592 4 0.3706 0.852 0 0.000 0 0.620 0.380 0.000
#> SRR1223593 2 0.0000 0.981 0 1.000 0 0.000 0.000 0.000
#> SRR1223594 4 0.3706 0.852 0 0.000 0 0.620 0.380 0.000
#> SRR1223595 5 0.3706 0.822 0 0.380 0 0.000 0.620 0.000
#> SRR1223596 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223598 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223599 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223600 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "mclust"]
# you can also extract it by
# res = res_list["CV:mclust"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.817 0.879 0.952 0.4983 0.512 0.512
#> 3 3 0.944 0.946 0.976 0.3195 0.837 0.682
#> 4 4 0.927 0.922 0.960 0.0465 0.980 0.942
#> 5 5 0.934 0.899 0.949 0.0867 0.919 0.753
#> 6 6 0.929 0.864 0.900 0.0130 0.995 0.979
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] 3 4
There is also optional best \(k\) = 3 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1223541 2 0.000 0.914 0.000 1.000
#> SRR1223542 2 0.000 0.914 0.000 1.000
#> SRR1223543 2 0.000 0.914 0.000 1.000
#> SRR1223544 2 0.000 0.914 0.000 1.000
#> SRR1223545 2 0.000 0.914 0.000 1.000
#> SRR1223546 1 0.000 1.000 1.000 0.000
#> SRR1223547 1 0.000 1.000 1.000 0.000
#> SRR1223548 1 0.000 1.000 1.000 0.000
#> SRR1223549 1 0.000 1.000 1.000 0.000
#> SRR1223550 1 0.000 1.000 1.000 0.000
#> SRR1223551 2 0.000 0.914 0.000 1.000
#> SRR1223552 2 0.000 0.914 0.000 1.000
#> SRR1223553 2 0.000 0.914 0.000 1.000
#> SRR1223554 2 0.000 0.914 0.000 1.000
#> SRR1223555 2 0.000 0.914 0.000 1.000
#> SRR1223556 1 0.000 1.000 1.000 0.000
#> SRR1223557 2 0.998 0.221 0.476 0.524
#> SRR1223558 1 0.000 1.000 1.000 0.000
#> SRR1223559 2 0.998 0.221 0.476 0.524
#> SRR1223560 1 0.000 1.000 1.000 0.000
#> SRR1223561 2 0.000 0.914 0.000 1.000
#> SRR1223562 2 0.000 0.914 0.000 1.000
#> SRR1223563 2 0.000 0.914 0.000 1.000
#> SRR1223564 2 0.000 0.914 0.000 1.000
#> SRR1223565 2 0.000 0.914 0.000 1.000
#> SRR1223566 1 0.000 1.000 1.000 0.000
#> SRR1223567 1 0.000 1.000 1.000 0.000
#> SRR1223568 1 0.000 1.000 1.000 0.000
#> SRR1223569 1 0.000 1.000 1.000 0.000
#> SRR1223570 1 0.000 1.000 1.000 0.000
#> SRR1223571 2 0.000 0.914 0.000 1.000
#> SRR1223572 2 0.000 0.914 0.000 1.000
#> SRR1223573 2 0.000 0.914 0.000 1.000
#> SRR1223574 2 0.000 0.914 0.000 1.000
#> SRR1223575 2 0.000 0.914 0.000 1.000
#> SRR1223576 1 0.000 1.000 1.000 0.000
#> SRR1223577 2 0.998 0.221 0.476 0.524
#> SRR1223578 1 0.000 1.000 1.000 0.000
#> SRR1223579 2 0.998 0.221 0.476 0.524
#> SRR1223580 1 0.000 1.000 1.000 0.000
#> SRR1223581 2 0.000 0.914 0.000 1.000
#> SRR1223582 2 0.000 0.914 0.000 1.000
#> SRR1223583 2 0.000 0.914 0.000 1.000
#> SRR1223584 2 0.000 0.914 0.000 1.000
#> SRR1223585 2 0.000 0.914 0.000 1.000
#> SRR1223586 1 0.000 1.000 1.000 0.000
#> SRR1223587 1 0.000 1.000 1.000 0.000
#> SRR1223588 1 0.000 1.000 1.000 0.000
#> SRR1223589 1 0.000 1.000 1.000 0.000
#> SRR1223590 1 0.000 1.000 1.000 0.000
#> SRR1223591 2 0.000 0.914 0.000 1.000
#> SRR1223592 2 0.000 0.914 0.000 1.000
#> SRR1223593 2 0.000 0.914 0.000 1.000
#> SRR1223594 2 0.000 0.914 0.000 1.000
#> SRR1223595 2 0.000 0.914 0.000 1.000
#> SRR1223596 1 0.000 1.000 1.000 0.000
#> SRR1223597 2 0.998 0.221 0.476 0.524
#> SRR1223598 1 0.000 1.000 1.000 0.000
#> SRR1223599 2 0.998 0.221 0.476 0.524
#> SRR1223600 1 0.000 1.000 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.0000 0.939 0 1.000 0.000
#> SRR1223542 2 0.1643 0.914 0 0.956 0.044
#> SRR1223543 2 0.0000 0.939 0 1.000 0.000
#> SRR1223544 2 0.1643 0.914 0 0.956 0.044
#> SRR1223545 2 0.0000 0.939 0 1.000 0.000
#> SRR1223546 1 0.0000 1.000 1 0.000 0.000
#> SRR1223547 1 0.0000 1.000 1 0.000 0.000
#> SRR1223548 1 0.0000 1.000 1 0.000 0.000
#> SRR1223549 1 0.0000 1.000 1 0.000 0.000
#> SRR1223550 1 0.0000 1.000 1 0.000 0.000
#> SRR1223551 2 0.0000 0.939 0 1.000 0.000
#> SRR1223552 3 0.0892 0.981 0 0.020 0.980
#> SRR1223553 2 0.0000 0.939 0 1.000 0.000
#> SRR1223554 3 0.0000 0.994 0 0.000 1.000
#> SRR1223555 2 0.3619 0.838 0 0.864 0.136
#> SRR1223556 1 0.0000 1.000 1 0.000 0.000
#> SRR1223557 3 0.0000 0.994 0 0.000 1.000
#> SRR1223558 1 0.0000 1.000 1 0.000 0.000
#> SRR1223559 3 0.0000 0.994 0 0.000 1.000
#> SRR1223560 1 0.0000 1.000 1 0.000 0.000
#> SRR1223561 2 0.0000 0.939 0 1.000 0.000
#> SRR1223562 2 0.6225 0.288 0 0.568 0.432
#> SRR1223563 2 0.0000 0.939 0 1.000 0.000
#> SRR1223564 2 0.6225 0.288 0 0.568 0.432
#> SRR1223565 2 0.0000 0.939 0 1.000 0.000
#> SRR1223566 1 0.0000 1.000 1 0.000 0.000
#> SRR1223567 1 0.0000 1.000 1 0.000 0.000
#> SRR1223568 1 0.0000 1.000 1 0.000 0.000
#> SRR1223569 1 0.0000 1.000 1 0.000 0.000
#> SRR1223570 1 0.0000 1.000 1 0.000 0.000
#> SRR1223571 2 0.0000 0.939 0 1.000 0.000
#> SRR1223572 3 0.0000 0.994 0 0.000 1.000
#> SRR1223573 2 0.0000 0.939 0 1.000 0.000
#> SRR1223574 3 0.0000 0.994 0 0.000 1.000
#> SRR1223575 2 0.3619 0.838 0 0.864 0.136
#> SRR1223576 1 0.0000 1.000 1 0.000 0.000
#> SRR1223577 3 0.0000 0.994 0 0.000 1.000
#> SRR1223578 1 0.0000 1.000 1 0.000 0.000
#> SRR1223579 3 0.0000 0.994 0 0.000 1.000
#> SRR1223580 1 0.0000 1.000 1 0.000 0.000
#> SRR1223581 2 0.0000 0.939 0 1.000 0.000
#> SRR1223582 2 0.0000 0.939 0 1.000 0.000
#> SRR1223583 2 0.0000 0.939 0 1.000 0.000
#> SRR1223584 2 0.0000 0.939 0 1.000 0.000
#> SRR1223585 2 0.0000 0.939 0 1.000 0.000
#> SRR1223586 1 0.0000 1.000 1 0.000 0.000
#> SRR1223587 1 0.0000 1.000 1 0.000 0.000
#> SRR1223588 1 0.0000 1.000 1 0.000 0.000
#> SRR1223589 1 0.0000 1.000 1 0.000 0.000
#> SRR1223590 1 0.0000 1.000 1 0.000 0.000
#> SRR1223591 2 0.0000 0.939 0 1.000 0.000
#> SRR1223592 3 0.0892 0.981 0 0.020 0.980
#> SRR1223593 2 0.0000 0.939 0 1.000 0.000
#> SRR1223594 3 0.0892 0.981 0 0.020 0.980
#> SRR1223595 2 0.3619 0.838 0 0.864 0.136
#> SRR1223596 1 0.0000 1.000 1 0.000 0.000
#> SRR1223597 3 0.0000 0.994 0 0.000 1.000
#> SRR1223598 1 0.0000 1.000 1 0.000 0.000
#> SRR1223599 3 0.0000 0.994 0 0.000 1.000
#> SRR1223600 1 0.0000 1.000 1 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.0000 0.893 0 1.000 0 0.000
#> SRR1223542 2 0.4072 0.714 0 0.748 0 0.252
#> SRR1223543 2 0.0000 0.893 0 1.000 0 0.000
#> SRR1223544 2 0.4072 0.714 0 0.748 0 0.252
#> SRR1223545 2 0.0000 0.893 0 1.000 0 0.000
#> SRR1223546 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223547 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223548 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223549 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223550 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223551 2 0.0469 0.893 0 0.988 0 0.012
#> SRR1223552 4 0.0000 1.000 0 0.000 0 1.000
#> SRR1223553 2 0.0469 0.893 0 0.988 0 0.012
#> SRR1223554 4 0.0000 1.000 0 0.000 0 1.000
#> SRR1223555 2 0.4356 0.670 0 0.708 0 0.292
#> SRR1223556 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223557 3 0.0000 1.000 0 0.000 1 0.000
#> SRR1223558 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223559 3 0.0000 1.000 0 0.000 1 0.000
#> SRR1223560 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223561 2 0.0000 0.893 0 1.000 0 0.000
#> SRR1223562 2 0.4972 0.336 0 0.544 0 0.456
#> SRR1223563 2 0.0000 0.893 0 1.000 0 0.000
#> SRR1223564 2 0.4972 0.336 0 0.544 0 0.456
#> SRR1223565 2 0.0000 0.893 0 1.000 0 0.000
#> SRR1223566 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223567 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223568 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223569 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223570 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223571 2 0.0469 0.893 0 0.988 0 0.012
#> SRR1223572 4 0.0000 1.000 0 0.000 0 1.000
#> SRR1223573 2 0.0469 0.893 0 0.988 0 0.012
#> SRR1223574 4 0.0000 1.000 0 0.000 0 1.000
#> SRR1223575 2 0.4356 0.670 0 0.708 0 0.292
#> SRR1223576 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223577 3 0.0000 1.000 0 0.000 1 0.000
#> SRR1223578 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223579 3 0.0000 1.000 0 0.000 1 0.000
#> SRR1223580 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223581 2 0.0000 0.893 0 1.000 0 0.000
#> SRR1223582 2 0.0336 0.892 0 0.992 0 0.008
#> SRR1223583 2 0.0000 0.893 0 1.000 0 0.000
#> SRR1223584 2 0.0336 0.892 0 0.992 0 0.008
#> SRR1223585 2 0.0000 0.893 0 1.000 0 0.000
#> SRR1223586 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223587 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223588 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223589 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223590 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223591 2 0.0469 0.893 0 0.988 0 0.012
#> SRR1223592 4 0.0000 1.000 0 0.000 0 1.000
#> SRR1223593 2 0.0469 0.893 0 0.988 0 0.012
#> SRR1223594 4 0.0000 1.000 0 0.000 0 1.000
#> SRR1223595 2 0.4356 0.670 0 0.708 0 0.292
#> SRR1223596 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223597 3 0.0000 1.000 0 0.000 1 0.000
#> SRR1223598 1 0.0000 1.000 1 0.000 0 0.000
#> SRR1223599 3 0.0000 1.000 0 0.000 1 0.000
#> SRR1223600 1 0.0000 1.000 1 0.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.0000 0.908 0 1.000 0 0.000 0.000
#> SRR1223542 5 0.0290 0.782 0 0.008 0 0.000 0.992
#> SRR1223543 2 0.0000 0.908 0 1.000 0 0.000 0.000
#> SRR1223544 5 0.1043 0.785 0 0.040 0 0.000 0.960
#> SRR1223545 2 0.0000 0.908 0 1.000 0 0.000 0.000
#> SRR1223546 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223547 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223548 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223549 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223550 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223551 2 0.3534 0.633 0 0.744 0 0.000 0.256
#> SRR1223552 4 0.1478 0.962 0 0.000 0 0.936 0.064
#> SRR1223553 5 0.3561 0.678 0 0.260 0 0.000 0.740
#> SRR1223554 4 0.0000 0.961 0 0.000 0 1.000 0.000
#> SRR1223555 5 0.2511 0.763 0 0.028 0 0.080 0.892
#> SRR1223556 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR1223558 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223559 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR1223560 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223561 2 0.0000 0.908 0 1.000 0 0.000 0.000
#> SRR1223562 5 0.0609 0.776 0 0.000 0 0.020 0.980
#> SRR1223563 2 0.0000 0.908 0 1.000 0 0.000 0.000
#> SRR1223564 5 0.0609 0.776 0 0.000 0 0.020 0.980
#> SRR1223565 2 0.0000 0.908 0 1.000 0 0.000 0.000
#> SRR1223566 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223567 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223568 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223569 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223570 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223571 2 0.3534 0.633 0 0.744 0 0.000 0.256
#> SRR1223572 4 0.0162 0.960 0 0.000 0 0.996 0.004
#> SRR1223573 5 0.3508 0.683 0 0.252 0 0.000 0.748
#> SRR1223574 4 0.0000 0.961 0 0.000 0 1.000 0.000
#> SRR1223575 5 0.2233 0.756 0 0.016 0 0.080 0.904
#> SRR1223576 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR1223578 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223579 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR1223580 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223581 2 0.0000 0.908 0 1.000 0 0.000 0.000
#> SRR1223582 5 0.4201 0.436 0 0.408 0 0.000 0.592
#> SRR1223583 2 0.0000 0.908 0 1.000 0 0.000 0.000
#> SRR1223584 5 0.4242 0.364 0 0.428 0 0.000 0.572
#> SRR1223585 2 0.0000 0.908 0 1.000 0 0.000 0.000
#> SRR1223586 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223587 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223588 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223589 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223590 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223591 2 0.3534 0.633 0 0.744 0 0.000 0.256
#> SRR1223592 4 0.1478 0.962 0 0.000 0 0.936 0.064
#> SRR1223593 5 0.4030 0.545 0 0.352 0 0.000 0.648
#> SRR1223594 4 0.1478 0.962 0 0.000 0 0.936 0.064
#> SRR1223595 5 0.2511 0.763 0 0.028 0 0.080 0.892
#> SRR1223596 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR1223598 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR1223599 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR1223600 1 0.0000 1.000 1 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
#> SRR1223541 2 0.0000 0.916 0 1.000 0 0.000 0.000 0.000
#> SRR1223542 6 0.0405 0.607 0 0.000 0 0.008 0.004 0.988
#> SRR1223543 2 0.0000 0.916 0 1.000 0 0.000 0.000 0.000
#> SRR1223544 6 0.0692 0.614 0 0.020 0 0.004 0.000 0.976
#> SRR1223545 2 0.0000 0.916 0 1.000 0 0.000 0.000 0.000
#> SRR1223546 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223547 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223548 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223549 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223550 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223551 2 0.3163 0.671 0 0.764 0 0.004 0.000 0.232
#> SRR1223552 5 0.0000 1.000 0 0.000 0 0.000 1.000 0.000
#> SRR1223553 6 0.4471 0.205 0 0.472 0 0.028 0.000 0.500
#> SRR1223554 4 0.3747 1.000 0 0.000 0 0.604 0.396 0.000
#> SRR1223555 6 0.3874 0.535 0 0.008 0 0.356 0.000 0.636
#> SRR1223556 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223558 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223559 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223560 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223561 2 0.0000 0.916 0 1.000 0 0.000 0.000 0.000
#> SRR1223562 6 0.4235 0.526 0 0.000 0 0.192 0.084 0.724
#> SRR1223563 2 0.0000 0.916 0 1.000 0 0.000 0.000 0.000
#> SRR1223564 6 0.2724 0.547 0 0.000 0 0.052 0.084 0.864
#> SRR1223565 2 0.0000 0.916 0 1.000 0 0.000 0.000 0.000
#> SRR1223566 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223567 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223568 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223569 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223570 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223571 2 0.2969 0.687 0 0.776 0 0.000 0.000 0.224
#> SRR1223572 4 0.3747 1.000 0 0.000 0 0.604 0.396 0.000
#> SRR1223573 6 0.3833 0.444 0 0.344 0 0.008 0.000 0.648
#> SRR1223574 4 0.3747 1.000 0 0.000 0 0.604 0.396 0.000
#> SRR1223575 6 0.3737 0.505 0 0.000 0 0.392 0.000 0.608
#> SRR1223576 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223578 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223579 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223580 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223581 2 0.0000 0.916 0 1.000 0 0.000 0.000 0.000
#> SRR1223582 6 0.3737 0.339 0 0.392 0 0.000 0.000 0.608
#> SRR1223583 2 0.0000 0.916 0 1.000 0 0.000 0.000 0.000
#> SRR1223584 6 0.3706 0.354 0 0.380 0 0.000 0.000 0.620
#> SRR1223585 2 0.0000 0.916 0 1.000 0 0.000 0.000 0.000
#> SRR1223586 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223587 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223588 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223589 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223590 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223591 2 0.3052 0.691 0 0.780 0 0.004 0.000 0.216
#> SRR1223592 5 0.0000 1.000 0 0.000 0 0.000 1.000 0.000
#> SRR1223593 6 0.4025 0.321 0 0.416 0 0.008 0.000 0.576
#> SRR1223594 5 0.0000 1.000 0 0.000 0 0.000 1.000 0.000
#> SRR1223595 6 0.3874 0.535 0 0.008 0 0.356 0.000 0.636
#> SRR1223596 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223598 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> SRR1223599 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> SRR1223600 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "NMF"]
# you can also extract it by
# res = res_list["CV:NMF"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.5090 0.492 0.492
#> 3 3 1.000 0.978 0.991 0.2184 0.863 0.726
#> 4 4 1.000 0.981 0.992 0.1164 0.919 0.789
#> 5 5 0.877 0.832 0.909 0.0511 0.954 0.855
#> 6 6 0.862 0.768 0.896 0.0420 0.967 0.883
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3
There is also optional best \(k\) = 2 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.000 1.000 0 1.000 0.000
#> SRR1223542 2 0.000 1.000 0 1.000 0.000
#> SRR1223543 2 0.000 1.000 0 1.000 0.000
#> SRR1223544 2 0.000 1.000 0 1.000 0.000
#> SRR1223545 2 0.000 1.000 0 1.000 0.000
#> SRR1223546 1 0.000 1.000 1 0.000 0.000
#> SRR1223547 1 0.000 1.000 1 0.000 0.000
#> SRR1223548 1 0.000 1.000 1 0.000 0.000
#> SRR1223549 1 0.000 1.000 1 0.000 0.000
#> SRR1223550 1 0.000 1.000 1 0.000 0.000
#> SRR1223551 2 0.000 1.000 0 1.000 0.000
#> SRR1223552 2 0.000 1.000 0 1.000 0.000
#> SRR1223553 2 0.000 1.000 0 1.000 0.000
#> SRR1223554 3 0.271 0.867 0 0.088 0.912
#> SRR1223555 2 0.000 1.000 0 1.000 0.000
#> SRR1223556 1 0.000 1.000 1 0.000 0.000
#> SRR1223557 3 0.000 0.932 0 0.000 1.000
#> SRR1223558 1 0.000 1.000 1 0.000 0.000
#> SRR1223559 3 0.000 0.932 0 0.000 1.000
#> SRR1223560 1 0.000 1.000 1 0.000 0.000
#> SRR1223561 2 0.000 1.000 0 1.000 0.000
#> SRR1223562 2 0.000 1.000 0 1.000 0.000
#> SRR1223563 2 0.000 1.000 0 1.000 0.000
#> SRR1223564 2 0.000 1.000 0 1.000 0.000
#> SRR1223565 2 0.000 1.000 0 1.000 0.000
#> SRR1223566 1 0.000 1.000 1 0.000 0.000
#> SRR1223567 1 0.000 1.000 1 0.000 0.000
#> SRR1223568 1 0.000 1.000 1 0.000 0.000
#> SRR1223569 1 0.000 1.000 1 0.000 0.000
#> SRR1223570 1 0.000 1.000 1 0.000 0.000
#> SRR1223571 2 0.000 1.000 0 1.000 0.000
#> SRR1223572 3 0.622 0.265 0 0.432 0.568
#> SRR1223573 2 0.000 1.000 0 1.000 0.000
#> SRR1223574 3 0.000 0.932 0 0.000 1.000
#> SRR1223575 2 0.000 1.000 0 1.000 0.000
#> SRR1223576 1 0.000 1.000 1 0.000 0.000
#> SRR1223577 3 0.000 0.932 0 0.000 1.000
#> SRR1223578 1 0.000 1.000 1 0.000 0.000
#> SRR1223579 3 0.000 0.932 0 0.000 1.000
#> SRR1223580 1 0.000 1.000 1 0.000 0.000
#> SRR1223581 2 0.000 1.000 0 1.000 0.000
#> SRR1223582 2 0.000 1.000 0 1.000 0.000
#> SRR1223583 2 0.000 1.000 0 1.000 0.000
#> SRR1223584 2 0.000 1.000 0 1.000 0.000
#> SRR1223585 2 0.000 1.000 0 1.000 0.000
#> SRR1223586 1 0.000 1.000 1 0.000 0.000
#> SRR1223587 1 0.000 1.000 1 0.000 0.000
#> SRR1223588 1 0.000 1.000 1 0.000 0.000
#> SRR1223589 1 0.000 1.000 1 0.000 0.000
#> SRR1223590 1 0.000 1.000 1 0.000 0.000
#> SRR1223591 2 0.000 1.000 0 1.000 0.000
#> SRR1223592 2 0.000 1.000 0 1.000 0.000
#> SRR1223593 2 0.000 1.000 0 1.000 0.000
#> SRR1223594 2 0.000 1.000 0 1.000 0.000
#> SRR1223595 2 0.000 1.000 0 1.000 0.000
#> SRR1223596 1 0.000 1.000 1 0.000 0.000
#> SRR1223597 3 0.000 0.932 0 0.000 1.000
#> SRR1223598 1 0.000 1.000 1 0.000 0.000
#> SRR1223599 3 0.000 0.932 0 0.000 1.000
#> SRR1223600 1 0.000 1.000 1 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223542 2 0.0592 0.966 0.000 0.984 0.000 0.016
#> SRR1223543 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223544 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223545 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223546 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223547 1 0.0336 0.994 0.992 0.000 0.000 0.008
#> SRR1223548 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223549 1 0.0336 0.994 0.992 0.000 0.000 0.008
#> SRR1223550 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223551 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223552 4 0.0336 0.995 0.000 0.008 0.000 0.992
#> SRR1223553 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223554 4 0.0336 0.989 0.000 0.000 0.008 0.992
#> SRR1223555 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223556 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1223558 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223559 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1223560 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223561 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223562 4 0.0336 0.995 0.000 0.008 0.000 0.992
#> SRR1223563 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223564 4 0.0469 0.990 0.000 0.012 0.000 0.988
#> SRR1223565 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223566 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223567 1 0.0336 0.994 0.992 0.000 0.000 0.008
#> SRR1223568 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223569 1 0.0336 0.994 0.992 0.000 0.000 0.008
#> SRR1223570 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223571 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223572 4 0.0376 0.993 0.000 0.004 0.004 0.992
#> SRR1223573 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223574 4 0.0336 0.989 0.000 0.000 0.008 0.992
#> SRR1223575 2 0.4776 0.392 0.000 0.624 0.000 0.376
#> SRR1223576 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1223578 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223579 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1223580 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223581 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223582 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223583 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223584 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223585 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223586 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223587 1 0.0188 0.996 0.996 0.000 0.000 0.004
#> SRR1223588 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223589 1 0.0336 0.994 0.992 0.000 0.000 0.008
#> SRR1223590 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223591 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223592 4 0.0336 0.995 0.000 0.008 0.000 0.992
#> SRR1223593 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223594 4 0.0336 0.995 0.000 0.008 0.000 0.992
#> SRR1223595 2 0.0000 0.980 0.000 1.000 0.000 0.000
#> SRR1223596 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1223598 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> SRR1223599 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1223600 1 0.0000 0.998 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
#> SRR1223541 2 0.0000 0.95891 0.000 1.000 0.000 0.000 0.000
#> SRR1223542 5 0.6605 0.40767 0.000 0.348 0.000 0.220 0.432
#> SRR1223543 2 0.0000 0.95891 0.000 1.000 0.000 0.000 0.000
#> SRR1223544 5 0.6192 0.37290 0.000 0.432 0.000 0.136 0.432
#> SRR1223545 2 0.0000 0.95891 0.000 1.000 0.000 0.000 0.000
#> SRR1223546 1 0.0000 0.95259 1.000 0.000 0.000 0.000 0.000
#> SRR1223547 1 0.3266 0.82416 0.796 0.000 0.004 0.000 0.200
#> SRR1223548 1 0.0000 0.95259 1.000 0.000 0.000 0.000 0.000
#> SRR1223549 1 0.3266 0.82416 0.796 0.000 0.004 0.000 0.200
#> SRR1223550 1 0.0000 0.95259 1.000 0.000 0.000 0.000 0.000
#> SRR1223551 2 0.0000 0.95891 0.000 1.000 0.000 0.000 0.000
#> SRR1223552 4 0.0162 0.65894 0.000 0.000 0.000 0.996 0.004
#> SRR1223553 2 0.0162 0.95648 0.000 0.996 0.000 0.004 0.000
#> SRR1223554 4 0.2471 0.58414 0.000 0.000 0.000 0.864 0.136
#> SRR1223555 2 0.4743 0.60564 0.000 0.732 0.000 0.156 0.112
#> SRR1223556 1 0.0000 0.95259 1.000 0.000 0.000 0.000 0.000
#> SRR1223557 3 0.0000 1.00000 0.000 0.000 1.000 0.000 0.000
#> SRR1223558 1 0.0000 0.95259 1.000 0.000 0.000 0.000 0.000
#> SRR1223559 3 0.0000 1.00000 0.000 0.000 1.000 0.000 0.000
#> SRR1223560 1 0.0510 0.94667 0.984 0.000 0.000 0.000 0.016
#> SRR1223561 2 0.0000 0.95891 0.000 1.000 0.000 0.000 0.000
#> SRR1223562 5 0.4306 0.04984 0.000 0.000 0.000 0.492 0.508
#> SRR1223563 2 0.0000 0.95891 0.000 1.000 0.000 0.000 0.000
#> SRR1223564 5 0.4306 0.04984 0.000 0.000 0.000 0.492 0.508
#> SRR1223565 2 0.0000 0.95891 0.000 1.000 0.000 0.000 0.000
#> SRR1223566 1 0.0000 0.95259 1.000 0.000 0.000 0.000 0.000
#> SRR1223567 1 0.4555 0.76099 0.732 0.000 0.068 0.000 0.200
#> SRR1223568 1 0.0000 0.95259 1.000 0.000 0.000 0.000 0.000
#> SRR1223569 1 0.4433 0.77035 0.740 0.000 0.060 0.000 0.200
#> SRR1223570 1 0.0000 0.95259 1.000 0.000 0.000 0.000 0.000
#> SRR1223571 2 0.0000 0.95891 0.000 1.000 0.000 0.000 0.000
#> SRR1223572 4 0.1792 0.62925 0.000 0.000 0.000 0.916 0.084
#> SRR1223573 2 0.0794 0.93369 0.000 0.972 0.000 0.028 0.000
#> SRR1223574 4 0.4045 0.30808 0.000 0.000 0.000 0.644 0.356
#> SRR1223575 4 0.5865 0.00133 0.000 0.332 0.000 0.552 0.116
#> SRR1223576 1 0.0000 0.95259 1.000 0.000 0.000 0.000 0.000
#> SRR1223577 3 0.0000 1.00000 0.000 0.000 1.000 0.000 0.000
#> SRR1223578 1 0.0000 0.95259 1.000 0.000 0.000 0.000 0.000
#> SRR1223579 3 0.0000 1.00000 0.000 0.000 1.000 0.000 0.000
#> SRR1223580 1 0.0510 0.94667 0.984 0.000 0.000 0.000 0.016
#> SRR1223581 2 0.0000 0.95891 0.000 1.000 0.000 0.000 0.000
#> SRR1223582 2 0.0162 0.95602 0.000 0.996 0.000 0.000 0.004
#> SRR1223583 2 0.0000 0.95891 0.000 1.000 0.000 0.000 0.000
#> SRR1223584 2 0.0609 0.94024 0.000 0.980 0.000 0.000 0.020
#> SRR1223585 2 0.0000 0.95891 0.000 1.000 0.000 0.000 0.000
#> SRR1223586 1 0.0000 0.95259 1.000 0.000 0.000 0.000 0.000
#> SRR1223587 1 0.1478 0.92032 0.936 0.000 0.000 0.000 0.064
#> SRR1223588 1 0.0000 0.95259 1.000 0.000 0.000 0.000 0.000
#> SRR1223589 1 0.2561 0.86935 0.856 0.000 0.000 0.000 0.144
#> SRR1223590 1 0.0290 0.94998 0.992 0.000 0.000 0.000 0.008
#> SRR1223591 2 0.0000 0.95891 0.000 1.000 0.000 0.000 0.000
#> SRR1223592 4 0.2248 0.64231 0.000 0.012 0.000 0.900 0.088
#> SRR1223593 2 0.0162 0.95648 0.000 0.996 0.000 0.004 0.000
#> SRR1223594 4 0.2077 0.64654 0.000 0.008 0.000 0.908 0.084
#> SRR1223595 2 0.4704 0.61325 0.000 0.736 0.000 0.152 0.112
#> SRR1223596 1 0.0000 0.95259 1.000 0.000 0.000 0.000 0.000
#> SRR1223597 3 0.0000 1.00000 0.000 0.000 1.000 0.000 0.000
#> SRR1223598 1 0.0290 0.94998 0.992 0.000 0.000 0.000 0.008
#> SRR1223599 3 0.0000 1.00000 0.000 0.000 1.000 0.000 0.000
#> SRR1223600 1 0.0510 0.94667 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
#> SRR1223541 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1223542 6 0.2446 0.533 0.000 0.124 0.000 0.012 0.000 0.864
#> SRR1223543 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1223544 6 0.2362 0.519 0.000 0.136 0.000 0.004 0.000 0.860
#> SRR1223545 2 0.0692 0.965 0.000 0.976 0.000 0.020 0.000 0.004
#> SRR1223546 1 0.0000 0.914 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223547 1 0.3592 0.657 0.656 0.000 0.000 0.000 0.344 0.000
#> SRR1223548 1 0.0405 0.912 0.988 0.000 0.000 0.004 0.008 0.000
#> SRR1223549 1 0.3592 0.657 0.656 0.000 0.000 0.000 0.344 0.000
#> SRR1223550 1 0.0000 0.914 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223551 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1223552 4 0.4704 0.272 0.000 0.000 0.000 0.628 0.300 0.072
#> SRR1223553 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1223554 6 0.5949 -0.712 0.000 0.000 0.000 0.236 0.320 0.444
#> SRR1223555 4 0.3508 0.388 0.000 0.292 0.000 0.704 0.000 0.004
#> SRR1223556 1 0.0000 0.914 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223557 3 0.0260 0.992 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1223558 1 0.0146 0.913 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR1223559 3 0.0260 0.992 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1223560 1 0.1124 0.896 0.956 0.000 0.000 0.008 0.036 0.000
#> SRR1223561 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1223562 6 0.0363 0.505 0.000 0.000 0.000 0.012 0.000 0.988
#> SRR1223563 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1223564 6 0.0363 0.505 0.000 0.000 0.000 0.012 0.000 0.988
#> SRR1223565 2 0.2738 0.777 0.000 0.820 0.000 0.176 0.000 0.004
#> SRR1223566 1 0.0000 0.914 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223567 1 0.4948 0.538 0.564 0.000 0.076 0.000 0.360 0.000
#> SRR1223568 1 0.0291 0.913 0.992 0.000 0.000 0.004 0.004 0.000
#> SRR1223569 1 0.4808 0.556 0.576 0.000 0.064 0.000 0.360 0.000
#> SRR1223570 1 0.0000 0.914 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223571 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1223572 4 0.5748 -0.122 0.000 0.000 0.000 0.492 0.316 0.192
#> SRR1223573 2 0.0520 0.969 0.000 0.984 0.000 0.008 0.008 0.000
#> SRR1223574 5 0.5190 0.000 0.000 0.000 0.000 0.088 0.464 0.448
#> SRR1223575 4 0.2491 0.411 0.000 0.112 0.000 0.868 0.000 0.020
#> SRR1223576 1 0.0000 0.914 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223577 3 0.0260 0.989 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1223578 1 0.0000 0.914 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223579 3 0.0260 0.989 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1223580 1 0.1265 0.895 0.948 0.000 0.000 0.008 0.044 0.000
#> SRR1223581 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1223582 2 0.0632 0.964 0.000 0.976 0.000 0.000 0.000 0.024
#> SRR1223583 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1223584 2 0.0937 0.950 0.000 0.960 0.000 0.000 0.000 0.040
#> SRR1223585 2 0.0146 0.978 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1223586 1 0.0000 0.914 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223587 1 0.1765 0.866 0.904 0.000 0.000 0.000 0.096 0.000
#> SRR1223588 1 0.0146 0.913 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR1223589 1 0.3265 0.747 0.748 0.000 0.000 0.004 0.248 0.000
#> SRR1223590 1 0.0260 0.912 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR1223591 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1223592 4 0.3790 0.357 0.000 0.004 0.000 0.716 0.264 0.016
#> SRR1223593 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1223594 4 0.4236 0.316 0.000 0.000 0.000 0.656 0.308 0.036
#> SRR1223595 4 0.3508 0.388 0.000 0.292 0.000 0.704 0.000 0.004
#> SRR1223596 1 0.0000 0.914 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223597 3 0.0146 0.991 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1223598 1 0.0405 0.911 0.988 0.000 0.000 0.004 0.008 0.000
#> SRR1223599 3 0.0363 0.991 0.000 0.000 0.988 0.000 0.012 0.000
#> SRR1223600 1 0.1265 0.895 0.948 0.000 0.000 0.008 0.044 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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.5090 0.492 0.492
#> 3 3 0.902 0.992 0.973 0.1742 0.893 0.783
#> 4 4 0.818 0.901 0.935 0.0683 0.995 0.988
#> 5 5 1.000 0.983 1.000 0.0986 0.919 0.786
#> 6 6 0.939 0.933 0.955 0.0301 0.992 0.972
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 2 3
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
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.000 1.000 0 1.0 0.0
#> SRR1223542 2 0.000 1.000 0 1.0 0.0
#> SRR1223543 2 0.000 1.000 0 1.0 0.0
#> SRR1223544 2 0.000 1.000 0 1.0 0.0
#> SRR1223545 2 0.000 1.000 0 1.0 0.0
#> SRR1223546 1 0.000 1.000 1 0.0 0.0
#> SRR1223547 1 0.000 1.000 1 0.0 0.0
#> SRR1223548 1 0.000 1.000 1 0.0 0.0
#> SRR1223549 1 0.000 1.000 1 0.0 0.0
#> SRR1223550 1 0.000 1.000 1 0.0 0.0
#> SRR1223551 2 0.000 1.000 0 1.0 0.0
#> SRR1223552 3 0.455 0.969 0 0.2 0.8
#> SRR1223553 2 0.000 1.000 0 1.0 0.0
#> SRR1223554 3 0.455 0.969 0 0.2 0.8
#> SRR1223555 3 0.455 0.969 0 0.2 0.8
#> SRR1223556 1 0.000 1.000 1 0.0 0.0
#> SRR1223557 1 0.000 1.000 1 0.0 0.0
#> SRR1223558 1 0.000 1.000 1 0.0 0.0
#> SRR1223559 1 0.000 1.000 1 0.0 0.0
#> SRR1223560 1 0.000 1.000 1 0.0 0.0
#> SRR1223561 2 0.000 1.000 0 1.0 0.0
#> SRR1223562 2 0.000 1.000 0 1.0 0.0
#> SRR1223563 2 0.000 1.000 0 1.0 0.0
#> SRR1223564 2 0.000 1.000 0 1.0 0.0
#> SRR1223565 2 0.000 1.000 0 1.0 0.0
#> SRR1223566 1 0.000 1.000 1 0.0 0.0
#> SRR1223567 1 0.000 1.000 1 0.0 0.0
#> SRR1223568 1 0.000 1.000 1 0.0 0.0
#> SRR1223569 1 0.000 1.000 1 0.0 0.0
#> SRR1223570 1 0.000 1.000 1 0.0 0.0
#> SRR1223571 2 0.000 1.000 0 1.0 0.0
#> SRR1223572 3 0.455 0.969 0 0.2 0.8
#> SRR1223573 2 0.000 1.000 0 1.0 0.0
#> SRR1223574 3 0.000 0.780 0 0.0 1.0
#> SRR1223575 3 0.455 0.969 0 0.2 0.8
#> SRR1223576 1 0.000 1.000 1 0.0 0.0
#> SRR1223577 1 0.000 1.000 1 0.0 0.0
#> SRR1223578 1 0.000 1.000 1 0.0 0.0
#> SRR1223579 1 0.000 1.000 1 0.0 0.0
#> SRR1223580 1 0.000 1.000 1 0.0 0.0
#> SRR1223581 2 0.000 1.000 0 1.0 0.0
#> SRR1223582 2 0.000 1.000 0 1.0 0.0
#> SRR1223583 2 0.000 1.000 0 1.0 0.0
#> SRR1223584 2 0.000 1.000 0 1.0 0.0
#> SRR1223585 2 0.000 1.000 0 1.0 0.0
#> SRR1223586 1 0.000 1.000 1 0.0 0.0
#> SRR1223587 1 0.000 1.000 1 0.0 0.0
#> SRR1223588 1 0.000 1.000 1 0.0 0.0
#> SRR1223589 1 0.000 1.000 1 0.0 0.0
#> SRR1223590 1 0.000 1.000 1 0.0 0.0
#> SRR1223591 2 0.000 1.000 0 1.0 0.0
#> SRR1223592 3 0.455 0.969 0 0.2 0.8
#> SRR1223593 2 0.000 1.000 0 1.0 0.0
#> SRR1223594 3 0.455 0.969 0 0.2 0.8
#> SRR1223595 3 0.455 0.969 0 0.2 0.8
#> SRR1223596 1 0.000 1.000 1 0.0 0.0
#> SRR1223597 1 0.000 1.000 1 0.0 0.0
#> SRR1223598 1 0.000 1.000 1 0.0 0.0
#> SRR1223599 1 0.000 1.000 1 0.0 0.0
#> SRR1223600 1 0.000 1.000 1 0.0 0.0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223542 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223543 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223544 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223545 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223546 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223547 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223548 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223549 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223550 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223551 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223552 4 0.302 1.000 0.000 0.148 0.000 0.852
#> SRR1223553 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223554 4 0.302 1.000 0.000 0.148 0.000 0.852
#> SRR1223555 4 0.302 1.000 0.000 0.148 0.000 0.852
#> SRR1223556 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223557 1 0.489 0.531 0.588 0.000 0.412 0.000
#> SRR1223558 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223559 1 0.489 0.531 0.588 0.000 0.412 0.000
#> SRR1223560 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223561 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223562 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223563 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223564 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223565 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223566 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223567 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223568 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223569 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223570 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223571 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223572 4 0.302 1.000 0.000 0.148 0.000 0.852
#> SRR1223573 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223574 3 0.489 0.000 0.000 0.000 0.588 0.412
#> SRR1223575 4 0.302 1.000 0.000 0.148 0.000 0.852
#> SRR1223576 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223577 1 0.489 0.531 0.588 0.000 0.412 0.000
#> SRR1223578 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223579 1 0.489 0.531 0.588 0.000 0.412 0.000
#> SRR1223580 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223581 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223582 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223583 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223584 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223585 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223586 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223587 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223588 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223589 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223590 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223591 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223592 4 0.302 1.000 0.000 0.148 0.000 0.852
#> SRR1223593 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1223594 4 0.302 1.000 0.000 0.148 0.000 0.852
#> SRR1223595 4 0.302 1.000 0.000 0.148 0.000 0.852
#> SRR1223596 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223597 1 0.489 0.531 0.588 0.000 0.412 0.000
#> SRR1223598 1 0.000 0.911 1.000 0.000 0.000 0.000
#> SRR1223599 1 0.489 0.531 0.588 0.000 0.412 0.000
#> SRR1223600 1 0.000 0.911 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
#> SRR1223541 2 0 1 0 1 0 0 0
#> SRR1223542 2 0 1 0 1 0 0 0
#> SRR1223543 2 0 1 0 1 0 0 0
#> SRR1223544 2 0 1 0 1 0 0 0
#> SRR1223545 2 0 1 0 1 0 0 0
#> SRR1223546 1 0 1 1 0 0 0 0
#> SRR1223547 1 0 1 1 0 0 0 0
#> SRR1223548 1 0 1 1 0 0 0 0
#> SRR1223549 1 0 1 1 0 0 0 0
#> SRR1223550 1 0 1 1 0 0 0 0
#> SRR1223551 2 0 1 0 1 0 0 0
#> SRR1223552 4 0 1 0 0 0 1 0
#> SRR1223553 2 0 1 0 1 0 0 0
#> SRR1223554 4 0 1 0 0 0 1 0
#> SRR1223555 4 0 1 0 0 0 1 0
#> SRR1223556 1 0 1 1 0 0 0 0
#> SRR1223557 3 0 1 0 0 1 0 0
#> SRR1223558 1 0 1 1 0 0 0 0
#> SRR1223559 3 0 1 0 0 1 0 0
#> SRR1223560 1 0 1 1 0 0 0 0
#> SRR1223561 2 0 1 0 1 0 0 0
#> SRR1223562 2 0 1 0 1 0 0 0
#> SRR1223563 2 0 1 0 1 0 0 0
#> SRR1223564 2 0 1 0 1 0 0 0
#> SRR1223565 2 0 1 0 1 0 0 0
#> SRR1223566 1 0 1 1 0 0 0 0
#> SRR1223567 1 0 1 1 0 0 0 0
#> SRR1223568 1 0 1 1 0 0 0 0
#> SRR1223569 1 0 1 1 0 0 0 0
#> SRR1223570 1 0 1 1 0 0 0 0
#> SRR1223571 2 0 1 0 1 0 0 0
#> SRR1223572 4 0 1 0 0 0 1 0
#> SRR1223573 2 0 1 0 1 0 0 0
#> SRR1223574 5 0 0 0 0 0 0 1
#> SRR1223575 4 0 1 0 0 0 1 0
#> SRR1223576 1 0 1 1 0 0 0 0
#> SRR1223577 3 0 1 0 0 1 0 0
#> SRR1223578 1 0 1 1 0 0 0 0
#> SRR1223579 3 0 1 0 0 1 0 0
#> SRR1223580 1 0 1 1 0 0 0 0
#> SRR1223581 2 0 1 0 1 0 0 0
#> SRR1223582 2 0 1 0 1 0 0 0
#> SRR1223583 2 0 1 0 1 0 0 0
#> SRR1223584 2 0 1 0 1 0 0 0
#> SRR1223585 2 0 1 0 1 0 0 0
#> SRR1223586 1 0 1 1 0 0 0 0
#> SRR1223587 1 0 1 1 0 0 0 0
#> SRR1223588 1 0 1 1 0 0 0 0
#> SRR1223589 1 0 1 1 0 0 0 0
#> SRR1223590 1 0 1 1 0 0 0 0
#> SRR1223591 2 0 1 0 1 0 0 0
#> SRR1223592 4 0 1 0 0 0 1 0
#> SRR1223593 2 0 1 0 1 0 0 0
#> SRR1223594 4 0 1 0 0 0 1 0
#> SRR1223595 4 0 1 0 0 0 1 0
#> SRR1223596 1 0 1 1 0 0 0 0
#> SRR1223597 3 0 1 0 0 1 0 0
#> SRR1223598 1 0 1 1 0 0 0 0
#> SRR1223599 3 0 1 0 0 1 0 0
#> SRR1223600 1 0 1 1 0 0 0 0
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.0000 0.905 0 1.000 0 0.000 0.000 0
#> SRR1223542 2 0.3390 0.739 0 0.704 0 0.296 0.000 0
#> SRR1223543 2 0.0000 0.905 0 1.000 0 0.000 0.000 0
#> SRR1223544 2 0.3390 0.739 0 0.704 0 0.296 0.000 0
#> SRR1223545 2 0.0458 0.901 0 0.984 0 0.016 0.000 0
#> SRR1223546 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223547 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223548 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223549 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223550 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223551 2 0.0000 0.905 0 1.000 0 0.000 0.000 0
#> SRR1223552 4 0.3390 1.000 0 0.000 0 0.704 0.296 0
#> SRR1223553 2 0.0000 0.905 0 1.000 0 0.000 0.000 0
#> SRR1223554 4 0.3390 1.000 0 0.000 0 0.704 0.296 0
#> SRR1223555 5 0.0000 1.000 0 0.000 0 0.000 1.000 0
#> SRR1223556 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223557 3 0.0000 1.000 0 0.000 1 0.000 0.000 0
#> SRR1223558 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223559 3 0.0000 1.000 0 0.000 1 0.000 0.000 0
#> SRR1223560 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223561 2 0.0000 0.905 0 1.000 0 0.000 0.000 0
#> SRR1223562 2 0.3390 0.739 0 0.704 0 0.296 0.000 0
#> SRR1223563 2 0.0000 0.905 0 1.000 0 0.000 0.000 0
#> SRR1223564 2 0.3390 0.739 0 0.704 0 0.296 0.000 0
#> SRR1223565 2 0.0458 0.901 0 0.984 0 0.016 0.000 0
#> SRR1223566 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223567 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223568 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223569 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223570 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223571 2 0.0000 0.905 0 1.000 0 0.000 0.000 0
#> SRR1223572 4 0.3390 1.000 0 0.000 0 0.704 0.296 0
#> SRR1223573 2 0.0000 0.905 0 1.000 0 0.000 0.000 0
#> SRR1223574 6 0.0000 0.000 0 0.000 0 0.000 0.000 1
#> SRR1223575 5 0.0000 1.000 0 0.000 0 0.000 1.000 0
#> SRR1223576 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223577 3 0.0000 1.000 0 0.000 1 0.000 0.000 0
#> SRR1223578 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223579 3 0.0000 1.000 0 0.000 1 0.000 0.000 0
#> SRR1223580 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223581 2 0.0000 0.905 0 1.000 0 0.000 0.000 0
#> SRR1223582 2 0.3390 0.739 0 0.704 0 0.296 0.000 0
#> SRR1223583 2 0.0000 0.905 0 1.000 0 0.000 0.000 0
#> SRR1223584 2 0.3390 0.739 0 0.704 0 0.296 0.000 0
#> SRR1223585 2 0.0458 0.901 0 0.984 0 0.016 0.000 0
#> SRR1223586 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223587 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223588 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223589 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223590 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223591 2 0.0000 0.905 0 1.000 0 0.000 0.000 0
#> SRR1223592 4 0.3390 1.000 0 0.000 0 0.704 0.296 0
#> SRR1223593 2 0.0000 0.905 0 1.000 0 0.000 0.000 0
#> SRR1223594 4 0.3390 1.000 0 0.000 0 0.704 0.296 0
#> SRR1223595 5 0.0000 1.000 0 0.000 0 0.000 1.000 0
#> SRR1223596 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223597 3 0.0000 1.000 0 0.000 1 0.000 0.000 0
#> SRR1223598 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1223599 3 0.0000 1.000 0 0.000 1 0.000 0.000 0
#> SRR1223600 1 0.0000 1.000 1 0.000 0 0.000 0.000 0
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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.5090 0.492 0.492
#> 3 3 0.812 0.922 0.878 0.1852 0.893 0.783
#> 4 4 0.649 0.552 0.660 0.1160 0.893 0.722
#> 5 5 0.653 0.806 0.832 0.0846 0.873 0.641
#> 6 6 0.807 0.785 0.789 0.0598 0.924 0.749
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
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223542 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223543 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223544 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223545 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223546 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223547 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223548 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223549 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223550 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223551 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223552 3 0.631 1.000 0.000 0.488 0.512
#> SRR1223553 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223554 3 0.631 1.000 0.000 0.488 0.512
#> SRR1223555 3 0.631 1.000 0.000 0.488 0.512
#> SRR1223556 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223557 1 0.631 0.569 0.512 0.000 0.488
#> SRR1223558 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223559 1 0.631 0.569 0.512 0.000 0.488
#> SRR1223560 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223561 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223562 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223563 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223564 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223565 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223566 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223567 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223568 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223569 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223570 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223571 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223572 3 0.631 1.000 0.000 0.488 0.512
#> SRR1223573 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223574 3 0.631 1.000 0.000 0.488 0.512
#> SRR1223575 3 0.631 1.000 0.000 0.488 0.512
#> SRR1223576 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223577 1 0.631 0.569 0.512 0.000 0.488
#> SRR1223578 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223579 1 0.631 0.569 0.512 0.000 0.488
#> SRR1223580 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223581 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223582 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223583 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223584 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223585 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223586 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223587 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223588 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223589 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223590 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223591 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223592 3 0.631 1.000 0.000 0.488 0.512
#> SRR1223593 2 0.000 1.000 0.000 1.000 0.000
#> SRR1223594 3 0.631 1.000 0.000 0.488 0.512
#> SRR1223595 3 0.631 1.000 0.000 0.488 0.512
#> SRR1223596 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223597 1 0.631 0.569 0.512 0.000 0.488
#> SRR1223598 1 0.000 0.912 1.000 0.000 0.000
#> SRR1223599 1 0.631 0.569 0.512 0.000 0.488
#> SRR1223600 1 0.000 0.912 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.4193 0.898 0.000 0.732 0.000 0.268
#> SRR1223542 2 0.7491 0.796 0.000 0.500 0.232 0.268
#> SRR1223543 2 0.4748 0.896 0.000 0.716 0.016 0.268
#> SRR1223544 2 0.7554 0.791 0.000 0.488 0.244 0.268
#> SRR1223545 2 0.6851 0.860 0.000 0.584 0.148 0.268
#> SRR1223546 1 0.4933 -0.103 0.568 0.000 0.432 0.000
#> SRR1223547 3 0.4543 0.843 0.324 0.000 0.676 0.000
#> SRR1223548 1 0.4933 -0.103 0.568 0.000 0.432 0.000
#> SRR1223549 3 0.4543 0.843 0.324 0.000 0.676 0.000
#> SRR1223550 1 0.4933 -0.103 0.568 0.000 0.432 0.000
#> SRR1223551 2 0.4401 0.897 0.000 0.724 0.004 0.272
#> SRR1223552 4 0.0000 0.971 0.000 0.000 0.000 1.000
#> SRR1223553 2 0.4511 0.898 0.000 0.724 0.008 0.268
#> SRR1223554 4 0.2469 0.913 0.000 0.000 0.108 0.892
#> SRR1223555 4 0.0469 0.970 0.000 0.000 0.012 0.988
#> SRR1223556 1 0.4933 -0.103 0.568 0.000 0.432 0.000
#> SRR1223557 1 0.4103 0.170 0.744 0.256 0.000 0.000
#> SRR1223558 1 0.4933 -0.103 0.568 0.000 0.432 0.000
#> SRR1223559 1 0.4103 0.170 0.744 0.256 0.000 0.000
#> SRR1223560 3 0.5285 0.596 0.468 0.008 0.524 0.000
#> SRR1223561 2 0.4193 0.898 0.000 0.732 0.000 0.268
#> SRR1223562 2 0.7491 0.796 0.000 0.500 0.232 0.268
#> SRR1223563 2 0.4748 0.896 0.000 0.716 0.016 0.268
#> SRR1223564 2 0.7554 0.791 0.000 0.488 0.244 0.268
#> SRR1223565 2 0.6851 0.860 0.000 0.584 0.148 0.268
#> SRR1223566 1 0.4933 -0.103 0.568 0.000 0.432 0.000
#> SRR1223567 3 0.4543 0.843 0.324 0.000 0.676 0.000
#> SRR1223568 1 0.4933 -0.103 0.568 0.000 0.432 0.000
#> SRR1223569 3 0.4543 0.843 0.324 0.000 0.676 0.000
#> SRR1223570 1 0.4933 -0.103 0.568 0.000 0.432 0.000
#> SRR1223571 2 0.4401 0.897 0.000 0.724 0.004 0.272
#> SRR1223572 4 0.0188 0.970 0.000 0.000 0.004 0.996
#> SRR1223573 2 0.4401 0.897 0.000 0.724 0.004 0.272
#> SRR1223574 4 0.2469 0.913 0.000 0.000 0.108 0.892
#> SRR1223575 4 0.0592 0.969 0.000 0.000 0.016 0.984
#> SRR1223576 1 0.4933 -0.103 0.568 0.000 0.432 0.000
#> SRR1223577 1 0.4008 0.171 0.756 0.244 0.000 0.000
#> SRR1223578 1 0.4933 -0.103 0.568 0.000 0.432 0.000
#> SRR1223579 1 0.4008 0.171 0.756 0.244 0.000 0.000
#> SRR1223580 3 0.5285 0.596 0.468 0.008 0.524 0.000
#> SRR1223581 2 0.4193 0.898 0.000 0.732 0.000 0.268
#> SRR1223582 2 0.7072 0.842 0.000 0.560 0.172 0.268
#> SRR1223583 2 0.4748 0.896 0.000 0.716 0.016 0.268
#> SRR1223584 2 0.7105 0.842 0.000 0.556 0.176 0.268
#> SRR1223585 2 0.6501 0.872 0.000 0.616 0.116 0.268
#> SRR1223586 1 0.4933 -0.103 0.568 0.000 0.432 0.000
#> SRR1223587 3 0.4543 0.843 0.324 0.000 0.676 0.000
#> SRR1223588 1 0.4933 -0.103 0.568 0.000 0.432 0.000
#> SRR1223589 3 0.4543 0.843 0.324 0.000 0.676 0.000
#> SRR1223590 1 0.4933 -0.103 0.568 0.000 0.432 0.000
#> SRR1223591 2 0.4401 0.897 0.000 0.724 0.004 0.272
#> SRR1223592 4 0.0188 0.970 0.000 0.000 0.004 0.996
#> SRR1223593 2 0.4401 0.897 0.000 0.724 0.004 0.272
#> SRR1223594 4 0.0188 0.970 0.000 0.000 0.004 0.996
#> SRR1223595 4 0.0469 0.970 0.000 0.000 0.012 0.988
#> SRR1223596 1 0.4933 -0.103 0.568 0.000 0.432 0.000
#> SRR1223597 1 0.4040 0.170 0.752 0.248 0.000 0.000
#> SRR1223598 1 0.4933 -0.103 0.568 0.000 0.432 0.000
#> SRR1223599 1 0.4040 0.170 0.752 0.248 0.000 0.000
#> SRR1223600 3 0.5285 0.596 0.468 0.008 0.524 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.0162 0.834 0.000 0.996 0.004 0.000 NA
#> SRR1223542 2 0.4480 0.686 0.000 0.592 0.004 0.004 NA
#> SRR1223543 2 0.0898 0.832 0.000 0.972 0.008 0.000 NA
#> SRR1223544 2 0.4219 0.688 0.000 0.584 0.000 0.000 NA
#> SRR1223545 2 0.4305 0.776 0.000 0.748 0.052 0.000 NA
#> SRR1223546 1 0.0000 0.817 1.000 0.000 0.000 0.000 NA
#> SRR1223547 1 0.4528 0.550 0.548 0.000 0.000 0.008 NA
#> SRR1223548 1 0.1670 0.801 0.936 0.000 0.000 0.052 NA
#> SRR1223549 1 0.4632 0.544 0.540 0.000 0.000 0.012 NA
#> SRR1223550 1 0.0451 0.815 0.988 0.000 0.000 0.004 NA
#> SRR1223551 2 0.1173 0.830 0.000 0.964 0.012 0.004 NA
#> SRR1223552 4 0.3320 0.938 0.000 0.124 0.016 0.844 NA
#> SRR1223553 2 0.1195 0.832 0.000 0.960 0.012 0.000 NA
#> SRR1223554 4 0.6193 0.849 0.000 0.124 0.088 0.668 NA
#> SRR1223555 4 0.3107 0.938 0.000 0.124 0.008 0.852 NA
#> SRR1223556 1 0.0000 0.817 1.000 0.000 0.000 0.000 NA
#> SRR1223557 3 0.3439 0.993 0.188 0.000 0.800 0.008 NA
#> SRR1223558 1 0.0000 0.817 1.000 0.000 0.000 0.000 NA
#> SRR1223559 3 0.3439 0.993 0.188 0.000 0.800 0.008 NA
#> SRR1223560 1 0.4547 0.705 0.736 0.000 0.000 0.072 NA
#> SRR1223561 2 0.0162 0.834 0.000 0.996 0.004 0.000 NA
#> SRR1223562 2 0.4480 0.686 0.000 0.592 0.004 0.004 NA
#> SRR1223563 2 0.0898 0.832 0.000 0.972 0.008 0.000 NA
#> SRR1223564 2 0.4375 0.680 0.000 0.576 0.000 0.004 NA
#> SRR1223565 2 0.4305 0.776 0.000 0.748 0.052 0.000 NA
#> SRR1223566 1 0.0000 0.817 1.000 0.000 0.000 0.000 NA
#> SRR1223567 1 0.4528 0.550 0.548 0.000 0.000 0.008 NA
#> SRR1223568 1 0.1670 0.801 0.936 0.000 0.000 0.052 NA
#> SRR1223569 1 0.4538 0.544 0.540 0.000 0.000 0.008 NA
#> SRR1223570 1 0.0451 0.815 0.988 0.000 0.000 0.004 NA
#> SRR1223571 2 0.1173 0.830 0.000 0.964 0.012 0.004 NA
#> SRR1223572 4 0.3416 0.938 0.000 0.124 0.020 0.840 NA
#> SRR1223573 2 0.1173 0.830 0.000 0.964 0.012 0.004 NA
#> SRR1223574 4 0.6193 0.849 0.000 0.124 0.088 0.668 NA
#> SRR1223575 4 0.3203 0.938 0.000 0.124 0.008 0.848 NA
#> SRR1223576 1 0.0000 0.817 1.000 0.000 0.000 0.000 NA
#> SRR1223577 3 0.3003 0.996 0.188 0.000 0.812 0.000 NA
#> SRR1223578 1 0.0000 0.817 1.000 0.000 0.000 0.000 NA
#> SRR1223579 3 0.3003 0.996 0.188 0.000 0.812 0.000 NA
#> SRR1223580 1 0.4547 0.705 0.736 0.000 0.000 0.072 NA
#> SRR1223581 2 0.0162 0.834 0.000 0.996 0.004 0.000 NA
#> SRR1223582 2 0.4118 0.732 0.000 0.660 0.004 0.000 NA
#> SRR1223583 2 0.0898 0.832 0.000 0.972 0.008 0.000 NA
#> SRR1223584 2 0.4045 0.729 0.000 0.644 0.000 0.000 NA
#> SRR1223585 2 0.3983 0.787 0.000 0.784 0.052 0.000 NA
#> SRR1223586 1 0.0000 0.817 1.000 0.000 0.000 0.000 NA
#> SRR1223587 1 0.4528 0.550 0.548 0.000 0.000 0.008 NA
#> SRR1223588 1 0.1670 0.801 0.936 0.000 0.000 0.052 NA
#> SRR1223589 1 0.4632 0.544 0.540 0.000 0.000 0.012 NA
#> SRR1223590 1 0.0451 0.815 0.988 0.000 0.000 0.004 NA
#> SRR1223591 2 0.1173 0.830 0.000 0.964 0.012 0.004 NA
#> SRR1223592 4 0.3692 0.934 0.000 0.124 0.024 0.828 NA
#> SRR1223593 2 0.1074 0.831 0.000 0.968 0.012 0.004 NA
#> SRR1223594 4 0.3692 0.934 0.000 0.124 0.024 0.828 NA
#> SRR1223595 4 0.3107 0.938 0.000 0.124 0.008 0.852 NA
#> SRR1223596 1 0.0000 0.817 1.000 0.000 0.000 0.000 NA
#> SRR1223597 3 0.3160 0.995 0.188 0.000 0.808 0.000 NA
#> SRR1223598 1 0.0000 0.817 1.000 0.000 0.000 0.000 NA
#> SRR1223599 3 0.3160 0.995 0.188 0.000 0.808 0.000 NA
#> SRR1223600 1 0.4547 0.705 0.736 0.000 0.000 0.072 NA
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.0291 0.772 0.000 0.992 0.004 0.000 0.004 0.000
#> SRR1223542 2 0.6326 0.576 0.324 0.428 0.000 0.016 0.232 0.000
#> SRR1223543 2 0.1777 0.767 0.012 0.932 0.024 0.000 0.032 0.000
#> SRR1223544 2 0.6087 0.585 0.336 0.428 0.000 0.004 0.232 0.000
#> SRR1223545 2 0.5304 0.701 0.132 0.660 0.028 0.000 0.180 0.000
#> SRR1223546 1 0.3747 0.942 0.604 0.000 0.000 0.000 0.000 0.396
#> SRR1223547 6 0.0000 0.754 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1223548 1 0.5764 0.813 0.480 0.000 0.000 0.020 0.104 0.396
#> SRR1223549 6 0.0363 0.753 0.000 0.000 0.000 0.000 0.012 0.988
#> SRR1223550 1 0.4321 0.924 0.580 0.000 0.000 0.008 0.012 0.400
#> SRR1223551 2 0.2257 0.764 0.008 0.912 0.020 0.016 0.044 0.000
#> SRR1223552 4 0.1536 0.895 0.004 0.040 0.000 0.940 0.016 0.000
#> SRR1223553 2 0.2526 0.770 0.020 0.896 0.028 0.004 0.052 0.000
#> SRR1223554 4 0.4614 0.784 0.016 0.040 0.000 0.660 0.284 0.000
#> SRR1223555 4 0.3537 0.889 0.020 0.040 0.020 0.840 0.080 0.000
#> SRR1223556 1 0.3747 0.942 0.604 0.000 0.000 0.000 0.000 0.396
#> SRR1223557 3 0.3658 0.948 0.012 0.000 0.824 0.012 0.064 0.088
#> SRR1223558 1 0.3984 0.941 0.596 0.000 0.000 0.000 0.008 0.396
#> SRR1223559 3 0.3658 0.948 0.012 0.000 0.824 0.012 0.064 0.088
#> SRR1223560 6 0.5663 0.143 0.248 0.000 0.000 0.000 0.220 0.532
#> SRR1223561 2 0.0291 0.772 0.000 0.992 0.004 0.000 0.004 0.000
#> SRR1223562 2 0.6326 0.576 0.324 0.428 0.000 0.016 0.232 0.000
#> SRR1223563 2 0.1777 0.767 0.012 0.932 0.024 0.000 0.032 0.000
#> SRR1223564 2 0.6334 0.571 0.340 0.416 0.000 0.016 0.228 0.000
#> SRR1223565 2 0.5304 0.701 0.132 0.660 0.028 0.000 0.180 0.000
#> SRR1223566 1 0.3747 0.942 0.604 0.000 0.000 0.000 0.000 0.396
#> SRR1223567 6 0.0000 0.754 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1223568 1 0.5764 0.813 0.480 0.000 0.000 0.020 0.104 0.396
#> SRR1223569 6 0.0363 0.753 0.000 0.000 0.000 0.000 0.012 0.988
#> SRR1223570 1 0.4321 0.924 0.580 0.000 0.000 0.008 0.012 0.400
#> SRR1223571 2 0.2257 0.764 0.008 0.912 0.020 0.016 0.044 0.000
#> SRR1223572 4 0.1564 0.895 0.000 0.040 0.000 0.936 0.024 0.000
#> SRR1223573 2 0.2257 0.764 0.008 0.912 0.020 0.016 0.044 0.000
#> SRR1223574 4 0.4614 0.784 0.016 0.040 0.000 0.660 0.284 0.000
#> SRR1223575 4 0.3640 0.888 0.020 0.040 0.020 0.832 0.088 0.000
#> SRR1223576 1 0.3747 0.942 0.604 0.000 0.000 0.000 0.000 0.396
#> SRR1223577 3 0.1663 0.970 0.000 0.000 0.912 0.000 0.000 0.088
#> SRR1223578 1 0.3984 0.941 0.596 0.000 0.000 0.000 0.008 0.396
#> SRR1223579 3 0.1663 0.970 0.000 0.000 0.912 0.000 0.000 0.088
#> SRR1223580 6 0.5663 0.143 0.248 0.000 0.000 0.000 0.220 0.532
#> SRR1223581 2 0.0146 0.772 0.000 0.996 0.004 0.000 0.000 0.000
#> SRR1223582 2 0.5846 0.627 0.312 0.496 0.000 0.004 0.188 0.000
#> SRR1223583 2 0.1777 0.767 0.012 0.932 0.024 0.000 0.032 0.000
#> SRR1223584 2 0.5875 0.625 0.324 0.484 0.000 0.004 0.188 0.000
#> SRR1223585 2 0.4863 0.715 0.100 0.708 0.028 0.000 0.164 0.000
#> SRR1223586 1 0.3747 0.942 0.604 0.000 0.000 0.000 0.000 0.396
#> SRR1223587 6 0.0000 0.754 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1223588 1 0.5764 0.813 0.480 0.000 0.000 0.020 0.104 0.396
#> SRR1223589 6 0.0363 0.753 0.000 0.000 0.000 0.000 0.012 0.988
#> SRR1223590 1 0.4321 0.924 0.580 0.000 0.000 0.008 0.012 0.400
#> SRR1223591 2 0.2257 0.764 0.008 0.912 0.020 0.016 0.044 0.000
#> SRR1223592 4 0.1864 0.891 0.004 0.040 0.000 0.924 0.032 0.000
#> SRR1223593 2 0.2044 0.766 0.008 0.924 0.020 0.016 0.032 0.000
#> SRR1223594 4 0.1864 0.891 0.004 0.040 0.000 0.924 0.032 0.000
#> SRR1223595 4 0.3537 0.889 0.020 0.040 0.020 0.840 0.080 0.000
#> SRR1223596 1 0.3747 0.942 0.604 0.000 0.000 0.000 0.000 0.396
#> SRR1223597 3 0.2205 0.969 0.004 0.000 0.896 0.004 0.008 0.088
#> SRR1223598 1 0.3984 0.941 0.596 0.000 0.000 0.000 0.008 0.396
#> SRR1223599 3 0.2205 0.969 0.004 0.000 0.896 0.004 0.008 0.088
#> SRR1223600 6 0.5663 0.143 0.248 0.000 0.000 0.000 0.220 0.532
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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.5090 0.492 0.492
#> 3 3 0.812 0.928 0.917 0.1762 0.919 0.834
#> 4 4 1.000 0.997 0.995 0.1631 0.893 0.740
#> 5 5 0.880 0.872 0.915 0.0642 1.000 1.000
#> 6 6 0.831 0.883 0.888 0.0556 0.880 0.610
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
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223542 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223543 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223544 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223545 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223546 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223547 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223548 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223549 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223550 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223551 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223552 2 0.579 0.747 0.332 0.668 0.000
#> SRR1223553 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223554 2 0.579 0.747 0.332 0.668 0.000
#> SRR1223555 2 0.579 0.747 0.332 0.668 0.000
#> SRR1223556 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223557 3 0.000 1.000 0.000 0.000 1.000
#> SRR1223558 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223559 3 0.000 1.000 0.000 0.000 1.000
#> SRR1223560 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223561 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223562 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223563 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223564 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223565 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223566 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223567 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223568 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223569 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223570 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223571 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223572 2 0.579 0.747 0.332 0.668 0.000
#> SRR1223573 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223574 2 0.579 0.747 0.332 0.668 0.000
#> SRR1223575 2 0.579 0.747 0.332 0.668 0.000
#> SRR1223576 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223577 3 0.000 1.000 0.000 0.000 1.000
#> SRR1223578 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223579 3 0.000 1.000 0.000 0.000 1.000
#> SRR1223580 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223581 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223582 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223583 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223584 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223585 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223586 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223587 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223588 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223589 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223590 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223591 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223592 2 0.579 0.747 0.332 0.668 0.000
#> SRR1223593 2 0.000 0.903 0.000 1.000 0.000
#> SRR1223594 2 0.579 0.747 0.332 0.668 0.000
#> SRR1223595 2 0.579 0.747 0.332 0.668 0.000
#> SRR1223596 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223597 3 0.000 1.000 0.000 0.000 1.000
#> SRR1223598 1 0.579 1.000 0.668 0.000 0.332
#> SRR1223599 3 0.000 1.000 0.000 0.000 1.000
#> SRR1223600 1 0.579 1.000 0.668 0.000 0.332
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR1223542 2 0.0188 0.997 0.000 0.996 0.004 0.000
#> SRR1223543 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR1223544 2 0.0188 0.997 0.000 0.996 0.004 0.000
#> SRR1223545 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR1223546 1 0.0000 0.995 1.000 0.000 0.000 0.000
#> SRR1223547 1 0.0592 0.991 0.984 0.000 0.000 0.016
#> SRR1223548 1 0.0000 0.995 1.000 0.000 0.000 0.000
#> SRR1223549 1 0.0592 0.991 0.984 0.000 0.000 0.016
#> SRR1223550 1 0.0000 0.995 1.000 0.000 0.000 0.000
#> SRR1223551 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR1223552 4 0.0592 1.000 0.000 0.016 0.000 0.984
#> SRR1223553 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR1223554 4 0.0592 1.000 0.000 0.016 0.000 0.984
#> SRR1223555 4 0.0592 1.000 0.000 0.016 0.000 0.984
#> SRR1223556 1 0.0000 0.995 1.000 0.000 0.000 0.000
#> SRR1223557 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR1223558 1 0.0000 0.995 1.000 0.000 0.000 0.000
#> SRR1223559 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR1223560 1 0.0469 0.992 0.988 0.000 0.000 0.012
#> SRR1223561 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR1223562 2 0.0188 0.997 0.000 0.996 0.004 0.000
#> SRR1223563 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR1223564 2 0.0188 0.997 0.000 0.996 0.004 0.000
#> SRR1223565 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR1223566 1 0.0000 0.995 1.000 0.000 0.000 0.000
#> SRR1223567 1 0.0592 0.991 0.984 0.000 0.000 0.016
#> SRR1223568 1 0.0000 0.995 1.000 0.000 0.000 0.000
#> SRR1223569 1 0.0592 0.991 0.984 0.000 0.000 0.016
#> SRR1223570 1 0.0000 0.995 1.000 0.000 0.000 0.000
#> SRR1223571 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR1223572 4 0.0592 1.000 0.000 0.016 0.000 0.984
#> SRR1223573 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR1223574 4 0.0592 1.000 0.000 0.016 0.000 0.984
#> SRR1223575 4 0.0592 1.000 0.000 0.016 0.000 0.984
#> SRR1223576 1 0.0000 0.995 1.000 0.000 0.000 0.000
#> SRR1223577 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR1223578 1 0.0000 0.995 1.000 0.000 0.000 0.000
#> SRR1223579 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR1223580 1 0.0469 0.992 0.988 0.000 0.000 0.012
#> SRR1223581 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR1223582 2 0.0188 0.997 0.000 0.996 0.004 0.000
#> SRR1223583 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR1223584 2 0.0188 0.997 0.000 0.996 0.004 0.000
#> SRR1223585 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR1223586 1 0.0000 0.995 1.000 0.000 0.000 0.000
#> SRR1223587 1 0.0592 0.991 0.984 0.000 0.000 0.016
#> SRR1223588 1 0.0000 0.995 1.000 0.000 0.000 0.000
#> SRR1223589 1 0.0592 0.991 0.984 0.000 0.000 0.016
#> SRR1223590 1 0.0000 0.995 1.000 0.000 0.000 0.000
#> SRR1223591 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR1223592 4 0.0592 1.000 0.000 0.016 0.000 0.984
#> SRR1223593 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR1223594 4 0.0592 1.000 0.000 0.016 0.000 0.984
#> SRR1223595 4 0.0592 1.000 0.000 0.016 0.000 0.984
#> SRR1223596 1 0.0000 0.995 1.000 0.000 0.000 0.000
#> SRR1223597 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR1223598 1 0.0000 0.995 1.000 0.000 0.000 0.000
#> SRR1223599 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR1223600 1 0.0469 0.992 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
#> SRR1223541 2 0.0000 0.935 0.000 1.000 0 0.000 NA
#> SRR1223542 2 0.3366 0.837 0.000 0.768 0 0.000 NA
#> SRR1223543 2 0.0000 0.935 0.000 1.000 0 0.000 NA
#> SRR1223544 2 0.3305 0.842 0.000 0.776 0 0.000 NA
#> SRR1223545 2 0.0963 0.927 0.000 0.964 0 0.000 NA
#> SRR1223546 1 0.0000 0.875 1.000 0.000 0 0.000 NA
#> SRR1223547 1 0.4300 0.577 0.524 0.000 0 0.000 NA
#> SRR1223548 1 0.0000 0.875 1.000 0.000 0 0.000 NA
#> SRR1223549 1 0.4300 0.577 0.524 0.000 0 0.000 NA
#> SRR1223550 1 0.0000 0.875 1.000 0.000 0 0.000 NA
#> SRR1223551 2 0.0000 0.935 0.000 1.000 0 0.000 NA
#> SRR1223552 4 0.0000 0.940 0.000 0.000 0 1.000 NA
#> SRR1223553 2 0.0000 0.935 0.000 1.000 0 0.000 NA
#> SRR1223554 4 0.3774 0.769 0.000 0.000 0 0.704 NA
#> SRR1223555 4 0.0000 0.940 0.000 0.000 0 1.000 NA
#> SRR1223556 1 0.0000 0.875 1.000 0.000 0 0.000 NA
#> SRR1223557 3 0.0000 1.000 0.000 0.000 1 0.000 NA
#> SRR1223558 1 0.0000 0.875 1.000 0.000 0 0.000 NA
#> SRR1223559 3 0.0000 1.000 0.000 0.000 1 0.000 NA
#> SRR1223560 1 0.1341 0.855 0.944 0.000 0 0.000 NA
#> SRR1223561 2 0.0000 0.935 0.000 1.000 0 0.000 NA
#> SRR1223562 2 0.3366 0.837 0.000 0.768 0 0.000 NA
#> SRR1223563 2 0.0000 0.935 0.000 1.000 0 0.000 NA
#> SRR1223564 2 0.3366 0.837 0.000 0.768 0 0.000 NA
#> SRR1223565 2 0.0963 0.927 0.000 0.964 0 0.000 NA
#> SRR1223566 1 0.0000 0.875 1.000 0.000 0 0.000 NA
#> SRR1223567 1 0.4300 0.577 0.524 0.000 0 0.000 NA
#> SRR1223568 1 0.0000 0.875 1.000 0.000 0 0.000 NA
#> SRR1223569 1 0.4300 0.577 0.524 0.000 0 0.000 NA
#> SRR1223570 1 0.0000 0.875 1.000 0.000 0 0.000 NA
#> SRR1223571 2 0.0000 0.935 0.000 1.000 0 0.000 NA
#> SRR1223572 4 0.0000 0.940 0.000 0.000 0 1.000 NA
#> SRR1223573 2 0.0000 0.935 0.000 1.000 0 0.000 NA
#> SRR1223574 4 0.3816 0.764 0.000 0.000 0 0.696 NA
#> SRR1223575 4 0.0000 0.940 0.000 0.000 0 1.000 NA
#> SRR1223576 1 0.0000 0.875 1.000 0.000 0 0.000 NA
#> SRR1223577 3 0.0000 1.000 0.000 0.000 1 0.000 NA
#> SRR1223578 1 0.0000 0.875 1.000 0.000 0 0.000 NA
#> SRR1223579 3 0.0000 1.000 0.000 0.000 1 0.000 NA
#> SRR1223580 1 0.1341 0.855 0.944 0.000 0 0.000 NA
#> SRR1223581 2 0.0000 0.935 0.000 1.000 0 0.000 NA
#> SRR1223582 2 0.3274 0.844 0.000 0.780 0 0.000 NA
#> SRR1223583 2 0.0000 0.935 0.000 1.000 0 0.000 NA
#> SRR1223584 2 0.3274 0.844 0.000 0.780 0 0.000 NA
#> SRR1223585 2 0.0963 0.927 0.000 0.964 0 0.000 NA
#> SRR1223586 1 0.0000 0.875 1.000 0.000 0 0.000 NA
#> SRR1223587 1 0.4300 0.577 0.524 0.000 0 0.000 NA
#> SRR1223588 1 0.0000 0.875 1.000 0.000 0 0.000 NA
#> SRR1223589 1 0.4300 0.577 0.524 0.000 0 0.000 NA
#> SRR1223590 1 0.0000 0.875 1.000 0.000 0 0.000 NA
#> SRR1223591 2 0.0000 0.935 0.000 1.000 0 0.000 NA
#> SRR1223592 4 0.0000 0.940 0.000 0.000 0 1.000 NA
#> SRR1223593 2 0.0000 0.935 0.000 1.000 0 0.000 NA
#> SRR1223594 4 0.0000 0.940 0.000 0.000 0 1.000 NA
#> SRR1223595 4 0.0000 0.940 0.000 0.000 0 1.000 NA
#> SRR1223596 1 0.0000 0.875 1.000 0.000 0 0.000 NA
#> SRR1223597 3 0.0000 1.000 0.000 0.000 1 0.000 NA
#> SRR1223598 1 0.0000 0.875 1.000 0.000 0 0.000 NA
#> SRR1223599 3 0.0000 1.000 0.000 0.000 1 0.000 NA
#> SRR1223600 1 0.1341 0.855 0.944 0.000 0 0.000 NA
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.0000 0.945 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223542 6 0.2854 0.960 0.000 0.208 0 0.000 0.000 0.792
#> SRR1223543 2 0.0000 0.945 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223544 6 0.2912 0.960 0.000 0.216 0 0.000 0.000 0.784
#> SRR1223545 2 0.2902 0.706 0.000 0.800 0 0.000 0.004 0.196
#> SRR1223546 1 0.0000 0.962 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223547 5 0.3747 0.787 0.396 0.000 0 0.000 0.604 0.000
#> SRR1223548 1 0.0000 0.962 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223549 5 0.3747 0.787 0.396 0.000 0 0.000 0.604 0.000
#> SRR1223550 1 0.0000 0.962 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223551 2 0.0146 0.945 0.000 0.996 0 0.000 0.000 0.004
#> SRR1223552 4 0.0146 0.916 0.000 0.000 0 0.996 0.000 0.004
#> SRR1223553 2 0.0146 0.945 0.000 0.996 0 0.000 0.000 0.004
#> SRR1223554 4 0.5965 0.423 0.000 0.000 0 0.408 0.368 0.224
#> SRR1223555 4 0.0937 0.912 0.000 0.000 0 0.960 0.000 0.040
#> SRR1223556 1 0.0000 0.962 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223558 1 0.0000 0.962 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223559 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223560 1 0.2178 0.779 0.868 0.000 0 0.000 0.132 0.000
#> SRR1223561 2 0.0000 0.945 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223562 6 0.2854 0.960 0.000 0.208 0 0.000 0.000 0.792
#> SRR1223563 2 0.0000 0.945 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223564 6 0.2854 0.960 0.000 0.208 0 0.000 0.000 0.792
#> SRR1223565 2 0.2902 0.706 0.000 0.800 0 0.000 0.004 0.196
#> SRR1223566 1 0.0000 0.962 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223567 5 0.3747 0.787 0.396 0.000 0 0.000 0.604 0.000
#> SRR1223568 1 0.0000 0.962 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223569 5 0.3747 0.787 0.396 0.000 0 0.000 0.604 0.000
#> SRR1223570 1 0.0000 0.962 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223571 2 0.0146 0.945 0.000 0.996 0 0.000 0.000 0.004
#> SRR1223572 4 0.0405 0.913 0.000 0.000 0 0.988 0.008 0.004
#> SRR1223573 2 0.0146 0.945 0.000 0.996 0 0.000 0.000 0.004
#> SRR1223574 5 0.5970 -0.552 0.000 0.000 0 0.384 0.392 0.224
#> SRR1223575 4 0.0937 0.912 0.000 0.000 0 0.960 0.000 0.040
#> SRR1223576 1 0.0000 0.962 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223578 1 0.0000 0.962 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223579 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223580 1 0.2260 0.765 0.860 0.000 0 0.000 0.140 0.000
#> SRR1223581 2 0.0000 0.945 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223582 6 0.3266 0.922 0.000 0.272 0 0.000 0.000 0.728
#> SRR1223583 2 0.0000 0.945 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223584 6 0.3266 0.922 0.000 0.272 0 0.000 0.000 0.728
#> SRR1223585 2 0.2482 0.782 0.000 0.848 0 0.000 0.004 0.148
#> SRR1223586 1 0.0000 0.962 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223587 5 0.3747 0.787 0.396 0.000 0 0.000 0.604 0.000
#> SRR1223588 1 0.0000 0.962 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223589 5 0.3747 0.787 0.396 0.000 0 0.000 0.604 0.000
#> SRR1223590 1 0.0000 0.962 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223591 2 0.0146 0.945 0.000 0.996 0 0.000 0.000 0.004
#> SRR1223592 4 0.0146 0.916 0.000 0.000 0 0.996 0.000 0.004
#> SRR1223593 2 0.0146 0.945 0.000 0.996 0 0.000 0.000 0.004
#> SRR1223594 4 0.0146 0.916 0.000 0.000 0 0.996 0.000 0.004
#> SRR1223595 4 0.0937 0.912 0.000 0.000 0 0.960 0.000 0.040
#> SRR1223596 1 0.0000 0.962 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223598 1 0.0000 0.962 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223599 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223600 1 0.2219 0.772 0.864 0.000 0 0.000 0.136 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", "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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5090 0.492 0.492
#> 3 3 1.000 1.000 1.000 0.1597 0.919 0.834
#> 4 4 0.875 0.774 0.891 0.1963 0.893 0.740
#> 5 5 1.000 0.971 0.988 0.0616 0.934 0.789
#> 6 6 0.939 0.902 0.956 0.0875 0.933 0.733
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
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0 1 0 1 0
#> SRR1223542 2 0 1 0 1 0
#> SRR1223543 2 0 1 0 1 0
#> SRR1223544 2 0 1 0 1 0
#> SRR1223545 2 0 1 0 1 0
#> SRR1223546 1 0 1 1 0 0
#> SRR1223547 1 0 1 1 0 0
#> SRR1223548 1 0 1 1 0 0
#> SRR1223549 1 0 1 1 0 0
#> SRR1223550 1 0 1 1 0 0
#> SRR1223551 2 0 1 0 1 0
#> SRR1223552 2 0 1 0 1 0
#> SRR1223553 2 0 1 0 1 0
#> SRR1223554 2 0 1 0 1 0
#> SRR1223555 2 0 1 0 1 0
#> SRR1223556 1 0 1 1 0 0
#> SRR1223557 3 0 1 0 0 1
#> SRR1223558 1 0 1 1 0 0
#> SRR1223559 3 0 1 0 0 1
#> SRR1223560 1 0 1 1 0 0
#> SRR1223561 2 0 1 0 1 0
#> SRR1223562 2 0 1 0 1 0
#> SRR1223563 2 0 1 0 1 0
#> SRR1223564 2 0 1 0 1 0
#> SRR1223565 2 0 1 0 1 0
#> SRR1223566 1 0 1 1 0 0
#> SRR1223567 1 0 1 1 0 0
#> SRR1223568 1 0 1 1 0 0
#> SRR1223569 1 0 1 1 0 0
#> SRR1223570 1 0 1 1 0 0
#> SRR1223571 2 0 1 0 1 0
#> SRR1223572 2 0 1 0 1 0
#> SRR1223573 2 0 1 0 1 0
#> SRR1223574 2 0 1 0 1 0
#> SRR1223575 2 0 1 0 1 0
#> SRR1223576 1 0 1 1 0 0
#> SRR1223577 3 0 1 0 0 1
#> SRR1223578 1 0 1 1 0 0
#> SRR1223579 3 0 1 0 0 1
#> SRR1223580 1 0 1 1 0 0
#> SRR1223581 2 0 1 0 1 0
#> SRR1223582 2 0 1 0 1 0
#> SRR1223583 2 0 1 0 1 0
#> SRR1223584 2 0 1 0 1 0
#> SRR1223585 2 0 1 0 1 0
#> SRR1223586 1 0 1 1 0 0
#> SRR1223587 1 0 1 1 0 0
#> SRR1223588 1 0 1 1 0 0
#> SRR1223589 1 0 1 1 0 0
#> SRR1223590 1 0 1 1 0 0
#> SRR1223591 2 0 1 0 1 0
#> SRR1223592 2 0 1 0 1 0
#> SRR1223593 2 0 1 0 1 0
#> SRR1223594 2 0 1 0 1 0
#> SRR1223595 2 0 1 0 1 0
#> SRR1223596 1 0 1 1 0 0
#> SRR1223597 3 0 1 0 0 1
#> SRR1223598 1 0 1 1 0 0
#> SRR1223599 3 0 1 0 0 1
#> SRR1223600 1 0 1 1 0 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.500 0.680 0 0.504 0 0.496
#> SRR1223542 2 0.000 0.412 0 1.000 0 0.000
#> SRR1223543 2 0.500 0.680 0 0.504 0 0.496
#> SRR1223544 2 0.000 0.412 0 1.000 0 0.000
#> SRR1223545 2 0.000 0.412 0 1.000 0 0.000
#> SRR1223546 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223547 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223548 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223549 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223550 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223551 2 0.500 0.680 0 0.504 0 0.496
#> SRR1223552 4 0.281 0.548 0 0.132 0 0.868
#> SRR1223553 2 0.500 0.680 0 0.504 0 0.496
#> SRR1223554 4 0.500 0.553 0 0.496 0 0.504
#> SRR1223555 4 0.000 0.520 0 0.000 0 1.000
#> SRR1223556 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223557 3 0.000 1.000 0 0.000 1 0.000
#> SRR1223558 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223559 3 0.000 1.000 0 0.000 1 0.000
#> SRR1223560 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223561 2 0.500 0.680 0 0.504 0 0.496
#> SRR1223562 2 0.384 -0.114 0 0.776 0 0.224
#> SRR1223563 2 0.500 0.680 0 0.504 0 0.496
#> SRR1223564 2 0.000 0.412 0 1.000 0 0.000
#> SRR1223565 2 0.112 0.430 0 0.964 0 0.036
#> SRR1223566 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223567 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223568 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223569 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223570 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223571 2 0.500 0.680 0 0.504 0 0.496
#> SRR1223572 4 0.500 0.553 0 0.496 0 0.504
#> SRR1223573 2 0.500 0.680 0 0.504 0 0.496
#> SRR1223574 4 0.500 0.553 0 0.496 0 0.504
#> SRR1223575 4 0.500 0.555 0 0.488 0 0.512
#> SRR1223576 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223577 3 0.000 1.000 0 0.000 1 0.000
#> SRR1223578 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223579 3 0.000 1.000 0 0.000 1 0.000
#> SRR1223580 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223581 2 0.500 0.680 0 0.504 0 0.496
#> SRR1223582 2 0.000 0.412 0 1.000 0 0.000
#> SRR1223583 2 0.500 0.680 0 0.504 0 0.496
#> SRR1223584 2 0.000 0.412 0 1.000 0 0.000
#> SRR1223585 2 0.500 0.680 0 0.504 0 0.496
#> SRR1223586 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223587 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223588 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223589 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223590 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223591 2 0.500 0.680 0 0.504 0 0.496
#> SRR1223592 4 0.000 0.520 0 0.000 0 1.000
#> SRR1223593 2 0.500 0.680 0 0.504 0 0.496
#> SRR1223594 4 0.000 0.520 0 0.000 0 1.000
#> SRR1223595 4 0.000 0.520 0 0.000 0 1.000
#> SRR1223596 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223597 3 0.000 1.000 0 0.000 1 0.000
#> SRR1223598 1 0.000 1.000 1 0.000 0 0.000
#> SRR1223599 3 0.000 1.000 0 0.000 1 0.000
#> SRR1223600 1 0.000 1.000 1 0.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.000 0.985 0 1.000 0 0.000 0.000
#> SRR1223542 5 0.000 0.926 0 0.000 0 0.000 1.000
#> SRR1223543 2 0.000 0.985 0 1.000 0 0.000 0.000
#> SRR1223544 5 0.000 0.926 0 0.000 0 0.000 1.000
#> SRR1223545 2 0.000 0.985 0 1.000 0 0.000 0.000
#> SRR1223546 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223547 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223548 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223549 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223550 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223551 2 0.000 0.985 0 1.000 0 0.000 0.000
#> SRR1223552 4 0.000 1.000 0 0.000 0 1.000 0.000
#> SRR1223553 2 0.000 0.985 0 1.000 0 0.000 0.000
#> SRR1223554 5 0.421 0.309 0 0.000 0 0.412 0.588
#> SRR1223555 4 0.000 1.000 0 0.000 0 1.000 0.000
#> SRR1223556 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223557 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR1223558 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223559 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR1223560 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223561 2 0.000 0.985 0 1.000 0 0.000 0.000
#> SRR1223562 5 0.000 0.926 0 0.000 0 0.000 1.000
#> SRR1223563 2 0.000 0.985 0 1.000 0 0.000 0.000
#> SRR1223564 5 0.000 0.926 0 0.000 0 0.000 1.000
#> SRR1223565 2 0.314 0.746 0 0.796 0 0.000 0.204
#> SRR1223566 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223567 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223568 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223569 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223570 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223571 2 0.000 0.985 0 1.000 0 0.000 0.000
#> SRR1223572 4 0.000 1.000 0 0.000 0 1.000 0.000
#> SRR1223573 2 0.000 0.985 0 1.000 0 0.000 0.000
#> SRR1223574 5 0.173 0.869 0 0.000 0 0.080 0.920
#> SRR1223575 4 0.000 1.000 0 0.000 0 1.000 0.000
#> SRR1223576 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223577 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR1223578 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223579 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR1223580 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223581 2 0.000 0.985 0 1.000 0 0.000 0.000
#> SRR1223582 5 0.000 0.926 0 0.000 0 0.000 1.000
#> SRR1223583 2 0.000 0.985 0 1.000 0 0.000 0.000
#> SRR1223584 5 0.000 0.926 0 0.000 0 0.000 1.000
#> SRR1223585 2 0.000 0.985 0 1.000 0 0.000 0.000
#> SRR1223586 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223587 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223588 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223589 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223590 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223591 2 0.000 0.985 0 1.000 0 0.000 0.000
#> SRR1223592 4 0.000 1.000 0 0.000 0 1.000 0.000
#> SRR1223593 2 0.000 0.985 0 1.000 0 0.000 0.000
#> SRR1223594 4 0.000 1.000 0 0.000 0 1.000 0.000
#> SRR1223595 4 0.000 1.000 0 0.000 0 1.000 0.000
#> SRR1223596 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223597 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR1223598 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR1223599 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR1223600 1 0.000 1.000 1 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
#> SRR1223541 2 0.0000 0.985 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223542 6 0.0000 0.925 0.000 0.000 0 0.000 0.000 1.000
#> SRR1223543 2 0.0000 0.985 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223544 6 0.0000 0.925 0.000 0.000 0 0.000 0.000 1.000
#> SRR1223545 2 0.0000 0.985 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223546 1 0.0000 0.925 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223547 5 0.0937 0.882 0.040 0.000 0 0.000 0.960 0.000
#> SRR1223548 1 0.3695 0.341 0.624 0.000 0 0.000 0.376 0.000
#> SRR1223549 5 0.0937 0.882 0.040 0.000 0 0.000 0.960 0.000
#> SRR1223550 1 0.0000 0.925 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223551 2 0.0000 0.985 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223552 4 0.0000 0.983 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223553 2 0.0000 0.985 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223554 6 0.3782 0.325 0.000 0.000 0 0.412 0.000 0.588
#> SRR1223555 4 0.0937 0.978 0.000 0.000 0 0.960 0.040 0.000
#> SRR1223556 1 0.0000 0.925 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223558 1 0.0000 0.925 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223559 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223560 1 0.0000 0.925 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223561 2 0.0000 0.985 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223562 6 0.0000 0.925 0.000 0.000 0 0.000 0.000 1.000
#> SRR1223563 2 0.0000 0.985 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223564 6 0.0000 0.925 0.000 0.000 0 0.000 0.000 1.000
#> SRR1223565 2 0.2823 0.746 0.000 0.796 0 0.000 0.000 0.204
#> SRR1223566 1 0.0000 0.925 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223567 5 0.0937 0.882 0.040 0.000 0 0.000 0.960 0.000
#> SRR1223568 1 0.3727 0.299 0.612 0.000 0 0.000 0.388 0.000
#> SRR1223569 5 0.0937 0.882 0.040 0.000 0 0.000 0.960 0.000
#> SRR1223570 1 0.0000 0.925 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223571 2 0.0000 0.985 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223572 4 0.0000 0.983 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223573 2 0.0000 0.985 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223574 6 0.2039 0.858 0.000 0.000 0 0.076 0.020 0.904
#> SRR1223575 4 0.0937 0.978 0.000 0.000 0 0.960 0.040 0.000
#> SRR1223576 1 0.0000 0.925 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223578 1 0.0000 0.925 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223579 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223580 5 0.3464 0.612 0.312 0.000 0 0.000 0.688 0.000
#> SRR1223581 2 0.0000 0.985 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223582 6 0.0000 0.925 0.000 0.000 0 0.000 0.000 1.000
#> SRR1223583 2 0.0000 0.985 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223584 6 0.0000 0.925 0.000 0.000 0 0.000 0.000 1.000
#> SRR1223585 2 0.0000 0.985 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223586 1 0.0000 0.925 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223587 5 0.3351 0.659 0.288 0.000 0 0.000 0.712 0.000
#> SRR1223588 1 0.2092 0.809 0.876 0.000 0 0.000 0.124 0.000
#> SRR1223589 5 0.0937 0.882 0.040 0.000 0 0.000 0.960 0.000
#> SRR1223590 1 0.0000 0.925 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223591 2 0.0000 0.985 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223592 4 0.0000 0.983 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223593 2 0.0000 0.985 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223594 4 0.0000 0.983 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223595 4 0.0937 0.978 0.000 0.000 0 0.960 0.040 0.000
#> SRR1223596 1 0.0000 0.925 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223598 1 0.0000 0.925 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223599 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223600 1 0.2003 0.819 0.884 0.000 0 0.000 0.116 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "mclust"]
# you can also extract it by
# res = res_list["MAD:mclust"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.5090 0.492 0.492
#> 3 3 0.875 0.881 0.906 0.2043 0.893 0.783
#> 4 4 0.844 0.346 0.655 0.1169 0.751 0.449
#> 5 5 0.787 0.850 0.833 0.1005 0.801 0.441
#> 6 6 0.841 0.821 0.895 0.0748 0.955 0.815
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
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.0000 0.849 0.000 1.000 0.000
#> SRR1223542 3 0.6008 0.857 0.000 0.372 0.628
#> SRR1223543 2 0.0000 0.849 0.000 1.000 0.000
#> SRR1223544 3 0.6026 0.856 0.000 0.376 0.624
#> SRR1223545 2 0.0424 0.843 0.000 0.992 0.008
#> SRR1223546 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223547 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223548 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223549 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223550 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223551 2 0.1289 0.852 0.000 0.968 0.032
#> SRR1223552 2 0.6095 0.522 0.000 0.608 0.392
#> SRR1223553 2 0.1289 0.852 0.000 0.968 0.032
#> SRR1223554 3 0.4235 0.738 0.000 0.176 0.824
#> SRR1223555 2 0.5465 0.672 0.000 0.712 0.288
#> SRR1223556 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223557 1 0.2878 0.925 0.904 0.000 0.096
#> SRR1223558 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223559 1 0.2878 0.925 0.904 0.000 0.096
#> SRR1223560 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223561 2 0.0000 0.849 0.000 1.000 0.000
#> SRR1223562 3 0.6008 0.857 0.000 0.372 0.628
#> SRR1223563 2 0.0000 0.849 0.000 1.000 0.000
#> SRR1223564 3 0.6008 0.857 0.000 0.372 0.628
#> SRR1223565 2 0.0424 0.843 0.000 0.992 0.008
#> SRR1223566 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223567 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223568 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223569 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223570 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223571 2 0.1289 0.852 0.000 0.968 0.032
#> SRR1223572 3 0.5016 0.487 0.000 0.240 0.760
#> SRR1223573 2 0.1289 0.852 0.000 0.968 0.032
#> SRR1223574 3 0.4121 0.740 0.000 0.168 0.832
#> SRR1223575 2 0.5529 0.663 0.000 0.704 0.296
#> SRR1223576 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223577 1 0.2878 0.925 0.904 0.000 0.096
#> SRR1223578 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223579 1 0.2878 0.925 0.904 0.000 0.096
#> SRR1223580 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223581 2 0.0000 0.849 0.000 1.000 0.000
#> SRR1223582 3 0.6026 0.856 0.000 0.376 0.624
#> SRR1223583 2 0.0000 0.849 0.000 1.000 0.000
#> SRR1223584 3 0.6026 0.856 0.000 0.376 0.624
#> SRR1223585 2 0.0424 0.843 0.000 0.992 0.008
#> SRR1223586 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223587 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223588 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223589 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223590 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223591 2 0.1289 0.852 0.000 0.968 0.032
#> SRR1223592 2 0.5465 0.672 0.000 0.712 0.288
#> SRR1223593 2 0.1289 0.852 0.000 0.968 0.032
#> SRR1223594 2 0.5465 0.672 0.000 0.712 0.288
#> SRR1223595 2 0.5465 0.672 0.000 0.712 0.288
#> SRR1223596 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223597 1 0.2878 0.925 0.904 0.000 0.096
#> SRR1223598 1 0.0000 0.982 1.000 0.000 0.000
#> SRR1223599 1 0.2878 0.925 0.904 0.000 0.096
#> SRR1223600 1 0.0000 0.982 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 3 0.561 -0.595 0.000 0.488 0.492 0.020
#> SRR1223542 2 0.000 0.675 0.000 1.000 0.000 0.000
#> SRR1223543 2 0.530 0.549 0.000 0.500 0.492 0.008
#> SRR1223544 2 0.000 0.675 0.000 1.000 0.000 0.000
#> SRR1223545 2 0.498 0.581 0.000 0.536 0.464 0.000
#> SRR1223546 1 0.499 0.774 0.532 0.000 0.468 0.000
#> SRR1223547 1 0.500 0.749 0.500 0.000 0.500 0.000
#> SRR1223548 1 0.499 0.774 0.532 0.000 0.468 0.000
#> SRR1223549 3 0.500 -0.774 0.500 0.000 0.500 0.000
#> SRR1223550 3 0.500 -0.775 0.496 0.000 0.504 0.000
#> SRR1223551 3 0.621 -0.560 0.000 0.456 0.492 0.052
#> SRR1223552 4 0.121 0.935 0.000 0.040 0.000 0.960
#> SRR1223553 3 0.621 -0.560 0.000 0.456 0.492 0.052
#> SRR1223554 4 0.450 0.831 0.032 0.192 0.000 0.776
#> SRR1223555 4 0.121 0.935 0.000 0.040 0.000 0.960
#> SRR1223556 1 0.499 0.774 0.532 0.000 0.468 0.000
#> SRR1223557 1 0.179 0.474 0.932 0.000 0.000 0.068
#> SRR1223558 1 0.499 0.774 0.532 0.000 0.468 0.000
#> SRR1223559 1 0.179 0.474 0.932 0.000 0.000 0.068
#> SRR1223560 1 0.500 0.749 0.500 0.000 0.500 0.000
#> SRR1223561 3 0.561 -0.595 0.000 0.488 0.492 0.020
#> SRR1223562 2 0.000 0.675 0.000 1.000 0.000 0.000
#> SRR1223563 2 0.530 0.549 0.000 0.500 0.492 0.008
#> SRR1223564 2 0.000 0.675 0.000 1.000 0.000 0.000
#> SRR1223565 2 0.498 0.581 0.000 0.536 0.464 0.000
#> SRR1223566 1 0.499 0.774 0.532 0.000 0.468 0.000
#> SRR1223567 1 0.500 0.749 0.500 0.000 0.500 0.000
#> SRR1223568 1 0.499 0.774 0.532 0.000 0.468 0.000
#> SRR1223569 1 0.500 0.749 0.500 0.000 0.500 0.000
#> SRR1223570 3 0.500 -0.775 0.496 0.000 0.504 0.000
#> SRR1223571 3 0.621 -0.560 0.000 0.456 0.492 0.052
#> SRR1223572 4 0.231 0.917 0.032 0.044 0.000 0.924
#> SRR1223573 3 0.621 -0.560 0.000 0.456 0.492 0.052
#> SRR1223574 4 0.571 0.639 0.032 0.384 0.000 0.584
#> SRR1223575 4 0.121 0.935 0.000 0.040 0.000 0.960
#> SRR1223576 1 0.499 0.774 0.532 0.000 0.468 0.000
#> SRR1223577 1 0.179 0.474 0.932 0.000 0.000 0.068
#> SRR1223578 1 0.499 0.774 0.532 0.000 0.468 0.000
#> SRR1223579 1 0.179 0.474 0.932 0.000 0.000 0.068
#> SRR1223580 3 0.500 -0.774 0.500 0.000 0.500 0.000
#> SRR1223581 3 0.561 -0.595 0.000 0.488 0.492 0.020
#> SRR1223582 2 0.000 0.675 0.000 1.000 0.000 0.000
#> SRR1223583 2 0.530 0.549 0.000 0.500 0.492 0.008
#> SRR1223584 2 0.000 0.675 0.000 1.000 0.000 0.000
#> SRR1223585 2 0.498 0.581 0.000 0.536 0.464 0.000
#> SRR1223586 1 0.499 0.774 0.532 0.000 0.468 0.000
#> SRR1223587 1 0.500 0.749 0.500 0.000 0.500 0.000
#> SRR1223588 1 0.499 0.774 0.532 0.000 0.468 0.000
#> SRR1223589 3 0.500 -0.774 0.500 0.000 0.500 0.000
#> SRR1223590 3 0.500 -0.775 0.496 0.000 0.504 0.000
#> SRR1223591 3 0.621 -0.560 0.000 0.456 0.492 0.052
#> SRR1223592 4 0.155 0.930 0.000 0.040 0.008 0.952
#> SRR1223593 3 0.621 -0.560 0.000 0.456 0.492 0.052
#> SRR1223594 4 0.121 0.935 0.000 0.040 0.000 0.960
#> SRR1223595 4 0.121 0.935 0.000 0.040 0.000 0.960
#> SRR1223596 1 0.499 0.774 0.532 0.000 0.468 0.000
#> SRR1223597 1 0.179 0.474 0.932 0.000 0.000 0.068
#> SRR1223598 1 0.499 0.774 0.532 0.000 0.468 0.000
#> SRR1223599 1 0.179 0.474 0.932 0.000 0.000 0.068
#> SRR1223600 3 0.500 -0.774 0.500 0.000 0.500 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.0703 0.908 0.000 0.976 0.000 0.000 0.024
#> SRR1223542 5 0.4820 0.932 0.000 0.332 0.000 0.036 0.632
#> SRR1223543 2 0.1894 0.857 0.000 0.920 0.000 0.008 0.072
#> SRR1223544 5 0.4836 0.934 0.000 0.336 0.000 0.036 0.628
#> SRR1223545 5 0.5065 0.863 0.000 0.420 0.000 0.036 0.544
#> SRR1223546 1 0.2392 0.883 0.888 0.000 0.004 0.004 0.104
#> SRR1223547 1 0.3715 0.662 0.736 0.000 0.260 0.004 0.000
#> SRR1223548 1 0.2392 0.883 0.888 0.000 0.004 0.004 0.104
#> SRR1223549 1 0.3715 0.662 0.736 0.000 0.260 0.004 0.000
#> SRR1223550 1 0.0865 0.866 0.972 0.000 0.024 0.004 0.000
#> SRR1223551 2 0.0290 0.909 0.000 0.992 0.000 0.000 0.008
#> SRR1223552 4 0.4395 0.844 0.000 0.064 0.000 0.748 0.188
#> SRR1223553 2 0.0000 0.909 0.000 1.000 0.000 0.000 0.000
#> SRR1223554 4 0.3493 0.714 0.000 0.000 0.108 0.832 0.060
#> SRR1223555 4 0.4734 0.838 0.000 0.088 0.000 0.724 0.188
#> SRR1223556 1 0.2392 0.883 0.888 0.000 0.004 0.004 0.104
#> SRR1223557 3 0.1195 0.943 0.012 0.000 0.960 0.028 0.000
#> SRR1223558 1 0.2392 0.883 0.888 0.000 0.004 0.004 0.104
#> SRR1223559 3 0.1195 0.943 0.012 0.000 0.960 0.028 0.000
#> SRR1223560 1 0.2332 0.839 0.904 0.000 0.076 0.004 0.016
#> SRR1223561 2 0.0794 0.906 0.000 0.972 0.000 0.000 0.028
#> SRR1223562 5 0.4820 0.932 0.000 0.332 0.000 0.036 0.632
#> SRR1223563 2 0.1894 0.857 0.000 0.920 0.000 0.008 0.072
#> SRR1223564 5 0.4836 0.934 0.000 0.336 0.000 0.036 0.628
#> SRR1223565 5 0.5071 0.856 0.000 0.424 0.000 0.036 0.540
#> SRR1223566 1 0.1965 0.884 0.904 0.000 0.000 0.000 0.096
#> SRR1223567 1 0.3715 0.662 0.736 0.000 0.260 0.004 0.000
#> SRR1223568 1 0.2392 0.883 0.888 0.000 0.004 0.004 0.104
#> SRR1223569 1 0.3715 0.662 0.736 0.000 0.260 0.004 0.000
#> SRR1223570 1 0.0865 0.866 0.972 0.000 0.024 0.004 0.000
#> SRR1223571 2 0.0290 0.909 0.000 0.992 0.000 0.000 0.008
#> SRR1223572 4 0.2304 0.748 0.000 0.008 0.100 0.892 0.000
#> SRR1223573 2 0.0290 0.909 0.000 0.992 0.000 0.000 0.008
#> SRR1223574 4 0.3558 0.712 0.000 0.000 0.108 0.828 0.064
#> SRR1223575 4 0.2233 0.806 0.000 0.080 0.000 0.904 0.016
#> SRR1223576 1 0.2392 0.883 0.888 0.000 0.004 0.004 0.104
#> SRR1223577 3 0.1195 0.943 0.012 0.000 0.960 0.028 0.000
#> SRR1223578 1 0.2497 0.881 0.880 0.000 0.004 0.004 0.112
#> SRR1223579 3 0.1195 0.943 0.012 0.000 0.960 0.028 0.000
#> SRR1223580 1 0.2393 0.836 0.900 0.000 0.080 0.004 0.016
#> SRR1223581 2 0.0703 0.908 0.000 0.976 0.000 0.000 0.024
#> SRR1223582 5 0.4663 0.918 0.000 0.376 0.000 0.020 0.604
#> SRR1223583 2 0.1410 0.877 0.000 0.940 0.000 0.000 0.060
#> SRR1223584 5 0.4663 0.918 0.000 0.376 0.000 0.020 0.604
#> SRR1223585 2 0.4275 0.151 0.000 0.696 0.000 0.020 0.284
#> SRR1223586 1 0.2074 0.884 0.896 0.000 0.000 0.000 0.104
#> SRR1223587 1 0.0865 0.866 0.972 0.000 0.024 0.004 0.000
#> SRR1223588 1 0.2392 0.883 0.888 0.000 0.004 0.004 0.104
#> SRR1223589 1 0.0865 0.866 0.972 0.000 0.024 0.004 0.000
#> SRR1223590 1 0.0865 0.866 0.972 0.000 0.024 0.004 0.000
#> SRR1223591 2 0.0290 0.909 0.000 0.992 0.000 0.000 0.008
#> SRR1223592 4 0.4455 0.845 0.000 0.068 0.000 0.744 0.188
#> SRR1223593 2 0.0290 0.909 0.000 0.992 0.000 0.000 0.008
#> SRR1223594 4 0.4455 0.845 0.000 0.068 0.000 0.744 0.188
#> SRR1223595 4 0.4734 0.838 0.000 0.088 0.000 0.724 0.188
#> SRR1223596 1 0.2392 0.883 0.888 0.000 0.004 0.004 0.104
#> SRR1223597 3 0.2795 0.880 0.100 0.000 0.872 0.028 0.000
#> SRR1223598 1 0.2548 0.880 0.876 0.000 0.004 0.004 0.116
#> SRR1223599 3 0.2740 0.885 0.096 0.000 0.876 0.028 0.000
#> SRR1223600 1 0.2393 0.836 0.900 0.000 0.080 0.004 0.016
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.0865 0.937 0.000 0.964 0.000 0.000 0.000 0.036
#> SRR1223542 6 0.0000 0.812 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1223543 2 0.1327 0.922 0.000 0.936 0.000 0.000 0.000 0.064
#> SRR1223544 6 0.0000 0.812 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1223545 6 0.2362 0.782 0.000 0.136 0.000 0.000 0.004 0.860
#> SRR1223546 1 0.0000 0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223547 5 0.1863 0.996 0.104 0.000 0.000 0.000 0.896 0.000
#> SRR1223548 1 0.0146 0.795 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1223549 5 0.1863 0.996 0.104 0.000 0.000 0.000 0.896 0.000
#> SRR1223550 1 0.3747 0.541 0.604 0.000 0.000 0.000 0.396 0.000
#> SRR1223551 2 0.0146 0.932 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1223552 4 0.0000 0.927 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1223553 2 0.0935 0.937 0.000 0.964 0.000 0.004 0.000 0.032
#> SRR1223554 4 0.3448 0.867 0.000 0.000 0.092 0.828 0.064 0.016
#> SRR1223555 4 0.1141 0.919 0.000 0.052 0.000 0.948 0.000 0.000
#> SRR1223556 1 0.0000 0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223557 3 0.0547 0.985 0.000 0.000 0.980 0.000 0.020 0.000
#> SRR1223558 1 0.0000 0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223559 3 0.0547 0.985 0.000 0.000 0.980 0.000 0.020 0.000
#> SRR1223560 1 0.4482 0.587 0.628 0.000 0.048 0.000 0.324 0.000
#> SRR1223561 2 0.0865 0.937 0.000 0.964 0.000 0.000 0.000 0.036
#> SRR1223562 6 0.0000 0.812 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1223563 2 0.1267 0.925 0.000 0.940 0.000 0.000 0.000 0.060
#> SRR1223564 6 0.0000 0.812 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1223565 6 0.2362 0.782 0.000 0.136 0.000 0.000 0.004 0.860
#> SRR1223566 1 0.1957 0.753 0.888 0.000 0.000 0.000 0.112 0.000
#> SRR1223567 5 0.1814 0.996 0.100 0.000 0.000 0.000 0.900 0.000
#> SRR1223568 1 0.0363 0.792 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR1223569 5 0.1814 0.996 0.100 0.000 0.000 0.000 0.900 0.000
#> SRR1223570 1 0.3747 0.541 0.604 0.000 0.000 0.000 0.396 0.000
#> SRR1223571 2 0.0146 0.932 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1223572 4 0.2510 0.892 0.000 0.000 0.080 0.884 0.028 0.008
#> SRR1223573 2 0.0146 0.932 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1223574 4 0.3591 0.860 0.000 0.000 0.104 0.816 0.064 0.016
#> SRR1223575 4 0.1340 0.924 0.000 0.040 0.004 0.948 0.000 0.008
#> SRR1223576 1 0.0000 0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223577 3 0.0260 0.988 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1223578 1 0.0000 0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223579 3 0.0260 0.988 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1223580 1 0.4621 0.574 0.612 0.000 0.056 0.000 0.332 0.000
#> SRR1223581 2 0.0865 0.937 0.000 0.964 0.000 0.000 0.000 0.036
#> SRR1223582 6 0.3620 0.479 0.000 0.352 0.000 0.000 0.000 0.648
#> SRR1223583 2 0.1204 0.927 0.000 0.944 0.000 0.000 0.000 0.056
#> SRR1223584 6 0.3684 0.434 0.000 0.372 0.000 0.000 0.000 0.628
#> SRR1223585 2 0.3728 0.377 0.000 0.652 0.000 0.000 0.004 0.344
#> SRR1223586 1 0.1141 0.783 0.948 0.000 0.000 0.000 0.052 0.000
#> SRR1223587 1 0.3706 0.542 0.620 0.000 0.000 0.000 0.380 0.000
#> SRR1223588 1 0.0000 0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223589 1 0.3706 0.542 0.620 0.000 0.000 0.000 0.380 0.000
#> SRR1223590 1 0.3747 0.541 0.604 0.000 0.000 0.000 0.396 0.000
#> SRR1223591 2 0.0146 0.932 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1223592 4 0.0000 0.927 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1223593 2 0.0146 0.932 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1223594 4 0.0363 0.928 0.000 0.012 0.000 0.988 0.000 0.000
#> SRR1223595 4 0.1141 0.919 0.000 0.052 0.000 0.948 0.000 0.000
#> SRR1223596 1 0.0000 0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223597 3 0.0405 0.982 0.008 0.000 0.988 0.000 0.004 0.000
#> SRR1223598 1 0.0260 0.794 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR1223599 3 0.0405 0.982 0.008 0.000 0.988 0.000 0.004 0.000
#> SRR1223600 1 0.4621 0.574 0.612 0.000 0.056 0.000 0.332 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", "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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5090 0.492 0.492
#> 3 3 0.979 0.931 0.970 0.1715 0.905 0.809
#> 4 4 0.823 0.872 0.915 0.1291 0.877 0.705
#> 5 5 0.773 0.853 0.907 0.0526 0.992 0.974
#> 6 6 0.756 0.750 0.876 0.0397 0.995 0.985
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223542 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223543 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223544 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223545 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223546 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223547 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223548 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223549 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223550 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223551 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223552 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223553 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223554 3 0.581 0.500 0.000 0.336 0.664
#> SRR1223555 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223556 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223557 3 0.280 0.878 0.092 0.000 0.908
#> SRR1223558 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223559 3 0.254 0.888 0.080 0.000 0.920
#> SRR1223560 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223561 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223562 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223563 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223564 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223565 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223566 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223567 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223568 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223569 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223570 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223571 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223572 2 0.510 0.631 0.000 0.752 0.248
#> SRR1223573 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223574 3 0.226 0.851 0.000 0.068 0.932
#> SRR1223575 2 0.103 0.964 0.000 0.976 0.024
#> SRR1223576 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223577 3 0.226 0.888 0.068 0.000 0.932
#> SRR1223578 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223579 3 0.245 0.889 0.076 0.000 0.924
#> SRR1223580 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223581 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223582 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223583 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223584 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223585 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223586 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223587 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223588 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223589 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223590 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223591 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223592 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223593 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223594 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223595 2 0.000 0.989 0.000 1.000 0.000
#> SRR1223596 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223597 1 0.599 0.380 0.632 0.000 0.368
#> SRR1223598 1 0.000 0.965 1.000 0.000 0.000
#> SRR1223599 1 0.625 0.159 0.556 0.000 0.444
#> SRR1223600 1 0.000 0.965 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.0000 0.9563 0.000 1.000 0.000 0.000
#> SRR1223542 2 0.1867 0.8926 0.000 0.928 0.000 0.072
#> SRR1223543 2 0.0000 0.9563 0.000 1.000 0.000 0.000
#> SRR1223544 2 0.0921 0.9396 0.000 0.972 0.000 0.028
#> SRR1223545 2 0.0592 0.9493 0.000 0.984 0.000 0.016
#> SRR1223546 1 0.0000 0.9790 1.000 0.000 0.000 0.000
#> SRR1223547 1 0.0524 0.9736 0.988 0.000 0.008 0.004
#> SRR1223548 1 0.0000 0.9790 1.000 0.000 0.000 0.000
#> SRR1223549 1 0.1398 0.9465 0.956 0.000 0.040 0.004
#> SRR1223550 1 0.0000 0.9790 1.000 0.000 0.000 0.000
#> SRR1223551 2 0.0817 0.9426 0.000 0.976 0.000 0.024
#> SRR1223552 4 0.4877 0.7461 0.000 0.408 0.000 0.592
#> SRR1223553 2 0.0000 0.9563 0.000 1.000 0.000 0.000
#> SRR1223554 4 0.5387 0.0204 0.000 0.016 0.400 0.584
#> SRR1223555 4 0.4830 0.7555 0.000 0.392 0.000 0.608
#> SRR1223556 1 0.0000 0.9790 1.000 0.000 0.000 0.000
#> SRR1223557 3 0.1302 0.8249 0.044 0.000 0.956 0.000
#> SRR1223558 1 0.0000 0.9790 1.000 0.000 0.000 0.000
#> SRR1223559 3 0.1211 0.8252 0.040 0.000 0.960 0.000
#> SRR1223560 1 0.0000 0.9790 1.000 0.000 0.000 0.000
#> SRR1223561 2 0.0000 0.9563 0.000 1.000 0.000 0.000
#> SRR1223562 2 0.4164 0.4376 0.000 0.736 0.000 0.264
#> SRR1223563 2 0.0000 0.9563 0.000 1.000 0.000 0.000
#> SRR1223564 2 0.2345 0.8631 0.000 0.900 0.000 0.100
#> SRR1223565 2 0.0592 0.9493 0.000 0.984 0.000 0.016
#> SRR1223566 1 0.0000 0.9790 1.000 0.000 0.000 0.000
#> SRR1223567 1 0.2831 0.8573 0.876 0.000 0.120 0.004
#> SRR1223568 1 0.0000 0.9790 1.000 0.000 0.000 0.000
#> SRR1223569 1 0.3791 0.7436 0.796 0.000 0.200 0.004
#> SRR1223570 1 0.0188 0.9783 0.996 0.000 0.000 0.004
#> SRR1223571 2 0.0592 0.9491 0.000 0.984 0.000 0.016
#> SRR1223572 4 0.6278 0.4822 0.000 0.120 0.228 0.652
#> SRR1223573 2 0.0707 0.9462 0.000 0.980 0.000 0.020
#> SRR1223574 3 0.4843 0.3038 0.000 0.000 0.604 0.396
#> SRR1223575 4 0.6435 0.6677 0.000 0.224 0.136 0.640
#> SRR1223576 1 0.0188 0.9783 0.996 0.000 0.000 0.004
#> SRR1223577 3 0.0188 0.8078 0.004 0.000 0.996 0.000
#> SRR1223578 1 0.0188 0.9783 0.996 0.000 0.000 0.004
#> SRR1223579 3 0.0336 0.8107 0.008 0.000 0.992 0.000
#> SRR1223580 1 0.0707 0.9675 0.980 0.000 0.020 0.000
#> SRR1223581 2 0.0000 0.9563 0.000 1.000 0.000 0.000
#> SRR1223582 2 0.0469 0.9516 0.000 0.988 0.000 0.012
#> SRR1223583 2 0.0000 0.9563 0.000 1.000 0.000 0.000
#> SRR1223584 2 0.0592 0.9493 0.000 0.984 0.000 0.016
#> SRR1223585 2 0.0000 0.9563 0.000 1.000 0.000 0.000
#> SRR1223586 1 0.0188 0.9783 0.996 0.000 0.000 0.004
#> SRR1223587 1 0.0188 0.9777 0.996 0.000 0.000 0.004
#> SRR1223588 1 0.0000 0.9790 1.000 0.000 0.000 0.000
#> SRR1223589 1 0.0188 0.9777 0.996 0.000 0.000 0.004
#> SRR1223590 1 0.0188 0.9783 0.996 0.000 0.000 0.004
#> SRR1223591 2 0.0707 0.9462 0.000 0.980 0.000 0.020
#> SRR1223592 4 0.4898 0.7375 0.000 0.416 0.000 0.584
#> SRR1223593 2 0.0592 0.9491 0.000 0.984 0.000 0.016
#> SRR1223594 4 0.4898 0.7375 0.000 0.416 0.000 0.584
#> SRR1223595 4 0.4830 0.7555 0.000 0.392 0.000 0.608
#> SRR1223596 1 0.0188 0.9783 0.996 0.000 0.000 0.004
#> SRR1223597 3 0.3688 0.7107 0.208 0.000 0.792 0.000
#> SRR1223598 1 0.0188 0.9783 0.996 0.000 0.000 0.004
#> SRR1223599 3 0.3311 0.7490 0.172 0.000 0.828 0.000
#> SRR1223600 1 0.0592 0.9701 0.984 0.000 0.016 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.0290 0.921 0.000 0.992 0.000 0.008 NA
#> SRR1223542 2 0.4887 0.630 0.000 0.720 0.000 0.148 NA
#> SRR1223543 2 0.0162 0.920 0.000 0.996 0.000 0.000 NA
#> SRR1223544 2 0.2540 0.850 0.000 0.888 0.000 0.024 NA
#> SRR1223545 2 0.0912 0.913 0.000 0.972 0.000 0.012 NA
#> SRR1223546 1 0.0162 0.940 0.996 0.000 0.000 0.000 NA
#> SRR1223547 1 0.2149 0.906 0.916 0.000 0.036 0.000 NA
#> SRR1223548 1 0.0324 0.940 0.992 0.000 0.004 0.000 NA
#> SRR1223549 1 0.2708 0.883 0.884 0.000 0.072 0.000 NA
#> SRR1223550 1 0.0451 0.940 0.988 0.000 0.004 0.000 NA
#> SRR1223551 2 0.1965 0.846 0.000 0.904 0.000 0.096 NA
#> SRR1223552 4 0.3282 0.788 0.000 0.188 0.000 0.804 NA
#> SRR1223553 2 0.0290 0.921 0.000 0.992 0.000 0.008 NA
#> SRR1223554 4 0.7112 0.561 0.000 0.048 0.180 0.516 NA
#> SRR1223555 4 0.2439 0.793 0.000 0.120 0.004 0.876 NA
#> SRR1223556 1 0.0162 0.940 0.996 0.000 0.000 0.000 NA
#> SRR1223557 3 0.0963 0.922 0.036 0.000 0.964 0.000 NA
#> SRR1223558 1 0.0162 0.940 0.996 0.000 0.000 0.000 NA
#> SRR1223559 3 0.0671 0.914 0.016 0.000 0.980 0.000 NA
#> SRR1223560 1 0.2625 0.858 0.876 0.000 0.108 0.000 NA
#> SRR1223561 2 0.0290 0.921 0.000 0.992 0.000 0.008 NA
#> SRR1223562 2 0.5731 0.470 0.000 0.624 0.000 0.180 NA
#> SRR1223563 2 0.0162 0.920 0.000 0.996 0.000 0.000 NA
#> SRR1223564 2 0.5628 0.506 0.000 0.632 0.000 0.148 NA
#> SRR1223565 2 0.1310 0.904 0.000 0.956 0.000 0.024 NA
#> SRR1223566 1 0.0290 0.940 0.992 0.000 0.000 0.000 NA
#> SRR1223567 1 0.4113 0.776 0.784 0.000 0.140 0.000 NA
#> SRR1223568 1 0.0000 0.941 1.000 0.000 0.000 0.000 NA
#> SRR1223569 1 0.5150 0.553 0.652 0.000 0.272 0.000 NA
#> SRR1223570 1 0.0324 0.939 0.992 0.000 0.004 0.000 NA
#> SRR1223571 2 0.0510 0.918 0.000 0.984 0.000 0.016 NA
#> SRR1223572 4 0.5348 0.740 0.000 0.072 0.076 0.736 NA
#> SRR1223573 2 0.0880 0.909 0.000 0.968 0.000 0.032 NA
#> SRR1223574 4 0.6915 0.311 0.000 0.004 0.276 0.360 NA
#> SRR1223575 4 0.1894 0.720 0.000 0.008 0.072 0.920 NA
#> SRR1223576 1 0.0162 0.940 0.996 0.000 0.000 0.000 NA
#> SRR1223577 3 0.1059 0.919 0.020 0.000 0.968 0.008 NA
#> SRR1223578 1 0.0162 0.940 0.996 0.000 0.000 0.000 NA
#> SRR1223579 3 0.1026 0.922 0.024 0.000 0.968 0.004 NA
#> SRR1223580 1 0.3098 0.819 0.836 0.000 0.148 0.000 NA
#> SRR1223581 2 0.0290 0.921 0.000 0.992 0.000 0.008 NA
#> SRR1223582 2 0.0404 0.918 0.000 0.988 0.000 0.000 NA
#> SRR1223583 2 0.0162 0.921 0.000 0.996 0.000 0.004 NA
#> SRR1223584 2 0.0404 0.918 0.000 0.988 0.000 0.000 NA
#> SRR1223585 2 0.0451 0.918 0.000 0.988 0.000 0.004 NA
#> SRR1223586 1 0.0162 0.940 0.996 0.000 0.000 0.000 NA
#> SRR1223587 1 0.1408 0.922 0.948 0.000 0.008 0.000 NA
#> SRR1223588 1 0.0000 0.941 1.000 0.000 0.000 0.000 NA
#> SRR1223589 1 0.1331 0.922 0.952 0.000 0.008 0.000 NA
#> SRR1223590 1 0.0162 0.940 0.996 0.000 0.000 0.000 NA
#> SRR1223591 2 0.0609 0.916 0.000 0.980 0.000 0.020 NA
#> SRR1223592 4 0.3177 0.778 0.000 0.208 0.000 0.792 NA
#> SRR1223593 2 0.0404 0.920 0.000 0.988 0.000 0.012 NA
#> SRR1223594 4 0.3333 0.778 0.000 0.208 0.000 0.788 NA
#> SRR1223595 4 0.2621 0.790 0.000 0.112 0.008 0.876 NA
#> SRR1223596 1 0.0162 0.940 0.996 0.000 0.000 0.000 NA
#> SRR1223597 3 0.2723 0.853 0.124 0.000 0.864 0.000 NA
#> SRR1223598 1 0.0404 0.940 0.988 0.000 0.000 0.000 NA
#> SRR1223599 3 0.2574 0.868 0.112 0.000 0.876 0.000 NA
#> SRR1223600 1 0.3055 0.822 0.840 0.000 0.144 0.000 NA
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.0146 0.879 0.000 0.996 0.000 0.004 NA 0.000
#> SRR1223542 2 0.4550 0.643 0.000 0.676 0.000 0.084 NA 0.240
#> SRR1223543 2 0.0692 0.876 0.000 0.976 0.000 0.000 NA 0.004
#> SRR1223544 2 0.3566 0.738 0.000 0.752 0.000 0.024 NA 0.224
#> SRR1223545 2 0.2629 0.836 0.000 0.868 0.000 0.040 NA 0.092
#> SRR1223546 1 0.0000 0.879 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223547 1 0.4662 0.649 0.668 0.000 0.236 0.000 NA 0.000
#> SRR1223548 1 0.0260 0.879 0.992 0.000 0.000 0.000 NA 0.000
#> SRR1223549 1 0.4812 0.612 0.640 0.000 0.264 0.000 NA 0.000
#> SRR1223550 1 0.0260 0.878 0.992 0.000 0.008 0.000 NA 0.000
#> SRR1223551 2 0.2260 0.801 0.000 0.860 0.000 0.140 NA 0.000
#> SRR1223552 4 0.2944 0.637 0.000 0.148 0.000 0.832 NA 0.008
#> SRR1223553 2 0.0146 0.879 0.000 0.996 0.000 0.004 NA 0.000
#> SRR1223554 4 0.6080 -0.718 0.000 0.020 0.136 0.488 NA 0.352
#> SRR1223555 4 0.1078 0.638 0.000 0.016 0.000 0.964 NA 0.008
#> SRR1223556 1 0.0000 0.879 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223557 3 0.0260 0.976 0.008 0.000 0.992 0.000 NA 0.000
#> SRR1223558 1 0.0146 0.879 0.996 0.000 0.000 0.000 NA 0.000
#> SRR1223559 3 0.0260 0.976 0.008 0.000 0.992 0.000 NA 0.000
#> SRR1223560 1 0.3236 0.754 0.796 0.000 0.180 0.000 NA 0.000
#> SRR1223561 2 0.0146 0.879 0.000 0.996 0.000 0.004 NA 0.000
#> SRR1223562 2 0.5307 0.358 0.000 0.512 0.000 0.108 NA 0.380
#> SRR1223563 2 0.0692 0.876 0.000 0.976 0.000 0.000 NA 0.004
#> SRR1223564 2 0.4911 0.437 0.000 0.548 0.000 0.068 NA 0.384
#> SRR1223565 2 0.3982 0.751 0.000 0.764 0.000 0.076 NA 0.156
#> SRR1223566 1 0.0000 0.879 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223567 1 0.5745 0.557 0.596 0.000 0.260 0.000 NA 0.048
#> SRR1223568 1 0.0260 0.878 0.992 0.000 0.000 0.000 NA 0.000
#> SRR1223569 1 0.6985 0.248 0.432 0.000 0.300 0.000 NA 0.172
#> SRR1223570 1 0.0000 0.879 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223571 2 0.1327 0.862 0.000 0.936 0.000 0.064 NA 0.000
#> SRR1223572 4 0.3682 0.536 0.000 0.028 0.064 0.824 NA 0.080
#> SRR1223573 2 0.1267 0.864 0.000 0.940 0.000 0.060 NA 0.000
#> SRR1223574 6 0.5772 0.000 0.000 0.000 0.156 0.368 NA 0.472
#> SRR1223575 4 0.1565 0.607 0.000 0.004 0.000 0.940 NA 0.028
#> SRR1223576 1 0.0000 0.879 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223577 3 0.0363 0.966 0.000 0.000 0.988 0.000 NA 0.000
#> SRR1223578 1 0.0146 0.879 0.996 0.000 0.000 0.000 NA 0.000
#> SRR1223579 3 0.0000 0.972 0.000 0.000 1.000 0.000 NA 0.000
#> SRR1223580 1 0.4265 0.603 0.660 0.000 0.300 0.000 NA 0.000
#> SRR1223581 2 0.0291 0.879 0.000 0.992 0.000 0.004 NA 0.000
#> SRR1223582 2 0.1528 0.872 0.000 0.936 0.000 0.016 NA 0.048
#> SRR1223583 2 0.0547 0.876 0.000 0.980 0.000 0.000 NA 0.000
#> SRR1223584 2 0.1285 0.871 0.000 0.944 0.000 0.004 NA 0.052
#> SRR1223585 2 0.0891 0.877 0.000 0.968 0.000 0.008 NA 0.024
#> SRR1223586 1 0.0000 0.879 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223587 1 0.2510 0.824 0.872 0.000 0.028 0.000 NA 0.000
#> SRR1223588 1 0.0146 0.879 0.996 0.000 0.000 0.000 NA 0.000
#> SRR1223589 1 0.3567 0.775 0.800 0.000 0.100 0.000 NA 0.000
#> SRR1223590 1 0.0000 0.879 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223591 2 0.1387 0.861 0.000 0.932 0.000 0.068 NA 0.000
#> SRR1223592 4 0.3073 0.575 0.000 0.204 0.000 0.788 NA 0.000
#> SRR1223593 2 0.0632 0.875 0.000 0.976 0.000 0.024 NA 0.000
#> SRR1223594 4 0.3065 0.619 0.000 0.172 0.000 0.812 NA 0.008
#> SRR1223595 4 0.1053 0.631 0.000 0.012 0.000 0.964 NA 0.004
#> SRR1223596 1 0.0000 0.879 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223597 3 0.1245 0.956 0.016 0.000 0.952 0.000 NA 0.000
#> SRR1223598 1 0.0260 0.878 0.992 0.000 0.000 0.000 NA 0.000
#> SRR1223599 3 0.0909 0.966 0.012 0.000 0.968 0.000 NA 0.000
#> SRR1223600 1 0.3817 0.675 0.720 0.000 0.252 0.000 NA 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1 1.000 1.000 0.5090 0.492 0.492
#> 3 3 1 0.978 0.996 0.0370 0.984 0.967
#> 4 4 1 0.983 1.000 0.1750 0.905 0.800
#> 5 5 1 0.983 1.000 0.1311 0.919 0.786
#> 6 6 1 0.983 1.000 0.0121 0.992 0.972
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
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.000 0.992 0 1.000 0.000
#> SRR1223542 2 0.000 0.992 0 1.000 0.000
#> SRR1223543 2 0.000 0.992 0 1.000 0.000
#> SRR1223544 2 0.000 0.992 0 1.000 0.000
#> SRR1223545 2 0.000 0.992 0 1.000 0.000
#> SRR1223546 1 0.000 1.000 1 0.000 0.000
#> SRR1223547 1 0.000 1.000 1 0.000 0.000
#> SRR1223548 1 0.000 1.000 1 0.000 0.000
#> SRR1223549 1 0.000 1.000 1 0.000 0.000
#> SRR1223550 1 0.000 1.000 1 0.000 0.000
#> SRR1223551 2 0.000 0.992 0 1.000 0.000
#> SRR1223552 2 0.116 0.978 0 0.972 0.028
#> SRR1223553 2 0.000 0.992 0 1.000 0.000
#> SRR1223554 2 0.116 0.978 0 0.972 0.028
#> SRR1223555 2 0.116 0.978 0 0.972 0.028
#> SRR1223556 1 0.000 1.000 1 0.000 0.000
#> SRR1223557 1 0.000 1.000 1 0.000 0.000
#> SRR1223558 1 0.000 1.000 1 0.000 0.000
#> SRR1223559 1 0.000 1.000 1 0.000 0.000
#> SRR1223560 1 0.000 1.000 1 0.000 0.000
#> SRR1223561 2 0.000 0.992 0 1.000 0.000
#> SRR1223562 2 0.000 0.992 0 1.000 0.000
#> SRR1223563 2 0.000 0.992 0 1.000 0.000
#> SRR1223564 2 0.000 0.992 0 1.000 0.000
#> SRR1223565 2 0.000 0.992 0 1.000 0.000
#> SRR1223566 1 0.000 1.000 1 0.000 0.000
#> SRR1223567 1 0.000 1.000 1 0.000 0.000
#> SRR1223568 1 0.000 1.000 1 0.000 0.000
#> SRR1223569 1 0.000 1.000 1 0.000 0.000
#> SRR1223570 1 0.000 1.000 1 0.000 0.000
#> SRR1223571 2 0.000 0.992 0 1.000 0.000
#> SRR1223572 2 0.116 0.978 0 0.972 0.028
#> SRR1223573 2 0.000 0.992 0 1.000 0.000
#> SRR1223574 3 0.000 0.000 0 0.000 1.000
#> SRR1223575 2 0.116 0.978 0 0.972 0.028
#> SRR1223576 1 0.000 1.000 1 0.000 0.000
#> SRR1223577 1 0.000 1.000 1 0.000 0.000
#> SRR1223578 1 0.000 1.000 1 0.000 0.000
#> SRR1223579 1 0.000 1.000 1 0.000 0.000
#> SRR1223580 1 0.000 1.000 1 0.000 0.000
#> SRR1223581 2 0.000 0.992 0 1.000 0.000
#> SRR1223582 2 0.000 0.992 0 1.000 0.000
#> SRR1223583 2 0.000 0.992 0 1.000 0.000
#> SRR1223584 2 0.000 0.992 0 1.000 0.000
#> SRR1223585 2 0.000 0.992 0 1.000 0.000
#> SRR1223586 1 0.000 1.000 1 0.000 0.000
#> SRR1223587 1 0.000 1.000 1 0.000 0.000
#> SRR1223588 1 0.000 1.000 1 0.000 0.000
#> SRR1223589 1 0.000 1.000 1 0.000 0.000
#> SRR1223590 1 0.000 1.000 1 0.000 0.000
#> SRR1223591 2 0.000 0.992 0 1.000 0.000
#> SRR1223592 2 0.116 0.978 0 0.972 0.028
#> SRR1223593 2 0.000 0.992 0 1.000 0.000
#> SRR1223594 2 0.116 0.978 0 0.972 0.028
#> SRR1223595 2 0.116 0.978 0 0.972 0.028
#> SRR1223596 1 0.000 1.000 1 0.000 0.000
#> SRR1223597 1 0.000 1.000 1 0.000 0.000
#> SRR1223598 1 0.000 1.000 1 0.000 0.000
#> SRR1223599 1 0.000 1.000 1 0.000 0.000
#> SRR1223600 1 0.000 1.000 1 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0 1 0 1 0 0
#> SRR1223542 2 0 1 0 1 0 0
#> SRR1223543 2 0 1 0 1 0 0
#> SRR1223544 2 0 1 0 1 0 0
#> SRR1223545 2 0 1 0 1 0 0
#> SRR1223546 1 0 1 1 0 0 0
#> SRR1223547 1 0 1 1 0 0 0
#> SRR1223548 1 0 1 1 0 0 0
#> SRR1223549 1 0 1 1 0 0 0
#> SRR1223550 1 0 1 1 0 0 0
#> SRR1223551 2 0 1 0 1 0 0
#> SRR1223552 4 0 1 0 0 0 1
#> SRR1223553 2 0 1 0 1 0 0
#> SRR1223554 4 0 1 0 0 0 1
#> SRR1223555 4 0 1 0 0 0 1
#> SRR1223556 1 0 1 1 0 0 0
#> SRR1223557 1 0 1 1 0 0 0
#> SRR1223558 1 0 1 1 0 0 0
#> SRR1223559 1 0 1 1 0 0 0
#> SRR1223560 1 0 1 1 0 0 0
#> SRR1223561 2 0 1 0 1 0 0
#> SRR1223562 2 0 1 0 1 0 0
#> SRR1223563 2 0 1 0 1 0 0
#> SRR1223564 2 0 1 0 1 0 0
#> SRR1223565 2 0 1 0 1 0 0
#> SRR1223566 1 0 1 1 0 0 0
#> SRR1223567 1 0 1 1 0 0 0
#> SRR1223568 1 0 1 1 0 0 0
#> SRR1223569 1 0 1 1 0 0 0
#> SRR1223570 1 0 1 1 0 0 0
#> SRR1223571 2 0 1 0 1 0 0
#> SRR1223572 4 0 1 0 0 0 1
#> SRR1223573 2 0 1 0 1 0 0
#> SRR1223574 3 0 0 0 0 1 0
#> SRR1223575 4 0 1 0 0 0 1
#> SRR1223576 1 0 1 1 0 0 0
#> SRR1223577 1 0 1 1 0 0 0
#> SRR1223578 1 0 1 1 0 0 0
#> SRR1223579 1 0 1 1 0 0 0
#> SRR1223580 1 0 1 1 0 0 0
#> SRR1223581 2 0 1 0 1 0 0
#> SRR1223582 2 0 1 0 1 0 0
#> SRR1223583 2 0 1 0 1 0 0
#> SRR1223584 2 0 1 0 1 0 0
#> SRR1223585 2 0 1 0 1 0 0
#> SRR1223586 1 0 1 1 0 0 0
#> SRR1223587 1 0 1 1 0 0 0
#> SRR1223588 1 0 1 1 0 0 0
#> SRR1223589 1 0 1 1 0 0 0
#> SRR1223590 1 0 1 1 0 0 0
#> SRR1223591 2 0 1 0 1 0 0
#> SRR1223592 4 0 1 0 0 0 1
#> SRR1223593 2 0 1 0 1 0 0
#> SRR1223594 4 0 1 0 0 0 1
#> SRR1223595 4 0 1 0 0 0 1
#> SRR1223596 1 0 1 1 0 0 0
#> SRR1223597 1 0 1 1 0 0 0
#> SRR1223598 1 0 1 1 0 0 0
#> SRR1223599 1 0 1 1 0 0 0
#> SRR1223600 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
#> SRR1223541 2 0 1 0 1 0 0 0
#> SRR1223542 2 0 1 0 1 0 0 0
#> SRR1223543 2 0 1 0 1 0 0 0
#> SRR1223544 2 0 1 0 1 0 0 0
#> SRR1223545 2 0 1 0 1 0 0 0
#> SRR1223546 1 0 1 1 0 0 0 0
#> SRR1223547 1 0 1 1 0 0 0 0
#> SRR1223548 1 0 1 1 0 0 0 0
#> SRR1223549 1 0 1 1 0 0 0 0
#> SRR1223550 1 0 1 1 0 0 0 0
#> SRR1223551 2 0 1 0 1 0 0 0
#> SRR1223552 4 0 1 0 0 0 1 0
#> SRR1223553 2 0 1 0 1 0 0 0
#> SRR1223554 4 0 1 0 0 0 1 0
#> SRR1223555 4 0 1 0 0 0 1 0
#> SRR1223556 1 0 1 1 0 0 0 0
#> SRR1223557 3 0 1 0 0 1 0 0
#> SRR1223558 1 0 1 1 0 0 0 0
#> SRR1223559 3 0 1 0 0 1 0 0
#> SRR1223560 1 0 1 1 0 0 0 0
#> SRR1223561 2 0 1 0 1 0 0 0
#> SRR1223562 2 0 1 0 1 0 0 0
#> SRR1223563 2 0 1 0 1 0 0 0
#> SRR1223564 2 0 1 0 1 0 0 0
#> SRR1223565 2 0 1 0 1 0 0 0
#> SRR1223566 1 0 1 1 0 0 0 0
#> SRR1223567 1 0 1 1 0 0 0 0
#> SRR1223568 1 0 1 1 0 0 0 0
#> SRR1223569 1 0 1 1 0 0 0 0
#> SRR1223570 1 0 1 1 0 0 0 0
#> SRR1223571 2 0 1 0 1 0 0 0
#> SRR1223572 4 0 1 0 0 0 1 0
#> SRR1223573 2 0 1 0 1 0 0 0
#> SRR1223574 5 0 0 0 0 0 0 1
#> SRR1223575 4 0 1 0 0 0 1 0
#> SRR1223576 1 0 1 1 0 0 0 0
#> SRR1223577 3 0 1 0 0 1 0 0
#> SRR1223578 1 0 1 1 0 0 0 0
#> SRR1223579 3 0 1 0 0 1 0 0
#> SRR1223580 1 0 1 1 0 0 0 0
#> SRR1223581 2 0 1 0 1 0 0 0
#> SRR1223582 2 0 1 0 1 0 0 0
#> SRR1223583 2 0 1 0 1 0 0 0
#> SRR1223584 2 0 1 0 1 0 0 0
#> SRR1223585 2 0 1 0 1 0 0 0
#> SRR1223586 1 0 1 1 0 0 0 0
#> SRR1223587 1 0 1 1 0 0 0 0
#> SRR1223588 1 0 1 1 0 0 0 0
#> SRR1223589 1 0 1 1 0 0 0 0
#> SRR1223590 1 0 1 1 0 0 0 0
#> SRR1223591 2 0 1 0 1 0 0 0
#> SRR1223592 4 0 1 0 0 0 1 0
#> SRR1223593 2 0 1 0 1 0 0 0
#> SRR1223594 4 0 1 0 0 0 1 0
#> SRR1223595 4 0 1 0 0 0 1 0
#> SRR1223596 1 0 1 1 0 0 0 0
#> SRR1223597 3 0 1 0 0 1 0 0
#> SRR1223598 1 0 1 1 0 0 0 0
#> SRR1223599 3 0 1 0 0 1 0 0
#> SRR1223600 1 0 1 1 0 0 0 0
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223542 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223543 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223544 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223545 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223546 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223547 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223548 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223549 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223550 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223551 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223552 4 0.0146 0.998 0 0 0 0.996 0.004 0
#> SRR1223553 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223554 4 0.0000 0.997 0 0 0 1.000 0.000 0
#> SRR1223555 5 0.0000 1.000 0 0 0 0.000 1.000 0
#> SRR1223556 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223557 3 0.0000 1.000 0 0 1 0.000 0.000 0
#> SRR1223558 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223559 3 0.0000 1.000 0 0 1 0.000 0.000 0
#> SRR1223560 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223561 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223562 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223563 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223564 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223565 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223566 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223567 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223568 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223569 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223570 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223571 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223572 4 0.0000 0.997 0 0 0 1.000 0.000 0
#> SRR1223573 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223574 6 0.0000 0.000 0 0 0 0.000 0.000 1
#> SRR1223575 5 0.0000 1.000 0 0 0 0.000 1.000 0
#> SRR1223576 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223577 3 0.0000 1.000 0 0 1 0.000 0.000 0
#> SRR1223578 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223579 3 0.0000 1.000 0 0 1 0.000 0.000 0
#> SRR1223580 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223581 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223582 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223583 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223584 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223585 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223586 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223587 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223588 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223589 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223590 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223591 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223592 4 0.0146 0.998 0 0 0 0.996 0.004 0
#> SRR1223593 2 0.0000 1.000 0 1 0 0.000 0.000 0
#> SRR1223594 4 0.0146 0.998 0 0 0 0.996 0.004 0
#> SRR1223595 5 0.0000 1.000 0 0 0 0.000 1.000 0
#> SRR1223596 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223597 3 0.0000 1.000 0 0 1 0.000 0.000 0
#> SRR1223598 1 0.0000 1.000 1 0 0 0.000 0.000 0
#> SRR1223599 3 0.0000 1.000 0 0 1 0.000 0.000 0
#> SRR1223600 1 0.0000 1.000 1 0 0 0.000 0.000 0
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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.5090 0.492 0.492
#> 3 3 0.824 0.897 0.881 0.1830 0.919 0.834
#> 4 4 0.672 0.898 0.853 0.1059 0.893 0.740
#> 5 5 0.602 0.843 0.833 0.0874 1.000 1.000
#> 6 6 0.675 0.768 0.785 0.0549 0.939 0.799
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
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.0000 0.864 0.000 1.000 0.000
#> SRR1223542 2 0.0000 0.864 0.000 1.000 0.000
#> SRR1223543 2 0.0237 0.863 0.004 0.996 0.000
#> SRR1223544 2 0.0237 0.863 0.004 0.996 0.000
#> SRR1223545 2 0.0000 0.864 0.000 1.000 0.000
#> SRR1223546 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223547 1 0.6295 0.994 0.528 0.000 0.472
#> SRR1223548 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223549 1 0.6295 0.994 0.528 0.000 0.472
#> SRR1223550 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223551 2 0.0000 0.864 0.000 1.000 0.000
#> SRR1223552 2 0.6291 0.638 0.468 0.532 0.000
#> SRR1223553 2 0.0237 0.863 0.004 0.996 0.000
#> SRR1223554 2 0.6295 0.636 0.472 0.528 0.000
#> SRR1223555 2 0.6291 0.638 0.468 0.532 0.000
#> SRR1223556 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223557 3 0.0000 1.000 0.000 0.000 1.000
#> SRR1223558 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223559 3 0.0000 1.000 0.000 0.000 1.000
#> SRR1223560 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223561 2 0.0000 0.864 0.000 1.000 0.000
#> SRR1223562 2 0.0000 0.864 0.000 1.000 0.000
#> SRR1223563 2 0.0237 0.863 0.004 0.996 0.000
#> SRR1223564 2 0.0237 0.863 0.004 0.996 0.000
#> SRR1223565 2 0.0000 0.864 0.000 1.000 0.000
#> SRR1223566 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223567 1 0.6295 0.994 0.528 0.000 0.472
#> SRR1223568 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223569 1 0.6295 0.994 0.528 0.000 0.472
#> SRR1223570 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223571 2 0.0000 0.864 0.000 1.000 0.000
#> SRR1223572 2 0.6291 0.638 0.468 0.532 0.000
#> SRR1223573 2 0.0000 0.864 0.000 1.000 0.000
#> SRR1223574 2 0.6295 0.636 0.472 0.528 0.000
#> SRR1223575 2 0.6291 0.638 0.468 0.532 0.000
#> SRR1223576 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223577 3 0.0000 1.000 0.000 0.000 1.000
#> SRR1223578 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223579 3 0.0000 1.000 0.000 0.000 1.000
#> SRR1223580 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223581 2 0.0000 0.864 0.000 1.000 0.000
#> SRR1223582 2 0.0000 0.864 0.000 1.000 0.000
#> SRR1223583 2 0.0237 0.863 0.004 0.996 0.000
#> SRR1223584 2 0.0237 0.863 0.004 0.996 0.000
#> SRR1223585 2 0.0000 0.864 0.000 1.000 0.000
#> SRR1223586 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223587 1 0.6295 0.994 0.528 0.000 0.472
#> SRR1223588 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223589 1 0.6295 0.994 0.528 0.000 0.472
#> SRR1223590 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223591 2 0.0000 0.864 0.000 1.000 0.000
#> SRR1223592 2 0.6291 0.638 0.468 0.532 0.000
#> SRR1223593 2 0.0000 0.864 0.000 1.000 0.000
#> SRR1223594 2 0.6291 0.638 0.468 0.532 0.000
#> SRR1223595 2 0.6291 0.638 0.468 0.532 0.000
#> SRR1223596 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223597 3 0.0000 1.000 0.000 0.000 1.000
#> SRR1223598 1 0.6299 0.998 0.524 0.000 0.476
#> SRR1223599 3 0.0000 1.000 0.000 0.000 1.000
#> SRR1223600 1 0.6299 0.998 0.524 0.000 0.476
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.0000 0.922 0.000 1.000 0.000 0.000
#> SRR1223542 2 0.2647 0.885 0.000 0.880 0.120 0.000
#> SRR1223543 2 0.1118 0.916 0.000 0.964 0.036 0.000
#> SRR1223544 2 0.2973 0.880 0.000 0.856 0.144 0.000
#> SRR1223545 2 0.2345 0.896 0.000 0.900 0.100 0.000
#> SRR1223546 1 0.0000 0.891 1.000 0.000 0.000 0.000
#> SRR1223547 1 0.3486 0.772 0.812 0.000 0.000 0.188
#> SRR1223548 1 0.1474 0.881 0.948 0.000 0.000 0.052
#> SRR1223549 1 0.3942 0.755 0.764 0.000 0.000 0.236
#> SRR1223550 1 0.0000 0.891 1.000 0.000 0.000 0.000
#> SRR1223551 2 0.0817 0.916 0.000 0.976 0.024 0.000
#> SRR1223552 4 0.5527 0.957 0.000 0.356 0.028 0.616
#> SRR1223553 2 0.1211 0.915 0.000 0.960 0.040 0.000
#> SRR1223554 4 0.6653 0.912 0.000 0.356 0.096 0.548
#> SRR1223555 4 0.5007 0.959 0.000 0.356 0.008 0.636
#> SRR1223556 1 0.0000 0.891 1.000 0.000 0.000 0.000
#> SRR1223557 3 0.5466 0.977 0.292 0.000 0.668 0.040
#> SRR1223558 1 0.0188 0.891 0.996 0.000 0.000 0.004
#> SRR1223559 3 0.5466 0.977 0.292 0.000 0.668 0.040
#> SRR1223560 1 0.2760 0.844 0.872 0.000 0.000 0.128
#> SRR1223561 2 0.0000 0.922 0.000 1.000 0.000 0.000
#> SRR1223562 2 0.2647 0.885 0.000 0.880 0.120 0.000
#> SRR1223563 2 0.1118 0.916 0.000 0.964 0.036 0.000
#> SRR1223564 2 0.3024 0.877 0.000 0.852 0.148 0.000
#> SRR1223565 2 0.2345 0.896 0.000 0.900 0.100 0.000
#> SRR1223566 1 0.0000 0.891 1.000 0.000 0.000 0.000
#> SRR1223567 1 0.3486 0.772 0.812 0.000 0.000 0.188
#> SRR1223568 1 0.1474 0.881 0.948 0.000 0.000 0.052
#> SRR1223569 1 0.3942 0.755 0.764 0.000 0.000 0.236
#> SRR1223570 1 0.0000 0.891 1.000 0.000 0.000 0.000
#> SRR1223571 2 0.0817 0.916 0.000 0.976 0.024 0.000
#> SRR1223572 4 0.5237 0.959 0.000 0.356 0.016 0.628
#> SRR1223573 2 0.1022 0.916 0.000 0.968 0.032 0.000
#> SRR1223574 4 0.6653 0.912 0.000 0.356 0.096 0.548
#> SRR1223575 4 0.5007 0.959 0.000 0.356 0.008 0.636
#> SRR1223576 1 0.0000 0.891 1.000 0.000 0.000 0.000
#> SRR1223577 3 0.4356 0.988 0.292 0.000 0.708 0.000
#> SRR1223578 1 0.1211 0.887 0.960 0.000 0.000 0.040
#> SRR1223579 3 0.4356 0.988 0.292 0.000 0.708 0.000
#> SRR1223580 1 0.3172 0.836 0.840 0.000 0.000 0.160
#> SRR1223581 2 0.0000 0.922 0.000 1.000 0.000 0.000
#> SRR1223582 2 0.2281 0.901 0.000 0.904 0.096 0.000
#> SRR1223583 2 0.1118 0.916 0.000 0.964 0.036 0.000
#> SRR1223584 2 0.1792 0.913 0.000 0.932 0.068 0.000
#> SRR1223585 2 0.2345 0.896 0.000 0.900 0.100 0.000
#> SRR1223586 1 0.1022 0.887 0.968 0.000 0.000 0.032
#> SRR1223587 1 0.3801 0.770 0.780 0.000 0.000 0.220
#> SRR1223588 1 0.2011 0.878 0.920 0.000 0.000 0.080
#> SRR1223589 1 0.4164 0.750 0.736 0.000 0.000 0.264
#> SRR1223590 1 0.1022 0.887 0.968 0.000 0.000 0.032
#> SRR1223591 2 0.0817 0.916 0.000 0.976 0.024 0.000
#> SRR1223592 4 0.5855 0.950 0.000 0.356 0.044 0.600
#> SRR1223593 2 0.1022 0.916 0.000 0.968 0.032 0.000
#> SRR1223594 4 0.5855 0.950 0.000 0.356 0.044 0.600
#> SRR1223595 4 0.5007 0.959 0.000 0.356 0.008 0.636
#> SRR1223596 1 0.1022 0.887 0.968 0.000 0.000 0.032
#> SRR1223597 3 0.4356 0.988 0.292 0.000 0.708 0.000
#> SRR1223598 1 0.1211 0.887 0.960 0.000 0.000 0.040
#> SRR1223599 3 0.4356 0.988 0.292 0.000 0.708 0.000
#> SRR1223600 1 0.3172 0.836 0.840 0.000 0.000 0.160
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.0566 0.870 0.000 0.984 0.012 0.000 NA
#> SRR1223542 2 0.4313 0.806 0.000 0.760 0.068 0.000 NA
#> SRR1223543 2 0.2751 0.858 0.000 0.888 0.052 0.004 NA
#> SRR1223544 2 0.4944 0.816 0.000 0.724 0.116 0.004 NA
#> SRR1223545 2 0.4591 0.811 0.000 0.748 0.120 0.000 NA
#> SRR1223546 1 0.0000 0.837 1.000 0.000 0.000 0.000 NA
#> SRR1223547 1 0.4016 0.736 0.716 0.000 0.000 0.012 NA
#> SRR1223548 1 0.3400 0.812 0.828 0.000 0.000 0.036 NA
#> SRR1223549 1 0.4074 0.701 0.636 0.000 0.000 0.000 NA
#> SRR1223550 1 0.0290 0.837 0.992 0.000 0.000 0.008 NA
#> SRR1223551 2 0.1618 0.857 0.000 0.944 0.008 0.008 NA
#> SRR1223552 4 0.3055 0.913 0.000 0.144 0.000 0.840 NA
#> SRR1223553 2 0.2885 0.856 0.000 0.880 0.052 0.004 NA
#> SRR1223554 4 0.5952 0.788 0.000 0.136 0.000 0.560 NA
#> SRR1223555 4 0.4027 0.916 0.000 0.144 0.012 0.800 NA
#> SRR1223556 1 0.0000 0.837 1.000 0.000 0.000 0.000 NA
#> SRR1223557 3 0.4219 0.976 0.184 0.000 0.772 0.024 NA
#> SRR1223558 1 0.0566 0.839 0.984 0.000 0.000 0.012 NA
#> SRR1223559 3 0.4219 0.976 0.184 0.000 0.772 0.024 NA
#> SRR1223560 1 0.4747 0.760 0.720 0.000 0.000 0.084 NA
#> SRR1223561 2 0.0566 0.870 0.000 0.984 0.012 0.000 NA
#> SRR1223562 2 0.4313 0.806 0.000 0.760 0.068 0.000 NA
#> SRR1223563 2 0.2751 0.858 0.000 0.888 0.052 0.004 NA
#> SRR1223564 2 0.5243 0.792 0.000 0.684 0.104 0.004 NA
#> SRR1223565 2 0.4591 0.811 0.000 0.748 0.120 0.000 NA
#> SRR1223566 1 0.0290 0.837 0.992 0.000 0.000 0.008 NA
#> SRR1223567 1 0.4016 0.736 0.716 0.000 0.000 0.012 NA
#> SRR1223568 1 0.3400 0.812 0.828 0.000 0.000 0.036 NA
#> SRR1223569 1 0.4074 0.701 0.636 0.000 0.000 0.000 NA
#> SRR1223570 1 0.0290 0.837 0.992 0.000 0.000 0.008 NA
#> SRR1223571 2 0.1618 0.857 0.000 0.944 0.008 0.008 NA
#> SRR1223572 4 0.2798 0.915 0.000 0.140 0.000 0.852 NA
#> SRR1223573 2 0.1756 0.859 0.000 0.940 0.016 0.008 NA
#> SRR1223574 4 0.5952 0.788 0.000 0.136 0.000 0.560 NA
#> SRR1223575 4 0.4055 0.914 0.000 0.140 0.012 0.800 NA
#> SRR1223576 1 0.0000 0.837 1.000 0.000 0.000 0.000 NA
#> SRR1223577 3 0.2966 0.988 0.184 0.000 0.816 0.000 NA
#> SRR1223578 1 0.1753 0.836 0.936 0.000 0.000 0.032 NA
#> SRR1223579 3 0.2966 0.988 0.184 0.000 0.816 0.000 NA
#> SRR1223580 1 0.5110 0.753 0.680 0.000 0.000 0.096 NA
#> SRR1223581 2 0.0566 0.870 0.000 0.984 0.012 0.000 NA
#> SRR1223582 2 0.3543 0.841 0.000 0.828 0.060 0.000 NA
#> SRR1223583 2 0.2751 0.858 0.000 0.888 0.052 0.004 NA
#> SRR1223584 2 0.3612 0.851 0.000 0.832 0.064 0.004 NA
#> SRR1223585 2 0.4365 0.822 0.000 0.768 0.116 0.000 NA
#> SRR1223586 1 0.1493 0.834 0.948 0.000 0.000 0.024 NA
#> SRR1223587 1 0.4184 0.740 0.700 0.000 0.000 0.016 NA
#> SRR1223588 1 0.3752 0.811 0.804 0.000 0.000 0.048 NA
#> SRR1223589 1 0.4161 0.697 0.608 0.000 0.000 0.000 NA
#> SRR1223590 1 0.1493 0.834 0.948 0.000 0.000 0.024 NA
#> SRR1223591 2 0.1618 0.857 0.000 0.944 0.008 0.008 NA
#> SRR1223592 4 0.3688 0.904 0.000 0.148 0.004 0.812 NA
#> SRR1223593 2 0.1461 0.864 0.000 0.952 0.016 0.004 NA
#> SRR1223594 4 0.3688 0.904 0.000 0.148 0.004 0.812 NA
#> SRR1223595 4 0.4027 0.916 0.000 0.144 0.012 0.800 NA
#> SRR1223596 1 0.1399 0.834 0.952 0.000 0.000 0.020 NA
#> SRR1223597 3 0.2966 0.988 0.184 0.000 0.816 0.000 NA
#> SRR1223598 1 0.1753 0.836 0.936 0.000 0.000 0.032 NA
#> SRR1223599 3 0.2966 0.988 0.184 0.000 0.816 0.000 NA
#> SRR1223600 1 0.5110 0.753 0.680 0.000 0.000 0.096 NA
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.0665 0.798 0.000 0.980 0.004 0.000 NA 0.008
#> SRR1223542 2 0.3782 0.695 0.000 0.636 0.004 0.000 NA 0.000
#> SRR1223543 2 0.2889 0.780 0.000 0.852 0.012 0.000 NA 0.020
#> SRR1223544 2 0.4516 0.686 0.000 0.552 0.008 0.000 NA 0.020
#> SRR1223545 2 0.4725 0.708 0.000 0.652 0.036 0.000 NA 0.024
#> SRR1223546 1 0.0000 0.777 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223547 6 0.4390 0.871 0.472 0.000 0.000 0.004 NA 0.508
#> SRR1223548 1 0.4326 0.587 0.772 0.000 0.000 0.056 NA 0.112
#> SRR1223549 6 0.3984 0.878 0.396 0.000 0.000 0.008 NA 0.596
#> SRR1223550 1 0.0820 0.772 0.972 0.000 0.000 0.012 NA 0.000
#> SRR1223551 2 0.1837 0.787 0.000 0.932 0.012 0.004 NA 0.032
#> SRR1223552 4 0.3900 0.873 0.000 0.136 0.000 0.788 NA 0.056
#> SRR1223553 2 0.3477 0.777 0.000 0.824 0.024 0.000 NA 0.040
#> SRR1223554 4 0.6827 0.706 0.000 0.128 0.004 0.512 NA 0.236
#> SRR1223555 4 0.3333 0.878 0.000 0.128 0.016 0.828 NA 0.004
#> SRR1223556 1 0.0000 0.777 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223557 3 0.3501 0.956 0.084 0.000 0.840 0.028 NA 0.012
#> SRR1223558 1 0.0508 0.777 0.984 0.000 0.000 0.004 NA 0.000
#> SRR1223559 3 0.3504 0.956 0.084 0.000 0.840 0.032 NA 0.012
#> SRR1223560 1 0.5351 0.207 0.568 0.000 0.000 0.000 NA 0.144
#> SRR1223561 2 0.0665 0.798 0.000 0.980 0.004 0.000 NA 0.008
#> SRR1223562 2 0.3782 0.695 0.000 0.636 0.004 0.000 NA 0.000
#> SRR1223563 2 0.2889 0.780 0.000 0.852 0.012 0.000 NA 0.020
#> SRR1223564 2 0.4076 0.675 0.000 0.540 0.000 0.000 NA 0.008
#> SRR1223565 2 0.4725 0.708 0.000 0.652 0.036 0.000 NA 0.024
#> SRR1223566 1 0.0820 0.772 0.972 0.000 0.000 0.012 NA 0.000
#> SRR1223567 6 0.4390 0.871 0.472 0.000 0.000 0.004 NA 0.508
#> SRR1223568 1 0.4326 0.587 0.772 0.000 0.000 0.056 NA 0.112
#> SRR1223569 6 0.3747 0.881 0.396 0.000 0.000 0.000 NA 0.604
#> SRR1223570 1 0.0820 0.772 0.972 0.000 0.000 0.012 NA 0.000
#> SRR1223571 2 0.1837 0.787 0.000 0.932 0.012 0.004 NA 0.032
#> SRR1223572 4 0.3424 0.877 0.000 0.128 0.000 0.816 NA 0.048
#> SRR1223573 2 0.2094 0.786 0.000 0.920 0.016 0.004 NA 0.032
#> SRR1223574 4 0.6827 0.706 0.000 0.128 0.004 0.512 NA 0.236
#> SRR1223575 4 0.3443 0.878 0.000 0.128 0.016 0.824 NA 0.008
#> SRR1223576 1 0.0000 0.777 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1223577 3 0.1610 0.978 0.084 0.000 0.916 0.000 NA 0.000
#> SRR1223578 1 0.1755 0.767 0.932 0.000 0.000 0.032 NA 0.008
#> SRR1223579 3 0.1610 0.978 0.084 0.000 0.916 0.000 NA 0.000
#> SRR1223580 1 0.5440 0.205 0.552 0.000 0.000 0.000 NA 0.152
#> SRR1223581 2 0.0665 0.798 0.000 0.980 0.004 0.000 NA 0.008
#> SRR1223582 2 0.3468 0.738 0.000 0.712 0.004 0.000 NA 0.000
#> SRR1223583 2 0.2889 0.780 0.000 0.852 0.012 0.000 NA 0.020
#> SRR1223584 2 0.3979 0.753 0.000 0.708 0.008 0.000 NA 0.020
#> SRR1223585 2 0.4668 0.717 0.000 0.664 0.036 0.000 NA 0.024
#> SRR1223586 1 0.1503 0.771 0.944 0.000 0.000 0.032 NA 0.008
#> SRR1223587 6 0.4224 0.854 0.476 0.000 0.000 0.004 NA 0.512
#> SRR1223588 1 0.4752 0.584 0.740 0.000 0.000 0.076 NA 0.116
#> SRR1223589 6 0.3965 0.875 0.388 0.000 0.000 0.008 NA 0.604
#> SRR1223590 1 0.1503 0.771 0.944 0.000 0.000 0.032 NA 0.008
#> SRR1223591 2 0.1837 0.787 0.000 0.932 0.012 0.004 NA 0.032
#> SRR1223592 4 0.4263 0.866 0.000 0.140 0.000 0.764 NA 0.068
#> SRR1223593 2 0.1787 0.791 0.000 0.932 0.016 0.000 NA 0.032
#> SRR1223594 4 0.4263 0.866 0.000 0.140 0.000 0.764 NA 0.068
#> SRR1223595 4 0.3333 0.878 0.000 0.128 0.016 0.828 NA 0.004
#> SRR1223596 1 0.1149 0.772 0.960 0.000 0.000 0.024 NA 0.008
#> SRR1223597 3 0.1610 0.978 0.084 0.000 0.916 0.000 NA 0.000
#> SRR1223598 1 0.1755 0.767 0.932 0.000 0.000 0.032 NA 0.008
#> SRR1223599 3 0.1610 0.978 0.084 0.000 0.916 0.000 NA 0.000
#> SRR1223600 1 0.5440 0.205 0.552 0.000 0.000 0.000 NA 0.152
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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.5090 0.492 0.492
#> 3 3 1.000 0.997 0.996 0.2086 0.893 0.783
#> 4 4 1.000 0.998 0.996 0.1298 0.919 0.789
#> 5 5 0.935 0.973 0.979 0.0228 0.992 0.974
#> 6 6 0.840 0.782 0.900 0.0603 0.964 0.880
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3
There is also optional best \(k\) = 2 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223542 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223543 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223544 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223545 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223546 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223547 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223548 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223549 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223550 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223551 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223552 3 0.0892 0.997 0.000 0.020 0.980
#> SRR1223553 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223554 3 0.0747 0.998 0.000 0.016 0.984
#> SRR1223555 3 0.0747 0.998 0.000 0.016 0.984
#> SRR1223556 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223557 1 0.0747 0.988 0.984 0.000 0.016
#> SRR1223558 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223559 1 0.0747 0.988 0.984 0.000 0.016
#> SRR1223560 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223561 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223562 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223563 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223564 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223565 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223566 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223567 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223568 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223569 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223570 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223571 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223572 3 0.0747 0.998 0.000 0.016 0.984
#> SRR1223573 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223574 3 0.0747 0.998 0.000 0.016 0.984
#> SRR1223575 3 0.0747 0.998 0.000 0.016 0.984
#> SRR1223576 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223577 1 0.0747 0.988 0.984 0.000 0.016
#> SRR1223578 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223579 1 0.0747 0.988 0.984 0.000 0.016
#> SRR1223580 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223581 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223582 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223583 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223584 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223585 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223586 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223587 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223588 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223589 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223590 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223591 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223592 3 0.0892 0.997 0.000 0.020 0.980
#> SRR1223593 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1223594 3 0.0892 0.997 0.000 0.020 0.980
#> SRR1223595 3 0.0747 0.998 0.000 0.016 0.984
#> SRR1223596 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223597 1 0.0747 0.988 0.984 0.000 0.016
#> SRR1223598 1 0.0000 0.997 1.000 0.000 0.000
#> SRR1223599 1 0.0747 0.988 0.984 0.000 0.016
#> SRR1223600 1 0.0000 0.997 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223542 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223543 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223544 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223545 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223546 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223547 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223548 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223549 1 0.0188 0.997 0.996 0 0.004 0.000
#> SRR1223550 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223551 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223552 4 0.0000 0.995 0.000 0 0.000 1.000
#> SRR1223553 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223554 4 0.0707 0.986 0.000 0 0.020 0.980
#> SRR1223555 4 0.0000 0.995 0.000 0 0.000 1.000
#> SRR1223556 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223557 3 0.0921 1.000 0.028 0 0.972 0.000
#> SRR1223558 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223559 3 0.0921 1.000 0.028 0 0.972 0.000
#> SRR1223560 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223561 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223562 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223563 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223564 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223565 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223566 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223567 1 0.0188 0.997 0.996 0 0.004 0.000
#> SRR1223568 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223569 1 0.0188 0.997 0.996 0 0.004 0.000
#> SRR1223570 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223571 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223572 4 0.0000 0.995 0.000 0 0.000 1.000
#> SRR1223573 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223574 4 0.0921 0.981 0.000 0 0.028 0.972
#> SRR1223575 4 0.0000 0.995 0.000 0 0.000 1.000
#> SRR1223576 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223577 3 0.0921 1.000 0.028 0 0.972 0.000
#> SRR1223578 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223579 3 0.0921 1.000 0.028 0 0.972 0.000
#> SRR1223580 1 0.0188 0.997 0.996 0 0.004 0.000
#> SRR1223581 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223582 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223583 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223584 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223585 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223586 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223587 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223588 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223589 1 0.0188 0.997 0.996 0 0.004 0.000
#> SRR1223590 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223591 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223592 4 0.0000 0.995 0.000 0 0.000 1.000
#> SRR1223593 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1223594 4 0.0000 0.995 0.000 0 0.000 1.000
#> SRR1223595 4 0.0000 0.995 0.000 0 0.000 1.000
#> SRR1223596 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223597 3 0.0921 1.000 0.028 0 0.972 0.000
#> SRR1223598 1 0.0000 0.999 1.000 0 0.000 0.000
#> SRR1223599 3 0.0921 1.000 0.028 0 0.972 0.000
#> SRR1223600 1 0.0188 0.997 0.996 0 0.004 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> SRR1223542 2 0.0510 0.990 0.000 0.984 0.000 0.000 0.016
#> SRR1223543 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> SRR1223544 2 0.0510 0.990 0.000 0.984 0.000 0.000 0.016
#> SRR1223545 2 0.0290 0.993 0.000 0.992 0.000 0.000 0.008
#> SRR1223546 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> SRR1223547 1 0.2074 0.916 0.896 0.000 0.000 0.000 0.104
#> SRR1223548 1 0.0290 0.969 0.992 0.000 0.000 0.000 0.008
#> SRR1223549 1 0.2179 0.914 0.888 0.000 0.000 0.000 0.112
#> SRR1223550 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> SRR1223551 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> SRR1223552 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000
#> SRR1223553 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> SRR1223554 5 0.3661 0.796 0.000 0.000 0.000 0.276 0.724
#> SRR1223555 4 0.0162 0.995 0.000 0.000 0.004 0.996 0.000
#> SRR1223556 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> SRR1223557 3 0.0162 1.000 0.004 0.000 0.996 0.000 0.000
#> SRR1223558 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> SRR1223559 3 0.0162 1.000 0.004 0.000 0.996 0.000 0.000
#> SRR1223560 1 0.0404 0.968 0.988 0.000 0.000 0.000 0.012
#> SRR1223561 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> SRR1223562 2 0.0510 0.990 0.000 0.984 0.000 0.000 0.016
#> SRR1223563 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> SRR1223564 2 0.0510 0.990 0.000 0.984 0.000 0.000 0.016
#> SRR1223565 2 0.0290 0.993 0.000 0.992 0.000 0.000 0.008
#> SRR1223566 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> SRR1223567 1 0.2074 0.916 0.896 0.000 0.000 0.000 0.104
#> SRR1223568 1 0.0290 0.969 0.992 0.000 0.000 0.000 0.008
#> SRR1223569 1 0.2179 0.914 0.888 0.000 0.000 0.000 0.112
#> SRR1223570 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> SRR1223571 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> SRR1223572 4 0.0404 0.984 0.000 0.000 0.000 0.988 0.012
#> SRR1223573 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> SRR1223574 5 0.2377 0.825 0.000 0.000 0.000 0.128 0.872
#> SRR1223575 4 0.0162 0.995 0.000 0.000 0.004 0.996 0.000
#> SRR1223576 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> SRR1223577 3 0.0162 1.000 0.004 0.000 0.996 0.000 0.000
#> SRR1223578 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> SRR1223579 3 0.0162 1.000 0.004 0.000 0.996 0.000 0.000
#> SRR1223580 1 0.0404 0.968 0.988 0.000 0.000 0.000 0.012
#> SRR1223581 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> SRR1223582 2 0.0510 0.990 0.000 0.984 0.000 0.000 0.016
#> SRR1223583 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> SRR1223584 2 0.0510 0.990 0.000 0.984 0.000 0.000 0.016
#> SRR1223585 2 0.0290 0.993 0.000 0.992 0.000 0.000 0.008
#> SRR1223586 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> SRR1223587 1 0.2074 0.916 0.896 0.000 0.000 0.000 0.104
#> SRR1223588 1 0.0290 0.969 0.992 0.000 0.000 0.000 0.008
#> SRR1223589 1 0.2179 0.914 0.888 0.000 0.000 0.000 0.112
#> SRR1223590 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> SRR1223591 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> SRR1223592 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000
#> SRR1223593 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> SRR1223594 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000
#> SRR1223595 4 0.0162 0.995 0.000 0.000 0.004 0.996 0.000
#> SRR1223596 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> SRR1223597 3 0.0162 1.000 0.004 0.000 0.996 0.000 0.000
#> SRR1223598 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> SRR1223599 3 0.0162 1.000 0.004 0.000 0.996 0.000 0.000
#> SRR1223600 1 0.0404 0.968 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
#> SRR1223541 2 0.0000 0.927 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1223542 2 0.2896 0.874 0.000 0.824 0.000 0.000 0.160 0.016
#> SRR1223543 2 0.0937 0.920 0.000 0.960 0.000 0.000 0.040 0.000
#> SRR1223544 2 0.3200 0.865 0.000 0.788 0.000 0.000 0.196 0.016
#> SRR1223545 2 0.2494 0.893 0.000 0.864 0.000 0.000 0.120 0.016
#> SRR1223546 1 0.0000 0.792 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223547 1 0.3854 -0.826 0.536 0.000 0.000 0.000 0.464 0.000
#> SRR1223548 1 0.1814 0.721 0.900 0.000 0.000 0.000 0.100 0.000
#> SRR1223549 5 0.3854 1.000 0.464 0.000 0.000 0.000 0.536 0.000
#> SRR1223550 1 0.0000 0.792 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223551 2 0.0146 0.927 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1223552 4 0.0000 0.881 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1223553 2 0.1082 0.919 0.000 0.956 0.000 0.004 0.040 0.000
#> SRR1223554 6 0.3043 0.785 0.000 0.000 0.000 0.200 0.008 0.792
#> SRR1223555 4 0.2912 0.842 0.000 0.000 0.000 0.784 0.216 0.000
#> SRR1223556 1 0.0000 0.792 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1223558 1 0.0146 0.791 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1223559 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1223560 1 0.2135 0.689 0.872 0.000 0.000 0.000 0.128 0.000
#> SRR1223561 2 0.0000 0.927 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1223562 2 0.2896 0.874 0.000 0.824 0.000 0.000 0.160 0.016
#> SRR1223563 2 0.0937 0.920 0.000 0.960 0.000 0.000 0.040 0.000
#> SRR1223564 2 0.3231 0.863 0.000 0.784 0.000 0.000 0.200 0.016
#> SRR1223565 2 0.2494 0.893 0.000 0.864 0.000 0.000 0.120 0.016
#> SRR1223566 1 0.0000 0.792 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223567 1 0.3854 -0.826 0.536 0.000 0.000 0.000 0.464 0.000
#> SRR1223568 1 0.1814 0.721 0.900 0.000 0.000 0.000 0.100 0.000
#> SRR1223569 5 0.3854 1.000 0.464 0.000 0.000 0.000 0.536 0.000
#> SRR1223570 1 0.0000 0.792 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223571 2 0.0146 0.927 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1223572 4 0.0260 0.877 0.000 0.000 0.000 0.992 0.000 0.008
#> SRR1223573 2 0.0146 0.927 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1223574 6 0.0458 0.814 0.000 0.000 0.000 0.016 0.000 0.984
#> SRR1223575 4 0.2912 0.842 0.000 0.000 0.000 0.784 0.216 0.000
#> SRR1223576 1 0.0000 0.792 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1223578 1 0.0363 0.788 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR1223579 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1223580 1 0.2362 0.671 0.860 0.000 0.004 0.000 0.136 0.000
#> SRR1223581 2 0.0000 0.927 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1223582 2 0.2664 0.887 0.000 0.848 0.000 0.000 0.136 0.016
#> SRR1223583 2 0.0937 0.920 0.000 0.960 0.000 0.000 0.040 0.000
#> SRR1223584 2 0.2653 0.890 0.000 0.844 0.000 0.000 0.144 0.012
#> SRR1223585 2 0.2060 0.907 0.000 0.900 0.000 0.000 0.084 0.016
#> SRR1223586 1 0.0000 0.792 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223587 1 0.3854 -0.826 0.536 0.000 0.000 0.000 0.464 0.000
#> SRR1223588 1 0.1610 0.735 0.916 0.000 0.000 0.000 0.084 0.000
#> SRR1223589 5 0.3854 1.000 0.464 0.000 0.000 0.000 0.536 0.000
#> SRR1223590 1 0.0000 0.792 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223591 2 0.0146 0.927 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1223592 4 0.0000 0.881 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1223593 2 0.0146 0.927 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1223594 4 0.0000 0.881 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1223595 4 0.2912 0.842 0.000 0.000 0.000 0.784 0.216 0.000
#> SRR1223596 1 0.0000 0.792 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1223598 1 0.0547 0.784 0.980 0.000 0.000 0.000 0.020 0.000
#> SRR1223599 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1223600 1 0.2178 0.683 0.868 0.000 0.000 0.000 0.132 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", "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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5090 0.492 0.492
#> 3 3 0.812 0.969 0.963 0.1670 0.919 0.834
#> 4 4 1.000 1.000 1.000 0.1733 0.893 0.740
#> 5 5 0.841 0.696 0.792 0.0873 0.932 0.780
#> 6 6 0.939 0.906 0.944 0.0766 0.868 0.531
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
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223542 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223543 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223544 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223545 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223546 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223547 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223548 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223549 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223550 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223551 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223552 2 0.382 0.894 0.000 0.852 0.148
#> SRR1223553 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223554 2 0.382 0.894 0.000 0.852 0.148
#> SRR1223555 2 0.382 0.894 0.000 0.852 0.148
#> SRR1223556 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223557 3 0.382 1.000 0.148 0.000 0.852
#> SRR1223558 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223559 3 0.382 1.000 0.148 0.000 0.852
#> SRR1223560 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223561 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223562 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223563 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223564 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223565 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223566 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223567 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223568 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223569 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223570 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223571 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223572 2 0.382 0.894 0.000 0.852 0.148
#> SRR1223573 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223574 2 0.382 0.894 0.000 0.852 0.148
#> SRR1223575 2 0.382 0.894 0.000 0.852 0.148
#> SRR1223576 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223577 3 0.382 1.000 0.148 0.000 0.852
#> SRR1223578 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223579 3 0.382 1.000 0.148 0.000 0.852
#> SRR1223580 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223581 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223582 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223583 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223584 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223585 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223586 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223587 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223588 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223589 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223590 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223591 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223592 2 0.382 0.894 0.000 0.852 0.148
#> SRR1223593 2 0.000 0.957 0.000 1.000 0.000
#> SRR1223594 2 0.382 0.894 0.000 0.852 0.148
#> SRR1223595 2 0.382 0.894 0.000 0.852 0.148
#> SRR1223596 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223597 3 0.382 1.000 0.148 0.000 0.852
#> SRR1223598 1 0.000 1.000 1.000 0.000 0.000
#> SRR1223599 3 0.382 1.000 0.148 0.000 0.852
#> SRR1223600 1 0.000 1.000 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0 1 0 1 0 0
#> SRR1223542 2 0 1 0 1 0 0
#> SRR1223543 2 0 1 0 1 0 0
#> SRR1223544 2 0 1 0 1 0 0
#> SRR1223545 2 0 1 0 1 0 0
#> SRR1223546 1 0 1 1 0 0 0
#> SRR1223547 1 0 1 1 0 0 0
#> SRR1223548 1 0 1 1 0 0 0
#> SRR1223549 1 0 1 1 0 0 0
#> SRR1223550 1 0 1 1 0 0 0
#> SRR1223551 2 0 1 0 1 0 0
#> SRR1223552 4 0 1 0 0 0 1
#> SRR1223553 2 0 1 0 1 0 0
#> SRR1223554 4 0 1 0 0 0 1
#> SRR1223555 4 0 1 0 0 0 1
#> SRR1223556 1 0 1 1 0 0 0
#> SRR1223557 3 0 1 0 0 1 0
#> SRR1223558 1 0 1 1 0 0 0
#> SRR1223559 3 0 1 0 0 1 0
#> SRR1223560 1 0 1 1 0 0 0
#> SRR1223561 2 0 1 0 1 0 0
#> SRR1223562 2 0 1 0 1 0 0
#> SRR1223563 2 0 1 0 1 0 0
#> SRR1223564 2 0 1 0 1 0 0
#> SRR1223565 2 0 1 0 1 0 0
#> SRR1223566 1 0 1 1 0 0 0
#> SRR1223567 1 0 1 1 0 0 0
#> SRR1223568 1 0 1 1 0 0 0
#> SRR1223569 1 0 1 1 0 0 0
#> SRR1223570 1 0 1 1 0 0 0
#> SRR1223571 2 0 1 0 1 0 0
#> SRR1223572 4 0 1 0 0 0 1
#> SRR1223573 2 0 1 0 1 0 0
#> SRR1223574 4 0 1 0 0 0 1
#> SRR1223575 4 0 1 0 0 0 1
#> SRR1223576 1 0 1 1 0 0 0
#> SRR1223577 3 0 1 0 0 1 0
#> SRR1223578 1 0 1 1 0 0 0
#> SRR1223579 3 0 1 0 0 1 0
#> SRR1223580 1 0 1 1 0 0 0
#> SRR1223581 2 0 1 0 1 0 0
#> SRR1223582 2 0 1 0 1 0 0
#> SRR1223583 2 0 1 0 1 0 0
#> SRR1223584 2 0 1 0 1 0 0
#> SRR1223585 2 0 1 0 1 0 0
#> SRR1223586 1 0 1 1 0 0 0
#> SRR1223587 1 0 1 1 0 0 0
#> SRR1223588 1 0 1 1 0 0 0
#> SRR1223589 1 0 1 1 0 0 0
#> SRR1223590 1 0 1 1 0 0 0
#> SRR1223591 2 0 1 0 1 0 0
#> SRR1223592 4 0 1 0 0 0 1
#> SRR1223593 2 0 1 0 1 0 0
#> SRR1223594 4 0 1 0 0 0 1
#> SRR1223595 4 0 1 0 0 0 1
#> SRR1223596 1 0 1 1 0 0 0
#> SRR1223597 3 0 1 0 0 1 0
#> SRR1223598 1 0 1 1 0 0 0
#> SRR1223599 3 0 1 0 0 1 0
#> SRR1223600 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
#> SRR1223541 5 0.428 0.612 0.000 0.456 0 0.000 0.544
#> SRR1223542 2 0.297 0.406 0.000 0.816 0 0.000 0.184
#> SRR1223543 2 0.403 0.221 0.000 0.648 0 0.000 0.352
#> SRR1223544 2 0.000 0.515 0.000 1.000 0 0.000 0.000
#> SRR1223545 2 0.373 0.312 0.000 0.712 0 0.000 0.288
#> SRR1223546 1 0.427 0.867 0.556 0.000 0 0.444 0.000
#> SRR1223547 1 0.029 0.629 0.992 0.000 0 0.008 0.000
#> SRR1223548 1 0.000 0.628 1.000 0.000 0 0.000 0.000
#> SRR1223549 1 0.000 0.628 1.000 0.000 0 0.000 0.000
#> SRR1223550 1 0.427 0.867 0.556 0.000 0 0.444 0.000
#> SRR1223551 5 0.428 0.612 0.000 0.456 0 0.000 0.544
#> SRR1223552 4 0.428 0.996 0.000 0.000 0 0.544 0.456
#> SRR1223553 2 0.403 0.221 0.000 0.648 0 0.000 0.352
#> SRR1223554 4 0.427 0.993 0.000 0.000 0 0.556 0.444
#> SRR1223555 4 0.428 0.996 0.000 0.000 0 0.544 0.456
#> SRR1223556 1 0.427 0.867 0.556 0.000 0 0.444 0.000
#> SRR1223557 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1223558 1 0.427 0.867 0.556 0.000 0 0.444 0.000
#> SRR1223559 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1223560 1 0.427 0.867 0.556 0.000 0 0.444 0.000
#> SRR1223561 2 0.411 0.137 0.000 0.624 0 0.000 0.376
#> SRR1223562 2 0.297 0.406 0.000 0.816 0 0.000 0.184
#> SRR1223563 2 0.403 0.221 0.000 0.648 0 0.000 0.352
#> SRR1223564 2 0.000 0.515 0.000 1.000 0 0.000 0.000
#> SRR1223565 2 0.179 0.508 0.000 0.916 0 0.000 0.084
#> SRR1223566 1 0.427 0.867 0.556 0.000 0 0.444 0.000
#> SRR1223567 1 0.000 0.628 1.000 0.000 0 0.000 0.000
#> SRR1223568 1 0.000 0.628 1.000 0.000 0 0.000 0.000
#> SRR1223569 1 0.000 0.628 1.000 0.000 0 0.000 0.000
#> SRR1223570 1 0.427 0.867 0.556 0.000 0 0.444 0.000
#> SRR1223571 5 0.428 0.612 0.000 0.456 0 0.000 0.544
#> SRR1223572 4 0.427 0.993 0.000 0.000 0 0.556 0.444
#> SRR1223573 5 0.428 0.612 0.000 0.456 0 0.000 0.544
#> SRR1223574 4 0.427 0.993 0.000 0.000 0 0.556 0.444
#> SRR1223575 4 0.428 0.996 0.000 0.000 0 0.544 0.456
#> SRR1223576 1 0.427 0.867 0.556 0.000 0 0.444 0.000
#> SRR1223577 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1223578 1 0.427 0.867 0.556 0.000 0 0.444 0.000
#> SRR1223579 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1223580 1 0.426 0.866 0.564 0.000 0 0.436 0.000
#> SRR1223581 5 0.428 0.612 0.000 0.456 0 0.000 0.544
#> SRR1223582 2 0.297 0.406 0.000 0.816 0 0.000 0.184
#> SRR1223583 2 0.403 0.221 0.000 0.648 0 0.000 0.352
#> SRR1223584 2 0.127 0.506 0.000 0.948 0 0.000 0.052
#> SRR1223585 5 0.428 0.612 0.000 0.456 0 0.000 0.544
#> SRR1223586 1 0.427 0.867 0.556 0.000 0 0.444 0.000
#> SRR1223587 1 0.426 0.866 0.564 0.000 0 0.436 0.000
#> SRR1223588 1 0.426 0.866 0.564 0.000 0 0.436 0.000
#> SRR1223589 1 0.000 0.628 1.000 0.000 0 0.000 0.000
#> SRR1223590 1 0.427 0.867 0.556 0.000 0 0.444 0.000
#> SRR1223591 5 0.428 0.612 0.000 0.456 0 0.000 0.544
#> SRR1223592 5 0.406 -0.799 0.000 0.000 0 0.360 0.640
#> SRR1223593 5 0.428 0.612 0.000 0.456 0 0.000 0.544
#> SRR1223594 4 0.428 0.996 0.000 0.000 0 0.544 0.456
#> SRR1223595 4 0.428 0.996 0.000 0.000 0 0.544 0.456
#> SRR1223596 1 0.427 0.867 0.556 0.000 0 0.444 0.000
#> SRR1223597 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1223598 1 0.426 0.866 0.564 0.000 0 0.436 0.000
#> SRR1223599 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1223600 1 0.426 0.866 0.564 0.000 0 0.436 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.2527 0.842 0.000 0.832 0 0.000 0.000 0.168
#> SRR1223542 6 0.1141 0.849 0.000 0.052 0 0.000 0.000 0.948
#> SRR1223543 2 0.0632 0.795 0.000 0.976 0 0.000 0.000 0.024
#> SRR1223544 6 0.2823 0.817 0.000 0.204 0 0.000 0.000 0.796
#> SRR1223545 2 0.2454 0.636 0.000 0.840 0 0.000 0.000 0.160
#> SRR1223546 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223547 5 0.0790 0.989 0.032 0.000 0 0.000 0.968 0.000
#> SRR1223548 5 0.0632 0.998 0.024 0.000 0 0.000 0.976 0.000
#> SRR1223549 5 0.0632 0.998 0.024 0.000 0 0.000 0.976 0.000
#> SRR1223550 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223551 2 0.2527 0.842 0.000 0.832 0 0.000 0.000 0.168
#> SRR1223552 4 0.0000 0.954 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223553 2 0.0632 0.795 0.000 0.976 0 0.000 0.000 0.024
#> SRR1223554 4 0.1492 0.941 0.000 0.000 0 0.940 0.024 0.036
#> SRR1223555 4 0.0000 0.954 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223556 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223557 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223558 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223559 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223560 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223561 2 0.0000 0.803 0.000 1.000 0 0.000 0.000 0.000
#> SRR1223562 6 0.1141 0.849 0.000 0.052 0 0.000 0.000 0.948
#> SRR1223563 2 0.0632 0.795 0.000 0.976 0 0.000 0.000 0.024
#> SRR1223564 6 0.2823 0.817 0.000 0.204 0 0.000 0.000 0.796
#> SRR1223565 2 0.3823 -0.197 0.000 0.564 0 0.000 0.000 0.436
#> SRR1223566 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223567 5 0.0632 0.998 0.024 0.000 0 0.000 0.976 0.000
#> SRR1223568 5 0.0632 0.998 0.024 0.000 0 0.000 0.976 0.000
#> SRR1223569 5 0.0632 0.998 0.024 0.000 0 0.000 0.976 0.000
#> SRR1223570 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223571 2 0.2527 0.842 0.000 0.832 0 0.000 0.000 0.168
#> SRR1223572 4 0.1492 0.941 0.000 0.000 0 0.940 0.024 0.036
#> SRR1223573 2 0.2527 0.842 0.000 0.832 0 0.000 0.000 0.168
#> SRR1223574 4 0.1492 0.941 0.000 0.000 0 0.940 0.024 0.036
#> SRR1223575 4 0.0000 0.954 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223576 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223577 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223578 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223579 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223580 1 0.0363 0.991 0.988 0.000 0 0.000 0.012 0.000
#> SRR1223581 2 0.2527 0.842 0.000 0.832 0 0.000 0.000 0.168
#> SRR1223582 6 0.1141 0.849 0.000 0.052 0 0.000 0.000 0.948
#> SRR1223583 2 0.0632 0.795 0.000 0.976 0 0.000 0.000 0.024
#> SRR1223584 6 0.3151 0.768 0.000 0.252 0 0.000 0.000 0.748
#> SRR1223585 2 0.2527 0.842 0.000 0.832 0 0.000 0.000 0.168
#> SRR1223586 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223587 1 0.0260 0.994 0.992 0.000 0 0.000 0.008 0.000
#> SRR1223588 1 0.0260 0.994 0.992 0.000 0 0.000 0.008 0.000
#> SRR1223589 5 0.0632 0.998 0.024 0.000 0 0.000 0.976 0.000
#> SRR1223590 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223591 2 0.2527 0.842 0.000 0.832 0 0.000 0.000 0.168
#> SRR1223592 4 0.3017 0.743 0.000 0.020 0 0.816 0.000 0.164
#> SRR1223593 2 0.2527 0.842 0.000 0.832 0 0.000 0.000 0.168
#> SRR1223594 4 0.0000 0.954 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223595 4 0.0000 0.954 0.000 0.000 0 1.000 0.000 0.000
#> SRR1223596 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1223597 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223598 1 0.0260 0.994 0.992 0.000 0 0.000 0.008 0.000
#> SRR1223599 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1223600 1 0.0260 0.994 0.992 0.000 0 0.000 0.008 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "mclust"]
# you can also extract it by
# res = res_list["ATC:mclust"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5090 0.492 0.492
#> 3 3 0.952 0.979 0.982 0.1971 0.893 0.783
#> 4 4 0.865 0.938 0.945 0.1393 0.919 0.789
#> 5 5 0.726 0.502 0.743 0.0604 0.836 0.514
#> 6 6 0.756 0.587 0.782 0.0792 0.827 0.415
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.0000 0.985 0 1.000 0.000
#> SRR1223542 2 0.1529 0.964 0 0.960 0.040
#> SRR1223543 2 0.0000 0.985 0 1.000 0.000
#> SRR1223544 2 0.1529 0.964 0 0.960 0.040
#> SRR1223545 2 0.0000 0.985 0 1.000 0.000
#> SRR1223546 1 0.0000 1.000 1 0.000 0.000
#> SRR1223547 1 0.0000 1.000 1 0.000 0.000
#> SRR1223548 1 0.0000 1.000 1 0.000 0.000
#> SRR1223549 1 0.0000 1.000 1 0.000 0.000
#> SRR1223550 1 0.0000 1.000 1 0.000 0.000
#> SRR1223551 2 0.0237 0.984 0 0.996 0.004
#> SRR1223552 3 0.3116 0.931 0 0.108 0.892
#> SRR1223553 2 0.0237 0.984 0 0.996 0.004
#> SRR1223554 3 0.3941 0.859 0 0.156 0.844
#> SRR1223555 3 0.2356 0.934 0 0.072 0.928
#> SRR1223556 1 0.0000 1.000 1 0.000 0.000
#> SRR1223557 1 0.0000 1.000 1 0.000 0.000
#> SRR1223558 1 0.0000 1.000 1 0.000 0.000
#> SRR1223559 1 0.0000 1.000 1 0.000 0.000
#> SRR1223560 1 0.0000 1.000 1 0.000 0.000
#> SRR1223561 2 0.0000 0.985 0 1.000 0.000
#> SRR1223562 2 0.1529 0.964 0 0.960 0.040
#> SRR1223563 2 0.0237 0.984 0 0.996 0.004
#> SRR1223564 2 0.1529 0.964 0 0.960 0.040
#> SRR1223565 2 0.0000 0.985 0 1.000 0.000
#> SRR1223566 1 0.0000 1.000 1 0.000 0.000
#> SRR1223567 1 0.0000 1.000 1 0.000 0.000
#> SRR1223568 1 0.0000 1.000 1 0.000 0.000
#> SRR1223569 1 0.0000 1.000 1 0.000 0.000
#> SRR1223570 1 0.0000 1.000 1 0.000 0.000
#> SRR1223571 2 0.0237 0.984 0 0.996 0.004
#> SRR1223572 3 0.1411 0.918 0 0.036 0.964
#> SRR1223573 2 0.0237 0.984 0 0.996 0.004
#> SRR1223574 3 0.3686 0.867 0 0.140 0.860
#> SRR1223575 3 0.0424 0.902 0 0.008 0.992
#> SRR1223576 1 0.0000 1.000 1 0.000 0.000
#> SRR1223577 1 0.0000 1.000 1 0.000 0.000
#> SRR1223578 1 0.0000 1.000 1 0.000 0.000
#> SRR1223579 1 0.0000 1.000 1 0.000 0.000
#> SRR1223580 1 0.0000 1.000 1 0.000 0.000
#> SRR1223581 2 0.0000 0.985 0 1.000 0.000
#> SRR1223582 2 0.1529 0.964 0 0.960 0.040
#> SRR1223583 2 0.0000 0.985 0 1.000 0.000
#> SRR1223584 2 0.1529 0.964 0 0.960 0.040
#> SRR1223585 2 0.0000 0.985 0 1.000 0.000
#> SRR1223586 1 0.0000 1.000 1 0.000 0.000
#> SRR1223587 1 0.0000 1.000 1 0.000 0.000
#> SRR1223588 1 0.0000 1.000 1 0.000 0.000
#> SRR1223589 1 0.0000 1.000 1 0.000 0.000
#> SRR1223590 1 0.0000 1.000 1 0.000 0.000
#> SRR1223591 2 0.0237 0.984 0 0.996 0.004
#> SRR1223592 3 0.3116 0.931 0 0.108 0.892
#> SRR1223593 2 0.0237 0.984 0 0.996 0.004
#> SRR1223594 3 0.3116 0.931 0 0.108 0.892
#> SRR1223595 3 0.2356 0.934 0 0.072 0.928
#> SRR1223596 1 0.0000 1.000 1 0.000 0.000
#> SRR1223597 1 0.0000 1.000 1 0.000 0.000
#> SRR1223598 1 0.0000 1.000 1 0.000 0.000
#> SRR1223599 1 0.0000 1.000 1 0.000 0.000
#> SRR1223600 1 0.0000 1.000 1 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.0188 0.945 0.000 0.996 0.004 0.000
#> SRR1223542 2 0.2844 0.923 0.000 0.900 0.052 0.048
#> SRR1223543 2 0.0000 0.945 0.000 1.000 0.000 0.000
#> SRR1223544 2 0.2759 0.925 0.000 0.904 0.052 0.044
#> SRR1223545 2 0.2402 0.921 0.000 0.912 0.012 0.076
#> SRR1223546 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223547 1 0.0592 0.965 0.984 0.000 0.016 0.000
#> SRR1223548 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223549 1 0.0592 0.965 0.984 0.000 0.016 0.000
#> SRR1223550 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223551 2 0.2053 0.927 0.000 0.924 0.072 0.004
#> SRR1223552 4 0.0000 0.948 0.000 0.000 0.000 1.000
#> SRR1223553 2 0.2053 0.927 0.000 0.924 0.072 0.004
#> SRR1223554 4 0.2814 0.892 0.000 0.000 0.132 0.868
#> SRR1223555 4 0.0779 0.946 0.000 0.016 0.004 0.980
#> SRR1223556 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223557 3 0.2814 0.891 0.132 0.000 0.868 0.000
#> SRR1223558 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223559 3 0.2814 0.891 0.132 0.000 0.868 0.000
#> SRR1223560 1 0.0336 0.970 0.992 0.000 0.008 0.000
#> SRR1223561 2 0.0188 0.945 0.000 0.996 0.004 0.000
#> SRR1223562 2 0.2844 0.923 0.000 0.900 0.052 0.048
#> SRR1223563 2 0.0188 0.945 0.000 0.996 0.004 0.000
#> SRR1223564 2 0.2844 0.923 0.000 0.900 0.052 0.048
#> SRR1223565 2 0.2473 0.918 0.000 0.908 0.012 0.080
#> SRR1223566 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223567 1 0.3486 0.723 0.812 0.000 0.188 0.000
#> SRR1223568 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223569 1 0.3486 0.723 0.812 0.000 0.188 0.000
#> SRR1223570 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223571 2 0.2053 0.927 0.000 0.924 0.072 0.004
#> SRR1223572 4 0.1867 0.924 0.000 0.000 0.072 0.928
#> SRR1223573 2 0.2053 0.927 0.000 0.924 0.072 0.004
#> SRR1223574 4 0.2814 0.892 0.000 0.000 0.132 0.868
#> SRR1223575 4 0.2450 0.913 0.000 0.016 0.072 0.912
#> SRR1223576 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223577 3 0.3801 0.948 0.220 0.000 0.780 0.000
#> SRR1223578 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223579 3 0.3801 0.948 0.220 0.000 0.780 0.000
#> SRR1223580 1 0.0921 0.954 0.972 0.000 0.028 0.000
#> SRR1223581 2 0.0336 0.944 0.000 0.992 0.008 0.000
#> SRR1223582 2 0.1474 0.937 0.000 0.948 0.052 0.000
#> SRR1223583 2 0.0188 0.945 0.000 0.996 0.004 0.000
#> SRR1223584 2 0.1474 0.937 0.000 0.948 0.052 0.000
#> SRR1223585 2 0.1938 0.933 0.000 0.936 0.012 0.052
#> SRR1223586 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223587 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223588 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223589 1 0.0336 0.970 0.992 0.000 0.008 0.000
#> SRR1223590 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223591 2 0.2053 0.927 0.000 0.924 0.072 0.004
#> SRR1223592 4 0.0000 0.948 0.000 0.000 0.000 1.000
#> SRR1223593 2 0.2053 0.927 0.000 0.924 0.072 0.004
#> SRR1223594 4 0.0000 0.948 0.000 0.000 0.000 1.000
#> SRR1223595 4 0.0779 0.946 0.000 0.016 0.004 0.980
#> SRR1223596 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223597 3 0.3801 0.948 0.220 0.000 0.780 0.000
#> SRR1223598 1 0.0000 0.974 1.000 0.000 0.000 0.000
#> SRR1223599 3 0.3801 0.948 0.220 0.000 0.780 0.000
#> SRR1223600 1 0.0921 0.954 0.972 0.000 0.028 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.2813 0.861 0.000 0.832 0.000 0.000 0.168
#> SRR1223542 5 0.4390 -0.455 0.000 0.428 0.000 0.004 0.568
#> SRR1223543 2 0.2605 0.870 0.000 0.852 0.000 0.000 0.148
#> SRR1223544 5 0.4249 -0.457 0.000 0.432 0.000 0.000 0.568
#> SRR1223545 2 0.1670 0.896 0.000 0.936 0.000 0.012 0.052
#> SRR1223546 5 0.6734 -0.378 0.264 0.000 0.332 0.000 0.404
#> SRR1223547 1 0.3966 0.803 0.664 0.000 0.336 0.000 0.000
#> SRR1223548 1 0.6799 0.559 0.372 0.000 0.332 0.000 0.296
#> SRR1223549 1 0.3966 0.803 0.664 0.000 0.336 0.000 0.000
#> SRR1223550 5 0.6734 -0.378 0.264 0.000 0.332 0.000 0.404
#> SRR1223551 2 0.0609 0.893 0.000 0.980 0.000 0.000 0.020
#> SRR1223552 4 0.2377 0.872 0.128 0.000 0.000 0.872 0.000
#> SRR1223553 2 0.0000 0.897 0.000 1.000 0.000 0.000 0.000
#> SRR1223554 4 0.5939 0.730 0.332 0.032 0.008 0.588 0.040
#> SRR1223555 4 0.0000 0.914 0.000 0.000 0.000 1.000 0.000
#> SRR1223556 5 0.6734 -0.378 0.264 0.000 0.332 0.000 0.404
#> SRR1223557 3 0.0000 0.973 0.000 0.000 1.000 0.000 0.000
#> SRR1223558 5 0.6804 -0.459 0.300 0.000 0.332 0.000 0.368
#> SRR1223559 3 0.0000 0.973 0.000 0.000 1.000 0.000 0.000
#> SRR1223560 1 0.3949 0.804 0.668 0.000 0.332 0.000 0.000
#> SRR1223561 2 0.3612 0.792 0.000 0.732 0.000 0.000 0.268
#> SRR1223562 5 0.4390 -0.455 0.000 0.428 0.000 0.004 0.568
#> SRR1223563 2 0.3707 0.777 0.000 0.716 0.000 0.000 0.284
#> SRR1223564 5 0.4390 -0.455 0.000 0.428 0.000 0.004 0.568
#> SRR1223565 2 0.1670 0.896 0.000 0.936 0.000 0.012 0.052
#> SRR1223566 5 0.6763 -0.401 0.276 0.000 0.332 0.000 0.392
#> SRR1223567 1 0.3966 0.803 0.664 0.000 0.336 0.000 0.000
#> SRR1223568 1 0.6799 0.559 0.372 0.000 0.332 0.000 0.296
#> SRR1223569 1 0.3966 0.803 0.664 0.000 0.336 0.000 0.000
#> SRR1223570 5 0.6734 -0.378 0.264 0.000 0.332 0.000 0.404
#> SRR1223571 2 0.0609 0.893 0.000 0.980 0.000 0.000 0.020
#> SRR1223572 4 0.0404 0.911 0.012 0.000 0.000 0.988 0.000
#> SRR1223573 2 0.0609 0.893 0.000 0.980 0.000 0.000 0.020
#> SRR1223574 4 0.5939 0.730 0.332 0.032 0.008 0.588 0.040
#> SRR1223575 4 0.0000 0.914 0.000 0.000 0.000 1.000 0.000
#> SRR1223576 5 0.6763 -0.401 0.276 0.000 0.332 0.000 0.392
#> SRR1223577 3 0.0290 0.978 0.008 0.000 0.992 0.000 0.000
#> SRR1223578 1 0.6779 0.579 0.384 0.000 0.332 0.000 0.284
#> SRR1223579 3 0.0290 0.978 0.008 0.000 0.992 0.000 0.000
#> SRR1223580 1 0.3966 0.802 0.664 0.000 0.336 0.000 0.000
#> SRR1223581 2 0.2179 0.883 0.000 0.888 0.000 0.000 0.112
#> SRR1223582 5 0.4256 -0.461 0.000 0.436 0.000 0.000 0.564
#> SRR1223583 2 0.3508 0.805 0.000 0.748 0.000 0.000 0.252
#> SRR1223584 5 0.4256 -0.461 0.000 0.436 0.000 0.000 0.564
#> SRR1223585 2 0.1670 0.896 0.000 0.936 0.000 0.012 0.052
#> SRR1223586 5 0.6734 -0.378 0.264 0.000 0.332 0.000 0.404
#> SRR1223587 1 0.4671 0.797 0.640 0.000 0.332 0.000 0.028
#> SRR1223588 1 0.6813 0.536 0.360 0.000 0.332 0.000 0.308
#> SRR1223589 1 0.3949 0.804 0.668 0.000 0.332 0.000 0.000
#> SRR1223590 5 0.6734 -0.378 0.264 0.000 0.332 0.000 0.404
#> SRR1223591 2 0.0609 0.893 0.000 0.980 0.000 0.000 0.020
#> SRR1223592 4 0.0000 0.914 0.000 0.000 0.000 1.000 0.000
#> SRR1223593 2 0.0609 0.893 0.000 0.980 0.000 0.000 0.020
#> SRR1223594 4 0.0000 0.914 0.000 0.000 0.000 1.000 0.000
#> SRR1223595 4 0.0000 0.914 0.000 0.000 0.000 1.000 0.000
#> SRR1223596 5 0.6734 -0.378 0.264 0.000 0.332 0.000 0.404
#> SRR1223597 3 0.0794 0.962 0.028 0.000 0.972 0.000 0.000
#> SRR1223598 1 0.6645 0.637 0.432 0.000 0.332 0.000 0.236
#> SRR1223599 3 0.0794 0.962 0.028 0.000 0.972 0.000 0.000
#> SRR1223600 1 0.3966 0.802 0.664 0.000 0.336 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 6 0.2170 0.6507 0.000 0.100 0.000 0.000 0.012 0.888
#> SRR1223542 6 0.4871 0.5340 0.000 0.212 0.000 0.000 0.132 0.656
#> SRR1223543 6 0.1863 0.6515 0.000 0.104 0.000 0.000 0.000 0.896
#> SRR1223544 6 0.4809 0.5363 0.000 0.208 0.000 0.000 0.128 0.664
#> SRR1223545 2 0.5469 0.2124 0.000 0.568 0.000 0.124 0.008 0.300
#> SRR1223546 1 0.0000 0.6948 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223547 1 0.5146 -0.3044 0.516 0.000 0.088 0.000 0.396 0.000
#> SRR1223548 1 0.1765 0.6803 0.904 0.000 0.000 0.000 0.096 0.000
#> SRR1223549 1 0.4974 -0.0042 0.588 0.000 0.088 0.000 0.324 0.000
#> SRR1223550 1 0.0146 0.6963 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1223551 2 0.2912 0.7540 0.000 0.784 0.000 0.000 0.000 0.216
#> SRR1223552 4 0.0146 0.8709 0.000 0.004 0.000 0.996 0.000 0.000
#> SRR1223553 6 0.3867 -0.1341 0.000 0.488 0.000 0.000 0.000 0.512
#> SRR1223554 4 0.6272 0.4497 0.000 0.012 0.276 0.440 0.272 0.000
#> SRR1223555 4 0.0146 0.8710 0.000 0.004 0.000 0.996 0.000 0.000
#> SRR1223556 1 0.0000 0.6948 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223557 3 0.0146 0.7541 0.004 0.000 0.996 0.000 0.000 0.000
#> SRR1223558 1 0.0632 0.6985 0.976 0.000 0.000 0.000 0.024 0.000
#> SRR1223559 3 0.0146 0.7541 0.004 0.000 0.996 0.000 0.000 0.000
#> SRR1223560 5 0.4018 0.9041 0.412 0.000 0.008 0.000 0.580 0.000
#> SRR1223561 6 0.2121 0.6529 0.000 0.096 0.000 0.000 0.012 0.892
#> SRR1223562 6 0.4871 0.5340 0.000 0.212 0.000 0.000 0.132 0.656
#> SRR1223563 6 0.1765 0.6549 0.000 0.096 0.000 0.000 0.000 0.904
#> SRR1223564 6 0.4871 0.5340 0.000 0.212 0.000 0.000 0.132 0.656
#> SRR1223565 2 0.5469 0.2124 0.000 0.568 0.000 0.124 0.008 0.300
#> SRR1223566 1 0.2135 0.6355 0.872 0.000 0.000 0.000 0.128 0.000
#> SRR1223567 1 0.5521 -0.4011 0.468 0.000 0.132 0.000 0.400 0.000
#> SRR1223568 1 0.1910 0.6722 0.892 0.000 0.000 0.000 0.108 0.000
#> SRR1223569 1 0.5521 -0.4011 0.468 0.000 0.132 0.000 0.400 0.000
#> SRR1223570 1 0.0260 0.6966 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR1223571 2 0.2912 0.7540 0.000 0.784 0.000 0.000 0.000 0.216
#> SRR1223572 4 0.0508 0.8687 0.000 0.012 0.000 0.984 0.004 0.000
#> SRR1223573 2 0.2912 0.7540 0.000 0.784 0.000 0.000 0.000 0.216
#> SRR1223574 4 0.6272 0.4497 0.000 0.012 0.276 0.440 0.272 0.000
#> SRR1223575 4 0.0363 0.8697 0.000 0.012 0.000 0.988 0.000 0.000
#> SRR1223576 1 0.1327 0.6925 0.936 0.000 0.000 0.000 0.064 0.000
#> SRR1223577 3 0.3405 0.8562 0.004 0.000 0.724 0.000 0.272 0.000
#> SRR1223578 1 0.2454 0.6224 0.840 0.000 0.000 0.000 0.160 0.000
#> SRR1223579 3 0.3405 0.8562 0.004 0.000 0.724 0.000 0.272 0.000
#> SRR1223580 5 0.4534 0.9551 0.380 0.000 0.040 0.000 0.580 0.000
#> SRR1223581 6 0.2446 0.6271 0.000 0.124 0.000 0.000 0.012 0.864
#> SRR1223582 6 0.1908 0.6282 0.000 0.096 0.000 0.000 0.004 0.900
#> SRR1223583 6 0.2121 0.6529 0.000 0.096 0.000 0.000 0.012 0.892
#> SRR1223584 6 0.1908 0.6282 0.000 0.096 0.000 0.000 0.004 0.900
#> SRR1223585 6 0.4723 -0.1929 0.000 0.472 0.000 0.036 0.004 0.488
#> SRR1223586 1 0.0146 0.6963 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1223587 1 0.3244 0.4135 0.732 0.000 0.000 0.000 0.268 0.000
#> SRR1223588 1 0.1714 0.6828 0.908 0.000 0.000 0.000 0.092 0.000
#> SRR1223589 1 0.3464 0.2863 0.688 0.000 0.000 0.000 0.312 0.000
#> SRR1223590 1 0.0260 0.6966 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR1223591 2 0.2912 0.7540 0.000 0.784 0.000 0.000 0.000 0.216
#> SRR1223592 4 0.0363 0.8695 0.000 0.012 0.000 0.988 0.000 0.000
#> SRR1223593 2 0.2912 0.7540 0.000 0.784 0.000 0.000 0.000 0.216
#> SRR1223594 4 0.0363 0.8695 0.000 0.012 0.000 0.988 0.000 0.000
#> SRR1223595 4 0.0146 0.8710 0.000 0.004 0.000 0.996 0.000 0.000
#> SRR1223596 1 0.0000 0.6948 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1223597 3 0.3999 0.8408 0.032 0.000 0.696 0.000 0.272 0.000
#> SRR1223598 1 0.3482 0.1953 0.684 0.000 0.000 0.000 0.316 0.000
#> SRR1223599 3 0.3999 0.8408 0.032 0.000 0.696 0.000 0.272 0.000
#> SRR1223600 5 0.4534 0.9551 0.380 0.000 0.040 0.000 0.580 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 15517 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.5090 0.492 0.492
#> 3 3 0.924 0.913 0.964 0.0786 0.984 0.967
#> 4 4 0.820 0.929 0.892 0.1558 0.819 0.623
#> 5 5 0.739 0.874 0.922 0.0936 0.995 0.985
#> 6 6 0.785 0.839 0.893 0.0557 0.995 0.985
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
#> SRR1223541 2 0 1 0 1
#> SRR1223542 2 0 1 0 1
#> SRR1223543 2 0 1 0 1
#> SRR1223544 2 0 1 0 1
#> SRR1223545 2 0 1 0 1
#> SRR1223546 1 0 1 1 0
#> SRR1223547 1 0 1 1 0
#> SRR1223548 1 0 1 1 0
#> SRR1223549 1 0 1 1 0
#> SRR1223550 1 0 1 1 0
#> SRR1223551 2 0 1 0 1
#> SRR1223552 2 0 1 0 1
#> SRR1223553 2 0 1 0 1
#> SRR1223554 2 0 1 0 1
#> SRR1223555 2 0 1 0 1
#> SRR1223556 1 0 1 1 0
#> SRR1223557 1 0 1 1 0
#> SRR1223558 1 0 1 1 0
#> SRR1223559 1 0 1 1 0
#> SRR1223560 1 0 1 1 0
#> SRR1223561 2 0 1 0 1
#> SRR1223562 2 0 1 0 1
#> SRR1223563 2 0 1 0 1
#> SRR1223564 2 0 1 0 1
#> SRR1223565 2 0 1 0 1
#> SRR1223566 1 0 1 1 0
#> SRR1223567 1 0 1 1 0
#> SRR1223568 1 0 1 1 0
#> SRR1223569 1 0 1 1 0
#> SRR1223570 1 0 1 1 0
#> SRR1223571 2 0 1 0 1
#> SRR1223572 2 0 1 0 1
#> SRR1223573 2 0 1 0 1
#> SRR1223574 2 0 1 0 1
#> SRR1223575 2 0 1 0 1
#> SRR1223576 1 0 1 1 0
#> SRR1223577 1 0 1 1 0
#> SRR1223578 1 0 1 1 0
#> SRR1223579 1 0 1 1 0
#> SRR1223580 1 0 1 1 0
#> SRR1223581 2 0 1 0 1
#> SRR1223582 2 0 1 0 1
#> SRR1223583 2 0 1 0 1
#> SRR1223584 2 0 1 0 1
#> SRR1223585 2 0 1 0 1
#> SRR1223586 1 0 1 1 0
#> SRR1223587 1 0 1 1 0
#> SRR1223588 1 0 1 1 0
#> SRR1223589 1 0 1 1 0
#> SRR1223590 1 0 1 1 0
#> SRR1223591 2 0 1 0 1
#> SRR1223592 2 0 1 0 1
#> SRR1223593 2 0 1 0 1
#> SRR1223594 2 0 1 0 1
#> SRR1223595 2 0 1 0 1
#> SRR1223596 1 0 1 1 0
#> SRR1223597 1 0 1 1 0
#> SRR1223598 1 0 1 1 0
#> SRR1223599 1 0 1 1 0
#> SRR1223600 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1223541 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223542 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223543 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223544 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223545 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223546 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223547 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223548 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223549 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223550 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223551 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223552 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223553 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223554 2 0.0747 0.979 0.000 0.984 0.016
#> SRR1223555 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223556 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223557 1 0.5948 0.543 0.640 0.000 0.360
#> SRR1223558 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223559 1 0.6252 0.390 0.556 0.000 0.444
#> SRR1223560 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223561 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223562 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223563 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223564 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223565 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223566 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223567 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223568 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223569 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223570 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223571 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223572 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223573 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223574 3 0.4605 0.000 0.000 0.204 0.796
#> SRR1223575 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223576 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223577 1 0.6235 0.407 0.564 0.000 0.436
#> SRR1223578 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223579 1 0.6235 0.407 0.564 0.000 0.436
#> SRR1223580 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223581 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223582 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223583 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223584 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223585 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223586 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223587 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223588 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223589 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223590 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223591 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223592 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223593 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223594 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223595 2 0.0000 0.999 0.000 1.000 0.000
#> SRR1223596 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223597 1 0.3267 0.844 0.884 0.000 0.116
#> SRR1223598 1 0.0000 0.933 1.000 0.000 0.000
#> SRR1223599 1 0.3412 0.837 0.876 0.000 0.124
#> SRR1223600 1 0.0000 0.933 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1223541 2 0.0188 0.986 0.000 0.996 0.000 0.004
#> SRR1223542 2 0.0188 0.983 0.000 0.996 0.000 0.004
#> SRR1223543 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR1223544 2 0.0188 0.983 0.000 0.996 0.000 0.004
#> SRR1223545 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR1223546 1 0.0336 0.972 0.992 0.000 0.008 0.000
#> SRR1223547 1 0.1302 0.942 0.956 0.000 0.044 0.000
#> SRR1223548 1 0.0592 0.969 0.984 0.000 0.016 0.000
#> SRR1223549 1 0.1302 0.942 0.956 0.000 0.044 0.000
#> SRR1223550 1 0.0469 0.971 0.988 0.000 0.012 0.000
#> SRR1223551 2 0.1118 0.950 0.000 0.964 0.000 0.036
#> SRR1223552 4 0.4898 0.793 0.000 0.416 0.000 0.584
#> SRR1223553 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR1223554 4 0.4635 0.722 0.000 0.216 0.028 0.756
#> SRR1223555 4 0.4925 0.788 0.000 0.428 0.000 0.572
#> SRR1223556 1 0.0336 0.972 0.992 0.000 0.008 0.000
#> SRR1223557 3 0.4925 0.929 0.428 0.000 0.572 0.000
#> SRR1223558 1 0.0707 0.966 0.980 0.000 0.020 0.000
#> SRR1223559 3 0.4866 0.931 0.404 0.000 0.596 0.000
#> SRR1223560 1 0.1118 0.952 0.964 0.000 0.036 0.000
#> SRR1223561 2 0.0188 0.986 0.000 0.996 0.000 0.004
#> SRR1223562 2 0.1637 0.905 0.000 0.940 0.000 0.060
#> SRR1223563 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR1223564 2 0.0469 0.974 0.000 0.988 0.000 0.012
#> SRR1223565 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR1223566 1 0.0336 0.970 0.992 0.000 0.008 0.000
#> SRR1223567 1 0.1302 0.942 0.956 0.000 0.044 0.000
#> SRR1223568 1 0.0000 0.972 1.000 0.000 0.000 0.000
#> SRR1223569 1 0.1302 0.942 0.956 0.000 0.044 0.000
#> SRR1223570 1 0.0469 0.967 0.988 0.000 0.012 0.000
#> SRR1223571 2 0.0592 0.976 0.000 0.984 0.000 0.016
#> SRR1223572 4 0.4382 0.777 0.000 0.296 0.000 0.704
#> SRR1223573 2 0.0469 0.980 0.000 0.988 0.000 0.012
#> SRR1223574 4 0.2888 0.409 0.000 0.004 0.124 0.872
#> SRR1223575 4 0.4643 0.794 0.000 0.344 0.000 0.656
#> SRR1223576 1 0.0336 0.970 0.992 0.000 0.008 0.000
#> SRR1223577 3 0.4964 0.918 0.380 0.000 0.616 0.004
#> SRR1223578 1 0.0336 0.970 0.992 0.000 0.008 0.000
#> SRR1223579 3 0.5189 0.908 0.372 0.000 0.616 0.012
#> SRR1223580 1 0.0592 0.969 0.984 0.000 0.016 0.000
#> SRR1223581 2 0.0188 0.986 0.000 0.996 0.000 0.004
#> SRR1223582 2 0.0188 0.986 0.000 0.996 0.000 0.004
#> SRR1223583 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR1223584 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR1223585 2 0.0188 0.986 0.000 0.996 0.000 0.004
#> SRR1223586 1 0.0469 0.967 0.988 0.000 0.012 0.000
#> SRR1223587 1 0.0336 0.970 0.992 0.000 0.008 0.000
#> SRR1223588 1 0.0188 0.971 0.996 0.000 0.004 0.000
#> SRR1223589 1 0.0188 0.972 0.996 0.000 0.004 0.000
#> SRR1223590 1 0.0469 0.967 0.988 0.000 0.012 0.000
#> SRR1223591 2 0.0707 0.972 0.000 0.980 0.000 0.020
#> SRR1223592 4 0.4977 0.747 0.000 0.460 0.000 0.540
#> SRR1223593 2 0.0188 0.986 0.000 0.996 0.000 0.004
#> SRR1223594 4 0.4977 0.747 0.000 0.460 0.000 0.540
#> SRR1223595 4 0.4933 0.785 0.000 0.432 0.000 0.568
#> SRR1223596 1 0.0336 0.970 0.992 0.000 0.008 0.000
#> SRR1223597 3 0.4977 0.901 0.460 0.000 0.540 0.000
#> SRR1223598 1 0.0188 0.971 0.996 0.000 0.004 0.000
#> SRR1223599 3 0.4977 0.901 0.460 0.000 0.540 0.000
#> SRR1223600 1 0.0592 0.969 0.984 0.000 0.016 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1223541 2 0.0162 0.955 0.000 0.996 0.000 0.004 0.000
#> SRR1223542 2 0.1251 0.934 0.000 0.956 0.000 0.036 0.008
#> SRR1223543 2 0.0162 0.955 0.000 0.996 0.000 0.000 0.004
#> SRR1223544 2 0.0510 0.951 0.000 0.984 0.000 0.000 0.016
#> SRR1223545 2 0.0162 0.955 0.000 0.996 0.000 0.000 0.004
#> SRR1223546 1 0.0510 0.949 0.984 0.000 0.016 0.000 0.000
#> SRR1223547 1 0.2473 0.914 0.896 0.000 0.072 0.000 0.032
#> SRR1223548 1 0.1430 0.937 0.944 0.000 0.052 0.000 0.004
#> SRR1223549 1 0.2871 0.896 0.872 0.000 0.088 0.000 0.040
#> SRR1223550 1 0.0451 0.950 0.988 0.000 0.008 0.000 0.004
#> SRR1223551 2 0.2890 0.797 0.000 0.836 0.000 0.160 0.004
#> SRR1223552 4 0.2536 0.827 0.000 0.128 0.000 0.868 0.004
#> SRR1223553 2 0.0000 0.955 0.000 1.000 0.000 0.000 0.000
#> SRR1223554 4 0.5396 -0.146 0.000 0.032 0.036 0.648 0.284
#> SRR1223555 4 0.2561 0.829 0.000 0.144 0.000 0.856 0.000
#> SRR1223556 1 0.0404 0.949 0.988 0.000 0.012 0.000 0.000
#> SRR1223557 3 0.2732 0.906 0.160 0.000 0.840 0.000 0.000
#> SRR1223558 1 0.1205 0.941 0.956 0.000 0.040 0.000 0.004
#> SRR1223559 3 0.2280 0.903 0.120 0.000 0.880 0.000 0.000
#> SRR1223560 1 0.2890 0.828 0.836 0.000 0.160 0.000 0.004
#> SRR1223561 2 0.0162 0.955 0.000 0.996 0.000 0.004 0.000
#> SRR1223562 2 0.4017 0.755 0.000 0.788 0.000 0.064 0.148
#> SRR1223563 2 0.0000 0.955 0.000 1.000 0.000 0.000 0.000
#> SRR1223564 2 0.3804 0.767 0.000 0.796 0.000 0.044 0.160
#> SRR1223565 2 0.0290 0.954 0.000 0.992 0.000 0.000 0.008
#> SRR1223566 1 0.0451 0.948 0.988 0.000 0.004 0.000 0.008
#> SRR1223567 1 0.2438 0.918 0.900 0.000 0.060 0.000 0.040
#> SRR1223568 1 0.0693 0.949 0.980 0.000 0.008 0.000 0.012
#> SRR1223569 1 0.2569 0.913 0.892 0.000 0.068 0.000 0.040
#> SRR1223570 1 0.0693 0.944 0.980 0.000 0.012 0.000 0.008
#> SRR1223571 2 0.1121 0.935 0.000 0.956 0.000 0.044 0.000
#> SRR1223572 4 0.2645 0.721 0.000 0.068 0.000 0.888 0.044
#> SRR1223573 2 0.1043 0.938 0.000 0.960 0.000 0.040 0.000
#> SRR1223574 5 0.5852 0.000 0.000 0.000 0.104 0.372 0.524
#> SRR1223575 4 0.1943 0.718 0.000 0.056 0.000 0.924 0.020
#> SRR1223576 1 0.0000 0.948 1.000 0.000 0.000 0.000 0.000
#> SRR1223577 3 0.2230 0.901 0.116 0.000 0.884 0.000 0.000
#> SRR1223578 1 0.0162 0.948 0.996 0.000 0.000 0.000 0.004
#> SRR1223579 3 0.2230 0.901 0.116 0.000 0.884 0.000 0.000
#> SRR1223580 1 0.2873 0.863 0.856 0.000 0.128 0.000 0.016
#> SRR1223581 2 0.0404 0.953 0.000 0.988 0.000 0.012 0.000
#> SRR1223582 2 0.0162 0.955 0.000 0.996 0.000 0.004 0.000
#> SRR1223583 2 0.0000 0.955 0.000 1.000 0.000 0.000 0.000
#> SRR1223584 2 0.0162 0.955 0.000 0.996 0.000 0.000 0.004
#> SRR1223585 2 0.0000 0.955 0.000 1.000 0.000 0.000 0.000
#> SRR1223586 1 0.0000 0.948 1.000 0.000 0.000 0.000 0.000
#> SRR1223587 1 0.1364 0.938 0.952 0.000 0.012 0.000 0.036
#> SRR1223588 1 0.0290 0.949 0.992 0.000 0.000 0.000 0.008
#> SRR1223589 1 0.1549 0.938 0.944 0.000 0.016 0.000 0.040
#> SRR1223590 1 0.0290 0.946 0.992 0.000 0.008 0.000 0.000
#> SRR1223591 2 0.1270 0.929 0.000 0.948 0.000 0.052 0.000
#> SRR1223592 4 0.2605 0.826 0.000 0.148 0.000 0.852 0.000
#> SRR1223593 2 0.0609 0.950 0.000 0.980 0.000 0.020 0.000
#> SRR1223594 4 0.2732 0.808 0.000 0.160 0.000 0.840 0.000
#> SRR1223595 4 0.2471 0.831 0.000 0.136 0.000 0.864 0.000
#> SRR1223596 1 0.0000 0.948 1.000 0.000 0.000 0.000 0.000
#> SRR1223597 3 0.3274 0.860 0.220 0.000 0.780 0.000 0.000
#> SRR1223598 1 0.0162 0.948 0.996 0.000 0.000 0.000 0.004
#> SRR1223599 3 0.3210 0.871 0.212 0.000 0.788 0.000 0.000
#> SRR1223600 1 0.2358 0.886 0.888 0.000 0.104 0.000 0.008
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1223541 2 0.0508 0.889 0.000 0.984 0.000 0.012 NA 0.000
#> SRR1223542 2 0.3224 0.807 0.000 0.824 0.000 0.040 NA 0.132
#> SRR1223543 2 0.0725 0.888 0.000 0.976 0.000 0.000 NA 0.012
#> SRR1223544 2 0.2778 0.787 0.000 0.824 0.000 0.000 NA 0.168
#> SRR1223545 2 0.1124 0.883 0.000 0.956 0.000 0.000 NA 0.036
#> SRR1223546 1 0.0547 0.892 0.980 0.000 0.020 0.000 NA 0.000
#> SRR1223547 1 0.4486 0.697 0.696 0.000 0.208 0.000 NA 0.000
#> SRR1223548 1 0.1196 0.890 0.952 0.000 0.040 0.000 NA 0.000
#> SRR1223549 1 0.4614 0.671 0.676 0.000 0.228 0.000 NA 0.000
#> SRR1223550 1 0.0632 0.892 0.976 0.000 0.024 0.000 NA 0.000
#> SRR1223551 2 0.3476 0.670 0.000 0.732 0.000 0.260 NA 0.004
#> SRR1223552 4 0.1760 0.904 0.000 0.048 0.000 0.928 NA 0.020
#> SRR1223553 2 0.0405 0.889 0.000 0.988 0.000 0.000 NA 0.004
#> SRR1223554 6 0.4496 0.534 0.000 0.020 0.008 0.408 NA 0.564
#> SRR1223555 4 0.1265 0.911 0.000 0.044 0.000 0.948 NA 0.000
#> SRR1223556 1 0.0458 0.892 0.984 0.000 0.016 0.000 NA 0.000
#> SRR1223557 3 0.1141 0.980 0.052 0.000 0.948 0.000 NA 0.000
#> SRR1223558 1 0.0935 0.891 0.964 0.000 0.032 0.000 NA 0.000
#> SRR1223559 3 0.1007 0.980 0.044 0.000 0.956 0.000 NA 0.000
#> SRR1223560 1 0.3558 0.760 0.760 0.000 0.212 0.000 NA 0.000
#> SRR1223561 2 0.0363 0.890 0.000 0.988 0.000 0.012 NA 0.000
#> SRR1223562 2 0.4791 0.394 0.000 0.564 0.000 0.048 NA 0.384
#> SRR1223563 2 0.0520 0.889 0.000 0.984 0.000 0.000 NA 0.008
#> SRR1223564 2 0.4150 0.483 0.000 0.612 0.000 0.012 NA 0.372
#> SRR1223565 2 0.1398 0.877 0.000 0.940 0.000 0.000 NA 0.052
#> SRR1223566 1 0.0508 0.888 0.984 0.000 0.004 0.000 NA 0.000
#> SRR1223567 1 0.4530 0.694 0.692 0.000 0.208 0.000 NA 0.000
#> SRR1223568 1 0.0909 0.890 0.968 0.000 0.012 0.000 NA 0.000
#> SRR1223569 1 0.4727 0.648 0.660 0.000 0.240 0.000 NA 0.000
#> SRR1223570 1 0.0603 0.888 0.980 0.000 0.004 0.000 NA 0.000
#> SRR1223571 2 0.2420 0.828 0.000 0.864 0.000 0.128 NA 0.004
#> SRR1223572 4 0.2706 0.760 0.000 0.024 0.000 0.852 NA 0.124
#> SRR1223573 2 0.2062 0.859 0.000 0.900 0.000 0.088 NA 0.004
#> SRR1223574 6 0.4134 0.658 0.000 0.004 0.032 0.172 NA 0.764
#> SRR1223575 4 0.1275 0.858 0.000 0.016 0.000 0.956 NA 0.012
#> SRR1223576 1 0.0508 0.888 0.984 0.000 0.004 0.000 NA 0.000
#> SRR1223577 3 0.0937 0.977 0.040 0.000 0.960 0.000 NA 0.000
#> SRR1223578 1 0.1010 0.888 0.960 0.000 0.004 0.000 NA 0.000
#> SRR1223579 3 0.0865 0.972 0.036 0.000 0.964 0.000 NA 0.000
#> SRR1223580 1 0.3925 0.745 0.744 0.000 0.200 0.000 NA 0.000
#> SRR1223581 2 0.0858 0.887 0.000 0.968 0.000 0.028 NA 0.000
#> SRR1223582 2 0.1401 0.887 0.000 0.948 0.000 0.028 NA 0.020
#> SRR1223583 2 0.0405 0.889 0.000 0.988 0.000 0.000 NA 0.004
#> SRR1223584 2 0.0520 0.889 0.000 0.984 0.000 0.000 NA 0.008
#> SRR1223585 2 0.0891 0.889 0.000 0.968 0.000 0.008 NA 0.024
#> SRR1223586 1 0.1074 0.891 0.960 0.000 0.012 0.000 NA 0.000
#> SRR1223587 1 0.2170 0.855 0.888 0.000 0.012 0.000 NA 0.000
#> SRR1223588 1 0.0891 0.889 0.968 0.000 0.008 0.000 NA 0.000
#> SRR1223589 1 0.3150 0.832 0.832 0.000 0.064 0.000 NA 0.000
#> SRR1223590 1 0.0713 0.891 0.972 0.000 0.000 0.000 NA 0.000
#> SRR1223591 2 0.2544 0.818 0.000 0.852 0.000 0.140 NA 0.004
#> SRR1223592 4 0.1787 0.897 0.000 0.068 0.000 0.920 NA 0.008
#> SRR1223593 2 0.1606 0.877 0.000 0.932 0.000 0.056 NA 0.004
#> SRR1223594 4 0.1843 0.878 0.000 0.080 0.000 0.912 NA 0.004
#> SRR1223595 4 0.1265 0.911 0.000 0.044 0.000 0.948 NA 0.000
#> SRR1223596 1 0.0891 0.891 0.968 0.000 0.008 0.000 NA 0.000
#> SRR1223597 3 0.1471 0.965 0.064 0.000 0.932 0.000 NA 0.000
#> SRR1223598 1 0.1367 0.885 0.944 0.000 0.012 0.000 NA 0.000
#> SRR1223599 3 0.1349 0.976 0.056 0.000 0.940 0.000 NA 0.000
#> SRR1223600 1 0.3602 0.779 0.784 0.000 0.160 0.000 NA 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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