Date: 2019-12-26 00:43:09 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 16000 rows and 56 columns.
#> Top rows are extracted by 'SD, CV, MAD, ATC' methods.
#> Subgroups are detected by 'hclust, kmeans, skmeans, pam, mclust, NMF' method.
#> Number of partitions are tried for k = 2, 3, 4, 5, 6.
#> Performed in total 30000 partitions by row resampling.
#>
#> Following methods can be applied to this 'ConsensusPartitionList' object:
#> [1] "cola_report" "collect_classes" "collect_plots" "collect_stats"
#> [5] "colnames" "functional_enrichment" "get_anno_col" "get_anno"
#> [9] "get_classes" "get_matrix" "get_membership" "get_stats"
#> [13] "is_best_k" "is_stable_k" "ncol" "nrow"
#> [17] "rownames" "show" "suggest_best_k" "test_to_known_factors"
#> [21] "top_rows_heatmap" "top_rows_overlap"
#>
#> You can get result for a single method by, e.g. object["SD", "hclust"] or object["SD:hclust"]
#> or a subset of methods by object[c("SD", "CV")], c("hclust", "kmeans")]
The call of run_all_consensus_partition_methods()
was:
#> run_all_consensus_partition_methods(data = mat, mc.cores = 4)
Dimension of the input matrix:
mat = get_matrix(res_list)
dim(mat)
#> [1] 16000 56
The density distribution for each sample is visualized as in one column in the following heatmap. The clustering is based on the distance which is the Kolmogorov-Smirnov statistic between two distributions.
library(ComplexHeatmap)
densityHeatmap(mat, ylab = "value", cluster_columns = TRUE, show_column_names = FALSE,
mc.cores = 4)
Folowing table shows the best k
(number of partitions) for each combination
of top-value methods and partition methods. Clicking on the method name in
the table goes to the section for a single combination of methods.
The cola vignette explains the definition of the metrics used for determining the best number of partitions.
suggest_best_k(res_list)
The best k | 1-PAC | Mean silhouette | Concordance | Optional k | ||
---|---|---|---|---|---|---|
SD:hclust | 6 | 1.000 | 1.000 | 1.000 | ** | 2,5 |
SD:skmeans | 6 | 1.000 | 0.992 | 0.982 | ** | 2,5 |
SD:pam | 6 | 1.000 | 1.000 | 1.000 | ** | 2 |
SD:mclust | 6 | 1.000 | 1.000 | 1.000 | ** | 4,5 |
CV:hclust | 6 | 1.000 | 1.000 | 1.000 | ** | 3,4,5 |
CV:mclust | 6 | 1.000 | 0.998 | 0.995 | ** | 2,3,4,5 |
MAD:hclust | 6 | 1.000 | 1.000 | 1.000 | ** | 5 |
MAD:skmeans | 6 | 1.000 | 0.989 | 0.975 | ** | 2,5 |
MAD:pam | 6 | 1.000 | 1.000 | 1.000 | ** | 5 |
MAD:mclust | 6 | 1.000 | 1.000 | 1.000 | ** | 3,4,5 |
ATC:hclust | 6 | 1.000 | 0.993 | 0.985 | ** | 2,3,4 |
ATC:kmeans | 3 | 1.000 | 0.998 | 0.983 | ** | 2 |
ATC:pam | 6 | 1.000 | 0.999 | 0.999 | ** | 2,3,4,5 |
ATC:mclust | 6 | 1.000 | 1.000 | 1.000 | ** | 4,5 |
ATC:NMF | 3 | 1.000 | 0.986 | 0.992 | ** | 2 |
SD:NMF | 6 | 0.951 | 0.856 | 0.921 | ** | 4,5 |
MAD:NMF | 6 | 0.948 | 0.907 | 0.945 | * | 2,5 |
CV:NMF | 6 | 0.925 | 0.839 | 0.874 | * | 2 |
CV:skmeans | 6 | 0.917 | 0.970 | 0.941 | * | 2,5 |
CV:pam | 6 | 0.917 | 0.975 | 0.940 | * | 2,4,5 |
ATC:skmeans | 6 | 0.917 | 0.979 | 0.974 | * | 2,3 |
MAD:kmeans | 2 | 0.584 | 0.933 | 0.938 | ||
SD:kmeans | 4 | 0.574 | 0.774 | 0.768 | ||
CV:kmeans | 2 | 0.252 | 0.862 | 0.831 |
**: 1-PAC > 0.95, *: 1-PAC > 0.9
Cumulative distribution function curves of consensus matrix for all methods.
collect_plots(res_list, fun = plot_ecdf)
Consensus heatmaps for all methods. (What is a consensus heatmap?)
collect_plots(res_list, k = 2, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = consensus_heatmap, mc.cores = 4)
Membership heatmaps for all methods. (What is a membership heatmap?)
collect_plots(res_list, k = 2, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = membership_heatmap, mc.cores = 4)
Signature heatmaps for all methods. (What is a signature heatmap?)
Note in following heatmaps, rows are scaled.
collect_plots(res_list, k = 2, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 3, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 4, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 5, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 6, fun = get_signatures, mc.cores = 4)
The statistics used for measuring the stability of consensus partitioning. (How are they defined?)
get_stats(res_list, k = 2)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 2 0.537 0.707 0.888 0.386 0.584 0.584
#> CV:NMF 2 0.938 0.969 0.969 0.497 0.501 0.501
#> MAD:NMF 2 1.000 0.979 0.989 0.501 0.501 0.501
#> ATC:NMF 2 1.000 1.000 1.000 0.250 0.751 0.751
#> SD:skmeans 2 1.000 1.000 1.000 0.499 0.501 0.501
#> CV:skmeans 2 1.000 0.997 0.998 0.499 0.501 0.501
#> MAD:skmeans 2 1.000 0.998 0.999 0.499 0.501 0.501
#> ATC:skmeans 2 1.000 1.000 1.000 0.499 0.501 0.501
#> SD:mclust 2 0.751 0.936 0.959 0.479 0.501 0.501
#> CV:mclust 2 1.000 0.984 0.988 0.497 0.501 0.501
#> MAD:mclust 2 0.584 0.939 0.946 0.494 0.501 0.501
#> ATC:mclust 2 0.501 0.804 0.837 0.417 0.584 0.584
#> SD:kmeans 2 0.335 0.900 0.885 0.418 0.501 0.501
#> CV:kmeans 2 0.252 0.862 0.831 0.413 0.501 0.501
#> MAD:kmeans 2 0.584 0.933 0.938 0.456 0.501 0.501
#> ATC:kmeans 2 1.000 1.000 1.000 0.250 0.751 0.751
#> SD:pam 2 1.000 0.989 0.990 0.256 0.751 0.751
#> CV:pam 2 1.000 0.998 0.997 0.496 0.501 0.501
#> MAD:pam 2 0.454 0.757 0.850 0.401 0.501 0.501
#> ATC:pam 2 1.000 1.000 1.000 0.250 0.751 0.751
#> SD:hclust 2 1.000 1.000 1.000 0.250 0.751 0.751
#> CV:hclust 2 0.501 0.959 0.931 0.460 0.501 0.501
#> MAD:hclust 2 0.751 0.924 0.960 0.499 0.501 0.501
#> ATC:hclust 2 1.000 1.000 1.000 0.250 0.751 0.751
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 0.795 0.921 0.942 0.545 0.731 0.573
#> CV:NMF 3 0.792 0.911 0.885 0.233 0.875 0.751
#> MAD:NMF 3 0.861 0.941 0.965 0.192 0.886 0.778
#> ATC:NMF 3 1.000 0.986 0.992 1.335 0.668 0.557
#> SD:skmeans 3 0.709 0.944 0.903 0.192 0.917 0.834
#> CV:skmeans 3 0.875 0.951 0.959 0.266 0.875 0.751
#> MAD:skmeans 3 0.709 0.809 0.837 0.218 1.000 1.000
#> ATC:skmeans 3 0.917 0.951 0.963 0.166 0.917 0.834
#> SD:mclust 3 0.834 0.924 0.949 0.327 0.668 0.431
#> CV:mclust 3 1.000 0.996 0.997 0.335 0.751 0.541
#> MAD:mclust 3 1.000 1.000 1.000 0.179 0.584 0.377
#> ATC:mclust 3 0.834 0.967 0.981 0.424 0.834 0.716
#> SD:kmeans 3 0.501 0.658 0.758 0.429 0.948 0.896
#> CV:kmeans 3 0.294 0.745 0.721 0.376 1.000 1.000
#> MAD:kmeans 3 0.584 0.780 0.799 0.327 1.000 1.000
#> ATC:kmeans 3 1.000 0.998 0.983 1.267 0.668 0.557
#> SD:pam 3 0.782 0.918 0.960 1.326 0.668 0.557
#> CV:pam 3 0.792 0.910 0.859 0.214 0.875 0.751
#> MAD:pam 3 0.782 0.910 0.958 0.488 0.917 0.834
#> ATC:pam 3 1.000 1.000 1.000 1.328 0.668 0.557
#> SD:hclust 3 0.792 0.869 0.939 1.423 0.626 0.502
#> CV:hclust 3 1.000 0.999 0.998 0.357 0.875 0.751
#> MAD:hclust 3 0.792 0.921 0.960 0.190 0.917 0.834
#> ATC:hclust 3 1.000 1.000 1.000 1.328 0.668 0.557
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.975 0.947 0.978 0.1903 0.881 0.707
#> CV:NMF 4 0.834 0.954 0.930 0.1544 0.917 0.779
#> MAD:NMF 4 0.880 0.916 0.963 0.1928 0.881 0.707
#> ATC:NMF 4 0.794 0.885 0.901 0.1982 0.875 0.702
#> SD:skmeans 4 0.834 0.928 0.889 0.1931 0.875 0.702
#> CV:skmeans 4 0.834 0.923 0.901 0.1234 0.917 0.779
#> MAD:skmeans 4 0.834 0.871 0.822 0.1649 0.792 0.585
#> ATC:skmeans 4 0.834 0.939 0.913 0.1144 0.958 0.901
#> SD:mclust 4 1.000 1.000 1.000 0.1123 0.958 0.876
#> CV:mclust 4 1.000 1.000 1.000 0.0655 0.958 0.876
#> MAD:mclust 4 1.000 1.000 1.000 0.2139 0.875 0.702
#> ATC:mclust 4 1.000 1.000 1.000 0.1909 0.875 0.702
#> SD:kmeans 4 0.574 0.774 0.768 0.1492 0.823 0.616
#> CV:kmeans 4 0.626 0.762 0.710 0.1999 0.792 0.585
#> MAD:kmeans 4 0.532 0.770 0.772 0.1335 0.792 0.585
#> ATC:kmeans 4 0.709 0.802 0.788 0.2328 0.834 0.602
#> SD:pam 4 0.823 0.912 0.957 0.1908 0.875 0.702
#> CV:pam 4 1.000 0.998 0.998 0.1729 0.917 0.779
#> MAD:pam 4 0.849 0.942 0.968 0.1864 0.875 0.702
#> ATC:pam 4 1.000 0.936 0.975 0.2535 0.850 0.641
#> SD:hclust 4 0.834 0.873 0.939 0.1663 0.917 0.779
#> CV:hclust 4 1.000 0.997 0.995 0.1336 0.917 0.779
#> MAD:hclust 4 0.834 0.928 0.960 0.1902 0.875 0.702
#> ATC:hclust 4 1.000 0.985 0.990 0.2190 0.875 0.702
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 0.978 0.937 0.953 0.1073 0.922 0.730
#> CV:NMF 5 0.878 0.962 0.947 0.1095 0.917 0.717
#> MAD:NMF 5 0.933 0.936 0.957 0.1003 0.902 0.673
#> ATC:NMF 5 0.779 0.918 0.834 0.0753 0.917 0.717
#> SD:skmeans 5 0.917 0.964 0.967 0.1120 0.917 0.717
#> CV:skmeans 5 0.917 0.957 0.953 0.1097 0.917 0.717
#> MAD:skmeans 5 0.958 0.973 0.974 0.1148 0.917 0.717
#> ATC:skmeans 5 0.834 0.915 0.909 0.1578 0.875 0.669
#> SD:mclust 5 1.000 1.000 1.000 0.1175 0.917 0.717
#> CV:mclust 5 1.000 0.994 0.994 0.1175 0.917 0.717
#> MAD:mclust 5 1.000 1.000 1.000 0.1175 0.917 0.717
#> ATC:mclust 5 1.000 0.987 0.989 0.1175 0.917 0.717
#> SD:kmeans 5 0.522 0.692 0.689 0.0804 1.000 1.000
#> CV:kmeans 5 0.522 0.560 0.529 0.0786 0.834 0.504
#> MAD:kmeans 5 0.605 0.759 0.684 0.0900 0.917 0.717
#> ATC:kmeans 5 0.699 0.757 0.747 0.0922 1.000 1.000
#> SD:pam 5 0.892 0.859 0.921 0.1186 0.893 0.647
#> CV:pam 5 1.000 0.991 0.996 0.1168 0.897 0.660
#> MAD:pam 5 0.927 0.904 0.956 0.1203 0.912 0.701
#> ATC:pam 5 1.000 0.973 0.981 0.0947 0.918 0.700
#> SD:hclust 5 0.917 0.907 0.941 0.1175 0.917 0.717
#> CV:hclust 5 1.000 1.000 1.000 0.1175 0.917 0.717
#> MAD:hclust 5 0.917 0.983 0.985 0.1175 0.917 0.717
#> ATC:hclust 5 0.875 0.872 0.905 0.1129 0.917 0.717
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 0.951 0.856 0.921 0.0588 0.953 0.778
#> CV:NMF 6 0.925 0.839 0.874 0.0625 0.918 0.635
#> MAD:NMF 6 0.948 0.907 0.945 0.0630 0.948 0.756
#> ATC:NMF 6 0.824 0.908 0.855 0.0493 1.000 1.000
#> SD:skmeans 6 1.000 0.992 0.982 0.0532 0.958 0.802
#> CV:skmeans 6 0.917 0.970 0.941 0.0552 0.958 0.802
#> MAD:skmeans 6 1.000 0.989 0.975 0.0531 0.958 0.802
#> ATC:skmeans 6 0.917 0.979 0.974 0.1028 0.917 0.670
#> SD:mclust 6 1.000 1.000 1.000 0.0526 0.958 0.802
#> CV:mclust 6 1.000 0.998 0.995 0.0522 0.958 0.802
#> MAD:mclust 6 1.000 1.000 1.000 0.0526 0.958 0.802
#> ATC:mclust 6 1.000 1.000 1.000 0.0526 0.958 0.802
#> SD:kmeans 6 0.636 0.892 0.734 0.0676 0.875 0.575
#> CV:kmeans 6 0.626 0.680 0.688 0.0683 0.844 0.429
#> MAD:kmeans 6 0.647 0.890 0.700 0.0598 0.958 0.802
#> ATC:kmeans 6 0.768 0.909 0.719 0.0570 0.917 0.670
#> SD:pam 6 1.000 1.000 1.000 0.0483 0.945 0.744
#> CV:pam 6 0.917 0.975 0.940 0.0533 0.949 0.762
#> MAD:pam 6 1.000 1.000 1.000 0.0486 0.954 0.781
#> ATC:pam 6 1.000 0.999 0.999 0.0406 0.948 0.753
#> SD:hclust 6 1.000 1.000 1.000 0.0526 0.958 0.802
#> CV:hclust 6 1.000 1.000 1.000 0.0526 0.958 0.802
#> MAD:hclust 6 1.000 1.000 1.000 0.0526 0.958 0.802
#> ATC:hclust 6 1.000 0.993 0.985 0.0525 0.958 0.802
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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.2501 0.751 0.751
#> 3 3 0.792 0.869 0.939 1.4230 0.626 0.502
#> 4 4 0.834 0.873 0.939 0.1663 0.917 0.779
#> 5 5 0.917 0.907 0.941 0.1175 0.917 0.717
#> 6 6 1.000 1.000 1.000 0.0526 0.958 0.802
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 5
There is also optional best \(k\) = 2 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1740034 1 0 1 1 0
#> SRR1740035 1 0 1 1 0
#> SRR1740036 1 0 1 1 0
#> SRR1740037 1 0 1 1 0
#> SRR1740038 1 0 1 1 0
#> SRR1740039 1 0 1 1 0
#> SRR1740040 1 0 1 1 0
#> SRR1740041 1 0 1 1 0
#> SRR1740042 1 0 1 1 0
#> SRR1740043 1 0 1 1 0
#> SRR1740044 1 0 1 1 0
#> SRR1740045 1 0 1 1 0
#> SRR1740046 2 0 1 0 1
#> SRR1740048 2 0 1 0 1
#> SRR1740047 2 0 1 0 1
#> SRR1740049 2 0 1 0 1
#> SRR1740050 1 0 1 1 0
#> SRR1740051 1 0 1 1 0
#> SRR1740052 1 0 1 1 0
#> SRR1740054 1 0 1 1 0
#> SRR1740053 1 0 1 1 0
#> SRR1740056 1 0 1 1 0
#> SRR1740055 1 0 1 1 0
#> SRR1740057 1 0 1 1 0
#> SRR1740058 1 0 1 1 0
#> SRR1740059 1 0 1 1 0
#> SRR1740060 1 0 1 1 0
#> SRR1740061 1 0 1 1 0
#> SRR1740062 1 0 1 1 0
#> SRR1740063 1 0 1 1 0
#> SRR1740064 1 0 1 1 0
#> SRR1740065 1 0 1 1 0
#> SRR1740066 1 0 1 1 0
#> SRR1740067 1 0 1 1 0
#> SRR1740068 1 0 1 1 0
#> SRR1740069 1 0 1 1 0
#> SRR1740070 1 0 1 1 0
#> SRR1740071 1 0 1 1 0
#> SRR1740072 1 0 1 1 0
#> SRR1740073 1 0 1 1 0
#> SRR1740074 2 0 1 0 1
#> SRR1740075 2 0 1 0 1
#> SRR1740076 2 0 1 0 1
#> SRR1740077 2 0 1 0 1
#> SRR1740078 1 0 1 1 0
#> SRR1740079 1 0 1 1 0
#> SRR1740080 1 0 1 1 0
#> SRR1740081 1 0 1 1 0
#> SRR1740082 1 0 1 1 0
#> SRR1740083 1 0 1 1 0
#> SRR1740084 1 0 1 1 0
#> SRR1740085 1 0 1 1 0
#> SRR1740086 1 0 1 1 0
#> SRR1740087 1 0 1 1 0
#> SRR1740088 1 0 1 1 0
#> SRR1740089 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0.000 1.000 1.000 0.000 0
#> SRR1740035 1 0.000 1.000 1.000 0.000 0
#> SRR1740036 1 0.000 1.000 1.000 0.000 0
#> SRR1740037 1 0.000 1.000 1.000 0.000 0
#> SRR1740038 2 0.000 0.800 0.000 1.000 0
#> SRR1740039 2 0.000 0.800 0.000 1.000 0
#> SRR1740040 2 0.000 0.800 0.000 1.000 0
#> SRR1740041 2 0.000 0.800 0.000 1.000 0
#> SRR1740042 2 0.000 0.800 0.000 1.000 0
#> SRR1740043 2 0.000 0.800 0.000 1.000 0
#> SRR1740044 2 0.000 0.800 0.000 1.000 0
#> SRR1740045 2 0.000 0.800 0.000 1.000 0
#> SRR1740046 3 0.000 1.000 0.000 0.000 1
#> SRR1740048 3 0.000 1.000 0.000 0.000 1
#> SRR1740047 3 0.000 1.000 0.000 0.000 1
#> SRR1740049 3 0.000 1.000 0.000 0.000 1
#> SRR1740050 1 0.000 1.000 1.000 0.000 0
#> SRR1740051 1 0.000 1.000 1.000 0.000 0
#> SRR1740052 1 0.000 1.000 1.000 0.000 0
#> SRR1740054 2 0.621 0.479 0.428 0.572 0
#> SRR1740053 1 0.000 1.000 1.000 0.000 0
#> SRR1740056 2 0.621 0.479 0.428 0.572 0
#> SRR1740055 2 0.621 0.479 0.428 0.572 0
#> SRR1740057 2 0.621 0.479 0.428 0.572 0
#> SRR1740058 1 0.000 1.000 1.000 0.000 0
#> SRR1740059 1 0.000 1.000 1.000 0.000 0
#> SRR1740060 1 0.000 1.000 1.000 0.000 0
#> SRR1740061 1 0.000 1.000 1.000 0.000 0
#> SRR1740062 1 0.000 1.000 1.000 0.000 0
#> SRR1740063 1 0.000 1.000 1.000 0.000 0
#> SRR1740064 1 0.000 1.000 1.000 0.000 0
#> SRR1740065 1 0.000 1.000 1.000 0.000 0
#> SRR1740066 2 0.000 0.800 0.000 1.000 0
#> SRR1740067 2 0.000 0.800 0.000 1.000 0
#> SRR1740068 2 0.000 0.800 0.000 1.000 0
#> SRR1740069 2 0.000 0.800 0.000 1.000 0
#> SRR1740070 2 0.000 0.800 0.000 1.000 0
#> SRR1740071 2 0.000 0.800 0.000 1.000 0
#> SRR1740072 2 0.000 0.800 0.000 1.000 0
#> SRR1740073 2 0.000 0.800 0.000 1.000 0
#> SRR1740074 3 0.000 1.000 0.000 0.000 1
#> SRR1740075 3 0.000 1.000 0.000 0.000 1
#> SRR1740076 3 0.000 1.000 0.000 0.000 1
#> SRR1740077 3 0.000 1.000 0.000 0.000 1
#> SRR1740078 1 0.000 1.000 1.000 0.000 0
#> SRR1740079 1 0.000 1.000 1.000 0.000 0
#> SRR1740080 1 0.000 1.000 1.000 0.000 0
#> SRR1740081 1 0.000 1.000 1.000 0.000 0
#> SRR1740082 2 0.621 0.479 0.428 0.572 0
#> SRR1740083 2 0.621 0.479 0.428 0.572 0
#> SRR1740084 2 0.621 0.479 0.428 0.572 0
#> SRR1740085 2 0.621 0.479 0.428 0.572 0
#> SRR1740086 1 0.000 1.000 1.000 0.000 0
#> SRR1740087 1 0.000 1.000 1.000 0.000 0
#> SRR1740088 1 0.000 1.000 1.000 0.000 0
#> SRR1740089 1 0.000 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
#> SRR1740034 4 0.492 1.000 0.428 0.000 0 0.572
#> SRR1740035 4 0.492 1.000 0.428 0.000 0 0.572
#> SRR1740036 4 0.492 1.000 0.428 0.000 0 0.572
#> SRR1740037 4 0.492 1.000 0.428 0.000 0 0.572
#> SRR1740038 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740039 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740040 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740041 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740042 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740043 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740044 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740045 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740046 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR1740048 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR1740047 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR1740049 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR1740050 1 0.492 1.000 0.572 0.428 0 0.000
#> SRR1740051 1 0.492 1.000 0.572 0.428 0 0.000
#> SRR1740052 1 0.492 1.000 0.572 0.428 0 0.000
#> SRR1740054 2 0.000 0.479 0.000 1.000 0 0.000
#> SRR1740053 1 0.492 1.000 0.572 0.428 0 0.000
#> SRR1740056 2 0.000 0.479 0.000 1.000 0 0.000
#> SRR1740055 2 0.000 0.479 0.000 1.000 0 0.000
#> SRR1740057 2 0.000 0.479 0.000 1.000 0 0.000
#> SRR1740058 1 0.492 1.000 0.572 0.428 0 0.000
#> SRR1740059 1 0.492 1.000 0.572 0.428 0 0.000
#> SRR1740060 1 0.492 1.000 0.572 0.428 0 0.000
#> SRR1740061 1 0.492 1.000 0.572 0.428 0 0.000
#> SRR1740062 4 0.492 1.000 0.428 0.000 0 0.572
#> SRR1740063 4 0.492 1.000 0.428 0.000 0 0.572
#> SRR1740064 4 0.492 1.000 0.428 0.000 0 0.572
#> SRR1740065 4 0.492 1.000 0.428 0.000 0 0.572
#> SRR1740066 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740067 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740068 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740069 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740070 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740071 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740072 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740073 2 0.492 0.818 0.000 0.572 0 0.428
#> SRR1740074 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR1740075 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR1740076 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR1740077 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR1740078 1 0.492 1.000 0.572 0.428 0 0.000
#> SRR1740079 1 0.492 1.000 0.572 0.428 0 0.000
#> SRR1740080 1 0.492 1.000 0.572 0.428 0 0.000
#> SRR1740081 1 0.492 1.000 0.572 0.428 0 0.000
#> SRR1740082 2 0.000 0.479 0.000 1.000 0 0.000
#> SRR1740083 2 0.000 0.479 0.000 1.000 0 0.000
#> SRR1740084 2 0.000 0.479 0.000 1.000 0 0.000
#> SRR1740085 2 0.000 0.479 0.000 1.000 0 0.000
#> SRR1740086 1 0.492 1.000 0.572 0.428 0 0.000
#> SRR1740087 1 0.492 1.000 0.572 0.428 0 0.000
#> SRR1740088 1 0.492 1.000 0.572 0.428 0 0.000
#> SRR1740089 1 0.492 1.000 0.572 0.428 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.000 1.00 0.000 0 0 1 0.000
#> SRR1740035 4 0.000 1.00 0.000 0 0 1 0.000
#> SRR1740036 4 0.000 1.00 0.000 0 0 1 0.000
#> SRR1740037 4 0.000 1.00 0.000 0 0 1 0.000
#> SRR1740038 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740039 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740040 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740041 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740042 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740043 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740044 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740045 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740046 3 0.000 1.00 0.000 0 1 0 0.000
#> SRR1740048 3 0.000 1.00 0.000 0 1 0 0.000
#> SRR1740047 3 0.000 1.00 0.000 0 1 0 0.000
#> SRR1740049 3 0.000 1.00 0.000 0 1 0 0.000
#> SRR1740050 5 0.000 0.73 0.000 0 0 0 1.000
#> SRR1740051 5 0.000 0.73 0.000 0 0 0 1.000
#> SRR1740052 5 0.000 0.73 0.000 0 0 0 1.000
#> SRR1740054 1 0.000 1.00 1.000 0 0 0 0.000
#> SRR1740053 5 0.000 0.73 0.000 0 0 0 1.000
#> SRR1740056 1 0.000 1.00 1.000 0 0 0 0.000
#> SRR1740055 1 0.000 1.00 1.000 0 0 0 0.000
#> SRR1740057 1 0.000 1.00 1.000 0 0 0 0.000
#> SRR1740058 5 0.422 0.62 0.416 0 0 0 0.584
#> SRR1740059 5 0.422 0.62 0.416 0 0 0 0.584
#> SRR1740060 5 0.422 0.62 0.416 0 0 0 0.584
#> SRR1740061 5 0.422 0.62 0.416 0 0 0 0.584
#> SRR1740062 4 0.000 1.00 0.000 0 0 1 0.000
#> SRR1740063 4 0.000 1.00 0.000 0 0 1 0.000
#> SRR1740064 4 0.000 1.00 0.000 0 0 1 0.000
#> SRR1740065 4 0.000 1.00 0.000 0 0 1 0.000
#> SRR1740066 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740067 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740068 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740069 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740070 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740071 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740072 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740073 2 0.000 1.00 0.000 1 0 0 0.000
#> SRR1740074 3 0.000 1.00 0.000 0 1 0 0.000
#> SRR1740075 3 0.000 1.00 0.000 0 1 0 0.000
#> SRR1740076 3 0.000 1.00 0.000 0 1 0 0.000
#> SRR1740077 3 0.000 1.00 0.000 0 1 0 0.000
#> SRR1740078 5 0.000 0.73 0.000 0 0 0 1.000
#> SRR1740079 5 0.000 0.73 0.000 0 0 0 1.000
#> SRR1740080 5 0.000 0.73 0.000 0 0 0 1.000
#> SRR1740081 5 0.000 0.73 0.000 0 0 0 1.000
#> SRR1740082 1 0.000 1.00 1.000 0 0 0 0.000
#> SRR1740083 1 0.000 1.00 1.000 0 0 0 0.000
#> SRR1740084 1 0.000 1.00 1.000 0 0 0 0.000
#> SRR1740085 1 0.000 1.00 1.000 0 0 0 0.000
#> SRR1740086 5 0.422 0.62 0.416 0 0 0 0.584
#> SRR1740087 5 0.422 0.62 0.416 0 0 0 0.584
#> SRR1740088 5 0.422 0.62 0.416 0 0 0 0.584
#> SRR1740089 5 0.422 0.62 0.416 0 0 0 0.584
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0 1 0 0 0 1 0 0
#> SRR1740035 4 0 1 0 0 0 1 0 0
#> SRR1740036 4 0 1 0 0 0 1 0 0
#> SRR1740037 4 0 1 0 0 0 1 0 0
#> SRR1740038 2 0 1 0 1 0 0 0 0
#> SRR1740039 2 0 1 0 1 0 0 0 0
#> SRR1740040 2 0 1 0 1 0 0 0 0
#> SRR1740041 2 0 1 0 1 0 0 0 0
#> SRR1740042 2 0 1 0 1 0 0 0 0
#> SRR1740043 2 0 1 0 1 0 0 0 0
#> SRR1740044 2 0 1 0 1 0 0 0 0
#> SRR1740045 2 0 1 0 1 0 0 0 0
#> SRR1740046 3 0 1 0 0 1 0 0 0
#> SRR1740048 3 0 1 0 0 1 0 0 0
#> SRR1740047 3 0 1 0 0 1 0 0 0
#> SRR1740049 3 0 1 0 0 1 0 0 0
#> SRR1740050 5 0 1 0 0 0 0 1 0
#> SRR1740051 5 0 1 0 0 0 0 1 0
#> SRR1740052 5 0 1 0 0 0 0 1 0
#> SRR1740054 1 0 1 1 0 0 0 0 0
#> SRR1740053 5 0 1 0 0 0 0 1 0
#> SRR1740056 1 0 1 1 0 0 0 0 0
#> SRR1740055 1 0 1 1 0 0 0 0 0
#> SRR1740057 1 0 1 1 0 0 0 0 0
#> SRR1740058 6 0 1 0 0 0 0 0 1
#> SRR1740059 6 0 1 0 0 0 0 0 1
#> SRR1740060 6 0 1 0 0 0 0 0 1
#> SRR1740061 6 0 1 0 0 0 0 0 1
#> SRR1740062 4 0 1 0 0 0 1 0 0
#> SRR1740063 4 0 1 0 0 0 1 0 0
#> SRR1740064 4 0 1 0 0 0 1 0 0
#> SRR1740065 4 0 1 0 0 0 1 0 0
#> SRR1740066 2 0 1 0 1 0 0 0 0
#> SRR1740067 2 0 1 0 1 0 0 0 0
#> SRR1740068 2 0 1 0 1 0 0 0 0
#> SRR1740069 2 0 1 0 1 0 0 0 0
#> SRR1740070 2 0 1 0 1 0 0 0 0
#> SRR1740071 2 0 1 0 1 0 0 0 0
#> SRR1740072 2 0 1 0 1 0 0 0 0
#> SRR1740073 2 0 1 0 1 0 0 0 0
#> SRR1740074 3 0 1 0 0 1 0 0 0
#> SRR1740075 3 0 1 0 0 1 0 0 0
#> SRR1740076 3 0 1 0 0 1 0 0 0
#> SRR1740077 3 0 1 0 0 1 0 0 0
#> SRR1740078 5 0 1 0 0 0 0 1 0
#> SRR1740079 5 0 1 0 0 0 0 1 0
#> SRR1740080 5 0 1 0 0 0 0 1 0
#> SRR1740081 5 0 1 0 0 0 0 1 0
#> SRR1740082 1 0 1 1 0 0 0 0 0
#> SRR1740083 1 0 1 1 0 0 0 0 0
#> SRR1740084 1 0 1 1 0 0 0 0 0
#> SRR1740085 1 0 1 1 0 0 0 0 0
#> SRR1740086 6 0 1 0 0 0 0 0 1
#> SRR1740087 6 0 1 0 0 0 0 0 1
#> SRR1740088 6 0 1 0 0 0 0 0 1
#> SRR1740089 6 0 1 0 0 0 0 0 1
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.335 0.900 0.885 0.4182 0.501 0.501
#> 3 3 0.501 0.658 0.758 0.4293 0.948 0.896
#> 4 4 0.574 0.774 0.768 0.1492 0.823 0.616
#> 5 5 0.522 0.692 0.689 0.0804 1.000 1.000
#> 6 6 0.636 0.892 0.734 0.0676 0.875 0.575
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
#> SRR1740034 1 0.541 0.883 0.876 0.124
#> SRR1740035 1 0.541 0.883 0.876 0.124
#> SRR1740036 1 0.541 0.883 0.876 0.124
#> SRR1740037 1 0.541 0.883 0.876 0.124
#> SRR1740038 2 0.909 0.880 0.324 0.676
#> SRR1740039 2 0.909 0.880 0.324 0.676
#> SRR1740040 2 0.909 0.880 0.324 0.676
#> SRR1740041 2 0.909 0.880 0.324 0.676
#> SRR1740042 2 0.904 0.882 0.320 0.680
#> SRR1740043 2 0.904 0.882 0.320 0.680
#> SRR1740044 2 0.904 0.882 0.320 0.680
#> SRR1740045 2 0.904 0.882 0.320 0.680
#> SRR1740046 2 0.552 0.799 0.128 0.872
#> SRR1740048 2 0.552 0.799 0.128 0.872
#> SRR1740047 2 0.552 0.799 0.128 0.872
#> SRR1740049 2 0.552 0.799 0.128 0.872
#> SRR1740050 1 0.000 0.954 1.000 0.000
#> SRR1740051 1 0.000 0.954 1.000 0.000
#> SRR1740052 1 0.000 0.954 1.000 0.000
#> SRR1740054 1 0.118 0.949 0.984 0.016
#> SRR1740053 1 0.000 0.954 1.000 0.000
#> SRR1740056 1 0.118 0.949 0.984 0.016
#> SRR1740055 1 0.118 0.949 0.984 0.016
#> SRR1740057 1 0.118 0.949 0.984 0.016
#> SRR1740058 1 0.000 0.954 1.000 0.000
#> SRR1740059 1 0.000 0.954 1.000 0.000
#> SRR1740060 1 0.000 0.954 1.000 0.000
#> SRR1740061 1 0.000 0.954 1.000 0.000
#> SRR1740062 1 0.541 0.883 0.876 0.124
#> SRR1740063 1 0.541 0.883 0.876 0.124
#> SRR1740064 1 0.541 0.883 0.876 0.124
#> SRR1740065 1 0.541 0.883 0.876 0.124
#> SRR1740066 2 0.909 0.880 0.324 0.676
#> SRR1740067 2 0.909 0.880 0.324 0.676
#> SRR1740068 2 0.909 0.880 0.324 0.676
#> SRR1740069 2 0.909 0.880 0.324 0.676
#> SRR1740070 2 0.904 0.882 0.320 0.680
#> SRR1740071 2 0.904 0.882 0.320 0.680
#> SRR1740072 2 0.904 0.882 0.320 0.680
#> SRR1740073 2 0.904 0.882 0.320 0.680
#> SRR1740074 2 0.552 0.799 0.128 0.872
#> SRR1740075 2 0.552 0.799 0.128 0.872
#> SRR1740076 2 0.552 0.799 0.128 0.872
#> SRR1740077 2 0.552 0.799 0.128 0.872
#> SRR1740078 1 0.000 0.954 1.000 0.000
#> SRR1740079 1 0.000 0.954 1.000 0.000
#> SRR1740080 1 0.000 0.954 1.000 0.000
#> SRR1740081 1 0.000 0.954 1.000 0.000
#> SRR1740082 1 0.118 0.949 0.984 0.016
#> SRR1740083 1 0.118 0.949 0.984 0.016
#> SRR1740084 1 0.118 0.949 0.984 0.016
#> SRR1740085 1 0.118 0.949 0.984 0.016
#> SRR1740086 1 0.000 0.954 1.000 0.000
#> SRR1740087 1 0.000 0.954 1.000 0.000
#> SRR1740088 1 0.000 0.954 1.000 0.000
#> SRR1740089 1 0.000 0.954 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0.245 0.665 0.924 0.076 0.000
#> SRR1740035 1 0.245 0.665 0.924 0.076 0.000
#> SRR1740036 1 0.245 0.665 0.924 0.076 0.000
#> SRR1740037 1 0.245 0.665 0.924 0.076 0.000
#> SRR1740038 2 0.175 0.779 0.048 0.952 0.000
#> SRR1740039 2 0.175 0.779 0.048 0.952 0.000
#> SRR1740040 2 0.175 0.779 0.048 0.952 0.000
#> SRR1740041 2 0.175 0.779 0.048 0.952 0.000
#> SRR1740042 2 0.141 0.779 0.036 0.964 0.000
#> SRR1740043 2 0.141 0.779 0.036 0.964 0.000
#> SRR1740044 2 0.141 0.779 0.036 0.964 0.000
#> SRR1740045 2 0.141 0.779 0.036 0.964 0.000
#> SRR1740046 2 0.631 -0.954 0.000 0.508 0.492
#> SRR1740048 2 0.631 -0.954 0.000 0.508 0.492
#> SRR1740047 2 0.631 -0.954 0.000 0.508 0.492
#> SRR1740049 2 0.631 -0.954 0.000 0.508 0.492
#> SRR1740050 1 0.713 0.791 0.544 0.024 0.432
#> SRR1740051 1 0.713 0.791 0.544 0.024 0.432
#> SRR1740052 1 0.713 0.791 0.544 0.024 0.432
#> SRR1740054 1 0.885 0.759 0.560 0.156 0.284
#> SRR1740053 1 0.713 0.791 0.544 0.024 0.432
#> SRR1740056 1 0.885 0.759 0.560 0.156 0.284
#> SRR1740055 1 0.885 0.759 0.560 0.156 0.284
#> SRR1740057 1 0.880 0.761 0.564 0.152 0.284
#> SRR1740058 1 0.670 0.810 0.648 0.024 0.328
#> SRR1740059 1 0.670 0.810 0.648 0.024 0.328
#> SRR1740060 1 0.670 0.810 0.648 0.024 0.328
#> SRR1740061 1 0.670 0.810 0.648 0.024 0.328
#> SRR1740062 1 0.268 0.665 0.920 0.076 0.004
#> SRR1740063 1 0.268 0.665 0.920 0.076 0.004
#> SRR1740064 1 0.268 0.665 0.920 0.076 0.004
#> SRR1740065 1 0.268 0.665 0.920 0.076 0.004
#> SRR1740066 2 0.175 0.779 0.048 0.952 0.000
#> SRR1740067 2 0.175 0.779 0.048 0.952 0.000
#> SRR1740068 2 0.175 0.779 0.048 0.952 0.000
#> SRR1740069 2 0.175 0.779 0.048 0.952 0.000
#> SRR1740070 2 0.141 0.779 0.036 0.964 0.000
#> SRR1740071 2 0.141 0.779 0.036 0.964 0.000
#> SRR1740072 2 0.141 0.779 0.036 0.964 0.000
#> SRR1740073 2 0.141 0.779 0.036 0.964 0.000
#> SRR1740074 3 0.630 1.000 0.000 0.472 0.528
#> SRR1740075 3 0.630 1.000 0.000 0.472 0.528
#> SRR1740076 3 0.630 1.000 0.000 0.472 0.528
#> SRR1740077 3 0.630 1.000 0.000 0.472 0.528
#> SRR1740078 1 0.713 0.791 0.544 0.024 0.432
#> SRR1740079 1 0.713 0.791 0.544 0.024 0.432
#> SRR1740080 1 0.713 0.791 0.544 0.024 0.432
#> SRR1740081 1 0.713 0.791 0.544 0.024 0.432
#> SRR1740082 1 0.885 0.759 0.560 0.156 0.284
#> SRR1740083 1 0.885 0.759 0.560 0.156 0.284
#> SRR1740084 1 0.885 0.759 0.560 0.156 0.284
#> SRR1740085 1 0.885 0.759 0.560 0.156 0.284
#> SRR1740086 1 0.670 0.810 0.648 0.024 0.328
#> SRR1740087 1 0.670 0.810 0.648 0.024 0.328
#> SRR1740088 1 0.670 0.810 0.648 0.024 0.328
#> SRR1740089 1 0.670 0.810 0.648 0.024 0.328
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 4 0.6049 0.974 0.200 0.044 0.044 0.712
#> SRR1740035 4 0.6049 0.974 0.200 0.044 0.044 0.712
#> SRR1740036 4 0.6049 0.974 0.200 0.044 0.044 0.712
#> SRR1740037 4 0.6049 0.974 0.200 0.044 0.044 0.712
#> SRR1740038 2 0.0592 0.948 0.016 0.984 0.000 0.000
#> SRR1740039 2 0.0592 0.948 0.016 0.984 0.000 0.000
#> SRR1740040 2 0.0592 0.948 0.016 0.984 0.000 0.000
#> SRR1740041 2 0.0592 0.948 0.016 0.984 0.000 0.000
#> SRR1740042 2 0.2522 0.948 0.016 0.908 0.000 0.076
#> SRR1740043 2 0.2522 0.948 0.016 0.908 0.000 0.076
#> SRR1740044 2 0.2522 0.948 0.016 0.908 0.000 0.076
#> SRR1740045 2 0.2522 0.948 0.016 0.908 0.000 0.076
#> SRR1740046 3 0.4699 0.949 0.000 0.320 0.676 0.004
#> SRR1740048 3 0.4699 0.949 0.000 0.320 0.676 0.004
#> SRR1740047 3 0.4699 0.949 0.000 0.320 0.676 0.004
#> SRR1740049 3 0.4699 0.949 0.000 0.320 0.676 0.004
#> SRR1740050 1 0.0188 0.573 0.996 0.004 0.000 0.000
#> SRR1740051 1 0.0188 0.573 0.996 0.004 0.000 0.000
#> SRR1740052 1 0.0188 0.573 0.996 0.004 0.000 0.000
#> SRR1740054 1 0.9354 0.484 0.440 0.168 0.172 0.220
#> SRR1740053 1 0.0188 0.573 0.996 0.004 0.000 0.000
#> SRR1740056 1 0.9354 0.484 0.440 0.168 0.172 0.220
#> SRR1740055 1 0.9354 0.484 0.440 0.168 0.172 0.220
#> SRR1740057 1 0.9326 0.484 0.444 0.164 0.172 0.220
#> SRR1740058 1 0.6972 0.539 0.600 0.004 0.172 0.224
#> SRR1740059 1 0.6972 0.539 0.600 0.004 0.172 0.224
#> SRR1740060 1 0.6972 0.539 0.600 0.004 0.172 0.224
#> SRR1740061 1 0.6972 0.539 0.600 0.004 0.172 0.224
#> SRR1740062 4 0.4800 0.974 0.196 0.044 0.000 0.760
#> SRR1740063 4 0.4800 0.974 0.196 0.044 0.000 0.760
#> SRR1740064 4 0.4800 0.974 0.196 0.044 0.000 0.760
#> SRR1740065 4 0.4800 0.974 0.196 0.044 0.000 0.760
#> SRR1740066 2 0.0592 0.948 0.016 0.984 0.000 0.000
#> SRR1740067 2 0.0592 0.948 0.016 0.984 0.000 0.000
#> SRR1740068 2 0.0592 0.948 0.016 0.984 0.000 0.000
#> SRR1740069 2 0.0592 0.948 0.016 0.984 0.000 0.000
#> SRR1740070 2 0.2522 0.948 0.016 0.908 0.000 0.076
#> SRR1740071 2 0.2522 0.948 0.016 0.908 0.000 0.076
#> SRR1740072 2 0.2522 0.948 0.016 0.908 0.000 0.076
#> SRR1740073 2 0.2522 0.948 0.016 0.908 0.000 0.076
#> SRR1740074 3 0.6478 0.949 0.000 0.336 0.576 0.088
#> SRR1740075 3 0.6478 0.949 0.000 0.336 0.576 0.088
#> SRR1740076 3 0.6516 0.949 0.000 0.332 0.576 0.092
#> SRR1740077 3 0.6516 0.949 0.000 0.332 0.576 0.092
#> SRR1740078 1 0.0895 0.573 0.976 0.004 0.020 0.000
#> SRR1740079 1 0.0895 0.573 0.976 0.004 0.020 0.000
#> SRR1740080 1 0.0895 0.573 0.976 0.004 0.020 0.000
#> SRR1740081 1 0.0895 0.573 0.976 0.004 0.020 0.000
#> SRR1740082 1 0.9354 0.484 0.440 0.168 0.172 0.220
#> SRR1740083 1 0.9354 0.484 0.440 0.168 0.172 0.220
#> SRR1740084 1 0.9354 0.484 0.440 0.168 0.172 0.220
#> SRR1740085 1 0.9354 0.484 0.440 0.168 0.172 0.220
#> SRR1740086 1 0.6963 0.539 0.600 0.004 0.168 0.228
#> SRR1740087 1 0.6963 0.539 0.600 0.004 0.168 0.228
#> SRR1740088 1 0.6963 0.539 0.600 0.004 0.168 0.228
#> SRR1740089 1 0.6963 0.539 0.600 0.004 0.168 0.228
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.5574 0.922 0.076 0.028 0.064 0.748 0.084
#> SRR1740035 4 0.5574 0.922 0.076 0.028 0.064 0.748 0.084
#> SRR1740036 4 0.5574 0.922 0.076 0.028 0.064 0.748 0.084
#> SRR1740037 4 0.5574 0.922 0.076 0.028 0.064 0.748 0.084
#> SRR1740038 2 0.3890 0.836 0.012 0.736 0.000 0.000 0.252
#> SRR1740039 2 0.3890 0.836 0.012 0.736 0.000 0.000 0.252
#> SRR1740040 2 0.3890 0.836 0.012 0.736 0.000 0.000 0.252
#> SRR1740041 2 0.3890 0.836 0.012 0.736 0.000 0.000 0.252
#> SRR1740042 2 0.0000 0.836 0.000 1.000 0.000 0.000 0.000
#> SRR1740043 2 0.0000 0.836 0.000 1.000 0.000 0.000 0.000
#> SRR1740044 2 0.0000 0.836 0.000 1.000 0.000 0.000 0.000
#> SRR1740045 2 0.0000 0.836 0.000 1.000 0.000 0.000 0.000
#> SRR1740046 3 0.6039 0.923 0.000 0.192 0.660 0.056 0.092
#> SRR1740048 3 0.6026 0.923 0.000 0.192 0.660 0.052 0.096
#> SRR1740047 3 0.6026 0.923 0.000 0.192 0.660 0.052 0.096
#> SRR1740049 3 0.6039 0.923 0.000 0.192 0.660 0.056 0.092
#> SRR1740050 1 0.5900 0.483 0.468 0.008 0.000 0.076 0.448
#> SRR1740051 1 0.5855 0.483 0.468 0.008 0.000 0.072 0.452
#> SRR1740052 1 0.5855 0.483 0.468 0.008 0.000 0.072 0.452
#> SRR1740054 1 0.8700 0.390 0.484 0.160 0.104 0.112 0.140
#> SRR1740053 1 0.5900 0.483 0.468 0.008 0.000 0.076 0.448
#> SRR1740056 1 0.8700 0.390 0.484 0.160 0.104 0.112 0.140
#> SRR1740055 1 0.8700 0.390 0.484 0.160 0.104 0.112 0.140
#> SRR1740057 1 0.8700 0.390 0.484 0.160 0.104 0.112 0.140
#> SRR1740058 1 0.3203 0.459 0.820 0.012 0.000 0.168 0.000
#> SRR1740059 1 0.3203 0.459 0.820 0.012 0.000 0.168 0.000
#> SRR1740060 1 0.3203 0.459 0.820 0.012 0.000 0.168 0.000
#> SRR1740061 1 0.3203 0.459 0.820 0.012 0.000 0.168 0.000
#> SRR1740062 4 0.2548 0.921 0.072 0.028 0.004 0.896 0.000
#> SRR1740063 4 0.2548 0.921 0.072 0.028 0.004 0.896 0.000
#> SRR1740064 4 0.2548 0.921 0.072 0.028 0.000 0.896 0.004
#> SRR1740065 4 0.2548 0.921 0.072 0.028 0.000 0.896 0.004
#> SRR1740066 2 0.4044 0.836 0.012 0.732 0.000 0.004 0.252
#> SRR1740067 2 0.4044 0.836 0.012 0.732 0.000 0.004 0.252
#> SRR1740068 2 0.4044 0.836 0.012 0.732 0.000 0.004 0.252
#> SRR1740069 2 0.4044 0.836 0.012 0.732 0.000 0.004 0.252
#> SRR1740070 2 0.0324 0.836 0.000 0.992 0.000 0.004 0.004
#> SRR1740071 2 0.0324 0.836 0.000 0.992 0.000 0.004 0.004
#> SRR1740072 2 0.0324 0.836 0.000 0.992 0.000 0.004 0.004
#> SRR1740073 2 0.0324 0.836 0.000 0.992 0.000 0.004 0.004
#> SRR1740074 3 0.3866 0.918 0.004 0.192 0.780 0.024 0.000
#> SRR1740075 3 0.3866 0.918 0.004 0.192 0.780 0.024 0.000
#> SRR1740076 3 0.3710 0.918 0.000 0.192 0.784 0.000 0.024
#> SRR1740077 3 0.3710 0.918 0.000 0.192 0.784 0.000 0.024
#> SRR1740078 1 0.6085 0.483 0.468 0.008 0.004 0.080 0.440
#> SRR1740079 1 0.6085 0.483 0.468 0.008 0.004 0.080 0.440
#> SRR1740080 1 0.6042 0.483 0.468 0.008 0.004 0.076 0.444
#> SRR1740081 1 0.6042 0.483 0.468 0.008 0.004 0.076 0.444
#> SRR1740082 1 0.8662 0.390 0.484 0.160 0.092 0.108 0.156
#> SRR1740083 1 0.8662 0.390 0.484 0.160 0.092 0.108 0.156
#> SRR1740084 1 0.8662 0.390 0.484 0.160 0.092 0.108 0.156
#> SRR1740085 1 0.8662 0.390 0.484 0.160 0.092 0.108 0.156
#> SRR1740086 1 0.3693 0.459 0.804 0.012 0.016 0.168 0.000
#> SRR1740087 1 0.3693 0.459 0.804 0.012 0.016 0.168 0.000
#> SRR1740088 1 0.3693 0.459 0.804 0.012 0.016 0.168 0.000
#> SRR1740089 1 0.3693 0.459 0.804 0.012 0.016 0.168 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.643 0.912 0.152 0.004 0.036 0.592 0.028 0.188
#> SRR1740035 4 0.651 0.912 0.152 0.004 0.036 0.592 0.036 0.180
#> SRR1740036 4 0.643 0.912 0.152 0.004 0.036 0.592 0.028 0.188
#> SRR1740037 4 0.655 0.912 0.152 0.004 0.040 0.592 0.036 0.176
#> SRR1740038 2 0.104 0.770 0.008 0.964 0.000 0.004 0.024 0.000
#> SRR1740039 2 0.104 0.770 0.008 0.964 0.000 0.004 0.024 0.000
#> SRR1740040 2 0.104 0.770 0.008 0.964 0.000 0.004 0.024 0.000
#> SRR1740041 2 0.104 0.770 0.008 0.964 0.000 0.004 0.024 0.000
#> SRR1740042 2 0.577 0.770 0.008 0.644 0.000 0.116 0.180 0.052
#> SRR1740043 2 0.577 0.770 0.008 0.644 0.000 0.116 0.180 0.052
#> SRR1740044 2 0.577 0.770 0.008 0.644 0.000 0.116 0.180 0.052
#> SRR1740045 2 0.577 0.770 0.008 0.644 0.000 0.116 0.180 0.052
#> SRR1740046 3 0.605 0.908 0.032 0.120 0.684 0.028 0.088 0.048
#> SRR1740048 3 0.599 0.908 0.028 0.120 0.684 0.028 0.100 0.040
#> SRR1740047 3 0.599 0.908 0.028 0.120 0.684 0.028 0.100 0.040
#> SRR1740049 3 0.605 0.908 0.032 0.120 0.684 0.028 0.088 0.048
#> SRR1740050 5 0.558 0.929 0.172 0.000 0.000 0.016 0.604 0.208
#> SRR1740051 5 0.595 0.929 0.180 0.000 0.008 0.020 0.584 0.208
#> SRR1740052 5 0.595 0.929 0.180 0.000 0.008 0.020 0.584 0.208
#> SRR1740054 1 0.209 0.989 0.908 0.072 0.004 0.012 0.004 0.000
#> SRR1740053 5 0.558 0.929 0.172 0.000 0.000 0.016 0.604 0.208
#> SRR1740056 1 0.209 0.989 0.908 0.072 0.004 0.012 0.004 0.000
#> SRR1740055 1 0.209 0.989 0.908 0.072 0.004 0.012 0.004 0.000
#> SRR1740057 1 0.209 0.989 0.908 0.072 0.004 0.012 0.004 0.000
#> SRR1740058 6 0.317 0.965 0.256 0.000 0.000 0.000 0.000 0.744
#> SRR1740059 6 0.317 0.965 0.256 0.000 0.000 0.000 0.000 0.744
#> SRR1740060 6 0.317 0.965 0.256 0.000 0.000 0.000 0.000 0.744
#> SRR1740061 6 0.317 0.965 0.256 0.000 0.000 0.000 0.000 0.744
#> SRR1740062 4 0.468 0.910 0.136 0.004 0.000 0.724 0.012 0.124
#> SRR1740063 4 0.468 0.910 0.136 0.004 0.000 0.724 0.012 0.124
#> SRR1740064 4 0.490 0.910 0.136 0.004 0.016 0.724 0.008 0.112
#> SRR1740065 4 0.490 0.910 0.136 0.004 0.016 0.724 0.008 0.112
#> SRR1740066 2 0.133 0.770 0.008 0.952 0.000 0.012 0.000 0.028
#> SRR1740067 2 0.133 0.770 0.008 0.952 0.000 0.012 0.000 0.028
#> SRR1740068 2 0.133 0.770 0.008 0.952 0.000 0.012 0.000 0.028
#> SRR1740069 2 0.133 0.770 0.008 0.952 0.000 0.012 0.000 0.028
#> SRR1740070 2 0.581 0.770 0.008 0.644 0.000 0.148 0.148 0.052
#> SRR1740071 2 0.581 0.770 0.008 0.644 0.000 0.148 0.148 0.052
#> SRR1740072 2 0.581 0.770 0.008 0.644 0.000 0.148 0.148 0.052
#> SRR1740073 2 0.581 0.770 0.008 0.644 0.000 0.148 0.148 0.052
#> SRR1740074 3 0.230 0.909 0.000 0.120 0.872 0.008 0.000 0.000
#> SRR1740075 3 0.230 0.909 0.000 0.120 0.872 0.008 0.000 0.000
#> SRR1740076 3 0.230 0.909 0.000 0.120 0.872 0.000 0.008 0.000
#> SRR1740077 3 0.230 0.909 0.000 0.120 0.872 0.000 0.008 0.000
#> SRR1740078 5 0.696 0.929 0.180 0.000 0.036 0.040 0.500 0.244
#> SRR1740079 5 0.696 0.929 0.180 0.000 0.036 0.040 0.500 0.244
#> SRR1740080 5 0.717 0.929 0.188 0.000 0.044 0.044 0.480 0.244
#> SRR1740081 5 0.717 0.929 0.188 0.000 0.044 0.044 0.480 0.244
#> SRR1740082 1 0.144 0.989 0.928 0.072 0.000 0.000 0.000 0.000
#> SRR1740083 1 0.144 0.989 0.928 0.072 0.000 0.000 0.000 0.000
#> SRR1740084 1 0.144 0.989 0.928 0.072 0.000 0.000 0.000 0.000
#> SRR1740085 1 0.144 0.989 0.928 0.072 0.000 0.000 0.000 0.000
#> SRR1740086 6 0.451 0.965 0.264 0.000 0.016 0.016 0.016 0.688
#> SRR1740087 6 0.451 0.965 0.264 0.000 0.016 0.016 0.016 0.688
#> SRR1740088 6 0.451 0.965 0.264 0.000 0.016 0.016 0.016 0.688
#> SRR1740089 6 0.451 0.965 0.264 0.000 0.016 0.016 0.016 0.688
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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4992 0.501 0.501
#> 3 3 0.709 0.944 0.903 0.1918 0.917 0.834
#> 4 4 0.834 0.928 0.889 0.1931 0.875 0.702
#> 5 5 0.917 0.964 0.967 0.1120 0.917 0.717
#> 6 6 1.000 0.992 0.982 0.0532 0.958 0.802
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 5
There is also optional best \(k\) = 2 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1740034 1 0 1 1 0
#> SRR1740035 1 0 1 1 0
#> SRR1740036 1 0 1 1 0
#> SRR1740037 1 0 1 1 0
#> SRR1740038 2 0 1 0 1
#> SRR1740039 2 0 1 0 1
#> SRR1740040 2 0 1 0 1
#> SRR1740041 2 0 1 0 1
#> SRR1740042 2 0 1 0 1
#> SRR1740043 2 0 1 0 1
#> SRR1740044 2 0 1 0 1
#> SRR1740045 2 0 1 0 1
#> SRR1740046 2 0 1 0 1
#> SRR1740048 2 0 1 0 1
#> SRR1740047 2 0 1 0 1
#> SRR1740049 2 0 1 0 1
#> SRR1740050 1 0 1 1 0
#> SRR1740051 1 0 1 1 0
#> SRR1740052 1 0 1 1 0
#> SRR1740054 1 0 1 1 0
#> SRR1740053 1 0 1 1 0
#> SRR1740056 1 0 1 1 0
#> SRR1740055 1 0 1 1 0
#> SRR1740057 1 0 1 1 0
#> SRR1740058 1 0 1 1 0
#> SRR1740059 1 0 1 1 0
#> SRR1740060 1 0 1 1 0
#> SRR1740061 1 0 1 1 0
#> SRR1740062 1 0 1 1 0
#> SRR1740063 1 0 1 1 0
#> SRR1740064 1 0 1 1 0
#> SRR1740065 1 0 1 1 0
#> SRR1740066 2 0 1 0 1
#> SRR1740067 2 0 1 0 1
#> SRR1740068 2 0 1 0 1
#> SRR1740069 2 0 1 0 1
#> SRR1740070 2 0 1 0 1
#> SRR1740071 2 0 1 0 1
#> SRR1740072 2 0 1 0 1
#> SRR1740073 2 0 1 0 1
#> SRR1740074 2 0 1 0 1
#> SRR1740075 2 0 1 0 1
#> SRR1740076 2 0 1 0 1
#> SRR1740077 2 0 1 0 1
#> SRR1740078 1 0 1 1 0
#> SRR1740079 1 0 1 1 0
#> SRR1740080 1 0 1 1 0
#> SRR1740081 1 0 1 1 0
#> SRR1740082 1 0 1 1 0
#> SRR1740083 1 0 1 1 0
#> SRR1740084 1 0 1 1 0
#> SRR1740085 1 0 1 1 0
#> SRR1740086 1 0 1 1 0
#> SRR1740087 1 0 1 1 0
#> SRR1740088 1 0 1 1 0
#> SRR1740089 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0.4291 0.861 0.820 0.000 0.180
#> SRR1740035 1 0.4291 0.861 0.820 0.000 0.180
#> SRR1740036 1 0.4291 0.861 0.820 0.000 0.180
#> SRR1740037 1 0.4291 0.861 0.820 0.000 0.180
#> SRR1740038 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740039 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740040 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740041 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740042 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740043 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740044 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740045 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740046 3 0.5291 1.000 0.000 0.268 0.732
#> SRR1740048 3 0.5291 1.000 0.000 0.268 0.732
#> SRR1740047 3 0.5291 1.000 0.000 0.268 0.732
#> SRR1740049 3 0.5291 1.000 0.000 0.268 0.732
#> SRR1740050 1 0.0000 0.928 1.000 0.000 0.000
#> SRR1740051 1 0.0000 0.928 1.000 0.000 0.000
#> SRR1740052 1 0.0000 0.928 1.000 0.000 0.000
#> SRR1740054 1 0.3587 0.890 0.892 0.020 0.088
#> SRR1740053 1 0.0000 0.928 1.000 0.000 0.000
#> SRR1740056 1 0.3587 0.890 0.892 0.020 0.088
#> SRR1740055 1 0.3587 0.890 0.892 0.020 0.088
#> SRR1740057 1 0.3587 0.890 0.892 0.020 0.088
#> SRR1740058 1 0.0892 0.928 0.980 0.000 0.020
#> SRR1740059 1 0.0892 0.928 0.980 0.000 0.020
#> SRR1740060 1 0.0892 0.928 0.980 0.000 0.020
#> SRR1740061 1 0.0892 0.928 0.980 0.000 0.020
#> SRR1740062 1 0.4291 0.861 0.820 0.000 0.180
#> SRR1740063 1 0.4291 0.861 0.820 0.000 0.180
#> SRR1740064 1 0.4291 0.861 0.820 0.000 0.180
#> SRR1740065 1 0.4291 0.861 0.820 0.000 0.180
#> SRR1740066 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740067 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740068 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740069 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740070 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740071 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740072 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740073 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1740074 3 0.5291 1.000 0.000 0.268 0.732
#> SRR1740075 3 0.5291 1.000 0.000 0.268 0.732
#> SRR1740076 3 0.5291 1.000 0.000 0.268 0.732
#> SRR1740077 3 0.5291 1.000 0.000 0.268 0.732
#> SRR1740078 1 0.0000 0.928 1.000 0.000 0.000
#> SRR1740079 1 0.0000 0.928 1.000 0.000 0.000
#> SRR1740080 1 0.0000 0.928 1.000 0.000 0.000
#> SRR1740081 1 0.0000 0.928 1.000 0.000 0.000
#> SRR1740082 1 0.3587 0.890 0.892 0.020 0.088
#> SRR1740083 1 0.3587 0.890 0.892 0.020 0.088
#> SRR1740084 1 0.3587 0.890 0.892 0.020 0.088
#> SRR1740085 1 0.3587 0.890 0.892 0.020 0.088
#> SRR1740086 1 0.0892 0.928 0.980 0.000 0.020
#> SRR1740087 1 0.0892 0.928 0.980 0.000 0.020
#> SRR1740088 1 0.0892 0.928 0.980 0.000 0.020
#> SRR1740089 1 0.0892 0.928 0.980 0.000 0.020
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR1740035 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR1740036 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR1740037 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR1740038 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740039 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740040 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740041 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740042 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740043 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740044 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740045 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740046 3 0.112 1.000 0.000 0.036 0.964 0.000
#> SRR1740048 3 0.112 1.000 0.000 0.036 0.964 0.000
#> SRR1740047 3 0.112 1.000 0.000 0.036 0.964 0.000
#> SRR1740049 3 0.112 1.000 0.000 0.036 0.964 0.000
#> SRR1740050 1 0.375 0.865 0.800 0.000 0.004 0.196
#> SRR1740051 1 0.375 0.865 0.800 0.000 0.004 0.196
#> SRR1740052 1 0.375 0.865 0.800 0.000 0.004 0.196
#> SRR1740054 1 0.121 0.789 0.964 0.000 0.032 0.004
#> SRR1740053 1 0.375 0.865 0.800 0.000 0.004 0.196
#> SRR1740056 1 0.121 0.789 0.964 0.000 0.032 0.004
#> SRR1740055 1 0.121 0.789 0.964 0.000 0.032 0.004
#> SRR1740057 1 0.121 0.789 0.964 0.000 0.032 0.004
#> SRR1740058 1 0.419 0.840 0.732 0.000 0.000 0.268
#> SRR1740059 1 0.419 0.840 0.732 0.000 0.000 0.268
#> SRR1740060 1 0.419 0.840 0.732 0.000 0.000 0.268
#> SRR1740061 1 0.419 0.840 0.732 0.000 0.000 0.268
#> SRR1740062 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR1740063 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR1740064 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR1740065 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR1740066 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740067 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740068 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740069 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740070 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740071 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740072 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740073 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740074 3 0.112 1.000 0.000 0.036 0.964 0.000
#> SRR1740075 3 0.112 1.000 0.000 0.036 0.964 0.000
#> SRR1740076 3 0.112 1.000 0.000 0.036 0.964 0.000
#> SRR1740077 3 0.112 1.000 0.000 0.036 0.964 0.000
#> SRR1740078 1 0.375 0.865 0.800 0.000 0.004 0.196
#> SRR1740079 1 0.375 0.865 0.800 0.000 0.004 0.196
#> SRR1740080 1 0.375 0.865 0.800 0.000 0.004 0.196
#> SRR1740081 1 0.375 0.865 0.800 0.000 0.004 0.196
#> SRR1740082 1 0.121 0.789 0.964 0.000 0.032 0.004
#> SRR1740083 1 0.121 0.789 0.964 0.000 0.032 0.004
#> SRR1740084 1 0.121 0.789 0.964 0.000 0.032 0.004
#> SRR1740085 1 0.121 0.789 0.964 0.000 0.032 0.004
#> SRR1740086 1 0.419 0.840 0.732 0.000 0.000 0.268
#> SRR1740087 1 0.419 0.840 0.732 0.000 0.000 0.268
#> SRR1740088 1 0.419 0.840 0.732 0.000 0.000 0.268
#> SRR1740089 1 0.419 0.840 0.732 0.000 0.000 0.268
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.0290 1.000 0.000 0.000 0 0.992 0.008
#> SRR1740035 4 0.0290 1.000 0.000 0.000 0 0.992 0.008
#> SRR1740036 4 0.0290 1.000 0.000 0.000 0 0.992 0.008
#> SRR1740037 4 0.0290 1.000 0.000 0.000 0 0.992 0.008
#> SRR1740038 2 0.0451 0.995 0.004 0.988 0 0.008 0.000
#> SRR1740039 2 0.0451 0.995 0.004 0.988 0 0.008 0.000
#> SRR1740040 2 0.0451 0.995 0.004 0.988 0 0.008 0.000
#> SRR1740041 2 0.0451 0.995 0.004 0.988 0 0.008 0.000
#> SRR1740042 2 0.0000 0.995 0.000 1.000 0 0.000 0.000
#> SRR1740043 2 0.0000 0.995 0.000 1.000 0 0.000 0.000
#> SRR1740044 2 0.0000 0.995 0.000 1.000 0 0.000 0.000
#> SRR1740045 2 0.0000 0.995 0.000 1.000 0 0.000 0.000
#> SRR1740046 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740048 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740047 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740049 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740050 5 0.0000 0.885 0.000 0.000 0 0.000 1.000
#> SRR1740051 5 0.0000 0.885 0.000 0.000 0 0.000 1.000
#> SRR1740052 5 0.0000 0.885 0.000 0.000 0 0.000 1.000
#> SRR1740054 1 0.0162 1.000 0.996 0.000 0 0.000 0.004
#> SRR1740053 5 0.0000 0.885 0.000 0.000 0 0.000 1.000
#> SRR1740056 1 0.0162 1.000 0.996 0.000 0 0.000 0.004
#> SRR1740055 1 0.0162 1.000 0.996 0.000 0 0.000 0.004
#> SRR1740057 1 0.0162 1.000 0.996 0.000 0 0.000 0.004
#> SRR1740058 5 0.3804 0.875 0.160 0.000 0 0.044 0.796
#> SRR1740059 5 0.3804 0.875 0.160 0.000 0 0.044 0.796
#> SRR1740060 5 0.3804 0.875 0.160 0.000 0 0.044 0.796
#> SRR1740061 5 0.3804 0.875 0.160 0.000 0 0.044 0.796
#> SRR1740062 4 0.0290 1.000 0.000 0.000 0 0.992 0.008
#> SRR1740063 4 0.0290 1.000 0.000 0.000 0 0.992 0.008
#> SRR1740064 4 0.0290 1.000 0.000 0.000 0 0.992 0.008
#> SRR1740065 4 0.0290 1.000 0.000 0.000 0 0.992 0.008
#> SRR1740066 2 0.0451 0.995 0.004 0.988 0 0.008 0.000
#> SRR1740067 2 0.0451 0.995 0.004 0.988 0 0.008 0.000
#> SRR1740068 2 0.0451 0.995 0.004 0.988 0 0.008 0.000
#> SRR1740069 2 0.0451 0.995 0.004 0.988 0 0.008 0.000
#> SRR1740070 2 0.0000 0.995 0.000 1.000 0 0.000 0.000
#> SRR1740071 2 0.0000 0.995 0.000 1.000 0 0.000 0.000
#> SRR1740072 2 0.0000 0.995 0.000 1.000 0 0.000 0.000
#> SRR1740073 2 0.0000 0.995 0.000 1.000 0 0.000 0.000
#> SRR1740074 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740075 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740076 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740077 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740078 5 0.0000 0.885 0.000 0.000 0 0.000 1.000
#> SRR1740079 5 0.0000 0.885 0.000 0.000 0 0.000 1.000
#> SRR1740080 5 0.0000 0.885 0.000 0.000 0 0.000 1.000
#> SRR1740081 5 0.0000 0.885 0.000 0.000 0 0.000 1.000
#> SRR1740082 1 0.0162 1.000 0.996 0.000 0 0.000 0.004
#> SRR1740083 1 0.0162 1.000 0.996 0.000 0 0.000 0.004
#> SRR1740084 1 0.0162 1.000 0.996 0.000 0 0.000 0.004
#> SRR1740085 1 0.0162 1.000 0.996 0.000 0 0.000 0.004
#> SRR1740086 5 0.3804 0.875 0.160 0.000 0 0.044 0.796
#> SRR1740087 5 0.3804 0.875 0.160 0.000 0 0.044 0.796
#> SRR1740088 5 0.3804 0.875 0.160 0.000 0 0.044 0.796
#> SRR1740089 5 0.3804 0.875 0.160 0.000 0 0.044 0.796
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR1740035 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR1740036 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR1740037 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR1740038 2 0.0000 0.972 0.000 1.000 0 0 0.000 0.000
#> SRR1740039 2 0.0000 0.972 0.000 1.000 0 0 0.000 0.000
#> SRR1740040 2 0.0000 0.972 0.000 1.000 0 0 0.000 0.000
#> SRR1740041 2 0.0000 0.972 0.000 1.000 0 0 0.000 0.000
#> SRR1740042 2 0.1500 0.972 0.012 0.936 0 0 0.052 0.000
#> SRR1740043 2 0.1500 0.972 0.012 0.936 0 0 0.052 0.000
#> SRR1740044 2 0.1500 0.972 0.012 0.936 0 0 0.052 0.000
#> SRR1740045 2 0.1500 0.972 0.012 0.936 0 0 0.052 0.000
#> SRR1740046 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR1740048 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR1740047 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR1740049 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR1740050 5 0.1141 1.000 0.000 0.000 0 0 0.948 0.052
#> SRR1740051 5 0.1141 1.000 0.000 0.000 0 0 0.948 0.052
#> SRR1740052 5 0.1141 1.000 0.000 0.000 0 0 0.948 0.052
#> SRR1740054 1 0.0363 1.000 0.988 0.000 0 0 0.000 0.012
#> SRR1740053 5 0.1141 1.000 0.000 0.000 0 0 0.948 0.052
#> SRR1740056 1 0.0363 1.000 0.988 0.000 0 0 0.000 0.012
#> SRR1740055 1 0.0363 1.000 0.988 0.000 0 0 0.000 0.012
#> SRR1740057 1 0.0363 1.000 0.988 0.000 0 0 0.000 0.012
#> SRR1740058 6 0.0000 1.000 0.000 0.000 0 0 0.000 1.000
#> SRR1740059 6 0.0000 1.000 0.000 0.000 0 0 0.000 1.000
#> SRR1740060 6 0.0000 1.000 0.000 0.000 0 0 0.000 1.000
#> SRR1740061 6 0.0000 1.000 0.000 0.000 0 0 0.000 1.000
#> SRR1740062 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR1740063 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR1740064 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR1740065 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR1740066 2 0.0000 0.972 0.000 1.000 0 0 0.000 0.000
#> SRR1740067 2 0.0000 0.972 0.000 1.000 0 0 0.000 0.000
#> SRR1740068 2 0.0000 0.972 0.000 1.000 0 0 0.000 0.000
#> SRR1740069 2 0.0000 0.972 0.000 1.000 0 0 0.000 0.000
#> SRR1740070 2 0.1500 0.972 0.012 0.936 0 0 0.052 0.000
#> SRR1740071 2 0.1500 0.972 0.012 0.936 0 0 0.052 0.000
#> SRR1740072 2 0.1500 0.972 0.012 0.936 0 0 0.052 0.000
#> SRR1740073 2 0.1500 0.972 0.012 0.936 0 0 0.052 0.000
#> SRR1740074 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR1740075 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR1740076 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR1740077 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR1740078 5 0.1141 1.000 0.000 0.000 0 0 0.948 0.052
#> SRR1740079 5 0.1141 1.000 0.000 0.000 0 0 0.948 0.052
#> SRR1740080 5 0.1141 1.000 0.000 0.000 0 0 0.948 0.052
#> SRR1740081 5 0.1141 1.000 0.000 0.000 0 0 0.948 0.052
#> SRR1740082 1 0.0363 1.000 0.988 0.000 0 0 0.000 0.012
#> SRR1740083 1 0.0363 1.000 0.988 0.000 0 0 0.000 0.012
#> SRR1740084 1 0.0363 1.000 0.988 0.000 0 0 0.000 0.012
#> SRR1740085 1 0.0363 1.000 0.988 0.000 0 0 0.000 0.012
#> SRR1740086 6 0.0000 1.000 0.000 0.000 0 0 0.000 1.000
#> SRR1740087 6 0.0000 1.000 0.000 0.000 0 0 0.000 1.000
#> SRR1740088 6 0.0000 1.000 0.000 0.000 0 0 0.000 1.000
#> SRR1740089 6 0.0000 1.000 0.000 0.000 0 0 0.000 1.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.989 0.990 0.2559 0.751 0.751
#> 3 3 0.782 0.918 0.960 1.3264 0.668 0.557
#> 4 4 0.823 0.912 0.957 0.1908 0.875 0.702
#> 5 5 0.892 0.859 0.921 0.1186 0.893 0.647
#> 6 6 1.000 1.000 1.000 0.0483 0.945 0.744
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1740034 1 0.0000 0.988 1.000 0.000
#> SRR1740035 1 0.0000 0.988 1.000 0.000
#> SRR1740036 1 0.0000 0.988 1.000 0.000
#> SRR1740037 1 0.0000 0.988 1.000 0.000
#> SRR1740038 1 0.1633 0.987 0.976 0.024
#> SRR1740039 1 0.1633 0.987 0.976 0.024
#> SRR1740040 1 0.1633 0.987 0.976 0.024
#> SRR1740041 1 0.1633 0.987 0.976 0.024
#> SRR1740042 1 0.1633 0.987 0.976 0.024
#> SRR1740043 1 0.1633 0.987 0.976 0.024
#> SRR1740044 1 0.1633 0.987 0.976 0.024
#> SRR1740045 1 0.1633 0.987 0.976 0.024
#> SRR1740046 2 0.0000 1.000 0.000 1.000
#> SRR1740048 2 0.0000 1.000 0.000 1.000
#> SRR1740047 2 0.0000 1.000 0.000 1.000
#> SRR1740049 2 0.0000 1.000 0.000 1.000
#> SRR1740050 1 0.0000 0.988 1.000 0.000
#> SRR1740051 1 0.0000 0.988 1.000 0.000
#> SRR1740052 1 0.0000 0.988 1.000 0.000
#> SRR1740054 1 0.1633 0.987 0.976 0.024
#> SRR1740053 1 0.0000 0.988 1.000 0.000
#> SRR1740056 1 0.1633 0.987 0.976 0.024
#> SRR1740055 1 0.1633 0.987 0.976 0.024
#> SRR1740057 1 0.0376 0.988 0.996 0.004
#> SRR1740058 1 0.0000 0.988 1.000 0.000
#> SRR1740059 1 0.0000 0.988 1.000 0.000
#> SRR1740060 1 0.0000 0.988 1.000 0.000
#> SRR1740061 1 0.0000 0.988 1.000 0.000
#> SRR1740062 1 0.0000 0.988 1.000 0.000
#> SRR1740063 1 0.0000 0.988 1.000 0.000
#> SRR1740064 1 0.0000 0.988 1.000 0.000
#> SRR1740065 1 0.0000 0.988 1.000 0.000
#> SRR1740066 1 0.1633 0.987 0.976 0.024
#> SRR1740067 1 0.1633 0.987 0.976 0.024
#> SRR1740068 1 0.1633 0.987 0.976 0.024
#> SRR1740069 1 0.1633 0.987 0.976 0.024
#> SRR1740070 1 0.1633 0.987 0.976 0.024
#> SRR1740071 1 0.1633 0.987 0.976 0.024
#> SRR1740072 1 0.1633 0.987 0.976 0.024
#> SRR1740073 1 0.1633 0.987 0.976 0.024
#> SRR1740074 2 0.0000 1.000 0.000 1.000
#> SRR1740075 2 0.0000 1.000 0.000 1.000
#> SRR1740076 2 0.0000 1.000 0.000 1.000
#> SRR1740077 2 0.0000 1.000 0.000 1.000
#> SRR1740078 1 0.0000 0.988 1.000 0.000
#> SRR1740079 1 0.0000 0.988 1.000 0.000
#> SRR1740080 1 0.0000 0.988 1.000 0.000
#> SRR1740081 1 0.0000 0.988 1.000 0.000
#> SRR1740082 1 0.1633 0.987 0.976 0.024
#> SRR1740083 1 0.1633 0.987 0.976 0.024
#> SRR1740084 1 0.1633 0.987 0.976 0.024
#> SRR1740085 1 0.1633 0.987 0.976 0.024
#> SRR1740086 1 0.0000 0.988 1.000 0.000
#> SRR1740087 1 0.0000 0.988 1.000 0.000
#> SRR1740088 1 0.0000 0.988 1.000 0.000
#> SRR1740089 1 0.0000 0.988 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0.000 0.920 1.000 0.000 0
#> SRR1740035 1 0.000 0.920 1.000 0.000 0
#> SRR1740036 1 0.000 0.920 1.000 0.000 0
#> SRR1740037 1 0.000 0.920 1.000 0.000 0
#> SRR1740038 2 0.000 1.000 0.000 1.000 0
#> SRR1740039 2 0.000 1.000 0.000 1.000 0
#> SRR1740040 2 0.000 1.000 0.000 1.000 0
#> SRR1740041 2 0.000 1.000 0.000 1.000 0
#> SRR1740042 2 0.000 1.000 0.000 1.000 0
#> SRR1740043 2 0.000 1.000 0.000 1.000 0
#> SRR1740044 2 0.000 1.000 0.000 1.000 0
#> SRR1740045 2 0.000 1.000 0.000 1.000 0
#> SRR1740046 3 0.000 1.000 0.000 0.000 1
#> SRR1740048 3 0.000 1.000 0.000 0.000 1
#> SRR1740047 3 0.000 1.000 0.000 0.000 1
#> SRR1740049 3 0.000 1.000 0.000 0.000 1
#> SRR1740050 1 0.000 0.920 1.000 0.000 0
#> SRR1740051 1 0.000 0.920 1.000 0.000 0
#> SRR1740052 1 0.000 0.920 1.000 0.000 0
#> SRR1740054 1 0.593 0.559 0.644 0.356 0
#> SRR1740053 1 0.000 0.920 1.000 0.000 0
#> SRR1740056 1 0.455 0.775 0.800 0.200 0
#> SRR1740055 1 0.593 0.559 0.644 0.356 0
#> SRR1740057 1 0.455 0.775 0.800 0.200 0
#> SRR1740058 1 0.000 0.920 1.000 0.000 0
#> SRR1740059 1 0.000 0.920 1.000 0.000 0
#> SRR1740060 1 0.000 0.920 1.000 0.000 0
#> SRR1740061 1 0.000 0.920 1.000 0.000 0
#> SRR1740062 1 0.000 0.920 1.000 0.000 0
#> SRR1740063 1 0.000 0.920 1.000 0.000 0
#> SRR1740064 1 0.000 0.920 1.000 0.000 0
#> SRR1740065 1 0.000 0.920 1.000 0.000 0
#> SRR1740066 2 0.000 1.000 0.000 1.000 0
#> SRR1740067 2 0.000 1.000 0.000 1.000 0
#> SRR1740068 2 0.000 1.000 0.000 1.000 0
#> SRR1740069 2 0.000 1.000 0.000 1.000 0
#> SRR1740070 2 0.000 1.000 0.000 1.000 0
#> SRR1740071 2 0.000 1.000 0.000 1.000 0
#> SRR1740072 2 0.000 1.000 0.000 1.000 0
#> SRR1740073 2 0.000 1.000 0.000 1.000 0
#> SRR1740074 3 0.000 1.000 0.000 0.000 1
#> SRR1740075 3 0.000 1.000 0.000 0.000 1
#> SRR1740076 3 0.000 1.000 0.000 0.000 1
#> SRR1740077 3 0.000 1.000 0.000 0.000 1
#> SRR1740078 1 0.000 0.920 1.000 0.000 0
#> SRR1740079 1 0.000 0.920 1.000 0.000 0
#> SRR1740080 1 0.000 0.920 1.000 0.000 0
#> SRR1740081 1 0.000 0.920 1.000 0.000 0
#> SRR1740082 1 0.593 0.559 0.644 0.356 0
#> SRR1740083 1 0.593 0.559 0.644 0.356 0
#> SRR1740084 1 0.455 0.775 0.800 0.200 0
#> SRR1740085 1 0.455 0.775 0.800 0.200 0
#> SRR1740086 1 0.000 0.920 1.000 0.000 0
#> SRR1740087 1 0.000 0.920 1.000 0.000 0
#> SRR1740088 1 0.000 0.920 1.000 0.000 0
#> SRR1740089 1 0.000 0.920 1.000 0.000 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740035 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740036 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740037 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740038 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740039 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740040 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740041 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740042 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740043 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740044 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740045 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740046 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740048 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740047 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740049 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740050 1 0.000 0.878 1.000 0.000 0 0
#> SRR1740051 1 0.000 0.878 1.000 0.000 0 0
#> SRR1740052 1 0.000 0.878 1.000 0.000 0 0
#> SRR1740054 1 0.488 0.484 0.592 0.408 0 0
#> SRR1740053 1 0.000 0.878 1.000 0.000 0 0
#> SRR1740056 1 0.361 0.772 0.800 0.200 0 0
#> SRR1740055 1 0.488 0.484 0.592 0.408 0 0
#> SRR1740057 1 0.361 0.772 0.800 0.200 0 0
#> SRR1740058 1 0.000 0.878 1.000 0.000 0 0
#> SRR1740059 1 0.000 0.878 1.000 0.000 0 0
#> SRR1740060 1 0.000 0.878 1.000 0.000 0 0
#> SRR1740061 1 0.000 0.878 1.000 0.000 0 0
#> SRR1740062 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740063 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740064 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740065 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740066 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740067 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740068 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740069 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740070 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740071 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740072 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740073 2 0.000 1.000 0.000 1.000 0 0
#> SRR1740074 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740075 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740076 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740077 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740078 1 0.000 0.878 1.000 0.000 0 0
#> SRR1740079 1 0.000 0.878 1.000 0.000 0 0
#> SRR1740080 1 0.000 0.878 1.000 0.000 0 0
#> SRR1740081 1 0.000 0.878 1.000 0.000 0 0
#> SRR1740082 1 0.488 0.484 0.592 0.408 0 0
#> SRR1740083 1 0.488 0.484 0.592 0.408 0 0
#> SRR1740084 1 0.361 0.772 0.800 0.200 0 0
#> SRR1740085 1 0.361 0.772 0.800 0.200 0 0
#> SRR1740086 1 0.000 0.878 1.000 0.000 0 0
#> SRR1740087 1 0.000 0.878 1.000 0.000 0 0
#> SRR1740088 1 0.000 0.878 1.000 0.000 0 0
#> SRR1740089 1 0.000 0.878 1.000 0.000 0 0
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.000 1.000 0.000 0.000 0 1 0.000
#> SRR1740035 4 0.000 1.000 0.000 0.000 0 1 0.000
#> SRR1740036 4 0.000 1.000 0.000 0.000 0 1 0.000
#> SRR1740037 4 0.000 1.000 0.000 0.000 0 1 0.000
#> SRR1740038 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740039 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740040 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740041 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740042 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740043 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740044 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740045 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740046 3 0.000 1.000 0.000 0.000 1 0 0.000
#> SRR1740048 3 0.000 1.000 0.000 0.000 1 0 0.000
#> SRR1740047 3 0.000 1.000 0.000 0.000 1 0 0.000
#> SRR1740049 3 0.000 1.000 0.000 0.000 1 0 0.000
#> SRR1740050 5 0.342 0.752 0.240 0.000 0 0 0.760
#> SRR1740051 5 0.000 0.829 0.000 0.000 0 0 1.000
#> SRR1740052 5 0.000 0.829 0.000 0.000 0 0 1.000
#> SRR1740054 5 0.440 0.718 0.252 0.036 0 0 0.712
#> SRR1740053 5 0.351 0.741 0.252 0.000 0 0 0.748
#> SRR1740056 1 0.368 0.335 0.720 0.000 0 0 0.280
#> SRR1740055 2 0.551 0.458 0.252 0.632 0 0 0.116
#> SRR1740057 1 0.304 0.500 0.808 0.000 0 0 0.192
#> SRR1740058 1 0.351 0.749 0.748 0.000 0 0 0.252
#> SRR1740059 1 0.351 0.749 0.748 0.000 0 0 0.252
#> SRR1740060 1 0.351 0.749 0.748 0.000 0 0 0.252
#> SRR1740061 1 0.351 0.749 0.748 0.000 0 0 0.252
#> SRR1740062 4 0.000 1.000 0.000 0.000 0 1 0.000
#> SRR1740063 4 0.000 1.000 0.000 0.000 0 1 0.000
#> SRR1740064 4 0.000 1.000 0.000 0.000 0 1 0.000
#> SRR1740065 4 0.000 1.000 0.000 0.000 0 1 0.000
#> SRR1740066 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740067 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740068 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740069 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740070 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740071 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740072 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740073 2 0.000 0.976 0.000 1.000 0 0 0.000
#> SRR1740074 3 0.000 1.000 0.000 0.000 1 0 0.000
#> SRR1740075 3 0.000 1.000 0.000 0.000 1 0 0.000
#> SRR1740076 3 0.000 1.000 0.000 0.000 1 0 0.000
#> SRR1740077 3 0.000 1.000 0.000 0.000 1 0 0.000
#> SRR1740078 5 0.167 0.839 0.076 0.000 0 0 0.924
#> SRR1740079 5 0.161 0.840 0.072 0.000 0 0 0.928
#> SRR1740080 5 0.000 0.829 0.000 0.000 0 0 1.000
#> SRR1740081 5 0.000 0.829 0.000 0.000 0 0 1.000
#> SRR1740082 1 0.497 0.234 0.588 0.376 0 0 0.036
#> SRR1740083 1 0.326 0.561 0.840 0.124 0 0 0.036
#> SRR1740084 1 0.218 0.591 0.888 0.000 0 0 0.112
#> SRR1740085 1 0.218 0.591 0.888 0.000 0 0 0.112
#> SRR1740086 1 0.351 0.749 0.748 0.000 0 0 0.252
#> SRR1740087 1 0.351 0.749 0.748 0.000 0 0 0.252
#> SRR1740088 1 0.351 0.749 0.748 0.000 0 0 0.252
#> SRR1740089 1 0.351 0.749 0.748 0.000 0 0 0.252
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0 1 0 0 0 1 0 0
#> SRR1740035 4 0 1 0 0 0 1 0 0
#> SRR1740036 4 0 1 0 0 0 1 0 0
#> SRR1740037 4 0 1 0 0 0 1 0 0
#> SRR1740038 2 0 1 0 1 0 0 0 0
#> SRR1740039 2 0 1 0 1 0 0 0 0
#> SRR1740040 2 0 1 0 1 0 0 0 0
#> SRR1740041 2 0 1 0 1 0 0 0 0
#> SRR1740042 2 0 1 0 1 0 0 0 0
#> SRR1740043 2 0 1 0 1 0 0 0 0
#> SRR1740044 2 0 1 0 1 0 0 0 0
#> SRR1740045 2 0 1 0 1 0 0 0 0
#> SRR1740046 3 0 1 0 0 1 0 0 0
#> SRR1740048 3 0 1 0 0 1 0 0 0
#> SRR1740047 3 0 1 0 0 1 0 0 0
#> SRR1740049 3 0 1 0 0 1 0 0 0
#> SRR1740050 5 0 1 0 0 0 0 1 0
#> SRR1740051 5 0 1 0 0 0 0 1 0
#> SRR1740052 5 0 1 0 0 0 0 1 0
#> SRR1740054 1 0 1 1 0 0 0 0 0
#> SRR1740053 5 0 1 0 0 0 0 1 0
#> SRR1740056 1 0 1 1 0 0 0 0 0
#> SRR1740055 1 0 1 1 0 0 0 0 0
#> SRR1740057 1 0 1 1 0 0 0 0 0
#> SRR1740058 6 0 1 0 0 0 0 0 1
#> SRR1740059 6 0 1 0 0 0 0 0 1
#> SRR1740060 6 0 1 0 0 0 0 0 1
#> SRR1740061 6 0 1 0 0 0 0 0 1
#> SRR1740062 4 0 1 0 0 0 1 0 0
#> SRR1740063 4 0 1 0 0 0 1 0 0
#> SRR1740064 4 0 1 0 0 0 1 0 0
#> SRR1740065 4 0 1 0 0 0 1 0 0
#> SRR1740066 2 0 1 0 1 0 0 0 0
#> SRR1740067 2 0 1 0 1 0 0 0 0
#> SRR1740068 2 0 1 0 1 0 0 0 0
#> SRR1740069 2 0 1 0 1 0 0 0 0
#> SRR1740070 2 0 1 0 1 0 0 0 0
#> SRR1740071 2 0 1 0 1 0 0 0 0
#> SRR1740072 2 0 1 0 1 0 0 0 0
#> SRR1740073 2 0 1 0 1 0 0 0 0
#> SRR1740074 3 0 1 0 0 1 0 0 0
#> SRR1740075 3 0 1 0 0 1 0 0 0
#> SRR1740076 3 0 1 0 0 1 0 0 0
#> SRR1740077 3 0 1 0 0 1 0 0 0
#> SRR1740078 5 0 1 0 0 0 0 1 0
#> SRR1740079 5 0 1 0 0 0 0 1 0
#> SRR1740080 5 0 1 0 0 0 0 1 0
#> SRR1740081 5 0 1 0 0 0 0 1 0
#> SRR1740082 1 0 1 1 0 0 0 0 0
#> SRR1740083 1 0 1 1 0 0 0 0 0
#> SRR1740084 1 0 1 1 0 0 0 0 0
#> SRR1740085 1 0 1 1 0 0 0 0 0
#> SRR1740086 6 0 1 0 0 0 0 0 1
#> SRR1740087 6 0 1 0 0 0 0 0 1
#> SRR1740088 6 0 1 0 0 0 0 0 1
#> SRR1740089 6 0 1 0 0 0 0 0 1
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.751 0.936 0.959 0.4787 0.501 0.501
#> 3 3 0.834 0.924 0.949 0.3275 0.668 0.431
#> 4 4 1.000 1.000 1.000 0.1123 0.958 0.876
#> 5 5 1.000 1.000 1.000 0.1175 0.917 0.717
#> 6 6 1.000 1.000 1.000 0.0526 0.958 0.802
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] 4 5
There is also optional best \(k\) = 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
#> SRR1740034 1 0.0938 0.907 0.988 0.012
#> SRR1740035 1 0.0938 0.907 0.988 0.012
#> SRR1740036 1 0.0938 0.907 0.988 0.012
#> SRR1740037 1 0.0938 0.907 0.988 0.012
#> SRR1740038 2 0.0000 0.990 0.000 1.000
#> SRR1740039 2 0.0000 0.990 0.000 1.000
#> SRR1740040 2 0.0000 0.990 0.000 1.000
#> SRR1740041 2 0.0000 0.990 0.000 1.000
#> SRR1740042 2 0.0000 0.990 0.000 1.000
#> SRR1740043 2 0.0000 0.990 0.000 1.000
#> SRR1740044 2 0.0000 0.990 0.000 1.000
#> SRR1740045 2 0.0000 0.990 0.000 1.000
#> SRR1740046 1 0.0000 0.907 1.000 0.000
#> SRR1740048 1 0.0000 0.907 1.000 0.000
#> SRR1740047 1 0.0000 0.907 1.000 0.000
#> SRR1740049 1 0.0000 0.907 1.000 0.000
#> SRR1740050 2 0.1633 0.984 0.024 0.976
#> SRR1740051 2 0.1633 0.984 0.024 0.976
#> SRR1740052 2 0.1633 0.984 0.024 0.976
#> SRR1740054 2 0.0938 0.989 0.012 0.988
#> SRR1740053 2 0.1633 0.984 0.024 0.976
#> SRR1740056 2 0.0938 0.989 0.012 0.988
#> SRR1740055 2 0.0938 0.989 0.012 0.988
#> SRR1740057 2 0.0938 0.989 0.012 0.988
#> SRR1740058 1 0.7883 0.781 0.764 0.236
#> SRR1740059 1 0.7883 0.781 0.764 0.236
#> SRR1740060 1 0.7883 0.781 0.764 0.236
#> SRR1740061 1 0.7883 0.781 0.764 0.236
#> SRR1740062 1 0.0938 0.907 0.988 0.012
#> SRR1740063 1 0.0938 0.907 0.988 0.012
#> SRR1740064 1 0.0938 0.907 0.988 0.012
#> SRR1740065 1 0.0938 0.907 0.988 0.012
#> SRR1740066 2 0.0000 0.990 0.000 1.000
#> SRR1740067 2 0.0000 0.990 0.000 1.000
#> SRR1740068 2 0.0000 0.990 0.000 1.000
#> SRR1740069 2 0.0000 0.990 0.000 1.000
#> SRR1740070 2 0.0000 0.990 0.000 1.000
#> SRR1740071 2 0.0000 0.990 0.000 1.000
#> SRR1740072 2 0.0000 0.990 0.000 1.000
#> SRR1740073 2 0.0000 0.990 0.000 1.000
#> SRR1740074 1 0.0000 0.907 1.000 0.000
#> SRR1740075 1 0.0000 0.907 1.000 0.000
#> SRR1740076 1 0.0000 0.907 1.000 0.000
#> SRR1740077 1 0.0000 0.907 1.000 0.000
#> SRR1740078 2 0.1633 0.984 0.024 0.976
#> SRR1740079 2 0.1633 0.984 0.024 0.976
#> SRR1740080 2 0.1633 0.984 0.024 0.976
#> SRR1740081 2 0.1633 0.984 0.024 0.976
#> SRR1740082 2 0.0938 0.989 0.012 0.988
#> SRR1740083 2 0.0938 0.989 0.012 0.988
#> SRR1740084 2 0.0938 0.989 0.012 0.988
#> SRR1740085 2 0.0938 0.989 0.012 0.988
#> SRR1740086 1 0.7883 0.781 0.764 0.236
#> SRR1740087 1 0.7883 0.781 0.764 0.236
#> SRR1740088 1 0.7883 0.781 0.764 0.236
#> SRR1740089 1 0.7883 0.781 0.764 0.236
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 3 0.595 0.700 0.36 0 0.64
#> SRR1740035 3 0.595 0.700 0.36 0 0.64
#> SRR1740036 3 0.595 0.700 0.36 0 0.64
#> SRR1740037 3 0.595 0.700 0.36 0 0.64
#> SRR1740038 2 0.000 1.000 0.00 1 0.00
#> SRR1740039 2 0.000 1.000 0.00 1 0.00
#> SRR1740040 2 0.000 1.000 0.00 1 0.00
#> SRR1740041 2 0.000 1.000 0.00 1 0.00
#> SRR1740042 2 0.000 1.000 0.00 1 0.00
#> SRR1740043 2 0.000 1.000 0.00 1 0.00
#> SRR1740044 2 0.000 1.000 0.00 1 0.00
#> SRR1740045 2 0.000 1.000 0.00 1 0.00
#> SRR1740046 3 0.000 0.767 0.00 0 1.00
#> SRR1740048 3 0.000 0.767 0.00 0 1.00
#> SRR1740047 3 0.000 0.767 0.00 0 1.00
#> SRR1740049 3 0.000 0.767 0.00 0 1.00
#> SRR1740050 1 0.000 1.000 1.00 0 0.00
#> SRR1740051 1 0.000 1.000 1.00 0 0.00
#> SRR1740052 1 0.000 1.000 1.00 0 0.00
#> SRR1740054 1 0.000 1.000 1.00 0 0.00
#> SRR1740053 1 0.000 1.000 1.00 0 0.00
#> SRR1740056 1 0.000 1.000 1.00 0 0.00
#> SRR1740055 1 0.000 1.000 1.00 0 0.00
#> SRR1740057 1 0.000 1.000 1.00 0 0.00
#> SRR1740058 1 0.000 1.000 1.00 0 0.00
#> SRR1740059 1 0.000 1.000 1.00 0 0.00
#> SRR1740060 1 0.000 1.000 1.00 0 0.00
#> SRR1740061 1 0.000 1.000 1.00 0 0.00
#> SRR1740062 3 0.595 0.700 0.36 0 0.64
#> SRR1740063 3 0.595 0.700 0.36 0 0.64
#> SRR1740064 3 0.595 0.700 0.36 0 0.64
#> SRR1740065 3 0.595 0.700 0.36 0 0.64
#> SRR1740066 2 0.000 1.000 0.00 1 0.00
#> SRR1740067 2 0.000 1.000 0.00 1 0.00
#> SRR1740068 2 0.000 1.000 0.00 1 0.00
#> SRR1740069 2 0.000 1.000 0.00 1 0.00
#> SRR1740070 2 0.000 1.000 0.00 1 0.00
#> SRR1740071 2 0.000 1.000 0.00 1 0.00
#> SRR1740072 2 0.000 1.000 0.00 1 0.00
#> SRR1740073 2 0.000 1.000 0.00 1 0.00
#> SRR1740074 3 0.000 0.767 0.00 0 1.00
#> SRR1740075 3 0.000 0.767 0.00 0 1.00
#> SRR1740076 3 0.000 0.767 0.00 0 1.00
#> SRR1740077 3 0.000 0.767 0.00 0 1.00
#> SRR1740078 1 0.000 1.000 1.00 0 0.00
#> SRR1740079 1 0.000 1.000 1.00 0 0.00
#> SRR1740080 1 0.000 1.000 1.00 0 0.00
#> SRR1740081 1 0.000 1.000 1.00 0 0.00
#> SRR1740082 1 0.000 1.000 1.00 0 0.00
#> SRR1740083 1 0.000 1.000 1.00 0 0.00
#> SRR1740084 1 0.000 1.000 1.00 0 0.00
#> SRR1740085 1 0.000 1.000 1.00 0 0.00
#> SRR1740086 1 0.000 1.000 1.00 0 0.00
#> SRR1740087 1 0.000 1.000 1.00 0 0.00
#> SRR1740088 1 0.000 1.000 1.00 0 0.00
#> SRR1740089 1 0.000 1.000 1.00 0 0.00
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 4 0 1 0 0 0 1
#> SRR1740035 4 0 1 0 0 0 1
#> SRR1740036 4 0 1 0 0 0 1
#> SRR1740037 4 0 1 0 0 0 1
#> SRR1740038 2 0 1 0 1 0 0
#> SRR1740039 2 0 1 0 1 0 0
#> SRR1740040 2 0 1 0 1 0 0
#> SRR1740041 2 0 1 0 1 0 0
#> SRR1740042 2 0 1 0 1 0 0
#> SRR1740043 2 0 1 0 1 0 0
#> SRR1740044 2 0 1 0 1 0 0
#> SRR1740045 2 0 1 0 1 0 0
#> SRR1740046 3 0 1 0 0 1 0
#> SRR1740048 3 0 1 0 0 1 0
#> SRR1740047 3 0 1 0 0 1 0
#> SRR1740049 3 0 1 0 0 1 0
#> SRR1740050 1 0 1 1 0 0 0
#> SRR1740051 1 0 1 1 0 0 0
#> SRR1740052 1 0 1 1 0 0 0
#> SRR1740054 1 0 1 1 0 0 0
#> SRR1740053 1 0 1 1 0 0 0
#> SRR1740056 1 0 1 1 0 0 0
#> SRR1740055 1 0 1 1 0 0 0
#> SRR1740057 1 0 1 1 0 0 0
#> SRR1740058 1 0 1 1 0 0 0
#> SRR1740059 1 0 1 1 0 0 0
#> SRR1740060 1 0 1 1 0 0 0
#> SRR1740061 1 0 1 1 0 0 0
#> SRR1740062 4 0 1 0 0 0 1
#> SRR1740063 4 0 1 0 0 0 1
#> SRR1740064 4 0 1 0 0 0 1
#> SRR1740065 4 0 1 0 0 0 1
#> SRR1740066 2 0 1 0 1 0 0
#> SRR1740067 2 0 1 0 1 0 0
#> SRR1740068 2 0 1 0 1 0 0
#> SRR1740069 2 0 1 0 1 0 0
#> SRR1740070 2 0 1 0 1 0 0
#> SRR1740071 2 0 1 0 1 0 0
#> SRR1740072 2 0 1 0 1 0 0
#> SRR1740073 2 0 1 0 1 0 0
#> SRR1740074 3 0 1 0 0 1 0
#> SRR1740075 3 0 1 0 0 1 0
#> SRR1740076 3 0 1 0 0 1 0
#> SRR1740077 3 0 1 0 0 1 0
#> SRR1740078 1 0 1 1 0 0 0
#> SRR1740079 1 0 1 1 0 0 0
#> SRR1740080 1 0 1 1 0 0 0
#> SRR1740081 1 0 1 1 0 0 0
#> SRR1740082 1 0 1 1 0 0 0
#> SRR1740083 1 0 1 1 0 0 0
#> SRR1740084 1 0 1 1 0 0 0
#> SRR1740085 1 0 1 1 0 0 0
#> SRR1740086 1 0 1 1 0 0 0
#> SRR1740087 1 0 1 1 0 0 0
#> SRR1740088 1 0 1 1 0 0 0
#> SRR1740089 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
#> SRR1740034 4 0 1 0 0 0 1 0
#> SRR1740035 4 0 1 0 0 0 1 0
#> SRR1740036 4 0 1 0 0 0 1 0
#> SRR1740037 4 0 1 0 0 0 1 0
#> SRR1740038 2 0 1 0 1 0 0 0
#> SRR1740039 2 0 1 0 1 0 0 0
#> SRR1740040 2 0 1 0 1 0 0 0
#> SRR1740041 2 0 1 0 1 0 0 0
#> SRR1740042 2 0 1 0 1 0 0 0
#> SRR1740043 2 0 1 0 1 0 0 0
#> SRR1740044 2 0 1 0 1 0 0 0
#> SRR1740045 2 0 1 0 1 0 0 0
#> SRR1740046 3 0 1 0 0 1 0 0
#> SRR1740048 3 0 1 0 0 1 0 0
#> SRR1740047 3 0 1 0 0 1 0 0
#> SRR1740049 3 0 1 0 0 1 0 0
#> SRR1740050 5 0 1 0 0 0 0 1
#> SRR1740051 5 0 1 0 0 0 0 1
#> SRR1740052 5 0 1 0 0 0 0 1
#> SRR1740054 1 0 1 1 0 0 0 0
#> SRR1740053 5 0 1 0 0 0 0 1
#> SRR1740056 1 0 1 1 0 0 0 0
#> SRR1740055 1 0 1 1 0 0 0 0
#> SRR1740057 1 0 1 1 0 0 0 0
#> SRR1740058 5 0 1 0 0 0 0 1
#> SRR1740059 5 0 1 0 0 0 0 1
#> SRR1740060 5 0 1 0 0 0 0 1
#> SRR1740061 5 0 1 0 0 0 0 1
#> SRR1740062 4 0 1 0 0 0 1 0
#> SRR1740063 4 0 1 0 0 0 1 0
#> SRR1740064 4 0 1 0 0 0 1 0
#> SRR1740065 4 0 1 0 0 0 1 0
#> SRR1740066 2 0 1 0 1 0 0 0
#> SRR1740067 2 0 1 0 1 0 0 0
#> SRR1740068 2 0 1 0 1 0 0 0
#> SRR1740069 2 0 1 0 1 0 0 0
#> SRR1740070 2 0 1 0 1 0 0 0
#> SRR1740071 2 0 1 0 1 0 0 0
#> SRR1740072 2 0 1 0 1 0 0 0
#> SRR1740073 2 0 1 0 1 0 0 0
#> SRR1740074 3 0 1 0 0 1 0 0
#> SRR1740075 3 0 1 0 0 1 0 0
#> SRR1740076 3 0 1 0 0 1 0 0
#> SRR1740077 3 0 1 0 0 1 0 0
#> SRR1740078 5 0 1 0 0 0 0 1
#> SRR1740079 5 0 1 0 0 0 0 1
#> SRR1740080 5 0 1 0 0 0 0 1
#> SRR1740081 5 0 1 0 0 0 0 1
#> SRR1740082 1 0 1 1 0 0 0 0
#> SRR1740083 1 0 1 1 0 0 0 0
#> SRR1740084 1 0 1 1 0 0 0 0
#> SRR1740085 1 0 1 1 0 0 0 0
#> SRR1740086 5 0 1 0 0 0 0 1
#> SRR1740087 5 0 1 0 0 0 0 1
#> SRR1740088 5 0 1 0 0 0 0 1
#> SRR1740089 5 0 1 0 0 0 0 1
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0 1 0 0 0 1 0 0
#> SRR1740035 4 0 1 0 0 0 1 0 0
#> SRR1740036 4 0 1 0 0 0 1 0 0
#> SRR1740037 4 0 1 0 0 0 1 0 0
#> SRR1740038 2 0 1 0 1 0 0 0 0
#> SRR1740039 2 0 1 0 1 0 0 0 0
#> SRR1740040 2 0 1 0 1 0 0 0 0
#> SRR1740041 2 0 1 0 1 0 0 0 0
#> SRR1740042 2 0 1 0 1 0 0 0 0
#> SRR1740043 2 0 1 0 1 0 0 0 0
#> SRR1740044 2 0 1 0 1 0 0 0 0
#> SRR1740045 2 0 1 0 1 0 0 0 0
#> SRR1740046 3 0 1 0 0 1 0 0 0
#> SRR1740048 3 0 1 0 0 1 0 0 0
#> SRR1740047 3 0 1 0 0 1 0 0 0
#> SRR1740049 3 0 1 0 0 1 0 0 0
#> SRR1740050 5 0 1 0 0 0 0 1 0
#> SRR1740051 5 0 1 0 0 0 0 1 0
#> SRR1740052 5 0 1 0 0 0 0 1 0
#> SRR1740054 1 0 1 1 0 0 0 0 0
#> SRR1740053 5 0 1 0 0 0 0 1 0
#> SRR1740056 1 0 1 1 0 0 0 0 0
#> SRR1740055 1 0 1 1 0 0 0 0 0
#> SRR1740057 1 0 1 1 0 0 0 0 0
#> SRR1740058 6 0 1 0 0 0 0 0 1
#> SRR1740059 6 0 1 0 0 0 0 0 1
#> SRR1740060 6 0 1 0 0 0 0 0 1
#> SRR1740061 6 0 1 0 0 0 0 0 1
#> SRR1740062 4 0 1 0 0 0 1 0 0
#> SRR1740063 4 0 1 0 0 0 1 0 0
#> SRR1740064 4 0 1 0 0 0 1 0 0
#> SRR1740065 4 0 1 0 0 0 1 0 0
#> SRR1740066 2 0 1 0 1 0 0 0 0
#> SRR1740067 2 0 1 0 1 0 0 0 0
#> SRR1740068 2 0 1 0 1 0 0 0 0
#> SRR1740069 2 0 1 0 1 0 0 0 0
#> SRR1740070 2 0 1 0 1 0 0 0 0
#> SRR1740071 2 0 1 0 1 0 0 0 0
#> SRR1740072 2 0 1 0 1 0 0 0 0
#> SRR1740073 2 0 1 0 1 0 0 0 0
#> SRR1740074 3 0 1 0 0 1 0 0 0
#> SRR1740075 3 0 1 0 0 1 0 0 0
#> SRR1740076 3 0 1 0 0 1 0 0 0
#> SRR1740077 3 0 1 0 0 1 0 0 0
#> SRR1740078 5 0 1 0 0 0 0 1 0
#> SRR1740079 5 0 1 0 0 0 0 1 0
#> SRR1740080 5 0 1 0 0 0 0 1 0
#> SRR1740081 5 0 1 0 0 0 0 1 0
#> SRR1740082 1 0 1 1 0 0 0 0 0
#> SRR1740083 1 0 1 1 0 0 0 0 0
#> SRR1740084 1 0 1 1 0 0 0 0 0
#> SRR1740085 1 0 1 1 0 0 0 0 0
#> SRR1740086 6 0 1 0 0 0 0 0 1
#> SRR1740087 6 0 1 0 0 0 0 0 1
#> SRR1740088 6 0 1 0 0 0 0 0 1
#> SRR1740089 6 0 1 0 0 0 0 0 1
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.537 0.707 0.888 0.3861 0.584 0.584
#> 3 3 0.795 0.921 0.942 0.5453 0.731 0.573
#> 4 4 0.975 0.947 0.978 0.1903 0.881 0.707
#> 5 5 0.978 0.937 0.953 0.1073 0.922 0.730
#> 6 6 0.951 0.856 0.921 0.0588 0.953 0.778
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] 4 5
There is also optional best \(k\) = 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
#> SRR1740034 1 0.0000 0.886 1.000 0.000
#> SRR1740035 1 0.0000 0.886 1.000 0.000
#> SRR1740036 1 0.0000 0.886 1.000 0.000
#> SRR1740037 1 0.0000 0.886 1.000 0.000
#> SRR1740038 1 0.9710 0.147 0.600 0.400
#> SRR1740039 1 0.9661 0.176 0.608 0.392
#> SRR1740040 1 0.9710 0.147 0.600 0.400
#> SRR1740041 1 0.9635 0.189 0.612 0.388
#> SRR1740042 2 0.9933 0.395 0.452 0.548
#> SRR1740043 2 0.9909 0.416 0.444 0.556
#> SRR1740044 2 0.9881 0.434 0.436 0.564
#> SRR1740045 2 0.9933 0.395 0.452 0.548
#> SRR1740046 2 0.0000 0.745 0.000 1.000
#> SRR1740048 2 0.0000 0.745 0.000 1.000
#> SRR1740047 2 0.0000 0.745 0.000 1.000
#> SRR1740049 2 0.0000 0.745 0.000 1.000
#> SRR1740050 1 0.0000 0.886 1.000 0.000
#> SRR1740051 1 0.0000 0.886 1.000 0.000
#> SRR1740052 1 0.0000 0.886 1.000 0.000
#> SRR1740054 1 0.0000 0.886 1.000 0.000
#> SRR1740053 1 0.0000 0.886 1.000 0.000
#> SRR1740056 1 0.0000 0.886 1.000 0.000
#> SRR1740055 1 0.0672 0.879 0.992 0.008
#> SRR1740057 1 0.0000 0.886 1.000 0.000
#> SRR1740058 1 0.0000 0.886 1.000 0.000
#> SRR1740059 1 0.0000 0.886 1.000 0.000
#> SRR1740060 1 0.0000 0.886 1.000 0.000
#> SRR1740061 1 0.0000 0.886 1.000 0.000
#> SRR1740062 1 0.0000 0.886 1.000 0.000
#> SRR1740063 1 0.0000 0.886 1.000 0.000
#> SRR1740064 1 0.0000 0.886 1.000 0.000
#> SRR1740065 1 0.0000 0.886 1.000 0.000
#> SRR1740066 1 0.9710 0.147 0.600 0.400
#> SRR1740067 1 0.9710 0.147 0.600 0.400
#> SRR1740068 1 0.9635 0.189 0.612 0.388
#> SRR1740069 1 0.9608 0.201 0.616 0.384
#> SRR1740070 2 0.8386 0.646 0.268 0.732
#> SRR1740071 2 0.8813 0.624 0.300 0.700
#> SRR1740072 2 0.9427 0.562 0.360 0.640
#> SRR1740073 2 0.9661 0.516 0.392 0.608
#> SRR1740074 2 0.0000 0.745 0.000 1.000
#> SRR1740075 2 0.0000 0.745 0.000 1.000
#> SRR1740076 2 0.0000 0.745 0.000 1.000
#> SRR1740077 2 0.0000 0.745 0.000 1.000
#> SRR1740078 1 0.0000 0.886 1.000 0.000
#> SRR1740079 1 0.0000 0.886 1.000 0.000
#> SRR1740080 1 0.0000 0.886 1.000 0.000
#> SRR1740081 1 0.0000 0.886 1.000 0.000
#> SRR1740082 1 0.0376 0.882 0.996 0.004
#> SRR1740083 1 0.0376 0.882 0.996 0.004
#> SRR1740084 1 0.0000 0.886 1.000 0.000
#> SRR1740085 1 0.0000 0.886 1.000 0.000
#> SRR1740086 1 0.0000 0.886 1.000 0.000
#> SRR1740087 1 0.0000 0.886 1.000 0.000
#> SRR1740088 1 0.0000 0.886 1.000 0.000
#> SRR1740089 1 0.0000 0.886 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0.5500 0.8542 0.816 0.084 0.100
#> SRR1740035 1 0.5500 0.8542 0.816 0.084 0.100
#> SRR1740036 1 0.5500 0.8542 0.816 0.084 0.100
#> SRR1740037 1 0.5500 0.8542 0.816 0.084 0.100
#> SRR1740038 2 0.0000 0.9431 0.000 1.000 0.000
#> SRR1740039 2 0.0000 0.9431 0.000 1.000 0.000
#> SRR1740040 2 0.0000 0.9431 0.000 1.000 0.000
#> SRR1740041 2 0.0424 0.9358 0.000 0.992 0.008
#> SRR1740042 2 0.0747 0.9439 0.000 0.984 0.016
#> SRR1740043 2 0.0747 0.9439 0.000 0.984 0.016
#> SRR1740044 2 0.0747 0.9439 0.000 0.984 0.016
#> SRR1740045 2 0.0747 0.9439 0.000 0.984 0.016
#> SRR1740046 3 0.2959 1.0000 0.000 0.100 0.900
#> SRR1740048 3 0.2959 1.0000 0.000 0.100 0.900
#> SRR1740047 3 0.2959 1.0000 0.000 0.100 0.900
#> SRR1740049 3 0.2959 1.0000 0.000 0.100 0.900
#> SRR1740050 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740051 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740052 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740054 1 0.2165 0.9053 0.936 0.064 0.000
#> SRR1740053 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740056 1 0.0424 0.9415 0.992 0.008 0.000
#> SRR1740055 2 0.6309 0.0208 0.496 0.504 0.000
#> SRR1740057 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740058 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740059 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740060 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740061 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740062 1 0.5500 0.8542 0.816 0.084 0.100
#> SRR1740063 1 0.5500 0.8542 0.816 0.084 0.100
#> SRR1740064 1 0.5500 0.8542 0.816 0.084 0.100
#> SRR1740065 1 0.5500 0.8542 0.816 0.084 0.100
#> SRR1740066 2 0.0000 0.9431 0.000 1.000 0.000
#> SRR1740067 2 0.0000 0.9431 0.000 1.000 0.000
#> SRR1740068 2 0.0237 0.9441 0.000 0.996 0.004
#> SRR1740069 2 0.0237 0.9441 0.000 0.996 0.004
#> SRR1740070 2 0.0747 0.9439 0.000 0.984 0.016
#> SRR1740071 2 0.0747 0.9439 0.000 0.984 0.016
#> SRR1740072 2 0.0747 0.9439 0.000 0.984 0.016
#> SRR1740073 2 0.0747 0.9439 0.000 0.984 0.016
#> SRR1740074 3 0.2959 1.0000 0.000 0.100 0.900
#> SRR1740075 3 0.2959 1.0000 0.000 0.100 0.900
#> SRR1740076 3 0.2959 1.0000 0.000 0.100 0.900
#> SRR1740077 3 0.2959 1.0000 0.000 0.100 0.900
#> SRR1740078 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740079 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740080 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740081 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740082 1 0.1643 0.9252 0.956 0.044 0.000
#> SRR1740083 1 0.1753 0.9218 0.952 0.048 0.000
#> SRR1740084 1 0.1289 0.9287 0.968 0.032 0.000
#> SRR1740085 1 0.0747 0.9377 0.984 0.016 0.000
#> SRR1740086 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740087 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740088 1 0.0000 0.9447 1.000 0.000 0.000
#> SRR1740089 1 0.0000 0.9447 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 4 0.0000 1.0000 0.000 0.000 0.000 1
#> SRR1740035 4 0.0000 1.0000 0.000 0.000 0.000 1
#> SRR1740036 4 0.0000 1.0000 0.000 0.000 0.000 1
#> SRR1740037 4 0.0000 1.0000 0.000 0.000 0.000 1
#> SRR1740038 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740039 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740040 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740041 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740042 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740043 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740044 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740045 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740046 3 0.0188 1.0000 0.000 0.004 0.996 0
#> SRR1740048 3 0.0188 1.0000 0.000 0.004 0.996 0
#> SRR1740047 3 0.0188 1.0000 0.000 0.004 0.996 0
#> SRR1740049 3 0.0188 1.0000 0.000 0.004 0.996 0
#> SRR1740050 1 0.0188 0.9646 0.996 0.000 0.004 0
#> SRR1740051 1 0.0188 0.9646 0.996 0.000 0.004 0
#> SRR1740052 1 0.0188 0.9646 0.996 0.000 0.004 0
#> SRR1740054 1 0.2868 0.8558 0.864 0.136 0.000 0
#> SRR1740053 1 0.0188 0.9646 0.996 0.000 0.004 0
#> SRR1740056 1 0.0707 0.9551 0.980 0.020 0.000 0
#> SRR1740055 2 0.5151 0.0337 0.464 0.532 0.004 0
#> SRR1740057 1 0.0592 0.9574 0.984 0.016 0.000 0
#> SRR1740058 1 0.0000 0.9647 1.000 0.000 0.000 0
#> SRR1740059 1 0.0000 0.9647 1.000 0.000 0.000 0
#> SRR1740060 1 0.0000 0.9647 1.000 0.000 0.000 0
#> SRR1740061 1 0.0000 0.9647 1.000 0.000 0.000 0
#> SRR1740062 4 0.0000 1.0000 0.000 0.000 0.000 1
#> SRR1740063 4 0.0000 1.0000 0.000 0.000 0.000 1
#> SRR1740064 4 0.0000 1.0000 0.000 0.000 0.000 1
#> SRR1740065 4 0.0000 1.0000 0.000 0.000 0.000 1
#> SRR1740066 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740067 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740068 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740069 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740070 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740071 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740072 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740073 2 0.0000 0.9625 0.000 1.000 0.000 0
#> SRR1740074 3 0.0188 1.0000 0.000 0.004 0.996 0
#> SRR1740075 3 0.0188 1.0000 0.000 0.004 0.996 0
#> SRR1740076 3 0.0188 1.0000 0.000 0.004 0.996 0
#> SRR1740077 3 0.0188 1.0000 0.000 0.004 0.996 0
#> SRR1740078 1 0.0188 0.9646 0.996 0.000 0.004 0
#> SRR1740079 1 0.0188 0.9646 0.996 0.000 0.004 0
#> SRR1740080 1 0.0188 0.9646 0.996 0.000 0.004 0
#> SRR1740081 1 0.0188 0.9646 0.996 0.000 0.004 0
#> SRR1740082 1 0.3219 0.8234 0.836 0.164 0.000 0
#> SRR1740083 1 0.3764 0.7503 0.784 0.216 0.000 0
#> SRR1740084 1 0.2149 0.9014 0.912 0.088 0.000 0
#> SRR1740085 1 0.1022 0.9470 0.968 0.032 0.000 0
#> SRR1740086 1 0.0000 0.9647 1.000 0.000 0.000 0
#> SRR1740087 1 0.0000 0.9647 1.000 0.000 0.000 0
#> SRR1740088 1 0.0000 0.9647 1.000 0.000 0.000 0
#> SRR1740089 1 0.0000 0.9647 1.000 0.000 0.000 0
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740035 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740036 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740037 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740038 2 0.0290 0.9478 0.000 0.992 0 0 0.008
#> SRR1740039 2 0.0290 0.9478 0.000 0.992 0 0 0.008
#> SRR1740040 2 0.0290 0.9478 0.000 0.992 0 0 0.008
#> SRR1740041 2 0.0290 0.9478 0.000 0.992 0 0 0.008
#> SRR1740042 2 0.2017 0.9513 0.080 0.912 0 0 0.008
#> SRR1740043 2 0.2017 0.9513 0.080 0.912 0 0 0.008
#> SRR1740044 2 0.2017 0.9513 0.080 0.912 0 0 0.008
#> SRR1740045 2 0.2017 0.9513 0.080 0.912 0 0 0.008
#> SRR1740046 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740048 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740047 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740049 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740050 5 0.0510 1.0000 0.016 0.000 0 0 0.984
#> SRR1740051 5 0.0510 1.0000 0.016 0.000 0 0 0.984
#> SRR1740052 5 0.0510 1.0000 0.016 0.000 0 0 0.984
#> SRR1740054 1 0.4818 0.0448 0.520 0.460 0 0 0.020
#> SRR1740053 5 0.0510 1.0000 0.016 0.000 0 0 0.984
#> SRR1740056 1 0.3413 0.8124 0.832 0.124 0 0 0.044
#> SRR1740055 2 0.2561 0.8952 0.144 0.856 0 0 0.000
#> SRR1740057 1 0.3242 0.8659 0.852 0.076 0 0 0.072
#> SRR1740058 1 0.1732 0.8977 0.920 0.000 0 0 0.080
#> SRR1740059 1 0.1732 0.8977 0.920 0.000 0 0 0.080
#> SRR1740060 1 0.1732 0.8977 0.920 0.000 0 0 0.080
#> SRR1740061 1 0.1732 0.8977 0.920 0.000 0 0 0.080
#> SRR1740062 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740063 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740064 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740065 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740066 2 0.0290 0.9478 0.000 0.992 0 0 0.008
#> SRR1740067 2 0.0290 0.9478 0.000 0.992 0 0 0.008
#> SRR1740068 2 0.0290 0.9478 0.000 0.992 0 0 0.008
#> SRR1740069 2 0.0290 0.9478 0.000 0.992 0 0 0.008
#> SRR1740070 2 0.2017 0.9513 0.080 0.912 0 0 0.008
#> SRR1740071 2 0.2017 0.9513 0.080 0.912 0 0 0.008
#> SRR1740072 2 0.2017 0.9513 0.080 0.912 0 0 0.008
#> SRR1740073 2 0.2017 0.9513 0.080 0.912 0 0 0.008
#> SRR1740074 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740075 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740076 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740077 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740078 5 0.0510 1.0000 0.016 0.000 0 0 0.984
#> SRR1740079 5 0.0510 1.0000 0.016 0.000 0 0 0.984
#> SRR1740080 5 0.0510 1.0000 0.016 0.000 0 0 0.984
#> SRR1740081 5 0.0510 1.0000 0.016 0.000 0 0 0.984
#> SRR1740082 1 0.1197 0.8563 0.952 0.048 0 0 0.000
#> SRR1740083 1 0.0703 0.8695 0.976 0.024 0 0 0.000
#> SRR1740084 1 0.0510 0.8720 0.984 0.016 0 0 0.000
#> SRR1740085 1 0.0693 0.8780 0.980 0.012 0 0 0.008
#> SRR1740086 1 0.1732 0.8977 0.920 0.000 0 0 0.080
#> SRR1740087 1 0.1732 0.8977 0.920 0.000 0 0 0.080
#> SRR1740088 1 0.1732 0.8977 0.920 0.000 0 0 0.080
#> SRR1740089 1 0.1732 0.8977 0.920 0.000 0 0 0.080
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740035 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740036 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740037 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740038 2 0.0363 1.000 0.000 0.988 0 0 0 0.012
#> SRR1740039 2 0.0363 1.000 0.000 0.988 0 0 0 0.012
#> SRR1740040 2 0.0363 1.000 0.000 0.988 0 0 0 0.012
#> SRR1740041 2 0.0363 1.000 0.000 0.988 0 0 0 0.012
#> SRR1740042 1 0.4941 0.995 0.492 0.064 0 0 0 0.444
#> SRR1740043 1 0.4941 0.995 0.492 0.064 0 0 0 0.444
#> SRR1740044 1 0.4941 0.995 0.492 0.064 0 0 0 0.444
#> SRR1740045 1 0.4941 0.995 0.492 0.064 0 0 0 0.444
#> SRR1740046 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740048 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740047 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740049 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740050 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740051 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740052 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740054 6 0.4565 -0.875 0.432 0.036 0 0 0 0.532
#> SRR1740053 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740056 6 0.1753 0.226 0.084 0.004 0 0 0 0.912
#> SRR1740055 1 0.4650 0.958 0.488 0.040 0 0 0 0.472
#> SRR1740057 6 0.0713 0.426 0.028 0.000 0 0 0 0.972
#> SRR1740058 6 0.3854 0.703 0.464 0.000 0 0 0 0.536
#> SRR1740059 6 0.3854 0.703 0.464 0.000 0 0 0 0.536
#> SRR1740060 6 0.3854 0.703 0.464 0.000 0 0 0 0.536
#> SRR1740061 6 0.3854 0.703 0.464 0.000 0 0 0 0.536
#> SRR1740062 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740063 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740064 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740065 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740066 2 0.0363 1.000 0.000 0.988 0 0 0 0.012
#> SRR1740067 2 0.0363 1.000 0.000 0.988 0 0 0 0.012
#> SRR1740068 2 0.0363 1.000 0.000 0.988 0 0 0 0.012
#> SRR1740069 2 0.0363 1.000 0.000 0.988 0 0 0 0.012
#> SRR1740070 1 0.4941 0.995 0.492 0.064 0 0 0 0.444
#> SRR1740071 1 0.4941 0.995 0.492 0.064 0 0 0 0.444
#> SRR1740072 1 0.4941 0.995 0.492 0.064 0 0 0 0.444
#> SRR1740073 1 0.4941 0.995 0.492 0.064 0 0 0 0.444
#> SRR1740074 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740075 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740076 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740077 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740078 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740079 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740080 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740081 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740082 6 0.1196 0.379 0.040 0.008 0 0 0 0.952
#> SRR1740083 6 0.0790 0.460 0.032 0.000 0 0 0 0.968
#> SRR1740084 6 0.1007 0.340 0.044 0.000 0 0 0 0.956
#> SRR1740085 6 0.0547 0.447 0.020 0.000 0 0 0 0.980
#> SRR1740086 6 0.3854 0.703 0.464 0.000 0 0 0 0.536
#> SRR1740087 6 0.3854 0.703 0.464 0.000 0 0 0 0.536
#> SRR1740088 6 0.3854 0.703 0.464 0.000 0 0 0 0.536
#> SRR1740089 6 0.3854 0.703 0.464 0.000 0 0 0 0.536
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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.501 0.959 0.931 0.4595 0.501 0.501
#> 3 3 1.000 0.999 0.998 0.3568 0.875 0.751
#> 4 4 1.000 0.997 0.995 0.1336 0.917 0.779
#> 5 5 1.000 1.000 1.000 0.1175 0.917 0.717
#> 6 6 1.000 1.000 1.000 0.0526 0.958 0.802
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 3 4 5
There is also optional best \(k\) = 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
#> SRR1740034 1 0.000 0.859 1.00 0.00
#> SRR1740035 1 0.000 0.859 1.00 0.00
#> SRR1740036 1 0.000 0.859 1.00 0.00
#> SRR1740037 1 0.000 0.859 1.00 0.00
#> SRR1740038 2 0.000 1.000 0.00 1.00
#> SRR1740039 2 0.000 1.000 0.00 1.00
#> SRR1740040 2 0.000 1.000 0.00 1.00
#> SRR1740041 2 0.000 1.000 0.00 1.00
#> SRR1740042 2 0.000 1.000 0.00 1.00
#> SRR1740043 2 0.000 1.000 0.00 1.00
#> SRR1740044 2 0.000 1.000 0.00 1.00
#> SRR1740045 2 0.000 1.000 0.00 1.00
#> SRR1740046 2 0.000 1.000 0.00 1.00
#> SRR1740048 2 0.000 1.000 0.00 1.00
#> SRR1740047 2 0.000 1.000 0.00 1.00
#> SRR1740049 2 0.000 1.000 0.00 1.00
#> SRR1740050 1 0.634 0.951 0.84 0.16
#> SRR1740051 1 0.634 0.951 0.84 0.16
#> SRR1740052 1 0.634 0.951 0.84 0.16
#> SRR1740054 1 0.634 0.951 0.84 0.16
#> SRR1740053 1 0.634 0.951 0.84 0.16
#> SRR1740056 1 0.634 0.951 0.84 0.16
#> SRR1740055 1 0.634 0.951 0.84 0.16
#> SRR1740057 1 0.634 0.951 0.84 0.16
#> SRR1740058 1 0.634 0.951 0.84 0.16
#> SRR1740059 1 0.634 0.951 0.84 0.16
#> SRR1740060 1 0.634 0.951 0.84 0.16
#> SRR1740061 1 0.634 0.951 0.84 0.16
#> SRR1740062 1 0.000 0.859 1.00 0.00
#> SRR1740063 1 0.000 0.859 1.00 0.00
#> SRR1740064 1 0.000 0.859 1.00 0.00
#> SRR1740065 1 0.000 0.859 1.00 0.00
#> SRR1740066 2 0.000 1.000 0.00 1.00
#> SRR1740067 2 0.000 1.000 0.00 1.00
#> SRR1740068 2 0.000 1.000 0.00 1.00
#> SRR1740069 2 0.000 1.000 0.00 1.00
#> SRR1740070 2 0.000 1.000 0.00 1.00
#> SRR1740071 2 0.000 1.000 0.00 1.00
#> SRR1740072 2 0.000 1.000 0.00 1.00
#> SRR1740073 2 0.000 1.000 0.00 1.00
#> SRR1740074 2 0.000 1.000 0.00 1.00
#> SRR1740075 2 0.000 1.000 0.00 1.00
#> SRR1740076 2 0.000 1.000 0.00 1.00
#> SRR1740077 2 0.000 1.000 0.00 1.00
#> SRR1740078 1 0.634 0.951 0.84 0.16
#> SRR1740079 1 0.634 0.951 0.84 0.16
#> SRR1740080 1 0.634 0.951 0.84 0.16
#> SRR1740081 1 0.634 0.951 0.84 0.16
#> SRR1740082 1 0.634 0.951 0.84 0.16
#> SRR1740083 1 0.634 0.951 0.84 0.16
#> SRR1740084 1 0.634 0.951 0.84 0.16
#> SRR1740085 1 0.634 0.951 0.84 0.16
#> SRR1740086 1 0.634 0.951 0.84 0.16
#> SRR1740087 1 0.634 0.951 0.84 0.16
#> SRR1740088 1 0.634 0.951 0.84 0.16
#> SRR1740089 1 0.634 0.951 0.84 0.16
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 3 0.0424 1.000 0.008 0.000 0.992
#> SRR1740035 3 0.0424 1.000 0.008 0.000 0.992
#> SRR1740036 3 0.0424 1.000 0.008 0.000 0.992
#> SRR1740037 3 0.0424 1.000 0.008 0.000 0.992
#> SRR1740038 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740039 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740040 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740041 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740042 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740043 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740044 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740045 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740046 2 0.0424 0.995 0.000 0.992 0.008
#> SRR1740048 2 0.0424 0.995 0.000 0.992 0.008
#> SRR1740047 2 0.0424 0.995 0.000 0.992 0.008
#> SRR1740049 2 0.0424 0.995 0.000 0.992 0.008
#> SRR1740050 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740051 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740052 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740054 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740053 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740056 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740055 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740057 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740058 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740059 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740060 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740061 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740062 3 0.0424 1.000 0.008 0.000 0.992
#> SRR1740063 3 0.0424 1.000 0.008 0.000 0.992
#> SRR1740064 3 0.0424 1.000 0.008 0.000 0.992
#> SRR1740065 3 0.0424 1.000 0.008 0.000 0.992
#> SRR1740066 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740067 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740068 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740069 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740070 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740071 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740072 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740073 2 0.0000 0.998 0.000 1.000 0.000
#> SRR1740074 2 0.0424 0.995 0.000 0.992 0.008
#> SRR1740075 2 0.0424 0.995 0.000 0.992 0.008
#> SRR1740076 2 0.0424 0.995 0.000 0.992 0.008
#> SRR1740077 2 0.0424 0.995 0.000 0.992 0.008
#> SRR1740078 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740079 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740080 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740081 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740082 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740083 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740084 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740085 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740086 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740087 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740088 1 0.0000 1.000 1.000 0.000 0.000
#> SRR1740089 1 0.0000 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
#> SRR1740034 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740035 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740036 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740037 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740038 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740039 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740040 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740041 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740042 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740043 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740044 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740045 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740046 3 0.0592 1.000 0.000 0.016 0.984 0
#> SRR1740048 3 0.0592 1.000 0.000 0.016 0.984 0
#> SRR1740047 3 0.0592 1.000 0.000 0.016 0.984 0
#> SRR1740049 3 0.0592 1.000 0.000 0.016 0.984 0
#> SRR1740050 1 0.0592 0.990 0.984 0.000 0.016 0
#> SRR1740051 1 0.0592 0.990 0.984 0.000 0.016 0
#> SRR1740052 1 0.0592 0.990 0.984 0.000 0.016 0
#> SRR1740054 1 0.0000 0.995 1.000 0.000 0.000 0
#> SRR1740053 1 0.0592 0.990 0.984 0.000 0.016 0
#> SRR1740056 1 0.0000 0.995 1.000 0.000 0.000 0
#> SRR1740055 1 0.0000 0.995 1.000 0.000 0.000 0
#> SRR1740057 1 0.0000 0.995 1.000 0.000 0.000 0
#> SRR1740058 1 0.0000 0.995 1.000 0.000 0.000 0
#> SRR1740059 1 0.0000 0.995 1.000 0.000 0.000 0
#> SRR1740060 1 0.0000 0.995 1.000 0.000 0.000 0
#> SRR1740061 1 0.0000 0.995 1.000 0.000 0.000 0
#> SRR1740062 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740063 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740064 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740065 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740066 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740067 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740068 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740069 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740070 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740071 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740072 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740073 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740074 3 0.0592 1.000 0.000 0.016 0.984 0
#> SRR1740075 3 0.0592 1.000 0.000 0.016 0.984 0
#> SRR1740076 3 0.0592 1.000 0.000 0.016 0.984 0
#> SRR1740077 3 0.0592 1.000 0.000 0.016 0.984 0
#> SRR1740078 1 0.0592 0.990 0.984 0.000 0.016 0
#> SRR1740079 1 0.0592 0.990 0.984 0.000 0.016 0
#> SRR1740080 1 0.0592 0.990 0.984 0.000 0.016 0
#> SRR1740081 1 0.0592 0.990 0.984 0.000 0.016 0
#> SRR1740082 1 0.0000 0.995 1.000 0.000 0.000 0
#> SRR1740083 1 0.0000 0.995 1.000 0.000 0.000 0
#> SRR1740084 1 0.0000 0.995 1.000 0.000 0.000 0
#> SRR1740085 1 0.0000 0.995 1.000 0.000 0.000 0
#> SRR1740086 1 0.0000 0.995 1.000 0.000 0.000 0
#> SRR1740087 1 0.0000 0.995 1.000 0.000 0.000 0
#> SRR1740088 1 0.0000 0.995 1.000 0.000 0.000 0
#> SRR1740089 1 0.0000 0.995 1.000 0.000 0.000 0
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0 1 0 0 0 1 0
#> SRR1740035 4 0 1 0 0 0 1 0
#> SRR1740036 4 0 1 0 0 0 1 0
#> SRR1740037 4 0 1 0 0 0 1 0
#> SRR1740038 2 0 1 0 1 0 0 0
#> SRR1740039 2 0 1 0 1 0 0 0
#> SRR1740040 2 0 1 0 1 0 0 0
#> SRR1740041 2 0 1 0 1 0 0 0
#> SRR1740042 2 0 1 0 1 0 0 0
#> SRR1740043 2 0 1 0 1 0 0 0
#> SRR1740044 2 0 1 0 1 0 0 0
#> SRR1740045 2 0 1 0 1 0 0 0
#> SRR1740046 3 0 1 0 0 1 0 0
#> SRR1740048 3 0 1 0 0 1 0 0
#> SRR1740047 3 0 1 0 0 1 0 0
#> SRR1740049 3 0 1 0 0 1 0 0
#> SRR1740050 5 0 1 0 0 0 0 1
#> SRR1740051 5 0 1 0 0 0 0 1
#> SRR1740052 5 0 1 0 0 0 0 1
#> SRR1740054 1 0 1 1 0 0 0 0
#> SRR1740053 5 0 1 0 0 0 0 1
#> SRR1740056 1 0 1 1 0 0 0 0
#> SRR1740055 1 0 1 1 0 0 0 0
#> SRR1740057 1 0 1 1 0 0 0 0
#> SRR1740058 1 0 1 1 0 0 0 0
#> SRR1740059 1 0 1 1 0 0 0 0
#> SRR1740060 1 0 1 1 0 0 0 0
#> SRR1740061 1 0 1 1 0 0 0 0
#> SRR1740062 4 0 1 0 0 0 1 0
#> SRR1740063 4 0 1 0 0 0 1 0
#> SRR1740064 4 0 1 0 0 0 1 0
#> SRR1740065 4 0 1 0 0 0 1 0
#> SRR1740066 2 0 1 0 1 0 0 0
#> SRR1740067 2 0 1 0 1 0 0 0
#> SRR1740068 2 0 1 0 1 0 0 0
#> SRR1740069 2 0 1 0 1 0 0 0
#> SRR1740070 2 0 1 0 1 0 0 0
#> SRR1740071 2 0 1 0 1 0 0 0
#> SRR1740072 2 0 1 0 1 0 0 0
#> SRR1740073 2 0 1 0 1 0 0 0
#> SRR1740074 3 0 1 0 0 1 0 0
#> SRR1740075 3 0 1 0 0 1 0 0
#> SRR1740076 3 0 1 0 0 1 0 0
#> SRR1740077 3 0 1 0 0 1 0 0
#> SRR1740078 5 0 1 0 0 0 0 1
#> SRR1740079 5 0 1 0 0 0 0 1
#> SRR1740080 5 0 1 0 0 0 0 1
#> SRR1740081 5 0 1 0 0 0 0 1
#> SRR1740082 1 0 1 1 0 0 0 0
#> SRR1740083 1 0 1 1 0 0 0 0
#> SRR1740084 1 0 1 1 0 0 0 0
#> SRR1740085 1 0 1 1 0 0 0 0
#> SRR1740086 1 0 1 1 0 0 0 0
#> SRR1740087 1 0 1 1 0 0 0 0
#> SRR1740088 1 0 1 1 0 0 0 0
#> SRR1740089 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
#> SRR1740034 4 0 1 0 0 0 1 0 0
#> SRR1740035 4 0 1 0 0 0 1 0 0
#> SRR1740036 4 0 1 0 0 0 1 0 0
#> SRR1740037 4 0 1 0 0 0 1 0 0
#> SRR1740038 2 0 1 0 1 0 0 0 0
#> SRR1740039 2 0 1 0 1 0 0 0 0
#> SRR1740040 2 0 1 0 1 0 0 0 0
#> SRR1740041 2 0 1 0 1 0 0 0 0
#> SRR1740042 2 0 1 0 1 0 0 0 0
#> SRR1740043 2 0 1 0 1 0 0 0 0
#> SRR1740044 2 0 1 0 1 0 0 0 0
#> SRR1740045 2 0 1 0 1 0 0 0 0
#> SRR1740046 3 0 1 0 0 1 0 0 0
#> SRR1740048 3 0 1 0 0 1 0 0 0
#> SRR1740047 3 0 1 0 0 1 0 0 0
#> SRR1740049 3 0 1 0 0 1 0 0 0
#> SRR1740050 5 0 1 0 0 0 0 1 0
#> SRR1740051 5 0 1 0 0 0 0 1 0
#> SRR1740052 5 0 1 0 0 0 0 1 0
#> SRR1740054 1 0 1 1 0 0 0 0 0
#> SRR1740053 5 0 1 0 0 0 0 1 0
#> SRR1740056 1 0 1 1 0 0 0 0 0
#> SRR1740055 1 0 1 1 0 0 0 0 0
#> SRR1740057 1 0 1 1 0 0 0 0 0
#> SRR1740058 6 0 1 0 0 0 0 0 1
#> SRR1740059 6 0 1 0 0 0 0 0 1
#> SRR1740060 6 0 1 0 0 0 0 0 1
#> SRR1740061 6 0 1 0 0 0 0 0 1
#> SRR1740062 4 0 1 0 0 0 1 0 0
#> SRR1740063 4 0 1 0 0 0 1 0 0
#> SRR1740064 4 0 1 0 0 0 1 0 0
#> SRR1740065 4 0 1 0 0 0 1 0 0
#> SRR1740066 2 0 1 0 1 0 0 0 0
#> SRR1740067 2 0 1 0 1 0 0 0 0
#> SRR1740068 2 0 1 0 1 0 0 0 0
#> SRR1740069 2 0 1 0 1 0 0 0 0
#> SRR1740070 2 0 1 0 1 0 0 0 0
#> SRR1740071 2 0 1 0 1 0 0 0 0
#> SRR1740072 2 0 1 0 1 0 0 0 0
#> SRR1740073 2 0 1 0 1 0 0 0 0
#> SRR1740074 3 0 1 0 0 1 0 0 0
#> SRR1740075 3 0 1 0 0 1 0 0 0
#> SRR1740076 3 0 1 0 0 1 0 0 0
#> SRR1740077 3 0 1 0 0 1 0 0 0
#> SRR1740078 5 0 1 0 0 0 0 1 0
#> SRR1740079 5 0 1 0 0 0 0 1 0
#> SRR1740080 5 0 1 0 0 0 0 1 0
#> SRR1740081 5 0 1 0 0 0 0 1 0
#> SRR1740082 1 0 1 1 0 0 0 0 0
#> SRR1740083 1 0 1 1 0 0 0 0 0
#> SRR1740084 1 0 1 1 0 0 0 0 0
#> SRR1740085 1 0 1 1 0 0 0 0 0
#> SRR1740086 6 0 1 0 0 0 0 0 1
#> SRR1740087 6 0 1 0 0 0 0 0 1
#> SRR1740088 6 0 1 0 0 0 0 0 1
#> SRR1740089 6 0 1 0 0 0 0 0 1
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.252 0.862 0.831 0.4131 0.501 0.501
#> 3 3 0.294 0.745 0.721 0.3760 1.000 1.000
#> 4 4 0.626 0.762 0.710 0.1999 0.792 0.585
#> 5 5 0.522 0.560 0.529 0.0786 0.834 0.504
#> 6 6 0.626 0.680 0.688 0.0683 0.844 0.429
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
#> SRR1740034 1 0.671 0.742 0.824 0.176
#> SRR1740035 1 0.671 0.742 0.824 0.176
#> SRR1740036 1 0.671 0.742 0.824 0.176
#> SRR1740037 1 0.671 0.742 0.824 0.176
#> SRR1740038 2 0.584 0.912 0.140 0.860
#> SRR1740039 2 0.584 0.912 0.140 0.860
#> SRR1740040 2 0.584 0.912 0.140 0.860
#> SRR1740041 2 0.584 0.912 0.140 0.860
#> SRR1740042 2 0.574 0.913 0.136 0.864
#> SRR1740043 2 0.574 0.913 0.136 0.864
#> SRR1740044 2 0.574 0.913 0.136 0.864
#> SRR1740045 2 0.574 0.913 0.136 0.864
#> SRR1740046 2 0.224 0.842 0.036 0.964
#> SRR1740048 2 0.224 0.842 0.036 0.964
#> SRR1740047 2 0.224 0.842 0.036 0.964
#> SRR1740049 2 0.224 0.842 0.036 0.964
#> SRR1740050 1 0.689 0.868 0.816 0.184
#> SRR1740051 1 0.689 0.868 0.816 0.184
#> SRR1740052 1 0.689 0.868 0.816 0.184
#> SRR1740054 1 0.781 0.876 0.768 0.232
#> SRR1740053 1 0.689 0.868 0.816 0.184
#> SRR1740056 1 0.781 0.876 0.768 0.232
#> SRR1740055 1 0.781 0.876 0.768 0.232
#> SRR1740057 1 0.781 0.876 0.768 0.232
#> SRR1740058 1 0.697 0.880 0.812 0.188
#> SRR1740059 1 0.697 0.880 0.812 0.188
#> SRR1740060 1 0.697 0.880 0.812 0.188
#> SRR1740061 1 0.697 0.880 0.812 0.188
#> SRR1740062 1 0.671 0.742 0.824 0.176
#> SRR1740063 1 0.671 0.742 0.824 0.176
#> SRR1740064 1 0.671 0.742 0.824 0.176
#> SRR1740065 1 0.671 0.742 0.824 0.176
#> SRR1740066 2 0.584 0.912 0.140 0.860
#> SRR1740067 2 0.584 0.912 0.140 0.860
#> SRR1740068 2 0.584 0.912 0.140 0.860
#> SRR1740069 2 0.584 0.912 0.140 0.860
#> SRR1740070 2 0.574 0.913 0.136 0.864
#> SRR1740071 2 0.574 0.913 0.136 0.864
#> SRR1740072 2 0.574 0.913 0.136 0.864
#> SRR1740073 2 0.574 0.913 0.136 0.864
#> SRR1740074 2 0.224 0.842 0.036 0.964
#> SRR1740075 2 0.224 0.842 0.036 0.964
#> SRR1740076 2 0.224 0.842 0.036 0.964
#> SRR1740077 2 0.224 0.842 0.036 0.964
#> SRR1740078 1 0.689 0.868 0.816 0.184
#> SRR1740079 1 0.689 0.868 0.816 0.184
#> SRR1740080 1 0.689 0.868 0.816 0.184
#> SRR1740081 1 0.689 0.868 0.816 0.184
#> SRR1740082 1 0.781 0.876 0.768 0.232
#> SRR1740083 1 0.781 0.876 0.768 0.232
#> SRR1740084 1 0.781 0.876 0.768 0.232
#> SRR1740085 1 0.781 0.876 0.768 0.232
#> SRR1740086 1 0.697 0.880 0.812 0.188
#> SRR1740087 1 0.697 0.880 0.812 0.188
#> SRR1740088 1 0.697 0.880 0.812 0.188
#> SRR1740089 1 0.697 0.880 0.812 0.188
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0.797 0.590 0.560 0.068 NA
#> SRR1740035 1 0.797 0.590 0.560 0.068 NA
#> SRR1740036 1 0.797 0.590 0.560 0.068 NA
#> SRR1740037 1 0.797 0.590 0.560 0.068 NA
#> SRR1740038 2 0.925 0.786 0.164 0.480 NA
#> SRR1740039 2 0.925 0.786 0.164 0.480 NA
#> SRR1740040 2 0.925 0.786 0.164 0.480 NA
#> SRR1740041 2 0.925 0.786 0.164 0.480 NA
#> SRR1740042 2 0.846 0.815 0.156 0.612 NA
#> SRR1740043 2 0.846 0.815 0.156 0.612 NA
#> SRR1740044 2 0.846 0.815 0.156 0.612 NA
#> SRR1740045 2 0.846 0.815 0.156 0.612 NA
#> SRR1740046 2 0.186 0.716 0.052 0.948 NA
#> SRR1740048 2 0.186 0.716 0.052 0.948 NA
#> SRR1740047 2 0.186 0.716 0.052 0.948 NA
#> SRR1740049 2 0.186 0.716 0.052 0.948 NA
#> SRR1740050 1 0.584 0.726 0.768 0.036 NA
#> SRR1740051 1 0.584 0.726 0.768 0.036 NA
#> SRR1740052 1 0.584 0.726 0.768 0.036 NA
#> SRR1740054 1 0.183 0.794 0.956 0.036 NA
#> SRR1740053 1 0.584 0.726 0.768 0.036 NA
#> SRR1740056 1 0.183 0.794 0.956 0.036 NA
#> SRR1740055 1 0.183 0.794 0.956 0.036 NA
#> SRR1740057 1 0.183 0.794 0.956 0.036 NA
#> SRR1740058 1 0.300 0.791 0.916 0.016 NA
#> SRR1740059 1 0.300 0.791 0.916 0.016 NA
#> SRR1740060 1 0.300 0.791 0.916 0.016 NA
#> SRR1740061 1 0.300 0.791 0.916 0.016 NA
#> SRR1740062 1 0.777 0.590 0.560 0.056 NA
#> SRR1740063 1 0.777 0.590 0.560 0.056 NA
#> SRR1740064 1 0.777 0.590 0.560 0.056 NA
#> SRR1740065 1 0.777 0.590 0.560 0.056 NA
#> SRR1740066 2 0.925 0.786 0.164 0.480 NA
#> SRR1740067 2 0.925 0.786 0.164 0.480 NA
#> SRR1740068 2 0.925 0.786 0.164 0.480 NA
#> SRR1740069 2 0.925 0.786 0.164 0.480 NA
#> SRR1740070 2 0.846 0.815 0.156 0.612 NA
#> SRR1740071 2 0.846 0.815 0.156 0.612 NA
#> SRR1740072 2 0.846 0.815 0.156 0.612 NA
#> SRR1740073 2 0.846 0.815 0.156 0.612 NA
#> SRR1740074 2 0.301 0.716 0.052 0.920 NA
#> SRR1740075 2 0.301 0.716 0.052 0.920 NA
#> SRR1740076 2 0.301 0.716 0.052 0.920 NA
#> SRR1740077 2 0.301 0.716 0.052 0.920 NA
#> SRR1740078 1 0.546 0.726 0.768 0.016 NA
#> SRR1740079 1 0.546 0.726 0.768 0.016 NA
#> SRR1740080 1 0.546 0.726 0.768 0.016 NA
#> SRR1740081 1 0.546 0.726 0.768 0.016 NA
#> SRR1740082 1 0.183 0.794 0.956 0.036 NA
#> SRR1740083 1 0.183 0.794 0.956 0.036 NA
#> SRR1740084 1 0.183 0.794 0.956 0.036 NA
#> SRR1740085 1 0.183 0.794 0.956 0.036 NA
#> SRR1740086 1 0.300 0.791 0.916 0.016 NA
#> SRR1740087 1 0.300 0.791 0.916 0.016 NA
#> SRR1740088 1 0.300 0.791 0.916 0.016 NA
#> SRR1740089 1 0.300 0.791 0.916 0.016 NA
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 4 0.112 0.969 0.000 0.036 0.000 0.964
#> SRR1740035 4 0.112 0.969 0.000 0.036 0.000 0.964
#> SRR1740036 4 0.112 0.969 0.000 0.036 0.000 0.964
#> SRR1740037 4 0.112 0.969 0.000 0.036 0.000 0.964
#> SRR1740038 2 0.000 0.840 0.000 1.000 0.000 0.000
#> SRR1740039 2 0.000 0.840 0.000 1.000 0.000 0.000
#> SRR1740040 2 0.000 0.840 0.000 1.000 0.000 0.000
#> SRR1740041 2 0.000 0.840 0.000 1.000 0.000 0.000
#> SRR1740042 2 0.448 0.828 0.064 0.812 0.120 0.004
#> SRR1740043 2 0.448 0.828 0.064 0.812 0.120 0.004
#> SRR1740044 2 0.448 0.828 0.064 0.812 0.120 0.004
#> SRR1740045 2 0.448 0.828 0.064 0.812 0.120 0.004
#> SRR1740046 3 0.510 0.947 0.004 0.368 0.624 0.004
#> SRR1740048 3 0.510 0.947 0.004 0.368 0.624 0.004
#> SRR1740047 3 0.510 0.947 0.004 0.368 0.624 0.004
#> SRR1740049 3 0.510 0.947 0.004 0.368 0.624 0.004
#> SRR1740050 1 0.814 0.505 0.500 0.028 0.240 0.232
#> SRR1740051 1 0.814 0.505 0.500 0.028 0.240 0.232
#> SRR1740052 1 0.814 0.505 0.500 0.028 0.240 0.232
#> SRR1740054 1 0.624 0.638 0.604 0.076 0.000 0.320
#> SRR1740053 1 0.814 0.505 0.500 0.028 0.240 0.232
#> SRR1740056 1 0.624 0.638 0.604 0.076 0.000 0.320
#> SRR1740055 1 0.624 0.638 0.604 0.076 0.000 0.320
#> SRR1740057 1 0.624 0.638 0.604 0.076 0.000 0.320
#> SRR1740058 1 0.642 0.607 0.620 0.032 0.036 0.312
#> SRR1740059 1 0.642 0.607 0.620 0.032 0.036 0.312
#> SRR1740060 1 0.642 0.607 0.620 0.032 0.036 0.312
#> SRR1740061 1 0.642 0.607 0.620 0.032 0.036 0.312
#> SRR1740062 4 0.274 0.968 0.000 0.036 0.060 0.904
#> SRR1740063 4 0.274 0.968 0.000 0.036 0.060 0.904
#> SRR1740064 4 0.285 0.968 0.004 0.036 0.056 0.904
#> SRR1740065 4 0.285 0.968 0.004 0.036 0.056 0.904
#> SRR1740066 2 0.000 0.840 0.000 1.000 0.000 0.000
#> SRR1740067 2 0.000 0.840 0.000 1.000 0.000 0.000
#> SRR1740068 2 0.000 0.840 0.000 1.000 0.000 0.000
#> SRR1740069 2 0.000 0.840 0.000 1.000 0.000 0.000
#> SRR1740070 2 0.448 0.828 0.064 0.812 0.120 0.004
#> SRR1740071 2 0.448 0.828 0.064 0.812 0.120 0.004
#> SRR1740072 2 0.448 0.828 0.064 0.812 0.120 0.004
#> SRR1740073 2 0.448 0.828 0.064 0.812 0.120 0.004
#> SRR1740074 3 0.698 0.947 0.072 0.368 0.540 0.020
#> SRR1740075 3 0.698 0.947 0.072 0.368 0.540 0.020
#> SRR1740076 3 0.698 0.947 0.072 0.368 0.540 0.020
#> SRR1740077 3 0.698 0.947 0.072 0.368 0.540 0.020
#> SRR1740078 1 0.824 0.505 0.480 0.028 0.260 0.232
#> SRR1740079 1 0.824 0.505 0.480 0.028 0.260 0.232
#> SRR1740080 1 0.824 0.505 0.480 0.028 0.260 0.232
#> SRR1740081 1 0.824 0.505 0.480 0.028 0.260 0.232
#> SRR1740082 1 0.624 0.638 0.604 0.076 0.000 0.320
#> SRR1740083 1 0.624 0.638 0.604 0.076 0.000 0.320
#> SRR1740084 1 0.624 0.638 0.604 0.076 0.000 0.320
#> SRR1740085 1 0.624 0.638 0.604 0.076 0.000 0.320
#> SRR1740086 1 0.658 0.607 0.612 0.032 0.044 0.312
#> SRR1740087 1 0.658 0.607 0.612 0.032 0.044 0.312
#> SRR1740088 1 0.658 0.607 0.612 0.032 0.044 0.312
#> SRR1740089 1 0.658 0.607 0.612 0.032 0.044 0.312
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.2828 0.940 0.000 0.020 0.004 0.872 0.104
#> SRR1740035 4 0.2828 0.940 0.000 0.020 0.004 0.872 0.104
#> SRR1740036 4 0.2828 0.940 0.000 0.020 0.004 0.872 0.104
#> SRR1740037 4 0.2890 0.939 0.004 0.016 0.004 0.872 0.104
#> SRR1740038 3 0.5817 -0.120 0.000 0.384 0.544 0.028 0.044
#> SRR1740039 3 0.5817 -0.120 0.000 0.384 0.544 0.028 0.044
#> SRR1740040 3 0.5817 -0.120 0.000 0.384 0.544 0.028 0.044
#> SRR1740041 3 0.5817 -0.120 0.000 0.384 0.544 0.028 0.044
#> SRR1740042 2 0.4228 0.987 0.000 0.748 0.216 0.004 0.032
#> SRR1740043 2 0.4228 0.987 0.000 0.748 0.216 0.004 0.032
#> SRR1740044 2 0.4228 0.987 0.000 0.748 0.216 0.004 0.032
#> SRR1740045 2 0.4228 0.987 0.000 0.748 0.216 0.004 0.032
#> SRR1740046 3 0.6041 0.380 0.204 0.120 0.644 0.032 0.000
#> SRR1740048 3 0.5885 0.380 0.204 0.120 0.652 0.024 0.000
#> SRR1740047 3 0.5885 0.380 0.204 0.120 0.652 0.024 0.000
#> SRR1740049 3 0.6041 0.380 0.204 0.120 0.644 0.032 0.000
#> SRR1740050 5 0.2322 0.500 0.028 0.036 0.008 0.008 0.920
#> SRR1740051 5 0.2322 0.500 0.028 0.036 0.008 0.008 0.920
#> SRR1740052 5 0.2322 0.500 0.028 0.036 0.008 0.008 0.920
#> SRR1740054 5 0.8523 0.257 0.200 0.212 0.004 0.216 0.368
#> SRR1740053 5 0.2322 0.500 0.028 0.036 0.008 0.008 0.920
#> SRR1740056 5 0.8523 0.257 0.200 0.212 0.004 0.216 0.368
#> SRR1740055 5 0.8523 0.257 0.200 0.212 0.004 0.216 0.368
#> SRR1740057 5 0.8523 0.257 0.200 0.212 0.004 0.216 0.368
#> SRR1740058 1 0.6665 0.976 0.536 0.020 0.000 0.180 0.264
#> SRR1740059 1 0.6665 0.976 0.536 0.020 0.000 0.180 0.264
#> SRR1740060 1 0.6665 0.976 0.536 0.020 0.000 0.180 0.264
#> SRR1740061 1 0.6665 0.976 0.536 0.020 0.000 0.180 0.264
#> SRR1740062 4 0.4908 0.940 0.032 0.092 0.004 0.768 0.104
#> SRR1740063 4 0.4908 0.940 0.032 0.092 0.004 0.768 0.104
#> SRR1740064 4 0.4908 0.940 0.032 0.092 0.004 0.768 0.104
#> SRR1740065 4 0.4908 0.940 0.032 0.092 0.004 0.768 0.104
#> SRR1740066 3 0.6718 -0.120 0.040 0.392 0.496 0.028 0.044
#> SRR1740067 3 0.6718 -0.120 0.040 0.392 0.496 0.028 0.044
#> SRR1740068 3 0.6718 -0.120 0.040 0.392 0.496 0.028 0.044
#> SRR1740069 3 0.6718 -0.120 0.040 0.392 0.496 0.028 0.044
#> SRR1740070 2 0.4393 0.987 0.000 0.748 0.208 0.012 0.032
#> SRR1740071 2 0.4393 0.987 0.000 0.748 0.208 0.012 0.032
#> SRR1740072 2 0.4393 0.987 0.000 0.748 0.208 0.012 0.032
#> SRR1740073 2 0.4393 0.987 0.000 0.748 0.208 0.012 0.032
#> SRR1740074 3 0.6627 0.379 0.320 0.128 0.524 0.028 0.000
#> SRR1740075 3 0.6627 0.379 0.320 0.128 0.524 0.028 0.000
#> SRR1740076 3 0.6425 0.379 0.332 0.128 0.524 0.016 0.000
#> SRR1740077 3 0.6425 0.379 0.332 0.128 0.524 0.016 0.000
#> SRR1740078 5 0.0324 0.499 0.004 0.004 0.000 0.000 0.992
#> SRR1740079 5 0.0324 0.499 0.004 0.004 0.000 0.000 0.992
#> SRR1740080 5 0.0290 0.499 0.000 0.008 0.000 0.000 0.992
#> SRR1740081 5 0.0290 0.499 0.000 0.008 0.000 0.000 0.992
#> SRR1740082 5 0.8505 0.257 0.180 0.228 0.004 0.220 0.368
#> SRR1740083 5 0.8505 0.257 0.180 0.228 0.004 0.220 0.368
#> SRR1740084 5 0.8505 0.257 0.180 0.228 0.004 0.220 0.368
#> SRR1740085 5 0.8505 0.257 0.180 0.228 0.004 0.220 0.368
#> SRR1740086 1 0.7162 0.976 0.504 0.048 0.000 0.180 0.268
#> SRR1740087 1 0.7162 0.976 0.504 0.048 0.000 0.180 0.268
#> SRR1740088 1 0.7162 0.976 0.504 0.048 0.000 0.180 0.268
#> SRR1740089 1 0.7162 0.976 0.504 0.048 0.000 0.180 0.268
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.201 0.917 0.000 0.004 0.000 0.892 0.000 0.104
#> SRR1740035 4 0.201 0.917 0.000 0.004 0.000 0.892 0.000 0.104
#> SRR1740036 4 0.201 0.917 0.000 0.004 0.000 0.892 0.000 0.104
#> SRR1740037 4 0.240 0.916 0.000 0.004 0.008 0.880 0.004 0.104
#> SRR1740038 1 0.450 0.996 0.552 0.424 0.008 0.000 0.004 0.012
#> SRR1740039 1 0.445 0.996 0.552 0.424 0.012 0.000 0.000 0.012
#> SRR1740040 1 0.450 0.996 0.552 0.424 0.008 0.000 0.004 0.012
#> SRR1740041 1 0.445 0.996 0.552 0.424 0.012 0.000 0.000 0.012
#> SRR1740042 2 0.135 0.600 0.024 0.952 0.000 0.000 0.008 0.016
#> SRR1740043 2 0.135 0.599 0.024 0.952 0.000 0.008 0.000 0.016
#> SRR1740044 2 0.135 0.600 0.024 0.952 0.000 0.000 0.008 0.016
#> SRR1740045 2 0.135 0.600 0.024 0.952 0.000 0.000 0.008 0.016
#> SRR1740046 3 0.358 0.895 0.004 0.244 0.740 0.012 0.000 0.000
#> SRR1740048 3 0.351 0.895 0.000 0.248 0.740 0.004 0.008 0.000
#> SRR1740047 3 0.351 0.895 0.000 0.248 0.740 0.004 0.008 0.000
#> SRR1740049 3 0.358 0.895 0.004 0.244 0.740 0.012 0.000 0.000
#> SRR1740050 5 0.399 0.930 0.000 0.000 0.000 0.024 0.676 0.300
#> SRR1740051 5 0.399 0.930 0.000 0.000 0.000 0.024 0.676 0.300
#> SRR1740052 5 0.399 0.930 0.000 0.000 0.000 0.024 0.676 0.300
#> SRR1740054 6 0.311 0.639 0.024 0.036 0.000 0.076 0.004 0.860
#> SRR1740053 5 0.420 0.930 0.004 0.000 0.000 0.028 0.668 0.300
#> SRR1740056 6 0.311 0.639 0.024 0.036 0.000 0.076 0.004 0.860
#> SRR1740055 6 0.311 0.639 0.024 0.036 0.000 0.076 0.004 0.860
#> SRR1740057 6 0.311 0.639 0.024 0.036 0.000 0.076 0.004 0.860
#> SRR1740058 6 0.590 0.655 0.240 0.000 0.024 0.028 0.096 0.612
#> SRR1740059 6 0.593 0.655 0.240 0.000 0.024 0.032 0.092 0.612
#> SRR1740060 6 0.593 0.655 0.240 0.000 0.024 0.032 0.092 0.612
#> SRR1740061 6 0.590 0.655 0.240 0.000 0.024 0.028 0.096 0.612
#> SRR1740062 4 0.551 0.916 0.084 0.004 0.040 0.716 0.052 0.104
#> SRR1740063 4 0.551 0.916 0.084 0.004 0.040 0.716 0.052 0.104
#> SRR1740064 4 0.551 0.916 0.084 0.004 0.044 0.716 0.048 0.104
#> SRR1740065 4 0.549 0.916 0.088 0.004 0.036 0.716 0.052 0.104
#> SRR1740066 2 0.629 -0.748 0.428 0.452 0.056 0.024 0.028 0.012
#> SRR1740067 2 0.629 -0.748 0.428 0.452 0.056 0.024 0.028 0.012
#> SRR1740068 2 0.629 -0.748 0.428 0.452 0.056 0.024 0.028 0.012
#> SRR1740069 2 0.629 -0.748 0.428 0.452 0.056 0.024 0.028 0.012
#> SRR1740070 2 0.131 0.604 0.000 0.952 0.000 0.004 0.028 0.016
#> SRR1740071 2 0.131 0.604 0.000 0.952 0.000 0.004 0.028 0.016
#> SRR1740072 2 0.131 0.604 0.000 0.952 0.000 0.004 0.028 0.016
#> SRR1740073 2 0.131 0.604 0.000 0.952 0.000 0.004 0.028 0.016
#> SRR1740074 3 0.650 0.895 0.060 0.252 0.564 0.028 0.096 0.000
#> SRR1740075 3 0.650 0.895 0.060 0.252 0.564 0.028 0.096 0.000
#> SRR1740076 3 0.642 0.895 0.056 0.252 0.564 0.020 0.108 0.000
#> SRR1740077 3 0.642 0.895 0.056 0.252 0.564 0.020 0.108 0.000
#> SRR1740078 5 0.635 0.930 0.032 0.000 0.064 0.056 0.548 0.300
#> SRR1740079 5 0.635 0.930 0.032 0.000 0.064 0.056 0.548 0.300
#> SRR1740080 5 0.634 0.930 0.028 0.000 0.068 0.056 0.548 0.300
#> SRR1740081 5 0.637 0.929 0.036 0.000 0.060 0.056 0.548 0.300
#> SRR1740082 6 0.294 0.639 0.004 0.036 0.016 0.076 0.000 0.868
#> SRR1740083 6 0.294 0.639 0.004 0.036 0.016 0.076 0.000 0.868
#> SRR1740084 6 0.294 0.639 0.004 0.036 0.016 0.076 0.000 0.868
#> SRR1740085 6 0.294 0.639 0.004 0.036 0.016 0.076 0.000 0.868
#> SRR1740086 6 0.609 0.655 0.180 0.000 0.060 0.028 0.096 0.636
#> SRR1740087 6 0.609 0.655 0.180 0.000 0.060 0.028 0.096 0.636
#> SRR1740088 6 0.611 0.655 0.176 0.000 0.064 0.028 0.096 0.636
#> SRR1740089 6 0.611 0.655 0.176 0.000 0.064 0.028 0.096 0.636
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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.997 0.998 0.4992 0.501 0.501
#> 3 3 0.875 0.951 0.959 0.2661 0.875 0.751
#> 4 4 0.834 0.923 0.901 0.1234 0.917 0.779
#> 5 5 0.917 0.957 0.953 0.1097 0.917 0.717
#> 6 6 0.917 0.970 0.941 0.0552 0.958 0.802
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 5
There is also optional best \(k\) = 2 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1740034 1 0.0938 0.991 0.988 0.012
#> SRR1740035 1 0.0938 0.991 0.988 0.012
#> SRR1740036 1 0.0938 0.991 0.988 0.012
#> SRR1740037 1 0.0938 0.991 0.988 0.012
#> SRR1740038 2 0.0000 1.000 0.000 1.000
#> SRR1740039 2 0.0000 1.000 0.000 1.000
#> SRR1740040 2 0.0000 1.000 0.000 1.000
#> SRR1740041 2 0.0000 1.000 0.000 1.000
#> SRR1740042 2 0.0000 1.000 0.000 1.000
#> SRR1740043 2 0.0000 1.000 0.000 1.000
#> SRR1740044 2 0.0000 1.000 0.000 1.000
#> SRR1740045 2 0.0000 1.000 0.000 1.000
#> SRR1740046 2 0.0000 1.000 0.000 1.000
#> SRR1740048 2 0.0000 1.000 0.000 1.000
#> SRR1740047 2 0.0000 1.000 0.000 1.000
#> SRR1740049 2 0.0000 1.000 0.000 1.000
#> SRR1740050 1 0.0000 0.997 1.000 0.000
#> SRR1740051 1 0.0000 0.997 1.000 0.000
#> SRR1740052 1 0.0000 0.997 1.000 0.000
#> SRR1740054 1 0.0000 0.997 1.000 0.000
#> SRR1740053 1 0.0000 0.997 1.000 0.000
#> SRR1740056 1 0.0000 0.997 1.000 0.000
#> SRR1740055 1 0.0000 0.997 1.000 0.000
#> SRR1740057 1 0.0000 0.997 1.000 0.000
#> SRR1740058 1 0.0000 0.997 1.000 0.000
#> SRR1740059 1 0.0000 0.997 1.000 0.000
#> SRR1740060 1 0.0000 0.997 1.000 0.000
#> SRR1740061 1 0.0000 0.997 1.000 0.000
#> SRR1740062 1 0.0938 0.991 0.988 0.012
#> SRR1740063 1 0.0938 0.991 0.988 0.012
#> SRR1740064 1 0.0938 0.991 0.988 0.012
#> SRR1740065 1 0.0938 0.991 0.988 0.012
#> SRR1740066 2 0.0000 1.000 0.000 1.000
#> SRR1740067 2 0.0000 1.000 0.000 1.000
#> SRR1740068 2 0.0000 1.000 0.000 1.000
#> SRR1740069 2 0.0000 1.000 0.000 1.000
#> SRR1740070 2 0.0000 1.000 0.000 1.000
#> SRR1740071 2 0.0000 1.000 0.000 1.000
#> SRR1740072 2 0.0000 1.000 0.000 1.000
#> SRR1740073 2 0.0000 1.000 0.000 1.000
#> SRR1740074 2 0.0000 1.000 0.000 1.000
#> SRR1740075 2 0.0000 1.000 0.000 1.000
#> SRR1740076 2 0.0000 1.000 0.000 1.000
#> SRR1740077 2 0.0000 1.000 0.000 1.000
#> SRR1740078 1 0.0000 0.997 1.000 0.000
#> SRR1740079 1 0.0000 0.997 1.000 0.000
#> SRR1740080 1 0.0000 0.997 1.000 0.000
#> SRR1740081 1 0.0000 0.997 1.000 0.000
#> SRR1740082 1 0.0000 0.997 1.000 0.000
#> SRR1740083 1 0.0000 0.997 1.000 0.000
#> SRR1740084 1 0.0000 0.997 1.000 0.000
#> SRR1740085 1 0.0000 0.997 1.000 0.000
#> SRR1740086 1 0.0000 0.997 1.000 0.000
#> SRR1740087 1 0.0000 0.997 1.000 0.000
#> SRR1740088 1 0.0000 0.997 1.000 0.000
#> SRR1740089 1 0.0000 0.997 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 3 0.141 1.000 0.036 0.00 0.964
#> SRR1740035 3 0.141 1.000 0.036 0.00 0.964
#> SRR1740036 3 0.141 1.000 0.036 0.00 0.964
#> SRR1740037 3 0.141 1.000 0.036 0.00 0.964
#> SRR1740038 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740039 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740040 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740041 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740042 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740043 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740044 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740045 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740046 2 0.254 0.942 0.000 0.92 0.080
#> SRR1740048 2 0.254 0.942 0.000 0.92 0.080
#> SRR1740047 2 0.254 0.942 0.000 0.92 0.080
#> SRR1740049 2 0.254 0.942 0.000 0.92 0.080
#> SRR1740050 1 0.355 0.896 0.868 0.00 0.132
#> SRR1740051 1 0.355 0.896 0.868 0.00 0.132
#> SRR1740052 1 0.355 0.896 0.868 0.00 0.132
#> SRR1740054 1 0.000 0.939 1.000 0.00 0.000
#> SRR1740053 1 0.355 0.896 0.868 0.00 0.132
#> SRR1740056 1 0.000 0.939 1.000 0.00 0.000
#> SRR1740055 1 0.000 0.939 1.000 0.00 0.000
#> SRR1740057 1 0.000 0.939 1.000 0.00 0.000
#> SRR1740058 1 0.141 0.934 0.964 0.00 0.036
#> SRR1740059 1 0.141 0.934 0.964 0.00 0.036
#> SRR1740060 1 0.141 0.934 0.964 0.00 0.036
#> SRR1740061 1 0.141 0.934 0.964 0.00 0.036
#> SRR1740062 3 0.141 1.000 0.036 0.00 0.964
#> SRR1740063 3 0.141 1.000 0.036 0.00 0.964
#> SRR1740064 3 0.141 1.000 0.036 0.00 0.964
#> SRR1740065 3 0.141 1.000 0.036 0.00 0.964
#> SRR1740066 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740067 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740068 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740069 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740070 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740071 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740072 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740073 2 0.000 0.972 0.000 1.00 0.000
#> SRR1740074 2 0.254 0.942 0.000 0.92 0.080
#> SRR1740075 2 0.254 0.942 0.000 0.92 0.080
#> SRR1740076 2 0.254 0.942 0.000 0.92 0.080
#> SRR1740077 2 0.254 0.942 0.000 0.92 0.080
#> SRR1740078 1 0.355 0.896 0.868 0.00 0.132
#> SRR1740079 1 0.355 0.896 0.868 0.00 0.132
#> SRR1740080 1 0.355 0.896 0.868 0.00 0.132
#> SRR1740081 1 0.355 0.896 0.868 0.00 0.132
#> SRR1740082 1 0.000 0.939 1.000 0.00 0.000
#> SRR1740083 1 0.000 0.939 1.000 0.00 0.000
#> SRR1740084 1 0.000 0.939 1.000 0.00 0.000
#> SRR1740085 1 0.000 0.939 1.000 0.00 0.000
#> SRR1740086 1 0.141 0.934 0.964 0.00 0.036
#> SRR1740087 1 0.141 0.934 0.964 0.00 0.036
#> SRR1740088 1 0.141 0.934 0.964 0.00 0.036
#> SRR1740089 1 0.141 0.934 0.964 0.00 0.036
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> SRR1740035 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> SRR1740036 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> SRR1740037 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> SRR1740038 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR1740039 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR1740040 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR1740041 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR1740042 2 0.0336 0.994 0.000 0.992 0.008 0.000
#> SRR1740043 2 0.0336 0.994 0.000 0.992 0.008 0.000
#> SRR1740044 2 0.0336 0.994 0.000 0.992 0.008 0.000
#> SRR1740045 2 0.0336 0.994 0.000 0.992 0.008 0.000
#> SRR1740046 3 0.4584 1.000 0.000 0.300 0.696 0.004
#> SRR1740048 3 0.4584 1.000 0.000 0.300 0.696 0.004
#> SRR1740047 3 0.4584 1.000 0.000 0.300 0.696 0.004
#> SRR1740049 3 0.4584 1.000 0.000 0.300 0.696 0.004
#> SRR1740050 1 0.5883 0.730 0.648 0.000 0.288 0.064
#> SRR1740051 1 0.5883 0.730 0.648 0.000 0.288 0.064
#> SRR1740052 1 0.5883 0.730 0.648 0.000 0.288 0.064
#> SRR1740054 1 0.0592 0.871 0.984 0.000 0.016 0.000
#> SRR1740053 1 0.5883 0.730 0.648 0.000 0.288 0.064
#> SRR1740056 1 0.0592 0.871 0.984 0.000 0.016 0.000
#> SRR1740055 1 0.0592 0.871 0.984 0.000 0.016 0.000
#> SRR1740057 1 0.0592 0.871 0.984 0.000 0.016 0.000
#> SRR1740058 1 0.0469 0.872 0.988 0.000 0.000 0.012
#> SRR1740059 1 0.0469 0.872 0.988 0.000 0.000 0.012
#> SRR1740060 1 0.0469 0.872 0.988 0.000 0.000 0.012
#> SRR1740061 1 0.0469 0.872 0.988 0.000 0.000 0.012
#> SRR1740062 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> SRR1740063 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> SRR1740064 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> SRR1740065 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> SRR1740066 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR1740067 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR1740068 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR1740069 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR1740070 2 0.0336 0.994 0.000 0.992 0.008 0.000
#> SRR1740071 2 0.0336 0.994 0.000 0.992 0.008 0.000
#> SRR1740072 2 0.0336 0.994 0.000 0.992 0.008 0.000
#> SRR1740073 2 0.0336 0.994 0.000 0.992 0.008 0.000
#> SRR1740074 3 0.4584 1.000 0.000 0.300 0.696 0.004
#> SRR1740075 3 0.4584 1.000 0.000 0.300 0.696 0.004
#> SRR1740076 3 0.4584 1.000 0.000 0.300 0.696 0.004
#> SRR1740077 3 0.4584 1.000 0.000 0.300 0.696 0.004
#> SRR1740078 1 0.5883 0.730 0.648 0.000 0.288 0.064
#> SRR1740079 1 0.5883 0.730 0.648 0.000 0.288 0.064
#> SRR1740080 1 0.5883 0.730 0.648 0.000 0.288 0.064
#> SRR1740081 1 0.5883 0.730 0.648 0.000 0.288 0.064
#> SRR1740082 1 0.0592 0.871 0.984 0.000 0.016 0.000
#> SRR1740083 1 0.0592 0.871 0.984 0.000 0.016 0.000
#> SRR1740084 1 0.0592 0.871 0.984 0.000 0.016 0.000
#> SRR1740085 1 0.0592 0.871 0.984 0.000 0.016 0.000
#> SRR1740086 1 0.0469 0.872 0.988 0.000 0.000 0.012
#> SRR1740087 1 0.0469 0.872 0.988 0.000 0.000 0.012
#> SRR1740088 1 0.0469 0.872 0.988 0.000 0.000 0.012
#> SRR1740089 1 0.0469 0.872 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
#> SRR1740034 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1740035 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1740036 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1740037 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1740038 2 0.0000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1740039 2 0.0000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1740040 2 0.0000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1740041 2 0.0000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1740042 2 0.1469 0.973 0.000 0.948 0.036 0.000 0.016
#> SRR1740043 2 0.1469 0.973 0.000 0.948 0.036 0.000 0.016
#> SRR1740044 2 0.1469 0.973 0.000 0.948 0.036 0.000 0.016
#> SRR1740045 2 0.1469 0.973 0.000 0.948 0.036 0.000 0.016
#> SRR1740046 3 0.0963 1.000 0.000 0.036 0.964 0.000 0.000
#> SRR1740048 3 0.0963 1.000 0.000 0.036 0.964 0.000 0.000
#> SRR1740047 3 0.0963 1.000 0.000 0.036 0.964 0.000 0.000
#> SRR1740049 3 0.0963 1.000 0.000 0.036 0.964 0.000 0.000
#> SRR1740050 5 0.0510 1.000 0.016 0.000 0.000 0.000 0.984
#> SRR1740051 5 0.0510 1.000 0.016 0.000 0.000 0.000 0.984
#> SRR1740052 5 0.0510 1.000 0.016 0.000 0.000 0.000 0.984
#> SRR1740054 1 0.0162 0.880 0.996 0.000 0.000 0.000 0.004
#> SRR1740053 5 0.0510 1.000 0.016 0.000 0.000 0.000 0.984
#> SRR1740056 1 0.0162 0.880 0.996 0.000 0.000 0.000 0.004
#> SRR1740055 1 0.0162 0.880 0.996 0.000 0.000 0.000 0.004
#> SRR1740057 1 0.0162 0.880 0.996 0.000 0.000 0.000 0.004
#> SRR1740058 1 0.4586 0.872 0.780 0.000 0.036 0.056 0.128
#> SRR1740059 1 0.4586 0.872 0.780 0.000 0.036 0.056 0.128
#> SRR1740060 1 0.4586 0.872 0.780 0.000 0.036 0.056 0.128
#> SRR1740061 1 0.4586 0.872 0.780 0.000 0.036 0.056 0.128
#> SRR1740062 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1740063 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1740064 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1740065 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1740066 2 0.0000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1740067 2 0.0000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1740068 2 0.0000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1740069 2 0.0000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1740070 2 0.1469 0.973 0.000 0.948 0.036 0.000 0.016
#> SRR1740071 2 0.1469 0.973 0.000 0.948 0.036 0.000 0.016
#> SRR1740072 2 0.1469 0.973 0.000 0.948 0.036 0.000 0.016
#> SRR1740073 2 0.1469 0.973 0.000 0.948 0.036 0.000 0.016
#> SRR1740074 3 0.0963 1.000 0.000 0.036 0.964 0.000 0.000
#> SRR1740075 3 0.0963 1.000 0.000 0.036 0.964 0.000 0.000
#> SRR1740076 3 0.0963 1.000 0.000 0.036 0.964 0.000 0.000
#> SRR1740077 3 0.0963 1.000 0.000 0.036 0.964 0.000 0.000
#> SRR1740078 5 0.0510 1.000 0.016 0.000 0.000 0.000 0.984
#> SRR1740079 5 0.0510 1.000 0.016 0.000 0.000 0.000 0.984
#> SRR1740080 5 0.0510 1.000 0.016 0.000 0.000 0.000 0.984
#> SRR1740081 5 0.0510 1.000 0.016 0.000 0.000 0.000 0.984
#> SRR1740082 1 0.0162 0.880 0.996 0.000 0.000 0.000 0.004
#> SRR1740083 1 0.0162 0.880 0.996 0.000 0.000 0.000 0.004
#> SRR1740084 1 0.0162 0.880 0.996 0.000 0.000 0.000 0.004
#> SRR1740085 1 0.0162 0.880 0.996 0.000 0.000 0.000 0.004
#> SRR1740086 1 0.4586 0.872 0.780 0.000 0.036 0.056 0.128
#> SRR1740087 1 0.4586 0.872 0.780 0.000 0.036 0.056 0.128
#> SRR1740088 1 0.4586 0.872 0.780 0.000 0.036 0.056 0.128
#> SRR1740089 1 0.4586 0.872 0.780 0.000 0.036 0.056 0.128
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740035 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740036 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740037 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740038 2 0.3390 0.896 0.152 0.808 0.000 0.000 0.032 0.008
#> SRR1740039 2 0.3390 0.896 0.152 0.808 0.000 0.000 0.032 0.008
#> SRR1740040 2 0.3390 0.896 0.152 0.808 0.000 0.000 0.032 0.008
#> SRR1740041 2 0.3390 0.896 0.152 0.808 0.000 0.000 0.032 0.008
#> SRR1740042 2 0.0713 0.895 0.000 0.972 0.028 0.000 0.000 0.000
#> SRR1740043 2 0.0713 0.895 0.000 0.972 0.028 0.000 0.000 0.000
#> SRR1740044 2 0.0713 0.895 0.000 0.972 0.028 0.000 0.000 0.000
#> SRR1740045 2 0.0713 0.895 0.000 0.972 0.028 0.000 0.000 0.000
#> SRR1740046 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1740048 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1740047 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1740049 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1740050 5 0.0790 1.000 0.000 0.000 0.000 0.000 0.968 0.032
#> SRR1740051 5 0.0790 1.000 0.000 0.000 0.000 0.000 0.968 0.032
#> SRR1740052 5 0.0790 1.000 0.000 0.000 0.000 0.000 0.968 0.032
#> SRR1740054 1 0.2378 1.000 0.848 0.000 0.000 0.000 0.000 0.152
#> SRR1740053 5 0.0790 1.000 0.000 0.000 0.000 0.000 0.968 0.032
#> SRR1740056 1 0.2378 1.000 0.848 0.000 0.000 0.000 0.000 0.152
#> SRR1740055 1 0.2378 1.000 0.848 0.000 0.000 0.000 0.000 0.152
#> SRR1740057 1 0.2378 1.000 0.848 0.000 0.000 0.000 0.000 0.152
#> SRR1740058 6 0.0260 1.000 0.000 0.000 0.000 0.008 0.000 0.992
#> SRR1740059 6 0.0260 1.000 0.000 0.000 0.000 0.008 0.000 0.992
#> SRR1740060 6 0.0260 1.000 0.000 0.000 0.000 0.008 0.000 0.992
#> SRR1740061 6 0.0260 1.000 0.000 0.000 0.000 0.008 0.000 0.992
#> SRR1740062 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740063 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740064 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740065 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740066 2 0.3390 0.896 0.152 0.808 0.000 0.000 0.032 0.008
#> SRR1740067 2 0.3390 0.896 0.152 0.808 0.000 0.000 0.032 0.008
#> SRR1740068 2 0.3390 0.896 0.152 0.808 0.000 0.000 0.032 0.008
#> SRR1740069 2 0.3390 0.896 0.152 0.808 0.000 0.000 0.032 0.008
#> SRR1740070 2 0.0713 0.895 0.000 0.972 0.028 0.000 0.000 0.000
#> SRR1740071 2 0.0713 0.895 0.000 0.972 0.028 0.000 0.000 0.000
#> SRR1740072 2 0.0713 0.895 0.000 0.972 0.028 0.000 0.000 0.000
#> SRR1740073 2 0.0713 0.895 0.000 0.972 0.028 0.000 0.000 0.000
#> SRR1740074 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1740075 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1740076 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1740077 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1740078 5 0.0790 1.000 0.000 0.000 0.000 0.000 0.968 0.032
#> SRR1740079 5 0.0790 1.000 0.000 0.000 0.000 0.000 0.968 0.032
#> SRR1740080 5 0.0790 1.000 0.000 0.000 0.000 0.000 0.968 0.032
#> SRR1740081 5 0.0790 1.000 0.000 0.000 0.000 0.000 0.968 0.032
#> SRR1740082 1 0.2378 1.000 0.848 0.000 0.000 0.000 0.000 0.152
#> SRR1740083 1 0.2378 1.000 0.848 0.000 0.000 0.000 0.000 0.152
#> SRR1740084 1 0.2378 1.000 0.848 0.000 0.000 0.000 0.000 0.152
#> SRR1740085 1 0.2378 1.000 0.848 0.000 0.000 0.000 0.000 0.152
#> SRR1740086 6 0.0260 1.000 0.000 0.000 0.000 0.008 0.000 0.992
#> SRR1740087 6 0.0260 1.000 0.000 0.000 0.000 0.008 0.000 0.992
#> SRR1740088 6 0.0260 1.000 0.000 0.000 0.000 0.008 0.000 0.992
#> SRR1740089 6 0.0260 1.000 0.000 0.000 0.000 0.008 0.000 0.992
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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.998 0.997 0.4965 0.501 0.501
#> 3 3 0.792 0.910 0.859 0.2138 0.875 0.751
#> 4 4 1.000 0.998 0.998 0.1729 0.917 0.779
#> 5 5 1.000 0.991 0.996 0.1168 0.897 0.660
#> 6 6 0.917 0.975 0.940 0.0533 0.949 0.762
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 4 5
There is also optional best \(k\) = 2 4 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1740034 1 0.0000 1.000 1.000 0.000
#> SRR1740035 1 0.0000 1.000 1.000 0.000
#> SRR1740036 1 0.0000 1.000 1.000 0.000
#> SRR1740037 1 0.0000 1.000 1.000 0.000
#> SRR1740038 2 0.0938 0.996 0.012 0.988
#> SRR1740039 2 0.0938 0.996 0.012 0.988
#> SRR1740040 2 0.0938 0.996 0.012 0.988
#> SRR1740041 2 0.0938 0.996 0.012 0.988
#> SRR1740042 2 0.0938 0.996 0.012 0.988
#> SRR1740043 2 0.0938 0.996 0.012 0.988
#> SRR1740044 2 0.0938 0.996 0.012 0.988
#> SRR1740045 2 0.0938 0.996 0.012 0.988
#> SRR1740046 2 0.0000 0.992 0.000 1.000
#> SRR1740048 2 0.0000 0.992 0.000 1.000
#> SRR1740047 2 0.0000 0.992 0.000 1.000
#> SRR1740049 2 0.0000 0.992 0.000 1.000
#> SRR1740050 1 0.0000 1.000 1.000 0.000
#> SRR1740051 1 0.0000 1.000 1.000 0.000
#> SRR1740052 1 0.0000 1.000 1.000 0.000
#> SRR1740054 1 0.0000 1.000 1.000 0.000
#> SRR1740053 1 0.0000 1.000 1.000 0.000
#> SRR1740056 1 0.0000 1.000 1.000 0.000
#> SRR1740055 1 0.0000 1.000 1.000 0.000
#> SRR1740057 1 0.0000 1.000 1.000 0.000
#> SRR1740058 1 0.0000 1.000 1.000 0.000
#> SRR1740059 1 0.0000 1.000 1.000 0.000
#> SRR1740060 1 0.0000 1.000 1.000 0.000
#> SRR1740061 1 0.0000 1.000 1.000 0.000
#> SRR1740062 1 0.0000 1.000 1.000 0.000
#> SRR1740063 1 0.0000 1.000 1.000 0.000
#> SRR1740064 1 0.0000 1.000 1.000 0.000
#> SRR1740065 1 0.0000 1.000 1.000 0.000
#> SRR1740066 2 0.0938 0.996 0.012 0.988
#> SRR1740067 2 0.0938 0.996 0.012 0.988
#> SRR1740068 2 0.0938 0.996 0.012 0.988
#> SRR1740069 2 0.0938 0.996 0.012 0.988
#> SRR1740070 2 0.0938 0.996 0.012 0.988
#> SRR1740071 2 0.0938 0.996 0.012 0.988
#> SRR1740072 2 0.0938 0.996 0.012 0.988
#> SRR1740073 2 0.0938 0.996 0.012 0.988
#> SRR1740074 2 0.0000 0.992 0.000 1.000
#> SRR1740075 2 0.0000 0.992 0.000 1.000
#> SRR1740076 2 0.0000 0.992 0.000 1.000
#> SRR1740077 2 0.0000 0.992 0.000 1.000
#> SRR1740078 1 0.0000 1.000 1.000 0.000
#> SRR1740079 1 0.0000 1.000 1.000 0.000
#> SRR1740080 1 0.0000 1.000 1.000 0.000
#> SRR1740081 1 0.0000 1.000 1.000 0.000
#> SRR1740082 1 0.0000 1.000 1.000 0.000
#> SRR1740083 1 0.0000 1.000 1.000 0.000
#> SRR1740084 1 0.0000 1.000 1.000 0.000
#> SRR1740085 1 0.0000 1.000 1.000 0.000
#> SRR1740086 1 0.0000 1.000 1.000 0.000
#> SRR1740087 1 0.0000 1.000 1.000 0.000
#> SRR1740088 1 0.0000 1.000 1.000 0.000
#> SRR1740089 1 0.0000 1.000 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 3 0.630 1.000 0.484 0.000 0.516
#> SRR1740035 3 0.630 1.000 0.484 0.000 0.516
#> SRR1740036 3 0.630 1.000 0.484 0.000 0.516
#> SRR1740037 3 0.630 1.000 0.484 0.000 0.516
#> SRR1740038 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740039 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740040 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740041 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740042 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740043 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740044 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740045 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740046 2 0.000 0.670 0.000 1.000 0.000
#> SRR1740048 2 0.000 0.670 0.000 1.000 0.000
#> SRR1740047 2 0.000 0.670 0.000 1.000 0.000
#> SRR1740049 2 0.000 0.670 0.000 1.000 0.000
#> SRR1740050 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740051 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740052 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740054 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740053 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740056 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740055 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740057 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740058 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740059 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740060 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740061 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740062 3 0.630 1.000 0.484 0.000 0.516
#> SRR1740063 3 0.630 1.000 0.484 0.000 0.516
#> SRR1740064 3 0.630 1.000 0.484 0.000 0.516
#> SRR1740065 3 0.630 1.000 0.484 0.000 0.516
#> SRR1740066 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740067 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740068 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740069 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740070 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740071 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740072 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740073 2 0.668 0.851 0.008 0.508 0.484
#> SRR1740074 2 0.000 0.670 0.000 1.000 0.000
#> SRR1740075 2 0.000 0.670 0.000 1.000 0.000
#> SRR1740076 2 0.000 0.670 0.000 1.000 0.000
#> SRR1740077 2 0.000 0.670 0.000 1.000 0.000
#> SRR1740078 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740079 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740080 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740081 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740082 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740083 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740084 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740085 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740086 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740087 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740088 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740089 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
#> SRR1740034 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740035 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740036 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740037 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740038 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740039 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740040 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740041 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740042 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740043 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740044 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740045 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740046 3 0.0336 1.000 0.000 0.008 0.992 0
#> SRR1740048 3 0.0336 1.000 0.000 0.008 0.992 0
#> SRR1740047 3 0.0336 1.000 0.000 0.008 0.992 0
#> SRR1740049 3 0.0336 1.000 0.000 0.008 0.992 0
#> SRR1740050 1 0.0336 0.995 0.992 0.000 0.008 0
#> SRR1740051 1 0.0336 0.995 0.992 0.000 0.008 0
#> SRR1740052 1 0.0336 0.995 0.992 0.000 0.008 0
#> SRR1740054 1 0.0000 0.997 1.000 0.000 0.000 0
#> SRR1740053 1 0.0336 0.995 0.992 0.000 0.008 0
#> SRR1740056 1 0.0000 0.997 1.000 0.000 0.000 0
#> SRR1740055 1 0.0336 0.991 0.992 0.008 0.000 0
#> SRR1740057 1 0.0000 0.997 1.000 0.000 0.000 0
#> SRR1740058 1 0.0000 0.997 1.000 0.000 0.000 0
#> SRR1740059 1 0.0000 0.997 1.000 0.000 0.000 0
#> SRR1740060 1 0.0000 0.997 1.000 0.000 0.000 0
#> SRR1740061 1 0.0000 0.997 1.000 0.000 0.000 0
#> SRR1740062 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740063 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740064 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740065 4 0.0000 1.000 0.000 0.000 0.000 1
#> SRR1740066 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740067 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740068 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740069 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740070 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740071 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740072 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740073 2 0.0000 1.000 0.000 1.000 0.000 0
#> SRR1740074 3 0.0336 1.000 0.000 0.008 0.992 0
#> SRR1740075 3 0.0336 1.000 0.000 0.008 0.992 0
#> SRR1740076 3 0.0336 1.000 0.000 0.008 0.992 0
#> SRR1740077 3 0.0336 1.000 0.000 0.008 0.992 0
#> SRR1740078 1 0.0336 0.995 0.992 0.000 0.008 0
#> SRR1740079 1 0.0336 0.995 0.992 0.000 0.008 0
#> SRR1740080 1 0.0336 0.995 0.992 0.000 0.008 0
#> SRR1740081 1 0.0336 0.995 0.992 0.000 0.008 0
#> SRR1740082 1 0.0000 0.997 1.000 0.000 0.000 0
#> SRR1740083 1 0.0000 0.997 1.000 0.000 0.000 0
#> SRR1740084 1 0.0000 0.997 1.000 0.000 0.000 0
#> SRR1740085 1 0.0000 0.997 1.000 0.000 0.000 0
#> SRR1740086 1 0.0000 0.997 1.000 0.000 0.000 0
#> SRR1740087 1 0.0000 0.997 1.000 0.000 0.000 0
#> SRR1740088 1 0.0000 0.997 1.000 0.000 0.000 0
#> SRR1740089 1 0.0000 0.997 1.000 0.000 0.000 0
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.000 1.000 0.000 0.000 0 1 0
#> SRR1740035 4 0.000 1.000 0.000 0.000 0 1 0
#> SRR1740036 4 0.000 1.000 0.000 0.000 0 1 0
#> SRR1740037 4 0.000 1.000 0.000 0.000 0 1 0
#> SRR1740038 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740039 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740040 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740041 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740042 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740043 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740044 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740045 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740046 3 0.000 1.000 0.000 0.000 1 0 0
#> SRR1740048 3 0.000 1.000 0.000 0.000 1 0 0
#> SRR1740047 3 0.000 1.000 0.000 0.000 1 0 0
#> SRR1740049 3 0.000 1.000 0.000 0.000 1 0 0
#> SRR1740050 5 0.000 1.000 0.000 0.000 0 0 1
#> SRR1740051 5 0.000 1.000 0.000 0.000 0 0 1
#> SRR1740052 5 0.000 1.000 0.000 0.000 0 0 1
#> SRR1740054 1 0.000 1.000 1.000 0.000 0 0 0
#> SRR1740053 5 0.000 1.000 0.000 0.000 0 0 1
#> SRR1740056 1 0.000 1.000 1.000 0.000 0 0 0
#> SRR1740055 2 0.314 0.740 0.204 0.796 0 0 0
#> SRR1740057 1 0.000 1.000 1.000 0.000 0 0 0
#> SRR1740058 1 0.000 1.000 1.000 0.000 0 0 0
#> SRR1740059 1 0.000 1.000 1.000 0.000 0 0 0
#> SRR1740060 1 0.000 1.000 1.000 0.000 0 0 0
#> SRR1740061 1 0.000 1.000 1.000 0.000 0 0 0
#> SRR1740062 4 0.000 1.000 0.000 0.000 0 1 0
#> SRR1740063 4 0.000 1.000 0.000 0.000 0 1 0
#> SRR1740064 4 0.000 1.000 0.000 0.000 0 1 0
#> SRR1740065 4 0.000 1.000 0.000 0.000 0 1 0
#> SRR1740066 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740067 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740068 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740069 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740070 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740071 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740072 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740073 2 0.000 0.985 0.000 1.000 0 0 0
#> SRR1740074 3 0.000 1.000 0.000 0.000 1 0 0
#> SRR1740075 3 0.000 1.000 0.000 0.000 1 0 0
#> SRR1740076 3 0.000 1.000 0.000 0.000 1 0 0
#> SRR1740077 3 0.000 1.000 0.000 0.000 1 0 0
#> SRR1740078 5 0.000 1.000 0.000 0.000 0 0 1
#> SRR1740079 5 0.000 1.000 0.000 0.000 0 0 1
#> SRR1740080 5 0.000 1.000 0.000 0.000 0 0 1
#> SRR1740081 5 0.000 1.000 0.000 0.000 0 0 1
#> SRR1740082 1 0.000 1.000 1.000 0.000 0 0 0
#> SRR1740083 1 0.000 1.000 1.000 0.000 0 0 0
#> SRR1740084 1 0.000 1.000 1.000 0.000 0 0 0
#> SRR1740085 1 0.000 1.000 1.000 0.000 0 0 0
#> SRR1740086 1 0.000 1.000 1.000 0.000 0 0 0
#> SRR1740087 1 0.000 1.000 1.000 0.000 0 0 0
#> SRR1740088 1 0.000 1.000 1.000 0.000 0 0 0
#> SRR1740089 1 0.000 1.000 1.000 0.000 0 0 0
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740035 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740036 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740037 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740038 2 0.0000 0.913 0.000 1.000 0 0 0 0.000
#> SRR1740039 2 0.0000 0.913 0.000 1.000 0 0 0 0.000
#> SRR1740040 2 0.0000 0.913 0.000 1.000 0 0 0 0.000
#> SRR1740041 2 0.0000 0.913 0.000 1.000 0 0 0 0.000
#> SRR1740042 2 0.2697 0.913 0.000 0.812 0 0 0 0.188
#> SRR1740043 2 0.2697 0.913 0.000 0.812 0 0 0 0.188
#> SRR1740044 2 0.2697 0.913 0.000 0.812 0 0 0 0.188
#> SRR1740045 2 0.2697 0.913 0.000 0.812 0 0 0 0.188
#> SRR1740046 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740048 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740047 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740049 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740050 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740051 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740052 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740054 1 0.0000 0.999 1.000 0.000 0 0 0 0.000
#> SRR1740053 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740056 1 0.0000 0.999 1.000 0.000 0 0 0 0.000
#> SRR1740055 1 0.0146 0.994 0.996 0.000 0 0 0 0.004
#> SRR1740057 1 0.0000 0.999 1.000 0.000 0 0 0 0.000
#> SRR1740058 6 0.2697 1.000 0.188 0.000 0 0 0 0.812
#> SRR1740059 6 0.2697 1.000 0.188 0.000 0 0 0 0.812
#> SRR1740060 6 0.2697 1.000 0.188 0.000 0 0 0 0.812
#> SRR1740061 6 0.2697 1.000 0.188 0.000 0 0 0 0.812
#> SRR1740062 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740063 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740064 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740065 4 0.0000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740066 2 0.0000 0.913 0.000 1.000 0 0 0 0.000
#> SRR1740067 2 0.0000 0.913 0.000 1.000 0 0 0 0.000
#> SRR1740068 2 0.0000 0.913 0.000 1.000 0 0 0 0.000
#> SRR1740069 2 0.0000 0.913 0.000 1.000 0 0 0 0.000
#> SRR1740070 2 0.2697 0.913 0.000 0.812 0 0 0 0.188
#> SRR1740071 2 0.2697 0.913 0.000 0.812 0 0 0 0.188
#> SRR1740072 2 0.2697 0.913 0.000 0.812 0 0 0 0.188
#> SRR1740073 2 0.2697 0.913 0.000 0.812 0 0 0 0.188
#> SRR1740074 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740075 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740076 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740077 3 0.0000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740078 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740079 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740080 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740081 5 0.0000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740082 1 0.0000 0.999 1.000 0.000 0 0 0 0.000
#> SRR1740083 1 0.0000 0.999 1.000 0.000 0 0 0 0.000
#> SRR1740084 1 0.0000 0.999 1.000 0.000 0 0 0 0.000
#> SRR1740085 1 0.0000 0.999 1.000 0.000 0 0 0 0.000
#> SRR1740086 6 0.2697 1.000 0.188 0.000 0 0 0 0.812
#> SRR1740087 6 0.2697 1.000 0.188 0.000 0 0 0 0.812
#> SRR1740088 6 0.2697 1.000 0.188 0.000 0 0 0 0.812
#> SRR1740089 6 0.2697 1.000 0.188 0.000 0 0 0 0.812
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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1 0.984 0.988 0.4971 0.501 0.501
#> 3 3 1 0.996 0.997 0.3345 0.751 0.541
#> 4 4 1 1.000 1.000 0.0655 0.958 0.876
#> 5 5 1 0.994 0.994 0.1175 0.917 0.717
#> 6 6 1 0.998 0.995 0.0522 0.958 0.802
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
#> SRR1740034 1 0.2778 0.963 0.952 0.048
#> SRR1740035 1 0.2778 0.963 0.952 0.048
#> SRR1740036 1 0.2778 0.963 0.952 0.048
#> SRR1740037 1 0.2778 0.963 0.952 0.048
#> SRR1740038 2 0.0376 0.991 0.004 0.996
#> SRR1740039 2 0.0376 0.991 0.004 0.996
#> SRR1740040 2 0.0376 0.991 0.004 0.996
#> SRR1740041 2 0.0376 0.991 0.004 0.996
#> SRR1740042 2 0.0376 0.991 0.004 0.996
#> SRR1740043 2 0.0376 0.991 0.004 0.996
#> SRR1740044 2 0.0376 0.991 0.004 0.996
#> SRR1740045 2 0.0376 0.991 0.004 0.996
#> SRR1740046 2 0.1633 0.982 0.024 0.976
#> SRR1740048 2 0.1633 0.982 0.024 0.976
#> SRR1740047 2 0.1633 0.982 0.024 0.976
#> SRR1740049 2 0.1633 0.982 0.024 0.976
#> SRR1740050 1 0.0000 0.987 1.000 0.000
#> SRR1740051 1 0.0000 0.987 1.000 0.000
#> SRR1740052 1 0.0000 0.987 1.000 0.000
#> SRR1740054 1 0.0376 0.986 0.996 0.004
#> SRR1740053 1 0.0000 0.987 1.000 0.000
#> SRR1740056 1 0.0376 0.986 0.996 0.004
#> SRR1740055 1 0.0376 0.986 0.996 0.004
#> SRR1740057 1 0.0376 0.986 0.996 0.004
#> SRR1740058 1 0.0000 0.987 1.000 0.000
#> SRR1740059 1 0.0000 0.987 1.000 0.000
#> SRR1740060 1 0.0000 0.987 1.000 0.000
#> SRR1740061 1 0.0000 0.987 1.000 0.000
#> SRR1740062 1 0.2778 0.963 0.952 0.048
#> SRR1740063 1 0.2778 0.963 0.952 0.048
#> SRR1740064 1 0.2778 0.963 0.952 0.048
#> SRR1740065 1 0.2778 0.963 0.952 0.048
#> SRR1740066 2 0.0376 0.991 0.004 0.996
#> SRR1740067 2 0.0376 0.991 0.004 0.996
#> SRR1740068 2 0.0376 0.991 0.004 0.996
#> SRR1740069 2 0.0376 0.991 0.004 0.996
#> SRR1740070 2 0.0376 0.991 0.004 0.996
#> SRR1740071 2 0.0376 0.991 0.004 0.996
#> SRR1740072 2 0.0376 0.991 0.004 0.996
#> SRR1740073 2 0.0376 0.991 0.004 0.996
#> SRR1740074 2 0.1633 0.982 0.024 0.976
#> SRR1740075 2 0.1633 0.982 0.024 0.976
#> SRR1740076 2 0.1633 0.982 0.024 0.976
#> SRR1740077 2 0.1633 0.982 0.024 0.976
#> SRR1740078 1 0.0000 0.987 1.000 0.000
#> SRR1740079 1 0.0000 0.987 1.000 0.000
#> SRR1740080 1 0.0000 0.987 1.000 0.000
#> SRR1740081 1 0.0000 0.987 1.000 0.000
#> SRR1740082 1 0.0376 0.986 0.996 0.004
#> SRR1740083 1 0.0376 0.986 0.996 0.004
#> SRR1740084 1 0.0376 0.986 0.996 0.004
#> SRR1740085 1 0.0376 0.986 0.996 0.004
#> SRR1740086 1 0.0000 0.987 1.000 0.000
#> SRR1740087 1 0.0000 0.987 1.000 0.000
#> SRR1740088 1 0.0000 0.987 1.000 0.000
#> SRR1740089 1 0.0000 0.987 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 3 0.103 0.986 0.024 0 0.976
#> SRR1740035 3 0.103 0.986 0.024 0 0.976
#> SRR1740036 3 0.103 0.986 0.024 0 0.976
#> SRR1740037 3 0.103 0.986 0.024 0 0.976
#> SRR1740038 2 0.000 1.000 0.000 1 0.000
#> SRR1740039 2 0.000 1.000 0.000 1 0.000
#> SRR1740040 2 0.000 1.000 0.000 1 0.000
#> SRR1740041 2 0.000 1.000 0.000 1 0.000
#> SRR1740042 2 0.000 1.000 0.000 1 0.000
#> SRR1740043 2 0.000 1.000 0.000 1 0.000
#> SRR1740044 2 0.000 1.000 0.000 1 0.000
#> SRR1740045 2 0.000 1.000 0.000 1 0.000
#> SRR1740046 3 0.000 0.986 0.000 0 1.000
#> SRR1740048 3 0.000 0.986 0.000 0 1.000
#> SRR1740047 3 0.000 0.986 0.000 0 1.000
#> SRR1740049 3 0.000 0.986 0.000 0 1.000
#> SRR1740050 1 0.000 1.000 1.000 0 0.000
#> SRR1740051 1 0.000 1.000 1.000 0 0.000
#> SRR1740052 1 0.000 1.000 1.000 0 0.000
#> SRR1740054 1 0.000 1.000 1.000 0 0.000
#> SRR1740053 1 0.000 1.000 1.000 0 0.000
#> SRR1740056 1 0.000 1.000 1.000 0 0.000
#> SRR1740055 1 0.000 1.000 1.000 0 0.000
#> SRR1740057 1 0.000 1.000 1.000 0 0.000
#> SRR1740058 1 0.000 1.000 1.000 0 0.000
#> SRR1740059 1 0.000 1.000 1.000 0 0.000
#> SRR1740060 1 0.000 1.000 1.000 0 0.000
#> SRR1740061 1 0.000 1.000 1.000 0 0.000
#> SRR1740062 3 0.103 0.986 0.024 0 0.976
#> SRR1740063 3 0.103 0.986 0.024 0 0.976
#> SRR1740064 3 0.103 0.986 0.024 0 0.976
#> SRR1740065 3 0.103 0.986 0.024 0 0.976
#> SRR1740066 2 0.000 1.000 0.000 1 0.000
#> SRR1740067 2 0.000 1.000 0.000 1 0.000
#> SRR1740068 2 0.000 1.000 0.000 1 0.000
#> SRR1740069 2 0.000 1.000 0.000 1 0.000
#> SRR1740070 2 0.000 1.000 0.000 1 0.000
#> SRR1740071 2 0.000 1.000 0.000 1 0.000
#> SRR1740072 2 0.000 1.000 0.000 1 0.000
#> SRR1740073 2 0.000 1.000 0.000 1 0.000
#> SRR1740074 3 0.000 0.986 0.000 0 1.000
#> SRR1740075 3 0.000 0.986 0.000 0 1.000
#> SRR1740076 3 0.000 0.986 0.000 0 1.000
#> SRR1740077 3 0.000 0.986 0.000 0 1.000
#> SRR1740078 1 0.000 1.000 1.000 0 0.000
#> SRR1740079 1 0.000 1.000 1.000 0 0.000
#> SRR1740080 1 0.000 1.000 1.000 0 0.000
#> SRR1740081 1 0.000 1.000 1.000 0 0.000
#> SRR1740082 1 0.000 1.000 1.000 0 0.000
#> SRR1740083 1 0.000 1.000 1.000 0 0.000
#> SRR1740084 1 0.000 1.000 1.000 0 0.000
#> SRR1740085 1 0.000 1.000 1.000 0 0.000
#> SRR1740086 1 0.000 1.000 1.000 0 0.000
#> SRR1740087 1 0.000 1.000 1.000 0 0.000
#> SRR1740088 1 0.000 1.000 1.000 0 0.000
#> SRR1740089 1 0.000 1.000 1.000 0 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 4 0 1 0 0 0 1
#> SRR1740035 4 0 1 0 0 0 1
#> SRR1740036 4 0 1 0 0 0 1
#> SRR1740037 4 0 1 0 0 0 1
#> SRR1740038 2 0 1 0 1 0 0
#> SRR1740039 2 0 1 0 1 0 0
#> SRR1740040 2 0 1 0 1 0 0
#> SRR1740041 2 0 1 0 1 0 0
#> SRR1740042 2 0 1 0 1 0 0
#> SRR1740043 2 0 1 0 1 0 0
#> SRR1740044 2 0 1 0 1 0 0
#> SRR1740045 2 0 1 0 1 0 0
#> SRR1740046 3 0 1 0 0 1 0
#> SRR1740048 3 0 1 0 0 1 0
#> SRR1740047 3 0 1 0 0 1 0
#> SRR1740049 3 0 1 0 0 1 0
#> SRR1740050 1 0 1 1 0 0 0
#> SRR1740051 1 0 1 1 0 0 0
#> SRR1740052 1 0 1 1 0 0 0
#> SRR1740054 1 0 1 1 0 0 0
#> SRR1740053 1 0 1 1 0 0 0
#> SRR1740056 1 0 1 1 0 0 0
#> SRR1740055 1 0 1 1 0 0 0
#> SRR1740057 1 0 1 1 0 0 0
#> SRR1740058 1 0 1 1 0 0 0
#> SRR1740059 1 0 1 1 0 0 0
#> SRR1740060 1 0 1 1 0 0 0
#> SRR1740061 1 0 1 1 0 0 0
#> SRR1740062 4 0 1 0 0 0 1
#> SRR1740063 4 0 1 0 0 0 1
#> SRR1740064 4 0 1 0 0 0 1
#> SRR1740065 4 0 1 0 0 0 1
#> SRR1740066 2 0 1 0 1 0 0
#> SRR1740067 2 0 1 0 1 0 0
#> SRR1740068 2 0 1 0 1 0 0
#> SRR1740069 2 0 1 0 1 0 0
#> SRR1740070 2 0 1 0 1 0 0
#> SRR1740071 2 0 1 0 1 0 0
#> SRR1740072 2 0 1 0 1 0 0
#> SRR1740073 2 0 1 0 1 0 0
#> SRR1740074 3 0 1 0 0 1 0
#> SRR1740075 3 0 1 0 0 1 0
#> SRR1740076 3 0 1 0 0 1 0
#> SRR1740077 3 0 1 0 0 1 0
#> SRR1740078 1 0 1 1 0 0 0
#> SRR1740079 1 0 1 1 0 0 0
#> SRR1740080 1 0 1 1 0 0 0
#> SRR1740081 1 0 1 1 0 0 0
#> SRR1740082 1 0 1 1 0 0 0
#> SRR1740083 1 0 1 1 0 0 0
#> SRR1740084 1 0 1 1 0 0 0
#> SRR1740085 1 0 1 1 0 0 0
#> SRR1740086 1 0 1 1 0 0 0
#> SRR1740087 1 0 1 1 0 0 0
#> SRR1740088 1 0 1 1 0 0 0
#> SRR1740089 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
#> SRR1740034 4 0.000 1.000 0.00 0 0 1 0.00
#> SRR1740035 4 0.000 1.000 0.00 0 0 1 0.00
#> SRR1740036 4 0.000 1.000 0.00 0 0 1 0.00
#> SRR1740037 4 0.000 1.000 0.00 0 0 1 0.00
#> SRR1740038 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740039 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740040 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740041 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740042 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740043 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740044 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740045 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740046 3 0.000 1.000 0.00 0 1 0 0.00
#> SRR1740048 3 0.000 1.000 0.00 0 1 0 0.00
#> SRR1740047 3 0.000 1.000 0.00 0 1 0 0.00
#> SRR1740049 3 0.000 1.000 0.00 0 1 0 0.00
#> SRR1740050 5 0.000 0.978 0.00 0 0 0 1.00
#> SRR1740051 5 0.000 0.978 0.00 0 0 0 1.00
#> SRR1740052 5 0.000 0.978 0.00 0 0 0 1.00
#> SRR1740054 1 0.000 1.000 1.00 0 0 0 0.00
#> SRR1740053 5 0.000 0.978 0.00 0 0 0 1.00
#> SRR1740056 1 0.000 1.000 1.00 0 0 0 0.00
#> SRR1740055 1 0.000 1.000 1.00 0 0 0 0.00
#> SRR1740057 1 0.000 1.000 1.00 0 0 0 0.00
#> SRR1740058 5 0.104 0.978 0.04 0 0 0 0.96
#> SRR1740059 5 0.104 0.978 0.04 0 0 0 0.96
#> SRR1740060 5 0.104 0.978 0.04 0 0 0 0.96
#> SRR1740061 5 0.104 0.978 0.04 0 0 0 0.96
#> SRR1740062 4 0.000 1.000 0.00 0 0 1 0.00
#> SRR1740063 4 0.000 1.000 0.00 0 0 1 0.00
#> SRR1740064 4 0.000 1.000 0.00 0 0 1 0.00
#> SRR1740065 4 0.000 1.000 0.00 0 0 1 0.00
#> SRR1740066 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740067 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740068 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740069 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740070 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740071 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740072 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740073 2 0.000 1.000 0.00 1 0 0 0.00
#> SRR1740074 3 0.000 1.000 0.00 0 1 0 0.00
#> SRR1740075 3 0.000 1.000 0.00 0 1 0 0.00
#> SRR1740076 3 0.000 1.000 0.00 0 1 0 0.00
#> SRR1740077 3 0.000 1.000 0.00 0 1 0 0.00
#> SRR1740078 5 0.000 0.978 0.00 0 0 0 1.00
#> SRR1740079 5 0.000 0.978 0.00 0 0 0 1.00
#> SRR1740080 5 0.000 0.978 0.00 0 0 0 1.00
#> SRR1740081 5 0.000 0.978 0.00 0 0 0 1.00
#> SRR1740082 1 0.000 1.000 1.00 0 0 0 0.00
#> SRR1740083 1 0.000 1.000 1.00 0 0 0 0.00
#> SRR1740084 1 0.000 1.000 1.00 0 0 0 0.00
#> SRR1740085 1 0.000 1.000 1.00 0 0 0 0.00
#> SRR1740086 5 0.104 0.978 0.04 0 0 0 0.96
#> SRR1740087 5 0.104 0.978 0.04 0 0 0 0.96
#> SRR1740088 5 0.104 0.978 0.04 0 0 0 0.96
#> SRR1740089 5 0.104 0.978 0.04 0 0 0 0.96
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.0000 1.000 0.000 0.000 0 1 0.00 0.000
#> SRR1740035 4 0.0000 1.000 0.000 0.000 0 1 0.00 0.000
#> SRR1740036 4 0.0000 1.000 0.000 0.000 0 1 0.00 0.000
#> SRR1740037 4 0.0000 1.000 0.000 0.000 0 1 0.00 0.000
#> SRR1740038 2 0.0000 0.995 0.000 1.000 0 0 0.00 0.000
#> SRR1740039 2 0.0000 0.995 0.000 1.000 0 0 0.00 0.000
#> SRR1740040 2 0.0000 0.995 0.000 1.000 0 0 0.00 0.000
#> SRR1740041 2 0.0000 0.995 0.000 1.000 0 0 0.00 0.000
#> SRR1740042 2 0.0363 0.995 0.000 0.988 0 0 0.00 0.012
#> SRR1740043 2 0.0363 0.995 0.000 0.988 0 0 0.00 0.012
#> SRR1740044 2 0.0363 0.995 0.000 0.988 0 0 0.00 0.012
#> SRR1740045 2 0.0363 0.995 0.000 0.988 0 0 0.00 0.012
#> SRR1740046 3 0.0000 1.000 0.000 0.000 1 0 0.00 0.000
#> SRR1740048 3 0.0000 1.000 0.000 0.000 1 0 0.00 0.000
#> SRR1740047 3 0.0000 1.000 0.000 0.000 1 0 0.00 0.000
#> SRR1740049 3 0.0000 1.000 0.000 0.000 1 0 0.00 0.000
#> SRR1740050 5 0.0000 1.000 0.000 0.000 0 0 1.00 0.000
#> SRR1740051 5 0.0000 1.000 0.000 0.000 0 0 1.00 0.000
#> SRR1740052 5 0.0000 1.000 0.000 0.000 0 0 1.00 0.000
#> SRR1740054 1 0.0000 0.998 1.000 0.000 0 0 0.00 0.000
#> SRR1740053 5 0.0000 1.000 0.000 0.000 0 0 1.00 0.000
#> SRR1740056 1 0.0000 0.998 1.000 0.000 0 0 0.00 0.000
#> SRR1740055 1 0.0000 0.998 1.000 0.000 0 0 0.00 0.000
#> SRR1740057 1 0.0260 0.996 0.992 0.000 0 0 0.00 0.008
#> SRR1740058 6 0.0547 1.000 0.000 0.000 0 0 0.02 0.980
#> SRR1740059 6 0.0547 1.000 0.000 0.000 0 0 0.02 0.980
#> SRR1740060 6 0.0547 1.000 0.000 0.000 0 0 0.02 0.980
#> SRR1740061 6 0.0547 1.000 0.000 0.000 0 0 0.02 0.980
#> SRR1740062 4 0.0000 1.000 0.000 0.000 0 1 0.00 0.000
#> SRR1740063 4 0.0000 1.000 0.000 0.000 0 1 0.00 0.000
#> SRR1740064 4 0.0000 1.000 0.000 0.000 0 1 0.00 0.000
#> SRR1740065 4 0.0000 1.000 0.000 0.000 0 1 0.00 0.000
#> SRR1740066 2 0.0000 0.995 0.000 1.000 0 0 0.00 0.000
#> SRR1740067 2 0.0000 0.995 0.000 1.000 0 0 0.00 0.000
#> SRR1740068 2 0.0000 0.995 0.000 1.000 0 0 0.00 0.000
#> SRR1740069 2 0.0000 0.995 0.000 1.000 0 0 0.00 0.000
#> SRR1740070 2 0.0363 0.995 0.000 0.988 0 0 0.00 0.012
#> SRR1740071 2 0.0363 0.995 0.000 0.988 0 0 0.00 0.012
#> SRR1740072 2 0.0363 0.995 0.000 0.988 0 0 0.00 0.012
#> SRR1740073 2 0.0363 0.995 0.000 0.988 0 0 0.00 0.012
#> SRR1740074 3 0.0000 1.000 0.000 0.000 1 0 0.00 0.000
#> SRR1740075 3 0.0000 1.000 0.000 0.000 1 0 0.00 0.000
#> SRR1740076 3 0.0000 1.000 0.000 0.000 1 0 0.00 0.000
#> SRR1740077 3 0.0000 1.000 0.000 0.000 1 0 0.00 0.000
#> SRR1740078 5 0.0000 1.000 0.000 0.000 0 0 1.00 0.000
#> SRR1740079 5 0.0000 1.000 0.000 0.000 0 0 1.00 0.000
#> SRR1740080 5 0.0000 1.000 0.000 0.000 0 0 1.00 0.000
#> SRR1740081 5 0.0000 1.000 0.000 0.000 0 0 1.00 0.000
#> SRR1740082 1 0.0260 0.996 0.992 0.000 0 0 0.00 0.008
#> SRR1740083 1 0.0000 0.998 1.000 0.000 0 0 0.00 0.000
#> SRR1740084 1 0.0000 0.998 1.000 0.000 0 0 0.00 0.000
#> SRR1740085 1 0.0260 0.996 0.992 0.000 0 0 0.00 0.008
#> SRR1740086 6 0.0547 1.000 0.000 0.000 0 0 0.02 0.980
#> SRR1740087 6 0.0547 1.000 0.000 0.000 0 0 0.02 0.980
#> SRR1740088 6 0.0547 1.000 0.000 0.000 0 0 0.02 0.980
#> SRR1740089 6 0.0547 1.000 0.000 0.000 0 0 0.02 0.980
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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.938 0.969 0.969 0.4968 0.501 0.501
#> 3 3 0.792 0.911 0.885 0.2335 0.875 0.751
#> 4 4 0.834 0.954 0.930 0.1544 0.917 0.779
#> 5 5 0.878 0.962 0.947 0.1095 0.917 0.717
#> 6 6 0.925 0.839 0.874 0.0625 0.918 0.635
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1740034 1 0.4562 0.934 0.904 0.096
#> SRR1740035 1 0.4562 0.934 0.904 0.096
#> SRR1740036 1 0.4562 0.934 0.904 0.096
#> SRR1740037 1 0.4562 0.934 0.904 0.096
#> SRR1740038 2 0.2043 0.981 0.032 0.968
#> SRR1740039 2 0.2043 0.981 0.032 0.968
#> SRR1740040 2 0.2043 0.981 0.032 0.968
#> SRR1740041 2 0.2043 0.981 0.032 0.968
#> SRR1740042 2 0.2043 0.981 0.032 0.968
#> SRR1740043 2 0.2043 0.981 0.032 0.968
#> SRR1740044 2 0.2043 0.981 0.032 0.968
#> SRR1740045 2 0.2043 0.981 0.032 0.968
#> SRR1740046 2 0.2603 0.962 0.044 0.956
#> SRR1740048 2 0.2603 0.962 0.044 0.956
#> SRR1740047 2 0.2603 0.962 0.044 0.956
#> SRR1740049 2 0.2603 0.962 0.044 0.956
#> SRR1740050 1 0.0672 0.975 0.992 0.008
#> SRR1740051 1 0.0672 0.975 0.992 0.008
#> SRR1740052 1 0.0672 0.975 0.992 0.008
#> SRR1740054 1 0.0672 0.975 0.992 0.008
#> SRR1740053 1 0.0672 0.975 0.992 0.008
#> SRR1740056 1 0.0672 0.975 0.992 0.008
#> SRR1740055 1 0.0672 0.975 0.992 0.008
#> SRR1740057 1 0.0672 0.975 0.992 0.008
#> SRR1740058 1 0.0000 0.976 1.000 0.000
#> SRR1740059 1 0.0000 0.976 1.000 0.000
#> SRR1740060 1 0.0000 0.976 1.000 0.000
#> SRR1740061 1 0.0000 0.976 1.000 0.000
#> SRR1740062 1 0.4562 0.934 0.904 0.096
#> SRR1740063 1 0.4562 0.934 0.904 0.096
#> SRR1740064 1 0.4562 0.934 0.904 0.096
#> SRR1740065 1 0.4562 0.934 0.904 0.096
#> SRR1740066 2 0.2043 0.981 0.032 0.968
#> SRR1740067 2 0.2043 0.981 0.032 0.968
#> SRR1740068 2 0.2043 0.981 0.032 0.968
#> SRR1740069 2 0.2043 0.981 0.032 0.968
#> SRR1740070 2 0.2043 0.981 0.032 0.968
#> SRR1740071 2 0.2043 0.981 0.032 0.968
#> SRR1740072 2 0.2043 0.981 0.032 0.968
#> SRR1740073 2 0.2043 0.981 0.032 0.968
#> SRR1740074 2 0.2603 0.962 0.044 0.956
#> SRR1740075 2 0.2603 0.962 0.044 0.956
#> SRR1740076 2 0.2603 0.962 0.044 0.956
#> SRR1740077 2 0.2603 0.962 0.044 0.956
#> SRR1740078 1 0.0672 0.975 0.992 0.008
#> SRR1740079 1 0.0672 0.975 0.992 0.008
#> SRR1740080 1 0.0672 0.975 0.992 0.008
#> SRR1740081 1 0.0672 0.975 0.992 0.008
#> SRR1740082 1 0.0000 0.976 1.000 0.000
#> SRR1740083 1 0.0000 0.976 1.000 0.000
#> SRR1740084 1 0.0000 0.976 1.000 0.000
#> SRR1740085 1 0.0000 0.976 1.000 0.000
#> SRR1740086 1 0.0000 0.976 1.000 0.000
#> SRR1740087 1 0.0000 0.976 1.000 0.000
#> SRR1740088 1 0.0000 0.976 1.000 0.000
#> SRR1740089 1 0.0000 0.976 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 3 0.0747 1.000 0.000 0.016 0.984
#> SRR1740035 3 0.0747 1.000 0.000 0.016 0.984
#> SRR1740036 3 0.0747 1.000 0.000 0.016 0.984
#> SRR1740037 3 0.0747 1.000 0.000 0.016 0.984
#> SRR1740038 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740039 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740040 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740041 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740042 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740043 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740044 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740045 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740046 2 0.7885 0.693 0.352 0.580 0.068
#> SRR1740048 2 0.7885 0.693 0.352 0.580 0.068
#> SRR1740047 2 0.7885 0.693 0.352 0.580 0.068
#> SRR1740049 2 0.7885 0.693 0.352 0.580 0.068
#> SRR1740050 1 0.6081 0.982 0.652 0.004 0.344
#> SRR1740051 1 0.6081 0.982 0.652 0.004 0.344
#> SRR1740052 1 0.6081 0.982 0.652 0.004 0.344
#> SRR1740054 1 0.6252 0.984 0.648 0.008 0.344
#> SRR1740053 1 0.6081 0.982 0.652 0.004 0.344
#> SRR1740056 1 0.6081 0.986 0.652 0.004 0.344
#> SRR1740055 1 0.6962 0.944 0.648 0.036 0.316
#> SRR1740057 1 0.6081 0.986 0.652 0.004 0.344
#> SRR1740058 1 0.6057 0.988 0.656 0.004 0.340
#> SRR1740059 1 0.6057 0.988 0.656 0.004 0.340
#> SRR1740060 1 0.6057 0.988 0.656 0.004 0.340
#> SRR1740061 1 0.6057 0.988 0.656 0.004 0.340
#> SRR1740062 3 0.0747 1.000 0.000 0.016 0.984
#> SRR1740063 3 0.0747 1.000 0.000 0.016 0.984
#> SRR1740064 3 0.0747 1.000 0.000 0.016 0.984
#> SRR1740065 3 0.0747 1.000 0.000 0.016 0.984
#> SRR1740066 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740067 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740068 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740069 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740070 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740071 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740072 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740073 2 0.0000 0.865 0.000 1.000 0.000
#> SRR1740074 2 0.7885 0.693 0.352 0.580 0.068
#> SRR1740075 2 0.7885 0.693 0.352 0.580 0.068
#> SRR1740076 2 0.7885 0.693 0.352 0.580 0.068
#> SRR1740077 2 0.7885 0.693 0.352 0.580 0.068
#> SRR1740078 1 0.6081 0.982 0.652 0.004 0.344
#> SRR1740079 1 0.6081 0.982 0.652 0.004 0.344
#> SRR1740080 1 0.6081 0.982 0.652 0.004 0.344
#> SRR1740081 1 0.6081 0.982 0.652 0.004 0.344
#> SRR1740082 1 0.6057 0.988 0.656 0.004 0.340
#> SRR1740083 1 0.6057 0.988 0.656 0.004 0.340
#> SRR1740084 1 0.6057 0.988 0.656 0.004 0.340
#> SRR1740085 1 0.6057 0.988 0.656 0.004 0.340
#> SRR1740086 1 0.6057 0.988 0.656 0.004 0.340
#> SRR1740087 1 0.6057 0.988 0.656 0.004 0.340
#> SRR1740088 1 0.6057 0.988 0.656 0.004 0.340
#> SRR1740089 1 0.6057 0.988 0.656 0.004 0.340
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 4 0.0336 1.000 0.000 0.008 0.000 0.992
#> SRR1740035 4 0.0336 1.000 0.000 0.008 0.000 0.992
#> SRR1740036 4 0.0336 1.000 0.000 0.008 0.000 0.992
#> SRR1740037 4 0.0336 1.000 0.000 0.008 0.000 0.992
#> SRR1740038 2 0.0188 0.998 0.000 0.996 0.004 0.000
#> SRR1740039 2 0.0188 0.998 0.000 0.996 0.004 0.000
#> SRR1740040 2 0.0188 0.998 0.000 0.996 0.004 0.000
#> SRR1740041 2 0.0188 0.998 0.000 0.996 0.004 0.000
#> SRR1740042 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1740043 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1740044 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1740045 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1740046 3 0.4364 1.000 0.000 0.220 0.764 0.016
#> SRR1740048 3 0.4364 1.000 0.000 0.220 0.764 0.016
#> SRR1740047 3 0.4364 1.000 0.000 0.220 0.764 0.016
#> SRR1740049 3 0.4364 1.000 0.000 0.220 0.764 0.016
#> SRR1740050 1 0.4228 0.837 0.760 0.000 0.232 0.008
#> SRR1740051 1 0.4228 0.837 0.760 0.000 0.232 0.008
#> SRR1740052 1 0.4228 0.837 0.760 0.000 0.232 0.008
#> SRR1740054 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1740053 1 0.4228 0.837 0.760 0.000 0.232 0.008
#> SRR1740056 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1740055 1 0.0921 0.903 0.972 0.028 0.000 0.000
#> SRR1740057 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1740058 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1740059 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1740060 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1740061 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1740062 4 0.0336 1.000 0.000 0.008 0.000 0.992
#> SRR1740063 4 0.0336 1.000 0.000 0.008 0.000 0.992
#> SRR1740064 4 0.0336 1.000 0.000 0.008 0.000 0.992
#> SRR1740065 4 0.0336 1.000 0.000 0.008 0.000 0.992
#> SRR1740066 2 0.0188 0.998 0.000 0.996 0.004 0.000
#> SRR1740067 2 0.0188 0.998 0.000 0.996 0.004 0.000
#> SRR1740068 2 0.0188 0.998 0.000 0.996 0.004 0.000
#> SRR1740069 2 0.0188 0.998 0.000 0.996 0.004 0.000
#> SRR1740070 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1740071 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1740072 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1740073 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1740074 3 0.4364 1.000 0.000 0.220 0.764 0.016
#> SRR1740075 3 0.4364 1.000 0.000 0.220 0.764 0.016
#> SRR1740076 3 0.4364 1.000 0.000 0.220 0.764 0.016
#> SRR1740077 3 0.4364 1.000 0.000 0.220 0.764 0.016
#> SRR1740078 1 0.4228 0.837 0.760 0.000 0.232 0.008
#> SRR1740079 1 0.4228 0.837 0.760 0.000 0.232 0.008
#> SRR1740080 1 0.4228 0.837 0.760 0.000 0.232 0.008
#> SRR1740081 1 0.4228 0.837 0.760 0.000 0.232 0.008
#> SRR1740082 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1740083 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1740084 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1740085 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1740086 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1740087 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1740088 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1740089 1 0.0000 0.922 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
#> SRR1740034 4 0.0290 1.000 0.000 0.000 0.008 0.992 0.000
#> SRR1740035 4 0.0290 1.000 0.000 0.000 0.008 0.992 0.000
#> SRR1740036 4 0.0290 1.000 0.000 0.000 0.008 0.992 0.000
#> SRR1740037 4 0.0290 1.000 0.000 0.000 0.008 0.992 0.000
#> SRR1740038 2 0.2806 0.928 0.000 0.844 0.000 0.004 0.152
#> SRR1740039 2 0.2806 0.928 0.000 0.844 0.000 0.004 0.152
#> SRR1740040 2 0.2806 0.928 0.000 0.844 0.000 0.004 0.152
#> SRR1740041 2 0.2806 0.928 0.000 0.844 0.000 0.004 0.152
#> SRR1740042 2 0.0000 0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1740043 2 0.0000 0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1740044 2 0.0000 0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1740045 2 0.0000 0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1740046 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740048 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740047 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740049 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740050 5 0.2648 1.000 0.152 0.000 0.000 0.000 0.848
#> SRR1740051 5 0.2648 1.000 0.152 0.000 0.000 0.000 0.848
#> SRR1740052 5 0.2648 1.000 0.152 0.000 0.000 0.000 0.848
#> SRR1740054 1 0.0771 0.949 0.976 0.020 0.000 0.004 0.000
#> SRR1740053 5 0.2648 1.000 0.152 0.000 0.000 0.000 0.848
#> SRR1740056 1 0.0162 0.960 0.996 0.000 0.000 0.004 0.000
#> SRR1740055 1 0.3398 0.706 0.780 0.216 0.000 0.004 0.000
#> SRR1740057 1 0.0162 0.960 0.996 0.000 0.000 0.004 0.000
#> SRR1740058 1 0.0290 0.962 0.992 0.000 0.000 0.000 0.008
#> SRR1740059 1 0.0290 0.962 0.992 0.000 0.000 0.000 0.008
#> SRR1740060 1 0.0290 0.962 0.992 0.000 0.000 0.000 0.008
#> SRR1740061 1 0.0290 0.962 0.992 0.000 0.000 0.000 0.008
#> SRR1740062 4 0.0290 1.000 0.000 0.000 0.008 0.992 0.000
#> SRR1740063 4 0.0290 1.000 0.000 0.000 0.008 0.992 0.000
#> SRR1740064 4 0.0290 1.000 0.000 0.000 0.008 0.992 0.000
#> SRR1740065 4 0.0290 1.000 0.000 0.000 0.008 0.992 0.000
#> SRR1740066 2 0.2806 0.928 0.000 0.844 0.000 0.004 0.152
#> SRR1740067 2 0.2806 0.928 0.000 0.844 0.000 0.004 0.152
#> SRR1740068 2 0.2806 0.928 0.000 0.844 0.000 0.004 0.152
#> SRR1740069 2 0.2806 0.928 0.000 0.844 0.000 0.004 0.152
#> SRR1740070 2 0.0000 0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1740071 2 0.0000 0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1740072 2 0.0000 0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1740073 2 0.0000 0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1740074 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740075 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740076 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740077 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740078 5 0.2648 1.000 0.152 0.000 0.000 0.000 0.848
#> SRR1740079 5 0.2648 1.000 0.152 0.000 0.000 0.000 0.848
#> SRR1740080 5 0.2648 1.000 0.152 0.000 0.000 0.000 0.848
#> SRR1740081 5 0.2648 1.000 0.152 0.000 0.000 0.000 0.848
#> SRR1740082 1 0.1571 0.915 0.936 0.060 0.000 0.004 0.000
#> SRR1740083 1 0.1430 0.923 0.944 0.052 0.000 0.004 0.000
#> SRR1740084 1 0.0865 0.947 0.972 0.024 0.000 0.004 0.000
#> SRR1740085 1 0.0451 0.957 0.988 0.008 0.000 0.004 0.000
#> SRR1740086 1 0.0290 0.962 0.992 0.000 0.000 0.000 0.008
#> SRR1740087 1 0.0290 0.962 0.992 0.000 0.000 0.000 0.008
#> SRR1740088 1 0.0290 0.962 0.992 0.000 0.000 0.000 0.008
#> SRR1740089 1 0.0290 0.962 0.992 0.000 0.000 0.000 0.008
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.0260 0.9968 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR1740035 4 0.0260 0.9968 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR1740036 4 0.0260 0.9968 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR1740037 4 0.0260 0.9968 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR1740038 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1740039 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1740040 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1740041 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1740042 1 0.3774 0.6595 0.592 0.408 0.000 0.000 0.000 0.000
#> SRR1740043 1 0.3774 0.6595 0.592 0.408 0.000 0.000 0.000 0.000
#> SRR1740044 1 0.3774 0.6595 0.592 0.408 0.000 0.000 0.000 0.000
#> SRR1740045 1 0.3774 0.6595 0.592 0.408 0.000 0.000 0.000 0.000
#> SRR1740046 3 0.0146 0.9984 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1740048 3 0.0146 0.9984 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1740047 3 0.0146 0.9984 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1740049 3 0.0146 0.9984 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1740050 5 0.0146 1.0000 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1740051 5 0.0146 1.0000 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1740052 5 0.0146 1.0000 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1740054 1 0.2996 -0.0124 0.772 0.000 0.000 0.000 0.000 0.228
#> SRR1740053 5 0.0146 1.0000 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1740056 6 0.3797 0.6588 0.420 0.000 0.000 0.000 0.000 0.580
#> SRR1740055 1 0.1471 0.3423 0.932 0.004 0.000 0.000 0.000 0.064
#> SRR1740057 6 0.3695 0.6944 0.376 0.000 0.000 0.000 0.000 0.624
#> SRR1740058 6 0.0000 0.8290 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1740059 6 0.0000 0.8290 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1740060 6 0.0000 0.8290 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1740061 6 0.0000 0.8290 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1740062 4 0.0000 0.9968 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740063 4 0.0000 0.9968 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740064 4 0.0000 0.9968 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740065 4 0.0000 0.9968 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1740066 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1740067 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1740068 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1740069 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1740070 1 0.3774 0.6595 0.592 0.408 0.000 0.000 0.000 0.000
#> SRR1740071 1 0.3774 0.6595 0.592 0.408 0.000 0.000 0.000 0.000
#> SRR1740072 1 0.3774 0.6595 0.592 0.408 0.000 0.000 0.000 0.000
#> SRR1740073 1 0.3774 0.6595 0.592 0.408 0.000 0.000 0.000 0.000
#> SRR1740074 3 0.0000 0.9984 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1740075 3 0.0000 0.9984 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1740076 3 0.0000 0.9984 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1740077 3 0.0000 0.9984 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1740078 5 0.0146 1.0000 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1740079 5 0.0146 1.0000 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1740080 5 0.0146 1.0000 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1740081 5 0.0146 1.0000 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1740082 1 0.3854 -0.5557 0.536 0.000 0.000 0.000 0.000 0.464
#> SRR1740083 6 0.3851 0.6071 0.460 0.000 0.000 0.000 0.000 0.540
#> SRR1740084 6 0.3774 0.6709 0.408 0.000 0.000 0.000 0.000 0.592
#> SRR1740085 6 0.3717 0.6897 0.384 0.000 0.000 0.000 0.000 0.616
#> SRR1740086 6 0.0000 0.8290 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1740087 6 0.0000 0.8290 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1740088 6 0.0000 0.8290 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1740089 6 0.0000 0.8290 0.000 0.000 0.000 0.000 0.000 1.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.751 0.924 0.960 0.4992 0.501 0.501
#> 3 3 0.792 0.921 0.960 0.1896 0.917 0.834
#> 4 4 0.834 0.928 0.960 0.1902 0.875 0.702
#> 5 5 0.917 0.983 0.985 0.1175 0.917 0.717
#> 6 6 1.000 1.000 1.000 0.0526 0.958 0.802
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 5
There is also optional best \(k\) = 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1740034 1 0.000 0.923 1.00 0.00
#> SRR1740035 1 0.000 0.923 1.00 0.00
#> SRR1740036 1 0.000 0.923 1.00 0.00
#> SRR1740037 1 0.000 0.923 1.00 0.00
#> SRR1740038 2 0.000 1.000 0.00 1.00
#> SRR1740039 2 0.000 1.000 0.00 1.00
#> SRR1740040 2 0.000 1.000 0.00 1.00
#> SRR1740041 2 0.000 1.000 0.00 1.00
#> SRR1740042 2 0.000 1.000 0.00 1.00
#> SRR1740043 2 0.000 1.000 0.00 1.00
#> SRR1740044 2 0.000 1.000 0.00 1.00
#> SRR1740045 2 0.000 1.000 0.00 1.00
#> SRR1740046 2 0.000 1.000 0.00 1.00
#> SRR1740048 2 0.000 1.000 0.00 1.00
#> SRR1740047 2 0.000 1.000 0.00 1.00
#> SRR1740049 2 0.000 1.000 0.00 1.00
#> SRR1740050 1 0.000 0.923 1.00 0.00
#> SRR1740051 1 0.000 0.923 1.00 0.00
#> SRR1740052 1 0.000 0.923 1.00 0.00
#> SRR1740054 1 0.855 0.699 0.72 0.28
#> SRR1740053 1 0.000 0.923 1.00 0.00
#> SRR1740056 1 0.855 0.699 0.72 0.28
#> SRR1740055 1 0.855 0.699 0.72 0.28
#> SRR1740057 1 0.855 0.699 0.72 0.28
#> SRR1740058 1 0.000 0.923 1.00 0.00
#> SRR1740059 1 0.000 0.923 1.00 0.00
#> SRR1740060 1 0.000 0.923 1.00 0.00
#> SRR1740061 1 0.000 0.923 1.00 0.00
#> SRR1740062 1 0.000 0.923 1.00 0.00
#> SRR1740063 1 0.000 0.923 1.00 0.00
#> SRR1740064 1 0.000 0.923 1.00 0.00
#> SRR1740065 1 0.000 0.923 1.00 0.00
#> SRR1740066 2 0.000 1.000 0.00 1.00
#> SRR1740067 2 0.000 1.000 0.00 1.00
#> SRR1740068 2 0.000 1.000 0.00 1.00
#> SRR1740069 2 0.000 1.000 0.00 1.00
#> SRR1740070 2 0.000 1.000 0.00 1.00
#> SRR1740071 2 0.000 1.000 0.00 1.00
#> SRR1740072 2 0.000 1.000 0.00 1.00
#> SRR1740073 2 0.000 1.000 0.00 1.00
#> SRR1740074 2 0.000 1.000 0.00 1.00
#> SRR1740075 2 0.000 1.000 0.00 1.00
#> SRR1740076 2 0.000 1.000 0.00 1.00
#> SRR1740077 2 0.000 1.000 0.00 1.00
#> SRR1740078 1 0.000 0.923 1.00 0.00
#> SRR1740079 1 0.000 0.923 1.00 0.00
#> SRR1740080 1 0.000 0.923 1.00 0.00
#> SRR1740081 1 0.000 0.923 1.00 0.00
#> SRR1740082 1 0.855 0.699 0.72 0.28
#> SRR1740083 1 0.855 0.699 0.72 0.28
#> SRR1740084 1 0.855 0.699 0.72 0.28
#> SRR1740085 1 0.855 0.699 0.72 0.28
#> SRR1740086 1 0.000 0.923 1.00 0.00
#> SRR1740087 1 0.000 0.923 1.00 0.00
#> SRR1740088 1 0.000 0.923 1.00 0.00
#> SRR1740089 1 0.000 0.923 1.00 0.00
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0.00 0.917 1.00 0.00 0
#> SRR1740035 1 0.00 0.917 1.00 0.00 0
#> SRR1740036 1 0.00 0.917 1.00 0.00 0
#> SRR1740037 1 0.00 0.917 1.00 0.00 0
#> SRR1740038 2 0.00 1.000 0.00 1.00 0
#> SRR1740039 2 0.00 1.000 0.00 1.00 0
#> SRR1740040 2 0.00 1.000 0.00 1.00 0
#> SRR1740041 2 0.00 1.000 0.00 1.00 0
#> SRR1740042 2 0.00 1.000 0.00 1.00 0
#> SRR1740043 2 0.00 1.000 0.00 1.00 0
#> SRR1740044 2 0.00 1.000 0.00 1.00 0
#> SRR1740045 2 0.00 1.000 0.00 1.00 0
#> SRR1740046 3 0.00 1.000 0.00 0.00 1
#> SRR1740048 3 0.00 1.000 0.00 0.00 1
#> SRR1740047 3 0.00 1.000 0.00 0.00 1
#> SRR1740049 3 0.00 1.000 0.00 0.00 1
#> SRR1740050 1 0.00 0.917 1.00 0.00 0
#> SRR1740051 1 0.00 0.917 1.00 0.00 0
#> SRR1740052 1 0.00 0.917 1.00 0.00 0
#> SRR1740054 1 0.54 0.699 0.72 0.28 0
#> SRR1740053 1 0.00 0.917 1.00 0.00 0
#> SRR1740056 1 0.54 0.699 0.72 0.28 0
#> SRR1740055 1 0.54 0.699 0.72 0.28 0
#> SRR1740057 1 0.54 0.699 0.72 0.28 0
#> SRR1740058 1 0.00 0.917 1.00 0.00 0
#> SRR1740059 1 0.00 0.917 1.00 0.00 0
#> SRR1740060 1 0.00 0.917 1.00 0.00 0
#> SRR1740061 1 0.00 0.917 1.00 0.00 0
#> SRR1740062 1 0.00 0.917 1.00 0.00 0
#> SRR1740063 1 0.00 0.917 1.00 0.00 0
#> SRR1740064 1 0.00 0.917 1.00 0.00 0
#> SRR1740065 1 0.00 0.917 1.00 0.00 0
#> SRR1740066 2 0.00 1.000 0.00 1.00 0
#> SRR1740067 2 0.00 1.000 0.00 1.00 0
#> SRR1740068 2 0.00 1.000 0.00 1.00 0
#> SRR1740069 2 0.00 1.000 0.00 1.00 0
#> SRR1740070 2 0.00 1.000 0.00 1.00 0
#> SRR1740071 2 0.00 1.000 0.00 1.00 0
#> SRR1740072 2 0.00 1.000 0.00 1.00 0
#> SRR1740073 2 0.00 1.000 0.00 1.00 0
#> SRR1740074 3 0.00 1.000 0.00 0.00 1
#> SRR1740075 3 0.00 1.000 0.00 0.00 1
#> SRR1740076 3 0.00 1.000 0.00 0.00 1
#> SRR1740077 3 0.00 1.000 0.00 0.00 1
#> SRR1740078 1 0.00 0.917 1.00 0.00 0
#> SRR1740079 1 0.00 0.917 1.00 0.00 0
#> SRR1740080 1 0.00 0.917 1.00 0.00 0
#> SRR1740081 1 0.00 0.917 1.00 0.00 0
#> SRR1740082 1 0.54 0.699 0.72 0.28 0
#> SRR1740083 1 0.54 0.699 0.72 0.28 0
#> SRR1740084 1 0.54 0.699 0.72 0.28 0
#> SRR1740085 1 0.54 0.699 0.72 0.28 0
#> SRR1740086 1 0.00 0.917 1.00 0.00 0
#> SRR1740087 1 0.00 0.917 1.00 0.00 0
#> SRR1740088 1 0.00 0.917 1.00 0.00 0
#> SRR1740089 1 0.00 0.917 1.00 0.00 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 4 0.000 1.000 0.00 0.00 0 1
#> SRR1740035 4 0.000 1.000 0.00 0.00 0 1
#> SRR1740036 4 0.000 1.000 0.00 0.00 0 1
#> SRR1740037 4 0.000 1.000 0.00 0.00 0 1
#> SRR1740038 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740039 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740040 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740041 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740042 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740043 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740044 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740045 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740046 3 0.000 1.000 0.00 0.00 1 0
#> SRR1740048 3 0.000 1.000 0.00 0.00 1 0
#> SRR1740047 3 0.000 1.000 0.00 0.00 1 0
#> SRR1740049 3 0.000 1.000 0.00 0.00 1 0
#> SRR1740050 1 0.000 0.884 1.00 0.00 0 0
#> SRR1740051 1 0.000 0.884 1.00 0.00 0 0
#> SRR1740052 1 0.000 0.884 1.00 0.00 0 0
#> SRR1740054 1 0.428 0.729 0.72 0.28 0 0
#> SRR1740053 1 0.000 0.884 1.00 0.00 0 0
#> SRR1740056 1 0.428 0.729 0.72 0.28 0 0
#> SRR1740055 1 0.428 0.729 0.72 0.28 0 0
#> SRR1740057 1 0.428 0.729 0.72 0.28 0 0
#> SRR1740058 1 0.000 0.884 1.00 0.00 0 0
#> SRR1740059 1 0.000 0.884 1.00 0.00 0 0
#> SRR1740060 1 0.000 0.884 1.00 0.00 0 0
#> SRR1740061 1 0.000 0.884 1.00 0.00 0 0
#> SRR1740062 4 0.000 1.000 0.00 0.00 0 1
#> SRR1740063 4 0.000 1.000 0.00 0.00 0 1
#> SRR1740064 4 0.000 1.000 0.00 0.00 0 1
#> SRR1740065 4 0.000 1.000 0.00 0.00 0 1
#> SRR1740066 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740067 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740068 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740069 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740070 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740071 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740072 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740073 2 0.000 1.000 0.00 1.00 0 0
#> SRR1740074 3 0.000 1.000 0.00 0.00 1 0
#> SRR1740075 3 0.000 1.000 0.00 0.00 1 0
#> SRR1740076 3 0.000 1.000 0.00 0.00 1 0
#> SRR1740077 3 0.000 1.000 0.00 0.00 1 0
#> SRR1740078 1 0.000 0.884 1.00 0.00 0 0
#> SRR1740079 1 0.000 0.884 1.00 0.00 0 0
#> SRR1740080 1 0.000 0.884 1.00 0.00 0 0
#> SRR1740081 1 0.000 0.884 1.00 0.00 0 0
#> SRR1740082 1 0.428 0.729 0.72 0.28 0 0
#> SRR1740083 1 0.428 0.729 0.72 0.28 0 0
#> SRR1740084 1 0.428 0.729 0.72 0.28 0 0
#> SRR1740085 1 0.428 0.729 0.72 0.28 0 0
#> SRR1740086 1 0.000 0.884 1.00 0.00 0 0
#> SRR1740087 1 0.000 0.884 1.00 0.00 0 0
#> SRR1740088 1 0.000 0.884 1.00 0.00 0 0
#> SRR1740089 1 0.000 0.884 1.00 0.00 0 0
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.000 1.000 0.000 0 0 1 0.000
#> SRR1740035 4 0.000 1.000 0.000 0 0 1 0.000
#> SRR1740036 4 0.000 1.000 0.000 0 0 1 0.000
#> SRR1740037 4 0.000 1.000 0.000 0 0 1 0.000
#> SRR1740038 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740039 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740040 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740041 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740042 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740043 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740044 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740045 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740046 3 0.000 1.000 0.000 0 1 0 0.000
#> SRR1740048 3 0.000 1.000 0.000 0 1 0 0.000
#> SRR1740047 3 0.000 1.000 0.000 0 1 0 0.000
#> SRR1740049 3 0.000 1.000 0.000 0 1 0 0.000
#> SRR1740050 5 0.207 0.938 0.104 0 0 0 0.896
#> SRR1740051 5 0.207 0.938 0.104 0 0 0 0.896
#> SRR1740052 5 0.207 0.938 0.104 0 0 0 0.896
#> SRR1740054 1 0.000 1.000 1.000 0 0 0 0.000
#> SRR1740053 5 0.207 0.938 0.104 0 0 0 0.896
#> SRR1740056 1 0.000 1.000 1.000 0 0 0 0.000
#> SRR1740055 1 0.000 1.000 1.000 0 0 0 0.000
#> SRR1740057 1 0.000 1.000 1.000 0 0 0 0.000
#> SRR1740058 5 0.000 0.941 0.000 0 0 0 1.000
#> SRR1740059 5 0.000 0.941 0.000 0 0 0 1.000
#> SRR1740060 5 0.000 0.941 0.000 0 0 0 1.000
#> SRR1740061 5 0.000 0.941 0.000 0 0 0 1.000
#> SRR1740062 4 0.000 1.000 0.000 0 0 1 0.000
#> SRR1740063 4 0.000 1.000 0.000 0 0 1 0.000
#> SRR1740064 4 0.000 1.000 0.000 0 0 1 0.000
#> SRR1740065 4 0.000 1.000 0.000 0 0 1 0.000
#> SRR1740066 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740067 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740068 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740069 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740070 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740071 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740072 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740073 2 0.000 1.000 0.000 1 0 0 0.000
#> SRR1740074 3 0.000 1.000 0.000 0 1 0 0.000
#> SRR1740075 3 0.000 1.000 0.000 0 1 0 0.000
#> SRR1740076 3 0.000 1.000 0.000 0 1 0 0.000
#> SRR1740077 3 0.000 1.000 0.000 0 1 0 0.000
#> SRR1740078 5 0.207 0.938 0.104 0 0 0 0.896
#> SRR1740079 5 0.207 0.938 0.104 0 0 0 0.896
#> SRR1740080 5 0.207 0.938 0.104 0 0 0 0.896
#> SRR1740081 5 0.207 0.938 0.104 0 0 0 0.896
#> SRR1740082 1 0.000 1.000 1.000 0 0 0 0.000
#> SRR1740083 1 0.000 1.000 1.000 0 0 0 0.000
#> SRR1740084 1 0.000 1.000 1.000 0 0 0 0.000
#> SRR1740085 1 0.000 1.000 1.000 0 0 0 0.000
#> SRR1740086 5 0.000 0.941 0.000 0 0 0 1.000
#> SRR1740087 5 0.000 0.941 0.000 0 0 0 1.000
#> SRR1740088 5 0.000 0.941 0.000 0 0 0 1.000
#> SRR1740089 5 0.000 0.941 0.000 0 0 0 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0 1 0 0 0 1 0 0
#> SRR1740035 4 0 1 0 0 0 1 0 0
#> SRR1740036 4 0 1 0 0 0 1 0 0
#> SRR1740037 4 0 1 0 0 0 1 0 0
#> SRR1740038 2 0 1 0 1 0 0 0 0
#> SRR1740039 2 0 1 0 1 0 0 0 0
#> SRR1740040 2 0 1 0 1 0 0 0 0
#> SRR1740041 2 0 1 0 1 0 0 0 0
#> SRR1740042 2 0 1 0 1 0 0 0 0
#> SRR1740043 2 0 1 0 1 0 0 0 0
#> SRR1740044 2 0 1 0 1 0 0 0 0
#> SRR1740045 2 0 1 0 1 0 0 0 0
#> SRR1740046 3 0 1 0 0 1 0 0 0
#> SRR1740048 3 0 1 0 0 1 0 0 0
#> SRR1740047 3 0 1 0 0 1 0 0 0
#> SRR1740049 3 0 1 0 0 1 0 0 0
#> SRR1740050 5 0 1 0 0 0 0 1 0
#> SRR1740051 5 0 1 0 0 0 0 1 0
#> SRR1740052 5 0 1 0 0 0 0 1 0
#> SRR1740054 1 0 1 1 0 0 0 0 0
#> SRR1740053 5 0 1 0 0 0 0 1 0
#> SRR1740056 1 0 1 1 0 0 0 0 0
#> SRR1740055 1 0 1 1 0 0 0 0 0
#> SRR1740057 1 0 1 1 0 0 0 0 0
#> SRR1740058 6 0 1 0 0 0 0 0 1
#> SRR1740059 6 0 1 0 0 0 0 0 1
#> SRR1740060 6 0 1 0 0 0 0 0 1
#> SRR1740061 6 0 1 0 0 0 0 0 1
#> SRR1740062 4 0 1 0 0 0 1 0 0
#> SRR1740063 4 0 1 0 0 0 1 0 0
#> SRR1740064 4 0 1 0 0 0 1 0 0
#> SRR1740065 4 0 1 0 0 0 1 0 0
#> SRR1740066 2 0 1 0 1 0 0 0 0
#> SRR1740067 2 0 1 0 1 0 0 0 0
#> SRR1740068 2 0 1 0 1 0 0 0 0
#> SRR1740069 2 0 1 0 1 0 0 0 0
#> SRR1740070 2 0 1 0 1 0 0 0 0
#> SRR1740071 2 0 1 0 1 0 0 0 0
#> SRR1740072 2 0 1 0 1 0 0 0 0
#> SRR1740073 2 0 1 0 1 0 0 0 0
#> SRR1740074 3 0 1 0 0 1 0 0 0
#> SRR1740075 3 0 1 0 0 1 0 0 0
#> SRR1740076 3 0 1 0 0 1 0 0 0
#> SRR1740077 3 0 1 0 0 1 0 0 0
#> SRR1740078 5 0 1 0 0 0 0 1 0
#> SRR1740079 5 0 1 0 0 0 0 1 0
#> SRR1740080 5 0 1 0 0 0 0 1 0
#> SRR1740081 5 0 1 0 0 0 0 1 0
#> SRR1740082 1 0 1 1 0 0 0 0 0
#> SRR1740083 1 0 1 1 0 0 0 0 0
#> SRR1740084 1 0 1 1 0 0 0 0 0
#> SRR1740085 1 0 1 1 0 0 0 0 0
#> SRR1740086 6 0 1 0 0 0 0 0 1
#> SRR1740087 6 0 1 0 0 0 0 0 1
#> SRR1740088 6 0 1 0 0 0 0 0 1
#> SRR1740089 6 0 1 0 0 0 0 0 1
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.584 0.933 0.938 0.4564 0.501 0.501
#> 3 3 0.584 0.780 0.799 0.3269 1.000 1.000
#> 4 4 0.532 0.770 0.772 0.1335 0.792 0.585
#> 5 5 0.605 0.759 0.684 0.0900 0.917 0.717
#> 6 6 0.647 0.890 0.700 0.0598 0.958 0.802
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
#> SRR1740034 1 0.000 0.971 1.000 0.000
#> SRR1740035 1 0.000 0.971 1.000 0.000
#> SRR1740036 1 0.000 0.971 1.000 0.000
#> SRR1740037 1 0.000 0.971 1.000 0.000
#> SRR1740038 2 0.662 0.924 0.172 0.828
#> SRR1740039 2 0.662 0.924 0.172 0.828
#> SRR1740040 2 0.662 0.924 0.172 0.828
#> SRR1740041 2 0.662 0.924 0.172 0.828
#> SRR1740042 2 0.662 0.924 0.172 0.828
#> SRR1740043 2 0.662 0.924 0.172 0.828
#> SRR1740044 2 0.662 0.924 0.172 0.828
#> SRR1740045 2 0.662 0.924 0.172 0.828
#> SRR1740046 2 0.000 0.863 0.000 1.000
#> SRR1740048 2 0.000 0.863 0.000 1.000
#> SRR1740047 2 0.000 0.863 0.000 1.000
#> SRR1740049 2 0.000 0.863 0.000 1.000
#> SRR1740050 1 0.000 0.971 1.000 0.000
#> SRR1740051 1 0.000 0.971 1.000 0.000
#> SRR1740052 1 0.000 0.971 1.000 0.000
#> SRR1740054 1 0.443 0.907 0.908 0.092
#> SRR1740053 1 0.000 0.971 1.000 0.000
#> SRR1740056 1 0.443 0.907 0.908 0.092
#> SRR1740055 1 0.443 0.907 0.908 0.092
#> SRR1740057 1 0.443 0.907 0.908 0.092
#> SRR1740058 1 0.000 0.971 1.000 0.000
#> SRR1740059 1 0.000 0.971 1.000 0.000
#> SRR1740060 1 0.000 0.971 1.000 0.000
#> SRR1740061 1 0.000 0.971 1.000 0.000
#> SRR1740062 1 0.000 0.971 1.000 0.000
#> SRR1740063 1 0.000 0.971 1.000 0.000
#> SRR1740064 1 0.000 0.971 1.000 0.000
#> SRR1740065 1 0.000 0.971 1.000 0.000
#> SRR1740066 2 0.662 0.924 0.172 0.828
#> SRR1740067 2 0.662 0.924 0.172 0.828
#> SRR1740068 2 0.662 0.924 0.172 0.828
#> SRR1740069 2 0.662 0.924 0.172 0.828
#> SRR1740070 2 0.662 0.924 0.172 0.828
#> SRR1740071 2 0.662 0.924 0.172 0.828
#> SRR1740072 2 0.662 0.924 0.172 0.828
#> SRR1740073 2 0.662 0.924 0.172 0.828
#> SRR1740074 2 0.000 0.863 0.000 1.000
#> SRR1740075 2 0.000 0.863 0.000 1.000
#> SRR1740076 2 0.000 0.863 0.000 1.000
#> SRR1740077 2 0.000 0.863 0.000 1.000
#> SRR1740078 1 0.000 0.971 1.000 0.000
#> SRR1740079 1 0.000 0.971 1.000 0.000
#> SRR1740080 1 0.000 0.971 1.000 0.000
#> SRR1740081 1 0.000 0.971 1.000 0.000
#> SRR1740082 1 0.443 0.907 0.908 0.092
#> SRR1740083 1 0.443 0.907 0.908 0.092
#> SRR1740084 1 0.443 0.907 0.908 0.092
#> SRR1740085 1 0.443 0.907 0.908 0.092
#> SRR1740086 1 0.000 0.971 1.000 0.000
#> SRR1740087 1 0.000 0.971 1.000 0.000
#> SRR1740088 1 0.000 0.971 1.000 0.000
#> SRR1740089 1 0.000 0.971 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0.627 0.684 0.548 0.000 0.452
#> SRR1740035 1 0.627 0.684 0.548 0.000 0.452
#> SRR1740036 1 0.627 0.684 0.548 0.000 0.452
#> SRR1740037 1 0.627 0.684 0.548 0.000 0.452
#> SRR1740038 2 0.158 0.856 0.028 0.964 0.008
#> SRR1740039 2 0.158 0.856 0.028 0.964 0.008
#> SRR1740040 2 0.158 0.856 0.028 0.964 0.008
#> SRR1740041 2 0.158 0.856 0.028 0.964 0.008
#> SRR1740042 2 0.116 0.857 0.028 0.972 0.000
#> SRR1740043 2 0.116 0.857 0.028 0.972 0.000
#> SRR1740044 2 0.116 0.857 0.028 0.972 0.000
#> SRR1740045 2 0.116 0.857 0.028 0.972 0.000
#> SRR1740046 2 0.622 0.704 0.000 0.568 0.432
#> SRR1740048 2 0.622 0.704 0.000 0.568 0.432
#> SRR1740047 2 0.622 0.704 0.000 0.568 0.432
#> SRR1740049 2 0.622 0.704 0.000 0.568 0.432
#> SRR1740050 1 0.226 0.807 0.932 0.000 0.068
#> SRR1740051 1 0.226 0.807 0.932 0.000 0.068
#> SRR1740052 1 0.226 0.807 0.932 0.000 0.068
#> SRR1740054 1 0.637 0.736 0.764 0.152 0.084
#> SRR1740053 1 0.226 0.807 0.932 0.000 0.068
#> SRR1740056 1 0.637 0.736 0.764 0.152 0.084
#> SRR1740055 1 0.637 0.736 0.764 0.152 0.084
#> SRR1740057 1 0.625 0.741 0.772 0.144 0.084
#> SRR1740058 1 0.226 0.818 0.932 0.000 0.068
#> SRR1740059 1 0.226 0.818 0.932 0.000 0.068
#> SRR1740060 1 0.226 0.818 0.932 0.000 0.068
#> SRR1740061 1 0.226 0.818 0.932 0.000 0.068
#> SRR1740062 1 0.627 0.684 0.548 0.000 0.452
#> SRR1740063 1 0.627 0.684 0.548 0.000 0.452
#> SRR1740064 1 0.627 0.684 0.548 0.000 0.452
#> SRR1740065 1 0.627 0.684 0.548 0.000 0.452
#> SRR1740066 2 0.158 0.856 0.028 0.964 0.008
#> SRR1740067 2 0.158 0.856 0.028 0.964 0.008
#> SRR1740068 2 0.158 0.856 0.028 0.964 0.008
#> SRR1740069 2 0.158 0.856 0.028 0.964 0.008
#> SRR1740070 2 0.116 0.857 0.028 0.972 0.000
#> SRR1740071 2 0.116 0.857 0.028 0.972 0.000
#> SRR1740072 2 0.116 0.857 0.028 0.972 0.000
#> SRR1740073 2 0.116 0.857 0.028 0.972 0.000
#> SRR1740074 2 0.625 0.704 0.000 0.556 0.444
#> SRR1740075 2 0.625 0.704 0.000 0.556 0.444
#> SRR1740076 2 0.625 0.704 0.000 0.556 0.444
#> SRR1740077 2 0.625 0.704 0.000 0.556 0.444
#> SRR1740078 1 0.226 0.807 0.932 0.000 0.068
#> SRR1740079 1 0.226 0.807 0.932 0.000 0.068
#> SRR1740080 1 0.226 0.807 0.932 0.000 0.068
#> SRR1740081 1 0.226 0.807 0.932 0.000 0.068
#> SRR1740082 1 0.637 0.736 0.764 0.152 0.084
#> SRR1740083 1 0.637 0.736 0.764 0.152 0.084
#> SRR1740084 1 0.637 0.736 0.764 0.152 0.084
#> SRR1740085 1 0.637 0.736 0.764 0.152 0.084
#> SRR1740086 1 0.226 0.818 0.932 0.000 0.068
#> SRR1740087 1 0.226 0.818 0.932 0.000 0.068
#> SRR1740088 1 0.226 0.818 0.932 0.000 0.068
#> SRR1740089 1 0.226 0.818 0.932 0.000 0.068
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 4 0.4382 0.984 0.296 0.000 0.000 0.704
#> SRR1740035 4 0.4382 0.984 0.296 0.000 0.000 0.704
#> SRR1740036 4 0.4382 0.984 0.296 0.000 0.000 0.704
#> SRR1740037 4 0.4382 0.984 0.296 0.000 0.000 0.704
#> SRR1740038 2 0.6923 0.919 0.012 0.612 0.252 0.124
#> SRR1740039 2 0.6923 0.919 0.012 0.612 0.252 0.124
#> SRR1740040 2 0.6923 0.919 0.012 0.612 0.252 0.124
#> SRR1740041 2 0.6923 0.919 0.012 0.612 0.252 0.124
#> SRR1740042 2 0.4576 0.918 0.012 0.728 0.260 0.000
#> SRR1740043 2 0.4576 0.918 0.012 0.728 0.260 0.000
#> SRR1740044 2 0.4576 0.918 0.012 0.728 0.260 0.000
#> SRR1740045 2 0.4576 0.918 0.012 0.728 0.260 0.000
#> SRR1740046 3 0.2909 0.951 0.000 0.020 0.888 0.092
#> SRR1740048 3 0.2949 0.951 0.000 0.024 0.888 0.088
#> SRR1740047 3 0.2949 0.951 0.000 0.024 0.888 0.088
#> SRR1740049 3 0.2909 0.951 0.000 0.020 0.888 0.092
#> SRR1740050 1 0.0859 0.604 0.980 0.008 0.004 0.008
#> SRR1740051 1 0.0859 0.604 0.980 0.008 0.004 0.008
#> SRR1740052 1 0.0859 0.604 0.980 0.008 0.004 0.008
#> SRR1740054 1 0.7163 0.512 0.576 0.232 0.004 0.188
#> SRR1740053 1 0.0859 0.604 0.980 0.008 0.004 0.008
#> SRR1740056 1 0.7163 0.512 0.576 0.232 0.004 0.188
#> SRR1740055 1 0.7163 0.512 0.576 0.232 0.004 0.188
#> SRR1740057 1 0.7163 0.512 0.576 0.232 0.004 0.188
#> SRR1740058 1 0.6198 0.500 0.672 0.152 0.000 0.176
#> SRR1740059 1 0.6198 0.500 0.672 0.152 0.000 0.176
#> SRR1740060 1 0.6198 0.500 0.672 0.152 0.000 0.176
#> SRR1740061 1 0.6198 0.500 0.672 0.152 0.000 0.176
#> SRR1740062 4 0.5369 0.984 0.296 0.016 0.012 0.676
#> SRR1740063 4 0.5369 0.984 0.296 0.016 0.012 0.676
#> SRR1740064 4 0.5369 0.984 0.296 0.016 0.012 0.676
#> SRR1740065 4 0.5369 0.984 0.296 0.016 0.012 0.676
#> SRR1740066 2 0.6969 0.919 0.012 0.608 0.252 0.128
#> SRR1740067 2 0.6969 0.919 0.012 0.608 0.252 0.128
#> SRR1740068 2 0.6969 0.919 0.012 0.608 0.252 0.128
#> SRR1740069 2 0.6969 0.919 0.012 0.608 0.252 0.128
#> SRR1740070 2 0.4755 0.918 0.012 0.724 0.260 0.004
#> SRR1740071 2 0.4755 0.918 0.012 0.724 0.260 0.004
#> SRR1740072 2 0.4755 0.918 0.012 0.724 0.260 0.004
#> SRR1740073 2 0.4755 0.918 0.012 0.724 0.260 0.004
#> SRR1740074 3 0.0779 0.951 0.000 0.016 0.980 0.004
#> SRR1740075 3 0.0779 0.951 0.000 0.016 0.980 0.004
#> SRR1740076 3 0.0707 0.951 0.000 0.020 0.980 0.000
#> SRR1740077 3 0.0707 0.951 0.000 0.020 0.980 0.000
#> SRR1740078 1 0.0592 0.604 0.984 0.000 0.000 0.016
#> SRR1740079 1 0.0592 0.604 0.984 0.000 0.000 0.016
#> SRR1740080 1 0.0592 0.604 0.984 0.000 0.000 0.016
#> SRR1740081 1 0.0592 0.604 0.984 0.000 0.000 0.016
#> SRR1740082 1 0.7163 0.512 0.576 0.232 0.004 0.188
#> SRR1740083 1 0.7163 0.512 0.576 0.232 0.004 0.188
#> SRR1740084 1 0.7163 0.512 0.576 0.232 0.004 0.188
#> SRR1740085 1 0.7163 0.512 0.576 0.232 0.004 0.188
#> SRR1740086 1 0.6198 0.500 0.672 0.152 0.000 0.176
#> SRR1740087 1 0.6198 0.500 0.672 0.152 0.000 0.176
#> SRR1740088 1 0.6198 0.500 0.672 0.152 0.000 0.176
#> SRR1740089 1 0.6198 0.500 0.672 0.152 0.000 0.176
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.6477 0.944 0.292 0.000 0.036 0.564 0.108
#> SRR1740035 4 0.6477 0.944 0.292 0.000 0.036 0.564 0.108
#> SRR1740036 4 0.6477 0.944 0.292 0.000 0.036 0.564 0.108
#> SRR1740037 4 0.6477 0.944 0.292 0.000 0.036 0.564 0.108
#> SRR1740038 2 0.5401 0.805 0.084 0.696 0.000 0.196 0.024
#> SRR1740039 2 0.5401 0.805 0.084 0.696 0.000 0.196 0.024
#> SRR1740040 2 0.5401 0.805 0.084 0.696 0.000 0.196 0.024
#> SRR1740041 2 0.5401 0.805 0.084 0.696 0.000 0.196 0.024
#> SRR1740042 2 0.0324 0.806 0.004 0.992 0.000 0.000 0.004
#> SRR1740043 2 0.0324 0.806 0.004 0.992 0.000 0.000 0.004
#> SRR1740044 2 0.0324 0.806 0.004 0.992 0.000 0.000 0.004
#> SRR1740045 2 0.0324 0.806 0.004 0.992 0.000 0.000 0.004
#> SRR1740046 3 0.3427 0.928 0.012 0.192 0.796 0.000 0.000
#> SRR1740048 3 0.3427 0.928 0.000 0.192 0.796 0.012 0.000
#> SRR1740047 3 0.3427 0.928 0.000 0.192 0.796 0.012 0.000
#> SRR1740049 3 0.3427 0.928 0.012 0.192 0.796 0.000 0.000
#> SRR1740050 5 0.4234 0.328 0.252 0.000 0.004 0.020 0.724
#> SRR1740051 5 0.4167 0.328 0.252 0.000 0.000 0.024 0.724
#> SRR1740052 5 0.4167 0.328 0.252 0.000 0.000 0.024 0.724
#> SRR1740054 5 0.6761 0.512 0.096 0.060 0.104 0.072 0.668
#> SRR1740053 5 0.4234 0.328 0.252 0.000 0.004 0.020 0.724
#> SRR1740056 5 0.6761 0.512 0.096 0.060 0.104 0.072 0.668
#> SRR1740055 5 0.6761 0.512 0.096 0.060 0.104 0.072 0.668
#> SRR1740057 5 0.6808 0.510 0.100 0.060 0.104 0.072 0.664
#> SRR1740058 1 0.3534 0.992 0.744 0.000 0.000 0.000 0.256
#> SRR1740059 1 0.3534 0.992 0.744 0.000 0.000 0.000 0.256
#> SRR1740060 1 0.3534 0.992 0.744 0.000 0.000 0.000 0.256
#> SRR1740061 1 0.3534 0.992 0.744 0.000 0.000 0.000 0.256
#> SRR1740062 4 0.5303 0.943 0.232 0.000 0.000 0.660 0.108
#> SRR1740063 4 0.5303 0.943 0.232 0.000 0.000 0.660 0.108
#> SRR1740064 4 0.5546 0.942 0.228 0.000 0.008 0.656 0.108
#> SRR1740065 4 0.5429 0.943 0.228 0.000 0.004 0.660 0.108
#> SRR1740066 2 0.5385 0.805 0.076 0.692 0.000 0.208 0.024
#> SRR1740067 2 0.5385 0.805 0.076 0.692 0.000 0.208 0.024
#> SRR1740068 2 0.5385 0.805 0.076 0.692 0.000 0.208 0.024
#> SRR1740069 2 0.5385 0.805 0.076 0.692 0.000 0.208 0.024
#> SRR1740070 2 0.0324 0.806 0.000 0.992 0.000 0.004 0.004
#> SRR1740071 2 0.0324 0.806 0.000 0.992 0.000 0.004 0.004
#> SRR1740072 2 0.0324 0.806 0.000 0.992 0.000 0.004 0.004
#> SRR1740073 2 0.0324 0.806 0.000 0.992 0.000 0.004 0.004
#> SRR1740074 3 0.5927 0.929 0.088 0.192 0.668 0.052 0.000
#> SRR1740075 3 0.5927 0.929 0.088 0.192 0.668 0.052 0.000
#> SRR1740076 3 0.5948 0.929 0.080 0.192 0.668 0.060 0.000
#> SRR1740077 3 0.5948 0.929 0.080 0.192 0.668 0.060 0.000
#> SRR1740078 5 0.4321 0.328 0.252 0.000 0.024 0.004 0.720
#> SRR1740079 5 0.4321 0.328 0.252 0.000 0.024 0.004 0.720
#> SRR1740080 5 0.4354 0.328 0.252 0.000 0.020 0.008 0.720
#> SRR1740081 5 0.4354 0.328 0.252 0.000 0.020 0.008 0.720
#> SRR1740082 5 0.6851 0.512 0.096 0.060 0.112 0.072 0.660
#> SRR1740083 5 0.6851 0.512 0.096 0.060 0.112 0.072 0.660
#> SRR1740084 5 0.6851 0.512 0.096 0.060 0.112 0.072 0.660
#> SRR1740085 5 0.6851 0.512 0.096 0.060 0.112 0.072 0.660
#> SRR1740086 1 0.3916 0.992 0.732 0.000 0.012 0.000 0.256
#> SRR1740087 1 0.3916 0.992 0.732 0.000 0.012 0.000 0.256
#> SRR1740088 1 0.3916 0.992 0.732 0.000 0.012 0.000 0.256
#> SRR1740089 1 0.3916 0.992 0.732 0.000 0.012 0.000 0.256
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.2213 0.918 0.100 0.000 0.008 0.888 0.000 0.004
#> SRR1740035 4 0.2170 0.918 0.100 0.000 0.012 0.888 0.000 0.000
#> SRR1740036 4 0.2213 0.918 0.100 0.000 0.008 0.888 0.000 0.004
#> SRR1740037 4 0.2170 0.918 0.100 0.000 0.000 0.888 0.012 0.000
#> SRR1740038 2 0.0547 0.762 0.020 0.980 0.000 0.000 0.000 0.000
#> SRR1740039 2 0.0547 0.762 0.020 0.980 0.000 0.000 0.000 0.000
#> SRR1740040 2 0.0547 0.762 0.020 0.980 0.000 0.000 0.000 0.000
#> SRR1740041 2 0.0547 0.762 0.020 0.980 0.000 0.000 0.000 0.000
#> SRR1740042 2 0.5055 0.750 0.004 0.604 0.000 0.008 0.064 0.320
#> SRR1740043 2 0.5055 0.750 0.004 0.604 0.000 0.008 0.064 0.320
#> SRR1740044 2 0.5055 0.750 0.004 0.604 0.000 0.008 0.064 0.320
#> SRR1740045 2 0.5055 0.750 0.004 0.604 0.000 0.008 0.064 0.320
#> SRR1740046 3 0.2266 0.918 0.000 0.108 0.880 0.000 0.012 0.000
#> SRR1740048 3 0.2358 0.918 0.000 0.108 0.876 0.000 0.000 0.016
#> SRR1740047 3 0.2358 0.918 0.000 0.108 0.876 0.000 0.000 0.016
#> SRR1740049 3 0.2266 0.918 0.000 0.108 0.880 0.000 0.012 0.000
#> SRR1740050 5 0.5622 0.956 0.296 0.000 0.016 0.068 0.596 0.024
#> SRR1740051 5 0.5548 0.956 0.296 0.000 0.016 0.068 0.600 0.020
#> SRR1740052 5 0.5548 0.956 0.296 0.000 0.016 0.068 0.600 0.020
#> SRR1740054 1 0.1007 0.970 0.956 0.044 0.000 0.000 0.000 0.000
#> SRR1740053 5 0.5622 0.956 0.296 0.000 0.016 0.068 0.596 0.024
#> SRR1740056 1 0.1007 0.970 0.956 0.044 0.000 0.000 0.000 0.000
#> SRR1740055 1 0.1007 0.970 0.956 0.044 0.000 0.000 0.000 0.000
#> SRR1740057 1 0.1007 0.970 0.956 0.044 0.000 0.000 0.000 0.000
#> SRR1740058 6 0.7876 0.958 0.188 0.000 0.016 0.180 0.276 0.340
#> SRR1740059 6 0.7876 0.958 0.188 0.000 0.016 0.180 0.276 0.340
#> SRR1740060 6 0.7876 0.958 0.188 0.000 0.016 0.180 0.276 0.340
#> SRR1740061 6 0.7876 0.958 0.188 0.000 0.016 0.180 0.276 0.340
#> SRR1740062 4 0.4880 0.918 0.108 0.000 0.024 0.752 0.056 0.060
#> SRR1740063 4 0.4880 0.918 0.108 0.000 0.024 0.752 0.056 0.060
#> SRR1740064 4 0.4902 0.917 0.104 0.000 0.028 0.752 0.048 0.068
#> SRR1740065 4 0.4877 0.918 0.108 0.000 0.024 0.752 0.052 0.064
#> SRR1740066 2 0.1596 0.762 0.020 0.944 0.000 0.012 0.020 0.004
#> SRR1740067 2 0.1596 0.762 0.020 0.944 0.000 0.012 0.020 0.004
#> SRR1740068 2 0.1596 0.762 0.020 0.944 0.000 0.012 0.020 0.004
#> SRR1740069 2 0.1596 0.762 0.020 0.944 0.000 0.012 0.020 0.004
#> SRR1740070 2 0.3890 0.750 0.004 0.596 0.000 0.000 0.000 0.400
#> SRR1740071 2 0.3890 0.750 0.004 0.596 0.000 0.000 0.000 0.400
#> SRR1740072 2 0.3890 0.750 0.004 0.596 0.000 0.000 0.000 0.400
#> SRR1740073 2 0.3890 0.750 0.004 0.596 0.000 0.000 0.000 0.400
#> SRR1740074 3 0.5570 0.919 0.016 0.108 0.720 0.032 0.060 0.064
#> SRR1740075 3 0.5570 0.919 0.016 0.108 0.720 0.032 0.060 0.064
#> SRR1740076 3 0.5499 0.919 0.016 0.108 0.724 0.028 0.064 0.060
#> SRR1740077 3 0.5499 0.919 0.016 0.108 0.724 0.028 0.064 0.060
#> SRR1740078 5 0.4612 0.955 0.284 0.000 0.000 0.052 0.656 0.008
#> SRR1740079 5 0.4612 0.955 0.284 0.000 0.000 0.052 0.656 0.008
#> SRR1740080 5 0.4507 0.955 0.284 0.000 0.004 0.052 0.660 0.000
#> SRR1740081 5 0.4507 0.955 0.284 0.000 0.004 0.052 0.660 0.000
#> SRR1740082 1 0.2420 0.970 0.904 0.044 0.028 0.000 0.008 0.016
#> SRR1740083 1 0.2420 0.970 0.904 0.044 0.028 0.000 0.008 0.016
#> SRR1740084 1 0.2420 0.970 0.904 0.044 0.028 0.000 0.008 0.016
#> SRR1740085 1 0.2420 0.970 0.904 0.044 0.028 0.000 0.008 0.016
#> SRR1740086 6 0.7522 0.957 0.184 0.000 0.004 0.180 0.232 0.400
#> SRR1740087 6 0.7522 0.957 0.184 0.000 0.004 0.180 0.232 0.400
#> SRR1740088 6 0.7414 0.957 0.188 0.000 0.000 0.180 0.232 0.400
#> SRR1740089 6 0.7414 0.957 0.188 0.000 0.000 0.180 0.232 0.400
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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.998 0.999 0.4993 0.501 0.501
#> 3 3 0.709 0.809 0.837 0.2177 1.000 1.000
#> 4 4 0.834 0.871 0.822 0.1649 0.792 0.585
#> 5 5 0.958 0.973 0.974 0.1148 0.917 0.717
#> 6 6 1.000 0.989 0.975 0.0531 0.958 0.802
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 5
There is also optional best \(k\) = 2 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1740034 1 0.0000 0.997 1.000 0.000
#> SRR1740035 1 0.0000 0.997 1.000 0.000
#> SRR1740036 1 0.0000 0.997 1.000 0.000
#> SRR1740037 1 0.0000 0.997 1.000 0.000
#> SRR1740038 2 0.0000 1.000 0.000 1.000
#> SRR1740039 2 0.0000 1.000 0.000 1.000
#> SRR1740040 2 0.0000 1.000 0.000 1.000
#> SRR1740041 2 0.0000 1.000 0.000 1.000
#> SRR1740042 2 0.0000 1.000 0.000 1.000
#> SRR1740043 2 0.0000 1.000 0.000 1.000
#> SRR1740044 2 0.0000 1.000 0.000 1.000
#> SRR1740045 2 0.0000 1.000 0.000 1.000
#> SRR1740046 2 0.0000 1.000 0.000 1.000
#> SRR1740048 2 0.0000 1.000 0.000 1.000
#> SRR1740047 2 0.0000 1.000 0.000 1.000
#> SRR1740049 2 0.0000 1.000 0.000 1.000
#> SRR1740050 1 0.0000 0.997 1.000 0.000
#> SRR1740051 1 0.0000 0.997 1.000 0.000
#> SRR1740052 1 0.0000 0.997 1.000 0.000
#> SRR1740054 1 0.0938 0.990 0.988 0.012
#> SRR1740053 1 0.0000 0.997 1.000 0.000
#> SRR1740056 1 0.0938 0.990 0.988 0.012
#> SRR1740055 1 0.0938 0.990 0.988 0.012
#> SRR1740057 1 0.0000 0.997 1.000 0.000
#> SRR1740058 1 0.0000 0.997 1.000 0.000
#> SRR1740059 1 0.0000 0.997 1.000 0.000
#> SRR1740060 1 0.0000 0.997 1.000 0.000
#> SRR1740061 1 0.0000 0.997 1.000 0.000
#> SRR1740062 1 0.0000 0.997 1.000 0.000
#> SRR1740063 1 0.0000 0.997 1.000 0.000
#> SRR1740064 1 0.0000 0.997 1.000 0.000
#> SRR1740065 1 0.0000 0.997 1.000 0.000
#> SRR1740066 2 0.0000 1.000 0.000 1.000
#> SRR1740067 2 0.0000 1.000 0.000 1.000
#> SRR1740068 2 0.0000 1.000 0.000 1.000
#> SRR1740069 2 0.0000 1.000 0.000 1.000
#> SRR1740070 2 0.0000 1.000 0.000 1.000
#> SRR1740071 2 0.0000 1.000 0.000 1.000
#> SRR1740072 2 0.0000 1.000 0.000 1.000
#> SRR1740073 2 0.0000 1.000 0.000 1.000
#> SRR1740074 2 0.0000 1.000 0.000 1.000
#> SRR1740075 2 0.0000 1.000 0.000 1.000
#> SRR1740076 2 0.0000 1.000 0.000 1.000
#> SRR1740077 2 0.0000 1.000 0.000 1.000
#> SRR1740078 1 0.0000 0.997 1.000 0.000
#> SRR1740079 1 0.0000 0.997 1.000 0.000
#> SRR1740080 1 0.0000 0.997 1.000 0.000
#> SRR1740081 1 0.0000 0.997 1.000 0.000
#> SRR1740082 1 0.0938 0.990 0.988 0.012
#> SRR1740083 1 0.0938 0.990 0.988 0.012
#> SRR1740084 1 0.0938 0.990 0.988 0.012
#> SRR1740085 1 0.0938 0.990 0.988 0.012
#> SRR1740086 1 0.0000 0.997 1.000 0.000
#> SRR1740087 1 0.0000 0.997 1.000 0.000
#> SRR1740088 1 0.0000 0.997 1.000 0.000
#> SRR1740089 1 0.0000 0.997 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0.3752 0.814 0.856 0.000 0.144
#> SRR1740035 1 0.3752 0.814 0.856 0.000 0.144
#> SRR1740036 1 0.3752 0.814 0.856 0.000 0.144
#> SRR1740037 1 0.3752 0.814 0.856 0.000 0.144
#> SRR1740038 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740039 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740040 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740041 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740042 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740043 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740044 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740045 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740046 2 0.6192 0.753 0.000 0.580 0.420
#> SRR1740048 2 0.6192 0.753 0.000 0.580 0.420
#> SRR1740047 2 0.6192 0.753 0.000 0.580 0.420
#> SRR1740049 2 0.6192 0.753 0.000 0.580 0.420
#> SRR1740050 1 0.0237 0.858 0.996 0.000 0.004
#> SRR1740051 1 0.0237 0.858 0.996 0.000 0.004
#> SRR1740052 1 0.0237 0.858 0.996 0.000 0.004
#> SRR1740054 1 0.7453 0.613 0.528 0.036 0.436
#> SRR1740053 1 0.0237 0.858 0.996 0.000 0.004
#> SRR1740056 1 0.7453 0.613 0.528 0.036 0.436
#> SRR1740055 1 0.7453 0.613 0.528 0.036 0.436
#> SRR1740057 1 0.7453 0.613 0.528 0.036 0.436
#> SRR1740058 1 0.0000 0.858 1.000 0.000 0.000
#> SRR1740059 1 0.0000 0.858 1.000 0.000 0.000
#> SRR1740060 1 0.0000 0.858 1.000 0.000 0.000
#> SRR1740061 1 0.0000 0.858 1.000 0.000 0.000
#> SRR1740062 1 0.3752 0.814 0.856 0.000 0.144
#> SRR1740063 1 0.3752 0.814 0.856 0.000 0.144
#> SRR1740064 1 0.3752 0.814 0.856 0.000 0.144
#> SRR1740065 1 0.3752 0.814 0.856 0.000 0.144
#> SRR1740066 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740067 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740068 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740069 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740070 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740071 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740072 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740073 2 0.0000 0.885 0.000 1.000 0.000
#> SRR1740074 2 0.6192 0.753 0.000 0.580 0.420
#> SRR1740075 2 0.6192 0.753 0.000 0.580 0.420
#> SRR1740076 2 0.6192 0.753 0.000 0.580 0.420
#> SRR1740077 2 0.6192 0.753 0.000 0.580 0.420
#> SRR1740078 1 0.0237 0.858 0.996 0.000 0.004
#> SRR1740079 1 0.0237 0.858 0.996 0.000 0.004
#> SRR1740080 1 0.0237 0.858 0.996 0.000 0.004
#> SRR1740081 1 0.0237 0.858 0.996 0.000 0.004
#> SRR1740082 1 0.7453 0.613 0.528 0.036 0.436
#> SRR1740083 1 0.7453 0.613 0.528 0.036 0.436
#> SRR1740084 1 0.7453 0.613 0.528 0.036 0.436
#> SRR1740085 1 0.7453 0.613 0.528 0.036 0.436
#> SRR1740086 1 0.0000 0.858 1.000 0.000 0.000
#> SRR1740087 1 0.0000 0.858 1.000 0.000 0.000
#> SRR1740088 1 0.0000 0.858 1.000 0.000 0.000
#> SRR1740089 1 0.0000 0.858 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 1 0.6309 0.607 0.588 0.000 0.076 0.336
#> SRR1740035 1 0.6309 0.607 0.588 0.000 0.076 0.336
#> SRR1740036 1 0.6309 0.607 0.588 0.000 0.076 0.336
#> SRR1740037 1 0.6309 0.607 0.588 0.000 0.076 0.336
#> SRR1740038 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740039 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740040 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740041 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740042 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740043 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740044 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740045 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740046 3 0.2149 1.000 0.000 0.088 0.912 0.000
#> SRR1740048 3 0.2149 1.000 0.000 0.088 0.912 0.000
#> SRR1740047 3 0.2149 1.000 0.000 0.088 0.912 0.000
#> SRR1740049 3 0.2149 1.000 0.000 0.088 0.912 0.000
#> SRR1740050 1 0.1677 0.736 0.948 0.000 0.012 0.040
#> SRR1740051 1 0.1677 0.736 0.948 0.000 0.012 0.040
#> SRR1740052 1 0.1677 0.736 0.948 0.000 0.012 0.040
#> SRR1740054 4 0.4661 1.000 0.348 0.000 0.000 0.652
#> SRR1740053 1 0.1677 0.736 0.948 0.000 0.012 0.040
#> SRR1740056 4 0.4661 1.000 0.348 0.000 0.000 0.652
#> SRR1740055 4 0.4661 1.000 0.348 0.000 0.000 0.652
#> SRR1740057 4 0.4661 1.000 0.348 0.000 0.000 0.652
#> SRR1740058 1 0.0188 0.750 0.996 0.000 0.000 0.004
#> SRR1740059 1 0.0188 0.750 0.996 0.000 0.000 0.004
#> SRR1740060 1 0.0188 0.750 0.996 0.000 0.000 0.004
#> SRR1740061 1 0.0188 0.750 0.996 0.000 0.000 0.004
#> SRR1740062 1 0.6309 0.607 0.588 0.000 0.076 0.336
#> SRR1740063 1 0.6309 0.607 0.588 0.000 0.076 0.336
#> SRR1740064 1 0.6309 0.607 0.588 0.000 0.076 0.336
#> SRR1740065 1 0.6309 0.607 0.588 0.000 0.076 0.336
#> SRR1740066 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740067 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740068 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740069 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740070 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740071 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740072 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740073 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1740074 3 0.2149 1.000 0.000 0.088 0.912 0.000
#> SRR1740075 3 0.2149 1.000 0.000 0.088 0.912 0.000
#> SRR1740076 3 0.2149 1.000 0.000 0.088 0.912 0.000
#> SRR1740077 3 0.2149 1.000 0.000 0.088 0.912 0.000
#> SRR1740078 1 0.1677 0.736 0.948 0.000 0.012 0.040
#> SRR1740079 1 0.1677 0.736 0.948 0.000 0.012 0.040
#> SRR1740080 1 0.1677 0.736 0.948 0.000 0.012 0.040
#> SRR1740081 1 0.1677 0.736 0.948 0.000 0.012 0.040
#> SRR1740082 4 0.4661 1.000 0.348 0.000 0.000 0.652
#> SRR1740083 4 0.4661 1.000 0.348 0.000 0.000 0.652
#> SRR1740084 4 0.4661 1.000 0.348 0.000 0.000 0.652
#> SRR1740085 4 0.4661 1.000 0.348 0.000 0.000 0.652
#> SRR1740086 1 0.0188 0.750 0.996 0.000 0.000 0.004
#> SRR1740087 1 0.0188 0.750 0.996 0.000 0.000 0.004
#> SRR1740088 1 0.0188 0.750 0.996 0.000 0.000 0.004
#> SRR1740089 1 0.0188 0.750 0.996 0.000 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.0000 1.000 0.000 0.000 0 1.00 0.000
#> SRR1740035 4 0.0000 1.000 0.000 0.000 0 1.00 0.000
#> SRR1740036 4 0.0000 1.000 0.000 0.000 0 1.00 0.000
#> SRR1740037 4 0.0000 1.000 0.000 0.000 0 1.00 0.000
#> SRR1740038 2 0.0290 0.997 0.008 0.992 0 0.00 0.000
#> SRR1740039 2 0.0290 0.997 0.008 0.992 0 0.00 0.000
#> SRR1740040 2 0.0290 0.997 0.008 0.992 0 0.00 0.000
#> SRR1740041 2 0.0290 0.997 0.008 0.992 0 0.00 0.000
#> SRR1740042 2 0.0000 0.997 0.000 1.000 0 0.00 0.000
#> SRR1740043 2 0.0000 0.997 0.000 1.000 0 0.00 0.000
#> SRR1740044 2 0.0000 0.997 0.000 1.000 0 0.00 0.000
#> SRR1740045 2 0.0000 0.997 0.000 1.000 0 0.00 0.000
#> SRR1740046 3 0.0000 1.000 0.000 0.000 1 0.00 0.000
#> SRR1740048 3 0.0000 1.000 0.000 0.000 1 0.00 0.000
#> SRR1740047 3 0.0000 1.000 0.000 0.000 1 0.00 0.000
#> SRR1740049 3 0.0000 1.000 0.000 0.000 1 0.00 0.000
#> SRR1740050 5 0.0162 0.911 0.004 0.000 0 0.00 0.996
#> SRR1740051 5 0.0162 0.911 0.004 0.000 0 0.00 0.996
#> SRR1740052 5 0.0162 0.911 0.004 0.000 0 0.00 0.996
#> SRR1740054 1 0.0290 1.000 0.992 0.000 0 0.00 0.008
#> SRR1740053 5 0.0162 0.911 0.004 0.000 0 0.00 0.996
#> SRR1740056 1 0.0290 1.000 0.992 0.000 0 0.00 0.008
#> SRR1740055 1 0.0290 1.000 0.992 0.000 0 0.00 0.008
#> SRR1740057 1 0.0290 1.000 0.992 0.000 0 0.00 0.008
#> SRR1740058 5 0.3479 0.908 0.084 0.000 0 0.08 0.836
#> SRR1740059 5 0.3479 0.908 0.084 0.000 0 0.08 0.836
#> SRR1740060 5 0.3479 0.908 0.084 0.000 0 0.08 0.836
#> SRR1740061 5 0.3479 0.908 0.084 0.000 0 0.08 0.836
#> SRR1740062 4 0.0000 1.000 0.000 0.000 0 1.00 0.000
#> SRR1740063 4 0.0000 1.000 0.000 0.000 0 1.00 0.000
#> SRR1740064 4 0.0000 1.000 0.000 0.000 0 1.00 0.000
#> SRR1740065 4 0.0000 1.000 0.000 0.000 0 1.00 0.000
#> SRR1740066 2 0.0290 0.997 0.008 0.992 0 0.00 0.000
#> SRR1740067 2 0.0290 0.997 0.008 0.992 0 0.00 0.000
#> SRR1740068 2 0.0290 0.997 0.008 0.992 0 0.00 0.000
#> SRR1740069 2 0.0290 0.997 0.008 0.992 0 0.00 0.000
#> SRR1740070 2 0.0000 0.997 0.000 1.000 0 0.00 0.000
#> SRR1740071 2 0.0000 0.997 0.000 1.000 0 0.00 0.000
#> SRR1740072 2 0.0000 0.997 0.000 1.000 0 0.00 0.000
#> SRR1740073 2 0.0000 0.997 0.000 1.000 0 0.00 0.000
#> SRR1740074 3 0.0000 1.000 0.000 0.000 1 0.00 0.000
#> SRR1740075 3 0.0000 1.000 0.000 0.000 1 0.00 0.000
#> SRR1740076 3 0.0000 1.000 0.000 0.000 1 0.00 0.000
#> SRR1740077 3 0.0000 1.000 0.000 0.000 1 0.00 0.000
#> SRR1740078 5 0.0162 0.911 0.004 0.000 0 0.00 0.996
#> SRR1740079 5 0.0162 0.911 0.004 0.000 0 0.00 0.996
#> SRR1740080 5 0.0162 0.911 0.004 0.000 0 0.00 0.996
#> SRR1740081 5 0.0162 0.911 0.004 0.000 0 0.00 0.996
#> SRR1740082 1 0.0290 1.000 0.992 0.000 0 0.00 0.008
#> SRR1740083 1 0.0290 1.000 0.992 0.000 0 0.00 0.008
#> SRR1740084 1 0.0290 1.000 0.992 0.000 0 0.00 0.008
#> SRR1740085 1 0.0290 1.000 0.992 0.000 0 0.00 0.008
#> SRR1740086 5 0.3479 0.908 0.084 0.000 0 0.08 0.836
#> SRR1740087 5 0.3479 0.908 0.084 0.000 0 0.08 0.836
#> SRR1740088 5 0.3479 0.908 0.084 0.000 0 0.08 0.836
#> SRR1740089 5 0.3479 0.908 0.084 0.000 0 0.08 0.836
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.000 1.000 0.000 0.000 0 1.000 0.00 0.000
#> SRR1740035 4 0.000 1.000 0.000 0.000 0 1.000 0.00 0.000
#> SRR1740036 4 0.000 1.000 0.000 0.000 0 1.000 0.00 0.000
#> SRR1740037 4 0.000 1.000 0.000 0.000 0 1.000 0.00 0.000
#> SRR1740038 2 0.000 0.961 0.000 1.000 0 0.000 0.00 0.000
#> SRR1740039 2 0.000 0.961 0.000 1.000 0 0.000 0.00 0.000
#> SRR1740040 2 0.000 0.961 0.000 1.000 0 0.000 0.00 0.000
#> SRR1740041 2 0.000 0.961 0.000 1.000 0 0.000 0.00 0.000
#> SRR1740042 2 0.166 0.961 0.000 0.912 0 0.000 0.00 0.088
#> SRR1740043 2 0.166 0.961 0.000 0.912 0 0.000 0.00 0.088
#> SRR1740044 2 0.166 0.961 0.000 0.912 0 0.000 0.00 0.088
#> SRR1740045 2 0.166 0.961 0.000 0.912 0 0.000 0.00 0.088
#> SRR1740046 3 0.000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> SRR1740048 3 0.000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> SRR1740047 3 0.000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> SRR1740049 3 0.000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> SRR1740050 5 0.000 1.000 0.000 0.000 0 0.000 1.00 0.000
#> SRR1740051 5 0.000 1.000 0.000 0.000 0 0.000 1.00 0.000
#> SRR1740052 5 0.000 1.000 0.000 0.000 0 0.000 1.00 0.000
#> SRR1740054 1 0.000 1.000 1.000 0.000 0 0.000 0.00 0.000
#> SRR1740053 5 0.000 1.000 0.000 0.000 0 0.000 1.00 0.000
#> SRR1740056 1 0.000 1.000 1.000 0.000 0 0.000 0.00 0.000
#> SRR1740055 1 0.000 1.000 1.000 0.000 0 0.000 0.00 0.000
#> SRR1740057 1 0.000 1.000 1.000 0.000 0 0.000 0.00 0.000
#> SRR1740058 6 0.184 1.000 0.004 0.000 0 0.004 0.08 0.912
#> SRR1740059 6 0.184 1.000 0.004 0.000 0 0.004 0.08 0.912
#> SRR1740060 6 0.184 1.000 0.004 0.000 0 0.004 0.08 0.912
#> SRR1740061 6 0.184 1.000 0.004 0.000 0 0.004 0.08 0.912
#> SRR1740062 4 0.000 1.000 0.000 0.000 0 1.000 0.00 0.000
#> SRR1740063 4 0.000 1.000 0.000 0.000 0 1.000 0.00 0.000
#> SRR1740064 4 0.000 1.000 0.000 0.000 0 1.000 0.00 0.000
#> SRR1740065 4 0.000 1.000 0.000 0.000 0 1.000 0.00 0.000
#> SRR1740066 2 0.000 0.961 0.000 1.000 0 0.000 0.00 0.000
#> SRR1740067 2 0.000 0.961 0.000 1.000 0 0.000 0.00 0.000
#> SRR1740068 2 0.000 0.961 0.000 1.000 0 0.000 0.00 0.000
#> SRR1740069 2 0.000 0.961 0.000 1.000 0 0.000 0.00 0.000
#> SRR1740070 2 0.166 0.961 0.000 0.912 0 0.000 0.00 0.088
#> SRR1740071 2 0.166 0.961 0.000 0.912 0 0.000 0.00 0.088
#> SRR1740072 2 0.166 0.961 0.000 0.912 0 0.000 0.00 0.088
#> SRR1740073 2 0.166 0.961 0.000 0.912 0 0.000 0.00 0.088
#> SRR1740074 3 0.000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> SRR1740075 3 0.000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> SRR1740076 3 0.000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> SRR1740077 3 0.000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> SRR1740078 5 0.000 1.000 0.000 0.000 0 0.000 1.00 0.000
#> SRR1740079 5 0.000 1.000 0.000 0.000 0 0.000 1.00 0.000
#> SRR1740080 5 0.000 1.000 0.000 0.000 0 0.000 1.00 0.000
#> SRR1740081 5 0.000 1.000 0.000 0.000 0 0.000 1.00 0.000
#> SRR1740082 1 0.000 1.000 1.000 0.000 0 0.000 0.00 0.000
#> SRR1740083 1 0.000 1.000 1.000 0.000 0 0.000 0.00 0.000
#> SRR1740084 1 0.000 1.000 1.000 0.000 0 0.000 0.00 0.000
#> SRR1740085 1 0.000 1.000 1.000 0.000 0 0.000 0.00 0.000
#> SRR1740086 6 0.184 1.000 0.004 0.000 0 0.004 0.08 0.912
#> SRR1740087 6 0.184 1.000 0.004 0.000 0 0.004 0.08 0.912
#> SRR1740088 6 0.184 1.000 0.004 0.000 0 0.004 0.08 0.912
#> SRR1740089 6 0.184 1.000 0.004 0.000 0 0.004 0.08 0.912
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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.454 0.757 0.850 0.4008 0.501 0.501
#> 3 3 0.782 0.910 0.958 0.4882 0.917 0.834
#> 4 4 0.849 0.942 0.968 0.1864 0.875 0.702
#> 5 5 0.927 0.904 0.956 0.1203 0.912 0.701
#> 6 6 1.000 1.000 1.000 0.0486 0.954 0.781
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 5
There is also optional best \(k\) = 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1740034 1 0.000 0.901 1.000 0.000
#> SRR1740035 1 0.000 0.901 1.000 0.000
#> SRR1740036 1 0.000 0.901 1.000 0.000
#> SRR1740037 1 0.000 0.901 1.000 0.000
#> SRR1740038 2 0.971 0.725 0.400 0.600
#> SRR1740039 2 0.971 0.725 0.400 0.600
#> SRR1740040 2 0.971 0.725 0.400 0.600
#> SRR1740041 2 0.971 0.725 0.400 0.600
#> SRR1740042 2 0.971 0.725 0.400 0.600
#> SRR1740043 2 0.971 0.725 0.400 0.600
#> SRR1740044 2 0.971 0.725 0.400 0.600
#> SRR1740045 2 0.971 0.725 0.400 0.600
#> SRR1740046 2 0.000 0.628 0.000 1.000
#> SRR1740048 2 0.000 0.628 0.000 1.000
#> SRR1740047 2 0.000 0.628 0.000 1.000
#> SRR1740049 2 0.000 0.628 0.000 1.000
#> SRR1740050 1 0.000 0.901 1.000 0.000
#> SRR1740051 1 0.000 0.901 1.000 0.000
#> SRR1740052 1 0.000 0.901 1.000 0.000
#> SRR1740054 1 0.900 0.342 0.684 0.316
#> SRR1740053 1 0.000 0.901 1.000 0.000
#> SRR1740056 1 0.722 0.649 0.800 0.200
#> SRR1740055 1 0.900 0.342 0.684 0.316
#> SRR1740057 1 0.662 0.695 0.828 0.172
#> SRR1740058 1 0.000 0.901 1.000 0.000
#> SRR1740059 1 0.000 0.901 1.000 0.000
#> SRR1740060 1 0.000 0.901 1.000 0.000
#> SRR1740061 1 0.000 0.901 1.000 0.000
#> SRR1740062 1 0.000 0.901 1.000 0.000
#> SRR1740063 1 0.000 0.901 1.000 0.000
#> SRR1740064 1 0.000 0.901 1.000 0.000
#> SRR1740065 1 0.000 0.901 1.000 0.000
#> SRR1740066 2 0.971 0.725 0.400 0.600
#> SRR1740067 2 0.971 0.725 0.400 0.600
#> SRR1740068 2 0.971 0.725 0.400 0.600
#> SRR1740069 2 0.971 0.725 0.400 0.600
#> SRR1740070 2 0.971 0.725 0.400 0.600
#> SRR1740071 2 0.971 0.725 0.400 0.600
#> SRR1740072 2 0.971 0.725 0.400 0.600
#> SRR1740073 2 0.971 0.725 0.400 0.600
#> SRR1740074 2 0.000 0.628 0.000 1.000
#> SRR1740075 2 0.000 0.628 0.000 1.000
#> SRR1740076 2 0.000 0.628 0.000 1.000
#> SRR1740077 2 0.000 0.628 0.000 1.000
#> SRR1740078 1 0.000 0.901 1.000 0.000
#> SRR1740079 1 0.000 0.901 1.000 0.000
#> SRR1740080 1 0.000 0.901 1.000 0.000
#> SRR1740081 1 0.000 0.901 1.000 0.000
#> SRR1740082 1 0.900 0.342 0.684 0.316
#> SRR1740083 1 0.839 0.490 0.732 0.268
#> SRR1740084 1 0.722 0.649 0.800 0.200
#> SRR1740085 1 0.722 0.649 0.800 0.200
#> SRR1740086 1 0.000 0.901 1.000 0.000
#> SRR1740087 1 0.000 0.901 1.000 0.000
#> SRR1740088 1 0.000 0.901 1.000 0.000
#> SRR1740089 1 0.000 0.901 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0.000 0.914 1.000 0.000 0
#> SRR1740035 1 0.000 0.914 1.000 0.000 0
#> SRR1740036 1 0.000 0.914 1.000 0.000 0
#> SRR1740037 1 0.000 0.914 1.000 0.000 0
#> SRR1740038 2 0.000 1.000 0.000 1.000 0
#> SRR1740039 2 0.000 1.000 0.000 1.000 0
#> SRR1740040 2 0.000 1.000 0.000 1.000 0
#> SRR1740041 2 0.000 1.000 0.000 1.000 0
#> SRR1740042 2 0.000 1.000 0.000 1.000 0
#> SRR1740043 2 0.000 1.000 0.000 1.000 0
#> SRR1740044 2 0.000 1.000 0.000 1.000 0
#> SRR1740045 2 0.000 1.000 0.000 1.000 0
#> SRR1740046 3 0.000 1.000 0.000 0.000 1
#> SRR1740048 3 0.000 1.000 0.000 0.000 1
#> SRR1740047 3 0.000 1.000 0.000 0.000 1
#> SRR1740049 3 0.000 1.000 0.000 0.000 1
#> SRR1740050 1 0.000 0.914 1.000 0.000 0
#> SRR1740051 1 0.000 0.914 1.000 0.000 0
#> SRR1740052 1 0.000 0.914 1.000 0.000 0
#> SRR1740054 1 0.610 0.481 0.608 0.392 0
#> SRR1740053 1 0.000 0.914 1.000 0.000 0
#> SRR1740056 1 0.455 0.768 0.800 0.200 0
#> SRR1740055 1 0.610 0.481 0.608 0.392 0
#> SRR1740057 1 0.455 0.768 0.800 0.200 0
#> SRR1740058 1 0.000 0.914 1.000 0.000 0
#> SRR1740059 1 0.000 0.914 1.000 0.000 0
#> SRR1740060 1 0.000 0.914 1.000 0.000 0
#> SRR1740061 1 0.000 0.914 1.000 0.000 0
#> SRR1740062 1 0.000 0.914 1.000 0.000 0
#> SRR1740063 1 0.000 0.914 1.000 0.000 0
#> SRR1740064 1 0.000 0.914 1.000 0.000 0
#> SRR1740065 1 0.000 0.914 1.000 0.000 0
#> SRR1740066 2 0.000 1.000 0.000 1.000 0
#> SRR1740067 2 0.000 1.000 0.000 1.000 0
#> SRR1740068 2 0.000 1.000 0.000 1.000 0
#> SRR1740069 2 0.000 1.000 0.000 1.000 0
#> SRR1740070 2 0.000 1.000 0.000 1.000 0
#> SRR1740071 2 0.000 1.000 0.000 1.000 0
#> SRR1740072 2 0.000 1.000 0.000 1.000 0
#> SRR1740073 2 0.000 1.000 0.000 1.000 0
#> SRR1740074 3 0.000 1.000 0.000 0.000 1
#> SRR1740075 3 0.000 1.000 0.000 0.000 1
#> SRR1740076 3 0.000 1.000 0.000 0.000 1
#> SRR1740077 3 0.000 1.000 0.000 0.000 1
#> SRR1740078 1 0.000 0.914 1.000 0.000 0
#> SRR1740079 1 0.000 0.914 1.000 0.000 0
#> SRR1740080 1 0.000 0.914 1.000 0.000 0
#> SRR1740081 1 0.000 0.914 1.000 0.000 0
#> SRR1740082 1 0.610 0.481 0.608 0.392 0
#> SRR1740083 1 0.610 0.481 0.608 0.392 0
#> SRR1740084 1 0.455 0.768 0.800 0.200 0
#> SRR1740085 1 0.455 0.768 0.800 0.200 0
#> SRR1740086 1 0.000 0.914 1.000 0.000 0
#> SRR1740087 1 0.000 0.914 1.000 0.000 0
#> SRR1740088 1 0.000 0.914 1.000 0.000 0
#> SRR1740089 1 0.000 0.914 1.000 0.000 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 4 0.000 1.000 0.0 0.0 0 1
#> SRR1740035 4 0.000 1.000 0.0 0.0 0 1
#> SRR1740036 4 0.000 1.000 0.0 0.0 0 1
#> SRR1740037 4 0.000 1.000 0.0 0.0 0 1
#> SRR1740038 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740039 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740040 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740041 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740042 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740043 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740044 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740045 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740046 3 0.000 1.000 0.0 0.0 1 0
#> SRR1740048 3 0.000 1.000 0.0 0.0 1 0
#> SRR1740047 3 0.000 1.000 0.0 0.0 1 0
#> SRR1740049 3 0.000 1.000 0.0 0.0 1 0
#> SRR1740050 1 0.000 0.910 1.0 0.0 0 0
#> SRR1740051 1 0.000 0.910 1.0 0.0 0 0
#> SRR1740052 1 0.000 0.910 1.0 0.0 0 0
#> SRR1740054 1 0.361 0.813 0.8 0.2 0 0
#> SRR1740053 1 0.000 0.910 1.0 0.0 0 0
#> SRR1740056 1 0.361 0.813 0.8 0.2 0 0
#> SRR1740055 1 0.485 0.477 0.6 0.4 0 0
#> SRR1740057 1 0.361 0.813 0.8 0.2 0 0
#> SRR1740058 1 0.000 0.910 1.0 0.0 0 0
#> SRR1740059 1 0.000 0.910 1.0 0.0 0 0
#> SRR1740060 1 0.000 0.910 1.0 0.0 0 0
#> SRR1740061 1 0.000 0.910 1.0 0.0 0 0
#> SRR1740062 4 0.000 1.000 0.0 0.0 0 1
#> SRR1740063 4 0.000 1.000 0.0 0.0 0 1
#> SRR1740064 4 0.000 1.000 0.0 0.0 0 1
#> SRR1740065 4 0.000 1.000 0.0 0.0 0 1
#> SRR1740066 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740067 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740068 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740069 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740070 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740071 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740072 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740073 2 0.000 1.000 0.0 1.0 0 0
#> SRR1740074 3 0.000 1.000 0.0 0.0 1 0
#> SRR1740075 3 0.000 1.000 0.0 0.0 1 0
#> SRR1740076 3 0.000 1.000 0.0 0.0 1 0
#> SRR1740077 3 0.000 1.000 0.0 0.0 1 0
#> SRR1740078 1 0.000 0.910 1.0 0.0 0 0
#> SRR1740079 1 0.000 0.910 1.0 0.0 0 0
#> SRR1740080 1 0.000 0.910 1.0 0.0 0 0
#> SRR1740081 1 0.000 0.910 1.0 0.0 0 0
#> SRR1740082 1 0.361 0.813 0.8 0.2 0 0
#> SRR1740083 1 0.361 0.813 0.8 0.2 0 0
#> SRR1740084 1 0.361 0.813 0.8 0.2 0 0
#> SRR1740085 1 0.361 0.813 0.8 0.2 0 0
#> SRR1740086 1 0.000 0.910 1.0 0.0 0 0
#> SRR1740087 1 0.000 0.910 1.0 0.0 0 0
#> SRR1740088 1 0.000 0.910 1.0 0.0 0 0
#> SRR1740089 1 0.000 0.910 1.0 0.0 0 0
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740035 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740036 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740037 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740038 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740039 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740040 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740041 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740042 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740043 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740044 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740045 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740046 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740048 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740047 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740049 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740050 5 0.3109 0.7734 0.200 0.000 0 0 0.800
#> SRR1740051 1 0.4219 -0.0391 0.584 0.000 0 0 0.416
#> SRR1740052 5 0.4235 0.4525 0.424 0.000 0 0 0.576
#> SRR1740054 5 0.0000 0.8322 0.000 0.000 0 0 1.000
#> SRR1740053 5 0.3109 0.7734 0.200 0.000 0 0 0.800
#> SRR1740056 5 0.0000 0.8322 0.000 0.000 0 0 1.000
#> SRR1740055 5 0.0162 0.8294 0.000 0.004 0 0 0.996
#> SRR1740057 5 0.0000 0.8322 0.000 0.000 0 0 1.000
#> SRR1740058 1 0.0000 0.9325 1.000 0.000 0 0 0.000
#> SRR1740059 1 0.0000 0.9325 1.000 0.000 0 0 0.000
#> SRR1740060 1 0.0000 0.9325 1.000 0.000 0 0 0.000
#> SRR1740061 1 0.0000 0.9325 1.000 0.000 0 0 0.000
#> SRR1740062 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740063 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740064 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740065 4 0.0000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740066 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740067 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740068 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740069 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740070 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740071 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740072 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740073 2 0.0000 1.0000 0.000 1.000 0 0 0.000
#> SRR1740074 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740075 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740076 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740077 3 0.0000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740078 5 0.3109 0.7734 0.200 0.000 0 0 0.800
#> SRR1740079 5 0.3109 0.7734 0.200 0.000 0 0 0.800
#> SRR1740080 5 0.4182 0.5066 0.400 0.000 0 0 0.600
#> SRR1740081 5 0.4182 0.5066 0.400 0.000 0 0 0.600
#> SRR1740082 5 0.0000 0.8322 0.000 0.000 0 0 1.000
#> SRR1740083 5 0.0000 0.8322 0.000 0.000 0 0 1.000
#> SRR1740084 5 0.0000 0.8322 0.000 0.000 0 0 1.000
#> SRR1740085 5 0.0000 0.8322 0.000 0.000 0 0 1.000
#> SRR1740086 1 0.0000 0.9325 1.000 0.000 0 0 0.000
#> SRR1740087 1 0.0000 0.9325 1.000 0.000 0 0 0.000
#> SRR1740088 1 0.0000 0.9325 1.000 0.000 0 0 0.000
#> SRR1740089 1 0.0000 0.9325 1.000 0.000 0 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0 1 0 0 0 1 0 0
#> SRR1740035 4 0 1 0 0 0 1 0 0
#> SRR1740036 4 0 1 0 0 0 1 0 0
#> SRR1740037 4 0 1 0 0 0 1 0 0
#> SRR1740038 2 0 1 0 1 0 0 0 0
#> SRR1740039 2 0 1 0 1 0 0 0 0
#> SRR1740040 2 0 1 0 1 0 0 0 0
#> SRR1740041 2 0 1 0 1 0 0 0 0
#> SRR1740042 2 0 1 0 1 0 0 0 0
#> SRR1740043 2 0 1 0 1 0 0 0 0
#> SRR1740044 2 0 1 0 1 0 0 0 0
#> SRR1740045 2 0 1 0 1 0 0 0 0
#> SRR1740046 3 0 1 0 0 1 0 0 0
#> SRR1740048 3 0 1 0 0 1 0 0 0
#> SRR1740047 3 0 1 0 0 1 0 0 0
#> SRR1740049 3 0 1 0 0 1 0 0 0
#> SRR1740050 5 0 1 0 0 0 0 1 0
#> SRR1740051 5 0 1 0 0 0 0 1 0
#> SRR1740052 5 0 1 0 0 0 0 1 0
#> SRR1740054 1 0 1 1 0 0 0 0 0
#> SRR1740053 5 0 1 0 0 0 0 1 0
#> SRR1740056 1 0 1 1 0 0 0 0 0
#> SRR1740055 1 0 1 1 0 0 0 0 0
#> SRR1740057 1 0 1 1 0 0 0 0 0
#> SRR1740058 6 0 1 0 0 0 0 0 1
#> SRR1740059 6 0 1 0 0 0 0 0 1
#> SRR1740060 6 0 1 0 0 0 0 0 1
#> SRR1740061 6 0 1 0 0 0 0 0 1
#> SRR1740062 4 0 1 0 0 0 1 0 0
#> SRR1740063 4 0 1 0 0 0 1 0 0
#> SRR1740064 4 0 1 0 0 0 1 0 0
#> SRR1740065 4 0 1 0 0 0 1 0 0
#> SRR1740066 2 0 1 0 1 0 0 0 0
#> SRR1740067 2 0 1 0 1 0 0 0 0
#> SRR1740068 2 0 1 0 1 0 0 0 0
#> SRR1740069 2 0 1 0 1 0 0 0 0
#> SRR1740070 2 0 1 0 1 0 0 0 0
#> SRR1740071 2 0 1 0 1 0 0 0 0
#> SRR1740072 2 0 1 0 1 0 0 0 0
#> SRR1740073 2 0 1 0 1 0 0 0 0
#> SRR1740074 3 0 1 0 0 1 0 0 0
#> SRR1740075 3 0 1 0 0 1 0 0 0
#> SRR1740076 3 0 1 0 0 1 0 0 0
#> SRR1740077 3 0 1 0 0 1 0 0 0
#> SRR1740078 5 0 1 0 0 0 0 1 0
#> SRR1740079 5 0 1 0 0 0 0 1 0
#> SRR1740080 5 0 1 0 0 0 0 1 0
#> SRR1740081 5 0 1 0 0 0 0 1 0
#> SRR1740082 1 0 1 1 0 0 0 0 0
#> SRR1740083 1 0 1 1 0 0 0 0 0
#> SRR1740084 1 0 1 1 0 0 0 0 0
#> SRR1740085 1 0 1 1 0 0 0 0 0
#> SRR1740086 6 0 1 0 0 0 0 0 1
#> SRR1740087 6 0 1 0 0 0 0 0 1
#> SRR1740088 6 0 1 0 0 0 0 0 1
#> SRR1740089 6 0 1 0 0 0 0 0 1
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.584 0.939 0.946 0.4940 0.501 0.501
#> 3 3 1.000 1.000 1.000 0.1785 0.584 0.377
#> 4 4 1.000 1.000 1.000 0.2139 0.875 0.702
#> 5 5 1.000 1.000 1.000 0.1175 0.917 0.717
#> 6 6 1.000 1.000 1.000 0.0526 0.958 0.802
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 3 4 5
There is also optional best \(k\) = 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
#> SRR1740034 1 0.469 0.918 0.900 0.100
#> SRR1740035 1 0.469 0.918 0.900 0.100
#> SRR1740036 1 0.469 0.918 0.900 0.100
#> SRR1740037 1 0.469 0.918 0.900 0.100
#> SRR1740038 2 0.000 0.960 0.000 1.000
#> SRR1740039 2 0.000 0.960 0.000 1.000
#> SRR1740040 2 0.000 0.960 0.000 1.000
#> SRR1740041 2 0.000 0.960 0.000 1.000
#> SRR1740042 2 0.000 0.960 0.000 1.000
#> SRR1740043 2 0.000 0.960 0.000 1.000
#> SRR1740044 2 0.000 0.960 0.000 1.000
#> SRR1740045 2 0.000 0.960 0.000 1.000
#> SRR1740046 1 0.118 0.943 0.984 0.016
#> SRR1740048 1 0.118 0.943 0.984 0.016
#> SRR1740047 1 0.118 0.943 0.984 0.016
#> SRR1740049 1 0.118 0.943 0.984 0.016
#> SRR1740050 2 0.563 0.897 0.132 0.868
#> SRR1740051 2 0.563 0.897 0.132 0.868
#> SRR1740052 2 0.563 0.897 0.132 0.868
#> SRR1740054 2 0.163 0.956 0.024 0.976
#> SRR1740053 2 0.563 0.897 0.132 0.868
#> SRR1740056 2 0.163 0.956 0.024 0.976
#> SRR1740055 2 0.163 0.956 0.024 0.976
#> SRR1740057 2 0.163 0.956 0.024 0.976
#> SRR1740058 1 0.278 0.938 0.952 0.048
#> SRR1740059 1 0.278 0.938 0.952 0.048
#> SRR1740060 1 0.278 0.938 0.952 0.048
#> SRR1740061 1 0.278 0.938 0.952 0.048
#> SRR1740062 1 0.469 0.918 0.900 0.100
#> SRR1740063 1 0.469 0.918 0.900 0.100
#> SRR1740064 1 0.469 0.918 0.900 0.100
#> SRR1740065 1 0.469 0.918 0.900 0.100
#> SRR1740066 2 0.000 0.960 0.000 1.000
#> SRR1740067 2 0.000 0.960 0.000 1.000
#> SRR1740068 2 0.000 0.960 0.000 1.000
#> SRR1740069 2 0.000 0.960 0.000 1.000
#> SRR1740070 2 0.000 0.960 0.000 1.000
#> SRR1740071 2 0.000 0.960 0.000 1.000
#> SRR1740072 2 0.000 0.960 0.000 1.000
#> SRR1740073 2 0.000 0.960 0.000 1.000
#> SRR1740074 1 0.118 0.943 0.984 0.016
#> SRR1740075 1 0.118 0.943 0.984 0.016
#> SRR1740076 1 0.118 0.943 0.984 0.016
#> SRR1740077 1 0.118 0.943 0.984 0.016
#> SRR1740078 2 0.563 0.897 0.132 0.868
#> SRR1740079 2 0.563 0.897 0.132 0.868
#> SRR1740080 2 0.563 0.897 0.132 0.868
#> SRR1740081 2 0.563 0.897 0.132 0.868
#> SRR1740082 2 0.163 0.956 0.024 0.976
#> SRR1740083 2 0.163 0.956 0.024 0.976
#> SRR1740084 2 0.163 0.956 0.024 0.976
#> SRR1740085 2 0.163 0.956 0.024 0.976
#> SRR1740086 1 0.278 0.938 0.952 0.048
#> SRR1740087 1 0.278 0.938 0.952 0.048
#> SRR1740088 1 0.278 0.938 0.952 0.048
#> SRR1740089 1 0.278 0.938 0.952 0.048
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0 1 1 0 0
#> SRR1740035 1 0 1 1 0 0
#> SRR1740036 1 0 1 1 0 0
#> SRR1740037 1 0 1 1 0 0
#> SRR1740038 2 0 1 0 1 0
#> SRR1740039 2 0 1 0 1 0
#> SRR1740040 2 0 1 0 1 0
#> SRR1740041 2 0 1 0 1 0
#> SRR1740042 2 0 1 0 1 0
#> SRR1740043 2 0 1 0 1 0
#> SRR1740044 2 0 1 0 1 0
#> SRR1740045 2 0 1 0 1 0
#> SRR1740046 3 0 1 0 0 1
#> SRR1740048 3 0 1 0 0 1
#> SRR1740047 3 0 1 0 0 1
#> SRR1740049 3 0 1 0 0 1
#> SRR1740050 1 0 1 1 0 0
#> SRR1740051 1 0 1 1 0 0
#> SRR1740052 1 0 1 1 0 0
#> SRR1740054 1 0 1 1 0 0
#> SRR1740053 1 0 1 1 0 0
#> SRR1740056 1 0 1 1 0 0
#> SRR1740055 1 0 1 1 0 0
#> SRR1740057 1 0 1 1 0 0
#> SRR1740058 1 0 1 1 0 0
#> SRR1740059 1 0 1 1 0 0
#> SRR1740060 1 0 1 1 0 0
#> SRR1740061 1 0 1 1 0 0
#> SRR1740062 1 0 1 1 0 0
#> SRR1740063 1 0 1 1 0 0
#> SRR1740064 1 0 1 1 0 0
#> SRR1740065 1 0 1 1 0 0
#> SRR1740066 2 0 1 0 1 0
#> SRR1740067 2 0 1 0 1 0
#> SRR1740068 2 0 1 0 1 0
#> SRR1740069 2 0 1 0 1 0
#> SRR1740070 2 0 1 0 1 0
#> SRR1740071 2 0 1 0 1 0
#> SRR1740072 2 0 1 0 1 0
#> SRR1740073 2 0 1 0 1 0
#> SRR1740074 3 0 1 0 0 1
#> SRR1740075 3 0 1 0 0 1
#> SRR1740076 3 0 1 0 0 1
#> SRR1740077 3 0 1 0 0 1
#> SRR1740078 1 0 1 1 0 0
#> SRR1740079 1 0 1 1 0 0
#> SRR1740080 1 0 1 1 0 0
#> SRR1740081 1 0 1 1 0 0
#> SRR1740082 1 0 1 1 0 0
#> SRR1740083 1 0 1 1 0 0
#> SRR1740084 1 0 1 1 0 0
#> SRR1740085 1 0 1 1 0 0
#> SRR1740086 1 0 1 1 0 0
#> SRR1740087 1 0 1 1 0 0
#> SRR1740088 1 0 1 1 0 0
#> SRR1740089 1 0 1 1 0 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 4 0 1 0 0 0 1
#> SRR1740035 4 0 1 0 0 0 1
#> SRR1740036 4 0 1 0 0 0 1
#> SRR1740037 4 0 1 0 0 0 1
#> SRR1740038 2 0 1 0 1 0 0
#> SRR1740039 2 0 1 0 1 0 0
#> SRR1740040 2 0 1 0 1 0 0
#> SRR1740041 2 0 1 0 1 0 0
#> SRR1740042 2 0 1 0 1 0 0
#> SRR1740043 2 0 1 0 1 0 0
#> SRR1740044 2 0 1 0 1 0 0
#> SRR1740045 2 0 1 0 1 0 0
#> SRR1740046 3 0 1 0 0 1 0
#> SRR1740048 3 0 1 0 0 1 0
#> SRR1740047 3 0 1 0 0 1 0
#> SRR1740049 3 0 1 0 0 1 0
#> SRR1740050 1 0 1 1 0 0 0
#> SRR1740051 1 0 1 1 0 0 0
#> SRR1740052 1 0 1 1 0 0 0
#> SRR1740054 1 0 1 1 0 0 0
#> SRR1740053 1 0 1 1 0 0 0
#> SRR1740056 1 0 1 1 0 0 0
#> SRR1740055 1 0 1 1 0 0 0
#> SRR1740057 1 0 1 1 0 0 0
#> SRR1740058 1 0 1 1 0 0 0
#> SRR1740059 1 0 1 1 0 0 0
#> SRR1740060 1 0 1 1 0 0 0
#> SRR1740061 1 0 1 1 0 0 0
#> SRR1740062 4 0 1 0 0 0 1
#> SRR1740063 4 0 1 0 0 0 1
#> SRR1740064 4 0 1 0 0 0 1
#> SRR1740065 4 0 1 0 0 0 1
#> SRR1740066 2 0 1 0 1 0 0
#> SRR1740067 2 0 1 0 1 0 0
#> SRR1740068 2 0 1 0 1 0 0
#> SRR1740069 2 0 1 0 1 0 0
#> SRR1740070 2 0 1 0 1 0 0
#> SRR1740071 2 0 1 0 1 0 0
#> SRR1740072 2 0 1 0 1 0 0
#> SRR1740073 2 0 1 0 1 0 0
#> SRR1740074 3 0 1 0 0 1 0
#> SRR1740075 3 0 1 0 0 1 0
#> SRR1740076 3 0 1 0 0 1 0
#> SRR1740077 3 0 1 0 0 1 0
#> SRR1740078 1 0 1 1 0 0 0
#> SRR1740079 1 0 1 1 0 0 0
#> SRR1740080 1 0 1 1 0 0 0
#> SRR1740081 1 0 1 1 0 0 0
#> SRR1740082 1 0 1 1 0 0 0
#> SRR1740083 1 0 1 1 0 0 0
#> SRR1740084 1 0 1 1 0 0 0
#> SRR1740085 1 0 1 1 0 0 0
#> SRR1740086 1 0 1 1 0 0 0
#> SRR1740087 1 0 1 1 0 0 0
#> SRR1740088 1 0 1 1 0 0 0
#> SRR1740089 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
#> SRR1740034 4 0 1 0 0 0 1 0
#> SRR1740035 4 0 1 0 0 0 1 0
#> SRR1740036 4 0 1 0 0 0 1 0
#> SRR1740037 4 0 1 0 0 0 1 0
#> SRR1740038 2 0 1 0 1 0 0 0
#> SRR1740039 2 0 1 0 1 0 0 0
#> SRR1740040 2 0 1 0 1 0 0 0
#> SRR1740041 2 0 1 0 1 0 0 0
#> SRR1740042 2 0 1 0 1 0 0 0
#> SRR1740043 2 0 1 0 1 0 0 0
#> SRR1740044 2 0 1 0 1 0 0 0
#> SRR1740045 2 0 1 0 1 0 0 0
#> SRR1740046 3 0 1 0 0 1 0 0
#> SRR1740048 3 0 1 0 0 1 0 0
#> SRR1740047 3 0 1 0 0 1 0 0
#> SRR1740049 3 0 1 0 0 1 0 0
#> SRR1740050 5 0 1 0 0 0 0 1
#> SRR1740051 5 0 1 0 0 0 0 1
#> SRR1740052 5 0 1 0 0 0 0 1
#> SRR1740054 1 0 1 1 0 0 0 0
#> SRR1740053 5 0 1 0 0 0 0 1
#> SRR1740056 1 0 1 1 0 0 0 0
#> SRR1740055 1 0 1 1 0 0 0 0
#> SRR1740057 1 0 1 1 0 0 0 0
#> SRR1740058 5 0 1 0 0 0 0 1
#> SRR1740059 5 0 1 0 0 0 0 1
#> SRR1740060 5 0 1 0 0 0 0 1
#> SRR1740061 5 0 1 0 0 0 0 1
#> SRR1740062 4 0 1 0 0 0 1 0
#> SRR1740063 4 0 1 0 0 0 1 0
#> SRR1740064 4 0 1 0 0 0 1 0
#> SRR1740065 4 0 1 0 0 0 1 0
#> SRR1740066 2 0 1 0 1 0 0 0
#> SRR1740067 2 0 1 0 1 0 0 0
#> SRR1740068 2 0 1 0 1 0 0 0
#> SRR1740069 2 0 1 0 1 0 0 0
#> SRR1740070 2 0 1 0 1 0 0 0
#> SRR1740071 2 0 1 0 1 0 0 0
#> SRR1740072 2 0 1 0 1 0 0 0
#> SRR1740073 2 0 1 0 1 0 0 0
#> SRR1740074 3 0 1 0 0 1 0 0
#> SRR1740075 3 0 1 0 0 1 0 0
#> SRR1740076 3 0 1 0 0 1 0 0
#> SRR1740077 3 0 1 0 0 1 0 0
#> SRR1740078 5 0 1 0 0 0 0 1
#> SRR1740079 5 0 1 0 0 0 0 1
#> SRR1740080 5 0 1 0 0 0 0 1
#> SRR1740081 5 0 1 0 0 0 0 1
#> SRR1740082 1 0 1 1 0 0 0 0
#> SRR1740083 1 0 1 1 0 0 0 0
#> SRR1740084 1 0 1 1 0 0 0 0
#> SRR1740085 1 0 1 1 0 0 0 0
#> SRR1740086 5 0 1 0 0 0 0 1
#> SRR1740087 5 0 1 0 0 0 0 1
#> SRR1740088 5 0 1 0 0 0 0 1
#> SRR1740089 5 0 1 0 0 0 0 1
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0 1 0 0 0 1 0 0
#> SRR1740035 4 0 1 0 0 0 1 0 0
#> SRR1740036 4 0 1 0 0 0 1 0 0
#> SRR1740037 4 0 1 0 0 0 1 0 0
#> SRR1740038 2 0 1 0 1 0 0 0 0
#> SRR1740039 2 0 1 0 1 0 0 0 0
#> SRR1740040 2 0 1 0 1 0 0 0 0
#> SRR1740041 2 0 1 0 1 0 0 0 0
#> SRR1740042 2 0 1 0 1 0 0 0 0
#> SRR1740043 2 0 1 0 1 0 0 0 0
#> SRR1740044 2 0 1 0 1 0 0 0 0
#> SRR1740045 2 0 1 0 1 0 0 0 0
#> SRR1740046 3 0 1 0 0 1 0 0 0
#> SRR1740048 3 0 1 0 0 1 0 0 0
#> SRR1740047 3 0 1 0 0 1 0 0 0
#> SRR1740049 3 0 1 0 0 1 0 0 0
#> SRR1740050 5 0 1 0 0 0 0 1 0
#> SRR1740051 5 0 1 0 0 0 0 1 0
#> SRR1740052 5 0 1 0 0 0 0 1 0
#> SRR1740054 1 0 1 1 0 0 0 0 0
#> SRR1740053 5 0 1 0 0 0 0 1 0
#> SRR1740056 1 0 1 1 0 0 0 0 0
#> SRR1740055 1 0 1 1 0 0 0 0 0
#> SRR1740057 1 0 1 1 0 0 0 0 0
#> SRR1740058 6 0 1 0 0 0 0 0 1
#> SRR1740059 6 0 1 0 0 0 0 0 1
#> SRR1740060 6 0 1 0 0 0 0 0 1
#> SRR1740061 6 0 1 0 0 0 0 0 1
#> SRR1740062 4 0 1 0 0 0 1 0 0
#> SRR1740063 4 0 1 0 0 0 1 0 0
#> SRR1740064 4 0 1 0 0 0 1 0 0
#> SRR1740065 4 0 1 0 0 0 1 0 0
#> SRR1740066 2 0 1 0 1 0 0 0 0
#> SRR1740067 2 0 1 0 1 0 0 0 0
#> SRR1740068 2 0 1 0 1 0 0 0 0
#> SRR1740069 2 0 1 0 1 0 0 0 0
#> SRR1740070 2 0 1 0 1 0 0 0 0
#> SRR1740071 2 0 1 0 1 0 0 0 0
#> SRR1740072 2 0 1 0 1 0 0 0 0
#> SRR1740073 2 0 1 0 1 0 0 0 0
#> SRR1740074 3 0 1 0 0 1 0 0 0
#> SRR1740075 3 0 1 0 0 1 0 0 0
#> SRR1740076 3 0 1 0 0 1 0 0 0
#> SRR1740077 3 0 1 0 0 1 0 0 0
#> SRR1740078 5 0 1 0 0 0 0 1 0
#> SRR1740079 5 0 1 0 0 0 0 1 0
#> SRR1740080 5 0 1 0 0 0 0 1 0
#> SRR1740081 5 0 1 0 0 0 0 1 0
#> SRR1740082 1 0 1 1 0 0 0 0 0
#> SRR1740083 1 0 1 1 0 0 0 0 0
#> SRR1740084 1 0 1 1 0 0 0 0 0
#> SRR1740085 1 0 1 1 0 0 0 0 0
#> SRR1740086 6 0 1 0 0 0 0 0 1
#> SRR1740087 6 0 1 0 0 0 0 0 1
#> SRR1740088 6 0 1 0 0 0 0 0 1
#> SRR1740089 6 0 1 0 0 0 0 0 1
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "NMF"]
# you can also extract it by
# res = res_list["MAD:NMF"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.979 0.989 0.501 0.501 0.501
#> 3 3 0.861 0.941 0.965 0.192 0.886 0.778
#> 4 4 0.880 0.916 0.963 0.193 0.881 0.707
#> 5 5 0.933 0.936 0.957 0.100 0.902 0.673
#> 6 6 0.948 0.907 0.945 0.063 0.948 0.756
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 5
There is also optional best \(k\) = 2 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1740034 1 0.0000 0.981 1.000 0.000
#> SRR1740035 1 0.0000 0.981 1.000 0.000
#> SRR1740036 1 0.0000 0.981 1.000 0.000
#> SRR1740037 1 0.0000 0.981 1.000 0.000
#> SRR1740038 2 0.0000 1.000 0.000 1.000
#> SRR1740039 2 0.0000 1.000 0.000 1.000
#> SRR1740040 2 0.0000 1.000 0.000 1.000
#> SRR1740041 2 0.0000 1.000 0.000 1.000
#> SRR1740042 2 0.0000 1.000 0.000 1.000
#> SRR1740043 2 0.0000 1.000 0.000 1.000
#> SRR1740044 2 0.0000 1.000 0.000 1.000
#> SRR1740045 2 0.0000 1.000 0.000 1.000
#> SRR1740046 2 0.0000 1.000 0.000 1.000
#> SRR1740048 2 0.0000 1.000 0.000 1.000
#> SRR1740047 2 0.0000 1.000 0.000 1.000
#> SRR1740049 2 0.0000 1.000 0.000 1.000
#> SRR1740050 1 0.0000 0.981 1.000 0.000
#> SRR1740051 1 0.0000 0.981 1.000 0.000
#> SRR1740052 1 0.0000 0.981 1.000 0.000
#> SRR1740054 1 0.2948 0.943 0.948 0.052
#> SRR1740053 1 0.0000 0.981 1.000 0.000
#> SRR1740056 1 0.0672 0.976 0.992 0.008
#> SRR1740055 1 0.7528 0.749 0.784 0.216
#> SRR1740057 1 0.0000 0.981 1.000 0.000
#> SRR1740058 1 0.0000 0.981 1.000 0.000
#> SRR1740059 1 0.0000 0.981 1.000 0.000
#> SRR1740060 1 0.0000 0.981 1.000 0.000
#> SRR1740061 1 0.0000 0.981 1.000 0.000
#> SRR1740062 1 0.0000 0.981 1.000 0.000
#> SRR1740063 1 0.0000 0.981 1.000 0.000
#> SRR1740064 1 0.0000 0.981 1.000 0.000
#> SRR1740065 1 0.0000 0.981 1.000 0.000
#> SRR1740066 2 0.0000 1.000 0.000 1.000
#> SRR1740067 2 0.0000 1.000 0.000 1.000
#> SRR1740068 2 0.0000 1.000 0.000 1.000
#> SRR1740069 2 0.0000 1.000 0.000 1.000
#> SRR1740070 2 0.0000 1.000 0.000 1.000
#> SRR1740071 2 0.0000 1.000 0.000 1.000
#> SRR1740072 2 0.0000 1.000 0.000 1.000
#> SRR1740073 2 0.0000 1.000 0.000 1.000
#> SRR1740074 2 0.0000 1.000 0.000 1.000
#> SRR1740075 2 0.0000 1.000 0.000 1.000
#> SRR1740076 2 0.0000 1.000 0.000 1.000
#> SRR1740077 2 0.0000 1.000 0.000 1.000
#> SRR1740078 1 0.0000 0.981 1.000 0.000
#> SRR1740079 1 0.0000 0.981 1.000 0.000
#> SRR1740080 1 0.0000 0.981 1.000 0.000
#> SRR1740081 1 0.0000 0.981 1.000 0.000
#> SRR1740082 1 0.6148 0.837 0.848 0.152
#> SRR1740083 1 0.4815 0.892 0.896 0.104
#> SRR1740084 1 0.2948 0.943 0.948 0.052
#> SRR1740085 1 0.1414 0.967 0.980 0.020
#> SRR1740086 1 0.0000 0.981 1.000 0.000
#> SRR1740087 1 0.0000 0.981 1.000 0.000
#> SRR1740088 1 0.0000 0.981 1.000 0.000
#> SRR1740089 1 0.0000 0.981 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0.2680 0.925 0.924 0.068 0.008
#> SRR1740035 1 0.2584 0.927 0.928 0.064 0.008
#> SRR1740036 1 0.2584 0.927 0.928 0.064 0.008
#> SRR1740037 1 0.3129 0.913 0.904 0.088 0.008
#> SRR1740038 2 0.0000 0.963 0.000 1.000 0.000
#> SRR1740039 2 0.0000 0.963 0.000 1.000 0.000
#> SRR1740040 2 0.0000 0.963 0.000 1.000 0.000
#> SRR1740041 2 0.0000 0.963 0.000 1.000 0.000
#> SRR1740042 2 0.0592 0.962 0.000 0.988 0.012
#> SRR1740043 2 0.0592 0.962 0.000 0.988 0.012
#> SRR1740044 2 0.0592 0.962 0.000 0.988 0.012
#> SRR1740045 2 0.0592 0.962 0.000 0.988 0.012
#> SRR1740046 3 0.0424 1.000 0.000 0.008 0.992
#> SRR1740048 3 0.0424 1.000 0.000 0.008 0.992
#> SRR1740047 3 0.0424 1.000 0.000 0.008 0.992
#> SRR1740049 3 0.0424 1.000 0.000 0.008 0.992
#> SRR1740050 1 0.0000 0.952 1.000 0.000 0.000
#> SRR1740051 1 0.0000 0.952 1.000 0.000 0.000
#> SRR1740052 1 0.0000 0.952 1.000 0.000 0.000
#> SRR1740054 1 0.3816 0.852 0.852 0.148 0.000
#> SRR1740053 1 0.0000 0.952 1.000 0.000 0.000
#> SRR1740056 1 0.0424 0.950 0.992 0.008 0.000
#> SRR1740055 2 0.5443 0.609 0.260 0.736 0.004
#> SRR1740057 1 0.0237 0.951 0.996 0.004 0.000
#> SRR1740058 1 0.0000 0.952 1.000 0.000 0.000
#> SRR1740059 1 0.0000 0.952 1.000 0.000 0.000
#> SRR1740060 1 0.0000 0.952 1.000 0.000 0.000
#> SRR1740061 1 0.0000 0.952 1.000 0.000 0.000
#> SRR1740062 1 0.3965 0.879 0.860 0.132 0.008
#> SRR1740063 1 0.4099 0.872 0.852 0.140 0.008
#> SRR1740064 1 0.3896 0.883 0.864 0.128 0.008
#> SRR1740065 1 0.4164 0.868 0.848 0.144 0.008
#> SRR1740066 2 0.0000 0.963 0.000 1.000 0.000
#> SRR1740067 2 0.0000 0.963 0.000 1.000 0.000
#> SRR1740068 2 0.0000 0.963 0.000 1.000 0.000
#> SRR1740069 2 0.0000 0.963 0.000 1.000 0.000
#> SRR1740070 2 0.2066 0.933 0.000 0.940 0.060
#> SRR1740071 2 0.1860 0.939 0.000 0.948 0.052
#> SRR1740072 2 0.1753 0.943 0.000 0.952 0.048
#> SRR1740073 2 0.1529 0.948 0.000 0.960 0.040
#> SRR1740074 3 0.0424 1.000 0.000 0.008 0.992
#> SRR1740075 3 0.0424 1.000 0.000 0.008 0.992
#> SRR1740076 3 0.0424 1.000 0.000 0.008 0.992
#> SRR1740077 3 0.0424 1.000 0.000 0.008 0.992
#> SRR1740078 1 0.0000 0.952 1.000 0.000 0.000
#> SRR1740079 1 0.0000 0.952 1.000 0.000 0.000
#> SRR1740080 1 0.0000 0.952 1.000 0.000 0.000
#> SRR1740081 1 0.0000 0.952 1.000 0.000 0.000
#> SRR1740082 1 0.4291 0.848 0.840 0.152 0.008
#> SRR1740083 1 0.3192 0.894 0.888 0.112 0.000
#> SRR1740084 1 0.1753 0.931 0.952 0.048 0.000
#> SRR1740085 1 0.0892 0.946 0.980 0.020 0.000
#> SRR1740086 1 0.0000 0.952 1.000 0.000 0.000
#> SRR1740087 1 0.0000 0.952 1.000 0.000 0.000
#> SRR1740088 1 0.0000 0.952 1.000 0.000 0.000
#> SRR1740089 1 0.0000 0.952 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740035 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740036 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740037 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740038 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740039 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740040 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740041 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740042 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740043 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740044 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740045 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740046 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740048 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740047 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740049 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740050 1 0.000 0.896 1.000 0.000 0 0
#> SRR1740051 1 0.000 0.896 1.000 0.000 0 0
#> SRR1740052 1 0.000 0.896 1.000 0.000 0 0
#> SRR1740054 1 0.478 0.501 0.624 0.376 0 0
#> SRR1740053 1 0.000 0.896 1.000 0.000 0 0
#> SRR1740056 1 0.312 0.802 0.844 0.156 0 0
#> SRR1740055 2 0.241 0.863 0.104 0.896 0 0
#> SRR1740057 1 0.241 0.837 0.896 0.104 0 0
#> SRR1740058 1 0.000 0.896 1.000 0.000 0 0
#> SRR1740059 1 0.000 0.896 1.000 0.000 0 0
#> SRR1740060 1 0.000 0.896 1.000 0.000 0 0
#> SRR1740061 1 0.000 0.896 1.000 0.000 0 0
#> SRR1740062 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740063 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740064 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740065 4 0.000 1.000 0.000 0.000 0 1
#> SRR1740066 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740067 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740068 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740069 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740070 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740071 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740072 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740073 2 0.000 0.992 0.000 1.000 0 0
#> SRR1740074 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740075 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740076 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740077 3 0.000 1.000 0.000 0.000 1 0
#> SRR1740078 1 0.000 0.896 1.000 0.000 0 0
#> SRR1740079 1 0.000 0.896 1.000 0.000 0 0
#> SRR1740080 1 0.000 0.896 1.000 0.000 0 0
#> SRR1740081 1 0.000 0.896 1.000 0.000 0 0
#> SRR1740082 1 0.497 0.324 0.548 0.452 0 0
#> SRR1740083 1 0.497 0.325 0.548 0.452 0 0
#> SRR1740084 1 0.413 0.691 0.740 0.260 0 0
#> SRR1740085 1 0.353 0.770 0.808 0.192 0 0
#> SRR1740086 1 0.000 0.896 1.000 0.000 0 0
#> SRR1740087 1 0.000 0.896 1.000 0.000 0 0
#> SRR1740088 1 0.000 0.896 1.000 0.000 0 0
#> SRR1740089 1 0.000 0.896 1.000 0.000 0 0
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740035 4 0.000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740036 4 0.000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740037 4 0.000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740038 2 0.029 0.9417 0.000 0.992 0 0 0.008
#> SRR1740039 2 0.029 0.9417 0.000 0.992 0 0 0.008
#> SRR1740040 2 0.029 0.9417 0.000 0.992 0 0 0.008
#> SRR1740041 2 0.029 0.9417 0.000 0.992 0 0 0.008
#> SRR1740042 2 0.120 0.9446 0.048 0.952 0 0 0.000
#> SRR1740043 2 0.120 0.9446 0.048 0.952 0 0 0.000
#> SRR1740044 2 0.120 0.9446 0.048 0.952 0 0 0.000
#> SRR1740045 2 0.120 0.9446 0.048 0.952 0 0 0.000
#> SRR1740046 3 0.000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740048 3 0.000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740047 3 0.000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740049 3 0.000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740050 5 0.029 1.0000 0.008 0.000 0 0 0.992
#> SRR1740051 5 0.029 1.0000 0.008 0.000 0 0 0.992
#> SRR1740052 5 0.029 1.0000 0.008 0.000 0 0 0.992
#> SRR1740054 2 0.430 0.0689 0.476 0.524 0 0 0.000
#> SRR1740053 5 0.029 1.0000 0.008 0.000 0 0 0.992
#> SRR1740056 1 0.300 0.8468 0.840 0.148 0 0 0.012
#> SRR1740055 2 0.148 0.9334 0.064 0.936 0 0 0.000
#> SRR1740057 1 0.292 0.8599 0.852 0.132 0 0 0.016
#> SRR1740058 1 0.120 0.9004 0.952 0.000 0 0 0.048
#> SRR1740059 1 0.120 0.9004 0.952 0.000 0 0 0.048
#> SRR1740060 1 0.120 0.9004 0.952 0.000 0 0 0.048
#> SRR1740061 1 0.120 0.9004 0.952 0.000 0 0 0.048
#> SRR1740062 4 0.000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740063 4 0.000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740064 4 0.000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740065 4 0.000 1.0000 0.000 0.000 0 1 0.000
#> SRR1740066 2 0.029 0.9417 0.000 0.992 0 0 0.008
#> SRR1740067 2 0.029 0.9417 0.000 0.992 0 0 0.008
#> SRR1740068 2 0.029 0.9417 0.000 0.992 0 0 0.008
#> SRR1740069 2 0.029 0.9417 0.000 0.992 0 0 0.008
#> SRR1740070 2 0.120 0.9446 0.048 0.952 0 0 0.000
#> SRR1740071 2 0.120 0.9446 0.048 0.952 0 0 0.000
#> SRR1740072 2 0.120 0.9446 0.048 0.952 0 0 0.000
#> SRR1740073 2 0.120 0.9446 0.048 0.952 0 0 0.000
#> SRR1740074 3 0.000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740075 3 0.000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740076 3 0.000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740077 3 0.000 1.0000 0.000 0.000 1 0 0.000
#> SRR1740078 5 0.029 1.0000 0.008 0.000 0 0 0.992
#> SRR1740079 5 0.029 1.0000 0.008 0.000 0 0 0.992
#> SRR1740080 5 0.029 1.0000 0.008 0.000 0 0 0.992
#> SRR1740081 5 0.029 1.0000 0.008 0.000 0 0 0.992
#> SRR1740082 1 0.289 0.8091 0.824 0.176 0 0 0.000
#> SRR1740083 1 0.265 0.8375 0.848 0.152 0 0 0.000
#> SRR1740084 1 0.213 0.8672 0.892 0.108 0 0 0.000
#> SRR1740085 1 0.196 0.8716 0.904 0.096 0 0 0.000
#> SRR1740086 1 0.120 0.9004 0.952 0.000 0 0 0.048
#> SRR1740087 1 0.120 0.9004 0.952 0.000 0 0 0.048
#> SRR1740088 1 0.120 0.9004 0.952 0.000 0 0 0.048
#> SRR1740089 1 0.120 0.9004 0.952 0.000 0 0 0.048
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740035 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740036 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740037 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740038 2 0.114 0.999 0.052 0.948 0 0 0 0.000
#> SRR1740039 2 0.120 0.996 0.056 0.944 0 0 0 0.000
#> SRR1740040 2 0.114 0.999 0.052 0.948 0 0 0 0.000
#> SRR1740041 2 0.120 0.996 0.056 0.944 0 0 0 0.000
#> SRR1740042 1 0.000 0.981 1.000 0.000 0 0 0 0.000
#> SRR1740043 1 0.000 0.981 1.000 0.000 0 0 0 0.000
#> SRR1740044 1 0.000 0.981 1.000 0.000 0 0 0 0.000
#> SRR1740045 1 0.000 0.981 1.000 0.000 0 0 0 0.000
#> SRR1740046 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740048 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740047 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740049 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740050 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740051 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740052 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740054 1 0.209 0.801 0.876 0.000 0 0 0 0.124
#> SRR1740053 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740056 6 0.386 0.398 0.476 0.000 0 0 0 0.524
#> SRR1740055 1 0.000 0.981 1.000 0.000 0 0 0 0.000
#> SRR1740057 6 0.362 0.586 0.352 0.000 0 0 0 0.648
#> SRR1740058 6 0.000 0.778 0.000 0.000 0 0 0 1.000
#> SRR1740059 6 0.000 0.778 0.000 0.000 0 0 0 1.000
#> SRR1740060 6 0.000 0.778 0.000 0.000 0 0 0 1.000
#> SRR1740061 6 0.000 0.778 0.000 0.000 0 0 0 1.000
#> SRR1740062 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740063 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740064 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740065 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR1740066 2 0.114 0.999 0.052 0.948 0 0 0 0.000
#> SRR1740067 2 0.114 0.999 0.052 0.948 0 0 0 0.000
#> SRR1740068 2 0.114 0.999 0.052 0.948 0 0 0 0.000
#> SRR1740069 2 0.114 0.999 0.052 0.948 0 0 0 0.000
#> SRR1740070 1 0.000 0.981 1.000 0.000 0 0 0 0.000
#> SRR1740071 1 0.000 0.981 1.000 0.000 0 0 0 0.000
#> SRR1740072 1 0.000 0.981 1.000 0.000 0 0 0 0.000
#> SRR1740073 1 0.000 0.981 1.000 0.000 0 0 0 0.000
#> SRR1740074 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740075 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740076 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740077 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR1740078 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740079 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740080 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740081 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR1740082 6 0.386 0.408 0.472 0.000 0 0 0 0.528
#> SRR1740083 6 0.371 0.559 0.380 0.000 0 0 0 0.620
#> SRR1740084 6 0.384 0.450 0.452 0.000 0 0 0 0.548
#> SRR1740085 6 0.375 0.540 0.396 0.000 0 0 0 0.604
#> SRR1740086 6 0.000 0.778 0.000 0.000 0 0 0 1.000
#> SRR1740087 6 0.000 0.778 0.000 0.000 0 0 0 1.000
#> SRR1740088 6 0.000 0.778 0.000 0.000 0 0 0 1.000
#> SRR1740089 6 0.000 0.778 0.000 0.000 0 0 0 1.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.2501 0.751 0.751
#> 3 3 1.000 1.000 1.000 1.3280 0.668 0.557
#> 4 4 1.000 0.985 0.990 0.2190 0.875 0.702
#> 5 5 0.875 0.872 0.905 0.1129 0.917 0.717
#> 6 6 1.000 0.993 0.985 0.0525 0.958 0.802
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 4
There is also optional best \(k\) = 2 3 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1740034 1 0 1 1 0
#> SRR1740035 1 0 1 1 0
#> SRR1740036 1 0 1 1 0
#> SRR1740037 1 0 1 1 0
#> SRR1740038 1 0 1 1 0
#> SRR1740039 1 0 1 1 0
#> SRR1740040 1 0 1 1 0
#> SRR1740041 1 0 1 1 0
#> SRR1740042 1 0 1 1 0
#> SRR1740043 1 0 1 1 0
#> SRR1740044 1 0 1 1 0
#> SRR1740045 1 0 1 1 0
#> SRR1740046 2 0 1 0 1
#> SRR1740048 2 0 1 0 1
#> SRR1740047 2 0 1 0 1
#> SRR1740049 2 0 1 0 1
#> SRR1740050 1 0 1 1 0
#> SRR1740051 1 0 1 1 0
#> SRR1740052 1 0 1 1 0
#> SRR1740054 1 0 1 1 0
#> SRR1740053 1 0 1 1 0
#> SRR1740056 1 0 1 1 0
#> SRR1740055 1 0 1 1 0
#> SRR1740057 1 0 1 1 0
#> SRR1740058 1 0 1 1 0
#> SRR1740059 1 0 1 1 0
#> SRR1740060 1 0 1 1 0
#> SRR1740061 1 0 1 1 0
#> SRR1740062 1 0 1 1 0
#> SRR1740063 1 0 1 1 0
#> SRR1740064 1 0 1 1 0
#> SRR1740065 1 0 1 1 0
#> SRR1740066 1 0 1 1 0
#> SRR1740067 1 0 1 1 0
#> SRR1740068 1 0 1 1 0
#> SRR1740069 1 0 1 1 0
#> SRR1740070 1 0 1 1 0
#> SRR1740071 1 0 1 1 0
#> SRR1740072 1 0 1 1 0
#> SRR1740073 1 0 1 1 0
#> SRR1740074 2 0 1 0 1
#> SRR1740075 2 0 1 0 1
#> SRR1740076 2 0 1 0 1
#> SRR1740077 2 0 1 0 1
#> SRR1740078 1 0 1 1 0
#> SRR1740079 1 0 1 1 0
#> SRR1740080 1 0 1 1 0
#> SRR1740081 1 0 1 1 0
#> SRR1740082 1 0 1 1 0
#> SRR1740083 1 0 1 1 0
#> SRR1740084 1 0 1 1 0
#> SRR1740085 1 0 1 1 0
#> SRR1740086 1 0 1 1 0
#> SRR1740087 1 0 1 1 0
#> SRR1740088 1 0 1 1 0
#> SRR1740089 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0 1 1 0 0
#> SRR1740035 1 0 1 1 0 0
#> SRR1740036 1 0 1 1 0 0
#> SRR1740037 1 0 1 1 0 0
#> SRR1740038 2 0 1 0 1 0
#> SRR1740039 2 0 1 0 1 0
#> SRR1740040 2 0 1 0 1 0
#> SRR1740041 2 0 1 0 1 0
#> SRR1740042 2 0 1 0 1 0
#> SRR1740043 2 0 1 0 1 0
#> SRR1740044 2 0 1 0 1 0
#> SRR1740045 2 0 1 0 1 0
#> SRR1740046 3 0 1 0 0 1
#> SRR1740048 3 0 1 0 0 1
#> SRR1740047 3 0 1 0 0 1
#> SRR1740049 3 0 1 0 0 1
#> SRR1740050 1 0 1 1 0 0
#> SRR1740051 1 0 1 1 0 0
#> SRR1740052 1 0 1 1 0 0
#> SRR1740054 1 0 1 1 0 0
#> SRR1740053 1 0 1 1 0 0
#> SRR1740056 1 0 1 1 0 0
#> SRR1740055 1 0 1 1 0 0
#> SRR1740057 1 0 1 1 0 0
#> SRR1740058 1 0 1 1 0 0
#> SRR1740059 1 0 1 1 0 0
#> SRR1740060 1 0 1 1 0 0
#> SRR1740061 1 0 1 1 0 0
#> SRR1740062 1 0 1 1 0 0
#> SRR1740063 1 0 1 1 0 0
#> SRR1740064 1 0 1 1 0 0
#> SRR1740065 1 0 1 1 0 0
#> SRR1740066 2 0 1 0 1 0
#> SRR1740067 2 0 1 0 1 0
#> SRR1740068 2 0 1 0 1 0
#> SRR1740069 2 0 1 0 1 0
#> SRR1740070 2 0 1 0 1 0
#> SRR1740071 2 0 1 0 1 0
#> SRR1740072 2 0 1 0 1 0
#> SRR1740073 2 0 1 0 1 0
#> SRR1740074 3 0 1 0 0 1
#> SRR1740075 3 0 1 0 0 1
#> SRR1740076 3 0 1 0 0 1
#> SRR1740077 3 0 1 0 0 1
#> SRR1740078 1 0 1 1 0 0
#> SRR1740079 1 0 1 1 0 0
#> SRR1740080 1 0 1 1 0 0
#> SRR1740081 1 0 1 1 0 0
#> SRR1740082 1 0 1 1 0 0
#> SRR1740083 1 0 1 1 0 0
#> SRR1740084 1 0 1 1 0 0
#> SRR1740085 1 0 1 1 0 0
#> SRR1740086 1 0 1 1 0 0
#> SRR1740087 1 0 1 1 0 0
#> SRR1740088 1 0 1 1 0 0
#> SRR1740089 1 0 1 1 0 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 1 0.000 0.974 1.000 0 0 0.000
#> SRR1740035 1 0.000 0.974 1.000 0 0 0.000
#> SRR1740036 1 0.000 0.974 1.000 0 0 0.000
#> SRR1740037 1 0.000 0.974 1.000 0 0 0.000
#> SRR1740038 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740039 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740040 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740041 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740042 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740043 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740044 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740045 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740046 3 0.000 1.000 0.000 0 1 0.000
#> SRR1740048 3 0.000 1.000 0.000 0 1 0.000
#> SRR1740047 3 0.000 1.000 0.000 0 1 0.000
#> SRR1740049 3 0.000 1.000 0.000 0 1 0.000
#> SRR1740050 1 0.187 0.946 0.928 0 0 0.072
#> SRR1740051 1 0.187 0.946 0.928 0 0 0.072
#> SRR1740052 1 0.187 0.946 0.928 0 0 0.072
#> SRR1740054 4 0.000 1.000 0.000 0 0 1.000
#> SRR1740053 1 0.187 0.946 0.928 0 0 0.072
#> SRR1740056 4 0.000 1.000 0.000 0 0 1.000
#> SRR1740055 4 0.000 1.000 0.000 0 0 1.000
#> SRR1740057 4 0.000 1.000 0.000 0 0 1.000
#> SRR1740058 1 0.000 0.974 1.000 0 0 0.000
#> SRR1740059 1 0.000 0.974 1.000 0 0 0.000
#> SRR1740060 1 0.000 0.974 1.000 0 0 0.000
#> SRR1740061 1 0.000 0.974 1.000 0 0 0.000
#> SRR1740062 1 0.000 0.974 1.000 0 0 0.000
#> SRR1740063 1 0.000 0.974 1.000 0 0 0.000
#> SRR1740064 1 0.000 0.974 1.000 0 0 0.000
#> SRR1740065 1 0.000 0.974 1.000 0 0 0.000
#> SRR1740066 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740067 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740068 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740069 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740070 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740071 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740072 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740073 2 0.000 1.000 0.000 1 0 0.000
#> SRR1740074 3 0.000 1.000 0.000 0 1 0.000
#> SRR1740075 3 0.000 1.000 0.000 0 1 0.000
#> SRR1740076 3 0.000 1.000 0.000 0 1 0.000
#> SRR1740077 3 0.000 1.000 0.000 0 1 0.000
#> SRR1740078 1 0.187 0.946 0.928 0 0 0.072
#> SRR1740079 1 0.187 0.946 0.928 0 0 0.072
#> SRR1740080 1 0.187 0.946 0.928 0 0 0.072
#> SRR1740081 1 0.187 0.946 0.928 0 0 0.072
#> SRR1740082 4 0.000 1.000 0.000 0 0 1.000
#> SRR1740083 4 0.000 1.000 0.000 0 0 1.000
#> SRR1740084 4 0.000 1.000 0.000 0 0 1.000
#> SRR1740085 4 0.000 1.000 0.000 0 0 1.000
#> SRR1740086 1 0.000 0.974 1.000 0 0 0.000
#> SRR1740087 1 0.000 0.974 1.000 0 0 0.000
#> SRR1740088 1 0.000 0.974 1.000 0 0 0.000
#> SRR1740089 1 0.000 0.974 1.000 0 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.359 0.571 0 0 0 0.736 0.264
#> SRR1740035 4 0.359 0.571 0 0 0 0.736 0.264
#> SRR1740036 4 0.359 0.571 0 0 0 0.736 0.264
#> SRR1740037 4 0.359 0.571 0 0 0 0.736 0.264
#> SRR1740038 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740039 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740040 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740041 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740042 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740043 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740044 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740045 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740046 3 0.000 1.000 0 0 1 0.000 0.000
#> SRR1740048 3 0.000 1.000 0 0 1 0.000 0.000
#> SRR1740047 3 0.000 1.000 0 0 1 0.000 0.000
#> SRR1740049 3 0.000 1.000 0 0 1 0.000 0.000
#> SRR1740050 4 0.393 0.534 0 0 0 0.672 0.328
#> SRR1740051 4 0.393 0.534 0 0 0 0.672 0.328
#> SRR1740052 4 0.393 0.534 0 0 0 0.672 0.328
#> SRR1740054 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1740053 4 0.393 0.534 0 0 0 0.672 0.328
#> SRR1740056 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1740055 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1740057 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1740058 5 0.000 1.000 0 0 0 0.000 1.000
#> SRR1740059 5 0.000 1.000 0 0 0 0.000 1.000
#> SRR1740060 5 0.000 1.000 0 0 0 0.000 1.000
#> SRR1740061 5 0.000 1.000 0 0 0 0.000 1.000
#> SRR1740062 4 0.359 0.571 0 0 0 0.736 0.264
#> SRR1740063 4 0.359 0.571 0 0 0 0.736 0.264
#> SRR1740064 4 0.359 0.571 0 0 0 0.736 0.264
#> SRR1740065 4 0.359 0.571 0 0 0 0.736 0.264
#> SRR1740066 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740067 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740068 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740069 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740070 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740071 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740072 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740073 2 0.000 1.000 0 1 0 0.000 0.000
#> SRR1740074 3 0.000 1.000 0 0 1 0.000 0.000
#> SRR1740075 3 0.000 1.000 0 0 1 0.000 0.000
#> SRR1740076 3 0.000 1.000 0 0 1 0.000 0.000
#> SRR1740077 3 0.000 1.000 0 0 1 0.000 0.000
#> SRR1740078 4 0.393 0.534 0 0 0 0.672 0.328
#> SRR1740079 4 0.393 0.534 0 0 0 0.672 0.328
#> SRR1740080 4 0.393 0.534 0 0 0 0.672 0.328
#> SRR1740081 4 0.393 0.534 0 0 0 0.672 0.328
#> SRR1740082 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1740083 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1740084 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1740085 1 0.000 1.000 1 0 0 0.000 0.000
#> SRR1740086 5 0.000 1.000 0 0 0 0.000 1.000
#> SRR1740087 5 0.000 1.000 0 0 0 0.000 1.000
#> SRR1740088 5 0.000 1.000 0 0 0 0.000 1.000
#> SRR1740089 5 0.000 1.000 0 0 0 0.000 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.114 1.000 0 0.000 0 0.948 0.052 0
#> SRR1740035 4 0.114 1.000 0 0.000 0 0.948 0.052 0
#> SRR1740036 4 0.114 1.000 0 0.000 0 0.948 0.052 0
#> SRR1740037 4 0.114 1.000 0 0.000 0 0.948 0.052 0
#> SRR1740038 2 0.114 0.977 0 0.948 0 0.052 0.000 0
#> SRR1740039 2 0.114 0.977 0 0.948 0 0.052 0.000 0
#> SRR1740040 2 0.114 0.977 0 0.948 0 0.052 0.000 0
#> SRR1740041 2 0.114 0.977 0 0.948 0 0.052 0.000 0
#> SRR1740042 2 0.000 0.977 0 1.000 0 0.000 0.000 0
#> SRR1740043 2 0.000 0.977 0 1.000 0 0.000 0.000 0
#> SRR1740044 2 0.000 0.977 0 1.000 0 0.000 0.000 0
#> SRR1740045 2 0.000 0.977 0 1.000 0 0.000 0.000 0
#> SRR1740046 3 0.000 1.000 0 0.000 1 0.000 0.000 0
#> SRR1740048 3 0.000 1.000 0 0.000 1 0.000 0.000 0
#> SRR1740047 3 0.000 1.000 0 0.000 1 0.000 0.000 0
#> SRR1740049 3 0.000 1.000 0 0.000 1 0.000 0.000 0
#> SRR1740050 5 0.000 1.000 0 0.000 0 0.000 1.000 0
#> SRR1740051 5 0.000 1.000 0 0.000 0 0.000 1.000 0
#> SRR1740052 5 0.000 1.000 0 0.000 0 0.000 1.000 0
#> SRR1740054 1 0.000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1740053 5 0.000 1.000 0 0.000 0 0.000 1.000 0
#> SRR1740056 1 0.000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1740055 1 0.000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1740057 1 0.000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1740058 6 0.000 1.000 0 0.000 0 0.000 0.000 1
#> SRR1740059 6 0.000 1.000 0 0.000 0 0.000 0.000 1
#> SRR1740060 6 0.000 1.000 0 0.000 0 0.000 0.000 1
#> SRR1740061 6 0.000 1.000 0 0.000 0 0.000 0.000 1
#> SRR1740062 4 0.114 1.000 0 0.000 0 0.948 0.052 0
#> SRR1740063 4 0.114 1.000 0 0.000 0 0.948 0.052 0
#> SRR1740064 4 0.114 1.000 0 0.000 0 0.948 0.052 0
#> SRR1740065 4 0.114 1.000 0 0.000 0 0.948 0.052 0
#> SRR1740066 2 0.114 0.977 0 0.948 0 0.052 0.000 0
#> SRR1740067 2 0.114 0.977 0 0.948 0 0.052 0.000 0
#> SRR1740068 2 0.114 0.977 0 0.948 0 0.052 0.000 0
#> SRR1740069 2 0.114 0.977 0 0.948 0 0.052 0.000 0
#> SRR1740070 2 0.000 0.977 0 1.000 0 0.000 0.000 0
#> SRR1740071 2 0.000 0.977 0 1.000 0 0.000 0.000 0
#> SRR1740072 2 0.000 0.977 0 1.000 0 0.000 0.000 0
#> SRR1740073 2 0.000 0.977 0 1.000 0 0.000 0.000 0
#> SRR1740074 3 0.000 1.000 0 0.000 1 0.000 0.000 0
#> SRR1740075 3 0.000 1.000 0 0.000 1 0.000 0.000 0
#> SRR1740076 3 0.000 1.000 0 0.000 1 0.000 0.000 0
#> SRR1740077 3 0.000 1.000 0 0.000 1 0.000 0.000 0
#> SRR1740078 5 0.000 1.000 0 0.000 0 0.000 1.000 0
#> SRR1740079 5 0.000 1.000 0 0.000 0 0.000 1.000 0
#> SRR1740080 5 0.000 1.000 0 0.000 0 0.000 1.000 0
#> SRR1740081 5 0.000 1.000 0 0.000 0 0.000 1.000 0
#> SRR1740082 1 0.000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1740083 1 0.000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1740084 1 0.000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1740085 1 0.000 1.000 1 0.000 0 0.000 0.000 0
#> SRR1740086 6 0.000 1.000 0 0.000 0 0.000 0.000 1
#> SRR1740087 6 0.000 1.000 0 0.000 0 0.000 0.000 1
#> SRR1740088 6 0.000 1.000 0 0.000 0 0.000 0.000 1
#> SRR1740089 6 0.000 1.000 0 0.000 0 0.000 0.000 1
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.2501 0.751 0.751
#> 3 3 1.000 0.998 0.983 1.2674 0.668 0.557
#> 4 4 0.709 0.802 0.788 0.2328 0.834 0.602
#> 5 5 0.699 0.757 0.747 0.0922 1.000 1.000
#> 6 6 0.768 0.909 0.719 0.0570 0.917 0.670
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
#> SRR1740034 1 0 1 1 0
#> SRR1740035 1 0 1 1 0
#> SRR1740036 1 0 1 1 0
#> SRR1740037 1 0 1 1 0
#> SRR1740038 1 0 1 1 0
#> SRR1740039 1 0 1 1 0
#> SRR1740040 1 0 1 1 0
#> SRR1740041 1 0 1 1 0
#> SRR1740042 1 0 1 1 0
#> SRR1740043 1 0 1 1 0
#> SRR1740044 1 0 1 1 0
#> SRR1740045 1 0 1 1 0
#> SRR1740046 2 0 1 0 1
#> SRR1740048 2 0 1 0 1
#> SRR1740047 2 0 1 0 1
#> SRR1740049 2 0 1 0 1
#> SRR1740050 1 0 1 1 0
#> SRR1740051 1 0 1 1 0
#> SRR1740052 1 0 1 1 0
#> SRR1740054 1 0 1 1 0
#> SRR1740053 1 0 1 1 0
#> SRR1740056 1 0 1 1 0
#> SRR1740055 1 0 1 1 0
#> SRR1740057 1 0 1 1 0
#> SRR1740058 1 0 1 1 0
#> SRR1740059 1 0 1 1 0
#> SRR1740060 1 0 1 1 0
#> SRR1740061 1 0 1 1 0
#> SRR1740062 1 0 1 1 0
#> SRR1740063 1 0 1 1 0
#> SRR1740064 1 0 1 1 0
#> SRR1740065 1 0 1 1 0
#> SRR1740066 1 0 1 1 0
#> SRR1740067 1 0 1 1 0
#> SRR1740068 1 0 1 1 0
#> SRR1740069 1 0 1 1 0
#> SRR1740070 1 0 1 1 0
#> SRR1740071 1 0 1 1 0
#> SRR1740072 1 0 1 1 0
#> SRR1740073 1 0 1 1 0
#> SRR1740074 2 0 1 0 1
#> SRR1740075 2 0 1 0 1
#> SRR1740076 2 0 1 0 1
#> SRR1740077 2 0 1 0 1
#> SRR1740078 1 0 1 1 0
#> SRR1740079 1 0 1 1 0
#> SRR1740080 1 0 1 1 0
#> SRR1740081 1 0 1 1 0
#> SRR1740082 1 0 1 1 0
#> SRR1740083 1 0 1 1 0
#> SRR1740084 1 0 1 1 0
#> SRR1740085 1 0 1 1 0
#> SRR1740086 1 0 1 1 0
#> SRR1740087 1 0 1 1 0
#> SRR1740088 1 0 1 1 0
#> SRR1740089 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740035 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740036 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740037 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740038 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740039 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740040 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740041 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740042 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740043 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740044 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740045 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740046 3 0.000 0.984 0.000 0.000 1.000
#> SRR1740048 3 0.000 0.984 0.000 0.000 1.000
#> SRR1740047 3 0.000 0.984 0.000 0.000 1.000
#> SRR1740049 3 0.000 0.984 0.000 0.000 1.000
#> SRR1740050 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740051 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740052 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740054 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740053 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740056 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740055 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740057 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740058 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740059 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740060 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740061 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740062 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740063 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740064 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740065 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740066 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740067 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740068 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740069 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740070 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740071 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740072 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740073 2 0.175 1.000 0.048 0.952 0.000
#> SRR1740074 3 0.175 0.984 0.000 0.048 0.952
#> SRR1740075 3 0.175 0.984 0.000 0.048 0.952
#> SRR1740076 3 0.175 0.984 0.000 0.048 0.952
#> SRR1740077 3 0.175 0.984 0.000 0.048 0.952
#> SRR1740078 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740079 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740080 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740081 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740082 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740083 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740084 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740085 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740086 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740087 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740088 1 0.000 1.000 1.000 0.000 0.000
#> SRR1740089 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
#> SRR1740034 4 0.4679 0.670 0.352 0.000 0.000 0.648
#> SRR1740035 4 0.4697 0.667 0.356 0.000 0.000 0.644
#> SRR1740036 4 0.4697 0.667 0.356 0.000 0.000 0.644
#> SRR1740037 4 0.4679 0.670 0.352 0.000 0.000 0.648
#> SRR1740038 2 0.0336 0.929 0.008 0.992 0.000 0.000
#> SRR1740039 2 0.0336 0.929 0.008 0.992 0.000 0.000
#> SRR1740040 2 0.0336 0.929 0.008 0.992 0.000 0.000
#> SRR1740041 2 0.0336 0.929 0.008 0.992 0.000 0.000
#> SRR1740042 2 0.3351 0.929 0.008 0.844 0.000 0.148
#> SRR1740043 2 0.3351 0.929 0.008 0.844 0.000 0.148
#> SRR1740044 2 0.3351 0.929 0.008 0.844 0.000 0.148
#> SRR1740045 2 0.3351 0.929 0.008 0.844 0.000 0.148
#> SRR1740046 3 0.0188 0.969 0.000 0.004 0.996 0.000
#> SRR1740048 3 0.0188 0.969 0.000 0.000 0.996 0.004
#> SRR1740047 3 0.0188 0.969 0.000 0.000 0.996 0.004
#> SRR1740049 3 0.0188 0.969 0.000 0.004 0.996 0.000
#> SRR1740050 1 0.1557 0.720 0.944 0.000 0.000 0.056
#> SRR1740051 1 0.1716 0.716 0.936 0.000 0.000 0.064
#> SRR1740052 1 0.1716 0.716 0.936 0.000 0.000 0.064
#> SRR1740054 1 0.3764 0.712 0.784 0.000 0.000 0.216
#> SRR1740053 1 0.1716 0.716 0.936 0.000 0.000 0.064
#> SRR1740056 1 0.3764 0.712 0.784 0.000 0.000 0.216
#> SRR1740055 1 0.3764 0.712 0.784 0.000 0.000 0.216
#> SRR1740057 1 0.3764 0.712 0.784 0.000 0.000 0.216
#> SRR1740058 4 0.4955 0.694 0.444 0.000 0.000 0.556
#> SRR1740059 4 0.4955 0.694 0.444 0.000 0.000 0.556
#> SRR1740060 4 0.4955 0.694 0.444 0.000 0.000 0.556
#> SRR1740061 4 0.4955 0.694 0.444 0.000 0.000 0.556
#> SRR1740062 4 0.4746 0.654 0.368 0.000 0.000 0.632
#> SRR1740063 4 0.4746 0.654 0.368 0.000 0.000 0.632
#> SRR1740064 4 0.4746 0.654 0.368 0.000 0.000 0.632
#> SRR1740065 4 0.4746 0.654 0.368 0.000 0.000 0.632
#> SRR1740066 2 0.0672 0.929 0.008 0.984 0.000 0.008
#> SRR1740067 2 0.0672 0.929 0.008 0.984 0.000 0.008
#> SRR1740068 2 0.0672 0.929 0.008 0.984 0.000 0.008
#> SRR1740069 2 0.0672 0.929 0.008 0.984 0.000 0.008
#> SRR1740070 2 0.3450 0.929 0.008 0.836 0.000 0.156
#> SRR1740071 2 0.3450 0.929 0.008 0.836 0.000 0.156
#> SRR1740072 2 0.3450 0.929 0.008 0.836 0.000 0.156
#> SRR1740073 2 0.3450 0.929 0.008 0.836 0.000 0.156
#> SRR1740074 3 0.2081 0.969 0.000 0.000 0.916 0.084
#> SRR1740075 3 0.2081 0.969 0.000 0.000 0.916 0.084
#> SRR1740076 3 0.2197 0.969 0.000 0.004 0.916 0.080
#> SRR1740077 3 0.2197 0.969 0.000 0.004 0.916 0.080
#> SRR1740078 1 0.1557 0.720 0.944 0.000 0.000 0.056
#> SRR1740079 1 0.1716 0.716 0.936 0.000 0.000 0.064
#> SRR1740080 1 0.1716 0.716 0.936 0.000 0.000 0.064
#> SRR1740081 1 0.1557 0.720 0.944 0.000 0.000 0.056
#> SRR1740082 1 0.3764 0.712 0.784 0.000 0.000 0.216
#> SRR1740083 1 0.3764 0.712 0.784 0.000 0.000 0.216
#> SRR1740084 1 0.3764 0.712 0.784 0.000 0.000 0.216
#> SRR1740085 1 0.3764 0.712 0.784 0.000 0.000 0.216
#> SRR1740086 4 0.4955 0.694 0.444 0.000 0.000 0.556
#> SRR1740087 4 0.4955 0.694 0.444 0.000 0.000 0.556
#> SRR1740088 4 0.4955 0.694 0.444 0.000 0.000 0.556
#> SRR1740089 4 0.4955 0.694 0.444 0.000 0.000 0.556
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.6482 0.622 NA 0.000 0.000 0.492 0.232
#> SRR1740035 4 0.6482 0.622 NA 0.000 0.000 0.492 0.232
#> SRR1740036 4 0.6482 0.622 NA 0.000 0.000 0.492 0.232
#> SRR1740037 4 0.6482 0.622 NA 0.000 0.000 0.492 0.232
#> SRR1740038 2 0.3932 0.838 NA 0.672 0.000 0.000 0.000
#> SRR1740039 2 0.3932 0.838 NA 0.672 0.000 0.000 0.000
#> SRR1740040 2 0.3932 0.838 NA 0.672 0.000 0.000 0.000
#> SRR1740041 2 0.3932 0.838 NA 0.672 0.000 0.000 0.000
#> SRR1740042 2 0.0992 0.844 NA 0.968 0.000 0.000 0.024
#> SRR1740043 2 0.0992 0.844 NA 0.968 0.000 0.000 0.024
#> SRR1740044 2 0.0992 0.844 NA 0.968 0.000 0.000 0.024
#> SRR1740045 2 0.0992 0.844 NA 0.968 0.000 0.000 0.024
#> SRR1740046 3 0.2511 0.955 NA 0.000 0.892 0.000 0.028
#> SRR1740048 3 0.2482 0.955 NA 0.000 0.892 0.000 0.024
#> SRR1740047 3 0.2482 0.955 NA 0.000 0.892 0.000 0.024
#> SRR1740049 3 0.2511 0.955 NA 0.000 0.892 0.000 0.028
#> SRR1740050 5 0.6398 0.707 NA 0.000 0.000 0.200 0.500
#> SRR1740051 5 0.6410 0.707 NA 0.000 0.000 0.200 0.496
#> SRR1740052 5 0.6410 0.707 NA 0.000 0.000 0.200 0.496
#> SRR1740054 5 0.2852 0.678 NA 0.000 0.000 0.172 0.828
#> SRR1740053 5 0.6410 0.707 NA 0.000 0.000 0.200 0.496
#> SRR1740056 5 0.2852 0.678 NA 0.000 0.000 0.172 0.828
#> SRR1740055 5 0.2852 0.678 NA 0.000 0.000 0.172 0.828
#> SRR1740057 5 0.2852 0.678 NA 0.000 0.000 0.172 0.828
#> SRR1740058 4 0.0798 0.657 NA 0.000 0.000 0.976 0.016
#> SRR1740059 4 0.0798 0.657 NA 0.000 0.000 0.976 0.016
#> SRR1740060 4 0.0798 0.657 NA 0.000 0.000 0.976 0.016
#> SRR1740061 4 0.0798 0.657 NA 0.000 0.000 0.976 0.016
#> SRR1740062 4 0.6500 0.619 NA 0.000 0.000 0.488 0.236
#> SRR1740063 4 0.6500 0.619 NA 0.000 0.000 0.488 0.236
#> SRR1740064 4 0.6500 0.619 NA 0.000 0.000 0.488 0.236
#> SRR1740065 4 0.6500 0.619 NA 0.000 0.000 0.488 0.236
#> SRR1740066 2 0.4777 0.838 NA 0.680 0.000 0.000 0.052
#> SRR1740067 2 0.4777 0.838 NA 0.680 0.000 0.000 0.052
#> SRR1740068 2 0.4777 0.838 NA 0.680 0.000 0.000 0.052
#> SRR1740069 2 0.4777 0.838 NA 0.680 0.000 0.000 0.052
#> SRR1740070 2 0.0000 0.844 NA 1.000 0.000 0.000 0.000
#> SRR1740071 2 0.0000 0.844 NA 1.000 0.000 0.000 0.000
#> SRR1740072 2 0.0000 0.844 NA 1.000 0.000 0.000 0.000
#> SRR1740073 2 0.0000 0.844 NA 1.000 0.000 0.000 0.000
#> SRR1740074 3 0.0404 0.954 NA 0.000 0.988 0.000 0.012
#> SRR1740075 3 0.0404 0.954 NA 0.000 0.988 0.000 0.012
#> SRR1740076 3 0.0404 0.954 NA 0.000 0.988 0.000 0.000
#> SRR1740077 3 0.0404 0.954 NA 0.000 0.988 0.000 0.000
#> SRR1740078 5 0.6398 0.707 NA 0.000 0.000 0.200 0.500
#> SRR1740079 5 0.6398 0.707 NA 0.000 0.000 0.200 0.500
#> SRR1740080 5 0.6398 0.707 NA 0.000 0.000 0.200 0.500
#> SRR1740081 5 0.6398 0.707 NA 0.000 0.000 0.200 0.500
#> SRR1740082 5 0.2852 0.678 NA 0.000 0.000 0.172 0.828
#> SRR1740083 5 0.2852 0.678 NA 0.000 0.000 0.172 0.828
#> SRR1740084 5 0.2852 0.678 NA 0.000 0.000 0.172 0.828
#> SRR1740085 5 0.2852 0.678 NA 0.000 0.000 0.172 0.828
#> SRR1740086 4 0.0510 0.657 NA 0.000 0.000 0.984 0.016
#> SRR1740087 4 0.0510 0.657 NA 0.000 0.000 0.984 0.016
#> SRR1740088 4 0.0510 0.657 NA 0.000 0.000 0.984 0.016
#> SRR1740089 4 0.0510 0.657 NA 0.000 0.000 0.984 0.016
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.2907 0.967 0.028 0.000 0.000 0.860 0.096 0.016
#> SRR1740035 4 0.2858 0.969 0.028 0.000 0.000 0.864 0.092 0.016
#> SRR1740036 4 0.2858 0.969 0.028 0.000 0.000 0.864 0.092 0.016
#> SRR1740037 4 0.2907 0.967 0.028 0.000 0.000 0.860 0.096 0.016
#> SRR1740038 2 0.1682 0.773 0.052 0.928 0.000 0.020 0.000 0.000
#> SRR1740039 2 0.1682 0.773 0.052 0.928 0.000 0.020 0.000 0.000
#> SRR1740040 2 0.1682 0.773 0.052 0.928 0.000 0.020 0.000 0.000
#> SRR1740041 2 0.1682 0.773 0.052 0.928 0.000 0.020 0.000 0.000
#> SRR1740042 2 0.5871 0.771 0.224 0.556 0.000 0.016 0.000 0.204
#> SRR1740043 2 0.5871 0.771 0.224 0.556 0.000 0.016 0.000 0.204
#> SRR1740044 2 0.5871 0.771 0.224 0.556 0.000 0.016 0.000 0.204
#> SRR1740045 2 0.5927 0.771 0.220 0.556 0.000 0.020 0.000 0.204
#> SRR1740046 3 0.3592 0.915 0.124 0.000 0.812 0.044 0.000 0.020
#> SRR1740048 3 0.3664 0.915 0.116 0.000 0.812 0.044 0.000 0.028
#> SRR1740047 3 0.3664 0.915 0.116 0.000 0.812 0.044 0.000 0.028
#> SRR1740049 3 0.3592 0.915 0.124 0.000 0.812 0.044 0.000 0.020
#> SRR1740050 5 0.0146 0.978 0.000 0.000 0.000 0.004 0.996 0.000
#> SRR1740051 5 0.1088 0.968 0.024 0.000 0.000 0.000 0.960 0.016
#> SRR1740052 5 0.1088 0.968 0.024 0.000 0.000 0.000 0.960 0.016
#> SRR1740054 1 0.6210 0.995 0.472 0.000 0.000 0.172 0.332 0.024
#> SRR1740053 5 0.1088 0.968 0.024 0.000 0.000 0.000 0.960 0.016
#> SRR1740056 1 0.6210 0.995 0.472 0.000 0.000 0.172 0.332 0.024
#> SRR1740055 1 0.6275 0.992 0.468 0.000 0.000 0.172 0.332 0.028
#> SRR1740057 1 0.6210 0.995 0.472 0.000 0.000 0.172 0.332 0.024
#> SRR1740058 6 0.6153 0.968 0.052 0.000 0.000 0.216 0.164 0.568
#> SRR1740059 6 0.6153 0.968 0.052 0.000 0.000 0.216 0.164 0.568
#> SRR1740060 6 0.6153 0.968 0.052 0.000 0.000 0.216 0.164 0.568
#> SRR1740061 6 0.6153 0.968 0.052 0.000 0.000 0.216 0.164 0.568
#> SRR1740062 4 0.1765 0.971 0.000 0.000 0.000 0.904 0.096 0.000
#> SRR1740063 4 0.1765 0.971 0.000 0.000 0.000 0.904 0.096 0.000
#> SRR1740064 4 0.1765 0.971 0.000 0.000 0.000 0.904 0.096 0.000
#> SRR1740065 4 0.1765 0.971 0.000 0.000 0.000 0.904 0.096 0.000
#> SRR1740066 2 0.0000 0.773 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1740067 2 0.0000 0.773 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1740068 2 0.0000 0.773 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1740069 2 0.0000 0.773 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1740070 2 0.5529 0.771 0.152 0.560 0.000 0.004 0.000 0.284
#> SRR1740071 2 0.5529 0.771 0.152 0.560 0.000 0.004 0.000 0.284
#> SRR1740072 2 0.5542 0.771 0.156 0.560 0.000 0.004 0.000 0.280
#> SRR1740073 2 0.5542 0.771 0.156 0.560 0.000 0.004 0.000 0.280
#> SRR1740074 3 0.0632 0.913 0.000 0.000 0.976 0.000 0.000 0.024
#> SRR1740075 3 0.0632 0.913 0.000 0.000 0.976 0.000 0.000 0.024
#> SRR1740076 3 0.0547 0.913 0.020 0.000 0.980 0.000 0.000 0.000
#> SRR1740077 3 0.0547 0.913 0.020 0.000 0.980 0.000 0.000 0.000
#> SRR1740078 5 0.0146 0.978 0.000 0.000 0.000 0.004 0.996 0.000
#> SRR1740079 5 0.0000 0.978 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1740080 5 0.0000 0.978 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1740081 5 0.0146 0.978 0.000 0.000 0.000 0.004 0.996 0.000
#> SRR1740082 1 0.6068 0.995 0.480 0.000 0.000 0.172 0.332 0.016
#> SRR1740083 1 0.6068 0.995 0.480 0.000 0.000 0.172 0.332 0.016
#> SRR1740084 1 0.6068 0.995 0.480 0.000 0.000 0.172 0.332 0.016
#> SRR1740085 1 0.6068 0.995 0.480 0.000 0.000 0.172 0.332 0.016
#> SRR1740086 6 0.5133 0.968 0.000 0.000 0.000 0.212 0.164 0.624
#> SRR1740087 6 0.5133 0.968 0.000 0.000 0.000 0.212 0.164 0.624
#> SRR1740088 6 0.5133 0.968 0.000 0.000 0.000 0.212 0.164 0.624
#> SRR1740089 6 0.5133 0.968 0.000 0.000 0.000 0.212 0.164 0.624
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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.499 0.501 0.501
#> 3 3 0.917 0.951 0.963 0.166 0.917 0.834
#> 4 4 0.834 0.939 0.913 0.114 0.958 0.901
#> 5 5 0.834 0.915 0.909 0.158 0.875 0.669
#> 6 6 0.917 0.979 0.974 0.103 0.917 0.670
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3
There is also optional best \(k\) = 2 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1740034 1 0 1 1 0
#> SRR1740035 1 0 1 1 0
#> SRR1740036 1 0 1 1 0
#> SRR1740037 1 0 1 1 0
#> SRR1740038 2 0 1 0 1
#> SRR1740039 2 0 1 0 1
#> SRR1740040 2 0 1 0 1
#> SRR1740041 2 0 1 0 1
#> SRR1740042 2 0 1 0 1
#> SRR1740043 2 0 1 0 1
#> SRR1740044 2 0 1 0 1
#> SRR1740045 2 0 1 0 1
#> SRR1740046 2 0 1 0 1
#> SRR1740048 2 0 1 0 1
#> SRR1740047 2 0 1 0 1
#> SRR1740049 2 0 1 0 1
#> SRR1740050 1 0 1 1 0
#> SRR1740051 1 0 1 1 0
#> SRR1740052 1 0 1 1 0
#> SRR1740054 1 0 1 1 0
#> SRR1740053 1 0 1 1 0
#> SRR1740056 1 0 1 1 0
#> SRR1740055 1 0 1 1 0
#> SRR1740057 1 0 1 1 0
#> SRR1740058 1 0 1 1 0
#> SRR1740059 1 0 1 1 0
#> SRR1740060 1 0 1 1 0
#> SRR1740061 1 0 1 1 0
#> SRR1740062 1 0 1 1 0
#> SRR1740063 1 0 1 1 0
#> SRR1740064 1 0 1 1 0
#> SRR1740065 1 0 1 1 0
#> SRR1740066 2 0 1 0 1
#> SRR1740067 2 0 1 0 1
#> SRR1740068 2 0 1 0 1
#> SRR1740069 2 0 1 0 1
#> SRR1740070 2 0 1 0 1
#> SRR1740071 2 0 1 0 1
#> SRR1740072 2 0 1 0 1
#> SRR1740073 2 0 1 0 1
#> SRR1740074 2 0 1 0 1
#> SRR1740075 2 0 1 0 1
#> SRR1740076 2 0 1 0 1
#> SRR1740077 2 0 1 0 1
#> SRR1740078 1 0 1 1 0
#> SRR1740079 1 0 1 1 0
#> SRR1740080 1 0 1 1 0
#> SRR1740081 1 0 1 1 0
#> SRR1740082 1 0 1 1 0
#> SRR1740083 1 0 1 1 0
#> SRR1740084 1 0 1 1 0
#> SRR1740085 1 0 1 1 0
#> SRR1740086 1 0 1 1 0
#> SRR1740087 1 0 1 1 0
#> SRR1740088 1 0 1 1 0
#> SRR1740089 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740035 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740036 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740037 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740038 2 0.0000 0.844 0.000 1.000 0.000
#> SRR1740039 2 0.0000 0.844 0.000 1.000 0.000
#> SRR1740040 2 0.0000 0.844 0.000 1.000 0.000
#> SRR1740041 2 0.0000 0.844 0.000 1.000 0.000
#> SRR1740042 2 0.5138 0.819 0.000 0.748 0.252
#> SRR1740043 2 0.5138 0.819 0.000 0.748 0.252
#> SRR1740044 2 0.5138 0.819 0.000 0.748 0.252
#> SRR1740045 2 0.5138 0.819 0.000 0.748 0.252
#> SRR1740046 3 0.0237 1.000 0.000 0.004 0.996
#> SRR1740048 3 0.0237 1.000 0.000 0.004 0.996
#> SRR1740047 3 0.0237 1.000 0.000 0.004 0.996
#> SRR1740049 3 0.0237 1.000 0.000 0.004 0.996
#> SRR1740050 1 0.0237 0.997 0.996 0.000 0.004
#> SRR1740051 1 0.0237 0.997 0.996 0.000 0.004
#> SRR1740052 1 0.0237 0.997 0.996 0.000 0.004
#> SRR1740054 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740053 1 0.0237 0.997 0.996 0.000 0.004
#> SRR1740056 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740055 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740057 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740058 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740059 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740060 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740061 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740062 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740063 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740064 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740065 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740066 2 0.0000 0.844 0.000 1.000 0.000
#> SRR1740067 2 0.0000 0.844 0.000 1.000 0.000
#> SRR1740068 2 0.0000 0.844 0.000 1.000 0.000
#> SRR1740069 2 0.0000 0.844 0.000 1.000 0.000
#> SRR1740070 2 0.5138 0.819 0.000 0.748 0.252
#> SRR1740071 2 0.5138 0.819 0.000 0.748 0.252
#> SRR1740072 2 0.5138 0.819 0.000 0.748 0.252
#> SRR1740073 2 0.5138 0.819 0.000 0.748 0.252
#> SRR1740074 3 0.0237 1.000 0.000 0.004 0.996
#> SRR1740075 3 0.0237 1.000 0.000 0.004 0.996
#> SRR1740076 3 0.0237 1.000 0.000 0.004 0.996
#> SRR1740077 3 0.0237 1.000 0.000 0.004 0.996
#> SRR1740078 1 0.0237 0.997 0.996 0.000 0.004
#> SRR1740079 1 0.0237 0.997 0.996 0.000 0.004
#> SRR1740080 1 0.0237 0.997 0.996 0.000 0.004
#> SRR1740081 1 0.0237 0.997 0.996 0.000 0.004
#> SRR1740082 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740083 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740084 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740085 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740086 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740087 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740088 1 0.0000 0.999 1.000 0.000 0.000
#> SRR1740089 1 0.0000 0.999 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 1 0.208 0.902 0.916 0.000 0.000 0.084
#> SRR1740035 1 0.208 0.902 0.916 0.000 0.000 0.084
#> SRR1740036 1 0.208 0.902 0.916 0.000 0.000 0.084
#> SRR1740037 1 0.208 0.902 0.916 0.000 0.000 0.084
#> SRR1740038 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740039 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740040 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740041 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740042 4 0.520 1.000 0.000 0.264 0.036 0.700
#> SRR1740043 4 0.520 1.000 0.000 0.264 0.036 0.700
#> SRR1740044 4 0.520 1.000 0.000 0.264 0.036 0.700
#> SRR1740045 4 0.520 1.000 0.000 0.264 0.036 0.700
#> SRR1740046 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR1740048 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR1740047 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR1740049 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR1740050 1 0.384 0.821 0.776 0.000 0.000 0.224
#> SRR1740051 1 0.384 0.821 0.776 0.000 0.000 0.224
#> SRR1740052 1 0.384 0.821 0.776 0.000 0.000 0.224
#> SRR1740054 1 0.000 0.926 1.000 0.000 0.000 0.000
#> SRR1740053 1 0.384 0.821 0.776 0.000 0.000 0.224
#> SRR1740056 1 0.000 0.926 1.000 0.000 0.000 0.000
#> SRR1740055 1 0.000 0.926 1.000 0.000 0.000 0.000
#> SRR1740057 1 0.000 0.926 1.000 0.000 0.000 0.000
#> SRR1740058 1 0.000 0.926 1.000 0.000 0.000 0.000
#> SRR1740059 1 0.000 0.926 1.000 0.000 0.000 0.000
#> SRR1740060 1 0.000 0.926 1.000 0.000 0.000 0.000
#> SRR1740061 1 0.000 0.926 1.000 0.000 0.000 0.000
#> SRR1740062 1 0.208 0.902 0.916 0.000 0.000 0.084
#> SRR1740063 1 0.208 0.902 0.916 0.000 0.000 0.084
#> SRR1740064 1 0.208 0.902 0.916 0.000 0.000 0.084
#> SRR1740065 1 0.208 0.902 0.916 0.000 0.000 0.084
#> SRR1740066 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740067 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740068 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740069 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1740070 4 0.520 1.000 0.000 0.264 0.036 0.700
#> SRR1740071 4 0.520 1.000 0.000 0.264 0.036 0.700
#> SRR1740072 4 0.520 1.000 0.000 0.264 0.036 0.700
#> SRR1740073 4 0.520 1.000 0.000 0.264 0.036 0.700
#> SRR1740074 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR1740075 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR1740076 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR1740077 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR1740078 1 0.384 0.821 0.776 0.000 0.000 0.224
#> SRR1740079 1 0.384 0.821 0.776 0.000 0.000 0.224
#> SRR1740080 1 0.384 0.821 0.776 0.000 0.000 0.224
#> SRR1740081 1 0.384 0.821 0.776 0.000 0.000 0.224
#> SRR1740082 1 0.000 0.926 1.000 0.000 0.000 0.000
#> SRR1740083 1 0.000 0.926 1.000 0.000 0.000 0.000
#> SRR1740084 1 0.000 0.926 1.000 0.000 0.000 0.000
#> SRR1740085 1 0.000 0.926 1.000 0.000 0.000 0.000
#> SRR1740086 1 0.000 0.926 1.000 0.000 0.000 0.000
#> SRR1740087 1 0.000 0.926 1.000 0.000 0.000 0.000
#> SRR1740088 1 0.000 0.926 1.000 0.000 0.000 0.000
#> SRR1740089 1 0.000 0.926 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
#> SRR1740034 1 0.278 0.712 0.880 0.000 0 0.048 0.072
#> SRR1740035 1 0.278 0.712 0.880 0.000 0 0.048 0.072
#> SRR1740036 1 0.278 0.712 0.880 0.000 0 0.048 0.072
#> SRR1740037 1 0.278 0.712 0.880 0.000 0 0.048 0.072
#> SRR1740038 2 0.051 0.993 0.000 0.984 0 0.000 0.016
#> SRR1740039 2 0.051 0.993 0.000 0.984 0 0.000 0.016
#> SRR1740040 2 0.051 0.993 0.000 0.984 0 0.000 0.016
#> SRR1740041 2 0.051 0.993 0.000 0.984 0 0.000 0.016
#> SRR1740042 4 0.127 1.000 0.000 0.052 0 0.948 0.000
#> SRR1740043 4 0.127 1.000 0.000 0.052 0 0.948 0.000
#> SRR1740044 4 0.127 1.000 0.000 0.052 0 0.948 0.000
#> SRR1740045 4 0.127 1.000 0.000 0.052 0 0.948 0.000
#> SRR1740046 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740048 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740047 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740049 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740050 5 0.051 1.000 0.016 0.000 0 0.000 0.984
#> SRR1740051 5 0.051 1.000 0.016 0.000 0 0.000 0.984
#> SRR1740052 5 0.051 1.000 0.016 0.000 0 0.000 0.984
#> SRR1740054 1 0.340 0.851 0.780 0.000 0 0.004 0.216
#> SRR1740053 5 0.051 1.000 0.016 0.000 0 0.000 0.984
#> SRR1740056 1 0.340 0.851 0.780 0.000 0 0.004 0.216
#> SRR1740055 1 0.340 0.851 0.780 0.000 0 0.004 0.216
#> SRR1740057 1 0.340 0.851 0.780 0.000 0 0.004 0.216
#> SRR1740058 1 0.331 0.852 0.776 0.000 0 0.000 0.224
#> SRR1740059 1 0.331 0.852 0.776 0.000 0 0.000 0.224
#> SRR1740060 1 0.331 0.852 0.776 0.000 0 0.000 0.224
#> SRR1740061 1 0.331 0.852 0.776 0.000 0 0.000 0.224
#> SRR1740062 1 0.278 0.712 0.880 0.000 0 0.048 0.072
#> SRR1740063 1 0.278 0.712 0.880 0.000 0 0.048 0.072
#> SRR1740064 1 0.278 0.712 0.880 0.000 0 0.048 0.072
#> SRR1740065 1 0.278 0.712 0.880 0.000 0 0.048 0.072
#> SRR1740066 2 0.000 0.993 0.000 1.000 0 0.000 0.000
#> SRR1740067 2 0.000 0.993 0.000 1.000 0 0.000 0.000
#> SRR1740068 2 0.000 0.993 0.000 1.000 0 0.000 0.000
#> SRR1740069 2 0.000 0.993 0.000 1.000 0 0.000 0.000
#> SRR1740070 4 0.127 1.000 0.000 0.052 0 0.948 0.000
#> SRR1740071 4 0.127 1.000 0.000 0.052 0 0.948 0.000
#> SRR1740072 4 0.127 1.000 0.000 0.052 0 0.948 0.000
#> SRR1740073 4 0.127 1.000 0.000 0.052 0 0.948 0.000
#> SRR1740074 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740075 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740076 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740077 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740078 5 0.051 1.000 0.016 0.000 0 0.000 0.984
#> SRR1740079 5 0.051 1.000 0.016 0.000 0 0.000 0.984
#> SRR1740080 5 0.051 1.000 0.016 0.000 0 0.000 0.984
#> SRR1740081 5 0.051 1.000 0.016 0.000 0 0.000 0.984
#> SRR1740082 1 0.340 0.851 0.780 0.000 0 0.004 0.216
#> SRR1740083 1 0.340 0.851 0.780 0.000 0 0.004 0.216
#> SRR1740084 1 0.340 0.851 0.780 0.000 0 0.004 0.216
#> SRR1740085 1 0.340 0.851 0.780 0.000 0 0.004 0.216
#> SRR1740086 1 0.331 0.852 0.776 0.000 0 0.000 0.224
#> SRR1740087 1 0.331 0.852 0.776 0.000 0 0.000 0.224
#> SRR1740088 1 0.331 0.852 0.776 0.000 0 0.000 0.224
#> SRR1740089 1 0.331 0.852 0.776 0.000 0 0.000 0.224
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.0937 1.000 0.000 0.000 0 0.960 0.000 0.040
#> SRR1740035 4 0.0937 1.000 0.000 0.000 0 0.960 0.000 0.040
#> SRR1740036 4 0.0937 1.000 0.000 0.000 0 0.960 0.000 0.040
#> SRR1740037 4 0.0937 1.000 0.000 0.000 0 0.960 0.000 0.040
#> SRR1740038 2 0.1151 0.987 0.012 0.956 0 0.032 0.000 0.000
#> SRR1740039 2 0.1151 0.987 0.012 0.956 0 0.032 0.000 0.000
#> SRR1740040 2 0.1151 0.987 0.012 0.956 0 0.032 0.000 0.000
#> SRR1740041 2 0.1151 0.987 0.012 0.956 0 0.032 0.000 0.000
#> SRR1740042 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1740043 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1740044 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1740045 1 0.0000 0.997 1.000 0.000 0 0.000 0.000 0.000
#> SRR1740046 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1740048 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1740047 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1740049 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1740050 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> SRR1740051 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> SRR1740052 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> SRR1740054 6 0.0000 0.936 0.000 0.000 0 0.000 0.000 1.000
#> SRR1740053 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> SRR1740056 6 0.0000 0.936 0.000 0.000 0 0.000 0.000 1.000
#> SRR1740055 6 0.0000 0.936 0.000 0.000 0 0.000 0.000 1.000
#> SRR1740057 6 0.0000 0.936 0.000 0.000 0 0.000 0.000 1.000
#> SRR1740058 6 0.2264 0.934 0.000 0.012 0 0.096 0.004 0.888
#> SRR1740059 6 0.2264 0.934 0.000 0.012 0 0.096 0.004 0.888
#> SRR1740060 6 0.2264 0.934 0.000 0.012 0 0.096 0.004 0.888
#> SRR1740061 6 0.2264 0.934 0.000 0.012 0 0.096 0.004 0.888
#> SRR1740062 4 0.0937 1.000 0.000 0.000 0 0.960 0.000 0.040
#> SRR1740063 4 0.0937 1.000 0.000 0.000 0 0.960 0.000 0.040
#> SRR1740064 4 0.0937 1.000 0.000 0.000 0 0.960 0.000 0.040
#> SRR1740065 4 0.0937 1.000 0.000 0.000 0 0.960 0.000 0.040
#> SRR1740066 2 0.0363 0.987 0.012 0.988 0 0.000 0.000 0.000
#> SRR1740067 2 0.0363 0.987 0.012 0.988 0 0.000 0.000 0.000
#> SRR1740068 2 0.0363 0.987 0.012 0.988 0 0.000 0.000 0.000
#> SRR1740069 2 0.0363 0.987 0.012 0.988 0 0.000 0.000 0.000
#> SRR1740070 1 0.0260 0.997 0.992 0.000 0 0.008 0.000 0.000
#> SRR1740071 1 0.0260 0.997 0.992 0.000 0 0.008 0.000 0.000
#> SRR1740072 1 0.0260 0.997 0.992 0.000 0 0.008 0.000 0.000
#> SRR1740073 1 0.0260 0.997 0.992 0.000 0 0.008 0.000 0.000
#> SRR1740074 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1740075 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1740076 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1740077 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1740078 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> SRR1740079 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> SRR1740080 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> SRR1740081 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> SRR1740082 6 0.0000 0.936 0.000 0.000 0 0.000 0.000 1.000
#> SRR1740083 6 0.0000 0.936 0.000 0.000 0 0.000 0.000 1.000
#> SRR1740084 6 0.0000 0.936 0.000 0.000 0 0.000 0.000 1.000
#> SRR1740085 6 0.0000 0.936 0.000 0.000 0 0.000 0.000 1.000
#> SRR1740086 6 0.2264 0.934 0.000 0.012 0 0.096 0.004 0.888
#> SRR1740087 6 0.2264 0.934 0.000 0.012 0 0.096 0.004 0.888
#> SRR1740088 6 0.2264 0.934 0.000 0.012 0 0.096 0.004 0.888
#> SRR1740089 6 0.2264 0.934 0.000 0.012 0 0.096 0.004 0.888
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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1 1.000 1.000 0.2501 0.751 0.751
#> 3 3 1 1.000 1.000 1.3280 0.668 0.557
#> 4 4 1 0.936 0.975 0.2535 0.850 0.641
#> 5 5 1 0.973 0.981 0.0947 0.918 0.700
#> 6 6 1 0.999 0.999 0.0406 0.948 0.753
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
#> SRR1740034 1 0 1 1 0
#> SRR1740035 1 0 1 1 0
#> SRR1740036 1 0 1 1 0
#> SRR1740037 1 0 1 1 0
#> SRR1740038 1 0 1 1 0
#> SRR1740039 1 0 1 1 0
#> SRR1740040 1 0 1 1 0
#> SRR1740041 1 0 1 1 0
#> SRR1740042 1 0 1 1 0
#> SRR1740043 1 0 1 1 0
#> SRR1740044 1 0 1 1 0
#> SRR1740045 1 0 1 1 0
#> SRR1740046 2 0 1 0 1
#> SRR1740048 2 0 1 0 1
#> SRR1740047 2 0 1 0 1
#> SRR1740049 2 0 1 0 1
#> SRR1740050 1 0 1 1 0
#> SRR1740051 1 0 1 1 0
#> SRR1740052 1 0 1 1 0
#> SRR1740054 1 0 1 1 0
#> SRR1740053 1 0 1 1 0
#> SRR1740056 1 0 1 1 0
#> SRR1740055 1 0 1 1 0
#> SRR1740057 1 0 1 1 0
#> SRR1740058 1 0 1 1 0
#> SRR1740059 1 0 1 1 0
#> SRR1740060 1 0 1 1 0
#> SRR1740061 1 0 1 1 0
#> SRR1740062 1 0 1 1 0
#> SRR1740063 1 0 1 1 0
#> SRR1740064 1 0 1 1 0
#> SRR1740065 1 0 1 1 0
#> SRR1740066 1 0 1 1 0
#> SRR1740067 1 0 1 1 0
#> SRR1740068 1 0 1 1 0
#> SRR1740069 1 0 1 1 0
#> SRR1740070 1 0 1 1 0
#> SRR1740071 1 0 1 1 0
#> SRR1740072 1 0 1 1 0
#> SRR1740073 1 0 1 1 0
#> SRR1740074 2 0 1 0 1
#> SRR1740075 2 0 1 0 1
#> SRR1740076 2 0 1 0 1
#> SRR1740077 2 0 1 0 1
#> SRR1740078 1 0 1 1 0
#> SRR1740079 1 0 1 1 0
#> SRR1740080 1 0 1 1 0
#> SRR1740081 1 0 1 1 0
#> SRR1740082 1 0 1 1 0
#> SRR1740083 1 0 1 1 0
#> SRR1740084 1 0 1 1 0
#> SRR1740085 1 0 1 1 0
#> SRR1740086 1 0 1 1 0
#> SRR1740087 1 0 1 1 0
#> SRR1740088 1 0 1 1 0
#> SRR1740089 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0 1 1 0 0
#> SRR1740035 1 0 1 1 0 0
#> SRR1740036 1 0 1 1 0 0
#> SRR1740037 1 0 1 1 0 0
#> SRR1740038 2 0 1 0 1 0
#> SRR1740039 2 0 1 0 1 0
#> SRR1740040 2 0 1 0 1 0
#> SRR1740041 2 0 1 0 1 0
#> SRR1740042 2 0 1 0 1 0
#> SRR1740043 2 0 1 0 1 0
#> SRR1740044 2 0 1 0 1 0
#> SRR1740045 2 0 1 0 1 0
#> SRR1740046 3 0 1 0 0 1
#> SRR1740048 3 0 1 0 0 1
#> SRR1740047 3 0 1 0 0 1
#> SRR1740049 3 0 1 0 0 1
#> SRR1740050 1 0 1 1 0 0
#> SRR1740051 1 0 1 1 0 0
#> SRR1740052 1 0 1 1 0 0
#> SRR1740054 1 0 1 1 0 0
#> SRR1740053 1 0 1 1 0 0
#> SRR1740056 1 0 1 1 0 0
#> SRR1740055 1 0 1 1 0 0
#> SRR1740057 1 0 1 1 0 0
#> SRR1740058 1 0 1 1 0 0
#> SRR1740059 1 0 1 1 0 0
#> SRR1740060 1 0 1 1 0 0
#> SRR1740061 1 0 1 1 0 0
#> SRR1740062 1 0 1 1 0 0
#> SRR1740063 1 0 1 1 0 0
#> SRR1740064 1 0 1 1 0 0
#> SRR1740065 1 0 1 1 0 0
#> SRR1740066 2 0 1 0 1 0
#> SRR1740067 2 0 1 0 1 0
#> SRR1740068 2 0 1 0 1 0
#> SRR1740069 2 0 1 0 1 0
#> SRR1740070 2 0 1 0 1 0
#> SRR1740071 2 0 1 0 1 0
#> SRR1740072 2 0 1 0 1 0
#> SRR1740073 2 0 1 0 1 0
#> SRR1740074 3 0 1 0 0 1
#> SRR1740075 3 0 1 0 0 1
#> SRR1740076 3 0 1 0 0 1
#> SRR1740077 3 0 1 0 0 1
#> SRR1740078 1 0 1 1 0 0
#> SRR1740079 1 0 1 1 0 0
#> SRR1740080 1 0 1 1 0 0
#> SRR1740081 1 0 1 1 0 0
#> SRR1740082 1 0 1 1 0 0
#> SRR1740083 1 0 1 1 0 0
#> SRR1740084 1 0 1 1 0 0
#> SRR1740085 1 0 1 1 0 0
#> SRR1740086 1 0 1 1 0 0
#> SRR1740087 1 0 1 1 0 0
#> SRR1740088 1 0 1 1 0 0
#> SRR1740089 1 0 1 1 0 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 4 0.0000 0.8937 0.000 0 0 1.000
#> SRR1740035 1 0.4992 0.0208 0.524 0 0 0.476
#> SRR1740036 4 0.4994 0.0217 0.480 0 0 0.520
#> SRR1740037 4 0.2281 0.8257 0.096 0 0 0.904
#> SRR1740038 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740039 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740040 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740041 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740042 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740043 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740044 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740045 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740046 3 0.0000 1.0000 0.000 0 1 0.000
#> SRR1740048 3 0.0000 1.0000 0.000 0 1 0.000
#> SRR1740047 3 0.0000 1.0000 0.000 0 1 0.000
#> SRR1740049 3 0.0000 1.0000 0.000 0 1 0.000
#> SRR1740050 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740051 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740052 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740054 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740053 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740056 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740055 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740057 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740058 4 0.0921 0.9206 0.028 0 0 0.972
#> SRR1740059 4 0.0921 0.9206 0.028 0 0 0.972
#> SRR1740060 4 0.0921 0.9206 0.028 0 0 0.972
#> SRR1740061 4 0.0921 0.9206 0.028 0 0 0.972
#> SRR1740062 1 0.0921 0.9494 0.972 0 0 0.028
#> SRR1740063 1 0.0921 0.9494 0.972 0 0 0.028
#> SRR1740064 1 0.0921 0.9494 0.972 0 0 0.028
#> SRR1740065 1 0.0921 0.9494 0.972 0 0 0.028
#> SRR1740066 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740067 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740068 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740069 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740070 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740071 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740072 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740073 2 0.0000 1.0000 0.000 1 0 0.000
#> SRR1740074 3 0.0000 1.0000 0.000 0 1 0.000
#> SRR1740075 3 0.0000 1.0000 0.000 0 1 0.000
#> SRR1740076 3 0.0000 1.0000 0.000 0 1 0.000
#> SRR1740077 3 0.0000 1.0000 0.000 0 1 0.000
#> SRR1740078 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740079 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740080 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740081 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740082 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740083 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740084 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740085 1 0.0000 0.9681 1.000 0 0 0.000
#> SRR1740086 4 0.0921 0.9206 0.028 0 0 0.972
#> SRR1740087 4 0.0921 0.9206 0.028 0 0 0.972
#> SRR1740088 4 0.0921 0.9206 0.028 0 0 0.972
#> SRR1740089 4 0.0921 0.9206 0.028 0 0 0.972
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.127 0.918 0.052 0 0 0.948 0.000
#> SRR1740035 4 0.342 0.763 0.240 0 0 0.760 0.000
#> SRR1740036 4 0.342 0.763 0.240 0 0 0.760 0.000
#> SRR1740037 4 0.242 0.871 0.132 0 0 0.868 0.000
#> SRR1740038 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740039 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740040 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740041 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740042 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740043 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740044 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740045 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740046 3 0.000 1.000 0.000 0 1 0.000 0.000
#> SRR1740048 3 0.000 1.000 0.000 0 1 0.000 0.000
#> SRR1740047 3 0.000 1.000 0.000 0 1 0.000 0.000
#> SRR1740049 3 0.000 1.000 0.000 0 1 0.000 0.000
#> SRR1740050 5 0.000 1.000 0.000 0 0 0.000 1.000
#> SRR1740051 5 0.000 1.000 0.000 0 0 0.000 1.000
#> SRR1740052 5 0.000 1.000 0.000 0 0 0.000 1.000
#> SRR1740054 1 0.127 0.978 0.948 0 0 0.000 0.052
#> SRR1740053 5 0.000 1.000 0.000 0 0 0.000 1.000
#> SRR1740056 1 0.127 0.978 0.948 0 0 0.000 0.052
#> SRR1740055 1 0.127 0.978 0.948 0 0 0.000 0.052
#> SRR1740057 1 0.127 0.978 0.948 0 0 0.000 0.052
#> SRR1740058 4 0.000 0.940 0.000 0 0 1.000 0.000
#> SRR1740059 4 0.000 0.940 0.000 0 0 1.000 0.000
#> SRR1740060 4 0.000 0.940 0.000 0 0 1.000 0.000
#> SRR1740061 4 0.000 0.940 0.000 0 0 1.000 0.000
#> SRR1740062 1 0.000 0.957 1.000 0 0 0.000 0.000
#> SRR1740063 1 0.000 0.957 1.000 0 0 0.000 0.000
#> SRR1740064 1 0.000 0.957 1.000 0 0 0.000 0.000
#> SRR1740065 1 0.000 0.957 1.000 0 0 0.000 0.000
#> SRR1740066 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740067 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740068 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740069 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740070 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740071 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740072 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740073 2 0.000 1.000 0.000 1 0 0.000 0.000
#> SRR1740074 3 0.000 1.000 0.000 0 1 0.000 0.000
#> SRR1740075 3 0.000 1.000 0.000 0 1 0.000 0.000
#> SRR1740076 3 0.000 1.000 0.000 0 1 0.000 0.000
#> SRR1740077 3 0.000 1.000 0.000 0 1 0.000 0.000
#> SRR1740078 5 0.000 1.000 0.000 0 0 0.000 1.000
#> SRR1740079 5 0.000 1.000 0.000 0 0 0.000 1.000
#> SRR1740080 5 0.000 1.000 0.000 0 0 0.000 1.000
#> SRR1740081 5 0.000 1.000 0.000 0 0 0.000 1.000
#> SRR1740082 1 0.127 0.978 0.948 0 0 0.000 0.052
#> SRR1740083 1 0.127 0.978 0.948 0 0 0.000 0.052
#> SRR1740084 1 0.127 0.978 0.948 0 0 0.000 0.052
#> SRR1740085 1 0.127 0.978 0.948 0 0 0.000 0.052
#> SRR1740086 4 0.000 0.940 0.000 0 0 1.000 0.000
#> SRR1740087 4 0.000 0.940 0.000 0 0 1.000 0.000
#> SRR1740088 4 0.000 0.940 0.000 0 0 1.000 0.000
#> SRR1740089 4 0.000 0.940 0.000 0 0 1.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.0146 0.997 0.000 0.000 0 0.996 0 0.004
#> SRR1740035 4 0.0146 0.997 0.000 0.000 0 0.996 0 0.004
#> SRR1740036 4 0.0146 0.997 0.000 0.000 0 0.996 0 0.004
#> SRR1740037 4 0.0146 0.997 0.000 0.000 0 0.996 0 0.004
#> SRR1740038 2 0.0000 0.998 0.000 1.000 0 0.000 0 0.000
#> SRR1740039 2 0.0000 0.998 0.000 1.000 0 0.000 0 0.000
#> SRR1740040 2 0.0000 0.998 0.000 1.000 0 0.000 0 0.000
#> SRR1740041 2 0.0000 0.998 0.000 1.000 0 0.000 0 0.000
#> SRR1740042 2 0.0146 0.998 0.000 0.996 0 0.004 0 0.000
#> SRR1740043 2 0.0146 0.998 0.000 0.996 0 0.004 0 0.000
#> SRR1740044 2 0.0146 0.998 0.000 0.996 0 0.004 0 0.000
#> SRR1740045 2 0.0146 0.998 0.000 0.996 0 0.004 0 0.000
#> SRR1740046 3 0.0000 1.000 0.000 0.000 1 0.000 0 0.000
#> SRR1740048 3 0.0000 1.000 0.000 0.000 1 0.000 0 0.000
#> SRR1740047 3 0.0000 1.000 0.000 0.000 1 0.000 0 0.000
#> SRR1740049 3 0.0000 1.000 0.000 0.000 1 0.000 0 0.000
#> SRR1740050 5 0.0000 1.000 0.000 0.000 0 0.000 1 0.000
#> SRR1740051 5 0.0000 1.000 0.000 0.000 0 0.000 1 0.000
#> SRR1740052 5 0.0000 1.000 0.000 0.000 0 0.000 1 0.000
#> SRR1740054 1 0.0000 1.000 1.000 0.000 0 0.000 0 0.000
#> SRR1740053 5 0.0000 1.000 0.000 0.000 0 0.000 1 0.000
#> SRR1740056 1 0.0000 1.000 1.000 0.000 0 0.000 0 0.000
#> SRR1740055 1 0.0000 1.000 1.000 0.000 0 0.000 0 0.000
#> SRR1740057 1 0.0000 1.000 1.000 0.000 0 0.000 0 0.000
#> SRR1740058 6 0.0000 1.000 0.000 0.000 0 0.000 0 1.000
#> SRR1740059 6 0.0000 1.000 0.000 0.000 0 0.000 0 1.000
#> SRR1740060 6 0.0000 1.000 0.000 0.000 0 0.000 0 1.000
#> SRR1740061 6 0.0000 1.000 0.000 0.000 0 0.000 0 1.000
#> SRR1740062 4 0.0146 0.997 0.004 0.000 0 0.996 0 0.000
#> SRR1740063 4 0.0146 0.997 0.004 0.000 0 0.996 0 0.000
#> SRR1740064 4 0.0146 0.997 0.004 0.000 0 0.996 0 0.000
#> SRR1740065 4 0.0146 0.997 0.004 0.000 0 0.996 0 0.000
#> SRR1740066 2 0.0000 0.998 0.000 1.000 0 0.000 0 0.000
#> SRR1740067 2 0.0000 0.998 0.000 1.000 0 0.000 0 0.000
#> SRR1740068 2 0.0000 0.998 0.000 1.000 0 0.000 0 0.000
#> SRR1740069 2 0.0000 0.998 0.000 1.000 0 0.000 0 0.000
#> SRR1740070 2 0.0146 0.998 0.000 0.996 0 0.004 0 0.000
#> SRR1740071 2 0.0146 0.998 0.000 0.996 0 0.004 0 0.000
#> SRR1740072 2 0.0146 0.998 0.000 0.996 0 0.004 0 0.000
#> SRR1740073 2 0.0146 0.998 0.000 0.996 0 0.004 0 0.000
#> SRR1740074 3 0.0000 1.000 0.000 0.000 1 0.000 0 0.000
#> SRR1740075 3 0.0000 1.000 0.000 0.000 1 0.000 0 0.000
#> SRR1740076 3 0.0000 1.000 0.000 0.000 1 0.000 0 0.000
#> SRR1740077 3 0.0000 1.000 0.000 0.000 1 0.000 0 0.000
#> SRR1740078 5 0.0000 1.000 0.000 0.000 0 0.000 1 0.000
#> SRR1740079 5 0.0000 1.000 0.000 0.000 0 0.000 1 0.000
#> SRR1740080 5 0.0000 1.000 0.000 0.000 0 0.000 1 0.000
#> SRR1740081 5 0.0000 1.000 0.000 0.000 0 0.000 1 0.000
#> SRR1740082 1 0.0000 1.000 1.000 0.000 0 0.000 0 0.000
#> SRR1740083 1 0.0000 1.000 1.000 0.000 0 0.000 0 0.000
#> SRR1740084 1 0.0000 1.000 1.000 0.000 0 0.000 0 0.000
#> SRR1740085 1 0.0000 1.000 1.000 0.000 0 0.000 0 0.000
#> SRR1740086 6 0.0000 1.000 0.000 0.000 0 0.000 0 1.000
#> SRR1740087 6 0.0000 1.000 0.000 0.000 0 0.000 0 1.000
#> SRR1740088 6 0.0000 1.000 0.000 0.000 0 0.000 0 1.000
#> SRR1740089 6 0.0000 1.000 0.000 0.000 0 0.000 0 1.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.501 0.804 0.837 0.4168 0.584 0.584
#> 3 3 0.834 0.967 0.981 0.4240 0.834 0.716
#> 4 4 1.000 1.000 1.000 0.1909 0.875 0.702
#> 5 5 1.000 0.987 0.989 0.1175 0.917 0.717
#> 6 6 1.000 1.000 1.000 0.0526 0.958 0.802
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] 4 5
There is also optional best \(k\) = 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
#> SRR1740034 1 0.955 0.746 0.624 0.376
#> SRR1740035 1 0.955 0.746 0.624 0.376
#> SRR1740036 1 0.955 0.746 0.624 0.376
#> SRR1740037 1 0.955 0.746 0.624 0.376
#> SRR1740038 2 0.000 1.000 0.000 1.000
#> SRR1740039 2 0.000 1.000 0.000 1.000
#> SRR1740040 2 0.000 1.000 0.000 1.000
#> SRR1740041 2 0.000 1.000 0.000 1.000
#> SRR1740042 2 0.000 1.000 0.000 1.000
#> SRR1740043 2 0.000 1.000 0.000 1.000
#> SRR1740044 2 0.000 1.000 0.000 1.000
#> SRR1740045 2 0.000 1.000 0.000 1.000
#> SRR1740046 1 0.000 0.697 1.000 0.000
#> SRR1740048 1 0.000 0.697 1.000 0.000
#> SRR1740047 1 0.000 0.697 1.000 0.000
#> SRR1740049 1 0.000 0.697 1.000 0.000
#> SRR1740050 1 0.000 0.697 1.000 0.000
#> SRR1740051 1 0.000 0.697 1.000 0.000
#> SRR1740052 1 0.000 0.697 1.000 0.000
#> SRR1740054 1 0.961 0.743 0.616 0.384
#> SRR1740053 1 0.000 0.697 1.000 0.000
#> SRR1740056 1 0.961 0.743 0.616 0.384
#> SRR1740055 1 0.961 0.743 0.616 0.384
#> SRR1740057 1 0.961 0.743 0.616 0.384
#> SRR1740058 1 0.961 0.743 0.616 0.384
#> SRR1740059 1 0.961 0.743 0.616 0.384
#> SRR1740060 1 0.961 0.743 0.616 0.384
#> SRR1740061 1 0.961 0.743 0.616 0.384
#> SRR1740062 1 0.955 0.746 0.624 0.376
#> SRR1740063 1 0.955 0.746 0.624 0.376
#> SRR1740064 1 0.955 0.746 0.624 0.376
#> SRR1740065 1 0.955 0.746 0.624 0.376
#> SRR1740066 2 0.000 1.000 0.000 1.000
#> SRR1740067 2 0.000 1.000 0.000 1.000
#> SRR1740068 2 0.000 1.000 0.000 1.000
#> SRR1740069 2 0.000 1.000 0.000 1.000
#> SRR1740070 2 0.000 1.000 0.000 1.000
#> SRR1740071 2 0.000 1.000 0.000 1.000
#> SRR1740072 2 0.000 1.000 0.000 1.000
#> SRR1740073 2 0.000 1.000 0.000 1.000
#> SRR1740074 1 0.000 0.697 1.000 0.000
#> SRR1740075 1 0.000 0.697 1.000 0.000
#> SRR1740076 1 0.000 0.697 1.000 0.000
#> SRR1740077 1 0.000 0.697 1.000 0.000
#> SRR1740078 1 0.000 0.697 1.000 0.000
#> SRR1740079 1 0.000 0.697 1.000 0.000
#> SRR1740080 1 0.000 0.697 1.000 0.000
#> SRR1740081 1 0.000 0.697 1.000 0.000
#> SRR1740082 1 0.961 0.743 0.616 0.384
#> SRR1740083 1 0.961 0.743 0.616 0.384
#> SRR1740084 1 0.961 0.743 0.616 0.384
#> SRR1740085 1 0.961 0.743 0.616 0.384
#> SRR1740086 1 0.961 0.743 0.616 0.384
#> SRR1740087 1 0.961 0.743 0.616 0.384
#> SRR1740088 1 0.961 0.743 0.616 0.384
#> SRR1740089 1 0.961 0.743 0.616 0.384
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0.000 0.963 1.000 0 0.000
#> SRR1740035 1 0.000 0.963 1.000 0 0.000
#> SRR1740036 1 0.000 0.963 1.000 0 0.000
#> SRR1740037 1 0.000 0.963 1.000 0 0.000
#> SRR1740038 2 0.000 1.000 0.000 1 0.000
#> SRR1740039 2 0.000 1.000 0.000 1 0.000
#> SRR1740040 2 0.000 1.000 0.000 1 0.000
#> SRR1740041 2 0.000 1.000 0.000 1 0.000
#> SRR1740042 2 0.000 1.000 0.000 1 0.000
#> SRR1740043 2 0.000 1.000 0.000 1 0.000
#> SRR1740044 2 0.000 1.000 0.000 1 0.000
#> SRR1740045 2 0.000 1.000 0.000 1 0.000
#> SRR1740046 3 0.000 1.000 0.000 0 1.000
#> SRR1740048 3 0.000 1.000 0.000 0 1.000
#> SRR1740047 3 0.000 1.000 0.000 0 1.000
#> SRR1740049 3 0.000 1.000 0.000 0 1.000
#> SRR1740050 1 0.362 0.878 0.864 0 0.136
#> SRR1740051 1 0.362 0.878 0.864 0 0.136
#> SRR1740052 1 0.362 0.878 0.864 0 0.136
#> SRR1740054 1 0.000 0.963 1.000 0 0.000
#> SRR1740053 1 0.362 0.878 0.864 0 0.136
#> SRR1740056 1 0.000 0.963 1.000 0 0.000
#> SRR1740055 1 0.000 0.963 1.000 0 0.000
#> SRR1740057 1 0.000 0.963 1.000 0 0.000
#> SRR1740058 1 0.000 0.963 1.000 0 0.000
#> SRR1740059 1 0.000 0.963 1.000 0 0.000
#> SRR1740060 1 0.000 0.963 1.000 0 0.000
#> SRR1740061 1 0.000 0.963 1.000 0 0.000
#> SRR1740062 1 0.000 0.963 1.000 0 0.000
#> SRR1740063 1 0.000 0.963 1.000 0 0.000
#> SRR1740064 1 0.000 0.963 1.000 0 0.000
#> SRR1740065 1 0.000 0.963 1.000 0 0.000
#> SRR1740066 2 0.000 1.000 0.000 1 0.000
#> SRR1740067 2 0.000 1.000 0.000 1 0.000
#> SRR1740068 2 0.000 1.000 0.000 1 0.000
#> SRR1740069 2 0.000 1.000 0.000 1 0.000
#> SRR1740070 2 0.000 1.000 0.000 1 0.000
#> SRR1740071 2 0.000 1.000 0.000 1 0.000
#> SRR1740072 2 0.000 1.000 0.000 1 0.000
#> SRR1740073 2 0.000 1.000 0.000 1 0.000
#> SRR1740074 3 0.000 1.000 0.000 0 1.000
#> SRR1740075 3 0.000 1.000 0.000 0 1.000
#> SRR1740076 3 0.000 1.000 0.000 0 1.000
#> SRR1740077 3 0.000 1.000 0.000 0 1.000
#> SRR1740078 1 0.362 0.878 0.864 0 0.136
#> SRR1740079 1 0.362 0.878 0.864 0 0.136
#> SRR1740080 1 0.362 0.878 0.864 0 0.136
#> SRR1740081 1 0.362 0.878 0.864 0 0.136
#> SRR1740082 1 0.000 0.963 1.000 0 0.000
#> SRR1740083 1 0.000 0.963 1.000 0 0.000
#> SRR1740084 1 0.000 0.963 1.000 0 0.000
#> SRR1740085 1 0.000 0.963 1.000 0 0.000
#> SRR1740086 1 0.000 0.963 1.000 0 0.000
#> SRR1740087 1 0.000 0.963 1.000 0 0.000
#> SRR1740088 1 0.000 0.963 1.000 0 0.000
#> SRR1740089 1 0.000 0.963 1.000 0 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 1 0 1 1 0 0 0
#> SRR1740035 1 0 1 1 0 0 0
#> SRR1740036 1 0 1 1 0 0 0
#> SRR1740037 1 0 1 1 0 0 0
#> SRR1740038 2 0 1 0 1 0 0
#> SRR1740039 2 0 1 0 1 0 0
#> SRR1740040 2 0 1 0 1 0 0
#> SRR1740041 2 0 1 0 1 0 0
#> SRR1740042 2 0 1 0 1 0 0
#> SRR1740043 2 0 1 0 1 0 0
#> SRR1740044 2 0 1 0 1 0 0
#> SRR1740045 2 0 1 0 1 0 0
#> SRR1740046 3 0 1 0 0 1 0
#> SRR1740048 3 0 1 0 0 1 0
#> SRR1740047 3 0 1 0 0 1 0
#> SRR1740049 3 0 1 0 0 1 0
#> SRR1740050 4 0 1 0 0 0 1
#> SRR1740051 4 0 1 0 0 0 1
#> SRR1740052 4 0 1 0 0 0 1
#> SRR1740054 1 0 1 1 0 0 0
#> SRR1740053 4 0 1 0 0 0 1
#> SRR1740056 1 0 1 1 0 0 0
#> SRR1740055 1 0 1 1 0 0 0
#> SRR1740057 1 0 1 1 0 0 0
#> SRR1740058 1 0 1 1 0 0 0
#> SRR1740059 1 0 1 1 0 0 0
#> SRR1740060 1 0 1 1 0 0 0
#> SRR1740061 1 0 1 1 0 0 0
#> SRR1740062 1 0 1 1 0 0 0
#> SRR1740063 1 0 1 1 0 0 0
#> SRR1740064 1 0 1 1 0 0 0
#> SRR1740065 1 0 1 1 0 0 0
#> SRR1740066 2 0 1 0 1 0 0
#> SRR1740067 2 0 1 0 1 0 0
#> SRR1740068 2 0 1 0 1 0 0
#> SRR1740069 2 0 1 0 1 0 0
#> SRR1740070 2 0 1 0 1 0 0
#> SRR1740071 2 0 1 0 1 0 0
#> SRR1740072 2 0 1 0 1 0 0
#> SRR1740073 2 0 1 0 1 0 0
#> SRR1740074 3 0 1 0 0 1 0
#> SRR1740075 3 0 1 0 0 1 0
#> SRR1740076 3 0 1 0 0 1 0
#> SRR1740077 3 0 1 0 0 1 0
#> SRR1740078 4 0 1 0 0 0 1
#> SRR1740079 4 0 1 0 0 0 1
#> SRR1740080 4 0 1 0 0 0 1
#> SRR1740081 4 0 1 0 0 0 1
#> SRR1740082 1 0 1 1 0 0 0
#> SRR1740083 1 0 1 1 0 0 0
#> SRR1740084 1 0 1 1 0 0 0
#> SRR1740085 1 0 1 1 0 0 0
#> SRR1740086 1 0 1 1 0 0 0
#> SRR1740087 1 0 1 1 0 0 0
#> SRR1740088 1 0 1 1 0 0 0
#> SRR1740089 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
#> SRR1740034 4 0.000 1.000 0.00 0 0 1.00 0
#> SRR1740035 4 0.000 1.000 0.00 0 0 1.00 0
#> SRR1740036 4 0.000 1.000 0.00 0 0 1.00 0
#> SRR1740037 4 0.000 1.000 0.00 0 0 1.00 0
#> SRR1740038 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740039 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740040 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740041 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740042 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740043 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740044 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740045 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740046 3 0.000 1.000 0.00 0 1 0.00 0
#> SRR1740048 3 0.000 1.000 0.00 0 1 0.00 0
#> SRR1740047 3 0.000 1.000 0.00 0 1 0.00 0
#> SRR1740049 3 0.000 1.000 0.00 0 1 0.00 0
#> SRR1740050 5 0.000 1.000 0.00 0 0 0.00 1
#> SRR1740051 5 0.000 1.000 0.00 0 0 0.00 1
#> SRR1740052 5 0.000 1.000 0.00 0 0 0.00 1
#> SRR1740054 1 0.000 0.955 1.00 0 0 0.00 0
#> SRR1740053 5 0.000 1.000 0.00 0 0 0.00 1
#> SRR1740056 1 0.000 0.955 1.00 0 0 0.00 0
#> SRR1740055 1 0.000 0.955 1.00 0 0 0.00 0
#> SRR1740057 1 0.000 0.955 1.00 0 0 0.00 0
#> SRR1740058 1 0.173 0.954 0.92 0 0 0.08 0
#> SRR1740059 1 0.173 0.954 0.92 0 0 0.08 0
#> SRR1740060 1 0.173 0.954 0.92 0 0 0.08 0
#> SRR1740061 1 0.173 0.954 0.92 0 0 0.08 0
#> SRR1740062 4 0.000 1.000 0.00 0 0 1.00 0
#> SRR1740063 4 0.000 1.000 0.00 0 0 1.00 0
#> SRR1740064 4 0.000 1.000 0.00 0 0 1.00 0
#> SRR1740065 4 0.000 1.000 0.00 0 0 1.00 0
#> SRR1740066 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740067 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740068 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740069 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740070 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740071 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740072 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740073 2 0.000 1.000 0.00 1 0 0.00 0
#> SRR1740074 3 0.000 1.000 0.00 0 1 0.00 0
#> SRR1740075 3 0.000 1.000 0.00 0 1 0.00 0
#> SRR1740076 3 0.000 1.000 0.00 0 1 0.00 0
#> SRR1740077 3 0.000 1.000 0.00 0 1 0.00 0
#> SRR1740078 5 0.000 1.000 0.00 0 0 0.00 1
#> SRR1740079 5 0.000 1.000 0.00 0 0 0.00 1
#> SRR1740080 5 0.000 1.000 0.00 0 0 0.00 1
#> SRR1740081 5 0.000 1.000 0.00 0 0 0.00 1
#> SRR1740082 1 0.000 0.955 1.00 0 0 0.00 0
#> SRR1740083 1 0.000 0.955 1.00 0 0 0.00 0
#> SRR1740084 1 0.000 0.955 1.00 0 0 0.00 0
#> SRR1740085 1 0.000 0.955 1.00 0 0 0.00 0
#> SRR1740086 1 0.173 0.954 0.92 0 0 0.08 0
#> SRR1740087 1 0.173 0.954 0.92 0 0 0.08 0
#> SRR1740088 1 0.173 0.954 0.92 0 0 0.08 0
#> SRR1740089 1 0.173 0.954 0.92 0 0 0.08 0
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0 1 0 0 0 1 0 0
#> SRR1740035 4 0 1 0 0 0 1 0 0
#> SRR1740036 4 0 1 0 0 0 1 0 0
#> SRR1740037 4 0 1 0 0 0 1 0 0
#> SRR1740038 2 0 1 0 1 0 0 0 0
#> SRR1740039 2 0 1 0 1 0 0 0 0
#> SRR1740040 2 0 1 0 1 0 0 0 0
#> SRR1740041 2 0 1 0 1 0 0 0 0
#> SRR1740042 2 0 1 0 1 0 0 0 0
#> SRR1740043 2 0 1 0 1 0 0 0 0
#> SRR1740044 2 0 1 0 1 0 0 0 0
#> SRR1740045 2 0 1 0 1 0 0 0 0
#> SRR1740046 3 0 1 0 0 1 0 0 0
#> SRR1740048 3 0 1 0 0 1 0 0 0
#> SRR1740047 3 0 1 0 0 1 0 0 0
#> SRR1740049 3 0 1 0 0 1 0 0 0
#> SRR1740050 5 0 1 0 0 0 0 1 0
#> SRR1740051 5 0 1 0 0 0 0 1 0
#> SRR1740052 5 0 1 0 0 0 0 1 0
#> SRR1740054 1 0 1 1 0 0 0 0 0
#> SRR1740053 5 0 1 0 0 0 0 1 0
#> SRR1740056 1 0 1 1 0 0 0 0 0
#> SRR1740055 1 0 1 1 0 0 0 0 0
#> SRR1740057 1 0 1 1 0 0 0 0 0
#> SRR1740058 6 0 1 0 0 0 0 0 1
#> SRR1740059 6 0 1 0 0 0 0 0 1
#> SRR1740060 6 0 1 0 0 0 0 0 1
#> SRR1740061 6 0 1 0 0 0 0 0 1
#> SRR1740062 4 0 1 0 0 0 1 0 0
#> SRR1740063 4 0 1 0 0 0 1 0 0
#> SRR1740064 4 0 1 0 0 0 1 0 0
#> SRR1740065 4 0 1 0 0 0 1 0 0
#> SRR1740066 2 0 1 0 1 0 0 0 0
#> SRR1740067 2 0 1 0 1 0 0 0 0
#> SRR1740068 2 0 1 0 1 0 0 0 0
#> SRR1740069 2 0 1 0 1 0 0 0 0
#> SRR1740070 2 0 1 0 1 0 0 0 0
#> SRR1740071 2 0 1 0 1 0 0 0 0
#> SRR1740072 2 0 1 0 1 0 0 0 0
#> SRR1740073 2 0 1 0 1 0 0 0 0
#> SRR1740074 3 0 1 0 0 1 0 0 0
#> SRR1740075 3 0 1 0 0 1 0 0 0
#> SRR1740076 3 0 1 0 0 1 0 0 0
#> SRR1740077 3 0 1 0 0 1 0 0 0
#> SRR1740078 5 0 1 0 0 0 0 1 0
#> SRR1740079 5 0 1 0 0 0 0 1 0
#> SRR1740080 5 0 1 0 0 0 0 1 0
#> SRR1740081 5 0 1 0 0 0 0 1 0
#> SRR1740082 1 0 1 1 0 0 0 0 0
#> SRR1740083 1 0 1 1 0 0 0 0 0
#> SRR1740084 1 0 1 1 0 0 0 0 0
#> SRR1740085 1 0 1 1 0 0 0 0 0
#> SRR1740086 6 0 1 0 0 0 0 0 1
#> SRR1740087 6 0 1 0 0 0 0 0 1
#> SRR1740088 6 0 1 0 0 0 0 0 1
#> SRR1740089 6 0 1 0 0 0 0 0 1
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 16000 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.2501 0.751 0.751
#> 3 3 1.000 0.986 0.992 1.3351 0.668 0.557
#> 4 4 0.794 0.885 0.901 0.1982 0.875 0.702
#> 5 5 0.779 0.918 0.834 0.0753 0.917 0.717
#> 6 6 0.824 0.908 0.855 0.0493 1.000 1.000
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 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
#> SRR1740034 1 0 1 1 0
#> SRR1740035 1 0 1 1 0
#> SRR1740036 1 0 1 1 0
#> SRR1740037 1 0 1 1 0
#> SRR1740038 1 0 1 1 0
#> SRR1740039 1 0 1 1 0
#> SRR1740040 1 0 1 1 0
#> SRR1740041 1 0 1 1 0
#> SRR1740042 1 0 1 1 0
#> SRR1740043 1 0 1 1 0
#> SRR1740044 1 0 1 1 0
#> SRR1740045 1 0 1 1 0
#> SRR1740046 2 0 1 0 1
#> SRR1740048 2 0 1 0 1
#> SRR1740047 2 0 1 0 1
#> SRR1740049 2 0 1 0 1
#> SRR1740050 1 0 1 1 0
#> SRR1740051 1 0 1 1 0
#> SRR1740052 1 0 1 1 0
#> SRR1740054 1 0 1 1 0
#> SRR1740053 1 0 1 1 0
#> SRR1740056 1 0 1 1 0
#> SRR1740055 1 0 1 1 0
#> SRR1740057 1 0 1 1 0
#> SRR1740058 1 0 1 1 0
#> SRR1740059 1 0 1 1 0
#> SRR1740060 1 0 1 1 0
#> SRR1740061 1 0 1 1 0
#> SRR1740062 1 0 1 1 0
#> SRR1740063 1 0 1 1 0
#> SRR1740064 1 0 1 1 0
#> SRR1740065 1 0 1 1 0
#> SRR1740066 1 0 1 1 0
#> SRR1740067 1 0 1 1 0
#> SRR1740068 1 0 1 1 0
#> SRR1740069 1 0 1 1 0
#> SRR1740070 1 0 1 1 0
#> SRR1740071 1 0 1 1 0
#> SRR1740072 1 0 1 1 0
#> SRR1740073 1 0 1 1 0
#> SRR1740074 2 0 1 0 1
#> SRR1740075 2 0 1 0 1
#> SRR1740076 2 0 1 0 1
#> SRR1740077 2 0 1 0 1
#> SRR1740078 1 0 1 1 0
#> SRR1740079 1 0 1 1 0
#> SRR1740080 1 0 1 1 0
#> SRR1740081 1 0 1 1 0
#> SRR1740082 1 0 1 1 0
#> SRR1740083 1 0 1 1 0
#> SRR1740084 1 0 1 1 0
#> SRR1740085 1 0 1 1 0
#> SRR1740086 1 0 1 1 0
#> SRR1740087 1 0 1 1 0
#> SRR1740088 1 0 1 1 0
#> SRR1740089 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1740034 1 0.0000 0.986 1.000 0.000 0
#> SRR1740035 1 0.0000 0.986 1.000 0.000 0
#> SRR1740036 1 0.0000 0.986 1.000 0.000 0
#> SRR1740037 1 0.0000 0.986 1.000 0.000 0
#> SRR1740038 2 0.0237 1.000 0.004 0.996 0
#> SRR1740039 2 0.0237 1.000 0.004 0.996 0
#> SRR1740040 2 0.0237 1.000 0.004 0.996 0
#> SRR1740041 2 0.0237 1.000 0.004 0.996 0
#> SRR1740042 2 0.0237 1.000 0.004 0.996 0
#> SRR1740043 2 0.0237 1.000 0.004 0.996 0
#> SRR1740044 2 0.0237 1.000 0.004 0.996 0
#> SRR1740045 2 0.0237 1.000 0.004 0.996 0
#> SRR1740046 3 0.0000 1.000 0.000 0.000 1
#> SRR1740048 3 0.0000 1.000 0.000 0.000 1
#> SRR1740047 3 0.0000 1.000 0.000 0.000 1
#> SRR1740049 3 0.0000 1.000 0.000 0.000 1
#> SRR1740050 1 0.0000 0.986 1.000 0.000 0
#> SRR1740051 1 0.0000 0.986 1.000 0.000 0
#> SRR1740052 1 0.0000 0.986 1.000 0.000 0
#> SRR1740054 1 0.1163 0.969 0.972 0.028 0
#> SRR1740053 1 0.0000 0.986 1.000 0.000 0
#> SRR1740056 1 0.1031 0.972 0.976 0.024 0
#> SRR1740055 1 0.4605 0.755 0.796 0.204 0
#> SRR1740057 1 0.1031 0.972 0.976 0.024 0
#> SRR1740058 1 0.0000 0.986 1.000 0.000 0
#> SRR1740059 1 0.0000 0.986 1.000 0.000 0
#> SRR1740060 1 0.0000 0.986 1.000 0.000 0
#> SRR1740061 1 0.0000 0.986 1.000 0.000 0
#> SRR1740062 1 0.0000 0.986 1.000 0.000 0
#> SRR1740063 1 0.0000 0.986 1.000 0.000 0
#> SRR1740064 1 0.0000 0.986 1.000 0.000 0
#> SRR1740065 1 0.0000 0.986 1.000 0.000 0
#> SRR1740066 2 0.0237 1.000 0.004 0.996 0
#> SRR1740067 2 0.0237 1.000 0.004 0.996 0
#> SRR1740068 2 0.0237 1.000 0.004 0.996 0
#> SRR1740069 2 0.0237 1.000 0.004 0.996 0
#> SRR1740070 2 0.0237 1.000 0.004 0.996 0
#> SRR1740071 2 0.0237 1.000 0.004 0.996 0
#> SRR1740072 2 0.0237 1.000 0.004 0.996 0
#> SRR1740073 2 0.0237 1.000 0.004 0.996 0
#> SRR1740074 3 0.0000 1.000 0.000 0.000 1
#> SRR1740075 3 0.0000 1.000 0.000 0.000 1
#> SRR1740076 3 0.0000 1.000 0.000 0.000 1
#> SRR1740077 3 0.0000 1.000 0.000 0.000 1
#> SRR1740078 1 0.0000 0.986 1.000 0.000 0
#> SRR1740079 1 0.0000 0.986 1.000 0.000 0
#> SRR1740080 1 0.0000 0.986 1.000 0.000 0
#> SRR1740081 1 0.0000 0.986 1.000 0.000 0
#> SRR1740082 1 0.1289 0.966 0.968 0.032 0
#> SRR1740083 1 0.1289 0.966 0.968 0.032 0
#> SRR1740084 1 0.1031 0.972 0.976 0.024 0
#> SRR1740085 1 0.1031 0.972 0.976 0.024 0
#> SRR1740086 1 0.0000 0.986 1.000 0.000 0
#> SRR1740087 1 0.0000 0.986 1.000 0.000 0
#> SRR1740088 1 0.0000 0.986 1.000 0.000 0
#> SRR1740089 1 0.0000 0.986 1.000 0.000 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1740034 1 0.0336 0.7847 0.992 0.000 0 0.008
#> SRR1740035 1 0.0469 0.7861 0.988 0.000 0 0.012
#> SRR1740036 1 0.0469 0.7824 0.988 0.000 0 0.012
#> SRR1740037 1 0.0336 0.7847 0.992 0.000 0 0.008
#> SRR1740038 2 0.0779 0.9839 0.004 0.980 0 0.016
#> SRR1740039 2 0.0779 0.9839 0.004 0.980 0 0.016
#> SRR1740040 2 0.0895 0.9824 0.004 0.976 0 0.020
#> SRR1740041 2 0.1042 0.9801 0.008 0.972 0 0.020
#> SRR1740042 2 0.0469 0.9848 0.000 0.988 0 0.012
#> SRR1740043 2 0.0469 0.9848 0.000 0.988 0 0.012
#> SRR1740044 2 0.0469 0.9848 0.000 0.988 0 0.012
#> SRR1740045 2 0.0469 0.9848 0.000 0.988 0 0.012
#> SRR1740046 3 0.0000 1.0000 0.000 0.000 1 0.000
#> SRR1740048 3 0.0000 1.0000 0.000 0.000 1 0.000
#> SRR1740047 3 0.0000 1.0000 0.000 0.000 1 0.000
#> SRR1740049 3 0.0000 1.0000 0.000 0.000 1 0.000
#> SRR1740050 4 0.3428 0.9962 0.144 0.012 0 0.844
#> SRR1740051 4 0.3479 0.9948 0.148 0.012 0 0.840
#> SRR1740052 4 0.3428 0.9962 0.144 0.012 0 0.844
#> SRR1740054 1 0.4961 0.3390 0.552 0.000 0 0.448
#> SRR1740053 4 0.3479 0.9913 0.148 0.012 0 0.840
#> SRR1740056 1 0.4643 0.6211 0.656 0.000 0 0.344
#> SRR1740055 1 0.7771 0.0545 0.420 0.252 0 0.328
#> SRR1740057 1 0.4277 0.7342 0.720 0.000 0 0.280
#> SRR1740058 1 0.3801 0.8048 0.780 0.000 0 0.220
#> SRR1740059 1 0.3610 0.8201 0.800 0.000 0 0.200
#> SRR1740060 1 0.3610 0.8198 0.800 0.000 0 0.200
#> SRR1740061 1 0.3649 0.8177 0.796 0.000 0 0.204
#> SRR1740062 1 0.0592 0.7799 0.984 0.000 0 0.016
#> SRR1740063 1 0.0592 0.7799 0.984 0.000 0 0.016
#> SRR1740064 1 0.0592 0.7799 0.984 0.000 0 0.016
#> SRR1740065 1 0.0592 0.7799 0.984 0.000 0 0.016
#> SRR1740066 2 0.0657 0.9843 0.004 0.984 0 0.012
#> SRR1740067 2 0.0779 0.9839 0.004 0.980 0 0.016
#> SRR1740068 2 0.1042 0.9801 0.008 0.972 0 0.020
#> SRR1740069 2 0.0779 0.9839 0.004 0.980 0 0.016
#> SRR1740070 2 0.0469 0.9848 0.000 0.988 0 0.012
#> SRR1740071 2 0.0592 0.9844 0.000 0.984 0 0.016
#> SRR1740072 2 0.0469 0.9848 0.000 0.988 0 0.012
#> SRR1740073 2 0.0469 0.9848 0.000 0.988 0 0.012
#> SRR1740074 3 0.0000 1.0000 0.000 0.000 1 0.000
#> SRR1740075 3 0.0000 1.0000 0.000 0.000 1 0.000
#> SRR1740076 3 0.0000 1.0000 0.000 0.000 1 0.000
#> SRR1740077 3 0.0000 1.0000 0.000 0.000 1 0.000
#> SRR1740078 4 0.3479 0.9948 0.148 0.012 0 0.840
#> SRR1740079 4 0.3479 0.9948 0.148 0.012 0 0.840
#> SRR1740080 4 0.3428 0.9962 0.144 0.012 0 0.844
#> SRR1740081 4 0.3428 0.9962 0.144 0.012 0 0.844
#> SRR1740082 1 0.3306 0.8250 0.840 0.004 0 0.156
#> SRR1740083 1 0.3157 0.8240 0.852 0.004 0 0.144
#> SRR1740084 1 0.3266 0.8263 0.832 0.000 0 0.168
#> SRR1740085 1 0.3266 0.8263 0.832 0.000 0 0.168
#> SRR1740086 1 0.3688 0.8175 0.792 0.000 0 0.208
#> SRR1740087 1 0.3569 0.8227 0.804 0.000 0 0.196
#> SRR1740088 1 0.3610 0.8211 0.800 0.000 0 0.200
#> SRR1740089 1 0.3528 0.8213 0.808 0.000 0 0.192
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1740034 4 0.5184 0.959 0.456 0.004 0 0.508 0.032
#> SRR1740035 4 0.5187 0.953 0.460 0.004 0 0.504 0.032
#> SRR1740036 4 0.5181 0.963 0.452 0.004 0 0.512 0.032
#> SRR1740037 4 0.5181 0.963 0.452 0.004 0 0.512 0.032
#> SRR1740038 2 0.3005 0.923 0.008 0.856 0 0.124 0.012
#> SRR1740039 2 0.2681 0.925 0.004 0.876 0 0.108 0.012
#> SRR1740040 2 0.3543 0.909 0.012 0.828 0 0.136 0.024
#> SRR1740041 2 0.3053 0.921 0.008 0.852 0 0.128 0.012
#> SRR1740042 2 0.1074 0.920 0.016 0.968 0 0.012 0.004
#> SRR1740043 2 0.0798 0.922 0.016 0.976 0 0.008 0.000
#> SRR1740044 2 0.1074 0.920 0.016 0.968 0 0.012 0.004
#> SRR1740045 2 0.0566 0.924 0.012 0.984 0 0.004 0.000
#> SRR1740046 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740048 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740047 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740049 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740050 5 0.2852 0.996 0.172 0.000 0 0.000 0.828
#> SRR1740051 5 0.3048 0.994 0.176 0.000 0 0.004 0.820
#> SRR1740052 5 0.3048 0.994 0.176 0.000 0 0.004 0.820
#> SRR1740054 1 0.4382 0.694 0.760 0.004 0 0.060 0.176
#> SRR1740053 5 0.3086 0.991 0.180 0.000 0 0.004 0.816
#> SRR1740056 1 0.3547 0.791 0.836 0.004 0 0.060 0.100
#> SRR1740055 1 0.6381 0.499 0.640 0.144 0 0.064 0.152
#> SRR1740057 1 0.3504 0.805 0.840 0.004 0 0.064 0.092
#> SRR1740058 1 0.1697 0.859 0.932 0.000 0 0.008 0.060
#> SRR1740059 1 0.1626 0.867 0.940 0.000 0 0.016 0.044
#> SRR1740060 1 0.1579 0.861 0.944 0.000 0 0.024 0.032
#> SRR1740061 1 0.1661 0.862 0.940 0.000 0 0.024 0.036
#> SRR1740062 4 0.5196 0.963 0.428 0.008 0 0.536 0.028
#> SRR1740063 4 0.5002 0.961 0.424 0.004 0 0.548 0.024
#> SRR1740064 4 0.5078 0.963 0.424 0.004 0 0.544 0.028
#> SRR1740065 4 0.5190 0.960 0.424 0.008 0 0.540 0.028
#> SRR1740066 2 0.3005 0.923 0.008 0.856 0 0.124 0.012
#> SRR1740067 2 0.2957 0.923 0.008 0.860 0 0.120 0.012
#> SRR1740068 2 0.2957 0.923 0.008 0.860 0 0.120 0.012
#> SRR1740069 2 0.3059 0.922 0.008 0.856 0 0.120 0.016
#> SRR1740070 2 0.0579 0.924 0.008 0.984 0 0.008 0.000
#> SRR1740071 2 0.0324 0.925 0.004 0.992 0 0.000 0.004
#> SRR1740072 2 0.1299 0.917 0.012 0.960 0 0.020 0.008
#> SRR1740073 2 0.1267 0.917 0.012 0.960 0 0.024 0.004
#> SRR1740074 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740075 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740076 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740077 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1740078 5 0.2852 0.996 0.172 0.000 0 0.000 0.828
#> SRR1740079 5 0.2891 0.995 0.176 0.000 0 0.000 0.824
#> SRR1740080 5 0.2852 0.996 0.172 0.000 0 0.000 0.828
#> SRR1740081 5 0.2852 0.996 0.172 0.000 0 0.000 0.828
#> SRR1740082 1 0.1891 0.827 0.936 0.016 0 0.032 0.016
#> SRR1740083 1 0.1869 0.814 0.936 0.012 0 0.036 0.016
#> SRR1740084 1 0.1186 0.840 0.964 0.008 0 0.020 0.008
#> SRR1740085 1 0.1673 0.847 0.944 0.008 0 0.032 0.016
#> SRR1740086 1 0.1041 0.867 0.964 0.000 0 0.004 0.032
#> SRR1740087 1 0.1485 0.856 0.948 0.000 0 0.032 0.020
#> SRR1740088 1 0.1041 0.865 0.964 0.000 0 0.004 0.032
#> SRR1740089 1 0.1168 0.867 0.960 0.000 0 0.008 0.032
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1740034 4 0.3810 0.957 0.176 0.008 0 0.780 0.016 NA
#> SRR1740035 4 0.3610 0.952 0.176 0.004 0 0.788 0.012 NA
#> SRR1740036 4 0.3325 0.973 0.152 0.008 0 0.816 0.016 NA
#> SRR1740037 4 0.3532 0.971 0.164 0.012 0 0.800 0.016 NA
#> SRR1740038 2 0.0881 0.843 0.012 0.972 0 0.000 0.008 NA
#> SRR1740039 2 0.0551 0.847 0.004 0.984 0 0.004 0.008 NA
#> SRR1740040 2 0.1604 0.830 0.016 0.944 0 0.008 0.008 NA
#> SRR1740041 2 0.0798 0.844 0.012 0.976 0 0.004 0.004 NA
#> SRR1740042 2 0.3897 0.847 0.016 0.712 0 0.000 0.008 NA
#> SRR1740043 2 0.3897 0.847 0.016 0.712 0 0.000 0.008 NA
#> SRR1740044 2 0.4013 0.847 0.016 0.712 0 0.004 0.008 NA
#> SRR1740045 2 0.3795 0.849 0.012 0.724 0 0.004 0.004 NA
#> SRR1740046 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 NA
#> SRR1740048 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 NA
#> SRR1740047 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 NA
#> SRR1740049 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 NA
#> SRR1740050 5 0.2145 0.990 0.076 0.004 0 0.012 0.904 NA
#> SRR1740051 5 0.1843 0.988 0.080 0.004 0 0.004 0.912 NA
#> SRR1740052 5 0.2009 0.984 0.084 0.004 0 0.000 0.904 NA
#> SRR1740054 1 0.4048 0.798 0.788 0.004 0 0.016 0.104 NA
#> SRR1740053 5 0.2062 0.980 0.088 0.004 0 0.000 0.900 NA
#> SRR1740056 1 0.2978 0.863 0.868 0.004 0 0.016 0.060 NA
#> SRR1740055 1 0.6740 0.466 0.536 0.140 0 0.012 0.084 NA
#> SRR1740057 1 0.3383 0.862 0.840 0.000 0 0.032 0.052 NA
#> SRR1740058 1 0.1059 0.904 0.964 0.000 0 0.016 0.016 NA
#> SRR1740059 1 0.0622 0.904 0.980 0.000 0 0.012 0.008 NA
#> SRR1740060 1 0.0820 0.902 0.972 0.000 0 0.016 0.012 NA
#> SRR1740061 1 0.1059 0.901 0.964 0.000 0 0.016 0.016 NA
#> SRR1740062 4 0.3232 0.971 0.140 0.020 0 0.824 0.016 NA
#> SRR1740063 4 0.3275 0.974 0.148 0.012 0 0.820 0.016 NA
#> SRR1740064 4 0.3327 0.973 0.144 0.016 0 0.820 0.016 NA
#> SRR1740065 4 0.3192 0.968 0.136 0.020 0 0.828 0.016 NA
#> SRR1740066 2 0.0810 0.845 0.008 0.976 0 0.004 0.008 NA
#> SRR1740067 2 0.0924 0.843 0.008 0.972 0 0.008 0.004 NA
#> SRR1740068 2 0.0748 0.843 0.016 0.976 0 0.004 0.000 NA
#> SRR1740069 2 0.1026 0.841 0.012 0.968 0 0.008 0.004 NA
#> SRR1740070 2 0.3875 0.848 0.016 0.716 0 0.000 0.008 NA
#> SRR1740071 2 0.3875 0.848 0.016 0.716 0 0.000 0.008 NA
#> SRR1740072 2 0.4119 0.838 0.016 0.692 0 0.004 0.008 NA
#> SRR1740073 2 0.4205 0.838 0.016 0.692 0 0.008 0.008 NA
#> SRR1740074 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 NA
#> SRR1740075 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 NA
#> SRR1740076 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 NA
#> SRR1740077 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 NA
#> SRR1740078 5 0.2089 0.988 0.072 0.004 0 0.012 0.908 NA
#> SRR1740079 5 0.2257 0.990 0.076 0.004 0 0.012 0.900 NA
#> SRR1740080 5 0.2157 0.989 0.076 0.004 0 0.008 0.904 NA
#> SRR1740081 5 0.2145 0.990 0.076 0.004 0 0.012 0.904 NA
#> SRR1740082 1 0.2123 0.886 0.908 0.008 0 0.020 0.000 NA
#> SRR1740083 1 0.2307 0.881 0.900 0.012 0 0.024 0.000 NA
#> SRR1740084 1 0.2728 0.878 0.876 0.004 0 0.024 0.012 NA
#> SRR1740085 1 0.2908 0.873 0.864 0.004 0 0.028 0.012 NA
#> SRR1740086 1 0.0551 0.905 0.984 0.000 0 0.008 0.004 NA
#> SRR1740087 1 0.1007 0.901 0.968 0.004 0 0.016 0.004 NA
#> SRR1740088 1 0.0551 0.906 0.984 0.000 0 0.004 0.008 NA
#> SRR1740089 1 0.0881 0.906 0.972 0.000 0 0.008 0.008 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
sessionInfo()
#> R version 3.6.0 (2019-04-26)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: CentOS Linux 7 (Core)
#>
#> Matrix products: default
#> BLAS: /usr/lib64/libblas.so.3.4.2
#> LAPACK: /usr/lib64/liblapack.so.3.4.2
#>
#> locale:
#> [1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8
#> [4] LC_COLLATE=en_GB.UTF-8 LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
#> [7] LC_PAPER=en_GB.UTF-8 LC_NAME=C LC_ADDRESS=C
#> [10] LC_TELEPHONE=C LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] grid stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] genefilter_1.66.0 ComplexHeatmap_2.3.1 markdown_1.1 knitr_1.26
#> [5] GetoptLong_0.1.7 cola_1.3.2
#>
#> loaded via a namespace (and not attached):
#> [1] circlize_0.4.8 shape_1.4.4 xfun_0.11 slam_0.1-46
#> [5] lattice_0.20-38 splines_3.6.0 colorspace_1.4-1 vctrs_0.2.0
#> [9] stats4_3.6.0 blob_1.2.0 XML_3.98-1.20 survival_2.44-1.1
#> [13] rlang_0.4.2 pillar_1.4.2 DBI_1.0.0 BiocGenerics_0.30.0
#> [17] bit64_0.9-7 RColorBrewer_1.1-2 matrixStats_0.55.0 stringr_1.4.0
#> [21] GlobalOptions_0.1.1 evaluate_0.14 memoise_1.1.0 Biobase_2.44.0
#> [25] IRanges_2.18.3 parallel_3.6.0 AnnotationDbi_1.46.1 highr_0.8
#> [29] Rcpp_1.0.3 xtable_1.8-4 backports_1.1.5 S4Vectors_0.22.1
#> [33] annotate_1.62.0 skmeans_0.2-11 bit_1.1-14 microbenchmark_1.4-7
#> [37] brew_1.0-6 impute_1.58.0 rjson_0.2.20 png_0.1-7
#> [41] digest_0.6.23 stringi_1.4.3 polyclip_1.10-0 clue_0.3-57
#> [45] tools_3.6.0 bitops_1.0-6 magrittr_1.5 eulerr_6.0.0
#> [49] RCurl_1.95-4.12 RSQLite_2.1.4 tibble_2.1.3 cluster_2.1.0
#> [53] crayon_1.3.4 pkgconfig_2.0.3 zeallot_0.1.0 Matrix_1.2-17
#> [57] xml2_1.2.2 httr_1.4.1 R6_2.4.1 mclust_5.4.5
#> [61] compiler_3.6.0