Date: 2019-12-25 23:30:11 CET, cola version: 1.3.2
Document is loading...
All available functions which can be applied to this res_list
object:
res_list
#> A 'ConsensusPartitionList' object with 24 methods.
#> On a matrix with 14939 rows and 54 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] 14939 54
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 | 0.935 | 0.973 | ** | 5 |
SD:NMF | 6 | 1.000 | 0.977 | 0.990 | ** | 3,5 |
CV:hclust | 5 | 1.000 | 1.000 | 1.000 | ** | 4 |
CV:skmeans | 6 | 1.000 | 0.968 | 0.978 | ** | 2,4,5 |
CV:mclust | 6 | 1.000 | 1.000 | 1.000 | ** | 4,5 |
CV:NMF | 6 | 1.000 | 0.996 | 0.996 | ** | 3,4,5 |
MAD:mclust | 5 | 1.000 | 1.000 | 1.000 | ** | |
MAD:NMF | 6 | 1.000 | 0.976 | 0.991 | ** | 5 |
ATC:pam | 6 | 1.000 | 0.965 | 0.987 | ** | 2,3 |
CV:pam | 6 | 0.970 | 0.924 | 0.956 | ** | 2,3,4,5 |
SD:pam | 6 | 0.956 | 0.934 | 0.909 | ** | 3,4,5 |
MAD:pam | 6 | 0.956 | 0.969 | 0.959 | ** | 2,3,5 |
SD:skmeans | 6 | 0.954 | 0.986 | 0.968 | ** | 3,4,5 |
MAD:skmeans | 6 | 0.954 | 0.977 | 0.951 | ** | 2,4,5 |
ATC:kmeans | 3 | 0.948 | 0.969 | 0.981 | * | |
SD:mclust | 6 | 0.946 | 0.933 | 0.909 | * | 4,5 |
ATC:mclust | 6 | 0.929 | 0.903 | 0.905 | * | 3 |
MAD:hclust | 5 | 0.928 | 0.885 | 0.933 | * | |
ATC:skmeans | 6 | 0.917 | 0.948 | 0.931 | * | 3,4,5 |
ATC:NMF | 6 | 0.911 | 0.894 | 0.911 | * | 2,3 |
ATC:hclust | 3 | 0.908 | 0.919 | 0.963 | * | |
SD:kmeans | 5 | 0.823 | 0.922 | 0.850 | ||
MAD:kmeans | 2 | 0.703 | 0.931 | 0.943 | ||
CV:kmeans | 4 | 0.589 | 0.781 | 0.714 |
**: 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.813 0.890 0.956 0.502 0.497 0.497
#> CV:NMF 2 0.720 0.903 0.953 0.489 0.497 0.497
#> MAD:NMF 2 0.888 0.930 0.972 0.502 0.497 0.497
#> ATC:NMF 2 1.000 0.996 0.998 0.285 0.717 0.717
#> SD:skmeans 2 0.829 0.961 0.980 0.501 0.502 0.502
#> CV:skmeans 2 0.925 0.954 0.982 0.504 0.497 0.497
#> MAD:skmeans 2 1.000 0.994 0.997 0.499 0.502 0.502
#> ATC:skmeans 2 0.885 0.920 0.968 0.509 0.491 0.491
#> SD:mclust 2 0.279 0.692 0.820 0.433 0.525 0.525
#> CV:mclust 2 0.249 0.299 0.587 0.468 0.669 0.669
#> MAD:mclust 2 0.256 0.479 0.700 0.419 0.669 0.669
#> ATC:mclust 2 0.762 0.948 0.944 0.473 0.525 0.525
#> SD:kmeans 2 0.442 0.764 0.876 0.465 0.491 0.491
#> CV:kmeans 2 0.466 0.722 0.859 0.417 0.516 0.516
#> MAD:kmeans 2 0.703 0.931 0.943 0.490 0.502 0.502
#> ATC:kmeans 2 0.688 0.826 0.920 0.487 0.516 0.516
#> SD:pam 2 0.485 0.839 0.901 0.460 0.516 0.516
#> CV:pam 2 1.000 0.957 0.984 0.351 0.648 0.648
#> MAD:pam 2 0.918 0.909 0.963 0.500 0.493 0.493
#> ATC:pam 2 1.000 0.993 0.997 0.463 0.535 0.535
#> SD:hclust 2 0.551 0.877 0.930 0.237 0.799 0.799
#> CV:hclust 2 0.456 0.587 0.843 0.431 0.508 0.508
#> MAD:hclust 2 0.438 0.859 0.912 0.256 0.799 0.799
#> ATC:hclust 2 0.860 0.926 0.964 0.331 0.628 0.628
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 0.911 0.912 0.963 0.293 0.825 0.656
#> CV:NMF 3 0.998 0.961 0.976 0.289 0.843 0.695
#> MAD:NMF 3 0.750 0.857 0.916 0.300 0.808 0.629
#> ATC:NMF 3 0.935 0.907 0.953 1.131 0.588 0.460
#> SD:skmeans 3 1.000 0.987 0.986 0.300 0.846 0.694
#> CV:skmeans 3 0.867 0.955 0.974 0.282 0.724 0.507
#> MAD:skmeans 3 0.846 0.979 0.979 0.303 0.846 0.694
#> ATC:skmeans 3 0.946 0.908 0.963 0.246 0.846 0.694
#> SD:mclust 3 0.663 0.800 0.825 0.465 0.669 0.458
#> CV:mclust 3 0.748 0.812 0.907 0.308 0.431 0.315
#> MAD:mclust 3 0.426 0.657 0.752 0.483 0.786 0.681
#> ATC:mclust 3 1.000 0.985 0.987 0.375 0.671 0.452
#> SD:kmeans 3 0.493 0.776 0.802 0.353 0.752 0.544
#> CV:kmeans 3 0.504 0.706 0.793 0.467 0.693 0.475
#> MAD:kmeans 3 0.499 0.689 0.721 0.294 0.862 0.724
#> ATC:kmeans 3 0.948 0.969 0.981 0.272 0.761 0.578
#> SD:pam 3 1.000 0.980 0.991 0.359 0.818 0.661
#> CV:pam 3 1.000 0.981 0.992 0.744 0.720 0.573
#> MAD:pam 3 0.933 0.923 0.967 0.283 0.823 0.654
#> ATC:pam 3 1.000 0.983 0.994 0.250 0.846 0.722
#> SD:hclust 3 0.402 0.764 0.780 1.131 0.716 0.644
#> CV:hclust 3 0.786 0.963 0.974 0.487 0.702 0.483
#> MAD:hclust 3 0.372 0.695 0.813 1.133 0.632 0.539
#> ATC:hclust 3 0.908 0.919 0.963 0.930 0.715 0.546
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.780 0.825 0.854 0.141 0.931 0.801
#> CV:NMF 4 1.000 0.964 0.986 0.168 0.847 0.613
#> MAD:NMF 4 0.742 0.696 0.771 0.135 0.860 0.622
#> ATC:NMF 4 0.780 0.857 0.922 0.194 0.823 0.579
#> SD:skmeans 4 1.000 0.984 0.974 0.110 0.931 0.801
#> CV:skmeans 4 1.000 0.966 0.981 0.138 0.889 0.692
#> MAD:skmeans 4 1.000 0.990 0.980 0.110 0.931 0.801
#> ATC:skmeans 4 1.000 0.979 0.985 0.163 0.873 0.662
#> SD:mclust 4 1.000 0.984 0.985 0.139 0.915 0.767
#> CV:mclust 4 1.000 0.956 0.984 0.193 0.839 0.619
#> MAD:mclust 4 0.849 0.965 0.968 0.165 0.823 0.612
#> ATC:mclust 4 0.737 0.825 0.851 0.102 0.748 0.425
#> SD:kmeans 4 0.640 0.650 0.705 0.147 0.822 0.538
#> CV:kmeans 4 0.589 0.781 0.714 0.171 0.909 0.744
#> MAD:kmeans 4 0.604 0.849 0.764 0.139 0.915 0.767
#> ATC:kmeans 4 0.681 0.636 0.787 0.150 0.814 0.557
#> SD:pam 4 1.000 0.969 0.987 0.162 0.875 0.679
#> CV:pam 4 1.000 0.972 0.979 0.207 0.843 0.609
#> MAD:pam 4 0.826 0.929 0.947 0.138 0.904 0.738
#> ATC:pam 4 0.702 0.654 0.811 0.212 0.834 0.614
#> SD:hclust 4 0.810 0.913 0.958 0.346 0.800 0.611
#> CV:hclust 4 1.000 0.999 0.997 0.125 0.931 0.801
#> MAD:hclust 4 0.661 0.608 0.752 0.257 0.850 0.693
#> ATC:hclust 4 0.749 0.787 0.816 0.122 1.000 1.000
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 1.000 0.992 0.996 0.1002 0.908 0.669
#> CV:NMF 5 1.000 0.988 0.995 0.1068 0.897 0.625
#> MAD:NMF 5 1.000 0.998 0.999 0.0986 0.891 0.605
#> ATC:NMF 5 0.868 0.883 0.893 0.0989 0.891 0.615
#> SD:skmeans 5 1.000 1.000 1.000 0.1249 0.908 0.669
#> CV:skmeans 5 1.000 0.984 0.993 0.1078 0.897 0.625
#> MAD:skmeans 5 1.000 1.000 0.999 0.1258 0.908 0.669
#> ATC:skmeans 5 0.902 0.937 0.969 0.0632 0.945 0.791
#> SD:mclust 5 1.000 1.000 1.000 0.1260 0.908 0.669
#> CV:mclust 5 1.000 0.978 0.990 0.1142 0.923 0.707
#> MAD:mclust 5 1.000 1.000 1.000 0.1239 0.908 0.669
#> ATC:mclust 5 0.805 0.852 0.916 0.0928 0.910 0.690
#> SD:kmeans 5 0.823 0.922 0.850 0.0819 0.891 0.597
#> CV:kmeans 5 0.895 0.948 0.867 0.0922 0.901 0.645
#> MAD:kmeans 5 0.772 0.905 0.813 0.0813 0.908 0.669
#> ATC:kmeans 5 0.683 0.686 0.788 0.0837 0.881 0.604
#> SD:pam 5 1.000 1.000 1.000 0.1187 0.908 0.669
#> CV:pam 5 1.000 0.990 0.995 0.1023 0.923 0.707
#> MAD:pam 5 1.000 1.000 1.000 0.1152 0.908 0.669
#> ATC:pam 5 0.858 0.714 0.857 0.1078 0.904 0.667
#> SD:hclust 5 1.000 0.963 0.985 0.1532 0.893 0.660
#> CV:hclust 5 1.000 1.000 1.000 0.0419 0.971 0.895
#> MAD:hclust 5 0.928 0.885 0.933 0.1271 0.809 0.520
#> ATC:hclust 5 0.854 0.842 0.854 0.0875 0.881 0.651
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 1.000 0.977 0.990 0.0194 0.986 0.925
#> CV:NMF 6 1.000 0.996 0.996 0.0152 0.986 0.925
#> MAD:NMF 6 1.000 0.976 0.991 0.0198 0.986 0.925
#> ATC:NMF 6 0.911 0.894 0.911 0.0375 0.964 0.812
#> SD:skmeans 6 0.954 0.986 0.968 0.0300 0.975 0.865
#> CV:skmeans 6 1.000 0.968 0.978 0.0203 0.986 0.925
#> MAD:skmeans 6 0.954 0.977 0.951 0.0299 0.975 0.865
#> ATC:skmeans 6 0.917 0.948 0.931 0.0491 0.947 0.756
#> SD:mclust 6 0.946 0.933 0.909 0.0271 0.975 0.865
#> CV:mclust 6 1.000 1.000 1.000 0.0159 0.987 0.932
#> MAD:mclust 6 0.959 0.904 0.907 0.0266 1.000 1.000
#> ATC:mclust 6 0.929 0.903 0.905 0.0611 0.935 0.704
#> SD:kmeans 6 0.885 0.882 0.843 0.0482 1.000 1.000
#> CV:kmeans 6 0.860 0.906 0.872 0.0404 1.000 1.000
#> MAD:kmeans 6 0.836 0.866 0.837 0.0473 1.000 1.000
#> ATC:kmeans 6 0.769 0.792 0.798 0.0572 0.943 0.730
#> SD:pam 6 0.956 0.934 0.909 0.0282 0.976 0.869
#> CV:pam 6 0.970 0.924 0.956 0.0227 0.969 0.834
#> MAD:pam 6 0.956 0.969 0.959 0.0293 0.976 0.869
#> ATC:pam 6 1.000 0.965 0.987 0.0760 0.924 0.661
#> SD:hclust 6 1.000 0.935 0.973 0.0271 0.979 0.899
#> CV:hclust 6 0.917 0.931 0.955 0.0283 0.993 0.972
#> MAD:hclust 6 0.896 0.920 0.939 0.0457 0.980 0.906
#> ATC:hclust 6 0.890 0.883 0.908 0.0343 0.965 0.843
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 14939 rows and 54 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.551 0.877 0.930 0.2375 0.799 0.799
#> 3 3 0.402 0.764 0.780 1.1307 0.716 0.644
#> 4 4 0.810 0.913 0.958 0.3461 0.800 0.611
#> 5 5 1.000 0.963 0.985 0.1532 0.893 0.660
#> 6 6 1.000 0.935 0.973 0.0271 0.979 0.899
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
#> SRR805725 1 0.680 0.842 0.820 0.180
#> SRR805726 1 0.680 0.842 0.820 0.180
#> SRR805727 1 0.680 0.842 0.820 0.180
#> SRR805728 1 0.680 0.842 0.820 0.180
#> SRR805729 1 0.680 0.842 0.820 0.180
#> SRR805730 2 0.871 0.595 0.292 0.708
#> SRR805731 2 0.855 0.618 0.280 0.720
#> SRR805732 2 0.000 0.866 0.000 1.000
#> SRR805733 2 0.000 0.866 0.000 1.000
#> SRR805735 1 0.680 0.842 0.820 0.180
#> SRR805736 1 0.680 0.842 0.820 0.180
#> SRR805737 1 0.680 0.842 0.820 0.180
#> SRR805738 1 0.680 0.842 0.820 0.180
#> SRR805739 1 0.680 0.842 0.820 0.180
#> SRR805740 1 0.680 0.842 0.820 0.180
#> SRR805741 1 0.680 0.842 0.820 0.180
#> SRR805742 1 0.680 0.842 0.820 0.180
#> SRR805743 1 0.680 0.842 0.820 0.180
#> SRR805744 1 0.680 0.842 0.820 0.180
#> SRR805745 1 0.680 0.842 0.820 0.180
#> SRR805746 1 0.680 0.842 0.820 0.180
#> SRR805747 1 0.118 0.915 0.984 0.016
#> SRR805748 1 0.118 0.915 0.984 0.016
#> SRR805749 1 0.118 0.915 0.984 0.016
#> SRR805750 1 0.118 0.915 0.984 0.016
#> SRR805751 1 0.118 0.915 0.984 0.016
#> SRR805752 2 0.000 0.866 0.000 1.000
#> SRR805753 2 0.000 0.866 0.000 1.000
#> SRR805754 1 0.118 0.915 0.984 0.016
#> SRR805755 1 0.118 0.915 0.984 0.016
#> SRR805756 1 0.118 0.915 0.984 0.016
#> SRR805757 1 0.118 0.915 0.984 0.016
#> SRR805758 1 0.000 0.916 1.000 0.000
#> SRR805759 1 0.000 0.916 1.000 0.000
#> SRR805760 1 0.000 0.916 1.000 0.000
#> SRR805761 1 0.000 0.916 1.000 0.000
#> SRR805762 1 0.000 0.916 1.000 0.000
#> SRR805763 1 0.000 0.916 1.000 0.000
#> SRR805764 1 0.000 0.916 1.000 0.000
#> SRR805765 1 0.000 0.916 1.000 0.000
#> SRR805766 1 0.000 0.916 1.000 0.000
#> SRR805767 1 0.000 0.916 1.000 0.000
#> SRR805768 1 0.000 0.916 1.000 0.000
#> SRR805769 1 0.000 0.916 1.000 0.000
#> SRR805770 1 0.000 0.916 1.000 0.000
#> SRR805771 1 0.000 0.916 1.000 0.000
#> SRR805772 1 0.000 0.916 1.000 0.000
#> SRR805773 1 0.000 0.916 1.000 0.000
#> SRR805774 1 0.000 0.916 1.000 0.000
#> SRR805775 1 0.000 0.916 1.000 0.000
#> SRR805776 1 0.000 0.916 1.000 0.000
#> SRR805777 1 0.000 0.916 1.000 0.000
#> SRR805778 1 0.000 0.916 1.000 0.000
#> SRR805779 1 0.000 0.916 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.000 0.746 0.000 1.000 0.000
#> SRR805726 2 0.000 0.746 0.000 1.000 0.000
#> SRR805727 2 0.000 0.746 0.000 1.000 0.000
#> SRR805728 2 0.000 0.746 0.000 1.000 0.000
#> SRR805729 2 0.000 0.746 0.000 1.000 0.000
#> SRR805730 1 0.630 0.531 0.528 0.472 0.000
#> SRR805731 1 0.628 0.545 0.540 0.460 0.000
#> SRR805732 1 0.429 0.819 0.820 0.180 0.000
#> SRR805733 1 0.429 0.819 0.820 0.180 0.000
#> SRR805735 2 0.000 0.746 0.000 1.000 0.000
#> SRR805736 2 0.000 0.746 0.000 1.000 0.000
#> SRR805737 2 0.000 0.746 0.000 1.000 0.000
#> SRR805738 2 0.000 0.746 0.000 1.000 0.000
#> SRR805739 2 0.000 0.746 0.000 1.000 0.000
#> SRR805740 2 0.000 0.746 0.000 1.000 0.000
#> SRR805741 2 0.000 0.746 0.000 1.000 0.000
#> SRR805742 2 0.000 0.746 0.000 1.000 0.000
#> SRR805743 2 0.000 0.746 0.000 1.000 0.000
#> SRR805744 2 0.000 0.746 0.000 1.000 0.000
#> SRR805745 2 0.000 0.746 0.000 1.000 0.000
#> SRR805746 2 0.000 0.746 0.000 1.000 0.000
#> SRR805747 2 0.406 0.747 0.000 0.836 0.164
#> SRR805748 2 0.406 0.747 0.000 0.836 0.164
#> SRR805749 2 0.406 0.747 0.000 0.836 0.164
#> SRR805750 2 0.406 0.747 0.000 0.836 0.164
#> SRR805751 2 0.406 0.747 0.000 0.836 0.164
#> SRR805752 1 0.429 0.819 0.820 0.180 0.000
#> SRR805753 1 0.429 0.819 0.820 0.180 0.000
#> SRR805754 2 0.406 0.747 0.000 0.836 0.164
#> SRR805755 2 0.406 0.747 0.000 0.836 0.164
#> SRR805756 2 0.406 0.747 0.000 0.836 0.164
#> SRR805757 2 0.406 0.747 0.000 0.836 0.164
#> SRR805758 3 0.901 1.000 0.180 0.268 0.552
#> SRR805759 3 0.901 1.000 0.180 0.268 0.552
#> SRR805760 3 0.901 1.000 0.180 0.268 0.552
#> SRR805761 3 0.901 1.000 0.180 0.268 0.552
#> SRR805762 3 0.901 1.000 0.180 0.268 0.552
#> SRR805763 3 0.901 1.000 0.180 0.268 0.552
#> SRR805764 3 0.901 1.000 0.180 0.268 0.552
#> SRR805765 3 0.901 1.000 0.180 0.268 0.552
#> SRR805766 3 0.901 1.000 0.180 0.268 0.552
#> SRR805767 3 0.901 1.000 0.180 0.268 0.552
#> SRR805768 3 0.901 1.000 0.180 0.268 0.552
#> SRR805769 2 0.630 0.588 0.000 0.520 0.480
#> SRR805770 2 0.630 0.588 0.000 0.520 0.480
#> SRR805771 2 0.630 0.588 0.000 0.520 0.480
#> SRR805772 2 0.630 0.588 0.000 0.520 0.480
#> SRR805773 2 0.630 0.588 0.000 0.520 0.480
#> SRR805774 2 0.630 0.588 0.000 0.520 0.480
#> SRR805775 2 0.630 0.588 0.000 0.520 0.480
#> SRR805776 2 0.630 0.588 0.000 0.520 0.480
#> SRR805777 2 0.630 0.588 0.000 0.520 0.480
#> SRR805778 2 0.630 0.588 0.000 0.520 0.480
#> SRR805779 2 0.630 0.588 0.000 0.520 0.480
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805726 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805727 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805728 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805729 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805730 4 0.498 0.337 0.000 0.460 0 0.540
#> SRR805731 4 0.460 0.552 0.000 0.336 0 0.664
#> SRR805732 4 0.000 0.790 0.000 0.000 0 1.000
#> SRR805733 4 0.000 0.790 0.000 0.000 0 1.000
#> SRR805735 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805736 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805737 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805738 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805739 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805740 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805741 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805742 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805743 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805744 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805745 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805746 2 0.000 0.921 0.000 1.000 0 0.000
#> SRR805747 2 0.322 0.845 0.164 0.836 0 0.000
#> SRR805748 2 0.322 0.845 0.164 0.836 0 0.000
#> SRR805749 2 0.322 0.845 0.164 0.836 0 0.000
#> SRR805750 2 0.322 0.845 0.164 0.836 0 0.000
#> SRR805751 2 0.322 0.845 0.164 0.836 0 0.000
#> SRR805752 4 0.000 0.790 0.000 0.000 0 1.000
#> SRR805753 4 0.000 0.790 0.000 0.000 0 1.000
#> SRR805754 2 0.322 0.845 0.164 0.836 0 0.000
#> SRR805755 2 0.322 0.845 0.164 0.836 0 0.000
#> SRR805756 2 0.322 0.845 0.164 0.836 0 0.000
#> SRR805757 2 0.322 0.845 0.164 0.836 0 0.000
#> SRR805758 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805759 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805760 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805761 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805762 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805763 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805764 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805765 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805766 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805767 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805768 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805769 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805770 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805771 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805772 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805773 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805774 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805775 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805776 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805777 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805778 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805779 1 0.000 1.000 1.000 0.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805726 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805727 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805728 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805729 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805730 2 0.429 0.284 0 0.540 0 0 0.460
#> SRR805731 2 0.397 0.552 0 0.664 0 0 0.336
#> SRR805732 2 0.000 0.796 0 1.000 0 0 0.000
#> SRR805733 2 0.000 0.796 0 1.000 0 0 0.000
#> SRR805735 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805736 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805737 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805738 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805739 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805740 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805741 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805742 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805743 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805744 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805745 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805746 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805747 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805748 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805749 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805750 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805751 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805752 2 0.000 0.796 0 1.000 0 0 0.000
#> SRR805753 2 0.000 0.796 0 1.000 0 0 0.000
#> SRR805754 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805755 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805756 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805757 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805758 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805759 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805760 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805761 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805762 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805763 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805764 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805765 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805766 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805767 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805768 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805769 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805770 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805771 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805772 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805773 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805774 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805775 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805776 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805777 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805778 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805779 1 0.000 1.000 1 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
#> SRR805725 5 0.0632 0.982 0 0.024 0.000 0 0.976 0.000
#> SRR805726 5 0.0632 0.982 0 0.024 0.000 0 0.976 0.000
#> SRR805727 5 0.0632 0.982 0 0.024 0.000 0 0.976 0.000
#> SRR805728 5 0.0632 0.982 0 0.024 0.000 0 0.976 0.000
#> SRR805729 5 0.0632 0.982 0 0.024 0.000 0 0.976 0.000
#> SRR805730 6 0.4377 0.308 0 0.024 0.000 0 0.436 0.540
#> SRR805731 6 0.4045 0.556 0 0.024 0.000 0 0.312 0.664
#> SRR805732 6 0.0000 0.754 0 0.000 0.000 0 0.000 1.000
#> SRR805733 6 0.0000 0.754 0 0.000 0.000 0 0.000 1.000
#> SRR805735 5 0.0632 0.982 0 0.024 0.000 0 0.976 0.000
#> SRR805736 5 0.0000 0.990 0 0.000 0.000 0 1.000 0.000
#> SRR805737 5 0.0000 0.990 0 0.000 0.000 0 1.000 0.000
#> SRR805738 5 0.0000 0.990 0 0.000 0.000 0 1.000 0.000
#> SRR805739 5 0.0000 0.990 0 0.000 0.000 0 1.000 0.000
#> SRR805740 5 0.0000 0.990 0 0.000 0.000 0 1.000 0.000
#> SRR805741 5 0.0000 0.990 0 0.000 0.000 0 1.000 0.000
#> SRR805742 5 0.0000 0.990 0 0.000 0.000 0 1.000 0.000
#> SRR805743 5 0.0000 0.990 0 0.000 0.000 0 1.000 0.000
#> SRR805744 5 0.0000 0.990 0 0.000 0.000 0 1.000 0.000
#> SRR805745 5 0.0000 0.990 0 0.000 0.000 0 1.000 0.000
#> SRR805746 5 0.0000 0.990 0 0.000 0.000 0 1.000 0.000
#> SRR805747 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805748 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805749 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805750 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805751 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805752 6 0.0000 0.754 0 0.000 0.000 0 0.000 1.000
#> SRR805753 6 0.0000 0.754 0 0.000 0.000 0 0.000 1.000
#> SRR805754 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805755 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805756 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805757 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805758 3 0.0000 1.000 0 0.000 1.000 0 0.000 0.000
#> SRR805759 3 0.0000 1.000 0 0.000 1.000 0 0.000 0.000
#> SRR805760 3 0.0000 1.000 0 0.000 1.000 0 0.000 0.000
#> SRR805761 3 0.0000 1.000 0 0.000 1.000 0 0.000 0.000
#> SRR805762 3 0.0000 1.000 0 0.000 1.000 0 0.000 0.000
#> SRR805763 2 0.0632 0.889 0 0.976 0.024 0 0.000 0.000
#> SRR805764 2 0.0632 0.889 0 0.976 0.024 0 0.000 0.000
#> SRR805765 2 0.0632 0.889 0 0.976 0.024 0 0.000 0.000
#> SRR805766 2 0.0632 0.889 0 0.976 0.024 0 0.000 0.000
#> SRR805767 2 0.3823 0.270 0 0.564 0.436 0 0.000 0.000
#> SRR805768 3 0.0000 1.000 0 0.000 1.000 0 0.000 0.000
#> SRR805769 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805770 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805771 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805772 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805773 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805774 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805775 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805776 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805777 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805778 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805779 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 14939 rows and 54 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 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.442 0.764 0.876 0.4654 0.491 0.491
#> 3 3 0.493 0.776 0.802 0.3525 0.752 0.544
#> 4 4 0.640 0.650 0.705 0.1474 0.822 0.538
#> 5 5 0.823 0.922 0.850 0.0819 0.891 0.597
#> 6 6 0.885 0.882 0.843 0.0482 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] 5
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
#> SRR805725 2 0.141 0.883 0.020 0.980
#> SRR805726 2 0.118 0.883 0.016 0.984
#> SRR805727 2 0.141 0.883 0.020 0.980
#> SRR805728 2 0.184 0.881 0.028 0.972
#> SRR805729 2 0.141 0.883 0.020 0.980
#> SRR805730 2 0.260 0.872 0.044 0.956
#> SRR805731 2 0.260 0.872 0.044 0.956
#> SRR805732 2 0.260 0.872 0.044 0.956
#> SRR805733 2 0.260 0.872 0.044 0.956
#> SRR805735 2 0.184 0.881 0.028 0.972
#> SRR805736 2 0.000 0.884 0.000 1.000
#> SRR805737 2 0.000 0.884 0.000 1.000
#> SRR805738 2 0.000 0.884 0.000 1.000
#> SRR805739 2 0.000 0.884 0.000 1.000
#> SRR805740 2 0.000 0.884 0.000 1.000
#> SRR805741 2 0.000 0.884 0.000 1.000
#> SRR805742 2 0.000 0.884 0.000 1.000
#> SRR805743 2 0.000 0.884 0.000 1.000
#> SRR805744 2 0.000 0.884 0.000 1.000
#> SRR805745 2 0.000 0.884 0.000 1.000
#> SRR805746 2 0.000 0.884 0.000 1.000
#> SRR805747 1 0.961 0.574 0.616 0.384
#> SRR805748 1 0.963 0.565 0.612 0.388
#> SRR805749 1 0.961 0.574 0.616 0.384
#> SRR805750 1 0.963 0.565 0.612 0.388
#> SRR805751 2 0.966 0.203 0.392 0.608
#> SRR805752 2 0.260 0.872 0.044 0.956
#> SRR805753 2 0.260 0.872 0.044 0.956
#> SRR805754 2 0.973 0.162 0.404 0.596
#> SRR805755 2 0.973 0.162 0.404 0.596
#> SRR805756 2 0.973 0.162 0.404 0.596
#> SRR805757 2 0.973 0.162 0.404 0.596
#> SRR805758 1 0.224 0.808 0.964 0.036
#> SRR805759 1 0.163 0.808 0.976 0.024
#> SRR805760 1 0.163 0.808 0.976 0.024
#> SRR805761 1 0.163 0.808 0.976 0.024
#> SRR805762 1 0.163 0.808 0.976 0.024
#> SRR805763 1 0.163 0.808 0.976 0.024
#> SRR805764 1 0.163 0.808 0.976 0.024
#> SRR805765 1 0.163 0.808 0.976 0.024
#> SRR805766 1 0.163 0.808 0.976 0.024
#> SRR805767 1 0.163 0.808 0.976 0.024
#> SRR805768 1 0.163 0.808 0.976 0.024
#> SRR805769 1 0.775 0.817 0.772 0.228
#> SRR805770 1 0.775 0.817 0.772 0.228
#> SRR805771 1 0.775 0.817 0.772 0.228
#> SRR805772 1 0.775 0.817 0.772 0.228
#> SRR805773 1 0.775 0.817 0.772 0.228
#> SRR805774 1 0.775 0.817 0.772 0.228
#> SRR805775 1 0.775 0.817 0.772 0.228
#> SRR805776 1 0.775 0.817 0.772 0.228
#> SRR805777 1 0.775 0.817 0.772 0.228
#> SRR805778 1 0.775 0.817 0.772 0.228
#> SRR805779 1 0.775 0.817 0.772 0.228
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.4121 0.871 0.084 0.876 0.040
#> SRR805726 2 0.4121 0.871 0.084 0.876 0.040
#> SRR805727 2 0.4121 0.871 0.084 0.876 0.040
#> SRR805728 2 0.5435 0.857 0.144 0.808 0.048
#> SRR805729 2 0.4121 0.871 0.084 0.876 0.040
#> SRR805730 2 0.6746 0.827 0.192 0.732 0.076
#> SRR805731 2 0.6746 0.827 0.192 0.732 0.076
#> SRR805732 2 0.6746 0.827 0.192 0.732 0.076
#> SRR805733 2 0.6746 0.827 0.192 0.732 0.076
#> SRR805735 2 0.5435 0.857 0.144 0.808 0.048
#> SRR805736 2 0.1636 0.876 0.020 0.964 0.016
#> SRR805737 2 0.1636 0.876 0.020 0.964 0.016
#> SRR805738 2 0.1636 0.876 0.020 0.964 0.016
#> SRR805739 2 0.1636 0.876 0.020 0.964 0.016
#> SRR805740 2 0.1636 0.876 0.020 0.964 0.016
#> SRR805741 2 0.1636 0.876 0.020 0.964 0.016
#> SRR805742 2 0.1636 0.876 0.020 0.964 0.016
#> SRR805743 2 0.1337 0.875 0.012 0.972 0.016
#> SRR805744 2 0.1636 0.876 0.020 0.964 0.016
#> SRR805745 2 0.1636 0.876 0.020 0.964 0.016
#> SRR805746 2 0.1636 0.876 0.020 0.964 0.016
#> SRR805747 1 0.8474 0.603 0.604 0.252 0.144
#> SRR805748 1 0.8474 0.603 0.604 0.252 0.144
#> SRR805749 1 0.8474 0.603 0.604 0.252 0.144
#> SRR805750 1 0.8474 0.603 0.604 0.252 0.144
#> SRR805751 1 0.9065 0.516 0.492 0.364 0.144
#> SRR805752 2 0.6746 0.827 0.192 0.732 0.076
#> SRR805753 2 0.6746 0.827 0.192 0.732 0.076
#> SRR805754 1 0.9065 0.516 0.492 0.364 0.144
#> SRR805755 1 0.9065 0.516 0.492 0.364 0.144
#> SRR805756 1 0.9065 0.516 0.492 0.364 0.144
#> SRR805757 1 0.9065 0.516 0.492 0.364 0.144
#> SRR805758 3 0.2796 0.935 0.092 0.000 0.908
#> SRR805759 3 0.2796 0.935 0.092 0.000 0.908
#> SRR805760 3 0.2796 0.935 0.092 0.000 0.908
#> SRR805761 3 0.2796 0.935 0.092 0.000 0.908
#> SRR805762 3 0.2796 0.935 0.092 0.000 0.908
#> SRR805763 3 0.0661 0.900 0.008 0.004 0.988
#> SRR805764 3 0.0661 0.900 0.008 0.004 0.988
#> SRR805765 3 0.0661 0.900 0.008 0.004 0.988
#> SRR805766 3 0.0661 0.900 0.008 0.004 0.988
#> SRR805767 3 0.2537 0.930 0.080 0.000 0.920
#> SRR805768 3 0.2796 0.935 0.092 0.000 0.908
#> SRR805769 1 0.5797 0.633 0.712 0.008 0.280
#> SRR805770 1 0.5797 0.633 0.712 0.008 0.280
#> SRR805771 1 0.5797 0.633 0.712 0.008 0.280
#> SRR805772 1 0.5797 0.633 0.712 0.008 0.280
#> SRR805773 1 0.5797 0.633 0.712 0.008 0.280
#> SRR805774 1 0.5797 0.633 0.712 0.008 0.280
#> SRR805775 1 0.5797 0.633 0.712 0.008 0.280
#> SRR805776 1 0.5797 0.633 0.712 0.008 0.280
#> SRR805777 1 0.5797 0.633 0.712 0.008 0.280
#> SRR805778 1 0.5797 0.633 0.712 0.008 0.280
#> SRR805779 1 0.5797 0.633 0.712 0.008 0.280
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.5898 0.497 0.000 0.604 0.048 0.348
#> SRR805726 2 0.5882 0.500 0.000 0.608 0.048 0.344
#> SRR805727 2 0.5898 0.497 0.000 0.604 0.048 0.348
#> SRR805728 2 0.6094 0.403 0.000 0.536 0.048 0.416
#> SRR805729 2 0.5882 0.500 0.000 0.608 0.048 0.344
#> SRR805730 4 0.6285 -0.251 0.000 0.412 0.060 0.528
#> SRR805731 4 0.6521 -0.241 0.000 0.412 0.076 0.512
#> SRR805732 4 0.6521 -0.241 0.000 0.412 0.076 0.512
#> SRR805733 4 0.6521 -0.241 0.000 0.412 0.076 0.512
#> SRR805735 2 0.6094 0.403 0.000 0.536 0.048 0.416
#> SRR805736 2 0.0592 0.771 0.016 0.984 0.000 0.000
#> SRR805737 2 0.0592 0.771 0.016 0.984 0.000 0.000
#> SRR805738 2 0.0592 0.771 0.016 0.984 0.000 0.000
#> SRR805739 2 0.0592 0.771 0.016 0.984 0.000 0.000
#> SRR805740 2 0.0592 0.771 0.016 0.984 0.000 0.000
#> SRR805741 2 0.0592 0.771 0.016 0.984 0.000 0.000
#> SRR805742 2 0.0592 0.771 0.016 0.984 0.000 0.000
#> SRR805743 2 0.0000 0.761 0.000 1.000 0.000 0.000
#> SRR805744 2 0.0592 0.771 0.016 0.984 0.000 0.000
#> SRR805745 2 0.0592 0.771 0.016 0.984 0.000 0.000
#> SRR805746 2 0.0592 0.771 0.016 0.984 0.000 0.000
#> SRR805747 4 0.8616 0.417 0.344 0.172 0.056 0.428
#> SRR805748 4 0.8616 0.417 0.344 0.172 0.056 0.428
#> SRR805749 4 0.8616 0.417 0.344 0.172 0.056 0.428
#> SRR805750 4 0.8616 0.417 0.344 0.172 0.056 0.428
#> SRR805751 4 0.8731 0.480 0.284 0.216 0.056 0.444
#> SRR805752 4 0.6521 -0.241 0.000 0.412 0.076 0.512
#> SRR805753 4 0.6521 -0.241 0.000 0.412 0.076 0.512
#> SRR805754 4 0.8731 0.480 0.284 0.216 0.056 0.444
#> SRR805755 4 0.8731 0.480 0.284 0.216 0.056 0.444
#> SRR805756 4 0.8731 0.480 0.284 0.216 0.056 0.444
#> SRR805757 4 0.8731 0.480 0.284 0.216 0.056 0.444
#> SRR805758 3 0.1940 0.941 0.076 0.000 0.924 0.000
#> SRR805759 3 0.1940 0.941 0.076 0.000 0.924 0.000
#> SRR805760 3 0.1940 0.941 0.076 0.000 0.924 0.000
#> SRR805761 3 0.1940 0.941 0.076 0.000 0.924 0.000
#> SRR805762 3 0.1940 0.941 0.076 0.000 0.924 0.000
#> SRR805763 3 0.2587 0.916 0.012 0.004 0.908 0.076
#> SRR805764 3 0.2587 0.916 0.012 0.004 0.908 0.076
#> SRR805765 3 0.2587 0.916 0.012 0.004 0.908 0.076
#> SRR805766 3 0.2587 0.916 0.012 0.004 0.908 0.076
#> SRR805767 3 0.3691 0.927 0.068 0.000 0.856 0.076
#> SRR805768 3 0.1940 0.941 0.076 0.000 0.924 0.000
#> SRR805769 1 0.1557 0.998 0.944 0.000 0.056 0.000
#> SRR805770 1 0.1743 0.998 0.940 0.000 0.056 0.004
#> SRR805771 1 0.1743 0.998 0.940 0.000 0.056 0.004
#> SRR805772 1 0.1557 0.998 0.944 0.000 0.056 0.000
#> SRR805773 1 0.1557 0.998 0.944 0.000 0.056 0.000
#> SRR805774 1 0.1557 0.998 0.944 0.000 0.056 0.000
#> SRR805775 1 0.1743 0.998 0.940 0.000 0.056 0.004
#> SRR805776 1 0.1743 0.998 0.940 0.000 0.056 0.004
#> SRR805777 1 0.1557 0.998 0.944 0.000 0.056 0.000
#> SRR805778 1 0.1743 0.998 0.940 0.000 0.056 0.004
#> SRR805779 1 0.1557 0.998 0.944 0.000 0.056 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 2 0.3607 0.788 0.000 0.820 0.008 0.028 0.144
#> SRR805726 2 0.3607 0.788 0.000 0.820 0.008 0.028 0.144
#> SRR805727 2 0.3607 0.788 0.000 0.820 0.008 0.028 0.144
#> SRR805728 2 0.2304 0.837 0.000 0.892 0.008 0.000 0.100
#> SRR805729 2 0.3607 0.788 0.000 0.820 0.008 0.028 0.144
#> SRR805730 2 0.0162 0.847 0.000 0.996 0.004 0.000 0.000
#> SRR805731 2 0.1844 0.848 0.000 0.936 0.012 0.040 0.012
#> SRR805732 2 0.1844 0.848 0.000 0.936 0.012 0.040 0.012
#> SRR805733 2 0.1844 0.848 0.000 0.936 0.012 0.040 0.012
#> SRR805735 2 0.2304 0.837 0.000 0.892 0.008 0.000 0.100
#> SRR805736 5 0.4719 0.991 0.000 0.248 0.000 0.056 0.696
#> SRR805737 5 0.4719 0.991 0.000 0.248 0.000 0.056 0.696
#> SRR805738 5 0.4719 0.991 0.000 0.248 0.000 0.056 0.696
#> SRR805739 5 0.4719 0.991 0.000 0.248 0.000 0.056 0.696
#> SRR805740 5 0.4719 0.991 0.000 0.248 0.000 0.056 0.696
#> SRR805741 5 0.4872 0.991 0.000 0.248 0.004 0.056 0.692
#> SRR805742 5 0.4993 0.988 0.000 0.248 0.004 0.064 0.684
#> SRR805743 5 0.4993 0.988 0.000 0.248 0.004 0.064 0.684
#> SRR805744 5 0.4993 0.988 0.000 0.248 0.004 0.064 0.684
#> SRR805745 5 0.5010 0.979 0.000 0.248 0.000 0.076 0.676
#> SRR805746 5 0.5010 0.979 0.000 0.248 0.000 0.076 0.676
#> SRR805747 4 0.3812 0.964 0.116 0.016 0.016 0.832 0.020
#> SRR805748 4 0.3812 0.964 0.116 0.016 0.016 0.832 0.020
#> SRR805749 4 0.3812 0.964 0.116 0.016 0.016 0.832 0.020
#> SRR805750 4 0.3812 0.964 0.116 0.016 0.016 0.832 0.020
#> SRR805751 4 0.3523 0.972 0.084 0.036 0.012 0.856 0.012
#> SRR805752 2 0.1844 0.848 0.000 0.936 0.012 0.040 0.012
#> SRR805753 2 0.1844 0.848 0.000 0.936 0.012 0.040 0.012
#> SRR805754 4 0.3523 0.972 0.084 0.036 0.012 0.856 0.012
#> SRR805755 4 0.3523 0.972 0.084 0.036 0.012 0.856 0.012
#> SRR805756 4 0.3523 0.972 0.084 0.036 0.012 0.856 0.012
#> SRR805757 4 0.3523 0.972 0.084 0.036 0.012 0.856 0.012
#> SRR805758 3 0.4997 0.900 0.024 0.000 0.736 0.072 0.168
#> SRR805759 3 0.4975 0.900 0.024 0.000 0.736 0.068 0.172
#> SRR805760 3 0.4997 0.900 0.024 0.000 0.736 0.072 0.168
#> SRR805761 3 0.4997 0.900 0.024 0.000 0.736 0.072 0.168
#> SRR805762 3 0.4975 0.900 0.024 0.000 0.736 0.068 0.172
#> SRR805763 3 0.0671 0.879 0.016 0.004 0.980 0.000 0.000
#> SRR805764 3 0.0833 0.879 0.016 0.004 0.976 0.004 0.000
#> SRR805765 3 0.0671 0.879 0.016 0.004 0.980 0.000 0.000
#> SRR805766 3 0.0671 0.879 0.016 0.004 0.980 0.000 0.000
#> SRR805767 3 0.0609 0.879 0.020 0.000 0.980 0.000 0.000
#> SRR805768 3 0.4975 0.900 0.024 0.000 0.736 0.068 0.172
#> SRR805769 1 0.0000 0.960 1.000 0.000 0.000 0.000 0.000
#> SRR805770 1 0.1908 0.951 0.908 0.000 0.000 0.000 0.092
#> SRR805771 1 0.1908 0.951 0.908 0.000 0.000 0.000 0.092
#> SRR805772 1 0.0000 0.960 1.000 0.000 0.000 0.000 0.000
#> SRR805773 1 0.0000 0.960 1.000 0.000 0.000 0.000 0.000
#> SRR805774 1 0.0000 0.960 1.000 0.000 0.000 0.000 0.000
#> SRR805775 1 0.2020 0.948 0.900 0.000 0.000 0.000 0.100
#> SRR805776 1 0.2020 0.948 0.900 0.000 0.000 0.000 0.100
#> SRR805777 1 0.0000 0.960 1.000 0.000 0.000 0.000 0.000
#> SRR805778 1 0.1908 0.951 0.908 0.000 0.000 0.000 0.092
#> SRR805779 1 0.0000 0.960 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0.6166 0.752 0.000 0.412 0.000 0.008 0.220 NA
#> SRR805726 2 0.6166 0.752 0.000 0.412 0.000 0.008 0.220 NA
#> SRR805727 2 0.6166 0.752 0.000 0.412 0.000 0.008 0.220 NA
#> SRR805728 2 0.6053 0.764 0.000 0.440 0.000 0.008 0.192 NA
#> SRR805729 2 0.6166 0.752 0.000 0.412 0.000 0.008 0.220 NA
#> SRR805730 2 0.5223 0.764 0.000 0.576 0.000 0.008 0.088 NA
#> SRR805731 2 0.2062 0.730 0.000 0.900 0.000 0.008 0.088 NA
#> SRR805732 2 0.1918 0.729 0.000 0.904 0.000 0.008 0.088 NA
#> SRR805733 2 0.1918 0.729 0.000 0.904 0.000 0.008 0.088 NA
#> SRR805735 2 0.6053 0.764 0.000 0.440 0.000 0.008 0.192 NA
#> SRR805736 5 0.0909 0.979 0.000 0.000 0.000 0.012 0.968 NA
#> SRR805737 5 0.0622 0.983 0.000 0.000 0.000 0.008 0.980 NA
#> SRR805738 5 0.0000 0.984 0.000 0.000 0.000 0.000 1.000 NA
#> SRR805739 5 0.0909 0.979 0.000 0.000 0.000 0.012 0.968 NA
#> SRR805740 5 0.0000 0.984 0.000 0.000 0.000 0.000 1.000 NA
#> SRR805741 5 0.0458 0.984 0.000 0.000 0.000 0.000 0.984 NA
#> SRR805742 5 0.0692 0.982 0.000 0.000 0.004 0.000 0.976 NA
#> SRR805743 5 0.0405 0.982 0.000 0.000 0.004 0.000 0.988 NA
#> SRR805744 5 0.0405 0.982 0.000 0.000 0.004 0.000 0.988 NA
#> SRR805745 5 0.0837 0.975 0.000 0.004 0.000 0.004 0.972 NA
#> SRR805746 5 0.0837 0.975 0.000 0.004 0.000 0.004 0.972 NA
#> SRR805747 4 0.3636 0.959 0.048 0.020 0.000 0.840 0.036 NA
#> SRR805748 4 0.3636 0.959 0.048 0.020 0.000 0.840 0.036 NA
#> SRR805749 4 0.3636 0.959 0.048 0.020 0.000 0.840 0.036 NA
#> SRR805750 4 0.3636 0.959 0.048 0.020 0.000 0.840 0.036 NA
#> SRR805751 4 0.2194 0.966 0.040 0.008 0.000 0.912 0.036 NA
#> SRR805752 2 0.2425 0.728 0.000 0.884 0.004 0.024 0.088 NA
#> SRR805753 2 0.2425 0.728 0.000 0.884 0.004 0.024 0.088 NA
#> SRR805754 4 0.2051 0.967 0.040 0.008 0.000 0.916 0.036 NA
#> SRR805755 4 0.2051 0.967 0.040 0.008 0.000 0.916 0.036 NA
#> SRR805756 4 0.2051 0.967 0.040 0.008 0.000 0.916 0.036 NA
#> SRR805757 4 0.2051 0.967 0.040 0.008 0.000 0.916 0.036 NA
#> SRR805758 3 0.4245 0.873 0.008 0.016 0.684 0.008 0.000 NA
#> SRR805759 3 0.3897 0.874 0.008 0.000 0.684 0.008 0.000 NA
#> SRR805760 3 0.4103 0.874 0.008 0.000 0.684 0.020 0.000 NA
#> SRR805761 3 0.4103 0.874 0.008 0.000 0.684 0.020 0.000 NA
#> SRR805762 3 0.3897 0.874 0.008 0.000 0.684 0.008 0.000 NA
#> SRR805763 3 0.0551 0.847 0.008 0.004 0.984 0.004 0.000 NA
#> SRR805764 3 0.0951 0.846 0.008 0.004 0.968 0.020 0.000 NA
#> SRR805765 3 0.0260 0.847 0.008 0.000 0.992 0.000 0.000 NA
#> SRR805766 3 0.0260 0.847 0.008 0.000 0.992 0.000 0.000 NA
#> SRR805767 3 0.0665 0.847 0.008 0.004 0.980 0.008 0.000 NA
#> SRR805768 3 0.3897 0.874 0.008 0.000 0.684 0.008 0.000 NA
#> SRR805769 1 0.0405 0.894 0.988 0.004 0.000 0.000 0.000 NA
#> SRR805770 1 0.3735 0.872 0.748 0.020 0.000 0.008 0.000 NA
#> SRR805771 1 0.3735 0.872 0.748 0.020 0.000 0.008 0.000 NA
#> SRR805772 1 0.0260 0.895 0.992 0.008 0.000 0.000 0.000 NA
#> SRR805773 1 0.0146 0.895 0.996 0.004 0.000 0.000 0.000 NA
#> SRR805774 1 0.0000 0.895 1.000 0.000 0.000 0.000 0.000 NA
#> SRR805775 1 0.3906 0.870 0.744 0.032 0.000 0.008 0.000 NA
#> SRR805776 1 0.3906 0.870 0.744 0.032 0.000 0.008 0.000 NA
#> SRR805777 1 0.0363 0.895 0.988 0.012 0.000 0.000 0.000 NA
#> SRR805778 1 0.3735 0.872 0.748 0.020 0.000 0.008 0.000 NA
#> SRR805779 1 0.0363 0.895 0.988 0.012 0.000 0.000 0.000 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 14939 rows and 54 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 0.829 0.961 0.980 0.501 0.502 0.502
#> 3 3 1.000 0.987 0.986 0.300 0.846 0.694
#> 4 4 1.000 0.984 0.974 0.110 0.931 0.801
#> 5 5 1.000 1.000 1.000 0.125 0.908 0.669
#> 6 6 0.954 0.986 0.968 0.030 0.975 0.865
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 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
#> SRR805725 2 0.000 1.000 0.000 1.000
#> SRR805726 2 0.000 1.000 0.000 1.000
#> SRR805727 2 0.000 1.000 0.000 1.000
#> SRR805728 2 0.000 1.000 0.000 1.000
#> SRR805729 2 0.000 1.000 0.000 1.000
#> SRR805730 2 0.000 1.000 0.000 1.000
#> SRR805731 2 0.000 1.000 0.000 1.000
#> SRR805732 2 0.000 1.000 0.000 1.000
#> SRR805733 2 0.000 1.000 0.000 1.000
#> SRR805735 2 0.000 1.000 0.000 1.000
#> SRR805736 2 0.000 1.000 0.000 1.000
#> SRR805737 2 0.000 1.000 0.000 1.000
#> SRR805738 2 0.000 1.000 0.000 1.000
#> SRR805739 2 0.000 1.000 0.000 1.000
#> SRR805740 2 0.000 1.000 0.000 1.000
#> SRR805741 2 0.000 1.000 0.000 1.000
#> SRR805742 2 0.000 1.000 0.000 1.000
#> SRR805743 2 0.000 1.000 0.000 1.000
#> SRR805744 2 0.000 1.000 0.000 1.000
#> SRR805745 2 0.000 1.000 0.000 1.000
#> SRR805746 2 0.000 1.000 0.000 1.000
#> SRR805747 1 0.000 0.963 1.000 0.000
#> SRR805748 1 0.000 0.963 1.000 0.000
#> SRR805749 1 0.000 0.963 1.000 0.000
#> SRR805750 1 0.000 0.963 1.000 0.000
#> SRR805751 1 0.730 0.779 0.796 0.204
#> SRR805752 2 0.000 1.000 0.000 1.000
#> SRR805753 2 0.000 1.000 0.000 1.000
#> SRR805754 1 0.730 0.779 0.796 0.204
#> SRR805755 1 0.730 0.779 0.796 0.204
#> SRR805756 1 0.730 0.779 0.796 0.204
#> SRR805757 1 0.730 0.779 0.796 0.204
#> SRR805758 1 0.000 0.963 1.000 0.000
#> SRR805759 1 0.000 0.963 1.000 0.000
#> SRR805760 1 0.000 0.963 1.000 0.000
#> SRR805761 1 0.000 0.963 1.000 0.000
#> SRR805762 1 0.000 0.963 1.000 0.000
#> SRR805763 1 0.000 0.963 1.000 0.000
#> SRR805764 1 0.242 0.933 0.960 0.040
#> SRR805765 1 0.000 0.963 1.000 0.000
#> SRR805766 1 0.000 0.963 1.000 0.000
#> SRR805767 1 0.000 0.963 1.000 0.000
#> SRR805768 1 0.000 0.963 1.000 0.000
#> SRR805769 1 0.000 0.963 1.000 0.000
#> SRR805770 1 0.000 0.963 1.000 0.000
#> SRR805771 1 0.000 0.963 1.000 0.000
#> SRR805772 1 0.000 0.963 1.000 0.000
#> SRR805773 1 0.000 0.963 1.000 0.000
#> SRR805774 1 0.000 0.963 1.000 0.000
#> SRR805775 1 0.000 0.963 1.000 0.000
#> SRR805776 1 0.000 0.963 1.000 0.000
#> SRR805777 1 0.000 0.963 1.000 0.000
#> SRR805778 1 0.000 0.963 1.000 0.000
#> SRR805779 1 0.000 0.963 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.0475 0.996 0.004 0.992 0.004
#> SRR805726 2 0.0475 0.996 0.004 0.992 0.004
#> SRR805727 2 0.0475 0.996 0.004 0.992 0.004
#> SRR805728 2 0.0475 0.996 0.004 0.992 0.004
#> SRR805729 2 0.0475 0.996 0.004 0.992 0.004
#> SRR805730 2 0.0475 0.996 0.004 0.992 0.004
#> SRR805731 2 0.0475 0.996 0.004 0.992 0.004
#> SRR805732 2 0.0475 0.996 0.004 0.992 0.004
#> SRR805733 2 0.0475 0.996 0.004 0.992 0.004
#> SRR805735 2 0.0475 0.996 0.004 0.992 0.004
#> SRR805736 2 0.0000 0.996 0.000 1.000 0.000
#> SRR805737 2 0.0000 0.996 0.000 1.000 0.000
#> SRR805738 2 0.0000 0.996 0.000 1.000 0.000
#> SRR805739 2 0.0000 0.996 0.000 1.000 0.000
#> SRR805740 2 0.0000 0.996 0.000 1.000 0.000
#> SRR805741 2 0.0000 0.996 0.000 1.000 0.000
#> SRR805742 2 0.0000 0.996 0.000 1.000 0.000
#> SRR805743 2 0.0000 0.996 0.000 1.000 0.000
#> SRR805744 2 0.0000 0.996 0.000 1.000 0.000
#> SRR805745 2 0.0000 0.996 0.000 1.000 0.000
#> SRR805746 2 0.0000 0.996 0.000 1.000 0.000
#> SRR805747 1 0.0237 0.968 0.996 0.000 0.004
#> SRR805748 1 0.0237 0.968 0.996 0.000 0.004
#> SRR805749 1 0.0237 0.968 0.996 0.000 0.004
#> SRR805750 1 0.0237 0.968 0.996 0.000 0.004
#> SRR805751 1 0.0237 0.968 0.996 0.000 0.004
#> SRR805752 2 0.0475 0.996 0.004 0.992 0.004
#> SRR805753 2 0.0475 0.996 0.004 0.992 0.004
#> SRR805754 1 0.0237 0.968 0.996 0.000 0.004
#> SRR805755 1 0.0237 0.968 0.996 0.000 0.004
#> SRR805756 1 0.0237 0.968 0.996 0.000 0.004
#> SRR805757 1 0.0237 0.968 0.996 0.000 0.004
#> SRR805758 3 0.0237 0.998 0.004 0.000 0.996
#> SRR805759 3 0.0237 0.998 0.004 0.000 0.996
#> SRR805760 3 0.0237 0.998 0.004 0.000 0.996
#> SRR805761 3 0.0237 0.998 0.004 0.000 0.996
#> SRR805762 3 0.0237 0.998 0.004 0.000 0.996
#> SRR805763 3 0.0000 0.997 0.000 0.000 1.000
#> SRR805764 3 0.0000 0.997 0.000 0.000 1.000
#> SRR805765 3 0.0000 0.997 0.000 0.000 1.000
#> SRR805766 3 0.0000 0.997 0.000 0.000 1.000
#> SRR805767 3 0.0237 0.998 0.004 0.000 0.996
#> SRR805768 3 0.0237 0.998 0.004 0.000 0.996
#> SRR805769 1 0.1860 0.973 0.948 0.000 0.052
#> SRR805770 1 0.1860 0.973 0.948 0.000 0.052
#> SRR805771 1 0.1860 0.973 0.948 0.000 0.052
#> SRR805772 1 0.1860 0.973 0.948 0.000 0.052
#> SRR805773 1 0.1860 0.973 0.948 0.000 0.052
#> SRR805774 1 0.1860 0.973 0.948 0.000 0.052
#> SRR805775 1 0.1860 0.973 0.948 0.000 0.052
#> SRR805776 1 0.1860 0.973 0.948 0.000 0.052
#> SRR805777 1 0.1860 0.973 0.948 0.000 0.052
#> SRR805778 1 0.1860 0.973 0.948 0.000 0.052
#> SRR805779 1 0.1860 0.973 0.948 0.000 0.052
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.187 0.968 0.000 0.928 0 0.072
#> SRR805726 2 0.187 0.968 0.000 0.928 0 0.072
#> SRR805727 2 0.187 0.968 0.000 0.928 0 0.072
#> SRR805728 2 0.187 0.968 0.000 0.928 0 0.072
#> SRR805729 2 0.187 0.968 0.000 0.928 0 0.072
#> SRR805730 2 0.187 0.968 0.000 0.928 0 0.072
#> SRR805731 2 0.187 0.968 0.000 0.928 0 0.072
#> SRR805732 2 0.187 0.968 0.000 0.928 0 0.072
#> SRR805733 2 0.187 0.968 0.000 0.928 0 0.072
#> SRR805735 2 0.187 0.968 0.000 0.928 0 0.072
#> SRR805736 2 0.000 0.966 0.000 1.000 0 0.000
#> SRR805737 2 0.000 0.966 0.000 1.000 0 0.000
#> SRR805738 2 0.000 0.966 0.000 1.000 0 0.000
#> SRR805739 2 0.000 0.966 0.000 1.000 0 0.000
#> SRR805740 2 0.000 0.966 0.000 1.000 0 0.000
#> SRR805741 2 0.000 0.966 0.000 1.000 0 0.000
#> SRR805742 2 0.000 0.966 0.000 1.000 0 0.000
#> SRR805743 2 0.000 0.966 0.000 1.000 0 0.000
#> SRR805744 2 0.000 0.966 0.000 1.000 0 0.000
#> SRR805745 2 0.000 0.966 0.000 1.000 0 0.000
#> SRR805746 2 0.000 0.966 0.000 1.000 0 0.000
#> SRR805747 4 0.187 0.990 0.072 0.000 0 0.928
#> SRR805748 4 0.187 0.990 0.072 0.000 0 0.928
#> SRR805749 4 0.187 0.990 0.072 0.000 0 0.928
#> SRR805750 4 0.187 0.990 0.072 0.000 0 0.928
#> SRR805751 4 0.164 0.992 0.060 0.000 0 0.940
#> SRR805752 2 0.187 0.968 0.000 0.928 0 0.072
#> SRR805753 2 0.187 0.968 0.000 0.928 0 0.072
#> SRR805754 4 0.164 0.992 0.060 0.000 0 0.940
#> SRR805755 4 0.164 0.992 0.060 0.000 0 0.940
#> SRR805756 4 0.164 0.992 0.060 0.000 0 0.940
#> SRR805757 4 0.164 0.992 0.060 0.000 0 0.940
#> SRR805758 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805759 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805760 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805761 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805762 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805763 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805764 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805765 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805766 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805767 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805768 3 0.000 1.000 0.000 0.000 1 0.000
#> SRR805769 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805770 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805771 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805772 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805773 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805774 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805775 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805776 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805777 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805778 1 0.000 1.000 1.000 0.000 0 0.000
#> SRR805779 1 0.000 1.000 1.000 0.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 2 0 1 0 1 0 0 0
#> SRR805726 2 0 1 0 1 0 0 0
#> SRR805727 2 0 1 0 1 0 0 0
#> SRR805728 2 0 1 0 1 0 0 0
#> SRR805729 2 0 1 0 1 0 0 0
#> SRR805730 2 0 1 0 1 0 0 0
#> SRR805731 2 0 1 0 1 0 0 0
#> SRR805732 2 0 1 0 1 0 0 0
#> SRR805733 2 0 1 0 1 0 0 0
#> SRR805735 2 0 1 0 1 0 0 0
#> SRR805736 5 0 1 0 0 0 0 1
#> SRR805737 5 0 1 0 0 0 0 1
#> SRR805738 5 0 1 0 0 0 0 1
#> SRR805739 5 0 1 0 0 0 0 1
#> SRR805740 5 0 1 0 0 0 0 1
#> SRR805741 5 0 1 0 0 0 0 1
#> SRR805742 5 0 1 0 0 0 0 1
#> SRR805743 5 0 1 0 0 0 0 1
#> SRR805744 5 0 1 0 0 0 0 1
#> SRR805745 5 0 1 0 0 0 0 1
#> SRR805746 5 0 1 0 0 0 0 1
#> SRR805747 4 0 1 0 0 0 1 0
#> SRR805748 4 0 1 0 0 0 1 0
#> SRR805749 4 0 1 0 0 0 1 0
#> SRR805750 4 0 1 0 0 0 1 0
#> SRR805751 4 0 1 0 0 0 1 0
#> SRR805752 2 0 1 0 1 0 0 0
#> SRR805753 2 0 1 0 1 0 0 0
#> SRR805754 4 0 1 0 0 0 1 0
#> SRR805755 4 0 1 0 0 0 1 0
#> SRR805756 4 0 1 0 0 0 1 0
#> SRR805757 4 0 1 0 0 0 1 0
#> SRR805758 3 0 1 0 0 1 0 0
#> SRR805759 3 0 1 0 0 1 0 0
#> SRR805760 3 0 1 0 0 1 0 0
#> SRR805761 3 0 1 0 0 1 0 0
#> SRR805762 3 0 1 0 0 1 0 0
#> SRR805763 3 0 1 0 0 1 0 0
#> SRR805764 3 0 1 0 0 1 0 0
#> SRR805765 3 0 1 0 0 1 0 0
#> SRR805766 3 0 1 0 0 1 0 0
#> SRR805767 3 0 1 0 0 1 0 0
#> SRR805768 3 0 1 0 0 1 0 0
#> SRR805769 1 0 1 1 0 0 0 0
#> SRR805770 1 0 1 1 0 0 0 0
#> SRR805771 1 0 1 1 0 0 0 0
#> SRR805772 1 0 1 1 0 0 0 0
#> SRR805773 1 0 1 1 0 0 0 0
#> SRR805774 1 0 1 1 0 0 0 0
#> SRR805775 1 0 1 1 0 0 0 0
#> SRR805776 1 0 1 1 0 0 0 0
#> SRR805777 1 0 1 1 0 0 0 0
#> SRR805778 1 0 1 1 0 0 0 0
#> SRR805779 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
#> SRR805725 2 0.2416 1.000 0.000 0.844 0.000 0.000 0 0.156
#> SRR805726 2 0.2416 1.000 0.000 0.844 0.000 0.000 0 0.156
#> SRR805727 2 0.2416 1.000 0.000 0.844 0.000 0.000 0 0.156
#> SRR805728 2 0.2416 1.000 0.000 0.844 0.000 0.000 0 0.156
#> SRR805729 2 0.2416 1.000 0.000 0.844 0.000 0.000 0 0.156
#> SRR805730 6 0.0000 1.000 0.000 0.000 0.000 0.000 0 1.000
#> SRR805731 6 0.0000 1.000 0.000 0.000 0.000 0.000 0 1.000
#> SRR805732 6 0.0000 1.000 0.000 0.000 0.000 0.000 0 1.000
#> SRR805733 6 0.0000 1.000 0.000 0.000 0.000 0.000 0 1.000
#> SRR805735 2 0.2416 1.000 0.000 0.844 0.000 0.000 0 0.156
#> SRR805736 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> SRR805737 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> SRR805738 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> SRR805739 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> SRR805740 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> SRR805741 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> SRR805742 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> SRR805743 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> SRR805744 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> SRR805745 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> SRR805746 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> SRR805747 4 0.0146 0.998 0.000 0.004 0.000 0.996 0 0.000
#> SRR805748 4 0.0146 0.998 0.000 0.004 0.000 0.996 0 0.000
#> SRR805749 4 0.0146 0.998 0.000 0.004 0.000 0.996 0 0.000
#> SRR805750 4 0.0146 0.998 0.000 0.004 0.000 0.996 0 0.000
#> SRR805751 4 0.0000 0.998 0.000 0.000 0.000 1.000 0 0.000
#> SRR805752 6 0.0000 1.000 0.000 0.000 0.000 0.000 0 1.000
#> SRR805753 6 0.0000 1.000 0.000 0.000 0.000 0.000 0 1.000
#> SRR805754 4 0.0000 0.998 0.000 0.000 0.000 1.000 0 0.000
#> SRR805755 4 0.0000 0.998 0.000 0.000 0.000 1.000 0 0.000
#> SRR805756 4 0.0000 0.998 0.000 0.000 0.000 1.000 0 0.000
#> SRR805757 4 0.0000 0.998 0.000 0.000 0.000 1.000 0 0.000
#> SRR805758 3 0.0000 0.940 0.000 0.000 1.000 0.000 0 0.000
#> SRR805759 3 0.0000 0.940 0.000 0.000 1.000 0.000 0 0.000
#> SRR805760 3 0.0000 0.940 0.000 0.000 1.000 0.000 0 0.000
#> SRR805761 3 0.0000 0.940 0.000 0.000 1.000 0.000 0 0.000
#> SRR805762 3 0.0000 0.940 0.000 0.000 1.000 0.000 0 0.000
#> SRR805763 3 0.2300 0.927 0.000 0.144 0.856 0.000 0 0.000
#> SRR805764 3 0.2300 0.927 0.000 0.144 0.856 0.000 0 0.000
#> SRR805765 3 0.2300 0.927 0.000 0.144 0.856 0.000 0 0.000
#> SRR805766 3 0.2300 0.927 0.000 0.144 0.856 0.000 0 0.000
#> SRR805767 3 0.2300 0.927 0.000 0.144 0.856 0.000 0 0.000
#> SRR805768 3 0.0000 0.940 0.000 0.000 1.000 0.000 0 0.000
#> SRR805769 1 0.0000 0.997 1.000 0.000 0.000 0.000 0 0.000
#> SRR805770 1 0.0260 0.996 0.992 0.008 0.000 0.000 0 0.000
#> SRR805771 1 0.0260 0.996 0.992 0.008 0.000 0.000 0 0.000
#> SRR805772 1 0.0000 0.997 1.000 0.000 0.000 0.000 0 0.000
#> SRR805773 1 0.0000 0.997 1.000 0.000 0.000 0.000 0 0.000
#> SRR805774 1 0.0000 0.997 1.000 0.000 0.000 0.000 0 0.000
#> SRR805775 1 0.0260 0.996 0.992 0.008 0.000 0.000 0 0.000
#> SRR805776 1 0.0260 0.996 0.992 0.008 0.000 0.000 0 0.000
#> SRR805777 1 0.0000 0.997 1.000 0.000 0.000 0.000 0 0.000
#> SRR805778 1 0.0260 0.996 0.992 0.008 0.000 0.000 0 0.000
#> SRR805779 1 0.0000 0.997 1.000 0.000 0.000 0.000 0 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14939 rows and 54 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 0.485 0.839 0.901 0.4603 0.516 0.516
#> 3 3 1.000 0.980 0.991 0.3592 0.818 0.661
#> 4 4 1.000 0.969 0.987 0.1624 0.875 0.679
#> 5 5 1.000 1.000 1.000 0.1187 0.908 0.669
#> 6 6 0.956 0.934 0.909 0.0282 0.976 0.869
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
#> SRR805725 2 0.000 0.916 0.000 1.000
#> SRR805726 2 0.000 0.916 0.000 1.000
#> SRR805727 2 0.000 0.916 0.000 1.000
#> SRR805728 2 0.000 0.916 0.000 1.000
#> SRR805729 2 0.000 0.916 0.000 1.000
#> SRR805730 2 0.000 0.916 0.000 1.000
#> SRR805731 2 0.000 0.916 0.000 1.000
#> SRR805732 2 0.000 0.916 0.000 1.000
#> SRR805733 2 0.000 0.916 0.000 1.000
#> SRR805735 2 0.000 0.916 0.000 1.000
#> SRR805736 2 0.000 0.916 0.000 1.000
#> SRR805737 2 0.000 0.916 0.000 1.000
#> SRR805738 2 0.000 0.916 0.000 1.000
#> SRR805739 2 0.000 0.916 0.000 1.000
#> SRR805740 2 0.000 0.916 0.000 1.000
#> SRR805741 2 0.000 0.916 0.000 1.000
#> SRR805742 2 0.000 0.916 0.000 1.000
#> SRR805743 2 0.000 0.916 0.000 1.000
#> SRR805744 2 0.000 0.916 0.000 1.000
#> SRR805745 2 0.000 0.916 0.000 1.000
#> SRR805746 2 0.000 0.916 0.000 1.000
#> SRR805747 1 0.722 0.898 0.800 0.200
#> SRR805748 1 0.767 0.872 0.776 0.224
#> SRR805749 1 0.714 0.901 0.804 0.196
#> SRR805750 1 0.975 0.540 0.592 0.408
#> SRR805751 2 0.000 0.916 0.000 1.000
#> SRR805752 2 0.000 0.916 0.000 1.000
#> SRR805753 2 0.000 0.916 0.000 1.000
#> SRR805754 2 0.781 0.601 0.232 0.768
#> SRR805755 2 0.163 0.895 0.024 0.976
#> SRR805756 2 0.921 0.344 0.336 0.664
#> SRR805757 2 0.949 0.240 0.368 0.632
#> SRR805758 1 0.000 0.809 1.000 0.000
#> SRR805759 1 0.000 0.809 1.000 0.000
#> SRR805760 1 0.000 0.809 1.000 0.000
#> SRR805761 1 0.000 0.809 1.000 0.000
#> SRR805762 1 0.000 0.809 1.000 0.000
#> SRR805763 2 0.714 0.740 0.196 0.804
#> SRR805764 2 0.714 0.740 0.196 0.804
#> SRR805765 2 0.714 0.740 0.196 0.804
#> SRR805766 2 0.714 0.740 0.196 0.804
#> SRR805767 2 0.998 0.315 0.472 0.528
#> SRR805768 1 0.000 0.809 1.000 0.000
#> SRR805769 1 0.714 0.901 0.804 0.196
#> SRR805770 1 0.714 0.901 0.804 0.196
#> SRR805771 1 0.653 0.891 0.832 0.168
#> SRR805772 1 0.714 0.901 0.804 0.196
#> SRR805773 1 0.714 0.901 0.804 0.196
#> SRR805774 1 0.714 0.901 0.804 0.196
#> SRR805775 1 0.714 0.901 0.804 0.196
#> SRR805776 1 0.714 0.901 0.804 0.196
#> SRR805777 1 0.714 0.901 0.804 0.196
#> SRR805778 1 0.714 0.901 0.804 0.196
#> SRR805779 1 0.714 0.901 0.804 0.196
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805726 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805727 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805728 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805729 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805730 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805731 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805732 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805733 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805735 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805736 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805737 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805738 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805739 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805740 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805741 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805742 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805743 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805744 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805745 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805746 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805747 1 0.2165 0.928 0.936 0.000 0.064
#> SRR805748 1 0.0237 0.981 0.996 0.004 0.000
#> SRR805749 1 0.0237 0.981 0.996 0.004 0.000
#> SRR805750 1 0.4295 0.841 0.864 0.104 0.032
#> SRR805751 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805752 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805753 2 0.0000 0.988 0.000 1.000 0.000
#> SRR805754 2 0.1860 0.944 0.052 0.948 0.000
#> SRR805755 2 0.1031 0.969 0.024 0.976 0.000
#> SRR805756 2 0.2448 0.921 0.076 0.924 0.000
#> SRR805757 2 0.3879 0.829 0.152 0.848 0.000
#> SRR805758 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805759 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805760 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805761 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805762 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805763 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805764 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805765 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805766 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805767 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805768 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805769 1 0.0000 0.984 1.000 0.000 0.000
#> SRR805770 1 0.0000 0.984 1.000 0.000 0.000
#> SRR805771 1 0.0000 0.984 1.000 0.000 0.000
#> SRR805772 1 0.0000 0.984 1.000 0.000 0.000
#> SRR805773 1 0.0000 0.984 1.000 0.000 0.000
#> SRR805774 1 0.0000 0.984 1.000 0.000 0.000
#> SRR805775 1 0.0000 0.984 1.000 0.000 0.000
#> SRR805776 1 0.0000 0.984 1.000 0.000 0.000
#> SRR805777 1 0.0000 0.984 1.000 0.000 0.000
#> SRR805778 1 0.0000 0.984 1.000 0.000 0.000
#> SRR805779 1 0.0000 0.984 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805726 2 0.2281 0.882 0 0.904 0 0.096
#> SRR805727 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805728 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805729 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805730 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805731 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805732 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805733 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805735 2 0.0188 0.965 0 0.996 0 0.004
#> SRR805736 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805737 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805738 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805739 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805740 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805741 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805742 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805743 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805744 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805745 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805746 2 0.0000 0.968 0 1.000 0 0.000
#> SRR805747 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805748 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805749 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805750 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805751 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805752 2 0.3074 0.819 0 0.848 0 0.152
#> SRR805753 2 0.4955 0.241 0 0.556 0 0.444
#> SRR805754 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805755 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805756 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805757 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805758 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805759 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805760 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805761 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805762 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805763 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805764 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805765 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805766 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805767 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805768 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805769 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805770 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805771 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805772 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805773 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805774 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805775 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805776 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805777 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805778 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805779 1 0.0000 1.000 1 0.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 2 0 1 0 1 0 0 0
#> SRR805726 2 0 1 0 1 0 0 0
#> SRR805727 2 0 1 0 1 0 0 0
#> SRR805728 2 0 1 0 1 0 0 0
#> SRR805729 2 0 1 0 1 0 0 0
#> SRR805730 2 0 1 0 1 0 0 0
#> SRR805731 2 0 1 0 1 0 0 0
#> SRR805732 2 0 1 0 1 0 0 0
#> SRR805733 2 0 1 0 1 0 0 0
#> SRR805735 2 0 1 0 1 0 0 0
#> SRR805736 5 0 1 0 0 0 0 1
#> SRR805737 5 0 1 0 0 0 0 1
#> SRR805738 5 0 1 0 0 0 0 1
#> SRR805739 5 0 1 0 0 0 0 1
#> SRR805740 5 0 1 0 0 0 0 1
#> SRR805741 5 0 1 0 0 0 0 1
#> SRR805742 5 0 1 0 0 0 0 1
#> SRR805743 5 0 1 0 0 0 0 1
#> SRR805744 5 0 1 0 0 0 0 1
#> SRR805745 5 0 1 0 0 0 0 1
#> SRR805746 5 0 1 0 0 0 0 1
#> SRR805747 4 0 1 0 0 0 1 0
#> SRR805748 4 0 1 0 0 0 1 0
#> SRR805749 4 0 1 0 0 0 1 0
#> SRR805750 4 0 1 0 0 0 1 0
#> SRR805751 4 0 1 0 0 0 1 0
#> SRR805752 2 0 1 0 1 0 0 0
#> SRR805753 2 0 1 0 1 0 0 0
#> SRR805754 4 0 1 0 0 0 1 0
#> SRR805755 4 0 1 0 0 0 1 0
#> SRR805756 4 0 1 0 0 0 1 0
#> SRR805757 4 0 1 0 0 0 1 0
#> SRR805758 3 0 1 0 0 1 0 0
#> SRR805759 3 0 1 0 0 1 0 0
#> SRR805760 3 0 1 0 0 1 0 0
#> SRR805761 3 0 1 0 0 1 0 0
#> SRR805762 3 0 1 0 0 1 0 0
#> SRR805763 3 0 1 0 0 1 0 0
#> SRR805764 3 0 1 0 0 1 0 0
#> SRR805765 3 0 1 0 0 1 0 0
#> SRR805766 3 0 1 0 0 1 0 0
#> SRR805767 3 0 1 0 0 1 0 0
#> SRR805768 3 0 1 0 0 1 0 0
#> SRR805769 1 0 1 1 0 0 0 0
#> SRR805770 1 0 1 1 0 0 0 0
#> SRR805771 1 0 1 1 0 0 0 0
#> SRR805772 1 0 1 1 0 0 0 0
#> SRR805773 1 0 1 1 0 0 0 0
#> SRR805774 1 0 1 1 0 0 0 0
#> SRR805775 1 0 1 1 0 0 0 0
#> SRR805776 1 0 1 1 0 0 0 0
#> SRR805777 1 0 1 1 0 0 0 0
#> SRR805778 1 0 1 1 0 0 0 0
#> SRR805779 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
#> SRR805725 2 0.000 0.932 0 1.000 0.000 0 0 0.000
#> SRR805726 2 0.000 0.932 0 1.000 0.000 0 0 0.000
#> SRR805727 2 0.000 0.932 0 1.000 0.000 0 0 0.000
#> SRR805728 2 0.000 0.932 0 1.000 0.000 0 0 0.000
#> SRR805729 2 0.000 0.932 0 1.000 0.000 0 0 0.000
#> SRR805730 2 0.285 0.358 0 0.792 0.000 0 0 0.208
#> SRR805731 6 0.386 1.000 0 0.468 0.000 0 0 0.532
#> SRR805732 6 0.386 1.000 0 0.468 0.000 0 0 0.532
#> SRR805733 6 0.386 1.000 0 0.468 0.000 0 0 0.532
#> SRR805735 2 0.000 0.932 0 1.000 0.000 0 0 0.000
#> SRR805736 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805737 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805738 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805739 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805740 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805741 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805742 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805743 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805744 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805745 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805746 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805747 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805748 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805749 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805750 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805751 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805752 6 0.386 1.000 0 0.468 0.000 0 0 0.532
#> SRR805753 6 0.386 1.000 0 0.468 0.000 0 0 0.532
#> SRR805754 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805755 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805756 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805757 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805758 3 0.000 0.794 0 0.000 1.000 0 0 0.000
#> SRR805759 3 0.000 0.794 0 0.000 1.000 0 0 0.000
#> SRR805760 3 0.000 0.794 0 0.000 1.000 0 0 0.000
#> SRR805761 3 0.000 0.794 0 0.000 1.000 0 0 0.000
#> SRR805762 3 0.000 0.794 0 0.000 1.000 0 0 0.000
#> SRR805763 3 0.386 0.746 0 0.000 0.532 0 0 0.468
#> SRR805764 3 0.386 0.746 0 0.000 0.532 0 0 0.468
#> SRR805765 3 0.386 0.746 0 0.000 0.532 0 0 0.468
#> SRR805766 3 0.386 0.746 0 0.000 0.532 0 0 0.468
#> SRR805767 3 0.386 0.746 0 0.000 0.532 0 0 0.468
#> SRR805768 3 0.000 0.794 0 0.000 1.000 0 0 0.000
#> SRR805769 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805770 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805771 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805772 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805773 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805774 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805775 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805776 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805777 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805778 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805779 1 0.000 1.000 1 0.000 0.000 0 0 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14939 rows and 54 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.279 0.692 0.820 0.4329 0.525 0.525
#> 3 3 0.663 0.800 0.825 0.4654 0.669 0.458
#> 4 4 1.000 0.984 0.985 0.1390 0.915 0.767
#> 5 5 1.000 1.000 1.000 0.1260 0.908 0.669
#> 6 6 0.946 0.933 0.909 0.0271 0.975 0.865
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 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
#> SRR805725 2 0.0000 0.815 0.000 1.000
#> SRR805726 2 0.0000 0.815 0.000 1.000
#> SRR805727 2 0.0000 0.815 0.000 1.000
#> SRR805728 2 0.1414 0.815 0.020 0.980
#> SRR805729 2 0.0376 0.817 0.004 0.996
#> SRR805730 2 0.2236 0.810 0.036 0.964
#> SRR805731 2 0.2236 0.810 0.036 0.964
#> SRR805732 2 0.2236 0.810 0.036 0.964
#> SRR805733 2 0.2236 0.810 0.036 0.964
#> SRR805735 2 0.0376 0.817 0.004 0.996
#> SRR805736 2 0.0938 0.820 0.012 0.988
#> SRR805737 2 0.0938 0.820 0.012 0.988
#> SRR805738 2 0.0938 0.820 0.012 0.988
#> SRR805739 2 0.0000 0.815 0.000 1.000
#> SRR805740 2 0.0938 0.820 0.012 0.988
#> SRR805741 2 0.0938 0.820 0.012 0.988
#> SRR805742 2 0.0938 0.820 0.012 0.988
#> SRR805743 2 0.0938 0.820 0.012 0.988
#> SRR805744 2 0.0938 0.820 0.012 0.988
#> SRR805745 2 0.0938 0.820 0.012 0.988
#> SRR805746 2 0.0938 0.820 0.012 0.988
#> SRR805747 1 0.9909 0.522 0.556 0.444
#> SRR805748 1 0.9909 0.522 0.556 0.444
#> SRR805749 1 0.9909 0.522 0.556 0.444
#> SRR805750 1 0.9909 0.522 0.556 0.444
#> SRR805751 1 0.9909 0.522 0.556 0.444
#> SRR805752 2 0.2236 0.810 0.036 0.964
#> SRR805753 2 0.2236 0.810 0.036 0.964
#> SRR805754 1 0.9909 0.522 0.556 0.444
#> SRR805755 1 0.9909 0.522 0.556 0.444
#> SRR805756 1 0.9909 0.522 0.556 0.444
#> SRR805757 1 0.9909 0.522 0.556 0.444
#> SRR805758 1 0.6438 0.661 0.836 0.164
#> SRR805759 1 0.6438 0.661 0.836 0.164
#> SRR805760 1 0.6438 0.661 0.836 0.164
#> SRR805761 1 0.6438 0.661 0.836 0.164
#> SRR805762 1 0.6438 0.661 0.836 0.164
#> SRR805763 1 0.6438 0.661 0.836 0.164
#> SRR805764 1 0.6438 0.661 0.836 0.164
#> SRR805765 1 0.6438 0.661 0.836 0.164
#> SRR805766 1 0.6438 0.661 0.836 0.164
#> SRR805767 1 0.6438 0.661 0.836 0.164
#> SRR805768 1 0.6438 0.661 0.836 0.164
#> SRR805769 2 0.8763 0.602 0.296 0.704
#> SRR805770 2 0.8763 0.602 0.296 0.704
#> SRR805771 2 0.8763 0.602 0.296 0.704
#> SRR805772 2 0.8763 0.602 0.296 0.704
#> SRR805773 2 0.8763 0.602 0.296 0.704
#> SRR805774 2 0.8763 0.602 0.296 0.704
#> SRR805775 2 0.8763 0.602 0.296 0.704
#> SRR805776 2 0.8763 0.602 0.296 0.704
#> SRR805777 2 0.8763 0.602 0.296 0.704
#> SRR805778 2 0.8763 0.602 0.296 0.704
#> SRR805779 2 0.8763 0.602 0.296 0.704
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.6685 0.765 0.244 0.708 0.048
#> SRR805726 2 0.6685 0.765 0.244 0.708 0.048
#> SRR805727 2 0.6685 0.765 0.244 0.708 0.048
#> SRR805728 2 0.6685 0.765 0.244 0.708 0.048
#> SRR805729 2 0.6685 0.765 0.244 0.708 0.048
#> SRR805730 2 0.6685 0.765 0.244 0.708 0.048
#> SRR805731 2 0.6685 0.765 0.244 0.708 0.048
#> SRR805732 2 0.6685 0.765 0.244 0.708 0.048
#> SRR805733 2 0.6685 0.765 0.244 0.708 0.048
#> SRR805735 2 0.6685 0.765 0.244 0.708 0.048
#> SRR805736 2 0.0237 0.783 0.000 0.996 0.004
#> SRR805737 2 0.0237 0.783 0.000 0.996 0.004
#> SRR805738 2 0.0237 0.783 0.000 0.996 0.004
#> SRR805739 2 0.1031 0.765 0.000 0.976 0.024
#> SRR805740 2 0.0237 0.783 0.000 0.996 0.004
#> SRR805741 2 0.0000 0.785 0.000 1.000 0.000
#> SRR805742 2 0.0000 0.785 0.000 1.000 0.000
#> SRR805743 2 0.0000 0.785 0.000 1.000 0.000
#> SRR805744 2 0.0000 0.785 0.000 1.000 0.000
#> SRR805745 2 0.0000 0.785 0.000 1.000 0.000
#> SRR805746 2 0.0000 0.785 0.000 1.000 0.000
#> SRR805747 1 0.2537 1.000 0.920 0.080 0.000
#> SRR805748 1 0.2537 1.000 0.920 0.080 0.000
#> SRR805749 1 0.2537 1.000 0.920 0.080 0.000
#> SRR805750 1 0.2537 1.000 0.920 0.080 0.000
#> SRR805751 1 0.2537 1.000 0.920 0.080 0.000
#> SRR805752 2 0.6379 0.756 0.256 0.712 0.032
#> SRR805753 2 0.6379 0.756 0.256 0.712 0.032
#> SRR805754 1 0.2537 1.000 0.920 0.080 0.000
#> SRR805755 1 0.2537 1.000 0.920 0.080 0.000
#> SRR805756 1 0.2537 1.000 0.920 0.080 0.000
#> SRR805757 1 0.2537 1.000 0.920 0.080 0.000
#> SRR805758 3 0.3816 0.746 0.148 0.000 0.852
#> SRR805759 3 0.3816 0.746 0.148 0.000 0.852
#> SRR805760 3 0.3816 0.746 0.148 0.000 0.852
#> SRR805761 3 0.3816 0.746 0.148 0.000 0.852
#> SRR805762 3 0.3816 0.746 0.148 0.000 0.852
#> SRR805763 3 0.3816 0.746 0.148 0.000 0.852
#> SRR805764 3 0.3816 0.746 0.148 0.000 0.852
#> SRR805765 3 0.3816 0.746 0.148 0.000 0.852
#> SRR805766 3 0.3816 0.746 0.148 0.000 0.852
#> SRR805767 3 0.3816 0.746 0.148 0.000 0.852
#> SRR805768 3 0.3816 0.746 0.148 0.000 0.852
#> SRR805769 3 0.5465 0.749 0.000 0.288 0.712
#> SRR805770 3 0.5465 0.749 0.000 0.288 0.712
#> SRR805771 3 0.5465 0.749 0.000 0.288 0.712
#> SRR805772 3 0.5465 0.749 0.000 0.288 0.712
#> SRR805773 3 0.5465 0.749 0.000 0.288 0.712
#> SRR805774 3 0.5465 0.749 0.000 0.288 0.712
#> SRR805775 3 0.5465 0.749 0.000 0.288 0.712
#> SRR805776 3 0.5465 0.749 0.000 0.288 0.712
#> SRR805777 3 0.5465 0.749 0.000 0.288 0.712
#> SRR805778 3 0.5465 0.749 0.000 0.288 0.712
#> SRR805779 3 0.5465 0.749 0.000 0.288 0.712
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.179 0.964 0 0.932 0 0.068
#> SRR805726 2 0.179 0.964 0 0.932 0 0.068
#> SRR805727 2 0.179 0.964 0 0.932 0 0.068
#> SRR805728 2 0.179 0.964 0 0.932 0 0.068
#> SRR805729 2 0.179 0.964 0 0.932 0 0.068
#> SRR805730 2 0.179 0.964 0 0.932 0 0.068
#> SRR805731 2 0.179 0.964 0 0.932 0 0.068
#> SRR805732 2 0.179 0.964 0 0.932 0 0.068
#> SRR805733 2 0.179 0.964 0 0.932 0 0.068
#> SRR805735 2 0.179 0.964 0 0.932 0 0.068
#> SRR805736 2 0.000 0.961 0 1.000 0 0.000
#> SRR805737 2 0.000 0.961 0 1.000 0 0.000
#> SRR805738 2 0.000 0.961 0 1.000 0 0.000
#> SRR805739 2 0.000 0.961 0 1.000 0 0.000
#> SRR805740 2 0.000 0.961 0 1.000 0 0.000
#> SRR805741 2 0.000 0.961 0 1.000 0 0.000
#> SRR805742 2 0.000 0.961 0 1.000 0 0.000
#> SRR805743 2 0.000 0.961 0 1.000 0 0.000
#> SRR805744 2 0.000 0.961 0 1.000 0 0.000
#> SRR805745 2 0.000 0.961 0 1.000 0 0.000
#> SRR805746 2 0.000 0.961 0 1.000 0 0.000
#> SRR805747 4 0.000 1.000 0 0.000 0 1.000
#> SRR805748 4 0.000 1.000 0 0.000 0 1.000
#> SRR805749 4 0.000 1.000 0 0.000 0 1.000
#> SRR805750 4 0.000 1.000 0 0.000 0 1.000
#> SRR805751 4 0.000 1.000 0 0.000 0 1.000
#> SRR805752 2 0.179 0.964 0 0.932 0 0.068
#> SRR805753 2 0.179 0.964 0 0.932 0 0.068
#> SRR805754 4 0.000 1.000 0 0.000 0 1.000
#> SRR805755 4 0.000 1.000 0 0.000 0 1.000
#> SRR805756 4 0.000 1.000 0 0.000 0 1.000
#> SRR805757 4 0.000 1.000 0 0.000 0 1.000
#> SRR805758 3 0.000 1.000 0 0.000 1 0.000
#> SRR805759 3 0.000 1.000 0 0.000 1 0.000
#> SRR805760 3 0.000 1.000 0 0.000 1 0.000
#> SRR805761 3 0.000 1.000 0 0.000 1 0.000
#> SRR805762 3 0.000 1.000 0 0.000 1 0.000
#> SRR805763 3 0.000 1.000 0 0.000 1 0.000
#> SRR805764 3 0.000 1.000 0 0.000 1 0.000
#> SRR805765 3 0.000 1.000 0 0.000 1 0.000
#> SRR805766 3 0.000 1.000 0 0.000 1 0.000
#> SRR805767 3 0.000 1.000 0 0.000 1 0.000
#> SRR805768 3 0.000 1.000 0 0.000 1 0.000
#> SRR805769 1 0.000 1.000 1 0.000 0 0.000
#> SRR805770 1 0.000 1.000 1 0.000 0 0.000
#> SRR805771 1 0.000 1.000 1 0.000 0 0.000
#> SRR805772 1 0.000 1.000 1 0.000 0 0.000
#> SRR805773 1 0.000 1.000 1 0.000 0 0.000
#> SRR805774 1 0.000 1.000 1 0.000 0 0.000
#> SRR805775 1 0.000 1.000 1 0.000 0 0.000
#> SRR805776 1 0.000 1.000 1 0.000 0 0.000
#> SRR805777 1 0.000 1.000 1 0.000 0 0.000
#> SRR805778 1 0.000 1.000 1 0.000 0 0.000
#> SRR805779 1 0.000 1.000 1 0.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 2 0 1 0 1 0 0 0
#> SRR805726 2 0 1 0 1 0 0 0
#> SRR805727 2 0 1 0 1 0 0 0
#> SRR805728 2 0 1 0 1 0 0 0
#> SRR805729 2 0 1 0 1 0 0 0
#> SRR805730 2 0 1 0 1 0 0 0
#> SRR805731 2 0 1 0 1 0 0 0
#> SRR805732 2 0 1 0 1 0 0 0
#> SRR805733 2 0 1 0 1 0 0 0
#> SRR805735 2 0 1 0 1 0 0 0
#> SRR805736 5 0 1 0 0 0 0 1
#> SRR805737 5 0 1 0 0 0 0 1
#> SRR805738 5 0 1 0 0 0 0 1
#> SRR805739 5 0 1 0 0 0 0 1
#> SRR805740 5 0 1 0 0 0 0 1
#> SRR805741 5 0 1 0 0 0 0 1
#> SRR805742 5 0 1 0 0 0 0 1
#> SRR805743 5 0 1 0 0 0 0 1
#> SRR805744 5 0 1 0 0 0 0 1
#> SRR805745 5 0 1 0 0 0 0 1
#> SRR805746 5 0 1 0 0 0 0 1
#> SRR805747 4 0 1 0 0 0 1 0
#> SRR805748 4 0 1 0 0 0 1 0
#> SRR805749 4 0 1 0 0 0 1 0
#> SRR805750 4 0 1 0 0 0 1 0
#> SRR805751 4 0 1 0 0 0 1 0
#> SRR805752 2 0 1 0 1 0 0 0
#> SRR805753 2 0 1 0 1 0 0 0
#> SRR805754 4 0 1 0 0 0 1 0
#> SRR805755 4 0 1 0 0 0 1 0
#> SRR805756 4 0 1 0 0 0 1 0
#> SRR805757 4 0 1 0 0 0 1 0
#> SRR805758 3 0 1 0 0 1 0 0
#> SRR805759 3 0 1 0 0 1 0 0
#> SRR805760 3 0 1 0 0 1 0 0
#> SRR805761 3 0 1 0 0 1 0 0
#> SRR805762 3 0 1 0 0 1 0 0
#> SRR805763 3 0 1 0 0 1 0 0
#> SRR805764 3 0 1 0 0 1 0 0
#> SRR805765 3 0 1 0 0 1 0 0
#> SRR805766 3 0 1 0 0 1 0 0
#> SRR805767 3 0 1 0 0 1 0 0
#> SRR805768 3 0 1 0 0 1 0 0
#> SRR805769 1 0 1 1 0 0 0 0
#> SRR805770 1 0 1 1 0 0 0 0
#> SRR805771 1 0 1 1 0 0 0 0
#> SRR805772 1 0 1 1 0 0 0 0
#> SRR805773 1 0 1 1 0 0 0 0
#> SRR805774 1 0 1 1 0 0 0 0
#> SRR805775 1 0 1 1 0 0 0 0
#> SRR805776 1 0 1 1 0 0 0 0
#> SRR805777 1 0 1 1 0 0 0 0
#> SRR805778 1 0 1 1 0 0 0 0
#> SRR805779 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
#> SRR805725 2 0.000 1.000 0.000 1.000 0.00 0 0.000 0.000
#> SRR805726 2 0.000 1.000 0.000 1.000 0.00 0 0.000 0.000
#> SRR805727 2 0.000 1.000 0.000 1.000 0.00 0 0.000 0.000
#> SRR805728 2 0.000 1.000 0.000 1.000 0.00 0 0.000 0.000
#> SRR805729 2 0.000 1.000 0.000 1.000 0.00 0 0.000 0.000
#> SRR805730 6 0.376 0.901 0.000 0.400 0.00 0 0.000 0.600
#> SRR805731 6 0.387 0.891 0.000 0.492 0.00 0 0.000 0.508
#> SRR805732 6 0.387 0.891 0.000 0.492 0.00 0 0.000 0.508
#> SRR805733 6 0.387 0.891 0.000 0.492 0.00 0 0.000 0.508
#> SRR805735 2 0.000 1.000 0.000 1.000 0.00 0 0.000 0.000
#> SRR805736 5 0.000 0.954 0.000 0.000 0.00 0 1.000 0.000
#> SRR805737 5 0.000 0.954 0.000 0.000 0.00 0 1.000 0.000
#> SRR805738 5 0.000 0.954 0.000 0.000 0.00 0 1.000 0.000
#> SRR805739 5 0.377 0.322 0.404 0.000 0.00 0 0.596 0.000
#> SRR805740 5 0.000 0.954 0.000 0.000 0.00 0 1.000 0.000
#> SRR805741 5 0.000 0.954 0.000 0.000 0.00 0 1.000 0.000
#> SRR805742 5 0.000 0.954 0.000 0.000 0.00 0 1.000 0.000
#> SRR805743 5 0.000 0.954 0.000 0.000 0.00 0 1.000 0.000
#> SRR805744 5 0.000 0.954 0.000 0.000 0.00 0 1.000 0.000
#> SRR805745 5 0.000 0.954 0.000 0.000 0.00 0 1.000 0.000
#> SRR805746 5 0.000 0.954 0.000 0.000 0.00 0 1.000 0.000
#> SRR805747 4 0.000 1.000 0.000 0.000 0.00 1 0.000 0.000
#> SRR805748 4 0.000 1.000 0.000 0.000 0.00 1 0.000 0.000
#> SRR805749 4 0.000 1.000 0.000 0.000 0.00 1 0.000 0.000
#> SRR805750 4 0.000 1.000 0.000 0.000 0.00 1 0.000 0.000
#> SRR805751 4 0.000 1.000 0.000 0.000 0.00 1 0.000 0.000
#> SRR805752 6 0.376 0.901 0.000 0.400 0.00 0 0.000 0.600
#> SRR805753 6 0.376 0.901 0.000 0.400 0.00 0 0.000 0.600
#> SRR805754 4 0.000 1.000 0.000 0.000 0.00 1 0.000 0.000
#> SRR805755 4 0.000 1.000 0.000 0.000 0.00 1 0.000 0.000
#> SRR805756 4 0.000 1.000 0.000 0.000 0.00 1 0.000 0.000
#> SRR805757 4 0.000 1.000 0.000 0.000 0.00 1 0.000 0.000
#> SRR805758 3 0.205 0.811 0.000 0.000 0.88 0 0.000 0.120
#> SRR805759 3 0.000 0.847 0.000 0.000 1.00 0 0.000 0.000
#> SRR805760 3 0.205 0.811 0.000 0.000 0.88 0 0.000 0.120
#> SRR805761 3 0.000 0.847 0.000 0.000 1.00 0 0.000 0.000
#> SRR805762 3 0.205 0.811 0.000 0.000 0.88 0 0.000 0.120
#> SRR805763 3 0.331 0.834 0.000 0.000 0.72 0 0.000 0.280
#> SRR805764 3 0.331 0.834 0.000 0.000 0.72 0 0.000 0.280
#> SRR805765 3 0.331 0.834 0.000 0.000 0.72 0 0.000 0.280
#> SRR805766 3 0.331 0.834 0.000 0.000 0.72 0 0.000 0.280
#> SRR805767 3 0.331 0.834 0.000 0.000 0.72 0 0.000 0.280
#> SRR805768 3 0.000 0.847 0.000 0.000 1.00 0 0.000 0.000
#> SRR805769 1 0.000 1.000 1.000 0.000 0.00 0 0.000 0.000
#> SRR805770 1 0.000 1.000 1.000 0.000 0.00 0 0.000 0.000
#> SRR805771 1 0.000 1.000 1.000 0.000 0.00 0 0.000 0.000
#> SRR805772 1 0.000 1.000 1.000 0.000 0.00 0 0.000 0.000
#> SRR805773 1 0.000 1.000 1.000 0.000 0.00 0 0.000 0.000
#> SRR805774 1 0.000 1.000 1.000 0.000 0.00 0 0.000 0.000
#> SRR805775 1 0.000 1.000 1.000 0.000 0.00 0 0.000 0.000
#> SRR805776 1 0.000 1.000 1.000 0.000 0.00 0 0.000 0.000
#> SRR805777 1 0.000 1.000 1.000 0.000 0.00 0 0.000 0.000
#> SRR805778 1 0.000 1.000 1.000 0.000 0.00 0 0.000 0.000
#> SRR805779 1 0.000 1.000 1.000 0.000 0.00 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 14939 rows and 54 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.813 0.890 0.956 0.5015 0.497 0.497
#> 3 3 0.911 0.912 0.963 0.2926 0.825 0.656
#> 4 4 0.780 0.825 0.854 0.1406 0.931 0.801
#> 5 5 1.000 0.992 0.996 0.1002 0.908 0.669
#> 6 6 1.000 0.977 0.990 0.0194 0.986 0.925
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 5
There is also optional best \(k\) = 3 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805725 2 0.0000 0.960 0.000 1.000
#> SRR805726 2 0.0000 0.960 0.000 1.000
#> SRR805727 2 0.0000 0.960 0.000 1.000
#> SRR805728 2 0.0000 0.960 0.000 1.000
#> SRR805729 2 0.0000 0.960 0.000 1.000
#> SRR805730 2 0.0000 0.960 0.000 1.000
#> SRR805731 2 0.0000 0.960 0.000 1.000
#> SRR805732 2 0.0000 0.960 0.000 1.000
#> SRR805733 2 0.0000 0.960 0.000 1.000
#> SRR805735 2 0.0000 0.960 0.000 1.000
#> SRR805736 2 0.0000 0.960 0.000 1.000
#> SRR805737 2 0.0000 0.960 0.000 1.000
#> SRR805738 2 0.0000 0.960 0.000 1.000
#> SRR805739 2 0.1633 0.940 0.024 0.976
#> SRR805740 2 0.0000 0.960 0.000 1.000
#> SRR805741 2 0.0000 0.960 0.000 1.000
#> SRR805742 2 0.0000 0.960 0.000 1.000
#> SRR805743 2 0.0000 0.960 0.000 1.000
#> SRR805744 2 0.0000 0.960 0.000 1.000
#> SRR805745 2 0.7883 0.678 0.236 0.764
#> SRR805746 2 0.6887 0.758 0.184 0.816
#> SRR805747 1 0.0000 0.941 1.000 0.000
#> SRR805748 1 0.0000 0.941 1.000 0.000
#> SRR805749 1 0.0000 0.941 1.000 0.000
#> SRR805750 1 0.0000 0.941 1.000 0.000
#> SRR805751 2 0.9635 0.332 0.388 0.612
#> SRR805752 2 0.0000 0.960 0.000 1.000
#> SRR805753 2 0.0000 0.960 0.000 1.000
#> SRR805754 1 0.9608 0.392 0.616 0.384
#> SRR805755 1 0.9686 0.360 0.604 0.396
#> SRR805756 1 0.9248 0.493 0.660 0.340
#> SRR805757 1 0.8955 0.549 0.688 0.312
#> SRR805758 1 0.0000 0.941 1.000 0.000
#> SRR805759 1 0.0000 0.941 1.000 0.000
#> SRR805760 1 0.0000 0.941 1.000 0.000
#> SRR805761 1 0.0000 0.941 1.000 0.000
#> SRR805762 1 0.0000 0.941 1.000 0.000
#> SRR805763 1 0.0000 0.941 1.000 0.000
#> SRR805764 1 0.5519 0.819 0.872 0.128
#> SRR805765 1 0.0376 0.938 0.996 0.004
#> SRR805766 1 0.0000 0.941 1.000 0.000
#> SRR805767 1 0.0000 0.941 1.000 0.000
#> SRR805768 1 0.0000 0.941 1.000 0.000
#> SRR805769 1 0.0000 0.941 1.000 0.000
#> SRR805770 1 0.0000 0.941 1.000 0.000
#> SRR805771 1 0.0000 0.941 1.000 0.000
#> SRR805772 1 0.0000 0.941 1.000 0.000
#> SRR805773 1 0.0000 0.941 1.000 0.000
#> SRR805774 1 0.0000 0.941 1.000 0.000
#> SRR805775 1 0.0000 0.941 1.000 0.000
#> SRR805776 1 0.0000 0.941 1.000 0.000
#> SRR805777 1 0.0000 0.941 1.000 0.000
#> SRR805778 1 0.0000 0.941 1.000 0.000
#> SRR805779 1 0.0000 0.941 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.0000 0.952 0.000 1.000 0.000
#> SRR805726 2 0.0237 0.951 0.004 0.996 0.000
#> SRR805727 2 0.0000 0.952 0.000 1.000 0.000
#> SRR805728 2 0.0000 0.952 0.000 1.000 0.000
#> SRR805729 2 0.0000 0.952 0.000 1.000 0.000
#> SRR805730 2 0.0237 0.950 0.000 0.996 0.004
#> SRR805731 2 0.0237 0.950 0.000 0.996 0.004
#> SRR805732 2 0.0237 0.950 0.000 0.996 0.004
#> SRR805733 2 0.0237 0.950 0.000 0.996 0.004
#> SRR805735 2 0.0000 0.952 0.000 1.000 0.000
#> SRR805736 2 0.1163 0.936 0.028 0.972 0.000
#> SRR805737 2 0.1163 0.936 0.028 0.972 0.000
#> SRR805738 2 0.0424 0.950 0.008 0.992 0.000
#> SRR805739 2 0.0892 0.942 0.020 0.980 0.000
#> SRR805740 2 0.0424 0.950 0.008 0.992 0.000
#> SRR805741 2 0.0424 0.950 0.008 0.992 0.000
#> SRR805742 2 0.0237 0.951 0.004 0.996 0.000
#> SRR805743 2 0.0000 0.952 0.000 1.000 0.000
#> SRR805744 2 0.0237 0.951 0.004 0.996 0.000
#> SRR805745 2 0.6244 0.159 0.440 0.560 0.000
#> SRR805746 2 0.6045 0.346 0.380 0.620 0.000
#> SRR805747 1 0.0237 0.937 0.996 0.004 0.000
#> SRR805748 1 0.0237 0.937 0.996 0.004 0.000
#> SRR805749 1 0.0237 0.937 0.996 0.004 0.000
#> SRR805750 1 0.0237 0.937 0.996 0.004 0.000
#> SRR805751 1 0.5591 0.593 0.696 0.304 0.000
#> SRR805752 2 0.0237 0.950 0.000 0.996 0.004
#> SRR805753 2 0.0237 0.950 0.000 0.996 0.004
#> SRR805754 1 0.4654 0.754 0.792 0.208 0.000
#> SRR805755 1 0.5138 0.688 0.748 0.252 0.000
#> SRR805756 1 0.3340 0.854 0.880 0.120 0.000
#> SRR805757 1 0.2448 0.890 0.924 0.076 0.000
#> SRR805758 3 0.0237 0.998 0.004 0.000 0.996
#> SRR805759 3 0.0237 0.998 0.004 0.000 0.996
#> SRR805760 3 0.0237 0.998 0.004 0.000 0.996
#> SRR805761 3 0.0237 0.998 0.004 0.000 0.996
#> SRR805762 3 0.0237 0.998 0.004 0.000 0.996
#> SRR805763 3 0.0000 0.997 0.000 0.000 1.000
#> SRR805764 3 0.0000 0.997 0.000 0.000 1.000
#> SRR805765 3 0.0000 0.997 0.000 0.000 1.000
#> SRR805766 3 0.0000 0.997 0.000 0.000 1.000
#> SRR805767 3 0.0237 0.998 0.004 0.000 0.996
#> SRR805768 3 0.0237 0.998 0.004 0.000 0.996
#> SRR805769 1 0.0237 0.937 0.996 0.000 0.004
#> SRR805770 1 0.0237 0.937 0.996 0.000 0.004
#> SRR805771 1 0.0424 0.935 0.992 0.000 0.008
#> SRR805772 1 0.0237 0.937 0.996 0.000 0.004
#> SRR805773 1 0.0000 0.937 1.000 0.000 0.000
#> SRR805774 1 0.0000 0.937 1.000 0.000 0.000
#> SRR805775 1 0.0237 0.937 0.996 0.000 0.004
#> SRR805776 1 0.0237 0.937 0.996 0.000 0.004
#> SRR805777 1 0.0237 0.937 0.996 0.000 0.004
#> SRR805778 1 0.0237 0.937 0.996 0.000 0.004
#> SRR805779 1 0.0237 0.937 0.996 0.000 0.004
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.4761 0.742 0.000 0.628 0.000 0.372
#> SRR805726 2 0.4720 0.746 0.004 0.672 0.000 0.324
#> SRR805727 2 0.4746 0.743 0.000 0.632 0.000 0.368
#> SRR805728 2 0.5125 0.740 0.004 0.616 0.004 0.376
#> SRR805729 2 0.4585 0.747 0.000 0.668 0.000 0.332
#> SRR805730 2 0.5125 0.740 0.004 0.616 0.004 0.376
#> SRR805731 2 0.5125 0.740 0.004 0.616 0.004 0.376
#> SRR805732 2 0.5125 0.740 0.004 0.616 0.004 0.376
#> SRR805733 2 0.5125 0.740 0.004 0.616 0.004 0.376
#> SRR805735 2 0.5125 0.740 0.004 0.616 0.004 0.376
#> SRR805736 2 0.0469 0.718 0.012 0.988 0.000 0.000
#> SRR805737 2 0.2408 0.656 0.104 0.896 0.000 0.000
#> SRR805738 2 0.0469 0.718 0.012 0.988 0.000 0.000
#> SRR805739 2 0.2868 0.627 0.136 0.864 0.000 0.000
#> SRR805740 2 0.0188 0.721 0.004 0.996 0.000 0.000
#> SRR805741 2 0.0336 0.720 0.008 0.992 0.000 0.000
#> SRR805742 2 0.0336 0.720 0.008 0.992 0.000 0.000
#> SRR805743 2 0.0000 0.721 0.000 1.000 0.000 0.000
#> SRR805744 2 0.0188 0.721 0.004 0.996 0.000 0.000
#> SRR805745 2 0.4746 0.237 0.368 0.632 0.000 0.000
#> SRR805746 2 0.4730 0.247 0.364 0.636 0.000 0.000
#> SRR805747 4 0.4776 0.724 0.376 0.000 0.000 0.624
#> SRR805748 4 0.4776 0.724 0.376 0.000 0.000 0.624
#> SRR805749 4 0.4776 0.724 0.376 0.000 0.000 0.624
#> SRR805750 4 0.4564 0.768 0.328 0.000 0.000 0.672
#> SRR805751 4 0.1940 0.730 0.076 0.000 0.000 0.924
#> SRR805752 2 0.5125 0.740 0.004 0.616 0.004 0.376
#> SRR805753 2 0.5125 0.740 0.004 0.616 0.004 0.376
#> SRR805754 4 0.3074 0.807 0.152 0.000 0.000 0.848
#> SRR805755 4 0.2973 0.801 0.144 0.000 0.000 0.856
#> SRR805756 4 0.3356 0.815 0.176 0.000 0.000 0.824
#> SRR805757 4 0.3726 0.816 0.212 0.000 0.000 0.788
#> SRR805758 3 0.0188 0.999 0.004 0.000 0.996 0.000
#> SRR805759 3 0.0188 0.999 0.004 0.000 0.996 0.000
#> SRR805760 3 0.0188 0.999 0.004 0.000 0.996 0.000
#> SRR805761 3 0.0188 0.999 0.004 0.000 0.996 0.000
#> SRR805762 3 0.0188 0.999 0.004 0.000 0.996 0.000
#> SRR805763 3 0.0188 0.999 0.004 0.000 0.996 0.000
#> SRR805764 3 0.0000 0.996 0.000 0.000 1.000 0.000
#> SRR805765 3 0.0000 0.996 0.000 0.000 1.000 0.000
#> SRR805766 3 0.0188 0.999 0.004 0.000 0.996 0.000
#> SRR805767 3 0.0188 0.999 0.004 0.000 0.996 0.000
#> SRR805768 3 0.0188 0.999 0.004 0.000 0.996 0.000
#> SRR805769 1 0.0336 0.997 0.992 0.000 0.008 0.000
#> SRR805770 1 0.0336 0.997 0.992 0.000 0.008 0.000
#> SRR805771 1 0.0469 0.992 0.988 0.000 0.012 0.000
#> SRR805772 1 0.0336 0.997 0.992 0.000 0.008 0.000
#> SRR805773 1 0.0376 0.987 0.992 0.000 0.004 0.004
#> SRR805774 1 0.0188 0.993 0.996 0.000 0.004 0.000
#> SRR805775 1 0.0336 0.997 0.992 0.000 0.008 0.000
#> SRR805776 1 0.0336 0.997 0.992 0.000 0.008 0.000
#> SRR805777 1 0.0336 0.997 0.992 0.000 0.008 0.000
#> SRR805778 1 0.0336 0.997 0.992 0.000 0.008 0.000
#> SRR805779 1 0.0336 0.997 0.992 0.000 0.008 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 2 0.0290 0.977 0 0.992 0 0.000 0.008
#> SRR805726 2 0.3224 0.805 0 0.824 0 0.016 0.160
#> SRR805727 2 0.0609 0.969 0 0.980 0 0.000 0.020
#> SRR805728 2 0.0000 0.980 0 1.000 0 0.000 0.000
#> SRR805729 2 0.0510 0.972 0 0.984 0 0.000 0.016
#> SRR805730 2 0.0000 0.980 0 1.000 0 0.000 0.000
#> SRR805731 2 0.0000 0.980 0 1.000 0 0.000 0.000
#> SRR805732 2 0.0000 0.980 0 1.000 0 0.000 0.000
#> SRR805733 2 0.0000 0.980 0 1.000 0 0.000 0.000
#> SRR805735 2 0.0000 0.980 0 1.000 0 0.000 0.000
#> SRR805736 5 0.0000 1.000 0 0.000 0 0.000 1.000
#> SRR805737 5 0.0000 1.000 0 0.000 0 0.000 1.000
#> SRR805738 5 0.0000 1.000 0 0.000 0 0.000 1.000
#> SRR805739 5 0.0000 1.000 0 0.000 0 0.000 1.000
#> SRR805740 5 0.0000 1.000 0 0.000 0 0.000 1.000
#> SRR805741 5 0.0000 1.000 0 0.000 0 0.000 1.000
#> SRR805742 5 0.0000 1.000 0 0.000 0 0.000 1.000
#> SRR805743 5 0.0000 1.000 0 0.000 0 0.000 1.000
#> SRR805744 5 0.0000 1.000 0 0.000 0 0.000 1.000
#> SRR805745 5 0.0000 1.000 0 0.000 0 0.000 1.000
#> SRR805746 5 0.0000 1.000 0 0.000 0 0.000 1.000
#> SRR805747 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805748 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805749 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805750 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805751 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805752 2 0.0000 0.980 0 1.000 0 0.000 0.000
#> SRR805753 2 0.0000 0.980 0 1.000 0 0.000 0.000
#> SRR805754 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805755 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805756 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805757 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805758 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805759 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805760 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805761 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805762 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805763 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805764 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805765 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805766 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805767 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805768 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805769 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805770 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805771 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805772 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805773 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805774 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805775 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805776 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805777 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805778 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805779 1 0.0000 1.000 1 0.000 0 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0.0146 0.946 0 0.996 0 0 0.004 0.000
#> SRR805726 2 0.0260 0.942 0 0.992 0 0 0.008 0.000
#> SRR805727 2 0.0146 0.946 0 0.996 0 0 0.004 0.000
#> SRR805728 2 0.0146 0.946 0 0.996 0 0 0.004 0.000
#> SRR805729 2 0.0146 0.946 0 0.996 0 0 0.004 0.000
#> SRR805730 2 0.0146 0.943 0 0.996 0 0 0.000 0.004
#> SRR805731 2 0.0260 0.941 0 0.992 0 0 0.000 0.008
#> SRR805732 2 0.3789 0.272 0 0.584 0 0 0.000 0.416
#> SRR805733 2 0.0458 0.936 0 0.984 0 0 0.000 0.016
#> SRR805735 2 0.0146 0.946 0 0.996 0 0 0.004 0.000
#> SRR805736 5 0.0000 1.000 0 0.000 0 0 1.000 0.000
#> SRR805737 5 0.0000 1.000 0 0.000 0 0 1.000 0.000
#> SRR805738 5 0.0000 1.000 0 0.000 0 0 1.000 0.000
#> SRR805739 5 0.0000 1.000 0 0.000 0 0 1.000 0.000
#> SRR805740 5 0.0000 1.000 0 0.000 0 0 1.000 0.000
#> SRR805741 5 0.0000 1.000 0 0.000 0 0 1.000 0.000
#> SRR805742 5 0.0000 1.000 0 0.000 0 0 1.000 0.000
#> SRR805743 5 0.0000 1.000 0 0.000 0 0 1.000 0.000
#> SRR805744 5 0.0000 1.000 0 0.000 0 0 1.000 0.000
#> SRR805745 5 0.0000 1.000 0 0.000 0 0 1.000 0.000
#> SRR805746 5 0.0000 1.000 0 0.000 0 0 1.000 0.000
#> SRR805747 4 0.0000 1.000 0 0.000 0 1 0.000 0.000
#> SRR805748 4 0.0000 1.000 0 0.000 0 1 0.000 0.000
#> SRR805749 4 0.0000 1.000 0 0.000 0 1 0.000 0.000
#> SRR805750 4 0.0000 1.000 0 0.000 0 1 0.000 0.000
#> SRR805751 4 0.0000 1.000 0 0.000 0 1 0.000 0.000
#> SRR805752 6 0.0547 1.000 0 0.020 0 0 0.000 0.980
#> SRR805753 6 0.0547 1.000 0 0.020 0 0 0.000 0.980
#> SRR805754 4 0.0000 1.000 0 0.000 0 1 0.000 0.000
#> SRR805755 4 0.0000 1.000 0 0.000 0 1 0.000 0.000
#> SRR805756 4 0.0000 1.000 0 0.000 0 1 0.000 0.000
#> SRR805757 4 0.0000 1.000 0 0.000 0 1 0.000 0.000
#> SRR805758 3 0.0000 1.000 0 0.000 1 0 0.000 0.000
#> SRR805759 3 0.0000 1.000 0 0.000 1 0 0.000 0.000
#> SRR805760 3 0.0000 1.000 0 0.000 1 0 0.000 0.000
#> SRR805761 3 0.0000 1.000 0 0.000 1 0 0.000 0.000
#> SRR805762 3 0.0000 1.000 0 0.000 1 0 0.000 0.000
#> SRR805763 3 0.0000 1.000 0 0.000 1 0 0.000 0.000
#> SRR805764 3 0.0000 1.000 0 0.000 1 0 0.000 0.000
#> SRR805765 3 0.0000 1.000 0 0.000 1 0 0.000 0.000
#> SRR805766 3 0.0000 1.000 0 0.000 1 0 0.000 0.000
#> SRR805767 3 0.0000 1.000 0 0.000 1 0 0.000 0.000
#> SRR805768 3 0.0000 1.000 0 0.000 1 0 0.000 0.000
#> SRR805769 1 0.0000 1.000 1 0.000 0 0 0.000 0.000
#> SRR805770 1 0.0000 1.000 1 0.000 0 0 0.000 0.000
#> SRR805771 1 0.0000 1.000 1 0.000 0 0 0.000 0.000
#> SRR805772 1 0.0000 1.000 1 0.000 0 0 0.000 0.000
#> SRR805773 1 0.0000 1.000 1 0.000 0 0 0.000 0.000
#> SRR805774 1 0.0000 1.000 1 0.000 0 0 0.000 0.000
#> SRR805775 1 0.0000 1.000 1 0.000 0 0 0.000 0.000
#> SRR805776 1 0.0000 1.000 1 0.000 0 0 0.000 0.000
#> SRR805777 1 0.0000 1.000 1 0.000 0 0 0.000 0.000
#> SRR805778 1 0.0000 1.000 1 0.000 0 0 0.000 0.000
#> SRR805779 1 0.0000 1.000 1 0.000 0 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "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 14939 rows and 54 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.456 0.587 0.843 0.4308 0.508 0.508
#> 3 3 0.786 0.963 0.974 0.4871 0.702 0.483
#> 4 4 1.000 0.999 0.997 0.1246 0.931 0.801
#> 5 5 1.000 1.000 1.000 0.0419 0.971 0.895
#> 6 6 0.917 0.931 0.955 0.0283 0.993 0.972
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 4
There is also optional best \(k\) = 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
#> SRR805725 2 0.000 0.8056 0.000 1.000
#> SRR805726 2 0.000 0.8056 0.000 1.000
#> SRR805727 2 0.000 0.8056 0.000 1.000
#> SRR805728 2 0.000 0.8056 0.000 1.000
#> SRR805729 2 0.000 0.8056 0.000 1.000
#> SRR805730 2 0.000 0.8056 0.000 1.000
#> SRR805731 2 0.000 0.8056 0.000 1.000
#> SRR805732 2 0.000 0.8056 0.000 1.000
#> SRR805733 2 0.000 0.8056 0.000 1.000
#> SRR805735 2 0.000 0.8056 0.000 1.000
#> SRR805736 2 0.000 0.8056 0.000 1.000
#> SRR805737 2 0.000 0.8056 0.000 1.000
#> SRR805738 2 0.000 0.8056 0.000 1.000
#> SRR805739 2 0.000 0.8056 0.000 1.000
#> SRR805740 2 0.000 0.8056 0.000 1.000
#> SRR805741 2 0.000 0.8056 0.000 1.000
#> SRR805742 2 0.000 0.8056 0.000 1.000
#> SRR805743 2 0.000 0.8056 0.000 1.000
#> SRR805744 2 0.000 0.8056 0.000 1.000
#> SRR805745 2 0.000 0.8056 0.000 1.000
#> SRR805746 2 0.000 0.8056 0.000 1.000
#> SRR805747 2 0.994 -0.0497 0.456 0.544
#> SRR805748 2 0.994 -0.0497 0.456 0.544
#> SRR805749 2 0.994 -0.0497 0.456 0.544
#> SRR805750 2 0.994 -0.0497 0.456 0.544
#> SRR805751 2 0.994 -0.0497 0.456 0.544
#> SRR805752 2 0.000 0.8056 0.000 1.000
#> SRR805753 2 0.000 0.8056 0.000 1.000
#> SRR805754 2 0.994 -0.0497 0.456 0.544
#> SRR805755 2 0.994 -0.0497 0.456 0.544
#> SRR805756 2 0.994 -0.0497 0.456 0.544
#> SRR805757 2 0.994 -0.0497 0.456 0.544
#> SRR805758 1 0.000 0.7069 1.000 0.000
#> SRR805759 1 0.000 0.7069 1.000 0.000
#> SRR805760 1 0.000 0.7069 1.000 0.000
#> SRR805761 1 0.000 0.7069 1.000 0.000
#> SRR805762 1 0.000 0.7069 1.000 0.000
#> SRR805763 1 0.000 0.7069 1.000 0.000
#> SRR805764 1 0.000 0.7069 1.000 0.000
#> SRR805765 1 0.000 0.7069 1.000 0.000
#> SRR805766 1 0.000 0.7069 1.000 0.000
#> SRR805767 1 0.000 0.7069 1.000 0.000
#> SRR805768 1 0.000 0.7069 1.000 0.000
#> SRR805769 1 0.971 0.5288 0.600 0.400
#> SRR805770 1 0.971 0.5288 0.600 0.400
#> SRR805771 1 0.971 0.5288 0.600 0.400
#> SRR805772 1 0.971 0.5288 0.600 0.400
#> SRR805773 1 0.971 0.5288 0.600 0.400
#> SRR805774 1 0.971 0.5288 0.600 0.400
#> SRR805775 1 0.971 0.5288 0.600 0.400
#> SRR805776 1 0.971 0.5288 0.600 0.400
#> SRR805777 1 0.971 0.5288 0.600 0.400
#> SRR805778 1 0.971 0.5288 0.600 0.400
#> SRR805779 1 0.971 0.5288 0.600 0.400
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.000 1.000 0.000 1.000 0
#> SRR805726 2 0.000 1.000 0.000 1.000 0
#> SRR805727 2 0.000 1.000 0.000 1.000 0
#> SRR805728 2 0.000 1.000 0.000 1.000 0
#> SRR805729 2 0.000 1.000 0.000 1.000 0
#> SRR805730 2 0.000 1.000 0.000 1.000 0
#> SRR805731 2 0.000 1.000 0.000 1.000 0
#> SRR805732 2 0.000 1.000 0.000 1.000 0
#> SRR805733 2 0.000 1.000 0.000 1.000 0
#> SRR805735 2 0.000 1.000 0.000 1.000 0
#> SRR805736 2 0.000 1.000 0.000 1.000 0
#> SRR805737 2 0.000 1.000 0.000 1.000 0
#> SRR805738 2 0.000 1.000 0.000 1.000 0
#> SRR805739 2 0.000 1.000 0.000 1.000 0
#> SRR805740 2 0.000 1.000 0.000 1.000 0
#> SRR805741 2 0.000 1.000 0.000 1.000 0
#> SRR805742 2 0.000 1.000 0.000 1.000 0
#> SRR805743 2 0.000 1.000 0.000 1.000 0
#> SRR805744 2 0.000 1.000 0.000 1.000 0
#> SRR805745 2 0.000 1.000 0.000 1.000 0
#> SRR805746 2 0.000 1.000 0.000 1.000 0
#> SRR805747 1 0.394 0.889 0.844 0.156 0
#> SRR805748 1 0.394 0.889 0.844 0.156 0
#> SRR805749 1 0.394 0.889 0.844 0.156 0
#> SRR805750 1 0.394 0.889 0.844 0.156 0
#> SRR805751 1 0.394 0.889 0.844 0.156 0
#> SRR805752 2 0.000 1.000 0.000 1.000 0
#> SRR805753 2 0.000 1.000 0.000 1.000 0
#> SRR805754 1 0.394 0.889 0.844 0.156 0
#> SRR805755 1 0.394 0.889 0.844 0.156 0
#> SRR805756 1 0.394 0.889 0.844 0.156 0
#> SRR805757 1 0.394 0.889 0.844 0.156 0
#> SRR805758 3 0.000 1.000 0.000 0.000 1
#> SRR805759 3 0.000 1.000 0.000 0.000 1
#> SRR805760 3 0.000 1.000 0.000 0.000 1
#> SRR805761 3 0.000 1.000 0.000 0.000 1
#> SRR805762 3 0.000 1.000 0.000 0.000 1
#> SRR805763 3 0.000 1.000 0.000 0.000 1
#> SRR805764 3 0.000 1.000 0.000 0.000 1
#> SRR805765 3 0.000 1.000 0.000 0.000 1
#> SRR805766 3 0.000 1.000 0.000 0.000 1
#> SRR805767 3 0.000 1.000 0.000 0.000 1
#> SRR805768 3 0.000 1.000 0.000 0.000 1
#> SRR805769 1 0.000 0.909 1.000 0.000 0
#> SRR805770 1 0.000 0.909 1.000 0.000 0
#> SRR805771 1 0.000 0.909 1.000 0.000 0
#> SRR805772 1 0.000 0.909 1.000 0.000 0
#> SRR805773 1 0.000 0.909 1.000 0.000 0
#> SRR805774 1 0.000 0.909 1.000 0.000 0
#> SRR805775 1 0.000 0.909 1.000 0.000 0
#> SRR805776 1 0.000 0.909 1.000 0.000 0
#> SRR805777 1 0.000 0.909 1.000 0.000 0
#> SRR805778 1 0.000 0.909 1.000 0.000 0
#> SRR805779 1 0.000 0.909 1.000 0.000 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805726 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805727 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805728 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805729 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805730 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805731 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805732 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805733 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805735 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805736 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805737 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805738 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805739 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805740 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805741 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805742 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805743 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805744 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805745 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805746 2 0.0000 0.999 0.000 1.000 0 0.000
#> SRR805747 4 0.0672 1.000 0.008 0.008 0 0.984
#> SRR805748 4 0.0672 1.000 0.008 0.008 0 0.984
#> SRR805749 4 0.0672 1.000 0.008 0.008 0 0.984
#> SRR805750 4 0.0672 1.000 0.008 0.008 0 0.984
#> SRR805751 4 0.0672 1.000 0.008 0.008 0 0.984
#> SRR805752 2 0.0592 0.986 0.000 0.984 0 0.016
#> SRR805753 2 0.0592 0.986 0.000 0.984 0 0.016
#> SRR805754 4 0.0672 1.000 0.008 0.008 0 0.984
#> SRR805755 4 0.0672 1.000 0.008 0.008 0 0.984
#> SRR805756 4 0.0672 1.000 0.008 0.008 0 0.984
#> SRR805757 4 0.0672 1.000 0.008 0.008 0 0.984
#> SRR805758 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805759 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805760 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805761 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805762 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805763 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805764 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805765 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805766 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805767 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805768 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805769 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805770 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805771 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805772 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805773 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805774 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805775 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805776 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805777 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805778 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805779 1 0.0000 1.000 1.000 0.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805726 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805727 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805728 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805729 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805730 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805731 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805732 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805733 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805735 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805736 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805737 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805738 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805739 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805740 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805741 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805742 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805743 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805744 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805745 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805746 5 0.0000 1.000 0 0.000 0.000 0 1.000
#> SRR805747 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805748 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805749 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805750 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805751 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805752 2 0.0162 1.000 0 0.996 0.000 0 0.004
#> SRR805753 2 0.0162 1.000 0 0.996 0.000 0 0.004
#> SRR805754 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805755 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805756 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805757 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805758 3 0.0162 0.996 0 0.004 0.996 0 0.000
#> SRR805759 3 0.0000 1.000 0 0.000 1.000 0 0.000
#> SRR805760 3 0.0000 1.000 0 0.000 1.000 0 0.000
#> SRR805761 3 0.0000 1.000 0 0.000 1.000 0 0.000
#> SRR805762 3 0.0000 1.000 0 0.000 1.000 0 0.000
#> SRR805763 3 0.0000 1.000 0 0.000 1.000 0 0.000
#> SRR805764 3 0.0000 1.000 0 0.000 1.000 0 0.000
#> SRR805765 3 0.0000 1.000 0 0.000 1.000 0 0.000
#> SRR805766 3 0.0000 1.000 0 0.000 1.000 0 0.000
#> SRR805767 3 0.0000 1.000 0 0.000 1.000 0 0.000
#> SRR805768 3 0.0000 1.000 0 0.000 1.000 0 0.000
#> SRR805769 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805770 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805771 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805772 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805773 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805774 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805775 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805776 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805777 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805778 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805779 1 0.0000 1.000 1 0.000 0.000 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 5 0.2664 0.893 0 0.000 0.000 0 0.816 0.184
#> SRR805726 5 0.2664 0.893 0 0.000 0.000 0 0.816 0.184
#> SRR805727 5 0.2664 0.893 0 0.000 0.000 0 0.816 0.184
#> SRR805728 5 0.2664 0.893 0 0.000 0.000 0 0.816 0.184
#> SRR805729 5 0.2664 0.893 0 0.000 0.000 0 0.816 0.184
#> SRR805730 5 0.2664 0.893 0 0.000 0.000 0 0.816 0.184
#> SRR805731 5 0.2664 0.893 0 0.000 0.000 0 0.816 0.184
#> SRR805732 5 0.2664 0.893 0 0.000 0.000 0 0.816 0.184
#> SRR805733 5 0.2664 0.893 0 0.000 0.000 0 0.816 0.184
#> SRR805735 5 0.2664 0.893 0 0.000 0.000 0 0.816 0.184
#> SRR805736 5 0.0000 0.904 0 0.000 0.000 0 1.000 0.000
#> SRR805737 5 0.0000 0.904 0 0.000 0.000 0 1.000 0.000
#> SRR805738 5 0.0000 0.904 0 0.000 0.000 0 1.000 0.000
#> SRR805739 5 0.0000 0.904 0 0.000 0.000 0 1.000 0.000
#> SRR805740 5 0.0000 0.904 0 0.000 0.000 0 1.000 0.000
#> SRR805741 5 0.0000 0.904 0 0.000 0.000 0 1.000 0.000
#> SRR805742 5 0.0000 0.904 0 0.000 0.000 0 1.000 0.000
#> SRR805743 5 0.0000 0.904 0 0.000 0.000 0 1.000 0.000
#> SRR805744 5 0.0000 0.904 0 0.000 0.000 0 1.000 0.000
#> SRR805745 5 0.0000 0.904 0 0.000 0.000 0 1.000 0.000
#> SRR805746 5 0.0000 0.904 0 0.000 0.000 0 1.000 0.000
#> SRR805747 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805748 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805749 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805750 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805751 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805752 6 0.2664 1.000 0 0.184 0.000 0 0.000 0.816
#> SRR805753 6 0.2664 1.000 0 0.184 0.000 0 0.000 0.816
#> SRR805754 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805755 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805756 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805757 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR805758 2 0.2730 0.000 0 0.808 0.192 0 0.000 0.000
#> SRR805759 3 0.1387 0.934 0 0.068 0.932 0 0.000 0.000
#> SRR805760 3 0.1387 0.935 0 0.068 0.932 0 0.000 0.000
#> SRR805761 3 0.0146 0.948 0 0.004 0.996 0 0.000 0.000
#> SRR805762 3 0.1501 0.929 0 0.076 0.924 0 0.000 0.000
#> SRR805763 3 0.0260 0.947 0 0.008 0.992 0 0.000 0.000
#> SRR805764 3 0.0260 0.947 0 0.008 0.992 0 0.000 0.000
#> SRR805765 3 0.0260 0.947 0 0.008 0.992 0 0.000 0.000
#> SRR805766 3 0.0260 0.947 0 0.008 0.992 0 0.000 0.000
#> SRR805767 3 0.1327 0.914 0 0.064 0.936 0 0.000 0.000
#> SRR805768 3 0.1501 0.929 0 0.076 0.924 0 0.000 0.000
#> SRR805769 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805770 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805771 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805772 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805773 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805774 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805775 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805776 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805777 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805778 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR805779 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "kmeans"]
# you can also extract it by
# res = res_list["CV:kmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 14939 rows and 54 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 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.466 0.722 0.859 0.4173 0.516 0.516
#> 3 3 0.504 0.706 0.793 0.4670 0.693 0.475
#> 4 4 0.589 0.781 0.714 0.1714 0.909 0.744
#> 5 5 0.895 0.948 0.867 0.0922 0.901 0.645
#> 6 6 0.860 0.906 0.872 0.0404 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] 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
#> SRR805725 2 0.141 0.898 0.020 0.980
#> SRR805726 2 0.141 0.898 0.020 0.980
#> SRR805727 2 0.141 0.898 0.020 0.980
#> SRR805728 2 0.141 0.898 0.020 0.980
#> SRR805729 2 0.141 0.898 0.020 0.980
#> SRR805730 2 0.141 0.898 0.020 0.980
#> SRR805731 2 0.141 0.898 0.020 0.980
#> SRR805732 2 0.141 0.898 0.020 0.980
#> SRR805733 2 0.141 0.898 0.020 0.980
#> SRR805735 2 0.141 0.898 0.020 0.980
#> SRR805736 2 0.000 0.898 0.000 1.000
#> SRR805737 2 0.000 0.898 0.000 1.000
#> SRR805738 2 0.000 0.898 0.000 1.000
#> SRR805739 2 0.000 0.898 0.000 1.000
#> SRR805740 2 0.000 0.898 0.000 1.000
#> SRR805741 2 0.000 0.898 0.000 1.000
#> SRR805742 2 0.000 0.898 0.000 1.000
#> SRR805743 2 0.000 0.898 0.000 1.000
#> SRR805744 2 0.000 0.898 0.000 1.000
#> SRR805745 2 0.000 0.898 0.000 1.000
#> SRR805746 2 0.000 0.898 0.000 1.000
#> SRR805747 2 0.730 0.750 0.204 0.796
#> SRR805748 2 0.730 0.750 0.204 0.796
#> SRR805749 2 0.689 0.781 0.184 0.816
#> SRR805750 2 0.689 0.781 0.184 0.816
#> SRR805751 2 0.689 0.781 0.184 0.816
#> SRR805752 2 0.260 0.883 0.044 0.956
#> SRR805753 2 0.260 0.883 0.044 0.956
#> SRR805754 2 0.689 0.781 0.184 0.816
#> SRR805755 2 0.689 0.781 0.184 0.816
#> SRR805756 2 0.689 0.781 0.184 0.816
#> SRR805757 2 0.689 0.781 0.184 0.816
#> SRR805758 1 0.204 0.703 0.968 0.032
#> SRR805759 1 0.204 0.703 0.968 0.032
#> SRR805760 1 0.204 0.703 0.968 0.032
#> SRR805761 1 0.204 0.703 0.968 0.032
#> SRR805762 1 0.204 0.703 0.968 0.032
#> SRR805763 1 0.204 0.703 0.968 0.032
#> SRR805764 1 0.204 0.703 0.968 0.032
#> SRR805765 1 0.204 0.703 0.968 0.032
#> SRR805766 1 0.204 0.703 0.968 0.032
#> SRR805767 1 0.204 0.703 0.968 0.032
#> SRR805768 1 0.204 0.703 0.968 0.032
#> SRR805769 1 1.000 0.410 0.508 0.492
#> SRR805770 1 1.000 0.410 0.508 0.492
#> SRR805771 1 1.000 0.410 0.508 0.492
#> SRR805772 1 1.000 0.410 0.508 0.492
#> SRR805773 1 1.000 0.410 0.508 0.492
#> SRR805774 1 1.000 0.410 0.508 0.492
#> SRR805775 1 1.000 0.410 0.508 0.492
#> SRR805776 2 1.000 -0.417 0.496 0.504
#> SRR805777 1 1.000 0.410 0.508 0.492
#> SRR805778 1 1.000 0.410 0.508 0.492
#> SRR805779 1 1.000 0.410 0.508 0.492
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.0237 0.801 0.000 0.996 0.004
#> SRR805726 2 0.0237 0.801 0.000 0.996 0.004
#> SRR805727 2 0.0237 0.801 0.000 0.996 0.004
#> SRR805728 2 0.0237 0.801 0.000 0.996 0.004
#> SRR805729 2 0.0237 0.801 0.000 0.996 0.004
#> SRR805730 2 0.0237 0.801 0.000 0.996 0.004
#> SRR805731 2 0.0237 0.801 0.000 0.996 0.004
#> SRR805732 2 0.0237 0.801 0.000 0.996 0.004
#> SRR805733 2 0.0237 0.801 0.000 0.996 0.004
#> SRR805735 2 0.0237 0.801 0.000 0.996 0.004
#> SRR805736 2 0.5397 0.777 0.280 0.720 0.000
#> SRR805737 2 0.5397 0.777 0.280 0.720 0.000
#> SRR805738 2 0.5397 0.777 0.280 0.720 0.000
#> SRR805739 2 0.5397 0.777 0.280 0.720 0.000
#> SRR805740 2 0.5397 0.777 0.280 0.720 0.000
#> SRR805741 2 0.5397 0.777 0.280 0.720 0.000
#> SRR805742 2 0.5397 0.777 0.280 0.720 0.000
#> SRR805743 2 0.5397 0.777 0.280 0.720 0.000
#> SRR805744 2 0.5397 0.777 0.280 0.720 0.000
#> SRR805745 2 0.5397 0.777 0.280 0.720 0.000
#> SRR805746 2 0.5397 0.777 0.280 0.720 0.000
#> SRR805747 1 0.7422 0.425 0.608 0.344 0.048
#> SRR805748 1 0.7422 0.425 0.608 0.344 0.048
#> SRR805749 1 0.7660 0.351 0.548 0.404 0.048
#> SRR805750 1 0.7681 0.338 0.540 0.412 0.048
#> SRR805751 1 0.7758 0.229 0.484 0.468 0.048
#> SRR805752 2 0.2878 0.708 0.096 0.904 0.000
#> SRR805753 2 0.3267 0.683 0.116 0.884 0.000
#> SRR805754 1 0.7758 0.229 0.484 0.468 0.048
#> SRR805755 1 0.7758 0.229 0.484 0.468 0.048
#> SRR805756 1 0.7758 0.229 0.484 0.468 0.048
#> SRR805757 1 0.7758 0.229 0.484 0.468 0.048
#> SRR805758 3 0.0000 0.981 0.000 0.000 1.000
#> SRR805759 3 0.0000 0.981 0.000 0.000 1.000
#> SRR805760 3 0.0000 0.981 0.000 0.000 1.000
#> SRR805761 3 0.0000 0.981 0.000 0.000 1.000
#> SRR805762 3 0.0000 0.981 0.000 0.000 1.000
#> SRR805763 3 0.1753 0.977 0.048 0.000 0.952
#> SRR805764 3 0.1753 0.977 0.048 0.000 0.952
#> SRR805765 3 0.1753 0.977 0.048 0.000 0.952
#> SRR805766 3 0.1753 0.977 0.048 0.000 0.952
#> SRR805767 3 0.1753 0.977 0.048 0.000 0.952
#> SRR805768 3 0.0000 0.981 0.000 0.000 1.000
#> SRR805769 1 0.7533 0.612 0.668 0.088 0.244
#> SRR805770 1 0.7533 0.612 0.668 0.088 0.244
#> SRR805771 1 0.7533 0.612 0.668 0.088 0.244
#> SRR805772 1 0.7533 0.612 0.668 0.088 0.244
#> SRR805773 1 0.7533 0.612 0.668 0.088 0.244
#> SRR805774 1 0.7533 0.612 0.668 0.088 0.244
#> SRR805775 1 0.7533 0.612 0.668 0.088 0.244
#> SRR805776 1 0.7569 0.612 0.668 0.092 0.240
#> SRR805777 1 0.7533 0.612 0.668 0.088 0.244
#> SRR805778 1 0.7533 0.612 0.668 0.088 0.244
#> SRR805779 1 0.7533 0.612 0.668 0.088 0.244
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.6634 0.593 0.312 0.580 0.000 0.108
#> SRR805726 2 0.6634 0.593 0.312 0.580 0.000 0.108
#> SRR805727 2 0.6634 0.593 0.312 0.580 0.000 0.108
#> SRR805728 2 0.6634 0.593 0.312 0.580 0.000 0.108
#> SRR805729 2 0.6634 0.593 0.312 0.580 0.000 0.108
#> SRR805730 2 0.6634 0.593 0.312 0.580 0.000 0.108
#> SRR805731 2 0.6634 0.593 0.312 0.580 0.000 0.108
#> SRR805732 2 0.6652 0.592 0.316 0.576 0.000 0.108
#> SRR805733 2 0.6652 0.592 0.316 0.576 0.000 0.108
#> SRR805735 2 0.6634 0.593 0.312 0.580 0.000 0.108
#> SRR805736 2 0.2973 0.603 0.000 0.856 0.000 0.144
#> SRR805737 2 0.2973 0.603 0.000 0.856 0.000 0.144
#> SRR805738 2 0.2973 0.603 0.000 0.856 0.000 0.144
#> SRR805739 2 0.2973 0.603 0.000 0.856 0.000 0.144
#> SRR805740 2 0.2973 0.603 0.000 0.856 0.000 0.144
#> SRR805741 2 0.2973 0.603 0.000 0.856 0.000 0.144
#> SRR805742 2 0.2973 0.603 0.000 0.856 0.000 0.144
#> SRR805743 2 0.2973 0.603 0.000 0.856 0.000 0.144
#> SRR805744 2 0.2973 0.603 0.000 0.856 0.000 0.144
#> SRR805745 2 0.2973 0.603 0.000 0.856 0.000 0.144
#> SRR805746 2 0.2973 0.603 0.000 0.856 0.000 0.144
#> SRR805747 4 0.2604 0.889 0.016 0.056 0.012 0.916
#> SRR805748 4 0.2604 0.889 0.016 0.056 0.012 0.916
#> SRR805749 4 0.2563 0.894 0.012 0.060 0.012 0.916
#> SRR805750 4 0.2563 0.894 0.012 0.060 0.012 0.916
#> SRR805751 4 0.2402 0.900 0.000 0.076 0.012 0.912
#> SRR805752 2 0.7792 0.347 0.324 0.416 0.000 0.260
#> SRR805753 4 0.7916 -0.228 0.316 0.328 0.000 0.356
#> SRR805754 4 0.2402 0.900 0.000 0.076 0.012 0.912
#> SRR805755 4 0.2402 0.900 0.000 0.076 0.012 0.912
#> SRR805756 4 0.2402 0.900 0.000 0.076 0.012 0.912
#> SRR805757 4 0.2402 0.900 0.000 0.076 0.012 0.912
#> SRR805758 3 0.0657 0.955 0.004 0.000 0.984 0.012
#> SRR805759 3 0.0188 0.955 0.000 0.000 0.996 0.004
#> SRR805760 3 0.0657 0.953 0.012 0.000 0.984 0.004
#> SRR805761 3 0.0657 0.953 0.012 0.000 0.984 0.004
#> SRR805762 3 0.0188 0.955 0.000 0.000 0.996 0.004
#> SRR805763 3 0.3004 0.946 0.060 0.000 0.892 0.048
#> SRR805764 3 0.3164 0.944 0.064 0.000 0.884 0.052
#> SRR805765 3 0.3004 0.945 0.060 0.000 0.892 0.048
#> SRR805766 3 0.3004 0.945 0.060 0.000 0.892 0.048
#> SRR805767 3 0.2660 0.949 0.056 0.000 0.908 0.036
#> SRR805768 3 0.0188 0.955 0.000 0.000 0.996 0.004
#> SRR805769 1 0.7714 0.996 0.596 0.064 0.116 0.224
#> SRR805770 1 0.7714 0.997 0.596 0.064 0.116 0.224
#> SRR805771 1 0.7742 0.996 0.592 0.064 0.116 0.228
#> SRR805772 1 0.7685 0.997 0.600 0.064 0.116 0.220
#> SRR805773 1 0.7685 0.997 0.600 0.064 0.116 0.220
#> SRR805774 1 0.7685 0.997 0.600 0.064 0.116 0.220
#> SRR805775 1 0.7714 0.997 0.596 0.064 0.116 0.224
#> SRR805776 1 0.7714 0.997 0.596 0.064 0.116 0.224
#> SRR805777 1 0.7685 0.997 0.600 0.064 0.116 0.220
#> SRR805778 1 0.7742 0.996 0.592 0.064 0.116 0.228
#> SRR805779 1 0.7685 0.997 0.600 0.064 0.116 0.220
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 2 0.4382 0.941 0.000 0.700 0.004 0.020 0.276
#> SRR805726 2 0.4382 0.941 0.000 0.700 0.004 0.020 0.276
#> SRR805727 2 0.4382 0.941 0.000 0.700 0.004 0.020 0.276
#> SRR805728 2 0.4382 0.941 0.000 0.700 0.004 0.020 0.276
#> SRR805729 2 0.4382 0.941 0.000 0.700 0.004 0.020 0.276
#> SRR805730 2 0.4382 0.941 0.000 0.700 0.004 0.020 0.276
#> SRR805731 2 0.4229 0.939 0.000 0.704 0.000 0.020 0.276
#> SRR805732 2 0.4315 0.938 0.000 0.700 0.000 0.024 0.276
#> SRR805733 2 0.4315 0.938 0.000 0.700 0.000 0.024 0.276
#> SRR805735 2 0.4382 0.941 0.000 0.700 0.004 0.020 0.276
#> SRR805736 5 0.0000 0.998 0.000 0.000 0.000 0.000 1.000
#> SRR805737 5 0.0000 0.998 0.000 0.000 0.000 0.000 1.000
#> SRR805738 5 0.0000 0.998 0.000 0.000 0.000 0.000 1.000
#> SRR805739 5 0.0000 0.998 0.000 0.000 0.000 0.000 1.000
#> SRR805740 5 0.0000 0.998 0.000 0.000 0.000 0.000 1.000
#> SRR805741 5 0.0000 0.998 0.000 0.000 0.000 0.000 1.000
#> SRR805742 5 0.0162 0.998 0.000 0.000 0.000 0.004 0.996
#> SRR805743 5 0.0162 0.998 0.000 0.000 0.000 0.004 0.996
#> SRR805744 5 0.0162 0.998 0.000 0.000 0.000 0.004 0.996
#> SRR805745 5 0.0162 0.998 0.000 0.000 0.000 0.004 0.996
#> SRR805746 5 0.0162 0.998 0.000 0.000 0.000 0.004 0.996
#> SRR805747 4 0.3437 0.971 0.072 0.016 0.004 0.860 0.048
#> SRR805748 4 0.3437 0.971 0.072 0.016 0.004 0.860 0.048
#> SRR805749 4 0.3437 0.971 0.072 0.016 0.004 0.860 0.048
#> SRR805750 4 0.3099 0.974 0.072 0.004 0.004 0.872 0.048
#> SRR805751 4 0.3825 0.979 0.064 0.040 0.004 0.844 0.048
#> SRR805752 2 0.5979 0.777 0.040 0.664 0.000 0.124 0.172
#> SRR805753 2 0.6520 0.589 0.040 0.580 0.000 0.260 0.120
#> SRR805754 4 0.3825 0.979 0.064 0.040 0.004 0.844 0.048
#> SRR805755 4 0.3825 0.979 0.064 0.040 0.004 0.844 0.048
#> SRR805756 4 0.3825 0.979 0.064 0.040 0.004 0.844 0.048
#> SRR805757 4 0.3825 0.979 0.064 0.040 0.004 0.844 0.048
#> SRR805758 3 0.4402 0.907 0.020 0.148 0.780 0.052 0.000
#> SRR805759 3 0.4166 0.909 0.012 0.144 0.792 0.052 0.000
#> SRR805760 3 0.4440 0.906 0.016 0.148 0.776 0.060 0.000
#> SRR805761 3 0.4440 0.906 0.016 0.148 0.776 0.060 0.000
#> SRR805762 3 0.4166 0.909 0.012 0.144 0.792 0.052 0.000
#> SRR805763 3 0.0671 0.889 0.000 0.004 0.980 0.016 0.000
#> SRR805764 3 0.1173 0.886 0.004 0.012 0.964 0.020 0.000
#> SRR805765 3 0.0693 0.889 0.000 0.012 0.980 0.008 0.000
#> SRR805766 3 0.0693 0.889 0.000 0.012 0.980 0.008 0.000
#> SRR805767 3 0.0854 0.893 0.004 0.012 0.976 0.008 0.000
#> SRR805768 3 0.4166 0.909 0.012 0.144 0.792 0.052 0.000
#> SRR805769 1 0.2765 0.970 0.896 0.036 0.044 0.000 0.024
#> SRR805770 1 0.2924 0.979 0.892 0.036 0.044 0.004 0.024
#> SRR805771 1 0.3425 0.967 0.864 0.064 0.044 0.004 0.024
#> SRR805772 1 0.1818 0.982 0.932 0.000 0.044 0.000 0.024
#> SRR805773 1 0.1818 0.982 0.932 0.000 0.044 0.000 0.024
#> SRR805774 1 0.2217 0.982 0.920 0.012 0.044 0.000 0.024
#> SRR805775 1 0.2843 0.979 0.896 0.032 0.044 0.004 0.024
#> SRR805776 1 0.2843 0.979 0.896 0.032 0.044 0.004 0.024
#> SRR805777 1 0.1818 0.982 0.932 0.000 0.044 0.000 0.024
#> SRR805778 1 0.2843 0.979 0.896 0.032 0.044 0.004 0.024
#> SRR805779 1 0.1818 0.982 0.932 0.000 0.044 0.000 0.024
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0.2454 0.900 0.000 0.840 0.000 0.000 0.160 0.000
#> SRR805726 2 0.2454 0.900 0.000 0.840 0.000 0.000 0.160 0.000
#> SRR805727 2 0.2454 0.900 0.000 0.840 0.000 0.000 0.160 0.000
#> SRR805728 2 0.2454 0.900 0.000 0.840 0.000 0.000 0.160 0.000
#> SRR805729 2 0.2454 0.900 0.000 0.840 0.000 0.000 0.160 0.000
#> SRR805730 2 0.3099 0.896 0.004 0.820 0.008 0.008 0.160 0.000
#> SRR805731 2 0.3099 0.896 0.004 0.820 0.008 0.008 0.160 0.000
#> SRR805732 2 0.4021 0.882 0.004 0.780 0.008 0.012 0.160 0.036
#> SRR805733 2 0.4021 0.882 0.004 0.780 0.008 0.012 0.160 0.036
#> SRR805735 2 0.2454 0.900 0.000 0.840 0.000 0.000 0.160 0.000
#> SRR805736 5 0.0547 0.975 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR805737 5 0.0547 0.975 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR805738 5 0.0547 0.975 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR805739 5 0.0547 0.975 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR805740 5 0.0547 0.975 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR805741 5 0.0000 0.976 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR805742 5 0.0790 0.974 0.000 0.000 0.000 0.000 0.968 0.032
#> SRR805743 5 0.0790 0.974 0.000 0.000 0.000 0.000 0.968 0.032
#> SRR805744 5 0.0790 0.974 0.000 0.000 0.000 0.000 0.968 0.032
#> SRR805745 5 0.0937 0.971 0.000 0.000 0.000 0.000 0.960 0.040
#> SRR805746 5 0.0937 0.971 0.000 0.000 0.000 0.000 0.960 0.040
#> SRR805747 4 0.3123 0.960 0.024 0.020 0.000 0.868 0.028 0.060
#> SRR805748 4 0.3123 0.960 0.024 0.020 0.000 0.868 0.028 0.060
#> SRR805749 4 0.3123 0.960 0.024 0.020 0.000 0.868 0.028 0.060
#> SRR805750 4 0.2849 0.964 0.024 0.016 0.000 0.884 0.028 0.048
#> SRR805751 4 0.1485 0.971 0.024 0.004 0.000 0.944 0.028 0.000
#> SRR805752 2 0.6885 0.536 0.004 0.448 0.000 0.144 0.084 0.320
#> SRR805753 2 0.6933 0.315 0.004 0.372 0.000 0.260 0.044 0.320
#> SRR805754 4 0.1485 0.971 0.024 0.004 0.000 0.944 0.028 0.000
#> SRR805755 4 0.1485 0.971 0.024 0.004 0.000 0.944 0.028 0.000
#> SRR805756 4 0.1485 0.971 0.024 0.004 0.000 0.944 0.028 0.000
#> SRR805757 4 0.1485 0.971 0.024 0.004 0.000 0.944 0.028 0.000
#> SRR805758 3 0.4002 0.863 0.008 0.008 0.704 0.008 0.000 0.272
#> SRR805759 3 0.3323 0.876 0.008 0.000 0.752 0.000 0.000 0.240
#> SRR805760 3 0.4241 0.868 0.012 0.012 0.712 0.016 0.000 0.248
#> SRR805761 3 0.4241 0.868 0.012 0.012 0.712 0.016 0.000 0.248
#> SRR805762 3 0.3323 0.876 0.008 0.000 0.752 0.000 0.000 0.240
#> SRR805763 3 0.1856 0.849 0.008 0.024 0.932 0.008 0.000 0.028
#> SRR805764 3 0.2562 0.841 0.012 0.024 0.892 0.008 0.000 0.064
#> SRR805765 3 0.1655 0.849 0.008 0.008 0.932 0.000 0.000 0.052
#> SRR805766 3 0.1655 0.849 0.008 0.008 0.932 0.000 0.000 0.052
#> SRR805767 3 0.1837 0.859 0.012 0.020 0.932 0.004 0.000 0.032
#> SRR805768 3 0.3323 0.876 0.008 0.000 0.752 0.000 0.000 0.240
#> SRR805769 1 0.3092 0.913 0.852 0.044 0.000 0.000 0.016 0.088
#> SRR805770 1 0.2982 0.926 0.844 0.016 0.000 0.000 0.016 0.124
#> SRR805771 1 0.3918 0.908 0.776 0.048 0.000 0.000 0.016 0.160
#> SRR805772 1 0.1148 0.934 0.960 0.020 0.000 0.000 0.016 0.004
#> SRR805773 1 0.1448 0.931 0.948 0.024 0.000 0.000 0.016 0.012
#> SRR805774 1 0.2542 0.932 0.884 0.020 0.000 0.000 0.016 0.080
#> SRR805775 1 0.2803 0.928 0.856 0.012 0.000 0.000 0.016 0.116
#> SRR805776 1 0.2617 0.930 0.872 0.012 0.000 0.000 0.016 0.100
#> SRR805777 1 0.1346 0.932 0.952 0.024 0.000 0.000 0.016 0.008
#> SRR805778 1 0.2455 0.932 0.888 0.016 0.000 0.000 0.016 0.080
#> SRR805779 1 0.0862 0.935 0.972 0.004 0.000 0.000 0.016 0.008
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 14939 rows and 54 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 0.925 0.954 0.982 0.5039 0.497 0.497
#> 3 3 0.867 0.955 0.974 0.2816 0.724 0.507
#> 4 4 1.000 0.966 0.981 0.1375 0.889 0.692
#> 5 5 1.000 0.984 0.993 0.1078 0.897 0.625
#> 6 6 1.000 0.968 0.978 0.0203 0.986 0.925
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
#> SRR805725 2 0.0000 0.976 0.000 1.000
#> SRR805726 2 0.0000 0.976 0.000 1.000
#> SRR805727 2 0.0000 0.976 0.000 1.000
#> SRR805728 2 0.0000 0.976 0.000 1.000
#> SRR805729 2 0.0000 0.976 0.000 1.000
#> SRR805730 2 0.0000 0.976 0.000 1.000
#> SRR805731 2 0.0000 0.976 0.000 1.000
#> SRR805732 2 0.0000 0.976 0.000 1.000
#> SRR805733 2 0.0000 0.976 0.000 1.000
#> SRR805735 2 0.0000 0.976 0.000 1.000
#> SRR805736 2 0.0000 0.976 0.000 1.000
#> SRR805737 2 0.0000 0.976 0.000 1.000
#> SRR805738 2 0.0000 0.976 0.000 1.000
#> SRR805739 2 0.0000 0.976 0.000 1.000
#> SRR805740 2 0.0000 0.976 0.000 1.000
#> SRR805741 2 0.0000 0.976 0.000 1.000
#> SRR805742 2 0.0000 0.976 0.000 1.000
#> SRR805743 2 0.0000 0.976 0.000 1.000
#> SRR805744 2 0.0000 0.976 0.000 1.000
#> SRR805745 2 0.0000 0.976 0.000 1.000
#> SRR805746 2 0.0000 0.976 0.000 1.000
#> SRR805747 1 0.6148 0.821 0.848 0.152
#> SRR805748 1 0.6148 0.821 0.848 0.152
#> SRR805749 2 0.9970 0.108 0.468 0.532
#> SRR805750 2 0.6887 0.764 0.184 0.816
#> SRR805751 2 0.0376 0.974 0.004 0.996
#> SRR805752 2 0.0000 0.976 0.000 1.000
#> SRR805753 2 0.0000 0.976 0.000 1.000
#> SRR805754 2 0.0376 0.974 0.004 0.996
#> SRR805755 2 0.0376 0.974 0.004 0.996
#> SRR805756 2 0.0376 0.974 0.004 0.996
#> SRR805757 2 0.0376 0.974 0.004 0.996
#> SRR805758 1 0.0000 0.986 1.000 0.000
#> SRR805759 1 0.0000 0.986 1.000 0.000
#> SRR805760 1 0.0000 0.986 1.000 0.000
#> SRR805761 1 0.0000 0.986 1.000 0.000
#> SRR805762 1 0.0000 0.986 1.000 0.000
#> SRR805763 1 0.0000 0.986 1.000 0.000
#> SRR805764 1 0.0000 0.986 1.000 0.000
#> SRR805765 1 0.0000 0.986 1.000 0.000
#> SRR805766 1 0.0000 0.986 1.000 0.000
#> SRR805767 1 0.0000 0.986 1.000 0.000
#> SRR805768 1 0.0000 0.986 1.000 0.000
#> SRR805769 1 0.0000 0.986 1.000 0.000
#> SRR805770 1 0.0000 0.986 1.000 0.000
#> SRR805771 1 0.0000 0.986 1.000 0.000
#> SRR805772 1 0.0000 0.986 1.000 0.000
#> SRR805773 1 0.0000 0.986 1.000 0.000
#> SRR805774 1 0.0000 0.986 1.000 0.000
#> SRR805775 1 0.0000 0.986 1.000 0.000
#> SRR805776 1 0.0000 0.986 1.000 0.000
#> SRR805777 1 0.0000 0.986 1.000 0.000
#> SRR805778 1 0.0000 0.986 1.000 0.000
#> SRR805779 1 0.0000 0.986 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805726 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805727 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805728 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805729 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805730 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805731 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805732 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805733 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805735 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805736 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805737 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805738 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805739 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805740 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805741 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805742 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805743 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805744 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805745 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805746 2 0.0000 0.999 0.000 1.000 0.00
#> SRR805747 1 0.0000 0.914 1.000 0.000 0.00
#> SRR805748 1 0.0000 0.914 1.000 0.000 0.00
#> SRR805749 1 0.0424 0.912 0.992 0.008 0.00
#> SRR805750 1 0.0592 0.911 0.988 0.012 0.00
#> SRR805751 1 0.4842 0.767 0.776 0.224 0.00
#> SRR805752 2 0.0592 0.989 0.012 0.988 0.00
#> SRR805753 2 0.0592 0.989 0.012 0.988 0.00
#> SRR805754 1 0.4842 0.767 0.776 0.224 0.00
#> SRR805755 1 0.4842 0.767 0.776 0.224 0.00
#> SRR805756 1 0.4842 0.767 0.776 0.224 0.00
#> SRR805757 1 0.4842 0.767 0.776 0.224 0.00
#> SRR805758 3 0.0000 1.000 0.000 0.000 1.00
#> SRR805759 3 0.0000 1.000 0.000 0.000 1.00
#> SRR805760 3 0.0000 1.000 0.000 0.000 1.00
#> SRR805761 3 0.0000 1.000 0.000 0.000 1.00
#> SRR805762 3 0.0000 1.000 0.000 0.000 1.00
#> SRR805763 3 0.0000 1.000 0.000 0.000 1.00
#> SRR805764 3 0.0000 1.000 0.000 0.000 1.00
#> SRR805765 3 0.0000 1.000 0.000 0.000 1.00
#> SRR805766 3 0.0000 1.000 0.000 0.000 1.00
#> SRR805767 3 0.0000 1.000 0.000 0.000 1.00
#> SRR805768 3 0.0000 1.000 0.000 0.000 1.00
#> SRR805769 1 0.0892 0.919 0.980 0.000 0.02
#> SRR805770 1 0.0892 0.919 0.980 0.000 0.02
#> SRR805771 1 0.0892 0.919 0.980 0.000 0.02
#> SRR805772 1 0.0892 0.919 0.980 0.000 0.02
#> SRR805773 1 0.0892 0.919 0.980 0.000 0.02
#> SRR805774 1 0.0892 0.919 0.980 0.000 0.02
#> SRR805775 1 0.0892 0.919 0.980 0.000 0.02
#> SRR805776 1 0.0892 0.919 0.980 0.000 0.02
#> SRR805777 1 0.0892 0.919 0.980 0.000 0.02
#> SRR805778 1 0.0892 0.919 0.980 0.000 0.02
#> SRR805779 1 0.0892 0.919 0.980 0.000 0.02
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.1398 0.975 0.000 0.956 0.004 0.040
#> SRR805726 2 0.1398 0.975 0.000 0.956 0.004 0.040
#> SRR805727 2 0.1398 0.975 0.000 0.956 0.004 0.040
#> SRR805728 2 0.1398 0.975 0.000 0.956 0.004 0.040
#> SRR805729 2 0.1398 0.975 0.000 0.956 0.004 0.040
#> SRR805730 2 0.1398 0.975 0.000 0.956 0.004 0.040
#> SRR805731 2 0.1398 0.975 0.000 0.956 0.004 0.040
#> SRR805732 2 0.1398 0.975 0.000 0.956 0.004 0.040
#> SRR805733 2 0.1398 0.975 0.000 0.956 0.004 0.040
#> SRR805735 2 0.1398 0.975 0.000 0.956 0.004 0.040
#> SRR805736 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR805737 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR805738 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR805739 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR805740 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR805741 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR805742 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR805743 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR805744 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR805745 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR805746 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR805747 4 0.0336 0.938 0.008 0.000 0.000 0.992
#> SRR805748 4 0.0336 0.938 0.008 0.000 0.000 0.992
#> SRR805749 4 0.0336 0.938 0.008 0.000 0.000 0.992
#> SRR805750 4 0.0336 0.938 0.008 0.000 0.000 0.992
#> SRR805751 4 0.0188 0.939 0.004 0.000 0.000 0.996
#> SRR805752 4 0.4991 0.339 0.000 0.388 0.004 0.608
#> SRR805753 4 0.2266 0.859 0.000 0.084 0.004 0.912
#> SRR805754 4 0.0188 0.939 0.004 0.000 0.000 0.996
#> SRR805755 4 0.0188 0.939 0.004 0.000 0.000 0.996
#> SRR805756 4 0.0188 0.939 0.004 0.000 0.000 0.996
#> SRR805757 4 0.0188 0.939 0.004 0.000 0.000 0.996
#> SRR805758 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR805759 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR805760 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR805761 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR805762 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR805763 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR805764 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR805765 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR805766 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR805767 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR805768 3 0.0188 1.000 0.004 0.000 0.996 0.000
#> SRR805769 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805770 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805771 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805772 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805773 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805774 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805775 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805776 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805777 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805778 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805779 1 0.0000 1.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 2 0.0162 0.968 0.000 0.996 0 0.000 0.004
#> SRR805726 2 0.0162 0.968 0.000 0.996 0 0.000 0.004
#> SRR805727 2 0.0162 0.968 0.000 0.996 0 0.000 0.004
#> SRR805728 2 0.0162 0.968 0.000 0.996 0 0.000 0.004
#> SRR805729 2 0.0162 0.968 0.000 0.996 0 0.000 0.004
#> SRR805730 2 0.0162 0.968 0.000 0.996 0 0.000 0.004
#> SRR805731 2 0.0162 0.968 0.000 0.996 0 0.000 0.004
#> SRR805732 2 0.0162 0.968 0.000 0.996 0 0.000 0.004
#> SRR805733 2 0.0162 0.968 0.000 0.996 0 0.000 0.004
#> SRR805735 2 0.0162 0.968 0.000 0.996 0 0.000 0.004
#> SRR805736 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR805737 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR805738 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR805739 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR805740 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR805741 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR805742 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR805743 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR805744 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR805745 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR805746 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR805747 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805748 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805749 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805750 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805751 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805752 2 0.0510 0.955 0.000 0.984 0 0.016 0.000
#> SRR805753 2 0.3949 0.507 0.000 0.668 0 0.332 0.000
#> SRR805754 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805755 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805756 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805757 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805758 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805759 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805760 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805761 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805762 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805763 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805764 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805765 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805766 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805767 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805768 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805769 1 0.0000 0.999 1.000 0.000 0 0.000 0.000
#> SRR805770 1 0.0000 0.999 1.000 0.000 0 0.000 0.000
#> SRR805771 1 0.0000 0.999 1.000 0.000 0 0.000 0.000
#> SRR805772 1 0.0000 0.999 1.000 0.000 0 0.000 0.000
#> SRR805773 1 0.0000 0.999 1.000 0.000 0 0.000 0.000
#> SRR805774 1 0.0162 0.998 0.996 0.004 0 0.000 0.000
#> SRR805775 1 0.0162 0.998 0.996 0.004 0 0.000 0.000
#> SRR805776 1 0.0162 0.998 0.996 0.004 0 0.000 0.000
#> SRR805777 1 0.0000 0.999 1.000 0.000 0 0.000 0.000
#> SRR805778 1 0.0000 0.999 1.000 0.000 0 0.000 0.000
#> SRR805779 1 0.0000 0.999 1.000 0.000 0 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0.0000 0.923 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805726 2 0.0146 0.923 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR805727 2 0.0000 0.923 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805728 2 0.0146 0.923 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR805729 2 0.0146 0.923 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR805730 2 0.0713 0.915 0.000 0.972 0.000 0.000 0.000 0.028
#> SRR805731 2 0.2178 0.852 0.000 0.868 0.000 0.000 0.000 0.132
#> SRR805732 2 0.3151 0.731 0.000 0.748 0.000 0.000 0.000 0.252
#> SRR805733 2 0.2996 0.762 0.000 0.772 0.000 0.000 0.000 0.228
#> SRR805735 2 0.0000 0.923 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805736 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR805737 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR805738 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR805739 5 0.0260 0.993 0.000 0.000 0.000 0.000 0.992 0.008
#> SRR805740 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR805741 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR805742 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR805743 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR805744 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR805745 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR805746 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR805747 4 0.0260 0.960 0.000 0.000 0.000 0.992 0.000 0.008
#> SRR805748 4 0.0260 0.960 0.000 0.000 0.000 0.992 0.000 0.008
#> SRR805749 4 0.0260 0.960 0.000 0.000 0.000 0.992 0.000 0.008
#> SRR805750 4 0.0146 0.961 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR805751 4 0.1267 0.964 0.000 0.000 0.000 0.940 0.000 0.060
#> SRR805752 6 0.0937 0.982 0.000 0.040 0.000 0.000 0.000 0.960
#> SRR805753 6 0.1074 0.982 0.000 0.028 0.000 0.012 0.000 0.960
#> SRR805754 4 0.1267 0.964 0.000 0.000 0.000 0.940 0.000 0.060
#> SRR805755 4 0.1327 0.962 0.000 0.000 0.000 0.936 0.000 0.064
#> SRR805756 4 0.1141 0.966 0.000 0.000 0.000 0.948 0.000 0.052
#> SRR805757 4 0.1141 0.966 0.000 0.000 0.000 0.948 0.000 0.052
#> SRR805758 3 0.0000 0.992 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805759 3 0.0000 0.992 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805760 3 0.0000 0.992 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805761 3 0.0000 0.992 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805762 3 0.0000 0.992 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805763 3 0.0547 0.989 0.000 0.000 0.980 0.000 0.000 0.020
#> SRR805764 3 0.0547 0.989 0.000 0.000 0.980 0.000 0.000 0.020
#> SRR805765 3 0.0547 0.989 0.000 0.000 0.980 0.000 0.000 0.020
#> SRR805766 3 0.0547 0.989 0.000 0.000 0.980 0.000 0.000 0.020
#> SRR805767 3 0.0363 0.990 0.000 0.000 0.988 0.000 0.000 0.012
#> SRR805768 3 0.0000 0.992 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805769 1 0.0146 0.998 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR805770 1 0.0146 0.998 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR805771 1 0.0146 0.998 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR805772 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805773 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805774 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805775 1 0.0146 0.998 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR805776 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805777 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805778 1 0.0146 0.998 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR805779 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 14939 rows and 54 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.00 0.957 0.984 0.3512 0.648 0.648
#> 3 3 1.00 0.981 0.992 0.7439 0.720 0.573
#> 4 4 1.00 0.972 0.979 0.2070 0.843 0.609
#> 5 5 1.00 0.990 0.995 0.1023 0.923 0.707
#> 6 6 0.97 0.924 0.956 0.0227 0.969 0.834
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
#> SRR805725 2 0.0000 0.990 0.000 1.000
#> SRR805726 2 0.0000 0.990 0.000 1.000
#> SRR805727 2 0.0000 0.990 0.000 1.000
#> SRR805728 2 0.0000 0.990 0.000 1.000
#> SRR805729 2 0.0000 0.990 0.000 1.000
#> SRR805730 2 0.0000 0.990 0.000 1.000
#> SRR805731 2 0.0000 0.990 0.000 1.000
#> SRR805732 2 0.0000 0.990 0.000 1.000
#> SRR805733 2 0.0000 0.990 0.000 1.000
#> SRR805735 2 0.0000 0.990 0.000 1.000
#> SRR805736 2 0.0000 0.990 0.000 1.000
#> SRR805737 2 0.0000 0.990 0.000 1.000
#> SRR805738 2 0.0000 0.990 0.000 1.000
#> SRR805739 2 0.0000 0.990 0.000 1.000
#> SRR805740 2 0.0000 0.990 0.000 1.000
#> SRR805741 2 0.0000 0.990 0.000 1.000
#> SRR805742 2 0.0000 0.990 0.000 1.000
#> SRR805743 2 0.0000 0.990 0.000 1.000
#> SRR805744 2 0.0000 0.990 0.000 1.000
#> SRR805745 2 0.0000 0.990 0.000 1.000
#> SRR805746 2 0.0000 0.990 0.000 1.000
#> SRR805747 2 0.0000 0.990 0.000 1.000
#> SRR805748 2 0.0000 0.990 0.000 1.000
#> SRR805749 2 0.0000 0.990 0.000 1.000
#> SRR805750 2 0.0000 0.990 0.000 1.000
#> SRR805751 2 0.0000 0.990 0.000 1.000
#> SRR805752 2 0.0000 0.990 0.000 1.000
#> SRR805753 2 0.0000 0.990 0.000 1.000
#> SRR805754 2 0.0000 0.990 0.000 1.000
#> SRR805755 2 0.0000 0.990 0.000 1.000
#> SRR805756 2 0.0000 0.990 0.000 1.000
#> SRR805757 2 0.0000 0.990 0.000 1.000
#> SRR805758 1 0.0000 0.958 1.000 0.000
#> SRR805759 1 0.0000 0.958 1.000 0.000
#> SRR805760 1 0.0000 0.958 1.000 0.000
#> SRR805761 1 0.0000 0.958 1.000 0.000
#> SRR805762 1 0.0000 0.958 1.000 0.000
#> SRR805763 1 0.0000 0.958 1.000 0.000
#> SRR805764 1 0.0000 0.958 1.000 0.000
#> SRR805765 1 0.0000 0.958 1.000 0.000
#> SRR805766 1 0.0000 0.958 1.000 0.000
#> SRR805767 1 0.0000 0.958 1.000 0.000
#> SRR805768 1 0.0000 0.958 1.000 0.000
#> SRR805769 2 0.4298 0.894 0.088 0.912
#> SRR805770 2 0.0376 0.986 0.004 0.996
#> SRR805771 1 0.9922 0.162 0.552 0.448
#> SRR805772 2 0.0000 0.990 0.000 1.000
#> SRR805773 2 0.0000 0.990 0.000 1.000
#> SRR805774 2 0.0000 0.990 0.000 1.000
#> SRR805775 2 0.0000 0.990 0.000 1.000
#> SRR805776 2 0.0000 0.990 0.000 1.000
#> SRR805777 2 0.0000 0.990 0.000 1.000
#> SRR805778 2 0.9000 0.515 0.316 0.684
#> SRR805779 2 0.0000 0.990 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.0000 0.995 0.000 1.000 0
#> SRR805726 2 0.0000 0.995 0.000 1.000 0
#> SRR805727 2 0.0000 0.995 0.000 1.000 0
#> SRR805728 2 0.0000 0.995 0.000 1.000 0
#> SRR805729 2 0.0000 0.995 0.000 1.000 0
#> SRR805730 2 0.0000 0.995 0.000 1.000 0
#> SRR805731 2 0.0000 0.995 0.000 1.000 0
#> SRR805732 2 0.0000 0.995 0.000 1.000 0
#> SRR805733 2 0.0000 0.995 0.000 1.000 0
#> SRR805735 2 0.0000 0.995 0.000 1.000 0
#> SRR805736 2 0.0000 0.995 0.000 1.000 0
#> SRR805737 2 0.0000 0.995 0.000 1.000 0
#> SRR805738 2 0.0000 0.995 0.000 1.000 0
#> SRR805739 2 0.0000 0.995 0.000 1.000 0
#> SRR805740 2 0.0000 0.995 0.000 1.000 0
#> SRR805741 2 0.0000 0.995 0.000 1.000 0
#> SRR805742 2 0.0000 0.995 0.000 1.000 0
#> SRR805743 2 0.0000 0.995 0.000 1.000 0
#> SRR805744 2 0.0000 0.995 0.000 1.000 0
#> SRR805745 2 0.0000 0.995 0.000 1.000 0
#> SRR805746 2 0.0000 0.995 0.000 1.000 0
#> SRR805747 1 0.1529 0.937 0.960 0.040 0
#> SRR805748 1 0.1411 0.941 0.964 0.036 0
#> SRR805749 1 0.4702 0.713 0.788 0.212 0
#> SRR805750 2 0.3340 0.860 0.120 0.880 0
#> SRR805751 2 0.0000 0.995 0.000 1.000 0
#> SRR805752 2 0.0000 0.995 0.000 1.000 0
#> SRR805753 2 0.0000 0.995 0.000 1.000 0
#> SRR805754 2 0.0237 0.992 0.004 0.996 0
#> SRR805755 2 0.0000 0.995 0.000 1.000 0
#> SRR805756 2 0.0237 0.992 0.004 0.996 0
#> SRR805757 2 0.0237 0.992 0.004 0.996 0
#> SRR805758 3 0.0000 1.000 0.000 0.000 1
#> SRR805759 3 0.0000 1.000 0.000 0.000 1
#> SRR805760 3 0.0000 1.000 0.000 0.000 1
#> SRR805761 3 0.0000 1.000 0.000 0.000 1
#> SRR805762 3 0.0000 1.000 0.000 0.000 1
#> SRR805763 3 0.0000 1.000 0.000 0.000 1
#> SRR805764 3 0.0000 1.000 0.000 0.000 1
#> SRR805765 3 0.0000 1.000 0.000 0.000 1
#> SRR805766 3 0.0000 1.000 0.000 0.000 1
#> SRR805767 3 0.0000 1.000 0.000 0.000 1
#> SRR805768 3 0.0000 1.000 0.000 0.000 1
#> SRR805769 1 0.0000 0.971 1.000 0.000 0
#> SRR805770 1 0.0000 0.971 1.000 0.000 0
#> SRR805771 1 0.0000 0.971 1.000 0.000 0
#> SRR805772 1 0.0000 0.971 1.000 0.000 0
#> SRR805773 1 0.0000 0.971 1.000 0.000 0
#> SRR805774 1 0.0000 0.971 1.000 0.000 0
#> SRR805775 1 0.0000 0.971 1.000 0.000 0
#> SRR805776 1 0.0000 0.971 1.000 0.000 0
#> SRR805777 1 0.0000 0.971 1.000 0.000 0
#> SRR805778 1 0.0000 0.971 1.000 0.000 0
#> SRR805779 1 0.0000 0.971 1.000 0.000 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.2216 0.946 0.000 0.908 0 0.092
#> SRR805726 2 0.2216 0.946 0.000 0.908 0 0.092
#> SRR805727 2 0.2216 0.946 0.000 0.908 0 0.092
#> SRR805728 2 0.2216 0.946 0.000 0.908 0 0.092
#> SRR805729 2 0.2216 0.946 0.000 0.908 0 0.092
#> SRR805730 2 0.2216 0.946 0.000 0.908 0 0.092
#> SRR805731 2 0.2216 0.946 0.000 0.908 0 0.092
#> SRR805732 2 0.2216 0.946 0.000 0.908 0 0.092
#> SRR805733 2 0.2469 0.933 0.000 0.892 0 0.108
#> SRR805735 2 0.2216 0.946 0.000 0.908 0 0.092
#> SRR805736 2 0.0000 0.953 0.000 1.000 0 0.000
#> SRR805737 2 0.0000 0.953 0.000 1.000 0 0.000
#> SRR805738 2 0.0000 0.953 0.000 1.000 0 0.000
#> SRR805739 2 0.0000 0.953 0.000 1.000 0 0.000
#> SRR805740 2 0.0000 0.953 0.000 1.000 0 0.000
#> SRR805741 2 0.0000 0.953 0.000 1.000 0 0.000
#> SRR805742 2 0.0000 0.953 0.000 1.000 0 0.000
#> SRR805743 2 0.0000 0.953 0.000 1.000 0 0.000
#> SRR805744 2 0.0000 0.953 0.000 1.000 0 0.000
#> SRR805745 2 0.0000 0.953 0.000 1.000 0 0.000
#> SRR805746 2 0.0000 0.953 0.000 1.000 0 0.000
#> SRR805747 4 0.2081 0.901 0.084 0.000 0 0.916
#> SRR805748 4 0.2216 0.892 0.092 0.000 0 0.908
#> SRR805749 4 0.0188 0.974 0.004 0.000 0 0.996
#> SRR805750 4 0.0000 0.976 0.000 0.000 0 1.000
#> SRR805751 4 0.0000 0.976 0.000 0.000 0 1.000
#> SRR805752 4 0.0592 0.967 0.000 0.016 0 0.984
#> SRR805753 4 0.0336 0.972 0.000 0.008 0 0.992
#> SRR805754 4 0.0000 0.976 0.000 0.000 0 1.000
#> SRR805755 4 0.0000 0.976 0.000 0.000 0 1.000
#> SRR805756 4 0.0000 0.976 0.000 0.000 0 1.000
#> SRR805757 4 0.0000 0.976 0.000 0.000 0 1.000
#> SRR805758 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805759 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805760 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805761 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805762 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805763 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805764 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805765 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805766 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805767 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805768 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805769 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805770 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805771 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805772 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805773 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805774 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805775 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805776 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805777 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805778 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805779 1 0.0000 1.000 1.000 0.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 2 0.0000 1.000 0 1.000 0 0.000 0
#> SRR805726 2 0.0000 1.000 0 1.000 0 0.000 0
#> SRR805727 2 0.0000 1.000 0 1.000 0 0.000 0
#> SRR805728 2 0.0000 1.000 0 1.000 0 0.000 0
#> SRR805729 2 0.0000 1.000 0 1.000 0 0.000 0
#> SRR805730 2 0.0000 1.000 0 1.000 0 0.000 0
#> SRR805731 2 0.0000 1.000 0 1.000 0 0.000 0
#> SRR805732 2 0.0000 1.000 0 1.000 0 0.000 0
#> SRR805733 2 0.0000 1.000 0 1.000 0 0.000 0
#> SRR805735 2 0.0000 1.000 0 1.000 0 0.000 0
#> SRR805736 5 0.0000 1.000 0 0.000 0 0.000 1
#> SRR805737 5 0.0000 1.000 0 0.000 0 0.000 1
#> SRR805738 5 0.0000 1.000 0 0.000 0 0.000 1
#> SRR805739 5 0.0000 1.000 0 0.000 0 0.000 1
#> SRR805740 5 0.0000 1.000 0 0.000 0 0.000 1
#> SRR805741 5 0.0000 1.000 0 0.000 0 0.000 1
#> SRR805742 5 0.0000 1.000 0 0.000 0 0.000 1
#> SRR805743 5 0.0000 1.000 0 0.000 0 0.000 1
#> SRR805744 5 0.0000 1.000 0 0.000 0 0.000 1
#> SRR805745 5 0.0000 1.000 0 0.000 0 0.000 1
#> SRR805746 5 0.0000 1.000 0 0.000 0 0.000 1
#> SRR805747 4 0.0000 0.975 0 0.000 0 1.000 0
#> SRR805748 4 0.0000 0.975 0 0.000 0 1.000 0
#> SRR805749 4 0.0000 0.975 0 0.000 0 1.000 0
#> SRR805750 4 0.0000 0.975 0 0.000 0 1.000 0
#> SRR805751 4 0.0000 0.975 0 0.000 0 1.000 0
#> SRR805752 4 0.3336 0.709 0 0.228 0 0.772 0
#> SRR805753 4 0.0609 0.960 0 0.020 0 0.980 0
#> SRR805754 4 0.0000 0.975 0 0.000 0 1.000 0
#> SRR805755 4 0.0000 0.975 0 0.000 0 1.000 0
#> SRR805756 4 0.0000 0.975 0 0.000 0 1.000 0
#> SRR805757 4 0.0000 0.975 0 0.000 0 1.000 0
#> SRR805758 3 0.0000 1.000 0 0.000 1 0.000 0
#> SRR805759 3 0.0000 1.000 0 0.000 1 0.000 0
#> SRR805760 3 0.0000 1.000 0 0.000 1 0.000 0
#> SRR805761 3 0.0000 1.000 0 0.000 1 0.000 0
#> SRR805762 3 0.0000 1.000 0 0.000 1 0.000 0
#> SRR805763 3 0.0000 1.000 0 0.000 1 0.000 0
#> SRR805764 3 0.0000 1.000 0 0.000 1 0.000 0
#> SRR805765 3 0.0000 1.000 0 0.000 1 0.000 0
#> SRR805766 3 0.0000 1.000 0 0.000 1 0.000 0
#> SRR805767 3 0.0000 1.000 0 0.000 1 0.000 0
#> SRR805768 3 0.0000 1.000 0 0.000 1 0.000 0
#> SRR805769 1 0.0000 1.000 1 0.000 0 0.000 0
#> SRR805770 1 0.0000 1.000 1 0.000 0 0.000 0
#> SRR805771 1 0.0000 1.000 1 0.000 0 0.000 0
#> SRR805772 1 0.0000 1.000 1 0.000 0 0.000 0
#> SRR805773 1 0.0000 1.000 1 0.000 0 0.000 0
#> SRR805774 1 0.0000 1.000 1 0.000 0 0.000 0
#> SRR805775 1 0.0000 1.000 1 0.000 0 0.000 0
#> SRR805776 1 0.0000 1.000 1 0.000 0 0.000 0
#> SRR805777 1 0.0000 1.000 1 0.000 0 0.000 0
#> SRR805778 1 0.0000 1.000 1 0.000 0 0.000 0
#> SRR805779 1 0.0000 1.000 1 0.000 0 0.000 0
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0.000 0.910 0 1.000 0 0.000 0 0.000
#> SRR805726 2 0.000 0.910 0 1.000 0 0.000 0 0.000
#> SRR805727 2 0.000 0.910 0 1.000 0 0.000 0 0.000
#> SRR805728 2 0.000 0.910 0 1.000 0 0.000 0 0.000
#> SRR805729 2 0.000 0.910 0 1.000 0 0.000 0 0.000
#> SRR805730 2 0.315 0.483 0 0.748 0 0.000 0 0.252
#> SRR805731 6 0.385 0.516 0 0.456 0 0.000 0 0.544
#> SRR805732 6 0.385 0.516 0 0.456 0 0.000 0 0.544
#> SRR805733 6 0.385 0.516 0 0.456 0 0.000 0 0.544
#> SRR805735 2 0.176 0.813 0 0.904 0 0.000 0 0.096
#> SRR805736 5 0.000 1.000 0 0.000 0 0.000 1 0.000
#> SRR805737 5 0.000 1.000 0 0.000 0 0.000 1 0.000
#> SRR805738 5 0.000 1.000 0 0.000 0 0.000 1 0.000
#> SRR805739 5 0.000 1.000 0 0.000 0 0.000 1 0.000
#> SRR805740 5 0.000 1.000 0 0.000 0 0.000 1 0.000
#> SRR805741 5 0.000 1.000 0 0.000 0 0.000 1 0.000
#> SRR805742 5 0.000 1.000 0 0.000 0 0.000 1 0.000
#> SRR805743 5 0.000 1.000 0 0.000 0 0.000 1 0.000
#> SRR805744 5 0.000 1.000 0 0.000 0 0.000 1 0.000
#> SRR805745 5 0.000 1.000 0 0.000 0 0.000 1 0.000
#> SRR805746 5 0.000 1.000 0 0.000 0 0.000 1 0.000
#> SRR805747 4 0.200 0.917 0 0.000 0 0.884 0 0.116
#> SRR805748 4 0.200 0.917 0 0.000 0 0.884 0 0.116
#> SRR805749 4 0.200 0.917 0 0.000 0 0.884 0 0.116
#> SRR805750 4 0.000 0.959 0 0.000 0 1.000 0 0.000
#> SRR805751 4 0.000 0.959 0 0.000 0 1.000 0 0.000
#> SRR805752 6 0.238 0.532 0 0.084 0 0.032 0 0.884
#> SRR805753 6 0.291 0.439 0 0.000 0 0.216 0 0.784
#> SRR805754 4 0.000 0.959 0 0.000 0 1.000 0 0.000
#> SRR805755 4 0.000 0.959 0 0.000 0 1.000 0 0.000
#> SRR805756 4 0.000 0.959 0 0.000 0 1.000 0 0.000
#> SRR805757 4 0.000 0.959 0 0.000 0 1.000 0 0.000
#> SRR805758 3 0.000 1.000 0 0.000 1 0.000 0 0.000
#> SRR805759 3 0.000 1.000 0 0.000 1 0.000 0 0.000
#> SRR805760 3 0.000 1.000 0 0.000 1 0.000 0 0.000
#> SRR805761 3 0.000 1.000 0 0.000 1 0.000 0 0.000
#> SRR805762 3 0.000 1.000 0 0.000 1 0.000 0 0.000
#> SRR805763 3 0.000 1.000 0 0.000 1 0.000 0 0.000
#> SRR805764 3 0.000 1.000 0 0.000 1 0.000 0 0.000
#> SRR805765 3 0.000 1.000 0 0.000 1 0.000 0 0.000
#> SRR805766 3 0.000 1.000 0 0.000 1 0.000 0 0.000
#> SRR805767 3 0.000 1.000 0 0.000 1 0.000 0 0.000
#> SRR805768 3 0.000 1.000 0 0.000 1 0.000 0 0.000
#> SRR805769 1 0.000 1.000 1 0.000 0 0.000 0 0.000
#> SRR805770 1 0.000 1.000 1 0.000 0 0.000 0 0.000
#> SRR805771 1 0.000 1.000 1 0.000 0 0.000 0 0.000
#> SRR805772 1 0.000 1.000 1 0.000 0 0.000 0 0.000
#> SRR805773 1 0.000 1.000 1 0.000 0 0.000 0 0.000
#> SRR805774 1 0.000 1.000 1 0.000 0 0.000 0 0.000
#> SRR805775 1 0.000 1.000 1 0.000 0 0.000 0 0.000
#> SRR805776 1 0.000 1.000 1 0.000 0 0.000 0 0.000
#> SRR805777 1 0.000 1.000 1 0.000 0 0.000 0 0.000
#> SRR805778 1 0.000 1.000 1 0.000 0 0.000 0 0.000
#> SRR805779 1 0.000 1.000 1 0.000 0 0.000 0 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14939 rows and 54 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.249 0.299 0.587 0.4685 0.669 0.669
#> 3 3 0.748 0.812 0.907 0.3082 0.431 0.315
#> 4 4 1.000 0.956 0.984 0.1930 0.839 0.619
#> 5 5 1.000 0.978 0.990 0.1142 0.923 0.707
#> 6 6 1.000 1.000 1.000 0.0159 0.987 0.932
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
#> SRR805725 2 1.000 0.2053 0.496 0.504
#> SRR805726 2 1.000 0.2053 0.496 0.504
#> SRR805727 2 1.000 0.2053 0.496 0.504
#> SRR805728 2 1.000 0.2053 0.496 0.504
#> SRR805729 2 1.000 0.2053 0.496 0.504
#> SRR805730 2 1.000 0.2053 0.496 0.504
#> SRR805731 2 1.000 0.2053 0.496 0.504
#> SRR805732 2 1.000 0.2053 0.496 0.504
#> SRR805733 2 1.000 0.2053 0.496 0.504
#> SRR805735 2 1.000 0.2053 0.496 0.504
#> SRR805736 2 1.000 0.2053 0.496 0.504
#> SRR805737 2 1.000 0.2053 0.496 0.504
#> SRR805738 2 1.000 0.2053 0.496 0.504
#> SRR805739 2 1.000 0.2053 0.496 0.504
#> SRR805740 2 1.000 0.2053 0.496 0.504
#> SRR805741 2 1.000 0.2053 0.496 0.504
#> SRR805742 2 1.000 0.2053 0.496 0.504
#> SRR805743 2 1.000 0.2053 0.496 0.504
#> SRR805744 2 1.000 0.2053 0.496 0.504
#> SRR805745 2 1.000 0.2053 0.496 0.504
#> SRR805746 2 1.000 0.2053 0.496 0.504
#> SRR805747 1 0.000 0.8886 1.000 0.000
#> SRR805748 1 0.000 0.8886 1.000 0.000
#> SRR805749 1 0.000 0.8886 1.000 0.000
#> SRR805750 1 0.000 0.8886 1.000 0.000
#> SRR805751 1 0.000 0.8886 1.000 0.000
#> SRR805752 1 0.952 0.0533 0.628 0.372
#> SRR805753 1 0.753 0.5271 0.784 0.216
#> SRR805754 1 0.000 0.8886 1.000 0.000
#> SRR805755 1 0.000 0.8886 1.000 0.000
#> SRR805756 1 0.000 0.8886 1.000 0.000
#> SRR805757 1 0.000 0.8886 1.000 0.000
#> SRR805758 2 0.814 0.2592 0.252 0.748
#> SRR805759 2 0.814 0.2592 0.252 0.748
#> SRR805760 2 0.814 0.2592 0.252 0.748
#> SRR805761 2 0.814 0.2592 0.252 0.748
#> SRR805762 2 0.814 0.2592 0.252 0.748
#> SRR805763 2 0.814 0.2592 0.252 0.748
#> SRR805764 2 0.814 0.2592 0.252 0.748
#> SRR805765 2 0.814 0.2592 0.252 0.748
#> SRR805766 2 0.814 0.2592 0.252 0.748
#> SRR805767 2 0.814 0.2592 0.252 0.748
#> SRR805768 2 0.814 0.2592 0.252 0.748
#> SRR805769 2 0.952 0.0348 0.372 0.628
#> SRR805770 2 0.952 0.0348 0.372 0.628
#> SRR805771 2 0.952 0.0348 0.372 0.628
#> SRR805772 2 0.952 0.0348 0.372 0.628
#> SRR805773 2 0.952 0.0348 0.372 0.628
#> SRR805774 2 0.952 0.0348 0.372 0.628
#> SRR805775 2 0.952 0.0348 0.372 0.628
#> SRR805776 2 0.952 0.0348 0.372 0.628
#> SRR805777 2 0.952 0.0348 0.372 0.628
#> SRR805778 2 0.952 0.0348 0.372 0.628
#> SRR805779 2 0.952 0.0348 0.372 0.628
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.0000 0.813 0.000 1.000 0.000
#> SRR805726 2 0.0000 0.813 0.000 1.000 0.000
#> SRR805727 2 0.0000 0.813 0.000 1.000 0.000
#> SRR805728 2 0.0000 0.813 0.000 1.000 0.000
#> SRR805729 2 0.0000 0.813 0.000 1.000 0.000
#> SRR805730 2 0.0000 0.813 0.000 1.000 0.000
#> SRR805731 2 0.0000 0.813 0.000 1.000 0.000
#> SRR805732 2 0.0000 0.813 0.000 1.000 0.000
#> SRR805733 2 0.0000 0.813 0.000 1.000 0.000
#> SRR805735 2 0.0000 0.813 0.000 1.000 0.000
#> SRR805736 2 0.0592 0.812 0.012 0.988 0.000
#> SRR805737 2 0.0592 0.812 0.012 0.988 0.000
#> SRR805738 2 0.0592 0.812 0.012 0.988 0.000
#> SRR805739 2 0.0592 0.812 0.012 0.988 0.000
#> SRR805740 2 0.0592 0.812 0.012 0.988 0.000
#> SRR805741 2 0.0592 0.812 0.012 0.988 0.000
#> SRR805742 2 0.0592 0.812 0.012 0.988 0.000
#> SRR805743 2 0.0592 0.812 0.012 0.988 0.000
#> SRR805744 2 0.0592 0.812 0.012 0.988 0.000
#> SRR805745 2 0.0592 0.812 0.012 0.988 0.000
#> SRR805746 2 0.0592 0.812 0.012 0.988 0.000
#> SRR805747 2 0.6274 0.425 0.000 0.544 0.456
#> SRR805748 2 0.6274 0.425 0.000 0.544 0.456
#> SRR805749 2 0.6274 0.425 0.000 0.544 0.456
#> SRR805750 2 0.6274 0.425 0.000 0.544 0.456
#> SRR805751 2 0.6274 0.425 0.000 0.544 0.456
#> SRR805752 2 0.5926 0.543 0.000 0.644 0.356
#> SRR805753 2 0.6267 0.431 0.000 0.548 0.452
#> SRR805754 2 0.6274 0.425 0.000 0.544 0.456
#> SRR805755 2 0.6274 0.425 0.000 0.544 0.456
#> SRR805756 2 0.6274 0.425 0.000 0.544 0.456
#> SRR805757 2 0.6274 0.425 0.000 0.544 0.456
#> SRR805758 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805759 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805760 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805761 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805762 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805763 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805764 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805765 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805766 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805767 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805768 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805769 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805770 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805771 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805772 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805773 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805774 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805775 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805776 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805777 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805778 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805779 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
#> SRR805725 2 0.0188 0.998 0 0.996 0 0.004
#> SRR805726 2 0.0188 0.998 0 0.996 0 0.004
#> SRR805727 2 0.0188 0.998 0 0.996 0 0.004
#> SRR805728 2 0.0188 0.998 0 0.996 0 0.004
#> SRR805729 2 0.0188 0.998 0 0.996 0 0.004
#> SRR805730 2 0.0188 0.998 0 0.996 0 0.004
#> SRR805731 2 0.0188 0.998 0 0.996 0 0.004
#> SRR805732 2 0.0188 0.998 0 0.996 0 0.004
#> SRR805733 2 0.0188 0.998 0 0.996 0 0.004
#> SRR805735 2 0.0188 0.998 0 0.996 0 0.004
#> SRR805736 2 0.0000 0.998 0 1.000 0 0.000
#> SRR805737 2 0.0000 0.998 0 1.000 0 0.000
#> SRR805738 2 0.0000 0.998 0 1.000 0 0.000
#> SRR805739 2 0.0000 0.998 0 1.000 0 0.000
#> SRR805740 2 0.0000 0.998 0 1.000 0 0.000
#> SRR805741 2 0.0000 0.998 0 1.000 0 0.000
#> SRR805742 2 0.0000 0.998 0 1.000 0 0.000
#> SRR805743 2 0.0000 0.998 0 1.000 0 0.000
#> SRR805744 2 0.0000 0.998 0 1.000 0 0.000
#> SRR805745 2 0.0000 0.998 0 1.000 0 0.000
#> SRR805746 2 0.0000 0.998 0 1.000 0 0.000
#> SRR805747 4 0.0000 0.895 0 0.000 0 1.000
#> SRR805748 4 0.0000 0.895 0 0.000 0 1.000
#> SRR805749 4 0.0000 0.895 0 0.000 0 1.000
#> SRR805750 4 0.0000 0.895 0 0.000 0 1.000
#> SRR805751 4 0.0000 0.895 0 0.000 0 1.000
#> SRR805752 4 0.4972 0.235 0 0.456 0 0.544
#> SRR805753 4 0.4830 0.403 0 0.392 0 0.608
#> SRR805754 4 0.0000 0.895 0 0.000 0 1.000
#> SRR805755 4 0.0000 0.895 0 0.000 0 1.000
#> SRR805756 4 0.0000 0.895 0 0.000 0 1.000
#> SRR805757 4 0.0000 0.895 0 0.000 0 1.000
#> SRR805758 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805759 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805760 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805761 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805762 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805763 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805764 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805765 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805766 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805767 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805768 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805769 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805770 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805771 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805772 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805773 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805774 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805775 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805776 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805777 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805778 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805779 1 0.0000 1.000 1 0.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 2 0.000 1.000 0 1.000 0 0.000 0.000
#> SRR805726 2 0.000 1.000 0 1.000 0 0.000 0.000
#> SRR805727 2 0.000 1.000 0 1.000 0 0.000 0.000
#> SRR805728 2 0.000 1.000 0 1.000 0 0.000 0.000
#> SRR805729 2 0.000 1.000 0 1.000 0 0.000 0.000
#> SRR805730 2 0.000 1.000 0 1.000 0 0.000 0.000
#> SRR805731 2 0.000 1.000 0 1.000 0 0.000 0.000
#> SRR805732 2 0.000 1.000 0 1.000 0 0.000 0.000
#> SRR805733 2 0.000 1.000 0 1.000 0 0.000 0.000
#> SRR805735 2 0.000 1.000 0 1.000 0 0.000 0.000
#> SRR805736 5 0.000 0.999 0 0.000 0 0.000 1.000
#> SRR805737 5 0.000 0.999 0 0.000 0 0.000 1.000
#> SRR805738 5 0.000 0.999 0 0.000 0 0.000 1.000
#> SRR805739 5 0.029 0.992 0 0.008 0 0.000 0.992
#> SRR805740 5 0.000 0.999 0 0.000 0 0.000 1.000
#> SRR805741 5 0.000 0.999 0 0.000 0 0.000 1.000
#> SRR805742 5 0.000 0.999 0 0.000 0 0.000 1.000
#> SRR805743 5 0.000 0.999 0 0.000 0 0.000 1.000
#> SRR805744 5 0.000 0.999 0 0.000 0 0.000 1.000
#> SRR805745 5 0.000 0.999 0 0.000 0 0.000 1.000
#> SRR805746 5 0.000 0.999 0 0.000 0 0.000 1.000
#> SRR805747 4 0.000 0.945 0 0.000 0 1.000 0.000
#> SRR805748 4 0.000 0.945 0 0.000 0 1.000 0.000
#> SRR805749 4 0.000 0.945 0 0.000 0 1.000 0.000
#> SRR805750 4 0.000 0.945 0 0.000 0 1.000 0.000
#> SRR805751 4 0.000 0.945 0 0.000 0 1.000 0.000
#> SRR805752 4 0.373 0.634 0 0.288 0 0.712 0.000
#> SRR805753 4 0.345 0.702 0 0.244 0 0.756 0.000
#> SRR805754 4 0.000 0.945 0 0.000 0 1.000 0.000
#> SRR805755 4 0.000 0.945 0 0.000 0 1.000 0.000
#> SRR805756 4 0.000 0.945 0 0.000 0 1.000 0.000
#> SRR805757 4 0.000 0.945 0 0.000 0 1.000 0.000
#> SRR805758 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR805759 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR805760 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR805761 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR805762 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR805763 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR805764 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR805765 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR805766 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR805767 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR805768 3 0.000 1.000 0 0.000 1 0.000 0.000
#> SRR805769 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR805770 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR805771 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR805772 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR805773 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR805774 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR805775 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR805776 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR805777 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR805778 1 0.000 1.000 1 0.000 0 0.000 0.000
#> SRR805779 1 0.000 1.000 1 0.000 0 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0 1 0 1 0 0 0 0
#> SRR805726 2 0 1 0 1 0 0 0 0
#> SRR805727 2 0 1 0 1 0 0 0 0
#> SRR805728 2 0 1 0 1 0 0 0 0
#> SRR805729 2 0 1 0 1 0 0 0 0
#> SRR805730 2 0 1 0 1 0 0 0 0
#> SRR805731 2 0 1 0 1 0 0 0 0
#> SRR805732 2 0 1 0 1 0 0 0 0
#> SRR805733 2 0 1 0 1 0 0 0 0
#> SRR805735 2 0 1 0 1 0 0 0 0
#> SRR805736 5 0 1 0 0 0 0 1 0
#> SRR805737 5 0 1 0 0 0 0 1 0
#> SRR805738 5 0 1 0 0 0 0 1 0
#> SRR805739 5 0 1 0 0 0 0 1 0
#> SRR805740 5 0 1 0 0 0 0 1 0
#> SRR805741 5 0 1 0 0 0 0 1 0
#> SRR805742 5 0 1 0 0 0 0 1 0
#> SRR805743 5 0 1 0 0 0 0 1 0
#> SRR805744 5 0 1 0 0 0 0 1 0
#> SRR805745 5 0 1 0 0 0 0 1 0
#> SRR805746 5 0 1 0 0 0 0 1 0
#> SRR805747 4 0 1 0 0 0 1 0 0
#> SRR805748 4 0 1 0 0 0 1 0 0
#> SRR805749 4 0 1 0 0 0 1 0 0
#> SRR805750 4 0 1 0 0 0 1 0 0
#> SRR805751 4 0 1 0 0 0 1 0 0
#> SRR805752 6 0 1 0 0 0 0 0 1
#> SRR805753 6 0 1 0 0 0 0 0 1
#> SRR805754 4 0 1 0 0 0 1 0 0
#> SRR805755 4 0 1 0 0 0 1 0 0
#> SRR805756 4 0 1 0 0 0 1 0 0
#> SRR805757 4 0 1 0 0 0 1 0 0
#> SRR805758 3 0 1 0 0 1 0 0 0
#> SRR805759 3 0 1 0 0 1 0 0 0
#> SRR805760 3 0 1 0 0 1 0 0 0
#> SRR805761 3 0 1 0 0 1 0 0 0
#> SRR805762 3 0 1 0 0 1 0 0 0
#> SRR805763 3 0 1 0 0 1 0 0 0
#> SRR805764 3 0 1 0 0 1 0 0 0
#> SRR805765 3 0 1 0 0 1 0 0 0
#> SRR805766 3 0 1 0 0 1 0 0 0
#> SRR805767 3 0 1 0 0 1 0 0 0
#> SRR805768 3 0 1 0 0 1 0 0 0
#> SRR805769 1 0 1 1 0 0 0 0 0
#> SRR805770 1 0 1 1 0 0 0 0 0
#> SRR805771 1 0 1 1 0 0 0 0 0
#> SRR805772 1 0 1 1 0 0 0 0 0
#> SRR805773 1 0 1 1 0 0 0 0 0
#> SRR805774 1 0 1 1 0 0 0 0 0
#> SRR805775 1 0 1 1 0 0 0 0 0
#> SRR805776 1 0 1 1 0 0 0 0 0
#> SRR805777 1 0 1 1 0 0 0 0 0
#> SRR805778 1 0 1 1 0 0 0 0 0
#> SRR805779 1 0 1 1 0 0 0 0 0
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 14939 rows and 54 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.720 0.903 0.953 0.4886 0.497 0.497
#> 3 3 0.998 0.961 0.976 0.2888 0.843 0.695
#> 4 4 1.000 0.964 0.986 0.1678 0.847 0.613
#> 5 5 1.000 0.988 0.995 0.1068 0.897 0.625
#> 6 6 1.000 0.996 0.996 0.0152 0.986 0.925
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
#> SRR805725 2 0.0000 0.965 0.000 1.000
#> SRR805726 2 0.0000 0.965 0.000 1.000
#> SRR805727 2 0.0000 0.965 0.000 1.000
#> SRR805728 2 0.0000 0.965 0.000 1.000
#> SRR805729 2 0.0000 0.965 0.000 1.000
#> SRR805730 2 0.0000 0.965 0.000 1.000
#> SRR805731 2 0.0000 0.965 0.000 1.000
#> SRR805732 2 0.0000 0.965 0.000 1.000
#> SRR805733 2 0.0000 0.965 0.000 1.000
#> SRR805735 2 0.0000 0.965 0.000 1.000
#> SRR805736 2 0.0000 0.965 0.000 1.000
#> SRR805737 2 0.0000 0.965 0.000 1.000
#> SRR805738 2 0.0000 0.965 0.000 1.000
#> SRR805739 2 0.0000 0.965 0.000 1.000
#> SRR805740 2 0.0000 0.965 0.000 1.000
#> SRR805741 2 0.0000 0.965 0.000 1.000
#> SRR805742 2 0.0000 0.965 0.000 1.000
#> SRR805743 2 0.0000 0.965 0.000 1.000
#> SRR805744 2 0.0000 0.965 0.000 1.000
#> SRR805745 2 0.0000 0.965 0.000 1.000
#> SRR805746 2 0.0000 0.965 0.000 1.000
#> SRR805747 1 0.7139 0.835 0.804 0.196
#> SRR805748 1 0.7139 0.835 0.804 0.196
#> SRR805749 2 0.9754 0.196 0.408 0.592
#> SRR805750 2 1.0000 -0.147 0.496 0.504
#> SRR805751 2 0.0000 0.965 0.000 1.000
#> SRR805752 2 0.0000 0.965 0.000 1.000
#> SRR805753 2 0.0000 0.965 0.000 1.000
#> SRR805754 2 0.0000 0.965 0.000 1.000
#> SRR805755 2 0.0000 0.965 0.000 1.000
#> SRR805756 2 0.0000 0.965 0.000 1.000
#> SRR805757 2 0.0000 0.965 0.000 1.000
#> SRR805758 1 0.0000 0.926 1.000 0.000
#> SRR805759 1 0.0000 0.926 1.000 0.000
#> SRR805760 1 0.0000 0.926 1.000 0.000
#> SRR805761 1 0.0000 0.926 1.000 0.000
#> SRR805762 1 0.0000 0.926 1.000 0.000
#> SRR805763 1 0.0000 0.926 1.000 0.000
#> SRR805764 1 0.0000 0.926 1.000 0.000
#> SRR805765 1 0.0000 0.926 1.000 0.000
#> SRR805766 1 0.0000 0.926 1.000 0.000
#> SRR805767 1 0.0000 0.926 1.000 0.000
#> SRR805768 1 0.0000 0.926 1.000 0.000
#> SRR805769 1 0.3274 0.921 0.940 0.060
#> SRR805770 1 0.4022 0.916 0.920 0.080
#> SRR805771 1 0.0376 0.926 0.996 0.004
#> SRR805772 1 0.5408 0.899 0.876 0.124
#> SRR805773 1 0.5294 0.901 0.880 0.120
#> SRR805774 1 0.5178 0.903 0.884 0.116
#> SRR805775 1 0.6148 0.879 0.848 0.152
#> SRR805776 1 0.7056 0.840 0.808 0.192
#> SRR805777 1 0.6712 0.857 0.824 0.176
#> SRR805778 1 0.3584 0.920 0.932 0.068
#> SRR805779 1 0.5737 0.891 0.864 0.136
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.0000 0.965 0.000 1.000 0.000
#> SRR805726 2 0.0000 0.965 0.000 1.000 0.000
#> SRR805727 2 0.0000 0.965 0.000 1.000 0.000
#> SRR805728 2 0.0237 0.964 0.004 0.996 0.000
#> SRR805729 2 0.0237 0.964 0.004 0.996 0.000
#> SRR805730 2 0.0424 0.963 0.008 0.992 0.000
#> SRR805731 2 0.0237 0.964 0.004 0.996 0.000
#> SRR805732 2 0.0747 0.959 0.016 0.984 0.000
#> SRR805733 2 0.0592 0.961 0.012 0.988 0.000
#> SRR805735 2 0.0000 0.965 0.000 1.000 0.000
#> SRR805736 2 0.0000 0.965 0.000 1.000 0.000
#> SRR805737 2 0.0000 0.965 0.000 1.000 0.000
#> SRR805738 2 0.0000 0.965 0.000 1.000 0.000
#> SRR805739 2 0.0000 0.965 0.000 1.000 0.000
#> SRR805740 2 0.0000 0.965 0.000 1.000 0.000
#> SRR805741 2 0.0000 0.965 0.000 1.000 0.000
#> SRR805742 2 0.0000 0.965 0.000 1.000 0.000
#> SRR805743 2 0.0000 0.965 0.000 1.000 0.000
#> SRR805744 2 0.0000 0.965 0.000 1.000 0.000
#> SRR805745 2 0.0000 0.965 0.000 1.000 0.000
#> SRR805746 2 0.0000 0.965 0.000 1.000 0.000
#> SRR805747 1 0.0237 0.972 0.996 0.000 0.004
#> SRR805748 1 0.0237 0.972 0.996 0.000 0.004
#> SRR805749 1 0.0000 0.972 1.000 0.000 0.000
#> SRR805750 1 0.2066 0.906 0.940 0.060 0.000
#> SRR805751 2 0.2165 0.928 0.064 0.936 0.000
#> SRR805752 2 0.1031 0.956 0.024 0.976 0.000
#> SRR805753 2 0.1031 0.956 0.024 0.976 0.000
#> SRR805754 2 0.4974 0.741 0.236 0.764 0.000
#> SRR805755 2 0.2878 0.901 0.096 0.904 0.000
#> SRR805756 2 0.4887 0.752 0.228 0.772 0.000
#> SRR805757 2 0.5178 0.710 0.256 0.744 0.000
#> SRR805758 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805759 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805760 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805761 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805762 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805763 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805764 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805765 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805766 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805767 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805768 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805769 1 0.1031 0.987 0.976 0.000 0.024
#> SRR805770 1 0.1031 0.987 0.976 0.000 0.024
#> SRR805771 1 0.1031 0.987 0.976 0.000 0.024
#> SRR805772 1 0.1031 0.987 0.976 0.000 0.024
#> SRR805773 1 0.1031 0.987 0.976 0.000 0.024
#> SRR805774 1 0.1031 0.987 0.976 0.000 0.024
#> SRR805775 1 0.1031 0.987 0.976 0.000 0.024
#> SRR805776 1 0.1031 0.987 0.976 0.000 0.024
#> SRR805777 1 0.1031 0.987 0.976 0.000 0.024
#> SRR805778 1 0.1031 0.987 0.976 0.000 0.024
#> SRR805779 1 0.1031 0.987 0.976 0.000 0.024
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.0000 0.986 0 1.000 0 0.000
#> SRR805726 2 0.0000 0.986 0 1.000 0 0.000
#> SRR805727 2 0.0000 0.986 0 1.000 0 0.000
#> SRR805728 2 0.0921 0.971 0 0.972 0 0.028
#> SRR805729 2 0.0592 0.978 0 0.984 0 0.016
#> SRR805730 2 0.1118 0.965 0 0.964 0 0.036
#> SRR805731 2 0.1302 0.959 0 0.956 0 0.044
#> SRR805732 2 0.1940 0.928 0 0.924 0 0.076
#> SRR805733 2 0.1792 0.937 0 0.932 0 0.068
#> SRR805735 2 0.0188 0.984 0 0.996 0 0.004
#> SRR805736 2 0.0000 0.986 0 1.000 0 0.000
#> SRR805737 2 0.0000 0.986 0 1.000 0 0.000
#> SRR805738 2 0.0000 0.986 0 1.000 0 0.000
#> SRR805739 2 0.0000 0.986 0 1.000 0 0.000
#> SRR805740 2 0.0000 0.986 0 1.000 0 0.000
#> SRR805741 2 0.0000 0.986 0 1.000 0 0.000
#> SRR805742 2 0.0000 0.986 0 1.000 0 0.000
#> SRR805743 2 0.0000 0.986 0 1.000 0 0.000
#> SRR805744 2 0.0000 0.986 0 1.000 0 0.000
#> SRR805745 2 0.0000 0.986 0 1.000 0 0.000
#> SRR805746 2 0.0000 0.986 0 1.000 0 0.000
#> SRR805747 4 0.0000 0.940 0 0.000 0 1.000
#> SRR805748 4 0.0000 0.940 0 0.000 0 1.000
#> SRR805749 4 0.0000 0.940 0 0.000 0 1.000
#> SRR805750 4 0.0000 0.940 0 0.000 0 1.000
#> SRR805751 4 0.0000 0.940 0 0.000 0 1.000
#> SRR805752 4 0.4972 0.130 0 0.456 0 0.544
#> SRR805753 4 0.1022 0.912 0 0.032 0 0.968
#> SRR805754 4 0.0000 0.940 0 0.000 0 1.000
#> SRR805755 4 0.0000 0.940 0 0.000 0 1.000
#> SRR805756 4 0.0000 0.940 0 0.000 0 1.000
#> SRR805757 4 0.0000 0.940 0 0.000 0 1.000
#> SRR805758 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805759 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805760 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805761 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805762 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805763 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805764 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805765 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805766 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805767 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805768 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805769 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805770 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805771 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805772 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805773 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805774 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805775 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805776 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805777 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805778 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805779 1 0.0000 1.000 1 0.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 2 0.000 0.975 0 1.000 0 0.000 0
#> SRR805726 2 0.000 0.975 0 1.000 0 0.000 0
#> SRR805727 2 0.000 0.975 0 1.000 0 0.000 0
#> SRR805728 2 0.000 0.975 0 1.000 0 0.000 0
#> SRR805729 2 0.000 0.975 0 1.000 0 0.000 0
#> SRR805730 2 0.000 0.975 0 1.000 0 0.000 0
#> SRR805731 2 0.000 0.975 0 1.000 0 0.000 0
#> SRR805732 2 0.000 0.975 0 1.000 0 0.000 0
#> SRR805733 2 0.000 0.975 0 1.000 0 0.000 0
#> SRR805735 2 0.000 0.975 0 1.000 0 0.000 0
#> SRR805736 5 0.000 1.000 0 0.000 0 0.000 1
#> SRR805737 5 0.000 1.000 0 0.000 0 0.000 1
#> SRR805738 5 0.000 1.000 0 0.000 0 0.000 1
#> SRR805739 5 0.000 1.000 0 0.000 0 0.000 1
#> SRR805740 5 0.000 1.000 0 0.000 0 0.000 1
#> SRR805741 5 0.000 1.000 0 0.000 0 0.000 1
#> SRR805742 5 0.000 1.000 0 0.000 0 0.000 1
#> SRR805743 5 0.000 1.000 0 0.000 0 0.000 1
#> SRR805744 5 0.000 1.000 0 0.000 0 0.000 1
#> SRR805745 5 0.000 1.000 0 0.000 0 0.000 1
#> SRR805746 5 0.000 1.000 0 0.000 0 0.000 1
#> SRR805747 4 0.000 1.000 0 0.000 0 1.000 0
#> SRR805748 4 0.000 1.000 0 0.000 0 1.000 0
#> SRR805749 4 0.000 1.000 0 0.000 0 1.000 0
#> SRR805750 4 0.000 1.000 0 0.000 0 1.000 0
#> SRR805751 4 0.000 1.000 0 0.000 0 1.000 0
#> SRR805752 2 0.000 0.975 0 1.000 0 0.000 0
#> SRR805753 2 0.364 0.626 0 0.728 0 0.272 0
#> SRR805754 4 0.000 1.000 0 0.000 0 1.000 0
#> SRR805755 4 0.000 1.000 0 0.000 0 1.000 0
#> SRR805756 4 0.000 1.000 0 0.000 0 1.000 0
#> SRR805757 4 0.000 1.000 0 0.000 0 1.000 0
#> SRR805758 3 0.000 1.000 0 0.000 1 0.000 0
#> SRR805759 3 0.000 1.000 0 0.000 1 0.000 0
#> SRR805760 3 0.000 1.000 0 0.000 1 0.000 0
#> SRR805761 3 0.000 1.000 0 0.000 1 0.000 0
#> SRR805762 3 0.000 1.000 0 0.000 1 0.000 0
#> SRR805763 3 0.000 1.000 0 0.000 1 0.000 0
#> SRR805764 3 0.000 1.000 0 0.000 1 0.000 0
#> SRR805765 3 0.000 1.000 0 0.000 1 0.000 0
#> SRR805766 3 0.000 1.000 0 0.000 1 0.000 0
#> SRR805767 3 0.000 1.000 0 0.000 1 0.000 0
#> SRR805768 3 0.000 1.000 0 0.000 1 0.000 0
#> SRR805769 1 0.000 1.000 1 0.000 0 0.000 0
#> SRR805770 1 0.000 1.000 1 0.000 0 0.000 0
#> SRR805771 1 0.000 1.000 1 0.000 0 0.000 0
#> SRR805772 1 0.000 1.000 1 0.000 0 0.000 0
#> SRR805773 1 0.000 1.000 1 0.000 0 0.000 0
#> SRR805774 1 0.000 1.000 1 0.000 0 0.000 0
#> SRR805775 1 0.000 1.000 1 0.000 0 0.000 0
#> SRR805776 1 0.000 1.000 1 0.000 0 0.000 0
#> SRR805777 1 0.000 1.000 1 0.000 0 0.000 0
#> SRR805778 1 0.000 1.000 1 0.000 0 0.000 0
#> SRR805779 1 0.000 1.000 1 0.000 0 0.000 0
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0.0000 1.000 0 1.000 0.000 0.000 0 0.000
#> SRR805726 2 0.0000 1.000 0 1.000 0.000 0.000 0 0.000
#> SRR805727 2 0.0000 1.000 0 1.000 0.000 0.000 0 0.000
#> SRR805728 2 0.0000 1.000 0 1.000 0.000 0.000 0 0.000
#> SRR805729 2 0.0000 1.000 0 1.000 0.000 0.000 0 0.000
#> SRR805730 2 0.0000 1.000 0 1.000 0.000 0.000 0 0.000
#> SRR805731 2 0.0000 1.000 0 1.000 0.000 0.000 0 0.000
#> SRR805732 2 0.0146 0.996 0 0.996 0.000 0.000 0 0.004
#> SRR805733 2 0.0000 1.000 0 1.000 0.000 0.000 0 0.000
#> SRR805735 2 0.0000 1.000 0 1.000 0.000 0.000 0 0.000
#> SRR805736 5 0.0000 1.000 0 0.000 0.000 0.000 1 0.000
#> SRR805737 5 0.0000 1.000 0 0.000 0.000 0.000 1 0.000
#> SRR805738 5 0.0000 1.000 0 0.000 0.000 0.000 1 0.000
#> SRR805739 5 0.0000 1.000 0 0.000 0.000 0.000 1 0.000
#> SRR805740 5 0.0000 1.000 0 0.000 0.000 0.000 1 0.000
#> SRR805741 5 0.0000 1.000 0 0.000 0.000 0.000 1 0.000
#> SRR805742 5 0.0000 1.000 0 0.000 0.000 0.000 1 0.000
#> SRR805743 5 0.0000 1.000 0 0.000 0.000 0.000 1 0.000
#> SRR805744 5 0.0000 1.000 0 0.000 0.000 0.000 1 0.000
#> SRR805745 5 0.0000 1.000 0 0.000 0.000 0.000 1 0.000
#> SRR805746 5 0.0000 1.000 0 0.000 0.000 0.000 1 0.000
#> SRR805747 4 0.0146 0.997 0 0.000 0.000 0.996 0 0.004
#> SRR805748 4 0.0146 0.997 0 0.000 0.000 0.996 0 0.004
#> SRR805749 4 0.0146 0.997 0 0.000 0.000 0.996 0 0.004
#> SRR805750 4 0.0000 0.998 0 0.000 0.000 1.000 0 0.000
#> SRR805751 4 0.0000 0.998 0 0.000 0.000 1.000 0 0.000
#> SRR805752 6 0.1958 0.908 0 0.100 0.000 0.004 0 0.896
#> SRR805753 6 0.2179 0.908 0 0.036 0.000 0.064 0 0.900
#> SRR805754 4 0.0000 0.998 0 0.000 0.000 1.000 0 0.000
#> SRR805755 4 0.0000 0.998 0 0.000 0.000 1.000 0 0.000
#> SRR805756 4 0.0000 0.998 0 0.000 0.000 1.000 0 0.000
#> SRR805757 4 0.0000 0.998 0 0.000 0.000 1.000 0 0.000
#> SRR805758 3 0.0146 0.998 0 0.000 0.996 0.000 0 0.004
#> SRR805759 3 0.0146 0.998 0 0.000 0.996 0.000 0 0.004
#> SRR805760 3 0.0146 0.998 0 0.000 0.996 0.000 0 0.004
#> SRR805761 3 0.0000 0.998 0 0.000 1.000 0.000 0 0.000
#> SRR805762 3 0.0146 0.998 0 0.000 0.996 0.000 0 0.004
#> SRR805763 3 0.0000 0.998 0 0.000 1.000 0.000 0 0.000
#> SRR805764 3 0.0000 0.998 0 0.000 1.000 0.000 0 0.000
#> SRR805765 3 0.0000 0.998 0 0.000 1.000 0.000 0 0.000
#> SRR805766 3 0.0000 0.998 0 0.000 1.000 0.000 0 0.000
#> SRR805767 3 0.0000 0.998 0 0.000 1.000 0.000 0 0.000
#> SRR805768 3 0.0146 0.998 0 0.000 0.996 0.000 0 0.004
#> SRR805769 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR805770 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR805771 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR805772 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR805773 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR805774 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR805775 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR805776 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR805777 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR805778 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR805779 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14939 rows and 54 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.438 0.859 0.912 0.2560 0.799 0.799
#> 3 3 0.372 0.695 0.813 1.1332 0.632 0.539
#> 4 4 0.661 0.608 0.752 0.2569 0.850 0.693
#> 5 5 0.928 0.885 0.933 0.1271 0.809 0.520
#> 6 6 0.896 0.920 0.939 0.0457 0.980 0.906
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
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
#> SRR805725 1 0.745 0.825 0.788 0.212
#> SRR805726 1 0.745 0.825 0.788 0.212
#> SRR805727 1 0.745 0.825 0.788 0.212
#> SRR805728 1 0.753 0.821 0.784 0.216
#> SRR805729 1 0.745 0.825 0.788 0.212
#> SRR805730 2 0.767 0.705 0.224 0.776
#> SRR805731 2 0.767 0.705 0.224 0.776
#> SRR805732 2 0.000 0.890 0.000 1.000
#> SRR805733 2 0.000 0.890 0.000 1.000
#> SRR805735 1 0.753 0.821 0.784 0.216
#> SRR805736 1 0.745 0.825 0.788 0.212
#> SRR805737 1 0.745 0.825 0.788 0.212
#> SRR805738 1 0.745 0.825 0.788 0.212
#> SRR805739 1 0.745 0.825 0.788 0.212
#> SRR805740 1 0.745 0.825 0.788 0.212
#> SRR805741 1 0.745 0.825 0.788 0.212
#> SRR805742 1 0.745 0.825 0.788 0.212
#> SRR805743 1 0.745 0.825 0.788 0.212
#> SRR805744 1 0.745 0.825 0.788 0.212
#> SRR805745 1 0.745 0.825 0.788 0.212
#> SRR805746 1 0.745 0.825 0.788 0.212
#> SRR805747 1 0.000 0.889 1.000 0.000
#> SRR805748 1 0.000 0.889 1.000 0.000
#> SRR805749 1 0.000 0.889 1.000 0.000
#> SRR805750 1 0.000 0.889 1.000 0.000
#> SRR805751 1 0.000 0.889 1.000 0.000
#> SRR805752 2 0.000 0.890 0.000 1.000
#> SRR805753 2 0.000 0.890 0.000 1.000
#> SRR805754 1 0.000 0.889 1.000 0.000
#> SRR805755 1 0.000 0.889 1.000 0.000
#> SRR805756 1 0.000 0.889 1.000 0.000
#> SRR805757 1 0.000 0.889 1.000 0.000
#> SRR805758 1 0.000 0.889 1.000 0.000
#> SRR805759 1 0.000 0.889 1.000 0.000
#> SRR805760 1 0.000 0.889 1.000 0.000
#> SRR805761 1 0.000 0.889 1.000 0.000
#> SRR805762 1 0.000 0.889 1.000 0.000
#> SRR805763 1 0.595 0.853 0.856 0.144
#> SRR805764 1 0.595 0.853 0.856 0.144
#> SRR805765 1 0.595 0.853 0.856 0.144
#> SRR805766 1 0.595 0.853 0.856 0.144
#> SRR805767 1 0.552 0.857 0.872 0.128
#> SRR805768 1 0.000 0.889 1.000 0.000
#> SRR805769 1 0.000 0.889 1.000 0.000
#> SRR805770 1 0.000 0.889 1.000 0.000
#> SRR805771 1 0.000 0.889 1.000 0.000
#> SRR805772 1 0.000 0.889 1.000 0.000
#> SRR805773 1 0.000 0.889 1.000 0.000
#> SRR805774 1 0.000 0.889 1.000 0.000
#> SRR805775 1 0.000 0.889 1.000 0.000
#> SRR805776 1 0.000 0.889 1.000 0.000
#> SRR805777 1 0.000 0.889 1.000 0.000
#> SRR805778 1 0.000 0.889 1.000 0.000
#> SRR805779 1 0.000 0.889 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.778 0.801 0.256 0.648 0.096
#> SRR805726 2 0.778 0.801 0.256 0.648 0.096
#> SRR805727 2 0.778 0.801 0.256 0.648 0.096
#> SRR805728 2 0.782 0.797 0.252 0.648 0.100
#> SRR805729 2 0.778 0.801 0.256 0.648 0.096
#> SRR805730 3 0.583 0.555 0.000 0.340 0.660
#> SRR805731 3 0.583 0.555 0.000 0.340 0.660
#> SRR805732 3 0.000 0.828 0.000 0.000 1.000
#> SRR805733 3 0.000 0.828 0.000 0.000 1.000
#> SRR805735 2 0.782 0.797 0.252 0.648 0.100
#> SRR805736 2 0.778 0.801 0.256 0.648 0.096
#> SRR805737 2 0.778 0.801 0.256 0.648 0.096
#> SRR805738 2 0.778 0.801 0.256 0.648 0.096
#> SRR805739 2 0.778 0.801 0.256 0.648 0.096
#> SRR805740 2 0.778 0.801 0.256 0.648 0.096
#> SRR805741 2 0.778 0.801 0.256 0.648 0.096
#> SRR805742 2 0.778 0.801 0.256 0.648 0.096
#> SRR805743 2 0.778 0.801 0.256 0.648 0.096
#> SRR805744 2 0.778 0.801 0.256 0.648 0.096
#> SRR805745 2 0.778 0.801 0.256 0.648 0.096
#> SRR805746 2 0.778 0.801 0.256 0.648 0.096
#> SRR805747 2 0.630 0.653 0.472 0.528 0.000
#> SRR805748 2 0.630 0.653 0.472 0.528 0.000
#> SRR805749 2 0.630 0.653 0.472 0.528 0.000
#> SRR805750 2 0.630 0.653 0.472 0.528 0.000
#> SRR805751 2 0.630 0.653 0.472 0.528 0.000
#> SRR805752 3 0.000 0.828 0.000 0.000 1.000
#> SRR805753 3 0.000 0.828 0.000 0.000 1.000
#> SRR805754 2 0.630 0.653 0.472 0.528 0.000
#> SRR805755 2 0.630 0.653 0.472 0.528 0.000
#> SRR805756 2 0.630 0.653 0.472 0.528 0.000
#> SRR805757 2 0.630 0.653 0.472 0.528 0.000
#> SRR805758 1 0.627 0.594 0.548 0.452 0.000
#> SRR805759 1 0.627 0.594 0.548 0.452 0.000
#> SRR805760 1 0.627 0.594 0.548 0.452 0.000
#> SRR805761 1 0.627 0.594 0.548 0.452 0.000
#> SRR805762 1 0.627 0.594 0.548 0.452 0.000
#> SRR805763 2 0.359 0.323 0.076 0.896 0.028
#> SRR805764 2 0.359 0.323 0.076 0.896 0.028
#> SRR805765 2 0.359 0.323 0.076 0.896 0.028
#> SRR805766 2 0.359 0.323 0.076 0.896 0.028
#> SRR805767 2 0.494 0.177 0.148 0.824 0.028
#> SRR805768 1 0.627 0.594 0.548 0.452 0.000
#> SRR805769 1 0.000 0.780 1.000 0.000 0.000
#> SRR805770 1 0.000 0.780 1.000 0.000 0.000
#> SRR805771 1 0.000 0.780 1.000 0.000 0.000
#> SRR805772 1 0.000 0.780 1.000 0.000 0.000
#> SRR805773 1 0.000 0.780 1.000 0.000 0.000
#> SRR805774 1 0.000 0.780 1.000 0.000 0.000
#> SRR805775 1 0.000 0.780 1.000 0.000 0.000
#> SRR805776 1 0.000 0.780 1.000 0.000 0.000
#> SRR805777 1 0.000 0.780 1.000 0.000 0.000
#> SRR805778 1 0.000 0.780 1.000 0.000 0.000
#> SRR805779 1 0.000 0.780 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.4985 0.7880 0.000 0.532 0.000 NA
#> SRR805726 2 0.4985 0.7880 0.000 0.532 0.000 NA
#> SRR805727 2 0.4985 0.7880 0.000 0.532 0.000 NA
#> SRR805728 2 0.5155 0.7845 0.000 0.528 0.004 NA
#> SRR805729 2 0.4985 0.7880 0.000 0.532 0.000 NA
#> SRR805730 3 0.6158 0.5675 0.000 0.088 0.640 NA
#> SRR805731 3 0.6158 0.5675 0.000 0.088 0.640 NA
#> SRR805732 3 0.0000 0.8149 0.000 0.000 1.000 NA
#> SRR805733 3 0.0000 0.8149 0.000 0.000 1.000 NA
#> SRR805735 2 0.5155 0.7845 0.000 0.528 0.004 NA
#> SRR805736 2 0.4985 0.7880 0.000 0.532 0.000 NA
#> SRR805737 2 0.4985 0.7880 0.000 0.532 0.000 NA
#> SRR805738 2 0.4985 0.7880 0.000 0.532 0.000 NA
#> SRR805739 2 0.4985 0.7880 0.000 0.532 0.000 NA
#> SRR805740 2 0.4985 0.7880 0.000 0.532 0.000 NA
#> SRR805741 2 0.4985 0.7880 0.000 0.532 0.000 NA
#> SRR805742 2 0.4985 0.7880 0.000 0.532 0.000 NA
#> SRR805743 2 0.4985 0.7880 0.000 0.532 0.000 NA
#> SRR805744 2 0.4985 0.7880 0.000 0.532 0.000 NA
#> SRR805745 2 0.4985 0.7880 0.000 0.532 0.000 NA
#> SRR805746 2 0.4985 0.7880 0.000 0.532 0.000 NA
#> SRR805747 2 0.0188 0.5607 0.004 0.996 0.000 NA
#> SRR805748 2 0.0188 0.5607 0.004 0.996 0.000 NA
#> SRR805749 2 0.0188 0.5607 0.004 0.996 0.000 NA
#> SRR805750 2 0.0188 0.5607 0.004 0.996 0.000 NA
#> SRR805751 2 0.0188 0.5607 0.004 0.996 0.000 NA
#> SRR805752 3 0.0000 0.8149 0.000 0.000 1.000 NA
#> SRR805753 3 0.0000 0.8149 0.000 0.000 1.000 NA
#> SRR805754 2 0.0188 0.5607 0.004 0.996 0.000 NA
#> SRR805755 2 0.0188 0.5607 0.004 0.996 0.000 NA
#> SRR805756 2 0.0188 0.5607 0.004 0.996 0.000 NA
#> SRR805757 2 0.0188 0.5607 0.004 0.996 0.000 NA
#> SRR805758 1 0.0000 0.4986 1.000 0.000 0.000 NA
#> SRR805759 1 0.0000 0.4986 1.000 0.000 0.000 NA
#> SRR805760 1 0.0000 0.4986 1.000 0.000 0.000 NA
#> SRR805761 1 0.0000 0.4986 1.000 0.000 0.000 NA
#> SRR805762 1 0.0000 0.4986 1.000 0.000 0.000 NA
#> SRR805763 1 0.4989 0.0861 0.528 0.000 0.000 NA
#> SRR805764 1 0.4989 0.0861 0.528 0.000 0.000 NA
#> SRR805765 1 0.4989 0.0861 0.528 0.000 0.000 NA
#> SRR805766 1 0.4989 0.0861 0.528 0.000 0.000 NA
#> SRR805767 1 0.4855 0.1503 0.600 0.000 0.000 NA
#> SRR805768 1 0.0000 0.4986 1.000 0.000 0.000 NA
#> SRR805769 1 0.6795 0.5916 0.472 0.096 0.000 NA
#> SRR805770 1 0.6795 0.5916 0.472 0.096 0.000 NA
#> SRR805771 1 0.6795 0.5916 0.472 0.096 0.000 NA
#> SRR805772 1 0.6795 0.5916 0.472 0.096 0.000 NA
#> SRR805773 1 0.6795 0.5916 0.472 0.096 0.000 NA
#> SRR805774 1 0.6795 0.5916 0.472 0.096 0.000 NA
#> SRR805775 1 0.6795 0.5916 0.472 0.096 0.000 NA
#> SRR805776 1 0.6795 0.5916 0.472 0.096 0.000 NA
#> SRR805777 1 0.6795 0.5916 0.472 0.096 0.000 NA
#> SRR805778 1 0.6795 0.5916 0.472 0.096 0.000 NA
#> SRR805779 1 0.6795 0.5916 0.472 0.096 0.000 NA
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805726 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805727 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805728 5 0.0162 0.996 0.000 0.004 0.000 0 0.996
#> SRR805729 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805730 2 0.4060 0.549 0.000 0.640 0.000 0 0.360
#> SRR805731 2 0.4060 0.549 0.000 0.640 0.000 0 0.360
#> SRR805732 2 0.0000 0.810 0.000 1.000 0.000 0 0.000
#> SRR805733 2 0.0000 0.810 0.000 1.000 0.000 0 0.000
#> SRR805735 5 0.0162 0.996 0.000 0.004 0.000 0 0.996
#> SRR805736 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805737 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805738 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805739 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805740 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805741 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805742 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805743 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805744 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805745 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805746 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805747 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805748 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805749 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805750 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805751 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805752 2 0.0000 0.810 0.000 1.000 0.000 0 0.000
#> SRR805753 2 0.0000 0.810 0.000 1.000 0.000 0 0.000
#> SRR805754 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805755 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805756 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805757 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805758 3 0.4297 0.571 0.472 0.000 0.528 0 0.000
#> SRR805759 3 0.4297 0.571 0.472 0.000 0.528 0 0.000
#> SRR805760 3 0.4297 0.571 0.472 0.000 0.528 0 0.000
#> SRR805761 3 0.4297 0.571 0.472 0.000 0.528 0 0.000
#> SRR805762 3 0.4297 0.571 0.472 0.000 0.528 0 0.000
#> SRR805763 3 0.0000 0.606 0.000 0.000 1.000 0 0.000
#> SRR805764 3 0.0000 0.606 0.000 0.000 1.000 0 0.000
#> SRR805765 3 0.0000 0.606 0.000 0.000 1.000 0 0.000
#> SRR805766 3 0.0000 0.606 0.000 0.000 1.000 0 0.000
#> SRR805767 3 0.1608 0.633 0.072 0.000 0.928 0 0.000
#> SRR805768 3 0.4297 0.571 0.472 0.000 0.528 0 0.000
#> SRR805769 1 0.0000 1.000 1.000 0.000 0.000 0 0.000
#> SRR805770 1 0.0000 1.000 1.000 0.000 0.000 0 0.000
#> SRR805771 1 0.0000 1.000 1.000 0.000 0.000 0 0.000
#> SRR805772 1 0.0000 1.000 1.000 0.000 0.000 0 0.000
#> SRR805773 1 0.0000 1.000 1.000 0.000 0.000 0 0.000
#> SRR805774 1 0.0000 1.000 1.000 0.000 0.000 0 0.000
#> SRR805775 1 0.0000 1.000 1.000 0.000 0.000 0 0.000
#> SRR805776 1 0.0000 1.000 1.000 0.000 0.000 0 0.000
#> SRR805777 1 0.0000 1.000 1.000 0.000 0.000 0 0.000
#> SRR805778 1 0.0000 1.000 1.000 0.000 0.000 0 0.000
#> SRR805779 1 0.0000 1.000 1.000 0.000 0.000 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 5 0.263 0.858 0.000 0.0 0.180 0 0.820 0.000
#> SRR805726 5 0.263 0.858 0.000 0.0 0.180 0 0.820 0.000
#> SRR805727 5 0.263 0.858 0.000 0.0 0.180 0 0.820 0.000
#> SRR805728 5 0.277 0.855 0.000 0.0 0.180 0 0.816 0.004
#> SRR805729 5 0.263 0.858 0.000 0.0 0.180 0 0.820 0.000
#> SRR805730 6 0.504 0.630 0.000 0.0 0.180 0 0.180 0.640
#> SRR805731 6 0.504 0.630 0.000 0.0 0.180 0 0.180 0.640
#> SRR805732 6 0.000 0.815 0.000 0.0 0.000 0 0.000 1.000
#> SRR805733 6 0.000 0.815 0.000 0.0 0.000 0 0.000 1.000
#> SRR805735 5 0.277 0.855 0.000 0.0 0.180 0 0.816 0.004
#> SRR805736 5 0.000 0.927 0.000 0.0 0.000 0 1.000 0.000
#> SRR805737 5 0.000 0.927 0.000 0.0 0.000 0 1.000 0.000
#> SRR805738 5 0.000 0.927 0.000 0.0 0.000 0 1.000 0.000
#> SRR805739 5 0.000 0.927 0.000 0.0 0.000 0 1.000 0.000
#> SRR805740 5 0.000 0.927 0.000 0.0 0.000 0 1.000 0.000
#> SRR805741 5 0.000 0.927 0.000 0.0 0.000 0 1.000 0.000
#> SRR805742 5 0.000 0.927 0.000 0.0 0.000 0 1.000 0.000
#> SRR805743 5 0.000 0.927 0.000 0.0 0.000 0 1.000 0.000
#> SRR805744 5 0.000 0.927 0.000 0.0 0.000 0 1.000 0.000
#> SRR805745 5 0.000 0.927 0.000 0.0 0.000 0 1.000 0.000
#> SRR805746 5 0.000 0.927 0.000 0.0 0.000 0 1.000 0.000
#> SRR805747 4 0.000 1.000 0.000 0.0 0.000 1 0.000 0.000
#> SRR805748 4 0.000 1.000 0.000 0.0 0.000 1 0.000 0.000
#> SRR805749 4 0.000 1.000 0.000 0.0 0.000 1 0.000 0.000
#> SRR805750 4 0.000 1.000 0.000 0.0 0.000 1 0.000 0.000
#> SRR805751 4 0.000 1.000 0.000 0.0 0.000 1 0.000 0.000
#> SRR805752 6 0.000 0.815 0.000 0.0 0.000 0 0.000 1.000
#> SRR805753 6 0.000 0.815 0.000 0.0 0.000 0 0.000 1.000
#> SRR805754 4 0.000 1.000 0.000 0.0 0.000 1 0.000 0.000
#> SRR805755 4 0.000 1.000 0.000 0.0 0.000 1 0.000 0.000
#> SRR805756 4 0.000 1.000 0.000 0.0 0.000 1 0.000 0.000
#> SRR805757 4 0.000 1.000 0.000 0.0 0.000 1 0.000 0.000
#> SRR805758 3 0.263 0.925 0.180 0.0 0.820 0 0.000 0.000
#> SRR805759 3 0.263 0.925 0.180 0.0 0.820 0 0.000 0.000
#> SRR805760 3 0.263 0.925 0.180 0.0 0.820 0 0.000 0.000
#> SRR805761 3 0.263 0.925 0.180 0.0 0.820 0 0.000 0.000
#> SRR805762 3 0.263 0.925 0.180 0.0 0.820 0 0.000 0.000
#> SRR805763 2 0.000 1.000 0.000 1.0 0.000 0 0.000 0.000
#> SRR805764 2 0.000 1.000 0.000 1.0 0.000 0 0.000 0.000
#> SRR805765 2 0.000 1.000 0.000 1.0 0.000 0 0.000 0.000
#> SRR805766 2 0.000 1.000 0.000 1.0 0.000 0 0.000 0.000
#> SRR805767 3 0.389 0.272 0.004 0.4 0.596 0 0.000 0.000
#> SRR805768 3 0.263 0.925 0.180 0.0 0.820 0 0.000 0.000
#> SRR805769 1 0.000 1.000 1.000 0.0 0.000 0 0.000 0.000
#> SRR805770 1 0.000 1.000 1.000 0.0 0.000 0 0.000 0.000
#> SRR805771 1 0.000 1.000 1.000 0.0 0.000 0 0.000 0.000
#> SRR805772 1 0.000 1.000 1.000 0.0 0.000 0 0.000 0.000
#> SRR805773 1 0.000 1.000 1.000 0.0 0.000 0 0.000 0.000
#> SRR805774 1 0.000 1.000 1.000 0.0 0.000 0 0.000 0.000
#> SRR805775 1 0.000 1.000 1.000 0.0 0.000 0 0.000 0.000
#> SRR805776 1 0.000 1.000 1.000 0.0 0.000 0 0.000 0.000
#> SRR805777 1 0.000 1.000 1.000 0.0 0.000 0 0.000 0.000
#> SRR805778 1 0.000 1.000 1.000 0.0 0.000 0 0.000 0.000
#> SRR805779 1 0.000 1.000 1.000 0.0 0.000 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "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 14939 rows and 54 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.703 0.931 0.943 0.4904 0.502 0.502
#> 3 3 0.499 0.689 0.721 0.2942 0.862 0.724
#> 4 4 0.604 0.849 0.764 0.1392 0.915 0.767
#> 5 5 0.772 0.905 0.813 0.0813 0.908 0.669
#> 6 6 0.836 0.866 0.837 0.0473 1.000 1.000
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 2
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805725 2 0.0672 0.986 0.008 0.992
#> SRR805726 2 0.0938 0.986 0.012 0.988
#> SRR805727 2 0.0672 0.986 0.008 0.992
#> SRR805728 2 0.0938 0.985 0.012 0.988
#> SRR805729 2 0.0672 0.986 0.008 0.992
#> SRR805730 2 0.1184 0.983 0.016 0.984
#> SRR805731 2 0.1184 0.983 0.016 0.984
#> SRR805732 2 0.1184 0.983 0.016 0.984
#> SRR805733 2 0.1184 0.983 0.016 0.984
#> SRR805735 2 0.0938 0.985 0.012 0.988
#> SRR805736 2 0.0938 0.986 0.012 0.988
#> SRR805737 2 0.0938 0.986 0.012 0.988
#> SRR805738 2 0.0938 0.986 0.012 0.988
#> SRR805739 2 0.0938 0.986 0.012 0.988
#> SRR805740 2 0.0938 0.986 0.012 0.988
#> SRR805741 2 0.0938 0.986 0.012 0.988
#> SRR805742 2 0.0938 0.986 0.012 0.988
#> SRR805743 2 0.0938 0.986 0.012 0.988
#> SRR805744 2 0.0938 0.986 0.012 0.988
#> SRR805745 2 0.0938 0.986 0.012 0.988
#> SRR805746 2 0.0938 0.986 0.012 0.988
#> SRR805747 1 0.4815 0.910 0.896 0.104
#> SRR805748 1 0.4815 0.910 0.896 0.104
#> SRR805749 1 0.4815 0.910 0.896 0.104
#> SRR805750 1 0.4815 0.910 0.896 0.104
#> SRR805751 1 0.8267 0.764 0.740 0.260
#> SRR805752 2 0.1184 0.983 0.016 0.984
#> SRR805753 2 0.1184 0.983 0.016 0.984
#> SRR805754 1 0.8267 0.764 0.740 0.260
#> SRR805755 1 0.8267 0.764 0.740 0.260
#> SRR805756 1 0.8267 0.764 0.740 0.260
#> SRR805757 1 0.8267 0.764 0.740 0.260
#> SRR805758 1 0.0376 0.908 0.996 0.004
#> SRR805759 1 0.0938 0.907 0.988 0.012
#> SRR805760 1 0.0938 0.907 0.988 0.012
#> SRR805761 1 0.0938 0.907 0.988 0.012
#> SRR805762 1 0.0938 0.907 0.988 0.012
#> SRR805763 1 0.3114 0.900 0.944 0.056
#> SRR805764 1 0.3114 0.900 0.944 0.056
#> SRR805765 1 0.3114 0.900 0.944 0.056
#> SRR805766 1 0.3114 0.900 0.944 0.056
#> SRR805767 1 0.0938 0.907 0.988 0.012
#> SRR805768 1 0.0938 0.907 0.988 0.012
#> SRR805769 1 0.3733 0.926 0.928 0.072
#> SRR805770 1 0.3733 0.926 0.928 0.072
#> SRR805771 1 0.3733 0.926 0.928 0.072
#> SRR805772 1 0.3733 0.926 0.928 0.072
#> SRR805773 1 0.3733 0.926 0.928 0.072
#> SRR805774 1 0.3733 0.926 0.928 0.072
#> SRR805775 1 0.3733 0.926 0.928 0.072
#> SRR805776 1 0.3733 0.926 0.928 0.072
#> SRR805777 1 0.3733 0.926 0.928 0.072
#> SRR805778 1 0.3733 0.926 0.928 0.072
#> SRR805779 1 0.3733 0.926 0.928 0.072
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.4121 0.840 0.168 0.832 0.000
#> SRR805726 2 0.4121 0.840 0.168 0.832 0.000
#> SRR805727 2 0.4121 0.840 0.168 0.832 0.000
#> SRR805728 2 0.5098 0.823 0.248 0.752 0.000
#> SRR805729 2 0.4121 0.840 0.168 0.832 0.000
#> SRR805730 2 0.5835 0.784 0.340 0.660 0.000
#> SRR805731 2 0.5835 0.784 0.340 0.660 0.000
#> SRR805732 2 0.5835 0.784 0.340 0.660 0.000
#> SRR805733 2 0.5835 0.784 0.340 0.660 0.000
#> SRR805735 2 0.5098 0.823 0.248 0.752 0.000
#> SRR805736 2 0.0747 0.844 0.016 0.984 0.000
#> SRR805737 2 0.0747 0.844 0.016 0.984 0.000
#> SRR805738 2 0.0747 0.844 0.016 0.984 0.000
#> SRR805739 2 0.0747 0.844 0.016 0.984 0.000
#> SRR805740 2 0.0747 0.844 0.016 0.984 0.000
#> SRR805741 2 0.0747 0.844 0.016 0.984 0.000
#> SRR805742 2 0.0747 0.844 0.016 0.984 0.000
#> SRR805743 2 0.0237 0.845 0.004 0.996 0.000
#> SRR805744 2 0.0747 0.844 0.016 0.984 0.000
#> SRR805745 2 0.0747 0.844 0.016 0.984 0.000
#> SRR805746 2 0.0747 0.844 0.016 0.984 0.000
#> SRR805747 1 0.9014 0.829 0.484 0.136 0.380
#> SRR805748 1 0.9014 0.829 0.484 0.136 0.380
#> SRR805749 1 0.9014 0.829 0.484 0.136 0.380
#> SRR805750 1 0.9014 0.829 0.484 0.136 0.380
#> SRR805751 1 0.9461 0.879 0.496 0.224 0.280
#> SRR805752 2 0.5859 0.781 0.344 0.656 0.000
#> SRR805753 2 0.5859 0.781 0.344 0.656 0.000
#> SRR805754 1 0.9461 0.879 0.496 0.224 0.280
#> SRR805755 1 0.9461 0.879 0.496 0.224 0.280
#> SRR805756 1 0.9461 0.879 0.496 0.224 0.280
#> SRR805757 1 0.9481 0.879 0.492 0.224 0.284
#> SRR805758 3 0.0000 0.532 0.000 0.000 1.000
#> SRR805759 3 0.0000 0.532 0.000 0.000 1.000
#> SRR805760 3 0.0000 0.532 0.000 0.000 1.000
#> SRR805761 3 0.0000 0.532 0.000 0.000 1.000
#> SRR805762 3 0.0000 0.532 0.000 0.000 1.000
#> SRR805763 3 0.4121 0.437 0.108 0.024 0.868
#> SRR805764 3 0.4413 0.415 0.124 0.024 0.852
#> SRR805765 3 0.4413 0.415 0.124 0.024 0.852
#> SRR805766 3 0.4121 0.437 0.108 0.024 0.868
#> SRR805767 3 0.1163 0.517 0.028 0.000 0.972
#> SRR805768 3 0.0000 0.532 0.000 0.000 1.000
#> SRR805769 3 0.6521 0.457 0.496 0.004 0.500
#> SRR805770 3 0.6518 0.468 0.484 0.004 0.512
#> SRR805771 3 0.6518 0.468 0.484 0.004 0.512
#> SRR805772 3 0.6521 0.457 0.496 0.004 0.500
#> SRR805773 3 0.6521 0.457 0.496 0.004 0.500
#> SRR805774 3 0.6521 0.457 0.496 0.004 0.500
#> SRR805775 3 0.6518 0.468 0.484 0.004 0.512
#> SRR805776 3 0.6521 0.457 0.496 0.004 0.500
#> SRR805777 3 0.6521 0.457 0.496 0.004 0.500
#> SRR805778 3 0.6518 0.468 0.484 0.004 0.512
#> SRR805779 3 0.6521 0.457 0.496 0.004 0.500
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.1888 0.721 0.000 0.940 0.016 0.044
#> SRR805726 2 0.1888 0.721 0.000 0.940 0.016 0.044
#> SRR805727 2 0.1888 0.721 0.000 0.940 0.016 0.044
#> SRR805728 2 0.1406 0.715 0.000 0.960 0.024 0.016
#> SRR805729 2 0.1888 0.721 0.000 0.940 0.016 0.044
#> SRR805730 2 0.3754 0.659 0.000 0.852 0.064 0.084
#> SRR805731 2 0.4030 0.658 0.000 0.836 0.072 0.092
#> SRR805732 2 0.4030 0.658 0.000 0.836 0.072 0.092
#> SRR805733 2 0.4030 0.658 0.000 0.836 0.072 0.092
#> SRR805735 2 0.1406 0.715 0.000 0.960 0.024 0.016
#> SRR805736 2 0.6978 0.723 0.008 0.544 0.100 0.348
#> SRR805737 2 0.6978 0.723 0.008 0.544 0.100 0.348
#> SRR805738 2 0.6978 0.723 0.008 0.544 0.100 0.348
#> SRR805739 2 0.6978 0.723 0.008 0.544 0.100 0.348
#> SRR805740 2 0.6978 0.723 0.008 0.544 0.100 0.348
#> SRR805741 2 0.6978 0.723 0.008 0.544 0.100 0.348
#> SRR805742 2 0.6978 0.723 0.008 0.544 0.100 0.348
#> SRR805743 2 0.6677 0.724 0.000 0.552 0.100 0.348
#> SRR805744 2 0.6978 0.723 0.008 0.544 0.100 0.348
#> SRR805745 2 0.7047 0.723 0.008 0.544 0.108 0.340
#> SRR805746 2 0.7047 0.723 0.008 0.544 0.108 0.340
#> SRR805747 4 0.6924 0.946 0.304 0.016 0.092 0.588
#> SRR805748 4 0.6924 0.946 0.304 0.016 0.092 0.588
#> SRR805749 4 0.6924 0.946 0.304 0.016 0.092 0.588
#> SRR805750 4 0.6924 0.946 0.304 0.016 0.092 0.588
#> SRR805751 4 0.7323 0.959 0.252 0.048 0.092 0.608
#> SRR805752 2 0.4030 0.658 0.000 0.836 0.072 0.092
#> SRR805753 2 0.4030 0.658 0.000 0.836 0.072 0.092
#> SRR805754 4 0.7323 0.959 0.252 0.048 0.092 0.608
#> SRR805755 4 0.7323 0.959 0.252 0.048 0.092 0.608
#> SRR805756 4 0.7323 0.959 0.252 0.048 0.092 0.608
#> SRR805757 4 0.7323 0.959 0.252 0.048 0.092 0.608
#> SRR805758 3 0.3569 0.935 0.196 0.000 0.804 0.000
#> SRR805759 3 0.3569 0.935 0.196 0.000 0.804 0.000
#> SRR805760 3 0.3569 0.935 0.196 0.000 0.804 0.000
#> SRR805761 3 0.3569 0.935 0.196 0.000 0.804 0.000
#> SRR805762 3 0.3569 0.935 0.196 0.000 0.804 0.000
#> SRR805763 3 0.4897 0.902 0.108 0.044 0.808 0.040
#> SRR805764 3 0.4897 0.902 0.108 0.044 0.808 0.040
#> SRR805765 3 0.4897 0.902 0.108 0.044 0.808 0.040
#> SRR805766 3 0.4897 0.902 0.108 0.044 0.808 0.040
#> SRR805767 3 0.4553 0.926 0.180 0.000 0.780 0.040
#> SRR805768 3 0.3569 0.935 0.196 0.000 0.804 0.000
#> SRR805769 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR805770 1 0.0524 0.988 0.988 0.000 0.008 0.004
#> SRR805771 1 0.0524 0.988 0.988 0.000 0.008 0.004
#> SRR805772 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR805773 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR805774 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR805775 1 0.0672 0.987 0.984 0.000 0.008 0.008
#> SRR805776 1 0.0336 0.990 0.992 0.000 0.000 0.008
#> SRR805777 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR805778 1 0.0524 0.988 0.988 0.000 0.008 0.004
#> SRR805779 1 0.0000 0.993 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
#> SRR805725 2 0.4054 0.716 0.000 0.748 0.028 0.000 0.224
#> SRR805726 2 0.4054 0.716 0.000 0.748 0.028 0.000 0.224
#> SRR805727 2 0.4054 0.716 0.000 0.748 0.028 0.000 0.224
#> SRR805728 2 0.3760 0.743 0.000 0.784 0.028 0.000 0.188
#> SRR805729 2 0.4054 0.716 0.000 0.748 0.028 0.000 0.224
#> SRR805730 2 0.0404 0.774 0.000 0.988 0.012 0.000 0.000
#> SRR805731 2 0.2208 0.775 0.072 0.908 0.000 0.020 0.000
#> SRR805732 2 0.2208 0.775 0.072 0.908 0.000 0.020 0.000
#> SRR805733 2 0.2208 0.775 0.072 0.908 0.000 0.020 0.000
#> SRR805735 2 0.3760 0.743 0.000 0.784 0.028 0.000 0.188
#> SRR805736 5 0.4418 0.969 0.020 0.196 0.008 0.016 0.760
#> SRR805737 5 0.4125 0.974 0.012 0.196 0.008 0.012 0.772
#> SRR805738 5 0.3074 0.977 0.000 0.196 0.000 0.000 0.804
#> SRR805739 5 0.4418 0.969 0.020 0.196 0.008 0.016 0.760
#> SRR805740 5 0.3074 0.977 0.000 0.196 0.000 0.000 0.804
#> SRR805741 5 0.3896 0.975 0.012 0.196 0.004 0.008 0.780
#> SRR805742 5 0.4117 0.973 0.016 0.196 0.008 0.008 0.772
#> SRR805743 5 0.3509 0.974 0.008 0.196 0.004 0.000 0.792
#> SRR805744 5 0.3618 0.973 0.012 0.196 0.004 0.000 0.788
#> SRR805745 5 0.4017 0.970 0.012 0.196 0.008 0.008 0.776
#> SRR805746 5 0.4017 0.970 0.012 0.196 0.008 0.008 0.776
#> SRR805747 4 0.3460 0.955 0.024 0.008 0.036 0.864 0.068
#> SRR805748 4 0.3460 0.955 0.024 0.008 0.036 0.864 0.068
#> SRR805749 4 0.3460 0.955 0.024 0.008 0.036 0.864 0.068
#> SRR805750 4 0.3460 0.955 0.024 0.008 0.036 0.864 0.068
#> SRR805751 4 0.2082 0.965 0.000 0.016 0.024 0.928 0.032
#> SRR805752 2 0.2208 0.775 0.072 0.908 0.000 0.020 0.000
#> SRR805753 2 0.2208 0.775 0.072 0.908 0.000 0.020 0.000
#> SRR805754 4 0.2082 0.965 0.000 0.016 0.024 0.928 0.032
#> SRR805755 4 0.2082 0.965 0.000 0.016 0.024 0.928 0.032
#> SRR805756 4 0.2082 0.965 0.000 0.016 0.024 0.928 0.032
#> SRR805757 4 0.2082 0.965 0.000 0.016 0.024 0.928 0.032
#> SRR805758 3 0.1484 0.924 0.048 0.000 0.944 0.008 0.000
#> SRR805759 3 0.1484 0.924 0.048 0.000 0.944 0.008 0.000
#> SRR805760 3 0.1484 0.924 0.048 0.000 0.944 0.008 0.000
#> SRR805761 3 0.1484 0.924 0.048 0.000 0.944 0.008 0.000
#> SRR805762 3 0.1484 0.924 0.048 0.000 0.944 0.008 0.000
#> SRR805763 3 0.3970 0.902 0.044 0.028 0.844 0.024 0.060
#> SRR805764 3 0.3970 0.902 0.044 0.028 0.844 0.024 0.060
#> SRR805765 3 0.3970 0.902 0.044 0.028 0.844 0.024 0.060
#> SRR805766 3 0.3970 0.902 0.044 0.028 0.844 0.024 0.060
#> SRR805767 3 0.3854 0.907 0.068 0.004 0.840 0.028 0.060
#> SRR805768 3 0.1484 0.924 0.048 0.000 0.944 0.008 0.000
#> SRR805769 1 0.3242 0.956 0.844 0.000 0.040 0.116 0.000
#> SRR805770 1 0.5083 0.945 0.752 0.000 0.048 0.116 0.084
#> SRR805771 1 0.5083 0.945 0.752 0.000 0.048 0.116 0.084
#> SRR805772 1 0.3242 0.956 0.844 0.000 0.040 0.116 0.000
#> SRR805773 1 0.3242 0.956 0.844 0.000 0.040 0.116 0.000
#> SRR805774 1 0.3242 0.956 0.844 0.000 0.040 0.116 0.000
#> SRR805775 1 0.5137 0.944 0.748 0.000 0.048 0.116 0.088
#> SRR805776 1 0.5087 0.945 0.748 0.000 0.040 0.124 0.088
#> SRR805777 1 0.3242 0.956 0.844 0.000 0.040 0.116 0.000
#> SRR805778 1 0.5083 0.945 0.752 0.000 0.048 0.116 0.084
#> SRR805779 1 0.3242 0.956 0.844 0.000 0.040 0.116 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0.6167 0.727 0.000 0.416 0.004 0.000 0.292 NA
#> SRR805726 2 0.6167 0.727 0.000 0.416 0.004 0.000 0.292 NA
#> SRR805727 2 0.6167 0.727 0.000 0.416 0.004 0.000 0.292 NA
#> SRR805728 2 0.6110 0.740 0.000 0.440 0.004 0.000 0.268 NA
#> SRR805729 2 0.6167 0.727 0.000 0.416 0.004 0.000 0.292 NA
#> SRR805730 2 0.5120 0.747 0.000 0.600 0.000 0.000 0.120 NA
#> SRR805731 2 0.2048 0.727 0.000 0.880 0.000 0.000 0.120 NA
#> SRR805732 2 0.2048 0.727 0.000 0.880 0.000 0.000 0.120 NA
#> SRR805733 2 0.2048 0.727 0.000 0.880 0.000 0.000 0.120 NA
#> SRR805735 2 0.6110 0.740 0.000 0.440 0.004 0.000 0.268 NA
#> SRR805736 5 0.1007 0.966 0.000 0.000 0.000 0.000 0.956 NA
#> SRR805737 5 0.0790 0.970 0.000 0.000 0.000 0.000 0.968 NA
#> SRR805738 5 0.0000 0.973 0.000 0.000 0.000 0.000 1.000 NA
#> SRR805739 5 0.1007 0.966 0.000 0.000 0.000 0.000 0.956 NA
#> SRR805740 5 0.0000 0.973 0.000 0.000 0.000 0.000 1.000 NA
#> SRR805741 5 0.0260 0.972 0.000 0.000 0.000 0.000 0.992 NA
#> SRR805742 5 0.0622 0.971 0.000 0.000 0.000 0.008 0.980 NA
#> SRR805743 5 0.0405 0.970 0.000 0.000 0.000 0.008 0.988 NA
#> SRR805744 5 0.0806 0.967 0.000 0.000 0.000 0.008 0.972 NA
#> SRR805745 5 0.1657 0.948 0.000 0.000 0.000 0.016 0.928 NA
#> SRR805746 5 0.1657 0.948 0.000 0.000 0.000 0.016 0.928 NA
#> SRR805747 4 0.3862 0.941 0.036 0.036 0.020 0.832 0.008 NA
#> SRR805748 4 0.3883 0.941 0.036 0.044 0.020 0.832 0.008 NA
#> SRR805749 4 0.3862 0.941 0.036 0.036 0.020 0.832 0.008 NA
#> SRR805750 4 0.3883 0.941 0.036 0.044 0.020 0.832 0.008 NA
#> SRR805751 4 0.1807 0.954 0.024 0.012 0.016 0.936 0.012 NA
#> SRR805752 2 0.2257 0.725 0.000 0.876 0.000 0.008 0.116 NA
#> SRR805753 2 0.2257 0.725 0.000 0.876 0.000 0.008 0.116 NA
#> SRR805754 4 0.1807 0.954 0.024 0.012 0.016 0.936 0.012 NA
#> SRR805755 4 0.1807 0.954 0.024 0.012 0.016 0.936 0.012 NA
#> SRR805756 4 0.1807 0.954 0.024 0.012 0.016 0.936 0.012 NA
#> SRR805757 4 0.1807 0.954 0.024 0.012 0.016 0.936 0.012 NA
#> SRR805758 3 0.0508 0.861 0.004 0.012 0.984 0.000 0.000 NA
#> SRR805759 3 0.0146 0.863 0.004 0.000 0.996 0.000 0.000 NA
#> SRR805760 3 0.0291 0.863 0.004 0.004 0.992 0.000 0.000 NA
#> SRR805761 3 0.0291 0.863 0.004 0.004 0.992 0.000 0.000 NA
#> SRR805762 3 0.0146 0.863 0.004 0.000 0.996 0.000 0.000 NA
#> SRR805763 3 0.4111 0.833 0.000 0.004 0.676 0.024 0.000 NA
#> SRR805764 3 0.4165 0.833 0.000 0.004 0.676 0.028 0.000 NA
#> SRR805765 3 0.4111 0.833 0.000 0.004 0.676 0.024 0.000 NA
#> SRR805766 3 0.4111 0.833 0.000 0.004 0.676 0.024 0.000 NA
#> SRR805767 3 0.3974 0.834 0.000 0.000 0.680 0.024 0.000 NA
#> SRR805768 3 0.0146 0.863 0.004 0.000 0.996 0.000 0.000 NA
#> SRR805769 1 0.0146 0.875 0.996 0.000 0.000 0.004 0.000 NA
#> SRR805770 1 0.3979 0.851 0.708 0.036 0.000 0.000 0.000 NA
#> SRR805771 1 0.3979 0.851 0.708 0.036 0.000 0.000 0.000 NA
#> SRR805772 1 0.0363 0.875 0.988 0.012 0.000 0.000 0.000 NA
#> SRR805773 1 0.0458 0.875 0.984 0.016 0.000 0.000 0.000 NA
#> SRR805774 1 0.0405 0.875 0.988 0.008 0.000 0.004 0.000 NA
#> SRR805775 1 0.4067 0.848 0.700 0.040 0.000 0.000 0.000 NA
#> SRR805776 1 0.4067 0.848 0.700 0.040 0.000 0.000 0.000 NA
#> SRR805777 1 0.0000 0.875 1.000 0.000 0.000 0.000 0.000 NA
#> SRR805778 1 0.3979 0.851 0.708 0.036 0.000 0.000 0.000 NA
#> SRR805779 1 0.0000 0.875 1.000 0.000 0.000 0.000 0.000 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 14939 rows and 54 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.994 0.997 0.4994 0.502 0.502
#> 3 3 0.846 0.979 0.979 0.3032 0.846 0.694
#> 4 4 1.000 0.990 0.980 0.1101 0.931 0.801
#> 5 5 1.000 1.000 0.999 0.1258 0.908 0.669
#> 6 6 0.954 0.977 0.951 0.0299 0.975 0.865
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 4 5
There is also optional best \(k\) = 2 4 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805725 2 0.000 1.000 0.00 1.00
#> SRR805726 2 0.000 1.000 0.00 1.00
#> SRR805727 2 0.000 1.000 0.00 1.00
#> SRR805728 2 0.000 1.000 0.00 1.00
#> SRR805729 2 0.000 1.000 0.00 1.00
#> SRR805730 2 0.000 1.000 0.00 1.00
#> SRR805731 2 0.000 1.000 0.00 1.00
#> SRR805732 2 0.000 1.000 0.00 1.00
#> SRR805733 2 0.000 1.000 0.00 1.00
#> SRR805735 2 0.000 1.000 0.00 1.00
#> SRR805736 2 0.000 1.000 0.00 1.00
#> SRR805737 2 0.000 1.000 0.00 1.00
#> SRR805738 2 0.000 1.000 0.00 1.00
#> SRR805739 2 0.000 1.000 0.00 1.00
#> SRR805740 2 0.000 1.000 0.00 1.00
#> SRR805741 2 0.000 1.000 0.00 1.00
#> SRR805742 2 0.000 1.000 0.00 1.00
#> SRR805743 2 0.000 1.000 0.00 1.00
#> SRR805744 2 0.000 1.000 0.00 1.00
#> SRR805745 2 0.000 1.000 0.00 1.00
#> SRR805746 2 0.000 1.000 0.00 1.00
#> SRR805747 1 0.000 0.995 1.00 0.00
#> SRR805748 1 0.000 0.995 1.00 0.00
#> SRR805749 1 0.000 0.995 1.00 0.00
#> SRR805750 1 0.000 0.995 1.00 0.00
#> SRR805751 1 0.000 0.995 1.00 0.00
#> SRR805752 2 0.000 1.000 0.00 1.00
#> SRR805753 2 0.000 1.000 0.00 1.00
#> SRR805754 1 0.000 0.995 1.00 0.00
#> SRR805755 1 0.000 0.995 1.00 0.00
#> SRR805756 1 0.000 0.995 1.00 0.00
#> SRR805757 1 0.000 0.995 1.00 0.00
#> SRR805758 1 0.000 0.995 1.00 0.00
#> SRR805759 1 0.000 0.995 1.00 0.00
#> SRR805760 1 0.000 0.995 1.00 0.00
#> SRR805761 1 0.000 0.995 1.00 0.00
#> SRR805762 1 0.000 0.995 1.00 0.00
#> SRR805763 1 0.000 0.995 1.00 0.00
#> SRR805764 1 0.584 0.837 0.86 0.14
#> SRR805765 1 0.000 0.995 1.00 0.00
#> SRR805766 1 0.000 0.995 1.00 0.00
#> SRR805767 1 0.000 0.995 1.00 0.00
#> SRR805768 1 0.000 0.995 1.00 0.00
#> SRR805769 1 0.000 0.995 1.00 0.00
#> SRR805770 1 0.000 0.995 1.00 0.00
#> SRR805771 1 0.000 0.995 1.00 0.00
#> SRR805772 1 0.000 0.995 1.00 0.00
#> SRR805773 1 0.000 0.995 1.00 0.00
#> SRR805774 1 0.000 0.995 1.00 0.00
#> SRR805775 1 0.000 0.995 1.00 0.00
#> SRR805776 1 0.000 0.995 1.00 0.00
#> SRR805777 1 0.000 0.995 1.00 0.00
#> SRR805778 1 0.000 0.995 1.00 0.00
#> SRR805779 1 0.000 0.995 1.00 0.00
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.0000 1.000 0.000 1 0.000
#> SRR805726 2 0.0000 1.000 0.000 1 0.000
#> SRR805727 2 0.0000 1.000 0.000 1 0.000
#> SRR805728 2 0.0000 1.000 0.000 1 0.000
#> SRR805729 2 0.0000 1.000 0.000 1 0.000
#> SRR805730 2 0.0000 1.000 0.000 1 0.000
#> SRR805731 2 0.0000 1.000 0.000 1 0.000
#> SRR805732 2 0.0000 1.000 0.000 1 0.000
#> SRR805733 2 0.0000 1.000 0.000 1 0.000
#> SRR805735 2 0.0000 1.000 0.000 1 0.000
#> SRR805736 2 0.0000 1.000 0.000 1 0.000
#> SRR805737 2 0.0000 1.000 0.000 1 0.000
#> SRR805738 2 0.0000 1.000 0.000 1 0.000
#> SRR805739 2 0.0000 1.000 0.000 1 0.000
#> SRR805740 2 0.0000 1.000 0.000 1 0.000
#> SRR805741 2 0.0000 1.000 0.000 1 0.000
#> SRR805742 2 0.0000 1.000 0.000 1 0.000
#> SRR805743 2 0.0000 1.000 0.000 1 0.000
#> SRR805744 2 0.0000 1.000 0.000 1 0.000
#> SRR805745 2 0.0000 1.000 0.000 1 0.000
#> SRR805746 2 0.0000 1.000 0.000 1 0.000
#> SRR805747 1 0.0237 0.937 0.996 0 0.004
#> SRR805748 1 0.0237 0.937 0.996 0 0.004
#> SRR805749 1 0.0237 0.937 0.996 0 0.004
#> SRR805750 1 0.0237 0.937 0.996 0 0.004
#> SRR805751 1 0.0237 0.937 0.996 0 0.004
#> SRR805752 2 0.0000 1.000 0.000 1 0.000
#> SRR805753 2 0.0000 1.000 0.000 1 0.000
#> SRR805754 1 0.0237 0.937 0.996 0 0.004
#> SRR805755 1 0.0237 0.937 0.996 0 0.004
#> SRR805756 1 0.0237 0.937 0.996 0 0.004
#> SRR805757 1 0.0237 0.937 0.996 0 0.004
#> SRR805758 3 0.0000 1.000 0.000 0 1.000
#> SRR805759 3 0.0000 1.000 0.000 0 1.000
#> SRR805760 3 0.0000 1.000 0.000 0 1.000
#> SRR805761 3 0.0000 1.000 0.000 0 1.000
#> SRR805762 3 0.0000 1.000 0.000 0 1.000
#> SRR805763 3 0.0000 1.000 0.000 0 1.000
#> SRR805764 3 0.0000 1.000 0.000 0 1.000
#> SRR805765 3 0.0000 1.000 0.000 0 1.000
#> SRR805766 3 0.0000 1.000 0.000 0 1.000
#> SRR805767 3 0.0000 1.000 0.000 0 1.000
#> SRR805768 3 0.0000 1.000 0.000 0 1.000
#> SRR805769 1 0.2959 0.947 0.900 0 0.100
#> SRR805770 1 0.2959 0.947 0.900 0 0.100
#> SRR805771 1 0.2959 0.947 0.900 0 0.100
#> SRR805772 1 0.2959 0.947 0.900 0 0.100
#> SRR805773 1 0.2959 0.947 0.900 0 0.100
#> SRR805774 1 0.2959 0.947 0.900 0 0.100
#> SRR805775 1 0.2959 0.947 0.900 0 0.100
#> SRR805776 1 0.2959 0.947 0.900 0 0.100
#> SRR805777 1 0.2959 0.947 0.900 0 0.100
#> SRR805778 1 0.2959 0.947 0.900 0 0.100
#> SRR805779 1 0.2959 0.947 0.900 0 0.100
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.0000 0.978 0.000 1.000 0.000 0.00
#> SRR805726 2 0.0000 0.978 0.000 1.000 0.000 0.00
#> SRR805727 2 0.0000 0.978 0.000 1.000 0.000 0.00
#> SRR805728 2 0.0000 0.978 0.000 1.000 0.000 0.00
#> SRR805729 2 0.0000 0.978 0.000 1.000 0.000 0.00
#> SRR805730 2 0.0000 0.978 0.000 1.000 0.000 0.00
#> SRR805731 2 0.0000 0.978 0.000 1.000 0.000 0.00
#> SRR805732 2 0.0000 0.978 0.000 1.000 0.000 0.00
#> SRR805733 2 0.0000 0.978 0.000 1.000 0.000 0.00
#> SRR805735 2 0.0000 0.978 0.000 1.000 0.000 0.00
#> SRR805736 2 0.1677 0.975 0.000 0.948 0.012 0.04
#> SRR805737 2 0.1677 0.975 0.000 0.948 0.012 0.04
#> SRR805738 2 0.1677 0.975 0.000 0.948 0.012 0.04
#> SRR805739 2 0.1677 0.975 0.000 0.948 0.012 0.04
#> SRR805740 2 0.1677 0.975 0.000 0.948 0.012 0.04
#> SRR805741 2 0.1677 0.975 0.000 0.948 0.012 0.04
#> SRR805742 2 0.1677 0.975 0.000 0.948 0.012 0.04
#> SRR805743 2 0.1677 0.975 0.000 0.948 0.012 0.04
#> SRR805744 2 0.1677 0.975 0.000 0.948 0.012 0.04
#> SRR805745 2 0.1677 0.975 0.000 0.948 0.012 0.04
#> SRR805746 2 0.1677 0.975 0.000 0.948 0.012 0.04
#> SRR805747 4 0.1211 1.000 0.040 0.000 0.000 0.96
#> SRR805748 4 0.1211 1.000 0.040 0.000 0.000 0.96
#> SRR805749 4 0.1211 1.000 0.040 0.000 0.000 0.96
#> SRR805750 4 0.1211 1.000 0.040 0.000 0.000 0.96
#> SRR805751 4 0.1211 1.000 0.040 0.000 0.000 0.96
#> SRR805752 2 0.0000 0.978 0.000 1.000 0.000 0.00
#> SRR805753 2 0.0000 0.978 0.000 1.000 0.000 0.00
#> SRR805754 4 0.1211 1.000 0.040 0.000 0.000 0.96
#> SRR805755 4 0.1211 1.000 0.040 0.000 0.000 0.96
#> SRR805756 4 0.1211 1.000 0.040 0.000 0.000 0.96
#> SRR805757 4 0.1211 1.000 0.040 0.000 0.000 0.96
#> SRR805758 3 0.0469 1.000 0.012 0.000 0.988 0.00
#> SRR805759 3 0.0469 1.000 0.012 0.000 0.988 0.00
#> SRR805760 3 0.0469 1.000 0.012 0.000 0.988 0.00
#> SRR805761 3 0.0469 1.000 0.012 0.000 0.988 0.00
#> SRR805762 3 0.0469 1.000 0.012 0.000 0.988 0.00
#> SRR805763 3 0.0469 1.000 0.012 0.000 0.988 0.00
#> SRR805764 3 0.0469 1.000 0.012 0.000 0.988 0.00
#> SRR805765 3 0.0469 1.000 0.012 0.000 0.988 0.00
#> SRR805766 3 0.0469 1.000 0.012 0.000 0.988 0.00
#> SRR805767 3 0.0469 1.000 0.012 0.000 0.988 0.00
#> SRR805768 3 0.0469 1.000 0.012 0.000 0.988 0.00
#> SRR805769 1 0.0000 1.000 1.000 0.000 0.000 0.00
#> SRR805770 1 0.0000 1.000 1.000 0.000 0.000 0.00
#> SRR805771 1 0.0000 1.000 1.000 0.000 0.000 0.00
#> SRR805772 1 0.0000 1.000 1.000 0.000 0.000 0.00
#> SRR805773 1 0.0000 1.000 1.000 0.000 0.000 0.00
#> SRR805774 1 0.0000 1.000 1.000 0.000 0.000 0.00
#> SRR805775 1 0.0000 1.000 1.000 0.000 0.000 0.00
#> SRR805776 1 0.0000 1.000 1.000 0.000 0.000 0.00
#> SRR805777 1 0.0000 1.000 1.000 0.000 0.000 0.00
#> SRR805778 1 0.0000 1.000 1.000 0.000 0.000 0.00
#> SRR805779 1 0.0000 1.000 1.000 0.000 0.000 0.00
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR805726 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR805727 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR805728 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR805729 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR805730 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR805731 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR805732 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR805733 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR805735 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR805736 5 0.0162 1.000 0 0.004 0.000 0 0.996
#> SRR805737 5 0.0162 1.000 0 0.004 0.000 0 0.996
#> SRR805738 5 0.0162 1.000 0 0.004 0.000 0 0.996
#> SRR805739 5 0.0162 1.000 0 0.004 0.000 0 0.996
#> SRR805740 5 0.0162 1.000 0 0.004 0.000 0 0.996
#> SRR805741 5 0.0162 1.000 0 0.004 0.000 0 0.996
#> SRR805742 5 0.0162 1.000 0 0.004 0.000 0 0.996
#> SRR805743 5 0.0162 1.000 0 0.004 0.000 0 0.996
#> SRR805744 5 0.0162 1.000 0 0.004 0.000 0 0.996
#> SRR805745 5 0.0162 1.000 0 0.004 0.000 0 0.996
#> SRR805746 5 0.0162 1.000 0 0.004 0.000 0 0.996
#> SRR805747 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805748 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805749 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805750 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805751 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805752 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR805753 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR805754 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805755 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805756 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805757 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR805758 3 0.0000 0.999 0 0.000 1.000 0 0.000
#> SRR805759 3 0.0000 0.999 0 0.000 1.000 0 0.000
#> SRR805760 3 0.0000 0.999 0 0.000 1.000 0 0.000
#> SRR805761 3 0.0000 0.999 0 0.000 1.000 0 0.000
#> SRR805762 3 0.0000 0.999 0 0.000 1.000 0 0.000
#> SRR805763 3 0.0162 0.998 0 0.000 0.996 0 0.004
#> SRR805764 3 0.0162 0.998 0 0.000 0.996 0 0.004
#> SRR805765 3 0.0162 0.998 0 0.000 0.996 0 0.004
#> SRR805766 3 0.0162 0.998 0 0.000 0.996 0 0.004
#> SRR805767 3 0.0162 0.998 0 0.000 0.996 0 0.004
#> SRR805768 3 0.0000 0.999 0 0.000 1.000 0 0.000
#> SRR805769 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805770 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805771 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805772 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805773 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805774 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805775 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805776 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805777 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805778 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR805779 1 0.0000 1.000 1 0.000 0.000 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0.3076 1.000 0.00 0.76 0.00 0 0 0.24
#> SRR805726 2 0.3076 1.000 0.00 0.76 0.00 0 0 0.24
#> SRR805727 2 0.3076 1.000 0.00 0.76 0.00 0 0 0.24
#> SRR805728 2 0.3076 1.000 0.00 0.76 0.00 0 0 0.24
#> SRR805729 2 0.3076 1.000 0.00 0.76 0.00 0 0 0.24
#> SRR805730 6 0.0000 1.000 0.00 0.00 0.00 0 0 1.00
#> SRR805731 6 0.0000 1.000 0.00 0.00 0.00 0 0 1.00
#> SRR805732 6 0.0000 1.000 0.00 0.00 0.00 0 0 1.00
#> SRR805733 6 0.0000 1.000 0.00 0.00 0.00 0 0 1.00
#> SRR805735 2 0.3076 1.000 0.00 0.76 0.00 0 0 0.24
#> SRR805736 5 0.0000 1.000 0.00 0.00 0.00 0 1 0.00
#> SRR805737 5 0.0000 1.000 0.00 0.00 0.00 0 1 0.00
#> SRR805738 5 0.0000 1.000 0.00 0.00 0.00 0 1 0.00
#> SRR805739 5 0.0000 1.000 0.00 0.00 0.00 0 1 0.00
#> SRR805740 5 0.0000 1.000 0.00 0.00 0.00 0 1 0.00
#> SRR805741 5 0.0000 1.000 0.00 0.00 0.00 0 1 0.00
#> SRR805742 5 0.0000 1.000 0.00 0.00 0.00 0 1 0.00
#> SRR805743 5 0.0000 1.000 0.00 0.00 0.00 0 1 0.00
#> SRR805744 5 0.0000 1.000 0.00 0.00 0.00 0 1 0.00
#> SRR805745 5 0.0000 1.000 0.00 0.00 0.00 0 1 0.00
#> SRR805746 5 0.0000 1.000 0.00 0.00 0.00 0 1 0.00
#> SRR805747 4 0.0000 1.000 0.00 0.00 0.00 1 0 0.00
#> SRR805748 4 0.0000 1.000 0.00 0.00 0.00 1 0 0.00
#> SRR805749 4 0.0000 1.000 0.00 0.00 0.00 1 0 0.00
#> SRR805750 4 0.0000 1.000 0.00 0.00 0.00 1 0 0.00
#> SRR805751 4 0.0000 1.000 0.00 0.00 0.00 1 0 0.00
#> SRR805752 6 0.0000 1.000 0.00 0.00 0.00 0 0 1.00
#> SRR805753 6 0.0000 1.000 0.00 0.00 0.00 0 0 1.00
#> SRR805754 4 0.0000 1.000 0.00 0.00 0.00 1 0 0.00
#> SRR805755 4 0.0000 1.000 0.00 0.00 0.00 1 0 0.00
#> SRR805756 4 0.0000 1.000 0.00 0.00 0.00 1 0 0.00
#> SRR805757 4 0.0000 1.000 0.00 0.00 0.00 1 0 0.00
#> SRR805758 3 0.2941 0.907 0.00 0.22 0.78 0 0 0.00
#> SRR805759 3 0.2941 0.907 0.00 0.22 0.78 0 0 0.00
#> SRR805760 3 0.2941 0.907 0.00 0.22 0.78 0 0 0.00
#> SRR805761 3 0.2941 0.907 0.00 0.22 0.78 0 0 0.00
#> SRR805762 3 0.2941 0.907 0.00 0.22 0.78 0 0 0.00
#> SRR805763 3 0.0000 0.887 0.00 0.00 1.00 0 0 0.00
#> SRR805764 3 0.0000 0.887 0.00 0.00 1.00 0 0 0.00
#> SRR805765 3 0.0000 0.887 0.00 0.00 1.00 0 0 0.00
#> SRR805766 3 0.0000 0.887 0.00 0.00 1.00 0 0 0.00
#> SRR805767 3 0.0000 0.887 0.00 0.00 1.00 0 0 0.00
#> SRR805768 3 0.2941 0.907 0.00 0.22 0.78 0 0 0.00
#> SRR805769 1 0.0000 0.992 1.00 0.00 0.00 0 0 0.00
#> SRR805770 1 0.0547 0.990 0.98 0.02 0.00 0 0 0.00
#> SRR805771 1 0.0547 0.990 0.98 0.02 0.00 0 0 0.00
#> SRR805772 1 0.0000 0.992 1.00 0.00 0.00 0 0 0.00
#> SRR805773 1 0.0000 0.992 1.00 0.00 0.00 0 0 0.00
#> SRR805774 1 0.0000 0.992 1.00 0.00 0.00 0 0 0.00
#> SRR805775 1 0.0547 0.990 0.98 0.02 0.00 0 0 0.00
#> SRR805776 1 0.0547 0.990 0.98 0.02 0.00 0 0 0.00
#> SRR805777 1 0.0000 0.992 1.00 0.00 0.00 0 0 0.00
#> SRR805778 1 0.0547 0.990 0.98 0.02 0.00 0 0 0.00
#> SRR805779 1 0.0000 0.992 1.00 0.00 0.00 0 0 0.00
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 14939 rows and 54 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.918 0.909 0.963 0.4998 0.493 0.493
#> 3 3 0.933 0.923 0.967 0.2830 0.823 0.654
#> 4 4 0.826 0.929 0.947 0.1377 0.904 0.738
#> 5 5 1.000 1.000 1.000 0.1152 0.908 0.669
#> 6 6 0.956 0.969 0.959 0.0293 0.976 0.869
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 5
There is also optional best \(k\) = 2 3 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805725 2 0.0000 0.9784 0.000 1.000
#> SRR805726 2 0.0000 0.9784 0.000 1.000
#> SRR805727 2 0.0000 0.9784 0.000 1.000
#> SRR805728 2 0.0000 0.9784 0.000 1.000
#> SRR805729 2 0.0000 0.9784 0.000 1.000
#> SRR805730 2 0.0000 0.9784 0.000 1.000
#> SRR805731 2 0.0000 0.9784 0.000 1.000
#> SRR805732 2 0.0000 0.9784 0.000 1.000
#> SRR805733 2 0.0000 0.9784 0.000 1.000
#> SRR805735 2 0.0000 0.9784 0.000 1.000
#> SRR805736 2 0.0000 0.9784 0.000 1.000
#> SRR805737 2 0.0000 0.9784 0.000 1.000
#> SRR805738 2 0.0000 0.9784 0.000 1.000
#> SRR805739 2 0.0000 0.9784 0.000 1.000
#> SRR805740 2 0.0000 0.9784 0.000 1.000
#> SRR805741 2 0.0000 0.9784 0.000 1.000
#> SRR805742 2 0.0000 0.9784 0.000 1.000
#> SRR805743 2 0.0000 0.9784 0.000 1.000
#> SRR805744 2 0.0000 0.9784 0.000 1.000
#> SRR805745 2 0.0000 0.9784 0.000 1.000
#> SRR805746 2 0.0000 0.9784 0.000 1.000
#> SRR805747 1 0.2603 0.9103 0.956 0.044
#> SRR805748 1 0.3584 0.8933 0.932 0.068
#> SRR805749 1 0.0000 0.9364 1.000 0.000
#> SRR805750 1 0.4431 0.8742 0.908 0.092
#> SRR805751 2 0.1843 0.9511 0.028 0.972
#> SRR805752 2 0.0000 0.9784 0.000 1.000
#> SRR805753 2 0.0000 0.9784 0.000 1.000
#> SRR805754 1 0.9427 0.5054 0.640 0.360
#> SRR805755 2 0.9993 -0.0921 0.484 0.516
#> SRR805756 1 0.9393 0.5141 0.644 0.356
#> SRR805757 1 0.9323 0.5302 0.652 0.348
#> SRR805758 1 0.0000 0.9364 1.000 0.000
#> SRR805759 1 0.0000 0.9364 1.000 0.000
#> SRR805760 1 0.0000 0.9364 1.000 0.000
#> SRR805761 1 0.0000 0.9364 1.000 0.000
#> SRR805762 1 0.0000 0.9364 1.000 0.000
#> SRR805763 2 0.0672 0.9726 0.008 0.992
#> SRR805764 2 0.0672 0.9726 0.008 0.992
#> SRR805765 2 0.0672 0.9726 0.008 0.992
#> SRR805766 2 0.0672 0.9726 0.008 0.992
#> SRR805767 1 0.7056 0.7643 0.808 0.192
#> SRR805768 1 0.0000 0.9364 1.000 0.000
#> SRR805769 1 0.0000 0.9364 1.000 0.000
#> SRR805770 1 0.0000 0.9364 1.000 0.000
#> SRR805771 1 0.0000 0.9364 1.000 0.000
#> SRR805772 1 0.0000 0.9364 1.000 0.000
#> SRR805773 1 0.0000 0.9364 1.000 0.000
#> SRR805774 1 0.0000 0.9364 1.000 0.000
#> SRR805775 1 0.0000 0.9364 1.000 0.000
#> SRR805776 1 0.0000 0.9364 1.000 0.000
#> SRR805777 1 0.0000 0.9364 1.000 0.000
#> SRR805778 1 0.0000 0.9364 1.000 0.000
#> SRR805779 1 0.0000 0.9364 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805726 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805727 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805728 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805729 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805730 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805731 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805732 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805733 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805735 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805736 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805737 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805738 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805739 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805740 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805741 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805742 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805743 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805744 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805745 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805746 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805747 1 0.440 0.7698 0.812 0.000 0.188
#> SRR805748 1 0.315 0.8775 0.916 0.048 0.036
#> SRR805749 1 0.000 0.9173 1.000 0.000 0.000
#> SRR805750 1 0.496 0.8230 0.836 0.048 0.116
#> SRR805751 2 0.116 0.9476 0.028 0.972 0.000
#> SRR805752 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805753 2 0.000 0.9764 0.000 1.000 0.000
#> SRR805754 1 0.536 0.6693 0.724 0.276 0.000
#> SRR805755 2 0.630 -0.0897 0.484 0.516 0.000
#> SRR805756 1 0.546 0.6489 0.712 0.288 0.000
#> SRR805757 1 0.510 0.7100 0.752 0.248 0.000
#> SRR805758 3 0.000 1.0000 0.000 0.000 1.000
#> SRR805759 3 0.000 1.0000 0.000 0.000 1.000
#> SRR805760 3 0.000 1.0000 0.000 0.000 1.000
#> SRR805761 3 0.000 1.0000 0.000 0.000 1.000
#> SRR805762 3 0.000 1.0000 0.000 0.000 1.000
#> SRR805763 3 0.000 1.0000 0.000 0.000 1.000
#> SRR805764 3 0.000 1.0000 0.000 0.000 1.000
#> SRR805765 3 0.000 1.0000 0.000 0.000 1.000
#> SRR805766 3 0.000 1.0000 0.000 0.000 1.000
#> SRR805767 3 0.000 1.0000 0.000 0.000 1.000
#> SRR805768 3 0.000 1.0000 0.000 0.000 1.000
#> SRR805769 1 0.000 0.9173 1.000 0.000 0.000
#> SRR805770 1 0.000 0.9173 1.000 0.000 0.000
#> SRR805771 1 0.000 0.9173 1.000 0.000 0.000
#> SRR805772 1 0.000 0.9173 1.000 0.000 0.000
#> SRR805773 1 0.000 0.9173 1.000 0.000 0.000
#> SRR805774 1 0.000 0.9173 1.000 0.000 0.000
#> SRR805775 1 0.000 0.9173 1.000 0.000 0.000
#> SRR805776 1 0.000 0.9173 1.000 0.000 0.000
#> SRR805777 1 0.000 0.9173 1.000 0.000 0.000
#> SRR805778 1 0.000 0.9173 1.000 0.000 0.000
#> SRR805779 1 0.000 0.9173 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.3123 0.900 0.000 0.844 0 0.156
#> SRR805726 2 0.3172 0.897 0.000 0.840 0 0.160
#> SRR805727 2 0.3123 0.900 0.000 0.844 0 0.156
#> SRR805728 2 0.3123 0.900 0.000 0.844 0 0.156
#> SRR805729 2 0.3123 0.900 0.000 0.844 0 0.156
#> SRR805730 2 0.3123 0.900 0.000 0.844 0 0.156
#> SRR805731 2 0.3123 0.900 0.000 0.844 0 0.156
#> SRR805732 2 0.3123 0.900 0.000 0.844 0 0.156
#> SRR805733 2 0.3123 0.900 0.000 0.844 0 0.156
#> SRR805735 2 0.3123 0.900 0.000 0.844 0 0.156
#> SRR805736 2 0.0000 0.900 0.000 1.000 0 0.000
#> SRR805737 2 0.0000 0.900 0.000 1.000 0 0.000
#> SRR805738 2 0.0000 0.900 0.000 1.000 0 0.000
#> SRR805739 2 0.0000 0.900 0.000 1.000 0 0.000
#> SRR805740 2 0.0000 0.900 0.000 1.000 0 0.000
#> SRR805741 2 0.0000 0.900 0.000 1.000 0 0.000
#> SRR805742 2 0.0000 0.900 0.000 1.000 0 0.000
#> SRR805743 2 0.0000 0.900 0.000 1.000 0 0.000
#> SRR805744 2 0.0000 0.900 0.000 1.000 0 0.000
#> SRR805745 2 0.0000 0.900 0.000 1.000 0 0.000
#> SRR805746 2 0.0000 0.900 0.000 1.000 0 0.000
#> SRR805747 4 0.3123 0.867 0.156 0.000 0 0.844
#> SRR805748 4 0.3123 0.867 0.156 0.000 0 0.844
#> SRR805749 4 0.3123 0.867 0.156 0.000 0 0.844
#> SRR805750 4 0.3123 0.867 0.156 0.000 0 0.844
#> SRR805751 4 0.0188 0.890 0.000 0.004 0 0.996
#> SRR805752 2 0.3123 0.900 0.000 0.844 0 0.156
#> SRR805753 2 0.4994 0.371 0.000 0.520 0 0.480
#> SRR805754 4 0.0592 0.904 0.016 0.000 0 0.984
#> SRR805755 4 0.0592 0.904 0.016 0.000 0 0.984
#> SRR805756 4 0.0592 0.904 0.016 0.000 0 0.984
#> SRR805757 4 0.0592 0.904 0.016 0.000 0 0.984
#> SRR805758 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805759 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805760 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805761 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805762 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805763 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805764 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805765 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805766 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805767 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805768 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805769 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805770 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805771 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805772 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805773 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805774 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805775 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805776 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805777 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805778 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805779 1 0.0000 1.000 1.000 0.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 2 0 1 0 1 0 0 0
#> SRR805726 2 0 1 0 1 0 0 0
#> SRR805727 2 0 1 0 1 0 0 0
#> SRR805728 2 0 1 0 1 0 0 0
#> SRR805729 2 0 1 0 1 0 0 0
#> SRR805730 2 0 1 0 1 0 0 0
#> SRR805731 2 0 1 0 1 0 0 0
#> SRR805732 2 0 1 0 1 0 0 0
#> SRR805733 2 0 1 0 1 0 0 0
#> SRR805735 2 0 1 0 1 0 0 0
#> SRR805736 5 0 1 0 0 0 0 1
#> SRR805737 5 0 1 0 0 0 0 1
#> SRR805738 5 0 1 0 0 0 0 1
#> SRR805739 5 0 1 0 0 0 0 1
#> SRR805740 5 0 1 0 0 0 0 1
#> SRR805741 5 0 1 0 0 0 0 1
#> SRR805742 5 0 1 0 0 0 0 1
#> SRR805743 5 0 1 0 0 0 0 1
#> SRR805744 5 0 1 0 0 0 0 1
#> SRR805745 5 0 1 0 0 0 0 1
#> SRR805746 5 0 1 0 0 0 0 1
#> SRR805747 4 0 1 0 0 0 1 0
#> SRR805748 4 0 1 0 0 0 1 0
#> SRR805749 4 0 1 0 0 0 1 0
#> SRR805750 4 0 1 0 0 0 1 0
#> SRR805751 4 0 1 0 0 0 1 0
#> SRR805752 2 0 1 0 1 0 0 0
#> SRR805753 2 0 1 0 1 0 0 0
#> SRR805754 4 0 1 0 0 0 1 0
#> SRR805755 4 0 1 0 0 0 1 0
#> SRR805756 4 0 1 0 0 0 1 0
#> SRR805757 4 0 1 0 0 0 1 0
#> SRR805758 3 0 1 0 0 1 0 0
#> SRR805759 3 0 1 0 0 1 0 0
#> SRR805760 3 0 1 0 0 1 0 0
#> SRR805761 3 0 1 0 0 1 0 0
#> SRR805762 3 0 1 0 0 1 0 0
#> SRR805763 3 0 1 0 0 1 0 0
#> SRR805764 3 0 1 0 0 1 0 0
#> SRR805765 3 0 1 0 0 1 0 0
#> SRR805766 3 0 1 0 0 1 0 0
#> SRR805767 3 0 1 0 0 1 0 0
#> SRR805768 3 0 1 0 0 1 0 0
#> SRR805769 1 0 1 1 0 0 0 0
#> SRR805770 1 0 1 1 0 0 0 0
#> SRR805771 1 0 1 1 0 0 0 0
#> SRR805772 1 0 1 1 0 0 0 0
#> SRR805773 1 0 1 1 0 0 0 0
#> SRR805774 1 0 1 1 0 0 0 0
#> SRR805775 1 0 1 1 0 0 0 0
#> SRR805776 1 0 1 1 0 0 0 0
#> SRR805777 1 0 1 1 0 0 0 0
#> SRR805778 1 0 1 1 0 0 0 0
#> SRR805779 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
#> SRR805725 2 0.000 0.957 0 1.000 0.000 0 0 0.000
#> SRR805726 2 0.000 0.957 0 1.000 0.000 0 0 0.000
#> SRR805727 2 0.000 0.957 0 1.000 0.000 0 0 0.000
#> SRR805728 2 0.000 0.957 0 1.000 0.000 0 0 0.000
#> SRR805729 2 0.000 0.957 0 1.000 0.000 0 0 0.000
#> SRR805730 2 0.279 0.664 0 0.800 0.000 0 0 0.200
#> SRR805731 6 0.282 1.000 0 0.204 0.000 0 0 0.796
#> SRR805732 6 0.282 1.000 0 0.204 0.000 0 0 0.796
#> SRR805733 6 0.282 1.000 0 0.204 0.000 0 0 0.796
#> SRR805735 2 0.000 0.957 0 1.000 0.000 0 0 0.000
#> SRR805736 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805737 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805738 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805739 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805740 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805741 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805742 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805743 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805744 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805745 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805746 5 0.000 1.000 0 0.000 0.000 0 1 0.000
#> SRR805747 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805748 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805749 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805750 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805751 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805752 6 0.282 1.000 0 0.204 0.000 0 0 0.796
#> SRR805753 6 0.282 1.000 0 0.204 0.000 0 0 0.796
#> SRR805754 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805755 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805756 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805757 4 0.000 1.000 0 0.000 0.000 1 0 0.000
#> SRR805758 3 0.000 0.911 0 0.000 1.000 0 0 0.000
#> SRR805759 3 0.000 0.911 0 0.000 1.000 0 0 0.000
#> SRR805760 3 0.000 0.911 0 0.000 1.000 0 0 0.000
#> SRR805761 3 0.000 0.911 0 0.000 1.000 0 0 0.000
#> SRR805762 3 0.000 0.911 0 0.000 1.000 0 0 0.000
#> SRR805763 3 0.282 0.892 0 0.000 0.796 0 0 0.204
#> SRR805764 3 0.282 0.892 0 0.000 0.796 0 0 0.204
#> SRR805765 3 0.282 0.892 0 0.000 0.796 0 0 0.204
#> SRR805766 3 0.282 0.892 0 0.000 0.796 0 0 0.204
#> SRR805767 3 0.282 0.892 0 0.000 0.796 0 0 0.204
#> SRR805768 3 0.000 0.911 0 0.000 1.000 0 0 0.000
#> SRR805769 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805770 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805771 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805772 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805773 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805774 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805775 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805776 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805777 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805778 1 0.000 1.000 1 0.000 0.000 0 0 0.000
#> SRR805779 1 0.000 1.000 1 0.000 0.000 0 0 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14939 rows and 54 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 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.256 0.479 0.700 0.4191 0.669 0.669
#> 3 3 0.426 0.657 0.752 0.4829 0.786 0.681
#> 4 4 0.849 0.965 0.968 0.1648 0.823 0.612
#> 5 5 1.000 1.000 1.000 0.1239 0.908 0.669
#> 6 6 0.959 0.904 0.907 0.0266 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] 5
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
#> SRR805725 2 0.260 0.530 0.044 0.956
#> SRR805726 2 0.242 0.532 0.040 0.960
#> SRR805727 2 0.224 0.532 0.036 0.964
#> SRR805728 2 0.833 0.240 0.264 0.736
#> SRR805729 2 0.745 0.344 0.212 0.788
#> SRR805730 2 0.850 0.212 0.276 0.724
#> SRR805731 2 0.850 0.212 0.276 0.724
#> SRR805732 2 0.850 0.212 0.276 0.724
#> SRR805733 2 0.850 0.212 0.276 0.724
#> SRR805735 2 0.584 0.454 0.140 0.860
#> SRR805736 2 0.278 0.532 0.048 0.952
#> SRR805737 2 0.278 0.532 0.048 0.952
#> SRR805738 2 0.278 0.532 0.048 0.952
#> SRR805739 2 0.295 0.529 0.052 0.948
#> SRR805740 2 0.278 0.532 0.048 0.952
#> SRR805741 2 0.278 0.532 0.048 0.952
#> SRR805742 2 0.278 0.532 0.048 0.952
#> SRR805743 2 0.278 0.532 0.048 0.952
#> SRR805744 2 0.278 0.532 0.048 0.952
#> SRR805745 2 0.278 0.532 0.048 0.952
#> SRR805746 2 0.278 0.532 0.048 0.952
#> SRR805747 2 0.992 0.388 0.448 0.552
#> SRR805748 2 0.992 0.388 0.448 0.552
#> SRR805749 2 0.992 0.388 0.448 0.552
#> SRR805750 2 0.992 0.388 0.448 0.552
#> SRR805751 2 0.992 0.388 0.448 0.552
#> SRR805752 2 0.850 0.212 0.276 0.724
#> SRR805753 2 0.844 0.222 0.272 0.728
#> SRR805754 2 0.992 0.388 0.448 0.552
#> SRR805755 2 0.992 0.388 0.448 0.552
#> SRR805756 2 0.992 0.388 0.448 0.552
#> SRR805757 2 0.992 0.388 0.448 0.552
#> SRR805758 1 0.943 1.000 0.640 0.360
#> SRR805759 1 0.943 1.000 0.640 0.360
#> SRR805760 1 0.943 1.000 0.640 0.360
#> SRR805761 1 0.943 1.000 0.640 0.360
#> SRR805762 1 0.943 1.000 0.640 0.360
#> SRR805763 1 0.943 1.000 0.640 0.360
#> SRR805764 1 0.943 1.000 0.640 0.360
#> SRR805765 1 0.943 1.000 0.640 0.360
#> SRR805766 1 0.943 1.000 0.640 0.360
#> SRR805767 1 0.943 1.000 0.640 0.360
#> SRR805768 1 0.943 1.000 0.640 0.360
#> SRR805769 2 0.850 0.145 0.276 0.724
#> SRR805770 2 0.850 0.145 0.276 0.724
#> SRR805771 2 0.850 0.145 0.276 0.724
#> SRR805772 2 0.850 0.145 0.276 0.724
#> SRR805773 2 0.850 0.145 0.276 0.724
#> SRR805774 2 0.850 0.145 0.276 0.724
#> SRR805775 2 0.844 0.145 0.272 0.728
#> SRR805776 2 0.850 0.145 0.276 0.724
#> SRR805777 2 0.850 0.145 0.276 0.724
#> SRR805778 2 0.850 0.145 0.276 0.724
#> SRR805779 2 0.850 0.145 0.276 0.724
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.9077 0.360 0.340 0.508 0.152
#> SRR805726 2 0.9077 0.360 0.340 0.508 0.152
#> SRR805727 2 0.9077 0.360 0.340 0.508 0.152
#> SRR805728 2 0.9077 0.360 0.340 0.508 0.152
#> SRR805729 2 0.9077 0.360 0.340 0.508 0.152
#> SRR805730 2 0.9077 0.360 0.340 0.508 0.152
#> SRR805731 2 0.9077 0.360 0.340 0.508 0.152
#> SRR805732 2 0.9077 0.360 0.340 0.508 0.152
#> SRR805733 2 0.9077 0.360 0.340 0.508 0.152
#> SRR805735 2 0.9077 0.360 0.340 0.508 0.152
#> SRR805736 2 0.0747 0.596 0.000 0.984 0.016
#> SRR805737 2 0.0747 0.596 0.000 0.984 0.016
#> SRR805738 2 0.0747 0.596 0.000 0.984 0.016
#> SRR805739 2 0.0747 0.596 0.000 0.984 0.016
#> SRR805740 2 0.0747 0.596 0.000 0.984 0.016
#> SRR805741 2 0.0747 0.596 0.000 0.984 0.016
#> SRR805742 2 0.0747 0.596 0.000 0.984 0.016
#> SRR805743 2 0.0747 0.596 0.000 0.984 0.016
#> SRR805744 2 0.0747 0.596 0.000 0.984 0.016
#> SRR805745 2 0.0747 0.596 0.000 0.984 0.016
#> SRR805746 2 0.0747 0.596 0.000 0.984 0.016
#> SRR805747 1 0.5222 1.000 0.816 0.040 0.144
#> SRR805748 1 0.5222 1.000 0.816 0.040 0.144
#> SRR805749 1 0.5222 1.000 0.816 0.040 0.144
#> SRR805750 1 0.5222 1.000 0.816 0.040 0.144
#> SRR805751 1 0.5222 1.000 0.816 0.040 0.144
#> SRR805752 2 0.8316 0.263 0.424 0.496 0.080
#> SRR805753 2 0.8316 0.263 0.424 0.496 0.080
#> SRR805754 1 0.5222 1.000 0.816 0.040 0.144
#> SRR805755 1 0.5222 1.000 0.816 0.040 0.144
#> SRR805756 1 0.5222 1.000 0.816 0.040 0.144
#> SRR805757 1 0.5222 1.000 0.816 0.040 0.144
#> SRR805758 3 0.2066 1.000 0.000 0.060 0.940
#> SRR805759 3 0.2066 1.000 0.000 0.060 0.940
#> SRR805760 3 0.2066 1.000 0.000 0.060 0.940
#> SRR805761 3 0.2066 1.000 0.000 0.060 0.940
#> SRR805762 3 0.2066 1.000 0.000 0.060 0.940
#> SRR805763 3 0.2066 1.000 0.000 0.060 0.940
#> SRR805764 3 0.2066 1.000 0.000 0.060 0.940
#> SRR805765 3 0.2066 1.000 0.000 0.060 0.940
#> SRR805766 3 0.2066 1.000 0.000 0.060 0.940
#> SRR805767 3 0.2066 1.000 0.000 0.060 0.940
#> SRR805768 3 0.2066 1.000 0.000 0.060 0.940
#> SRR805769 2 0.9190 0.434 0.184 0.524 0.292
#> SRR805770 2 0.9190 0.434 0.184 0.524 0.292
#> SRR805771 2 0.9190 0.434 0.184 0.524 0.292
#> SRR805772 2 0.9190 0.434 0.184 0.524 0.292
#> SRR805773 2 0.9190 0.434 0.184 0.524 0.292
#> SRR805774 2 0.9190 0.434 0.184 0.524 0.292
#> SRR805775 2 0.9190 0.434 0.184 0.524 0.292
#> SRR805776 2 0.9190 0.434 0.184 0.524 0.292
#> SRR805777 2 0.9190 0.434 0.184 0.524 0.292
#> SRR805778 2 0.9190 0.434 0.184 0.524 0.292
#> SRR805779 2 0.9190 0.434 0.184 0.524 0.292
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.359 0.920 0.04 0.856 0 0.104
#> SRR805726 2 0.359 0.920 0.04 0.856 0 0.104
#> SRR805727 2 0.359 0.920 0.04 0.856 0 0.104
#> SRR805728 2 0.359 0.920 0.04 0.856 0 0.104
#> SRR805729 2 0.359 0.920 0.04 0.856 0 0.104
#> SRR805730 2 0.359 0.920 0.04 0.856 0 0.104
#> SRR805731 2 0.359 0.920 0.04 0.856 0 0.104
#> SRR805732 2 0.359 0.920 0.04 0.856 0 0.104
#> SRR805733 2 0.359 0.920 0.04 0.856 0 0.104
#> SRR805735 2 0.359 0.920 0.04 0.856 0 0.104
#> SRR805736 2 0.000 0.920 0.00 1.000 0 0.000
#> SRR805737 2 0.000 0.920 0.00 1.000 0 0.000
#> SRR805738 2 0.000 0.920 0.00 1.000 0 0.000
#> SRR805739 2 0.000 0.920 0.00 1.000 0 0.000
#> SRR805740 2 0.000 0.920 0.00 1.000 0 0.000
#> SRR805741 2 0.000 0.920 0.00 1.000 0 0.000
#> SRR805742 2 0.000 0.920 0.00 1.000 0 0.000
#> SRR805743 2 0.000 0.920 0.00 1.000 0 0.000
#> SRR805744 2 0.000 0.920 0.00 1.000 0 0.000
#> SRR805745 2 0.000 0.920 0.00 1.000 0 0.000
#> SRR805746 2 0.000 0.920 0.00 1.000 0 0.000
#> SRR805747 4 0.000 1.000 0.00 0.000 0 1.000
#> SRR805748 4 0.000 1.000 0.00 0.000 0 1.000
#> SRR805749 4 0.000 1.000 0.00 0.000 0 1.000
#> SRR805750 4 0.000 1.000 0.00 0.000 0 1.000
#> SRR805751 4 0.000 1.000 0.00 0.000 0 1.000
#> SRR805752 2 0.297 0.901 0.00 0.856 0 0.144
#> SRR805753 2 0.297 0.901 0.00 0.856 0 0.144
#> SRR805754 4 0.000 1.000 0.00 0.000 0 1.000
#> SRR805755 4 0.000 1.000 0.00 0.000 0 1.000
#> SRR805756 4 0.000 1.000 0.00 0.000 0 1.000
#> SRR805757 4 0.000 1.000 0.00 0.000 0 1.000
#> SRR805758 3 0.000 1.000 0.00 0.000 1 0.000
#> SRR805759 3 0.000 1.000 0.00 0.000 1 0.000
#> SRR805760 3 0.000 1.000 0.00 0.000 1 0.000
#> SRR805761 3 0.000 1.000 0.00 0.000 1 0.000
#> SRR805762 3 0.000 1.000 0.00 0.000 1 0.000
#> SRR805763 3 0.000 1.000 0.00 0.000 1 0.000
#> SRR805764 3 0.000 1.000 0.00 0.000 1 0.000
#> SRR805765 3 0.000 1.000 0.00 0.000 1 0.000
#> SRR805766 3 0.000 1.000 0.00 0.000 1 0.000
#> SRR805767 3 0.000 1.000 0.00 0.000 1 0.000
#> SRR805768 3 0.000 1.000 0.00 0.000 1 0.000
#> SRR805769 1 0.000 1.000 1.00 0.000 0 0.000
#> SRR805770 1 0.000 1.000 1.00 0.000 0 0.000
#> SRR805771 1 0.000 1.000 1.00 0.000 0 0.000
#> SRR805772 1 0.000 1.000 1.00 0.000 0 0.000
#> SRR805773 1 0.000 1.000 1.00 0.000 0 0.000
#> SRR805774 1 0.000 1.000 1.00 0.000 0 0.000
#> SRR805775 1 0.000 1.000 1.00 0.000 0 0.000
#> SRR805776 1 0.000 1.000 1.00 0.000 0 0.000
#> SRR805777 1 0.000 1.000 1.00 0.000 0 0.000
#> SRR805778 1 0.000 1.000 1.00 0.000 0 0.000
#> SRR805779 1 0.000 1.000 1.00 0.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 2 0 1 0 1 0 0 0
#> SRR805726 2 0 1 0 1 0 0 0
#> SRR805727 2 0 1 0 1 0 0 0
#> SRR805728 2 0 1 0 1 0 0 0
#> SRR805729 2 0 1 0 1 0 0 0
#> SRR805730 2 0 1 0 1 0 0 0
#> SRR805731 2 0 1 0 1 0 0 0
#> SRR805732 2 0 1 0 1 0 0 0
#> SRR805733 2 0 1 0 1 0 0 0
#> SRR805735 2 0 1 0 1 0 0 0
#> SRR805736 5 0 1 0 0 0 0 1
#> SRR805737 5 0 1 0 0 0 0 1
#> SRR805738 5 0 1 0 0 0 0 1
#> SRR805739 5 0 1 0 0 0 0 1
#> SRR805740 5 0 1 0 0 0 0 1
#> SRR805741 5 0 1 0 0 0 0 1
#> SRR805742 5 0 1 0 0 0 0 1
#> SRR805743 5 0 1 0 0 0 0 1
#> SRR805744 5 0 1 0 0 0 0 1
#> SRR805745 5 0 1 0 0 0 0 1
#> SRR805746 5 0 1 0 0 0 0 1
#> SRR805747 4 0 1 0 0 0 1 0
#> SRR805748 4 0 1 0 0 0 1 0
#> SRR805749 4 0 1 0 0 0 1 0
#> SRR805750 4 0 1 0 0 0 1 0
#> SRR805751 4 0 1 0 0 0 1 0
#> SRR805752 2 0 1 0 1 0 0 0
#> SRR805753 2 0 1 0 1 0 0 0
#> SRR805754 4 0 1 0 0 0 1 0
#> SRR805755 4 0 1 0 0 0 1 0
#> SRR805756 4 0 1 0 0 0 1 0
#> SRR805757 4 0 1 0 0 0 1 0
#> SRR805758 3 0 1 0 0 1 0 0
#> SRR805759 3 0 1 0 0 1 0 0
#> SRR805760 3 0 1 0 0 1 0 0
#> SRR805761 3 0 1 0 0 1 0 0
#> SRR805762 3 0 1 0 0 1 0 0
#> SRR805763 3 0 1 0 0 1 0 0
#> SRR805764 3 0 1 0 0 1 0 0
#> SRR805765 3 0 1 0 0 1 0 0
#> SRR805766 3 0 1 0 0 1 0 0
#> SRR805767 3 0 1 0 0 1 0 0
#> SRR805768 3 0 1 0 0 1 0 0
#> SRR805769 1 0 1 1 0 0 0 0
#> SRR805770 1 0 1 1 0 0 0 0
#> SRR805771 1 0 1 1 0 0 0 0
#> SRR805772 1 0 1 1 0 0 0 0
#> SRR805773 1 0 1 1 0 0 0 0
#> SRR805774 1 0 1 1 0 0 0 0
#> SRR805775 1 0 1 1 0 0 0 0
#> SRR805776 1 0 1 1 0 0 0 0
#> SRR805777 1 0 1 1 0 0 0 0
#> SRR805778 1 0 1 1 0 0 0 0
#> SRR805779 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
#> SRR805725 2 0.3860 0.760 0.000 0.528 0.000 0 0.000 NA
#> SRR805726 2 0.3860 0.760 0.000 0.528 0.000 0 0.000 NA
#> SRR805727 2 0.3860 0.760 0.000 0.528 0.000 0 0.000 NA
#> SRR805728 2 0.3860 0.760 0.000 0.528 0.000 0 0.000 NA
#> SRR805729 2 0.3860 0.760 0.000 0.528 0.000 0 0.000 NA
#> SRR805730 2 0.0363 0.744 0.000 0.988 0.000 0 0.000 NA
#> SRR805731 2 0.0000 0.742 0.000 1.000 0.000 0 0.000 NA
#> SRR805732 2 0.0000 0.742 0.000 1.000 0.000 0 0.000 NA
#> SRR805733 2 0.0000 0.742 0.000 1.000 0.000 0 0.000 NA
#> SRR805735 2 0.3860 0.760 0.000 0.528 0.000 0 0.000 NA
#> SRR805736 5 0.0000 0.990 0.000 0.000 0.000 0 1.000 NA
#> SRR805737 5 0.0000 0.990 0.000 0.000 0.000 0 1.000 NA
#> SRR805738 5 0.0000 0.990 0.000 0.000 0.000 0 1.000 NA
#> SRR805739 5 0.1663 0.898 0.088 0.000 0.000 0 0.912 NA
#> SRR805740 5 0.0000 0.990 0.000 0.000 0.000 0 1.000 NA
#> SRR805741 5 0.0000 0.990 0.000 0.000 0.000 0 1.000 NA
#> SRR805742 5 0.0000 0.990 0.000 0.000 0.000 0 1.000 NA
#> SRR805743 5 0.0000 0.990 0.000 0.000 0.000 0 1.000 NA
#> SRR805744 5 0.0000 0.990 0.000 0.000 0.000 0 1.000 NA
#> SRR805745 5 0.0000 0.990 0.000 0.000 0.000 0 1.000 NA
#> SRR805746 5 0.0000 0.990 0.000 0.000 0.000 0 1.000 NA
#> SRR805747 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 NA
#> SRR805748 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 NA
#> SRR805749 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 NA
#> SRR805750 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 NA
#> SRR805751 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 NA
#> SRR805752 2 0.2454 0.662 0.000 0.840 0.000 0 0.000 NA
#> SRR805753 2 0.2454 0.662 0.000 0.840 0.000 0 0.000 NA
#> SRR805754 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 NA
#> SRR805755 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 NA
#> SRR805756 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 NA
#> SRR805757 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 NA
#> SRR805758 3 0.0000 0.850 0.000 0.000 1.000 0 0.000 NA
#> SRR805759 3 0.0000 0.850 0.000 0.000 1.000 0 0.000 NA
#> SRR805760 3 0.0000 0.850 0.000 0.000 1.000 0 0.000 NA
#> SRR805761 3 0.0000 0.850 0.000 0.000 1.000 0 0.000 NA
#> SRR805762 3 0.0000 0.850 0.000 0.000 1.000 0 0.000 NA
#> SRR805763 3 0.3672 0.806 0.000 0.000 0.632 0 0.000 NA
#> SRR805764 3 0.3672 0.806 0.000 0.000 0.632 0 0.000 NA
#> SRR805765 3 0.3672 0.806 0.000 0.000 0.632 0 0.000 NA
#> SRR805766 3 0.3672 0.806 0.000 0.000 0.632 0 0.000 NA
#> SRR805767 3 0.3464 0.817 0.000 0.000 0.688 0 0.000 NA
#> SRR805768 3 0.0000 0.850 0.000 0.000 1.000 0 0.000 NA
#> SRR805769 1 0.0000 1.000 1.000 0.000 0.000 0 0.000 NA
#> SRR805770 1 0.0000 1.000 1.000 0.000 0.000 0 0.000 NA
#> SRR805771 1 0.0000 1.000 1.000 0.000 0.000 0 0.000 NA
#> SRR805772 1 0.0000 1.000 1.000 0.000 0.000 0 0.000 NA
#> SRR805773 1 0.0000 1.000 1.000 0.000 0.000 0 0.000 NA
#> SRR805774 1 0.0000 1.000 1.000 0.000 0.000 0 0.000 NA
#> SRR805775 1 0.0000 1.000 1.000 0.000 0.000 0 0.000 NA
#> SRR805776 1 0.0000 1.000 1.000 0.000 0.000 0 0.000 NA
#> SRR805777 1 0.0000 1.000 1.000 0.000 0.000 0 0.000 NA
#> SRR805778 1 0.0000 1.000 1.000 0.000 0.000 0 0.000 NA
#> SRR805779 1 0.0000 1.000 1.000 0.000 0.000 0 0.000 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "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 14939 rows and 54 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 0.888 0.930 0.972 0.5021 0.497 0.497
#> 3 3 0.750 0.857 0.916 0.3001 0.808 0.629
#> 4 4 0.742 0.696 0.771 0.1347 0.860 0.622
#> 5 5 1.000 0.998 0.999 0.0986 0.891 0.605
#> 6 6 1.000 0.976 0.991 0.0198 0.986 0.925
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
#> SRR805725 2 0.0000 0.967 0.000 1.000
#> SRR805726 2 0.0000 0.967 0.000 1.000
#> SRR805727 2 0.0000 0.967 0.000 1.000
#> SRR805728 2 0.0000 0.967 0.000 1.000
#> SRR805729 2 0.0000 0.967 0.000 1.000
#> SRR805730 2 0.0000 0.967 0.000 1.000
#> SRR805731 2 0.0000 0.967 0.000 1.000
#> SRR805732 2 0.0000 0.967 0.000 1.000
#> SRR805733 2 0.0000 0.967 0.000 1.000
#> SRR805735 2 0.0000 0.967 0.000 1.000
#> SRR805736 2 0.0000 0.967 0.000 1.000
#> SRR805737 2 0.0000 0.967 0.000 1.000
#> SRR805738 2 0.0000 0.967 0.000 1.000
#> SRR805739 2 0.0672 0.960 0.008 0.992
#> SRR805740 2 0.0000 0.967 0.000 1.000
#> SRR805741 2 0.0000 0.967 0.000 1.000
#> SRR805742 2 0.0000 0.967 0.000 1.000
#> SRR805743 2 0.0000 0.967 0.000 1.000
#> SRR805744 2 0.0000 0.967 0.000 1.000
#> SRR805745 2 0.6801 0.771 0.180 0.820
#> SRR805746 2 0.4815 0.867 0.104 0.896
#> SRR805747 1 0.0000 0.972 1.000 0.000
#> SRR805748 1 0.0000 0.972 1.000 0.000
#> SRR805749 1 0.0000 0.972 1.000 0.000
#> SRR805750 1 0.0000 0.972 1.000 0.000
#> SRR805751 1 0.9815 0.268 0.580 0.420
#> SRR805752 2 0.0000 0.967 0.000 1.000
#> SRR805753 2 0.0000 0.967 0.000 1.000
#> SRR805754 1 0.5059 0.868 0.888 0.112
#> SRR805755 1 0.5946 0.829 0.856 0.144
#> SRR805756 1 0.2778 0.935 0.952 0.048
#> SRR805757 1 0.0938 0.964 0.988 0.012
#> SRR805758 1 0.0000 0.972 1.000 0.000
#> SRR805759 1 0.0000 0.972 1.000 0.000
#> SRR805760 1 0.0000 0.972 1.000 0.000
#> SRR805761 1 0.0000 0.972 1.000 0.000
#> SRR805762 1 0.0000 0.972 1.000 0.000
#> SRR805763 1 0.0000 0.972 1.000 0.000
#> SRR805764 2 0.9922 0.179 0.448 0.552
#> SRR805765 1 0.2423 0.942 0.960 0.040
#> SRR805766 1 0.0938 0.964 0.988 0.012
#> SRR805767 1 0.0000 0.972 1.000 0.000
#> SRR805768 1 0.0000 0.972 1.000 0.000
#> SRR805769 1 0.0000 0.972 1.000 0.000
#> SRR805770 1 0.0000 0.972 1.000 0.000
#> SRR805771 1 0.0000 0.972 1.000 0.000
#> SRR805772 1 0.0000 0.972 1.000 0.000
#> SRR805773 1 0.0000 0.972 1.000 0.000
#> SRR805774 1 0.0000 0.972 1.000 0.000
#> SRR805775 1 0.0000 0.972 1.000 0.000
#> SRR805776 1 0.0000 0.972 1.000 0.000
#> SRR805777 1 0.0000 0.972 1.000 0.000
#> SRR805778 1 0.0000 0.972 1.000 0.000
#> SRR805779 1 0.0000 0.972 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.0829 0.911 0.004 0.984 0.012
#> SRR805726 2 0.1989 0.905 0.048 0.948 0.004
#> SRR805727 2 0.0661 0.910 0.004 0.988 0.008
#> SRR805728 2 0.1163 0.908 0.000 0.972 0.028
#> SRR805729 2 0.0829 0.910 0.004 0.984 0.012
#> SRR805730 2 0.1163 0.908 0.000 0.972 0.028
#> SRR805731 2 0.1163 0.908 0.000 0.972 0.028
#> SRR805732 2 0.1163 0.908 0.000 0.972 0.028
#> SRR805733 2 0.1163 0.908 0.000 0.972 0.028
#> SRR805735 2 0.1163 0.908 0.000 0.972 0.028
#> SRR805736 2 0.4784 0.809 0.200 0.796 0.004
#> SRR805737 2 0.4784 0.809 0.200 0.796 0.004
#> SRR805738 2 0.4233 0.851 0.160 0.836 0.004
#> SRR805739 2 0.2301 0.902 0.060 0.936 0.004
#> SRR805740 2 0.4172 0.853 0.156 0.840 0.004
#> SRR805741 2 0.3644 0.876 0.124 0.872 0.004
#> SRR805742 2 0.3030 0.891 0.092 0.904 0.004
#> SRR805743 2 0.1399 0.908 0.028 0.968 0.004
#> SRR805744 2 0.3500 0.880 0.116 0.880 0.004
#> SRR805745 1 0.6521 -0.187 0.504 0.492 0.004
#> SRR805746 2 0.6516 0.196 0.480 0.516 0.004
#> SRR805747 1 0.2711 0.868 0.912 0.000 0.088
#> SRR805748 1 0.1753 0.881 0.952 0.000 0.048
#> SRR805749 1 0.1163 0.881 0.972 0.000 0.028
#> SRR805750 1 0.1411 0.882 0.964 0.000 0.036
#> SRR805751 1 0.5365 0.633 0.744 0.252 0.004
#> SRR805752 2 0.1163 0.908 0.000 0.972 0.028
#> SRR805753 2 0.1163 0.908 0.000 0.972 0.028
#> SRR805754 1 0.2982 0.857 0.920 0.056 0.024
#> SRR805755 1 0.4663 0.757 0.828 0.156 0.016
#> SRR805756 1 0.1905 0.868 0.956 0.028 0.016
#> SRR805757 1 0.0983 0.865 0.980 0.016 0.004
#> SRR805758 3 0.1289 0.987 0.032 0.000 0.968
#> SRR805759 3 0.1289 0.987 0.032 0.000 0.968
#> SRR805760 3 0.1289 0.987 0.032 0.000 0.968
#> SRR805761 3 0.1289 0.987 0.032 0.000 0.968
#> SRR805762 3 0.1289 0.987 0.032 0.000 0.968
#> SRR805763 3 0.0592 0.980 0.012 0.000 0.988
#> SRR805764 3 0.0661 0.965 0.004 0.008 0.988
#> SRR805765 3 0.0424 0.978 0.008 0.000 0.992
#> SRR805766 3 0.0424 0.978 0.008 0.000 0.992
#> SRR805767 3 0.1163 0.986 0.028 0.000 0.972
#> SRR805768 3 0.1289 0.987 0.032 0.000 0.968
#> SRR805769 1 0.1964 0.881 0.944 0.000 0.056
#> SRR805770 1 0.4002 0.809 0.840 0.000 0.160
#> SRR805771 1 0.4887 0.736 0.772 0.000 0.228
#> SRR805772 1 0.1529 0.882 0.960 0.000 0.040
#> SRR805773 1 0.0424 0.877 0.992 0.000 0.008
#> SRR805774 1 0.0892 0.881 0.980 0.000 0.020
#> SRR805775 1 0.3879 0.816 0.848 0.000 0.152
#> SRR805776 1 0.2356 0.871 0.928 0.000 0.072
#> SRR805777 1 0.2165 0.877 0.936 0.000 0.064
#> SRR805778 1 0.4452 0.778 0.808 0.000 0.192
#> SRR805779 1 0.1643 0.882 0.956 0.000 0.044
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.1302 0.787 0.044 0.956 0.000 0.000
#> SRR805726 2 0.2943 0.775 0.076 0.892 0.000 0.032
#> SRR805727 2 0.2011 0.784 0.080 0.920 0.000 0.000
#> SRR805728 2 0.0000 0.784 0.000 1.000 0.000 0.000
#> SRR805729 2 0.2011 0.784 0.080 0.920 0.000 0.000
#> SRR805730 2 0.0000 0.784 0.000 1.000 0.000 0.000
#> SRR805731 2 0.0000 0.784 0.000 1.000 0.000 0.000
#> SRR805732 2 0.0000 0.784 0.000 1.000 0.000 0.000
#> SRR805733 2 0.0000 0.784 0.000 1.000 0.000 0.000
#> SRR805735 2 0.0000 0.784 0.000 1.000 0.000 0.000
#> SRR805736 2 0.5296 0.602 0.492 0.500 0.000 0.008
#> SRR805737 1 0.5236 -0.550 0.560 0.432 0.000 0.008
#> SRR805738 2 0.5294 0.612 0.484 0.508 0.000 0.008
#> SRR805739 1 0.5132 -0.571 0.548 0.448 0.000 0.004
#> SRR805740 2 0.5285 0.629 0.468 0.524 0.000 0.008
#> SRR805741 2 0.5290 0.622 0.476 0.516 0.000 0.008
#> SRR805742 2 0.5288 0.625 0.472 0.520 0.000 0.008
#> SRR805743 2 0.5273 0.636 0.456 0.536 0.000 0.008
#> SRR805744 2 0.5285 0.629 0.468 0.524 0.000 0.008
#> SRR805745 1 0.3591 0.021 0.824 0.168 0.000 0.008
#> SRR805746 1 0.3591 0.021 0.824 0.168 0.000 0.008
#> SRR805747 4 0.0188 0.840 0.000 0.000 0.004 0.996
#> SRR805748 4 0.0000 0.843 0.000 0.000 0.000 1.000
#> SRR805749 4 0.0000 0.843 0.000 0.000 0.000 1.000
#> SRR805750 4 0.0000 0.843 0.000 0.000 0.000 1.000
#> SRR805751 4 0.4134 0.698 0.000 0.260 0.000 0.740
#> SRR805752 2 0.0000 0.784 0.000 1.000 0.000 0.000
#> SRR805753 2 0.0000 0.784 0.000 1.000 0.000 0.000
#> SRR805754 4 0.3219 0.812 0.000 0.164 0.000 0.836
#> SRR805755 4 0.3266 0.809 0.000 0.168 0.000 0.832
#> SRR805756 4 0.2469 0.840 0.000 0.108 0.000 0.892
#> SRR805757 4 0.1022 0.851 0.000 0.032 0.000 0.968
#> SRR805758 3 0.0000 0.978 0.000 0.000 1.000 0.000
#> SRR805759 3 0.0000 0.978 0.000 0.000 1.000 0.000
#> SRR805760 3 0.0000 0.978 0.000 0.000 1.000 0.000
#> SRR805761 3 0.0000 0.978 0.000 0.000 1.000 0.000
#> SRR805762 3 0.0000 0.978 0.000 0.000 1.000 0.000
#> SRR805763 3 0.0336 0.975 0.000 0.008 0.992 0.000
#> SRR805764 3 0.2149 0.902 0.000 0.088 0.912 0.000
#> SRR805765 3 0.1637 0.933 0.000 0.060 0.940 0.000
#> SRR805766 3 0.0707 0.967 0.000 0.020 0.980 0.000
#> SRR805767 3 0.0000 0.978 0.000 0.000 1.000 0.000
#> SRR805768 3 0.0000 0.978 0.000 0.000 1.000 0.000
#> SRR805769 1 0.6665 0.638 0.544 0.000 0.096 0.360
#> SRR805770 1 0.6750 0.636 0.540 0.000 0.104 0.356
#> SRR805771 1 0.6750 0.636 0.540 0.000 0.104 0.356
#> SRR805772 1 0.6665 0.638 0.544 0.000 0.096 0.360
#> SRR805773 1 0.6038 0.544 0.532 0.000 0.044 0.424
#> SRR805774 1 0.6543 0.624 0.544 0.000 0.084 0.372
#> SRR805775 1 0.6750 0.636 0.540 0.000 0.104 0.356
#> SRR805776 1 0.6665 0.638 0.544 0.000 0.096 0.360
#> SRR805777 1 0.6665 0.638 0.544 0.000 0.096 0.360
#> SRR805778 1 0.6750 0.636 0.540 0.000 0.104 0.356
#> SRR805779 1 0.6665 0.638 0.544 0.000 0.096 0.360
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 2 0.00 0.996 0 1.000 0 0.000 0.00
#> SRR805726 2 0.14 0.955 0 0.952 0 0.028 0.02
#> SRR805727 2 0.00 0.996 0 1.000 0 0.000 0.00
#> SRR805728 2 0.00 0.996 0 1.000 0 0.000 0.00
#> SRR805729 2 0.00 0.996 0 1.000 0 0.000 0.00
#> SRR805730 2 0.00 0.996 0 1.000 0 0.000 0.00
#> SRR805731 2 0.00 0.996 0 1.000 0 0.000 0.00
#> SRR805732 2 0.00 0.996 0 1.000 0 0.000 0.00
#> SRR805733 2 0.00 0.996 0 1.000 0 0.000 0.00
#> SRR805735 2 0.00 0.996 0 1.000 0 0.000 0.00
#> SRR805736 5 0.00 1.000 0 0.000 0 0.000 1.00
#> SRR805737 5 0.00 1.000 0 0.000 0 0.000 1.00
#> SRR805738 5 0.00 1.000 0 0.000 0 0.000 1.00
#> SRR805739 5 0.00 1.000 0 0.000 0 0.000 1.00
#> SRR805740 5 0.00 1.000 0 0.000 0 0.000 1.00
#> SRR805741 5 0.00 1.000 0 0.000 0 0.000 1.00
#> SRR805742 5 0.00 1.000 0 0.000 0 0.000 1.00
#> SRR805743 5 0.00 1.000 0 0.000 0 0.000 1.00
#> SRR805744 5 0.00 1.000 0 0.000 0 0.000 1.00
#> SRR805745 5 0.00 1.000 0 0.000 0 0.000 1.00
#> SRR805746 5 0.00 1.000 0 0.000 0 0.000 1.00
#> SRR805747 4 0.00 1.000 0 0.000 0 1.000 0.00
#> SRR805748 4 0.00 1.000 0 0.000 0 1.000 0.00
#> SRR805749 4 0.00 1.000 0 0.000 0 1.000 0.00
#> SRR805750 4 0.00 1.000 0 0.000 0 1.000 0.00
#> SRR805751 4 0.00 1.000 0 0.000 0 1.000 0.00
#> SRR805752 2 0.00 0.996 0 1.000 0 0.000 0.00
#> SRR805753 2 0.00 0.996 0 1.000 0 0.000 0.00
#> SRR805754 4 0.00 1.000 0 0.000 0 1.000 0.00
#> SRR805755 4 0.00 1.000 0 0.000 0 1.000 0.00
#> SRR805756 4 0.00 1.000 0 0.000 0 1.000 0.00
#> SRR805757 4 0.00 1.000 0 0.000 0 1.000 0.00
#> SRR805758 3 0.00 1.000 0 0.000 1 0.000 0.00
#> SRR805759 3 0.00 1.000 0 0.000 1 0.000 0.00
#> SRR805760 3 0.00 1.000 0 0.000 1 0.000 0.00
#> SRR805761 3 0.00 1.000 0 0.000 1 0.000 0.00
#> SRR805762 3 0.00 1.000 0 0.000 1 0.000 0.00
#> SRR805763 3 0.00 1.000 0 0.000 1 0.000 0.00
#> SRR805764 3 0.00 1.000 0 0.000 1 0.000 0.00
#> SRR805765 3 0.00 1.000 0 0.000 1 0.000 0.00
#> SRR805766 3 0.00 1.000 0 0.000 1 0.000 0.00
#> SRR805767 3 0.00 1.000 0 0.000 1 0.000 0.00
#> SRR805768 3 0.00 1.000 0 0.000 1 0.000 0.00
#> SRR805769 1 0.00 1.000 1 0.000 0 0.000 0.00
#> SRR805770 1 0.00 1.000 1 0.000 0 0.000 0.00
#> SRR805771 1 0.00 1.000 1 0.000 0 0.000 0.00
#> SRR805772 1 0.00 1.000 1 0.000 0 0.000 0.00
#> SRR805773 1 0.00 1.000 1 0.000 0 0.000 0.00
#> SRR805774 1 0.00 1.000 1 0.000 0 0.000 0.00
#> SRR805775 1 0.00 1.000 1 0.000 0 0.000 0.00
#> SRR805776 1 0.00 1.000 1 0.000 0 0.000 0.00
#> SRR805777 1 0.00 1.000 1 0.000 0 0.000 0.00
#> SRR805778 1 0.00 1.000 1 0.000 0 0.000 0.00
#> SRR805779 1 0.00 1.000 1 0.000 0 0.000 0.00
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0.0000 0.946 0 1.000 0 0 0 0.000
#> SRR805726 2 0.0000 0.946 0 1.000 0 0 0 0.000
#> SRR805727 2 0.0000 0.946 0 1.000 0 0 0 0.000
#> SRR805728 2 0.0000 0.946 0 1.000 0 0 0 0.000
#> SRR805729 2 0.0000 0.946 0 1.000 0 0 0 0.000
#> SRR805730 2 0.0146 0.945 0 0.996 0 0 0 0.004
#> SRR805731 2 0.0363 0.940 0 0.988 0 0 0 0.012
#> SRR805732 2 0.3828 0.219 0 0.560 0 0 0 0.440
#> SRR805733 2 0.0260 0.943 0 0.992 0 0 0 0.008
#> SRR805735 2 0.0000 0.946 0 1.000 0 0 0 0.000
#> SRR805736 5 0.0000 1.000 0 0.000 0 0 1 0.000
#> SRR805737 5 0.0000 1.000 0 0.000 0 0 1 0.000
#> SRR805738 5 0.0000 1.000 0 0.000 0 0 1 0.000
#> SRR805739 5 0.0000 1.000 0 0.000 0 0 1 0.000
#> SRR805740 5 0.0000 1.000 0 0.000 0 0 1 0.000
#> SRR805741 5 0.0000 1.000 0 0.000 0 0 1 0.000
#> SRR805742 5 0.0000 1.000 0 0.000 0 0 1 0.000
#> SRR805743 5 0.0000 1.000 0 0.000 0 0 1 0.000
#> SRR805744 5 0.0000 1.000 0 0.000 0 0 1 0.000
#> SRR805745 5 0.0000 1.000 0 0.000 0 0 1 0.000
#> SRR805746 5 0.0000 1.000 0 0.000 0 0 1 0.000
#> SRR805747 4 0.0000 1.000 0 0.000 0 1 0 0.000
#> SRR805748 4 0.0000 1.000 0 0.000 0 1 0 0.000
#> SRR805749 4 0.0000 1.000 0 0.000 0 1 0 0.000
#> SRR805750 4 0.0000 1.000 0 0.000 0 1 0 0.000
#> SRR805751 4 0.0000 1.000 0 0.000 0 1 0 0.000
#> SRR805752 6 0.0146 1.000 0 0.004 0 0 0 0.996
#> SRR805753 6 0.0146 1.000 0 0.004 0 0 0 0.996
#> SRR805754 4 0.0000 1.000 0 0.000 0 1 0 0.000
#> SRR805755 4 0.0000 1.000 0 0.000 0 1 0 0.000
#> SRR805756 4 0.0000 1.000 0 0.000 0 1 0 0.000
#> SRR805757 4 0.0000 1.000 0 0.000 0 1 0 0.000
#> SRR805758 3 0.0000 1.000 0 0.000 1 0 0 0.000
#> SRR805759 3 0.0000 1.000 0 0.000 1 0 0 0.000
#> SRR805760 3 0.0000 1.000 0 0.000 1 0 0 0.000
#> SRR805761 3 0.0000 1.000 0 0.000 1 0 0 0.000
#> SRR805762 3 0.0000 1.000 0 0.000 1 0 0 0.000
#> SRR805763 3 0.0000 1.000 0 0.000 1 0 0 0.000
#> SRR805764 3 0.0000 1.000 0 0.000 1 0 0 0.000
#> SRR805765 3 0.0000 1.000 0 0.000 1 0 0 0.000
#> SRR805766 3 0.0000 1.000 0 0.000 1 0 0 0.000
#> SRR805767 3 0.0000 1.000 0 0.000 1 0 0 0.000
#> SRR805768 3 0.0000 1.000 0 0.000 1 0 0 0.000
#> SRR805769 1 0.0000 1.000 1 0.000 0 0 0 0.000
#> SRR805770 1 0.0000 1.000 1 0.000 0 0 0 0.000
#> SRR805771 1 0.0000 1.000 1 0.000 0 0 0 0.000
#> SRR805772 1 0.0000 1.000 1 0.000 0 0 0 0.000
#> SRR805773 1 0.0000 1.000 1 0.000 0 0 0 0.000
#> SRR805774 1 0.0000 1.000 1 0.000 0 0 0 0.000
#> SRR805775 1 0.0000 1.000 1 0.000 0 0 0 0.000
#> SRR805776 1 0.0000 1.000 1 0.000 0 0 0 0.000
#> SRR805777 1 0.0000 1.000 1 0.000 0 0 0 0.000
#> SRR805778 1 0.0000 1.000 1 0.000 0 0 0 0.000
#> SRR805779 1 0.0000 1.000 1 0.000 0 0 0 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14939 rows and 54 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 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.860 0.926 0.964 0.3308 0.628 0.628
#> 3 3 0.908 0.919 0.963 0.9298 0.715 0.546
#> 4 4 0.749 0.787 0.816 0.1216 1.000 1.000
#> 5 5 0.854 0.842 0.854 0.0875 0.881 0.651
#> 6 6 0.890 0.883 0.908 0.0343 0.965 0.843
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805725 2 0.9933 0.396 0.452 0.548
#> SRR805726 2 0.9933 0.396 0.452 0.548
#> SRR805727 2 0.9933 0.396 0.452 0.548
#> SRR805728 2 0.0376 0.836 0.004 0.996
#> SRR805729 2 0.9933 0.396 0.452 0.548
#> SRR805730 2 0.0000 0.836 0.000 1.000
#> SRR805731 2 0.0000 0.836 0.000 1.000
#> SRR805732 2 0.0000 0.836 0.000 1.000
#> SRR805733 2 0.0000 0.836 0.000 1.000
#> SRR805735 2 0.0376 0.836 0.004 0.996
#> SRR805736 1 0.0000 0.999 1.000 0.000
#> SRR805737 1 0.0000 0.999 1.000 0.000
#> SRR805738 1 0.0672 0.991 0.992 0.008
#> SRR805739 1 0.0000 0.999 1.000 0.000
#> SRR805740 1 0.0672 0.991 0.992 0.008
#> SRR805741 1 0.0000 0.999 1.000 0.000
#> SRR805742 1 0.0000 0.999 1.000 0.000
#> SRR805743 2 0.4022 0.801 0.080 0.920
#> SRR805744 1 0.0672 0.991 0.992 0.008
#> SRR805745 1 0.0000 0.999 1.000 0.000
#> SRR805746 1 0.0000 0.999 1.000 0.000
#> SRR805747 1 0.0000 0.999 1.000 0.000
#> SRR805748 1 0.0000 0.999 1.000 0.000
#> SRR805749 1 0.0000 0.999 1.000 0.000
#> SRR805750 1 0.0000 0.999 1.000 0.000
#> SRR805751 1 0.0000 0.999 1.000 0.000
#> SRR805752 2 0.0000 0.836 0.000 1.000
#> SRR805753 2 0.0000 0.836 0.000 1.000
#> SRR805754 1 0.0000 0.999 1.000 0.000
#> SRR805755 1 0.0000 0.999 1.000 0.000
#> SRR805756 1 0.0000 0.999 1.000 0.000
#> SRR805757 1 0.0000 0.999 1.000 0.000
#> SRR805758 1 0.0000 0.999 1.000 0.000
#> SRR805759 1 0.0000 0.999 1.000 0.000
#> SRR805760 1 0.0000 0.999 1.000 0.000
#> SRR805761 1 0.0000 0.999 1.000 0.000
#> SRR805762 1 0.0000 0.999 1.000 0.000
#> SRR805763 1 0.0000 0.999 1.000 0.000
#> SRR805764 1 0.0000 0.999 1.000 0.000
#> SRR805765 1 0.0000 0.999 1.000 0.000
#> SRR805766 1 0.0000 0.999 1.000 0.000
#> SRR805767 1 0.0000 0.999 1.000 0.000
#> SRR805768 1 0.0000 0.999 1.000 0.000
#> SRR805769 1 0.0000 0.999 1.000 0.000
#> SRR805770 1 0.0000 0.999 1.000 0.000
#> SRR805771 1 0.0000 0.999 1.000 0.000
#> SRR805772 1 0.0000 0.999 1.000 0.000
#> SRR805773 1 0.0000 0.999 1.000 0.000
#> SRR805774 1 0.0000 0.999 1.000 0.000
#> SRR805775 1 0.0000 0.999 1.000 0.000
#> SRR805776 1 0.0000 0.999 1.000 0.000
#> SRR805777 1 0.0000 0.999 1.000 0.000
#> SRR805778 1 0.0000 0.999 1.000 0.000
#> SRR805779 1 0.0000 0.999 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.6267 0.398 0.000 0.548 0.452
#> SRR805726 2 0.6267 0.398 0.000 0.548 0.452
#> SRR805727 2 0.6267 0.398 0.000 0.548 0.452
#> SRR805728 2 0.0237 0.818 0.000 0.996 0.004
#> SRR805729 2 0.6267 0.398 0.000 0.548 0.452
#> SRR805730 2 0.0000 0.818 0.000 1.000 0.000
#> SRR805731 2 0.0000 0.818 0.000 1.000 0.000
#> SRR805732 2 0.0000 0.818 0.000 1.000 0.000
#> SRR805733 2 0.0000 0.818 0.000 1.000 0.000
#> SRR805735 2 0.0237 0.818 0.000 0.996 0.004
#> SRR805736 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805737 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805738 3 0.0424 0.986 0.000 0.008 0.992
#> SRR805739 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805740 3 0.0424 0.986 0.000 0.008 0.992
#> SRR805741 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805742 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805743 2 0.2537 0.792 0.000 0.920 0.080
#> SRR805744 3 0.0424 0.986 0.000 0.008 0.992
#> SRR805745 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805746 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805747 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805748 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805749 3 0.2625 0.879 0.084 0.000 0.916
#> SRR805750 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805751 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805752 2 0.0000 0.818 0.000 1.000 0.000
#> SRR805753 2 0.0000 0.818 0.000 1.000 0.000
#> SRR805754 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805755 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805756 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805757 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805758 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805759 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805760 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805761 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805762 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805763 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805764 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805765 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805766 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805767 3 0.0000 0.994 0.000 0.000 1.000
#> SRR805768 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805769 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805770 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805771 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805772 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805773 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805774 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805775 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805776 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805777 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805778 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805779 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
#> SRR805725 2 0.6286 0.489 0.000 0.552 NA 0.384
#> SRR805726 2 0.6286 0.489 0.000 0.552 NA 0.384
#> SRR805727 2 0.6286 0.489 0.000 0.552 NA 0.384
#> SRR805728 2 0.0000 0.750 0.000 1.000 NA 0.000
#> SRR805729 2 0.6286 0.489 0.000 0.552 NA 0.384
#> SRR805730 2 0.0188 0.750 0.000 0.996 NA 0.000
#> SRR805731 2 0.0188 0.750 0.000 0.996 NA 0.000
#> SRR805732 2 0.4697 0.681 0.000 0.644 NA 0.000
#> SRR805733 2 0.4697 0.681 0.000 0.644 NA 0.000
#> SRR805735 2 0.0000 0.750 0.000 1.000 NA 0.000
#> SRR805736 4 0.2647 0.767 0.000 0.000 NA 0.880
#> SRR805737 4 0.2647 0.767 0.000 0.000 NA 0.880
#> SRR805738 4 0.2048 0.685 0.000 0.008 NA 0.928
#> SRR805739 4 0.2647 0.767 0.000 0.000 NA 0.880
#> SRR805740 4 0.2048 0.685 0.000 0.008 NA 0.928
#> SRR805741 4 0.0000 0.733 0.000 0.000 NA 1.000
#> SRR805742 4 0.0000 0.733 0.000 0.000 NA 1.000
#> SRR805743 2 0.2179 0.735 0.000 0.924 NA 0.012
#> SRR805744 4 0.2048 0.685 0.000 0.008 NA 0.928
#> SRR805745 4 0.2647 0.767 0.000 0.000 NA 0.880
#> SRR805746 4 0.2647 0.767 0.000 0.000 NA 0.880
#> SRR805747 4 0.4972 0.692 0.000 0.000 NA 0.544
#> SRR805748 4 0.4967 0.692 0.000 0.000 NA 0.548
#> SRR805749 4 0.6638 0.635 0.084 0.000 NA 0.496
#> SRR805750 4 0.4972 0.692 0.000 0.000 NA 0.544
#> SRR805751 4 0.4877 0.705 0.000 0.000 NA 0.592
#> SRR805752 2 0.4697 0.681 0.000 0.644 NA 0.000
#> SRR805753 2 0.4697 0.681 0.000 0.644 NA 0.000
#> SRR805754 4 0.4972 0.692 0.000 0.000 NA 0.544
#> SRR805755 4 0.4972 0.692 0.000 0.000 NA 0.544
#> SRR805756 4 0.4972 0.692 0.000 0.000 NA 0.544
#> SRR805757 4 0.4972 0.692 0.000 0.000 NA 0.544
#> SRR805758 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805759 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805760 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805761 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805762 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805763 4 0.3837 0.723 0.000 0.000 NA 0.776
#> SRR805764 4 0.2760 0.689 0.000 0.000 NA 0.872
#> SRR805765 4 0.2760 0.689 0.000 0.000 NA 0.872
#> SRR805766 4 0.3024 0.697 0.000 0.000 NA 0.852
#> SRR805767 4 0.3837 0.723 0.000 0.000 NA 0.776
#> SRR805768 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805769 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805770 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805771 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805772 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805773 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805774 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805775 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805776 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805777 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805778 1 0.0000 1.000 1.000 0.000 NA 0.000
#> SRR805779 1 0.0000 1.000 1.000 0.000 NA 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 2 0.438 0.631 0.000 0.616 0.000 0.008 0.376
#> SRR805726 2 0.438 0.631 0.000 0.616 0.000 0.008 0.376
#> SRR805727 2 0.438 0.631 0.000 0.616 0.000 0.008 0.376
#> SRR805728 2 0.414 0.549 0.000 0.616 0.384 0.000 0.000
#> SRR805729 2 0.438 0.631 0.000 0.616 0.000 0.008 0.376
#> SRR805730 2 0.415 0.545 0.000 0.612 0.388 0.000 0.000
#> SRR805731 2 0.415 0.545 0.000 0.612 0.388 0.000 0.000
#> SRR805732 3 0.000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR805733 3 0.000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR805735 2 0.414 0.549 0.000 0.616 0.384 0.000 0.000
#> SRR805736 5 0.293 0.779 0.000 0.000 0.000 0.180 0.820
#> SRR805737 5 0.293 0.779 0.000 0.000 0.000 0.180 0.820
#> SRR805738 5 0.189 0.718 0.000 0.072 0.000 0.008 0.920
#> SRR805739 5 0.293 0.779 0.000 0.000 0.000 0.180 0.820
#> SRR805740 5 0.189 0.718 0.000 0.072 0.000 0.008 0.920
#> SRR805741 5 0.029 0.762 0.000 0.000 0.000 0.008 0.992
#> SRR805742 5 0.029 0.762 0.000 0.000 0.000 0.008 0.992
#> SRR805743 2 0.421 0.579 0.000 0.680 0.308 0.000 0.012
#> SRR805744 5 0.189 0.718 0.000 0.072 0.000 0.008 0.920
#> SRR805745 5 0.293 0.779 0.000 0.000 0.000 0.180 0.820
#> SRR805746 5 0.293 0.779 0.000 0.000 0.000 0.180 0.820
#> SRR805747 4 0.104 0.977 0.000 0.000 0.000 0.960 0.040
#> SRR805748 4 0.112 0.973 0.000 0.000 0.000 0.956 0.044
#> SRR805749 4 0.167 0.874 0.076 0.000 0.000 0.924 0.000
#> SRR805750 4 0.104 0.977 0.000 0.000 0.000 0.960 0.040
#> SRR805751 4 0.191 0.924 0.000 0.000 0.000 0.908 0.092
#> SRR805752 3 0.000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR805753 3 0.000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR805754 4 0.104 0.977 0.000 0.000 0.000 0.960 0.040
#> SRR805755 4 0.104 0.977 0.000 0.000 0.000 0.960 0.040
#> SRR805756 4 0.104 0.977 0.000 0.000 0.000 0.960 0.040
#> SRR805757 4 0.104 0.977 0.000 0.000 0.000 0.960 0.040
#> SRR805758 1 0.029 0.969 0.992 0.000 0.000 0.008 0.000
#> SRR805759 1 0.029 0.969 0.992 0.000 0.000 0.008 0.000
#> SRR805760 1 0.029 0.969 0.992 0.000 0.000 0.008 0.000
#> SRR805761 1 0.029 0.969 0.992 0.000 0.000 0.008 0.000
#> SRR805762 1 0.029 0.969 0.992 0.000 0.000 0.008 0.000
#> SRR805763 5 0.541 0.717 0.000 0.284 0.000 0.092 0.624
#> SRR805764 5 0.386 0.719 0.000 0.284 0.000 0.004 0.712
#> SRR805765 5 0.386 0.719 0.000 0.284 0.000 0.004 0.712
#> SRR805766 5 0.418 0.721 0.000 0.284 0.000 0.016 0.700
#> SRR805767 5 0.541 0.717 0.000 0.284 0.000 0.092 0.624
#> SRR805768 1 0.029 0.969 0.992 0.000 0.000 0.008 0.000
#> SRR805769 1 0.000 0.969 1.000 0.000 0.000 0.000 0.000
#> SRR805770 1 0.184 0.958 0.932 0.036 0.000 0.032 0.000
#> SRR805771 1 0.184 0.958 0.932 0.036 0.000 0.032 0.000
#> SRR805772 1 0.000 0.969 1.000 0.000 0.000 0.000 0.000
#> SRR805773 1 0.029 0.969 0.992 0.000 0.000 0.008 0.000
#> SRR805774 1 0.000 0.969 1.000 0.000 0.000 0.000 0.000
#> SRR805775 1 0.184 0.958 0.932 0.036 0.000 0.032 0.000
#> SRR805776 1 0.184 0.958 0.932 0.036 0.000 0.032 0.000
#> SRR805777 1 0.184 0.958 0.932 0.036 0.000 0.032 0.000
#> SRR805778 1 0.184 0.958 0.932 0.036 0.000 0.032 0.000
#> SRR805779 1 0.184 0.958 0.932 0.036 0.000 0.032 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0.3975 0.606 0.000 0.544 0.000 0.004 0.452 0.000
#> SRR805726 2 0.3975 0.606 0.000 0.544 0.000 0.004 0.452 0.000
#> SRR805727 2 0.3975 0.606 0.000 0.544 0.000 0.004 0.452 0.000
#> SRR805728 2 0.0000 0.717 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805729 2 0.3975 0.606 0.000 0.544 0.000 0.004 0.452 0.000
#> SRR805730 2 0.0146 0.715 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR805731 2 0.0146 0.715 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR805732 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805733 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805735 2 0.0000 0.717 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805736 5 0.4067 0.840 0.000 0.000 0.104 0.144 0.752 0.000
#> SRR805737 5 0.4067 0.840 0.000 0.000 0.104 0.144 0.752 0.000
#> SRR805738 5 0.0146 0.790 0.000 0.000 0.000 0.004 0.996 0.000
#> SRR805739 5 0.4067 0.840 0.000 0.000 0.104 0.144 0.752 0.000
#> SRR805740 5 0.0146 0.790 0.000 0.000 0.000 0.004 0.996 0.000
#> SRR805741 5 0.1588 0.822 0.000 0.000 0.072 0.004 0.924 0.000
#> SRR805742 5 0.1588 0.822 0.000 0.000 0.072 0.004 0.924 0.000
#> SRR805743 2 0.1610 0.719 0.000 0.916 0.000 0.000 0.084 0.000
#> SRR805744 5 0.0146 0.790 0.000 0.000 0.000 0.004 0.996 0.000
#> SRR805745 5 0.4067 0.840 0.000 0.000 0.104 0.144 0.752 0.000
#> SRR805746 5 0.4067 0.840 0.000 0.000 0.104 0.144 0.752 0.000
#> SRR805747 4 0.1007 0.972 0.000 0.000 0.000 0.956 0.044 0.000
#> SRR805748 4 0.1616 0.957 0.000 0.000 0.020 0.932 0.048 0.000
#> SRR805749 4 0.1444 0.872 0.072 0.000 0.000 0.928 0.000 0.000
#> SRR805750 4 0.1007 0.972 0.000 0.000 0.000 0.956 0.044 0.000
#> SRR805751 4 0.2301 0.915 0.000 0.000 0.020 0.884 0.096 0.000
#> SRR805752 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805753 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805754 4 0.1007 0.972 0.000 0.000 0.000 0.956 0.044 0.000
#> SRR805755 4 0.1007 0.972 0.000 0.000 0.000 0.956 0.044 0.000
#> SRR805756 4 0.1007 0.972 0.000 0.000 0.000 0.956 0.044 0.000
#> SRR805757 4 0.1007 0.972 0.000 0.000 0.000 0.956 0.044 0.000
#> SRR805758 1 0.0363 0.964 0.988 0.000 0.000 0.012 0.000 0.000
#> SRR805759 1 0.0363 0.964 0.988 0.000 0.000 0.012 0.000 0.000
#> SRR805760 1 0.0363 0.964 0.988 0.000 0.000 0.012 0.000 0.000
#> SRR805761 1 0.0363 0.964 0.988 0.000 0.000 0.012 0.000 0.000
#> SRR805762 1 0.0363 0.964 0.988 0.000 0.000 0.012 0.000 0.000
#> SRR805763 3 0.1411 0.897 0.000 0.000 0.936 0.060 0.004 0.000
#> SRR805764 3 0.1806 0.920 0.000 0.000 0.908 0.004 0.088 0.000
#> SRR805765 3 0.1806 0.920 0.000 0.000 0.908 0.004 0.088 0.000
#> SRR805766 3 0.1644 0.925 0.000 0.000 0.920 0.004 0.076 0.000
#> SRR805767 3 0.1411 0.897 0.000 0.000 0.936 0.060 0.004 0.000
#> SRR805768 1 0.0363 0.964 0.988 0.000 0.000 0.012 0.000 0.000
#> SRR805769 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805770 1 0.1720 0.953 0.928 0.000 0.040 0.032 0.000 0.000
#> SRR805771 1 0.1720 0.953 0.928 0.000 0.040 0.032 0.000 0.000
#> SRR805772 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805773 1 0.0363 0.964 0.988 0.000 0.000 0.012 0.000 0.000
#> SRR805774 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805775 1 0.1720 0.953 0.928 0.000 0.040 0.032 0.000 0.000
#> SRR805776 1 0.1720 0.953 0.928 0.000 0.040 0.032 0.000 0.000
#> SRR805777 1 0.1720 0.953 0.928 0.000 0.040 0.032 0.000 0.000
#> SRR805778 1 0.1720 0.953 0.928 0.000 0.040 0.032 0.000 0.000
#> SRR805779 1 0.1720 0.953 0.928 0.000 0.040 0.032 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "kmeans"]
# you can also extract it by
# res = res_list["ATC:kmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 14939 rows and 54 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 0.688 0.826 0.920 0.4865 0.516 0.516
#> 3 3 0.948 0.969 0.981 0.2721 0.761 0.578
#> 4 4 0.681 0.636 0.787 0.1500 0.814 0.557
#> 5 5 0.683 0.686 0.788 0.0837 0.881 0.604
#> 6 6 0.769 0.792 0.798 0.0572 0.943 0.730
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805725 2 0.000 0.861 0.000 1.000
#> SRR805726 2 0.000 0.861 0.000 1.000
#> SRR805727 2 0.000 0.861 0.000 1.000
#> SRR805728 2 0.000 0.861 0.000 1.000
#> SRR805729 2 0.000 0.861 0.000 1.000
#> SRR805730 2 0.000 0.861 0.000 1.000
#> SRR805731 2 0.000 0.861 0.000 1.000
#> SRR805732 2 0.000 0.861 0.000 1.000
#> SRR805733 2 0.000 0.861 0.000 1.000
#> SRR805735 2 0.000 0.861 0.000 1.000
#> SRR805736 2 0.000 0.861 0.000 1.000
#> SRR805737 2 0.000 0.861 0.000 1.000
#> SRR805738 2 0.000 0.861 0.000 1.000
#> SRR805739 2 0.969 0.506 0.396 0.604
#> SRR805740 2 0.000 0.861 0.000 1.000
#> SRR805741 2 0.000 0.861 0.000 1.000
#> SRR805742 2 0.000 0.861 0.000 1.000
#> SRR805743 2 0.000 0.861 0.000 1.000
#> SRR805744 2 0.000 0.861 0.000 1.000
#> SRR805745 2 0.969 0.506 0.396 0.604
#> SRR805746 2 0.969 0.506 0.396 0.604
#> SRR805747 1 0.946 0.247 0.636 0.364
#> SRR805748 2 0.969 0.506 0.396 0.604
#> SRR805749 1 0.000 0.974 1.000 0.000
#> SRR805750 2 0.969 0.506 0.396 0.604
#> SRR805751 2 0.000 0.861 0.000 1.000
#> SRR805752 2 0.000 0.861 0.000 1.000
#> SRR805753 2 0.000 0.861 0.000 1.000
#> SRR805754 2 0.963 0.519 0.388 0.612
#> SRR805755 2 0.969 0.506 0.396 0.604
#> SRR805756 2 0.963 0.519 0.388 0.612
#> SRR805757 2 0.963 0.519 0.388 0.612
#> SRR805758 1 0.000 0.974 1.000 0.000
#> SRR805759 1 0.000 0.974 1.000 0.000
#> SRR805760 1 0.000 0.974 1.000 0.000
#> SRR805761 1 0.000 0.974 1.000 0.000
#> SRR805762 1 0.000 0.974 1.000 0.000
#> SRR805763 1 0.343 0.899 0.936 0.064
#> SRR805764 2 0.000 0.861 0.000 1.000
#> SRR805765 2 0.000 0.861 0.000 1.000
#> SRR805766 2 0.949 0.544 0.368 0.632
#> SRR805767 1 0.000 0.974 1.000 0.000
#> SRR805768 1 0.000 0.974 1.000 0.000
#> SRR805769 1 0.000 0.974 1.000 0.000
#> SRR805770 1 0.000 0.974 1.000 0.000
#> SRR805771 1 0.000 0.974 1.000 0.000
#> SRR805772 1 0.000 0.974 1.000 0.000
#> SRR805773 1 0.000 0.974 1.000 0.000
#> SRR805774 1 0.000 0.974 1.000 0.000
#> SRR805775 1 0.000 0.974 1.000 0.000
#> SRR805776 1 0.000 0.974 1.000 0.000
#> SRR805777 1 0.000 0.974 1.000 0.000
#> SRR805778 1 0.000 0.974 1.000 0.000
#> SRR805779 1 0.000 0.974 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.0237 0.985 0.000 0.996 0.004
#> SRR805726 2 0.0237 0.985 0.000 0.996 0.004
#> SRR805727 2 0.0237 0.985 0.000 0.996 0.004
#> SRR805728 3 0.3116 0.919 0.000 0.108 0.892
#> SRR805729 2 0.0237 0.985 0.000 0.996 0.004
#> SRR805730 3 0.0747 0.960 0.000 0.016 0.984
#> SRR805731 3 0.0747 0.960 0.000 0.016 0.984
#> SRR805732 3 0.0747 0.960 0.000 0.016 0.984
#> SRR805733 3 0.0747 0.960 0.000 0.016 0.984
#> SRR805735 3 0.3116 0.919 0.000 0.108 0.892
#> SRR805736 2 0.0237 0.985 0.000 0.996 0.004
#> SRR805737 2 0.0237 0.985 0.000 0.996 0.004
#> SRR805738 2 0.0237 0.985 0.000 0.996 0.004
#> SRR805739 2 0.0237 0.982 0.000 0.996 0.004
#> SRR805740 2 0.0237 0.985 0.000 0.996 0.004
#> SRR805741 2 0.0237 0.985 0.000 0.996 0.004
#> SRR805742 2 0.0237 0.985 0.000 0.996 0.004
#> SRR805743 3 0.3116 0.919 0.000 0.108 0.892
#> SRR805744 2 0.0237 0.985 0.000 0.996 0.004
#> SRR805745 2 0.0237 0.984 0.004 0.996 0.000
#> SRR805746 2 0.0237 0.984 0.004 0.996 0.000
#> SRR805747 2 0.0829 0.976 0.004 0.984 0.012
#> SRR805748 2 0.0237 0.984 0.004 0.996 0.000
#> SRR805749 2 0.5493 0.673 0.232 0.756 0.012
#> SRR805750 2 0.0237 0.984 0.004 0.996 0.000
#> SRR805751 2 0.0237 0.985 0.000 0.996 0.004
#> SRR805752 3 0.0747 0.960 0.000 0.016 0.984
#> SRR805753 3 0.0747 0.960 0.000 0.016 0.984
#> SRR805754 2 0.0237 0.984 0.004 0.996 0.000
#> SRR805755 2 0.0237 0.984 0.004 0.996 0.000
#> SRR805756 2 0.0237 0.984 0.004 0.996 0.000
#> SRR805757 2 0.0237 0.984 0.004 0.996 0.000
#> SRR805758 1 0.0592 0.982 0.988 0.000 0.012
#> SRR805759 1 0.0829 0.981 0.984 0.004 0.012
#> SRR805760 1 0.0829 0.981 0.984 0.004 0.012
#> SRR805761 1 0.0829 0.981 0.984 0.004 0.012
#> SRR805762 1 0.0829 0.981 0.984 0.004 0.012
#> SRR805763 2 0.0747 0.972 0.000 0.984 0.016
#> SRR805764 2 0.0237 0.982 0.000 0.996 0.004
#> SRR805765 2 0.0237 0.982 0.000 0.996 0.004
#> SRR805766 2 0.0747 0.972 0.000 0.984 0.016
#> SRR805767 1 0.4068 0.830 0.864 0.120 0.016
#> SRR805768 1 0.0829 0.981 0.984 0.004 0.012
#> SRR805769 1 0.0000 0.986 1.000 0.000 0.000
#> SRR805770 1 0.0000 0.986 1.000 0.000 0.000
#> SRR805771 1 0.0000 0.986 1.000 0.000 0.000
#> SRR805772 1 0.0000 0.986 1.000 0.000 0.000
#> SRR805773 1 0.0000 0.986 1.000 0.000 0.000
#> SRR805774 1 0.0000 0.986 1.000 0.000 0.000
#> SRR805775 1 0.0000 0.986 1.000 0.000 0.000
#> SRR805776 1 0.0000 0.986 1.000 0.000 0.000
#> SRR805777 1 0.0000 0.986 1.000 0.000 0.000
#> SRR805778 1 0.0000 0.986 1.000 0.000 0.000
#> SRR805779 1 0.0000 0.986 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.0469 0.6676 0.000 0.988 0.000 0.012
#> SRR805726 2 0.0469 0.6676 0.000 0.988 0.000 0.012
#> SRR805727 2 0.0469 0.6676 0.000 0.988 0.000 0.012
#> SRR805728 2 0.4948 0.0770 0.000 0.560 0.440 0.000
#> SRR805729 2 0.0469 0.6676 0.000 0.988 0.000 0.012
#> SRR805730 3 0.3649 0.7518 0.000 0.204 0.796 0.000
#> SRR805731 3 0.0000 0.9570 0.000 0.000 1.000 0.000
#> SRR805732 3 0.0000 0.9570 0.000 0.000 1.000 0.000
#> SRR805733 3 0.0000 0.9570 0.000 0.000 1.000 0.000
#> SRR805735 2 0.4948 0.0770 0.000 0.560 0.440 0.000
#> SRR805736 2 0.3649 0.4247 0.000 0.796 0.000 0.204
#> SRR805737 2 0.3649 0.4247 0.000 0.796 0.000 0.204
#> SRR805738 2 0.0336 0.6707 0.000 0.992 0.000 0.008
#> SRR805739 2 0.3649 0.4247 0.000 0.796 0.000 0.204
#> SRR805740 2 0.0336 0.6707 0.000 0.992 0.000 0.008
#> SRR805741 2 0.0469 0.6693 0.000 0.988 0.000 0.012
#> SRR805742 2 0.0469 0.6693 0.000 0.988 0.000 0.012
#> SRR805743 2 0.4948 0.0770 0.000 0.560 0.440 0.000
#> SRR805744 2 0.0000 0.6703 0.000 1.000 0.000 0.000
#> SRR805745 2 0.3649 0.4247 0.000 0.796 0.000 0.204
#> SRR805746 2 0.3649 0.4247 0.000 0.796 0.000 0.204
#> SRR805747 4 0.4972 0.6859 0.000 0.456 0.000 0.544
#> SRR805748 4 0.4972 0.6859 0.000 0.456 0.000 0.544
#> SRR805749 4 0.3908 0.4650 0.004 0.212 0.000 0.784
#> SRR805750 4 0.4972 0.6859 0.000 0.456 0.000 0.544
#> SRR805751 4 0.4994 0.6418 0.000 0.480 0.000 0.520
#> SRR805752 3 0.0000 0.9570 0.000 0.000 1.000 0.000
#> SRR805753 3 0.0000 0.9570 0.000 0.000 1.000 0.000
#> SRR805754 4 0.4972 0.6859 0.000 0.456 0.000 0.544
#> SRR805755 4 0.4972 0.6859 0.000 0.456 0.000 0.544
#> SRR805756 4 0.4972 0.6859 0.000 0.456 0.000 0.544
#> SRR805757 4 0.4972 0.6859 0.000 0.456 0.000 0.544
#> SRR805758 1 0.4776 0.7280 0.624 0.000 0.000 0.376
#> SRR805759 1 0.4817 0.7230 0.612 0.000 0.000 0.388
#> SRR805760 1 0.4817 0.7230 0.612 0.000 0.000 0.388
#> SRR805761 1 0.4817 0.7230 0.612 0.000 0.000 0.388
#> SRR805762 1 0.4817 0.7230 0.612 0.000 0.000 0.388
#> SRR805763 4 0.4661 -0.0654 0.000 0.348 0.000 0.652
#> SRR805764 2 0.3610 0.5279 0.000 0.800 0.000 0.200
#> SRR805765 2 0.3764 0.5220 0.000 0.784 0.000 0.216
#> SRR805766 2 0.5000 0.1397 0.000 0.504 0.000 0.496
#> SRR805767 4 0.4978 -0.3355 0.324 0.012 0.000 0.664
#> SRR805768 1 0.4817 0.7230 0.612 0.000 0.000 0.388
#> SRR805769 1 0.0817 0.8514 0.976 0.000 0.000 0.024
#> SRR805770 1 0.0000 0.8516 1.000 0.000 0.000 0.000
#> SRR805771 1 0.0000 0.8516 1.000 0.000 0.000 0.000
#> SRR805772 1 0.0817 0.8514 0.976 0.000 0.000 0.024
#> SRR805773 1 0.1022 0.8503 0.968 0.000 0.000 0.032
#> SRR805774 1 0.0817 0.8514 0.976 0.000 0.000 0.024
#> SRR805775 1 0.0000 0.8516 1.000 0.000 0.000 0.000
#> SRR805776 1 0.0000 0.8516 1.000 0.000 0.000 0.000
#> SRR805777 1 0.0000 0.8516 1.000 0.000 0.000 0.000
#> SRR805778 1 0.0000 0.8516 1.000 0.000 0.000 0.000
#> SRR805779 1 0.0000 0.8516 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
#> SRR805725 5 0.0671 0.677 0.000 0.000 0.004 0.016 0.980
#> SRR805726 5 0.0671 0.677 0.000 0.000 0.004 0.016 0.980
#> SRR805727 5 0.0671 0.677 0.000 0.000 0.004 0.016 0.980
#> SRR805728 5 0.3500 0.489 0.000 0.172 0.004 0.016 0.808
#> SRR805729 5 0.0671 0.677 0.000 0.000 0.004 0.016 0.980
#> SRR805730 2 0.4415 0.399 0.000 0.552 0.004 0.000 0.444
#> SRR805731 2 0.0000 0.905 0.000 1.000 0.000 0.000 0.000
#> SRR805732 2 0.0000 0.905 0.000 1.000 0.000 0.000 0.000
#> SRR805733 2 0.0000 0.905 0.000 1.000 0.000 0.000 0.000
#> SRR805735 5 0.3500 0.489 0.000 0.172 0.004 0.016 0.808
#> SRR805736 5 0.6157 0.570 0.000 0.000 0.220 0.220 0.560
#> SRR805737 5 0.6157 0.570 0.000 0.000 0.220 0.220 0.560
#> SRR805738 5 0.4417 0.691 0.000 0.000 0.148 0.092 0.760
#> SRR805739 5 0.6180 0.567 0.000 0.000 0.224 0.220 0.556
#> SRR805740 5 0.4417 0.691 0.000 0.000 0.148 0.092 0.760
#> SRR805741 5 0.5195 0.667 0.000 0.000 0.216 0.108 0.676
#> SRR805742 5 0.5195 0.667 0.000 0.000 0.216 0.108 0.676
#> SRR805743 5 0.2852 0.494 0.000 0.172 0.000 0.000 0.828
#> SRR805744 5 0.1851 0.698 0.000 0.000 0.088 0.000 0.912
#> SRR805745 5 0.6180 0.564 0.000 0.000 0.220 0.224 0.556
#> SRR805746 5 0.6180 0.564 0.000 0.000 0.220 0.224 0.556
#> SRR805747 4 0.3209 0.968 0.000 0.000 0.008 0.812 0.180
#> SRR805748 4 0.3318 0.968 0.000 0.000 0.012 0.808 0.180
#> SRR805749 4 0.4139 0.800 0.000 0.000 0.132 0.784 0.084
#> SRR805750 4 0.3318 0.968 0.000 0.000 0.012 0.808 0.180
#> SRR805751 4 0.3123 0.965 0.000 0.000 0.004 0.812 0.184
#> SRR805752 2 0.0000 0.905 0.000 1.000 0.000 0.000 0.000
#> SRR805753 2 0.0000 0.905 0.000 1.000 0.000 0.000 0.000
#> SRR805754 4 0.2929 0.970 0.000 0.000 0.000 0.820 0.180
#> SRR805755 4 0.2929 0.970 0.000 0.000 0.000 0.820 0.180
#> SRR805756 4 0.2929 0.970 0.000 0.000 0.000 0.820 0.180
#> SRR805757 4 0.2929 0.970 0.000 0.000 0.000 0.820 0.180
#> SRR805758 3 0.4341 0.400 0.404 0.000 0.592 0.004 0.000
#> SRR805759 3 0.4341 0.400 0.404 0.000 0.592 0.004 0.000
#> SRR805760 3 0.4341 0.400 0.404 0.000 0.592 0.004 0.000
#> SRR805761 3 0.4341 0.400 0.404 0.000 0.592 0.004 0.000
#> SRR805762 3 0.4341 0.400 0.404 0.000 0.592 0.004 0.000
#> SRR805763 3 0.3061 0.426 0.000 0.000 0.844 0.136 0.020
#> SRR805764 3 0.5928 -0.219 0.000 0.000 0.500 0.108 0.392
#> SRR805765 3 0.5990 -0.215 0.000 0.000 0.500 0.116 0.384
#> SRR805766 3 0.5253 0.231 0.000 0.000 0.676 0.200 0.124
#> SRR805767 3 0.2653 0.453 0.024 0.000 0.880 0.096 0.000
#> SRR805768 3 0.4341 0.400 0.404 0.000 0.592 0.004 0.000
#> SRR805769 1 0.2588 0.909 0.892 0.000 0.048 0.060 0.000
#> SRR805770 1 0.1251 0.920 0.956 0.000 0.008 0.036 0.000
#> SRR805771 1 0.1251 0.920 0.956 0.000 0.008 0.036 0.000
#> SRR805772 1 0.2588 0.909 0.892 0.000 0.048 0.060 0.000
#> SRR805773 1 0.2588 0.909 0.892 0.000 0.048 0.060 0.000
#> SRR805774 1 0.2588 0.909 0.892 0.000 0.048 0.060 0.000
#> SRR805775 1 0.1251 0.920 0.956 0.000 0.008 0.036 0.000
#> SRR805776 1 0.1628 0.920 0.936 0.000 0.008 0.056 0.000
#> SRR805777 1 0.0000 0.927 1.000 0.000 0.000 0.000 0.000
#> SRR805778 1 0.1251 0.920 0.956 0.000 0.008 0.036 0.000
#> SRR805779 1 0.0000 0.927 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0.4439 0.8375 0.000 0.540 0.000 0.028 0.432 0.000
#> SRR805726 2 0.4439 0.8375 0.000 0.540 0.000 0.028 0.432 0.000
#> SRR805727 2 0.4439 0.8375 0.000 0.540 0.000 0.028 0.432 0.000
#> SRR805728 2 0.5665 0.8319 0.000 0.528 0.020 0.020 0.380 0.052
#> SRR805729 2 0.4439 0.8375 0.000 0.540 0.000 0.028 0.432 0.000
#> SRR805730 2 0.5464 0.2465 0.000 0.528 0.020 0.000 0.076 0.376
#> SRR805731 6 0.0806 0.9761 0.000 0.008 0.020 0.000 0.000 0.972
#> SRR805732 6 0.0000 0.9941 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805733 6 0.0000 0.9941 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805735 2 0.5665 0.8319 0.000 0.528 0.020 0.020 0.380 0.052
#> SRR805736 5 0.2165 0.9061 0.000 0.000 0.008 0.108 0.884 0.000
#> SRR805737 5 0.2165 0.9061 0.000 0.000 0.008 0.108 0.884 0.000
#> SRR805738 5 0.1863 0.8628 0.000 0.036 0.000 0.044 0.920 0.000
#> SRR805739 5 0.2165 0.9061 0.000 0.000 0.008 0.108 0.884 0.000
#> SRR805740 5 0.1863 0.8628 0.000 0.036 0.000 0.044 0.920 0.000
#> SRR805741 5 0.1141 0.8943 0.000 0.000 0.000 0.052 0.948 0.000
#> SRR805742 5 0.1141 0.8943 0.000 0.000 0.000 0.052 0.948 0.000
#> SRR805743 2 0.4882 0.8210 0.000 0.540 0.004 0.000 0.404 0.052
#> SRR805744 5 0.1556 0.7518 0.000 0.080 0.000 0.000 0.920 0.000
#> SRR805745 5 0.2165 0.9061 0.000 0.000 0.008 0.108 0.884 0.000
#> SRR805746 5 0.2165 0.9061 0.000 0.000 0.008 0.108 0.884 0.000
#> SRR805747 4 0.2594 0.9598 0.000 0.036 0.020 0.888 0.056 0.000
#> SRR805748 4 0.2815 0.9576 0.000 0.044 0.024 0.876 0.056 0.000
#> SRR805749 4 0.2556 0.9016 0.000 0.048 0.052 0.888 0.012 0.000
#> SRR805750 4 0.2594 0.9598 0.000 0.036 0.020 0.888 0.056 0.000
#> SRR805751 4 0.1606 0.9651 0.000 0.008 0.004 0.932 0.056 0.000
#> SRR805752 6 0.0000 0.9941 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805753 6 0.0000 0.9941 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805754 4 0.1204 0.9678 0.000 0.000 0.000 0.944 0.056 0.000
#> SRR805755 4 0.1462 0.9664 0.000 0.008 0.000 0.936 0.056 0.000
#> SRR805756 4 0.1204 0.9678 0.000 0.000 0.000 0.944 0.056 0.000
#> SRR805757 4 0.1204 0.9678 0.000 0.000 0.000 0.944 0.056 0.000
#> SRR805758 3 0.5589 0.5804 0.244 0.128 0.604 0.024 0.000 0.000
#> SRR805759 3 0.5589 0.5804 0.244 0.128 0.604 0.024 0.000 0.000
#> SRR805760 3 0.5589 0.5804 0.244 0.128 0.604 0.024 0.000 0.000
#> SRR805761 3 0.5589 0.5804 0.244 0.128 0.604 0.024 0.000 0.000
#> SRR805762 3 0.5589 0.5804 0.244 0.128 0.604 0.024 0.000 0.000
#> SRR805763 3 0.3080 0.4992 0.000 0.040 0.848 0.012 0.100 0.000
#> SRR805764 3 0.5567 0.0569 0.000 0.096 0.464 0.012 0.428 0.000
#> SRR805765 3 0.5610 0.0527 0.000 0.092 0.464 0.016 0.428 0.000
#> SRR805766 3 0.5319 0.3064 0.000 0.040 0.608 0.056 0.296 0.000
#> SRR805767 3 0.1788 0.5236 0.004 0.000 0.916 0.004 0.076 0.000
#> SRR805768 3 0.5589 0.5804 0.244 0.128 0.604 0.024 0.000 0.000
#> SRR805769 1 0.2095 0.8458 0.916 0.040 0.028 0.016 0.000 0.000
#> SRR805770 1 0.2793 0.8557 0.800 0.200 0.000 0.000 0.000 0.000
#> SRR805771 1 0.2793 0.8557 0.800 0.200 0.000 0.000 0.000 0.000
#> SRR805772 1 0.2095 0.8458 0.916 0.040 0.028 0.016 0.000 0.000
#> SRR805773 1 0.2307 0.8390 0.904 0.048 0.032 0.016 0.000 0.000
#> SRR805774 1 0.2095 0.8458 0.916 0.040 0.028 0.016 0.000 0.000
#> SRR805775 1 0.2902 0.8556 0.800 0.196 0.000 0.004 0.000 0.000
#> SRR805776 1 0.0603 0.8630 0.980 0.004 0.000 0.016 0.000 0.000
#> SRR805777 1 0.1910 0.8732 0.892 0.108 0.000 0.000 0.000 0.000
#> SRR805778 1 0.2793 0.8557 0.800 0.200 0.000 0.000 0.000 0.000
#> SRR805779 1 0.1910 0.8732 0.892 0.108 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "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 14939 rows and 54 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 0.885 0.920 0.968 0.5087 0.491 0.491
#> 3 3 0.946 0.908 0.963 0.2458 0.846 0.694
#> 4 4 1.000 0.979 0.985 0.1634 0.873 0.662
#> 5 5 0.902 0.937 0.969 0.0632 0.945 0.791
#> 6 6 0.917 0.948 0.931 0.0491 0.947 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] 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
#> SRR805725 2 0.000 0.96602 0.000 1.000
#> SRR805726 2 0.000 0.96602 0.000 1.000
#> SRR805727 2 0.000 0.96602 0.000 1.000
#> SRR805728 2 0.000 0.96602 0.000 1.000
#> SRR805729 2 0.000 0.96602 0.000 1.000
#> SRR805730 2 0.000 0.96602 0.000 1.000
#> SRR805731 2 0.000 0.96602 0.000 1.000
#> SRR805732 2 0.000 0.96602 0.000 1.000
#> SRR805733 2 0.000 0.96602 0.000 1.000
#> SRR805735 2 0.000 0.96602 0.000 1.000
#> SRR805736 2 0.000 0.96602 0.000 1.000
#> SRR805737 2 0.000 0.96602 0.000 1.000
#> SRR805738 2 0.000 0.96602 0.000 1.000
#> SRR805739 2 0.999 0.00669 0.484 0.516
#> SRR805740 2 0.000 0.96602 0.000 1.000
#> SRR805741 2 0.000 0.96602 0.000 1.000
#> SRR805742 2 0.000 0.96602 0.000 1.000
#> SRR805743 2 0.000 0.96602 0.000 1.000
#> SRR805744 2 0.000 0.96602 0.000 1.000
#> SRR805745 1 0.839 0.63565 0.732 0.268
#> SRR805746 1 0.866 0.60288 0.712 0.288
#> SRR805747 1 0.000 0.96332 1.000 0.000
#> SRR805748 1 0.689 0.76870 0.816 0.184
#> SRR805749 1 0.000 0.96332 1.000 0.000
#> SRR805750 1 0.118 0.95112 0.984 0.016
#> SRR805751 2 0.000 0.96602 0.000 1.000
#> SRR805752 2 0.000 0.96602 0.000 1.000
#> SRR805753 2 0.000 0.96602 0.000 1.000
#> SRR805754 2 0.184 0.94390 0.028 0.972
#> SRR805755 1 0.482 0.87041 0.896 0.104
#> SRR805756 2 0.163 0.94733 0.024 0.976
#> SRR805757 2 0.224 0.93661 0.036 0.964
#> SRR805758 1 0.000 0.96332 1.000 0.000
#> SRR805759 1 0.000 0.96332 1.000 0.000
#> SRR805760 1 0.000 0.96332 1.000 0.000
#> SRR805761 1 0.000 0.96332 1.000 0.000
#> SRR805762 1 0.000 0.96332 1.000 0.000
#> SRR805763 1 0.000 0.96332 1.000 0.000
#> SRR805764 2 0.000 0.96602 0.000 1.000
#> SRR805765 2 0.000 0.96602 0.000 1.000
#> SRR805766 2 0.871 0.57295 0.292 0.708
#> SRR805767 1 0.000 0.96332 1.000 0.000
#> SRR805768 1 0.000 0.96332 1.000 0.000
#> SRR805769 1 0.000 0.96332 1.000 0.000
#> SRR805770 1 0.000 0.96332 1.000 0.000
#> SRR805771 1 0.000 0.96332 1.000 0.000
#> SRR805772 1 0.000 0.96332 1.000 0.000
#> SRR805773 1 0.000 0.96332 1.000 0.000
#> SRR805774 1 0.000 0.96332 1.000 0.000
#> SRR805775 1 0.000 0.96332 1.000 0.000
#> SRR805776 1 0.000 0.96332 1.000 0.000
#> SRR805777 1 0.000 0.96332 1.000 0.000
#> SRR805778 1 0.000 0.96332 1.000 0.000
#> SRR805779 1 0.000 0.96332 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.0000 0.952 0.00 1.000 0.000
#> SRR805726 2 0.0000 0.952 0.00 1.000 0.000
#> SRR805727 2 0.0000 0.952 0.00 1.000 0.000
#> SRR805728 2 0.0000 0.952 0.00 1.000 0.000
#> SRR805729 2 0.0000 0.952 0.00 1.000 0.000
#> SRR805730 2 0.0000 0.952 0.00 1.000 0.000
#> SRR805731 2 0.0000 0.952 0.00 1.000 0.000
#> SRR805732 2 0.0000 0.952 0.00 1.000 0.000
#> SRR805733 2 0.0000 0.952 0.00 1.000 0.000
#> SRR805735 2 0.0000 0.952 0.00 1.000 0.000
#> SRR805736 2 0.0892 0.946 0.02 0.980 0.000
#> SRR805737 2 0.0892 0.946 0.02 0.980 0.000
#> SRR805738 2 0.0892 0.946 0.02 0.980 0.000
#> SRR805739 2 0.6994 0.190 0.02 0.556 0.424
#> SRR805740 2 0.0892 0.946 0.02 0.980 0.000
#> SRR805741 2 0.0892 0.946 0.02 0.980 0.000
#> SRR805742 2 0.0892 0.946 0.02 0.980 0.000
#> SRR805743 2 0.0000 0.952 0.00 1.000 0.000
#> SRR805744 2 0.0892 0.946 0.02 0.980 0.000
#> SRR805745 3 0.6579 0.475 0.02 0.328 0.652
#> SRR805746 3 0.6717 0.420 0.02 0.352 0.628
#> SRR805747 1 0.0892 0.959 0.98 0.000 0.020
#> SRR805748 1 0.1015 0.967 0.98 0.012 0.008
#> SRR805749 1 0.4555 0.750 0.80 0.000 0.200
#> SRR805750 1 0.0983 0.962 0.98 0.004 0.016
#> SRR805751 1 0.0892 0.966 0.98 0.020 0.000
#> SRR805752 2 0.0000 0.952 0.00 1.000 0.000
#> SRR805753 2 0.0000 0.952 0.00 1.000 0.000
#> SRR805754 1 0.0892 0.966 0.98 0.020 0.000
#> SRR805755 1 0.1015 0.967 0.98 0.012 0.008
#> SRR805756 1 0.0892 0.966 0.98 0.020 0.000
#> SRR805757 1 0.0892 0.966 0.98 0.020 0.000
#> SRR805758 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805759 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805760 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805761 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805762 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805763 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805764 2 0.0000 0.952 0.00 1.000 0.000
#> SRR805765 2 0.0000 0.952 0.00 1.000 0.000
#> SRR805766 2 0.5926 0.429 0.00 0.644 0.356
#> SRR805767 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805768 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805769 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805770 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805771 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805772 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805773 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805774 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805775 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805776 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805777 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805778 3 0.0000 0.954 0.00 0.000 1.000
#> SRR805779 3 0.0000 0.954 0.00 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR805726 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR805727 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR805728 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR805729 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR805730 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR805731 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR805732 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR805733 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR805735 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR805736 3 0.1118 0.975 0.000 0.036 0.964 0.000
#> SRR805737 3 0.1118 0.975 0.000 0.036 0.964 0.000
#> SRR805738 3 0.1716 0.963 0.000 0.064 0.936 0.000
#> SRR805739 3 0.0188 0.955 0.000 0.004 0.996 0.000
#> SRR805740 3 0.1716 0.963 0.000 0.064 0.936 0.000
#> SRR805741 3 0.1118 0.975 0.000 0.036 0.964 0.000
#> SRR805742 3 0.1118 0.975 0.000 0.036 0.964 0.000
#> SRR805743 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR805744 3 0.2081 0.944 0.000 0.084 0.916 0.000
#> SRR805745 3 0.1284 0.960 0.024 0.012 0.964 0.000
#> SRR805746 3 0.1284 0.960 0.024 0.012 0.964 0.000
#> SRR805747 4 0.0000 0.970 0.000 0.000 0.000 1.000
#> SRR805748 4 0.0000 0.970 0.000 0.000 0.000 1.000
#> SRR805749 4 0.3074 0.803 0.152 0.000 0.000 0.848
#> SRR805750 4 0.0000 0.970 0.000 0.000 0.000 1.000
#> SRR805751 4 0.1302 0.930 0.000 0.044 0.000 0.956
#> SRR805752 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR805753 2 0.0000 0.994 0.000 1.000 0.000 0.000
#> SRR805754 4 0.0000 0.970 0.000 0.000 0.000 1.000
#> SRR805755 4 0.0000 0.970 0.000 0.000 0.000 1.000
#> SRR805756 4 0.0000 0.970 0.000 0.000 0.000 1.000
#> SRR805757 4 0.0000 0.970 0.000 0.000 0.000 1.000
#> SRR805758 1 0.0336 0.993 0.992 0.000 0.008 0.000
#> SRR805759 1 0.0336 0.993 0.992 0.000 0.008 0.000
#> SRR805760 1 0.0336 0.993 0.992 0.000 0.008 0.000
#> SRR805761 1 0.0336 0.993 0.992 0.000 0.008 0.000
#> SRR805762 1 0.0336 0.993 0.992 0.000 0.008 0.000
#> SRR805763 1 0.1118 0.972 0.964 0.000 0.036 0.000
#> SRR805764 2 0.0921 0.974 0.000 0.972 0.028 0.000
#> SRR805765 2 0.0921 0.974 0.000 0.972 0.028 0.000
#> SRR805766 2 0.1118 0.967 0.000 0.964 0.036 0.000
#> SRR805767 1 0.1022 0.976 0.968 0.000 0.032 0.000
#> SRR805768 1 0.0336 0.993 0.992 0.000 0.008 0.000
#> SRR805769 1 0.0000 0.994 1.000 0.000 0.000 0.000
#> SRR805770 1 0.0000 0.994 1.000 0.000 0.000 0.000
#> SRR805771 1 0.0000 0.994 1.000 0.000 0.000 0.000
#> SRR805772 1 0.0000 0.994 1.000 0.000 0.000 0.000
#> SRR805773 1 0.0000 0.994 1.000 0.000 0.000 0.000
#> SRR805774 1 0.0000 0.994 1.000 0.000 0.000 0.000
#> SRR805775 1 0.0000 0.994 1.000 0.000 0.000 0.000
#> SRR805776 1 0.0000 0.994 1.000 0.000 0.000 0.000
#> SRR805777 1 0.0000 0.994 1.000 0.000 0.000 0.000
#> SRR805778 1 0.0000 0.994 1.000 0.000 0.000 0.000
#> SRR805779 1 0.0000 0.994 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
#> SRR805725 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR805726 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR805727 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR805728 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR805729 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR805730 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR805731 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR805732 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR805733 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR805735 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR805736 5 0.000 0.913 0.000 0.000 0.000 0.000 1.000
#> SRR805737 5 0.000 0.913 0.000 0.000 0.000 0.000 1.000
#> SRR805738 5 0.307 0.790 0.000 0.196 0.000 0.000 0.804
#> SRR805739 5 0.000 0.913 0.000 0.000 0.000 0.000 1.000
#> SRR805740 5 0.307 0.790 0.000 0.196 0.000 0.000 0.804
#> SRR805741 5 0.000 0.913 0.000 0.000 0.000 0.000 1.000
#> SRR805742 5 0.000 0.913 0.000 0.000 0.000 0.000 1.000
#> SRR805743 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR805744 5 0.311 0.785 0.000 0.200 0.000 0.000 0.800
#> SRR805745 5 0.000 0.913 0.000 0.000 0.000 0.000 1.000
#> SRR805746 5 0.000 0.913 0.000 0.000 0.000 0.000 1.000
#> SRR805747 4 0.000 0.965 0.000 0.000 0.000 1.000 0.000
#> SRR805748 4 0.000 0.965 0.000 0.000 0.000 1.000 0.000
#> SRR805749 4 0.207 0.837 0.104 0.000 0.000 0.896 0.000
#> SRR805750 4 0.000 0.965 0.000 0.000 0.000 1.000 0.000
#> SRR805751 4 0.191 0.861 0.000 0.092 0.000 0.908 0.000
#> SRR805752 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR805753 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR805754 4 0.000 0.965 0.000 0.000 0.000 1.000 0.000
#> SRR805755 4 0.000 0.965 0.000 0.000 0.000 1.000 0.000
#> SRR805756 4 0.000 0.965 0.000 0.000 0.000 1.000 0.000
#> SRR805757 4 0.000 0.965 0.000 0.000 0.000 1.000 0.000
#> SRR805758 1 0.154 0.936 0.932 0.000 0.068 0.000 0.000
#> SRR805759 1 0.207 0.919 0.896 0.000 0.104 0.000 0.000
#> SRR805760 1 0.207 0.919 0.896 0.000 0.104 0.000 0.000
#> SRR805761 1 0.207 0.919 0.896 0.000 0.104 0.000 0.000
#> SRR805762 1 0.207 0.919 0.896 0.000 0.104 0.000 0.000
#> SRR805763 3 0.000 0.891 0.000 0.000 1.000 0.000 0.000
#> SRR805764 3 0.154 0.880 0.000 0.068 0.932 0.000 0.000
#> SRR805765 3 0.154 0.880 0.000 0.068 0.932 0.000 0.000
#> SRR805766 3 0.000 0.891 0.000 0.000 1.000 0.000 0.000
#> SRR805767 3 0.300 0.723 0.188 0.000 0.812 0.000 0.000
#> SRR805768 1 0.207 0.919 0.896 0.000 0.104 0.000 0.000
#> SRR805769 1 0.000 0.962 1.000 0.000 0.000 0.000 0.000
#> SRR805770 1 0.000 0.962 1.000 0.000 0.000 0.000 0.000
#> SRR805771 1 0.000 0.962 1.000 0.000 0.000 0.000 0.000
#> SRR805772 1 0.000 0.962 1.000 0.000 0.000 0.000 0.000
#> SRR805773 1 0.000 0.962 1.000 0.000 0.000 0.000 0.000
#> SRR805774 1 0.000 0.962 1.000 0.000 0.000 0.000 0.000
#> SRR805775 1 0.000 0.962 1.000 0.000 0.000 0.000 0.000
#> SRR805776 1 0.000 0.962 1.000 0.000 0.000 0.000 0.000
#> SRR805777 1 0.000 0.962 1.000 0.000 0.000 0.000 0.000
#> SRR805778 1 0.000 0.962 1.000 0.000 0.000 0.000 0.000
#> SRR805779 1 0.000 0.962 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805726 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805727 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805728 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805729 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805730 2 0.0547 0.983 0.000 0.980 0.000 0.000 0.000 0.020
#> SRR805731 2 0.0547 0.983 0.000 0.980 0.000 0.000 0.000 0.020
#> SRR805732 2 0.0547 0.983 0.000 0.980 0.000 0.000 0.000 0.020
#> SRR805733 2 0.0547 0.983 0.000 0.980 0.000 0.000 0.000 0.020
#> SRR805735 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805736 5 0.2357 0.889 0.000 0.000 0.116 0.000 0.872 0.012
#> SRR805737 5 0.2357 0.889 0.000 0.000 0.116 0.000 0.872 0.012
#> SRR805738 5 0.2020 0.839 0.000 0.096 0.008 0.000 0.896 0.000
#> SRR805739 5 0.2692 0.882 0.000 0.000 0.148 0.000 0.840 0.012
#> SRR805740 5 0.2020 0.839 0.000 0.096 0.008 0.000 0.896 0.000
#> SRR805741 5 0.0146 0.879 0.000 0.004 0.000 0.000 0.996 0.000
#> SRR805742 5 0.0146 0.879 0.000 0.004 0.000 0.000 0.996 0.000
#> SRR805743 2 0.2349 0.901 0.000 0.892 0.008 0.000 0.080 0.020
#> SRR805744 5 0.2070 0.835 0.000 0.100 0.008 0.000 0.892 0.000
#> SRR805745 5 0.2692 0.882 0.000 0.000 0.148 0.000 0.840 0.012
#> SRR805746 5 0.2692 0.882 0.000 0.000 0.148 0.000 0.840 0.012
#> SRR805747 4 0.1327 0.940 0.000 0.000 0.064 0.936 0.000 0.000
#> SRR805748 4 0.1327 0.940 0.000 0.000 0.064 0.936 0.000 0.000
#> SRR805749 4 0.2856 0.872 0.076 0.000 0.068 0.856 0.000 0.000
#> SRR805750 4 0.1327 0.940 0.000 0.000 0.064 0.936 0.000 0.000
#> SRR805751 4 0.1908 0.852 0.000 0.096 0.004 0.900 0.000 0.000
#> SRR805752 2 0.0547 0.983 0.000 0.980 0.000 0.000 0.000 0.020
#> SRR805753 2 0.0547 0.983 0.000 0.980 0.000 0.000 0.000 0.020
#> SRR805754 4 0.0260 0.945 0.000 0.000 0.008 0.992 0.000 0.000
#> SRR805755 4 0.0146 0.945 0.000 0.000 0.004 0.996 0.000 0.000
#> SRR805756 4 0.0146 0.945 0.000 0.000 0.004 0.996 0.000 0.000
#> SRR805757 4 0.0146 0.945 0.000 0.000 0.004 0.996 0.000 0.000
#> SRR805758 3 0.3101 0.962 0.244 0.000 0.756 0.000 0.000 0.000
#> SRR805759 3 0.3023 0.975 0.232 0.000 0.768 0.000 0.000 0.000
#> SRR805760 3 0.3023 0.975 0.232 0.000 0.768 0.000 0.000 0.000
#> SRR805761 3 0.3023 0.975 0.232 0.000 0.768 0.000 0.000 0.000
#> SRR805762 3 0.3023 0.975 0.232 0.000 0.768 0.000 0.000 0.000
#> SRR805763 6 0.1714 0.920 0.000 0.000 0.092 0.000 0.000 0.908
#> SRR805764 6 0.0405 0.962 0.000 0.004 0.008 0.000 0.000 0.988
#> SRR805765 6 0.0405 0.962 0.000 0.004 0.008 0.000 0.000 0.988
#> SRR805766 6 0.0790 0.959 0.000 0.000 0.032 0.000 0.000 0.968
#> SRR805767 3 0.3845 0.850 0.140 0.000 0.772 0.000 0.000 0.088
#> SRR805768 3 0.3023 0.975 0.232 0.000 0.768 0.000 0.000 0.000
#> SRR805769 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805770 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805771 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805772 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805773 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805774 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805775 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805776 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805777 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805778 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805779 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "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 14939 rows and 54 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.993 0.997 0.463 0.535 0.535
#> 3 3 1.000 0.983 0.994 0.250 0.846 0.722
#> 4 4 0.702 0.654 0.811 0.212 0.834 0.614
#> 5 5 0.858 0.714 0.857 0.108 0.904 0.667
#> 6 6 1.000 0.965 0.987 0.076 0.924 0.661
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
#> SRR805725 2 0.000 1.000 0.00 1.00
#> SRR805726 2 0.000 1.000 0.00 1.00
#> SRR805727 2 0.000 1.000 0.00 1.00
#> SRR805728 2 0.000 1.000 0.00 1.00
#> SRR805729 2 0.000 1.000 0.00 1.00
#> SRR805730 2 0.000 1.000 0.00 1.00
#> SRR805731 2 0.000 1.000 0.00 1.00
#> SRR805732 2 0.000 1.000 0.00 1.00
#> SRR805733 2 0.000 1.000 0.00 1.00
#> SRR805735 2 0.000 1.000 0.00 1.00
#> SRR805736 2 0.000 1.000 0.00 1.00
#> SRR805737 2 0.000 1.000 0.00 1.00
#> SRR805738 2 0.000 1.000 0.00 1.00
#> SRR805739 2 0.000 1.000 0.00 1.00
#> SRR805740 2 0.000 1.000 0.00 1.00
#> SRR805741 2 0.000 1.000 0.00 1.00
#> SRR805742 2 0.000 1.000 0.00 1.00
#> SRR805743 2 0.000 1.000 0.00 1.00
#> SRR805744 2 0.000 1.000 0.00 1.00
#> SRR805745 2 0.000 1.000 0.00 1.00
#> SRR805746 2 0.000 1.000 0.00 1.00
#> SRR805747 2 0.000 1.000 0.00 1.00
#> SRR805748 2 0.000 1.000 0.00 1.00
#> SRR805749 1 0.000 0.991 1.00 0.00
#> SRR805750 2 0.000 1.000 0.00 1.00
#> SRR805751 2 0.000 1.000 0.00 1.00
#> SRR805752 2 0.000 1.000 0.00 1.00
#> SRR805753 2 0.000 1.000 0.00 1.00
#> SRR805754 2 0.000 1.000 0.00 1.00
#> SRR805755 2 0.000 1.000 0.00 1.00
#> SRR805756 2 0.000 1.000 0.00 1.00
#> SRR805757 2 0.000 1.000 0.00 1.00
#> SRR805758 1 0.000 0.991 1.00 0.00
#> SRR805759 1 0.000 0.991 1.00 0.00
#> SRR805760 1 0.000 0.991 1.00 0.00
#> SRR805761 1 0.000 0.991 1.00 0.00
#> SRR805762 1 0.000 0.991 1.00 0.00
#> SRR805763 2 0.000 1.000 0.00 1.00
#> SRR805764 2 0.000 1.000 0.00 1.00
#> SRR805765 2 0.000 1.000 0.00 1.00
#> SRR805766 2 0.000 1.000 0.00 1.00
#> SRR805767 1 0.634 0.810 0.84 0.16
#> SRR805768 1 0.000 0.991 1.00 0.00
#> SRR805769 1 0.000 0.991 1.00 0.00
#> SRR805770 1 0.000 0.991 1.00 0.00
#> SRR805771 1 0.000 0.991 1.00 0.00
#> SRR805772 1 0.000 0.991 1.00 0.00
#> SRR805773 1 0.000 0.991 1.00 0.00
#> SRR805774 1 0.000 0.991 1.00 0.00
#> SRR805775 1 0.000 0.991 1.00 0.00
#> SRR805776 1 0.000 0.991 1.00 0.00
#> SRR805777 1 0.000 0.991 1.00 0.00
#> SRR805778 1 0.000 0.991 1.00 0.00
#> SRR805779 1 0.000 0.991 1.00 0.00
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.000 0.992 0.00 1.00 0
#> SRR805726 2 0.000 0.992 0.00 1.00 0
#> SRR805727 2 0.000 0.992 0.00 1.00 0
#> SRR805728 2 0.000 0.992 0.00 1.00 0
#> SRR805729 2 0.000 0.992 0.00 1.00 0
#> SRR805730 3 0.000 1.000 0.00 0.00 1
#> SRR805731 3 0.000 1.000 0.00 0.00 1
#> SRR805732 3 0.000 1.000 0.00 0.00 1
#> SRR805733 3 0.000 1.000 0.00 0.00 1
#> SRR805735 2 0.000 0.992 0.00 1.00 0
#> SRR805736 2 0.000 0.992 0.00 1.00 0
#> SRR805737 2 0.000 0.992 0.00 1.00 0
#> SRR805738 2 0.000 0.992 0.00 1.00 0
#> SRR805739 2 0.000 0.992 0.00 1.00 0
#> SRR805740 2 0.000 0.992 0.00 1.00 0
#> SRR805741 2 0.000 0.992 0.00 1.00 0
#> SRR805742 2 0.000 0.992 0.00 1.00 0
#> SRR805743 2 0.000 0.992 0.00 1.00 0
#> SRR805744 2 0.000 0.992 0.00 1.00 0
#> SRR805745 2 0.000 0.992 0.00 1.00 0
#> SRR805746 2 0.000 0.992 0.00 1.00 0
#> SRR805747 2 0.000 0.992 0.00 1.00 0
#> SRR805748 2 0.000 0.992 0.00 1.00 0
#> SRR805749 1 0.369 0.784 0.86 0.14 0
#> SRR805750 2 0.000 0.992 0.00 1.00 0
#> SRR805751 2 0.000 0.992 0.00 1.00 0
#> SRR805752 3 0.000 1.000 0.00 0.00 1
#> SRR805753 3 0.000 1.000 0.00 0.00 1
#> SRR805754 2 0.000 0.992 0.00 1.00 0
#> SRR805755 2 0.000 0.992 0.00 1.00 0
#> SRR805756 2 0.000 0.992 0.00 1.00 0
#> SRR805757 2 0.000 0.992 0.00 1.00 0
#> SRR805758 1 0.000 0.988 1.00 0.00 0
#> SRR805759 1 0.000 0.988 1.00 0.00 0
#> SRR805760 1 0.000 0.988 1.00 0.00 0
#> SRR805761 1 0.000 0.988 1.00 0.00 0
#> SRR805762 1 0.000 0.988 1.00 0.00 0
#> SRR805763 2 0.000 0.992 0.00 1.00 0
#> SRR805764 2 0.000 0.992 0.00 1.00 0
#> SRR805765 2 0.000 0.992 0.00 1.00 0
#> SRR805766 2 0.000 0.992 0.00 1.00 0
#> SRR805767 2 0.455 0.730 0.20 0.80 0
#> SRR805768 1 0.000 0.988 1.00 0.00 0
#> SRR805769 1 0.000 0.988 1.00 0.00 0
#> SRR805770 1 0.000 0.988 1.00 0.00 0
#> SRR805771 1 0.000 0.988 1.00 0.00 0
#> SRR805772 1 0.000 0.988 1.00 0.00 0
#> SRR805773 1 0.000 0.988 1.00 0.00 0
#> SRR805774 1 0.000 0.988 1.00 0.00 0
#> SRR805775 1 0.000 0.988 1.00 0.00 0
#> SRR805776 1 0.000 0.988 1.00 0.00 0
#> SRR805777 1 0.000 0.988 1.00 0.00 0
#> SRR805778 1 0.000 0.988 1.00 0.00 0
#> SRR805779 1 0.000 0.988 1.00 0.00 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.0000 0.499 0.000 1.000 0.00 0.000
#> SRR805726 2 0.0000 0.499 0.000 1.000 0.00 0.000
#> SRR805727 2 0.0000 0.499 0.000 1.000 0.00 0.000
#> SRR805728 2 0.0000 0.499 0.000 1.000 0.00 0.000
#> SRR805729 2 0.0000 0.499 0.000 1.000 0.00 0.000
#> SRR805730 3 0.4907 0.579 0.000 0.420 0.58 0.000
#> SRR805731 3 0.0000 0.927 0.000 0.000 1.00 0.000
#> SRR805732 3 0.0000 0.927 0.000 0.000 1.00 0.000
#> SRR805733 3 0.0000 0.927 0.000 0.000 1.00 0.000
#> SRR805735 2 0.0000 0.499 0.000 1.000 0.00 0.000
#> SRR805736 2 0.4907 0.442 0.000 0.580 0.00 0.420
#> SRR805737 2 0.4907 0.442 0.000 0.580 0.00 0.420
#> SRR805738 2 0.4907 0.442 0.000 0.580 0.00 0.420
#> SRR805739 2 0.4907 0.442 0.000 0.580 0.00 0.420
#> SRR805740 2 0.4907 0.442 0.000 0.580 0.00 0.420
#> SRR805741 2 0.4907 0.442 0.000 0.580 0.00 0.420
#> SRR805742 2 0.4907 0.442 0.000 0.580 0.00 0.420
#> SRR805743 2 0.0000 0.499 0.000 1.000 0.00 0.000
#> SRR805744 2 0.4907 0.442 0.000 0.580 0.00 0.420
#> SRR805745 2 0.4907 0.442 0.000 0.580 0.00 0.420
#> SRR805746 2 0.4907 0.442 0.000 0.580 0.00 0.420
#> SRR805747 4 0.3356 0.731 0.000 0.176 0.00 0.824
#> SRR805748 4 0.3356 0.731 0.000 0.176 0.00 0.824
#> SRR805749 4 0.0188 0.584 0.004 0.000 0.00 0.996
#> SRR805750 4 0.3356 0.731 0.000 0.176 0.00 0.824
#> SRR805751 2 0.4888 -0.106 0.000 0.588 0.00 0.412
#> SRR805752 3 0.0000 0.927 0.000 0.000 1.00 0.000
#> SRR805753 3 0.0000 0.927 0.000 0.000 1.00 0.000
#> SRR805754 4 0.3356 0.731 0.000 0.176 0.00 0.824
#> SRR805755 4 0.3356 0.731 0.000 0.176 0.00 0.824
#> SRR805756 4 0.3356 0.731 0.000 0.176 0.00 0.824
#> SRR805757 4 0.3356 0.731 0.000 0.176 0.00 0.824
#> SRR805758 1 0.3356 0.871 0.824 0.000 0.00 0.176
#> SRR805759 1 0.3356 0.871 0.824 0.000 0.00 0.176
#> SRR805760 1 0.3356 0.871 0.824 0.000 0.00 0.176
#> SRR805761 1 0.3356 0.871 0.824 0.000 0.00 0.176
#> SRR805762 1 0.3356 0.871 0.824 0.000 0.00 0.176
#> SRR805763 4 0.4522 0.198 0.000 0.320 0.00 0.680
#> SRR805764 2 0.4907 0.442 0.000 0.580 0.00 0.420
#> SRR805765 4 0.5000 -0.317 0.000 0.500 0.00 0.500
#> SRR805766 4 0.4522 0.198 0.000 0.320 0.00 0.680
#> SRR805767 4 0.1557 0.589 0.000 0.056 0.00 0.944
#> SRR805768 1 0.3356 0.871 0.824 0.000 0.00 0.176
#> SRR805769 1 0.0000 0.932 1.000 0.000 0.00 0.000
#> SRR805770 1 0.0000 0.932 1.000 0.000 0.00 0.000
#> SRR805771 1 0.0000 0.932 1.000 0.000 0.00 0.000
#> SRR805772 1 0.0000 0.932 1.000 0.000 0.00 0.000
#> SRR805773 1 0.0000 0.932 1.000 0.000 0.00 0.000
#> SRR805774 1 0.0000 0.932 1.000 0.000 0.00 0.000
#> SRR805775 1 0.0000 0.932 1.000 0.000 0.00 0.000
#> SRR805776 1 0.0000 0.932 1.000 0.000 0.00 0.000
#> SRR805777 1 0.0000 0.932 1.000 0.000 0.00 0.000
#> SRR805778 1 0.0000 0.932 1.000 0.000 0.00 0.000
#> SRR805779 1 0.0000 0.932 1.000 0.000 0.00 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 5 0.0000 0.5390 0 0.00 0.000 0.000 1.000
#> SRR805726 5 0.0000 0.5390 0 0.00 0.000 0.000 1.000
#> SRR805727 5 0.0000 0.5390 0 0.00 0.000 0.000 1.000
#> SRR805728 5 0.0000 0.5390 0 0.00 0.000 0.000 1.000
#> SRR805729 5 0.0000 0.5390 0 0.00 0.000 0.000 1.000
#> SRR805730 2 0.4302 0.4798 0 0.52 0.000 0.000 0.480
#> SRR805731 2 0.0000 0.9027 0 1.00 0.000 0.000 0.000
#> SRR805732 2 0.0000 0.9027 0 1.00 0.000 0.000 0.000
#> SRR805733 2 0.0000 0.9027 0 1.00 0.000 0.000 0.000
#> SRR805735 5 0.0000 0.5390 0 0.00 0.000 0.000 1.000
#> SRR805736 5 0.4302 0.6183 0 0.00 0.000 0.480 0.520
#> SRR805737 5 0.4302 0.6183 0 0.00 0.000 0.480 0.520
#> SRR805738 5 0.4302 0.6183 0 0.00 0.000 0.480 0.520
#> SRR805739 5 0.4302 0.6183 0 0.00 0.000 0.480 0.520
#> SRR805740 5 0.4302 0.6183 0 0.00 0.000 0.480 0.520
#> SRR805741 5 0.4302 0.6183 0 0.00 0.000 0.480 0.520
#> SRR805742 5 0.4302 0.6183 0 0.00 0.000 0.480 0.520
#> SRR805743 5 0.0000 0.5390 0 0.00 0.000 0.000 1.000
#> SRR805744 5 0.4302 0.6183 0 0.00 0.000 0.480 0.520
#> SRR805745 5 0.4302 0.6183 0 0.00 0.000 0.480 0.520
#> SRR805746 5 0.4302 0.6183 0 0.00 0.000 0.480 0.520
#> SRR805747 4 0.0000 0.7420 0 0.00 0.000 1.000 0.000
#> SRR805748 4 0.0000 0.7420 0 0.00 0.000 1.000 0.000
#> SRR805749 4 0.4302 -0.1471 0 0.00 0.480 0.520 0.000
#> SRR805750 4 0.0000 0.7420 0 0.00 0.000 1.000 0.000
#> SRR805751 4 0.4297 0.1323 0 0.00 0.000 0.528 0.472
#> SRR805752 2 0.0000 0.9027 0 1.00 0.000 0.000 0.000
#> SRR805753 2 0.0000 0.9027 0 1.00 0.000 0.000 0.000
#> SRR805754 4 0.0000 0.7420 0 0.00 0.000 1.000 0.000
#> SRR805755 4 0.0000 0.7420 0 0.00 0.000 1.000 0.000
#> SRR805756 4 0.0000 0.7420 0 0.00 0.000 1.000 0.000
#> SRR805757 4 0.0000 0.7420 0 0.00 0.000 1.000 0.000
#> SRR805758 3 0.0000 0.9076 0 0.00 1.000 0.000 0.000
#> SRR805759 3 0.0000 0.9076 0 0.00 1.000 0.000 0.000
#> SRR805760 3 0.0000 0.9076 0 0.00 1.000 0.000 0.000
#> SRR805761 3 0.0000 0.9076 0 0.00 1.000 0.000 0.000
#> SRR805762 3 0.0000 0.9076 0 0.00 1.000 0.000 0.000
#> SRR805763 3 0.0963 0.8725 0 0.00 0.964 0.036 0.000
#> SRR805764 5 0.4302 0.6183 0 0.00 0.000 0.480 0.520
#> SRR805765 4 0.6442 -0.3132 0 0.00 0.196 0.480 0.324
#> SRR805766 3 0.4735 -0.0906 0 0.00 0.524 0.460 0.016
#> SRR805767 3 0.0000 0.9076 0 0.00 1.000 0.000 0.000
#> SRR805768 3 0.0000 0.9076 0 0.00 1.000 0.000 0.000
#> SRR805769 1 0.0000 1.0000 1 0.00 0.000 0.000 0.000
#> SRR805770 1 0.0000 1.0000 1 0.00 0.000 0.000 0.000
#> SRR805771 1 0.0000 1.0000 1 0.00 0.000 0.000 0.000
#> SRR805772 1 0.0000 1.0000 1 0.00 0.000 0.000 0.000
#> SRR805773 1 0.0000 1.0000 1 0.00 0.000 0.000 0.000
#> SRR805774 1 0.0000 1.0000 1 0.00 0.000 0.000 0.000
#> SRR805775 1 0.0000 1.0000 1 0.00 0.000 0.000 0.000
#> SRR805776 1 0.0000 1.0000 1 0.00 0.000 0.000 0.000
#> SRR805777 1 0.0000 1.0000 1 0.00 0.000 0.000 0.000
#> SRR805778 1 0.0000 1.0000 1 0.00 0.000 0.000 0.000
#> SRR805779 1 0.0000 1.0000 1 0.00 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0.0000 0.966 0 1.000 0.000 0.000 0.000 0
#> SRR805726 2 0.0000 0.966 0 1.000 0.000 0.000 0.000 0
#> SRR805727 2 0.0000 0.966 0 1.000 0.000 0.000 0.000 0
#> SRR805728 2 0.0000 0.966 0 1.000 0.000 0.000 0.000 0
#> SRR805729 2 0.0000 0.966 0 1.000 0.000 0.000 0.000 0
#> SRR805730 2 0.0000 0.966 0 1.000 0.000 0.000 0.000 0
#> SRR805731 6 0.0000 1.000 0 0.000 0.000 0.000 0.000 1
#> SRR805732 6 0.0000 1.000 0 0.000 0.000 0.000 0.000 1
#> SRR805733 6 0.0000 1.000 0 0.000 0.000 0.000 0.000 1
#> SRR805735 2 0.0000 0.966 0 1.000 0.000 0.000 0.000 0
#> SRR805736 5 0.0000 1.000 0 0.000 0.000 0.000 1.000 0
#> SRR805737 5 0.0000 1.000 0 0.000 0.000 0.000 1.000 0
#> SRR805738 5 0.0000 1.000 0 0.000 0.000 0.000 1.000 0
#> SRR805739 5 0.0000 1.000 0 0.000 0.000 0.000 1.000 0
#> SRR805740 5 0.0000 1.000 0 0.000 0.000 0.000 1.000 0
#> SRR805741 5 0.0000 1.000 0 0.000 0.000 0.000 1.000 0
#> SRR805742 5 0.0000 1.000 0 0.000 0.000 0.000 1.000 0
#> SRR805743 2 0.2697 0.747 0 0.812 0.000 0.000 0.188 0
#> SRR805744 5 0.0000 1.000 0 0.000 0.000 0.000 1.000 0
#> SRR805745 5 0.0000 1.000 0 0.000 0.000 0.000 1.000 0
#> SRR805746 5 0.0000 1.000 0 0.000 0.000 0.000 1.000 0
#> SRR805747 4 0.0000 1.000 0 0.000 0.000 1.000 0.000 0
#> SRR805748 4 0.0000 1.000 0 0.000 0.000 1.000 0.000 0
#> SRR805749 4 0.0000 1.000 0 0.000 0.000 1.000 0.000 0
#> SRR805750 4 0.0000 1.000 0 0.000 0.000 1.000 0.000 0
#> SRR805751 4 0.0000 1.000 0 0.000 0.000 1.000 0.000 0
#> SRR805752 6 0.0000 1.000 0 0.000 0.000 0.000 0.000 1
#> SRR805753 6 0.0000 1.000 0 0.000 0.000 0.000 0.000 1
#> SRR805754 4 0.0000 1.000 0 0.000 0.000 1.000 0.000 0
#> SRR805755 4 0.0000 1.000 0 0.000 0.000 1.000 0.000 0
#> SRR805756 4 0.0000 1.000 0 0.000 0.000 1.000 0.000 0
#> SRR805757 4 0.0000 1.000 0 0.000 0.000 1.000 0.000 0
#> SRR805758 3 0.0000 0.927 0 0.000 1.000 0.000 0.000 0
#> SRR805759 3 0.0000 0.927 0 0.000 1.000 0.000 0.000 0
#> SRR805760 3 0.0000 0.927 0 0.000 1.000 0.000 0.000 0
#> SRR805761 3 0.0000 0.927 0 0.000 1.000 0.000 0.000 0
#> SRR805762 3 0.0000 0.927 0 0.000 1.000 0.000 0.000 0
#> SRR805763 3 0.0260 0.920 0 0.000 0.992 0.000 0.008 0
#> SRR805764 5 0.0000 1.000 0 0.000 0.000 0.000 1.000 0
#> SRR805765 5 0.0146 0.996 0 0.000 0.004 0.000 0.996 0
#> SRR805766 3 0.5132 0.182 0 0.000 0.500 0.084 0.416 0
#> SRR805767 3 0.0000 0.927 0 0.000 1.000 0.000 0.000 0
#> SRR805768 3 0.0000 0.927 0 0.000 1.000 0.000 0.000 0
#> SRR805769 1 0.0000 1.000 1 0.000 0.000 0.000 0.000 0
#> SRR805770 1 0.0000 1.000 1 0.000 0.000 0.000 0.000 0
#> SRR805771 1 0.0000 1.000 1 0.000 0.000 0.000 0.000 0
#> SRR805772 1 0.0000 1.000 1 0.000 0.000 0.000 0.000 0
#> SRR805773 1 0.0000 1.000 1 0.000 0.000 0.000 0.000 0
#> SRR805774 1 0.0000 1.000 1 0.000 0.000 0.000 0.000 0
#> SRR805775 1 0.0000 1.000 1 0.000 0.000 0.000 0.000 0
#> SRR805776 1 0.0000 1.000 1 0.000 0.000 0.000 0.000 0
#> SRR805777 1 0.0000 1.000 1 0.000 0.000 0.000 0.000 0
#> SRR805778 1 0.0000 1.000 1 0.000 0.000 0.000 0.000 0
#> SRR805779 1 0.0000 1.000 1 0.000 0.000 0.000 0.000 0
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "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 14939 rows and 54 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.762 0.948 0.944 0.4727 0.525 0.525
#> 3 3 1.000 0.985 0.987 0.3754 0.671 0.452
#> 4 4 0.737 0.825 0.851 0.1016 0.748 0.425
#> 5 5 0.805 0.852 0.916 0.0928 0.910 0.690
#> 6 6 0.929 0.903 0.905 0.0611 0.935 0.704
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
There is also optional best \(k\) = 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
#> SRR805725 2 0.4298 0.927 0.088 0.912
#> SRR805726 2 0.4022 0.931 0.080 0.920
#> SRR805727 2 0.4022 0.931 0.080 0.920
#> SRR805728 2 0.4022 0.931 0.080 0.920
#> SRR805729 2 0.4022 0.931 0.080 0.920
#> SRR805730 2 0.5946 0.897 0.144 0.856
#> SRR805731 2 0.5946 0.897 0.144 0.856
#> SRR805732 2 0.5946 0.897 0.144 0.856
#> SRR805733 2 0.5946 0.897 0.144 0.856
#> SRR805735 2 0.5408 0.907 0.124 0.876
#> SRR805736 2 0.0672 0.952 0.008 0.992
#> SRR805737 2 0.0000 0.950 0.000 1.000
#> SRR805738 2 0.0000 0.950 0.000 1.000
#> SRR805739 2 0.0376 0.950 0.004 0.996
#> SRR805740 2 0.0000 0.950 0.000 1.000
#> SRR805741 2 0.0000 0.950 0.000 1.000
#> SRR805742 2 0.0000 0.950 0.000 1.000
#> SRR805743 2 0.0000 0.950 0.000 1.000
#> SRR805744 2 0.0000 0.950 0.000 1.000
#> SRR805745 2 0.0000 0.950 0.000 1.000
#> SRR805746 2 0.0000 0.950 0.000 1.000
#> SRR805747 1 0.3431 0.964 0.936 0.064
#> SRR805748 1 0.3431 0.964 0.936 0.064
#> SRR805749 1 0.3431 0.964 0.936 0.064
#> SRR805750 1 0.3431 0.964 0.936 0.064
#> SRR805751 1 0.3431 0.964 0.936 0.064
#> SRR805752 2 0.5946 0.897 0.144 0.856
#> SRR805753 2 0.5946 0.897 0.144 0.856
#> SRR805754 1 0.3431 0.964 0.936 0.064
#> SRR805755 1 0.3431 0.964 0.936 0.064
#> SRR805756 1 0.3431 0.964 0.936 0.064
#> SRR805757 1 0.3431 0.964 0.936 0.064
#> SRR805758 1 0.1184 0.969 0.984 0.016
#> SRR805759 1 0.0376 0.970 0.996 0.004
#> SRR805760 1 0.0376 0.970 0.996 0.004
#> SRR805761 1 0.0376 0.970 0.996 0.004
#> SRR805762 1 0.0376 0.970 0.996 0.004
#> SRR805763 1 0.0376 0.970 0.996 0.004
#> SRR805764 1 0.0376 0.970 0.996 0.004
#> SRR805765 1 0.0376 0.970 0.996 0.004
#> SRR805766 1 0.0376 0.970 0.996 0.004
#> SRR805767 1 0.0376 0.970 0.996 0.004
#> SRR805768 1 0.0376 0.970 0.996 0.004
#> SRR805769 2 0.1414 0.952 0.020 0.980
#> SRR805770 2 0.2423 0.949 0.040 0.960
#> SRR805771 2 0.2423 0.949 0.040 0.960
#> SRR805772 2 0.1414 0.952 0.020 0.980
#> SRR805773 2 0.1184 0.952 0.016 0.984
#> SRR805774 2 0.1414 0.952 0.020 0.980
#> SRR805775 2 0.2423 0.949 0.040 0.960
#> SRR805776 2 0.2423 0.949 0.040 0.960
#> SRR805777 2 0.2423 0.949 0.040 0.960
#> SRR805778 2 0.2423 0.949 0.040 0.960
#> SRR805779 2 0.2423 0.949 0.040 0.960
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.1289 0.973 0.032 0.968 0.000
#> SRR805726 2 0.2261 0.947 0.068 0.932 0.000
#> SRR805727 2 0.1753 0.964 0.048 0.952 0.000
#> SRR805728 2 0.2066 0.955 0.060 0.940 0.000
#> SRR805729 2 0.2066 0.955 0.060 0.940 0.000
#> SRR805730 2 0.1525 0.973 0.032 0.964 0.004
#> SRR805731 2 0.1525 0.973 0.032 0.964 0.004
#> SRR805732 2 0.1525 0.973 0.032 0.964 0.004
#> SRR805733 2 0.1525 0.973 0.032 0.964 0.004
#> SRR805735 2 0.1289 0.973 0.032 0.968 0.000
#> SRR805736 1 0.0237 0.996 0.996 0.004 0.000
#> SRR805737 1 0.0237 0.996 0.996 0.004 0.000
#> SRR805738 1 0.0237 0.996 0.996 0.004 0.000
#> SRR805739 1 0.0237 0.996 0.996 0.004 0.000
#> SRR805740 1 0.0237 0.996 0.996 0.004 0.000
#> SRR805741 1 0.0237 0.996 0.996 0.004 0.000
#> SRR805742 1 0.0237 0.996 0.996 0.004 0.000
#> SRR805743 1 0.0237 0.996 0.996 0.004 0.000
#> SRR805744 1 0.0237 0.996 0.996 0.004 0.000
#> SRR805745 1 0.0237 0.996 0.996 0.004 0.000
#> SRR805746 1 0.0237 0.996 0.996 0.004 0.000
#> SRR805747 2 0.0475 0.969 0.004 0.992 0.004
#> SRR805748 2 0.0475 0.969 0.004 0.992 0.004
#> SRR805749 2 0.0475 0.969 0.004 0.992 0.004
#> SRR805750 2 0.0475 0.969 0.004 0.992 0.004
#> SRR805751 2 0.0475 0.969 0.004 0.992 0.004
#> SRR805752 2 0.1525 0.973 0.032 0.964 0.004
#> SRR805753 2 0.1525 0.973 0.032 0.964 0.004
#> SRR805754 2 0.0475 0.969 0.004 0.992 0.004
#> SRR805755 2 0.0475 0.969 0.004 0.992 0.004
#> SRR805756 2 0.0475 0.969 0.004 0.992 0.004
#> SRR805757 2 0.0475 0.969 0.004 0.992 0.004
#> SRR805758 3 0.0000 0.998 0.000 0.000 1.000
#> SRR805759 3 0.0000 0.998 0.000 0.000 1.000
#> SRR805760 3 0.0000 0.998 0.000 0.000 1.000
#> SRR805761 3 0.0000 0.998 0.000 0.000 1.000
#> SRR805762 3 0.0000 0.998 0.000 0.000 1.000
#> SRR805763 3 0.0237 0.998 0.000 0.004 0.996
#> SRR805764 3 0.0237 0.998 0.000 0.004 0.996
#> SRR805765 3 0.0237 0.998 0.000 0.004 0.996
#> SRR805766 3 0.0237 0.998 0.000 0.004 0.996
#> SRR805767 3 0.0237 0.998 0.000 0.004 0.996
#> SRR805768 3 0.0000 0.998 0.000 0.000 1.000
#> SRR805769 1 0.0000 0.996 1.000 0.000 0.000
#> SRR805770 1 0.0000 0.996 1.000 0.000 0.000
#> SRR805771 1 0.0000 0.996 1.000 0.000 0.000
#> SRR805772 1 0.0000 0.996 1.000 0.000 0.000
#> SRR805773 1 0.1031 0.972 0.976 0.024 0.000
#> SRR805774 1 0.0000 0.996 1.000 0.000 0.000
#> SRR805775 1 0.0000 0.996 1.000 0.000 0.000
#> SRR805776 1 0.0000 0.996 1.000 0.000 0.000
#> SRR805777 1 0.0000 0.996 1.000 0.000 0.000
#> SRR805778 1 0.0000 0.996 1.000 0.000 0.000
#> SRR805779 1 0.0000 0.996 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 2 0.3234 0.673 0.012 0.884 0.020 0.084
#> SRR805726 2 0.4692 0.662 0.012 0.772 0.020 0.196
#> SRR805727 2 0.3234 0.673 0.012 0.884 0.020 0.084
#> SRR805728 2 0.3234 0.673 0.012 0.884 0.020 0.084
#> SRR805729 2 0.3234 0.673 0.012 0.884 0.020 0.084
#> SRR805730 2 0.0707 0.694 0.000 0.980 0.020 0.000
#> SRR805731 2 0.0707 0.694 0.000 0.980 0.020 0.000
#> SRR805732 2 0.0000 0.692 0.000 1.000 0.000 0.000
#> SRR805733 2 0.0000 0.692 0.000 1.000 0.000 0.000
#> SRR805735 2 0.3572 0.670 0.024 0.872 0.020 0.084
#> SRR805736 2 0.5069 0.611 0.000 0.664 0.016 0.320
#> SRR805737 2 0.4916 0.570 0.000 0.576 0.000 0.424
#> SRR805738 2 0.4916 0.570 0.000 0.576 0.000 0.424
#> SRR805739 2 0.4916 0.570 0.000 0.576 0.000 0.424
#> SRR805740 2 0.4916 0.570 0.000 0.576 0.000 0.424
#> SRR805741 2 0.4916 0.570 0.000 0.576 0.000 0.424
#> SRR805742 2 0.4916 0.570 0.000 0.576 0.000 0.424
#> SRR805743 2 0.4916 0.570 0.000 0.576 0.000 0.424
#> SRR805744 2 0.4916 0.570 0.000 0.576 0.000 0.424
#> SRR805745 2 0.4916 0.570 0.000 0.576 0.000 0.424
#> SRR805746 2 0.4916 0.570 0.000 0.576 0.000 0.424
#> SRR805747 4 0.4916 0.999 0.424 0.000 0.000 0.576
#> SRR805748 4 0.4916 0.999 0.424 0.000 0.000 0.576
#> SRR805749 4 0.4916 0.999 0.424 0.000 0.000 0.576
#> SRR805750 4 0.4916 0.999 0.424 0.000 0.000 0.576
#> SRR805751 4 0.4916 0.999 0.424 0.000 0.000 0.576
#> SRR805752 2 0.0000 0.692 0.000 1.000 0.000 0.000
#> SRR805753 2 0.0000 0.692 0.000 1.000 0.000 0.000
#> SRR805754 4 0.4916 0.999 0.424 0.000 0.000 0.576
#> SRR805755 4 0.4916 0.999 0.424 0.000 0.000 0.576
#> SRR805756 4 0.5080 0.994 0.420 0.000 0.004 0.576
#> SRR805757 4 0.4916 0.999 0.424 0.000 0.000 0.576
#> SRR805758 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805759 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805760 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805761 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805762 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805763 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805764 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805765 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805766 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805767 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805768 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805769 1 0.7204 0.933 0.504 0.084 0.020 0.392
#> SRR805770 1 0.5465 0.899 0.588 0.000 0.020 0.392
#> SRR805771 1 0.5465 0.899 0.588 0.000 0.020 0.392
#> SRR805772 1 0.7204 0.933 0.504 0.084 0.020 0.392
#> SRR805773 1 0.7632 0.884 0.504 0.132 0.020 0.344
#> SRR805774 1 0.7204 0.933 0.504 0.084 0.020 0.392
#> SRR805775 1 0.6124 0.899 0.556 0.020 0.020 0.404
#> SRR805776 1 0.7460 0.898 0.472 0.104 0.020 0.404
#> SRR805777 1 0.7204 0.933 0.504 0.084 0.020 0.392
#> SRR805778 1 0.5465 0.899 0.588 0.000 0.020 0.392
#> SRR805779 1 0.7204 0.933 0.504 0.084 0.020 0.392
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 5 0.3814 0.7146 0.000 0.276 0 0.004 0.720
#> SRR805726 5 0.3814 0.7146 0.000 0.276 0 0.004 0.720
#> SRR805727 5 0.3814 0.7146 0.000 0.276 0 0.004 0.720
#> SRR805728 5 0.3814 0.7146 0.000 0.276 0 0.004 0.720
#> SRR805729 5 0.3814 0.7146 0.000 0.276 0 0.004 0.720
#> SRR805730 2 0.1121 0.9512 0.000 0.956 0 0.000 0.044
#> SRR805731 2 0.1121 0.9512 0.000 0.956 0 0.000 0.044
#> SRR805732 2 0.0000 0.9758 0.000 1.000 0 0.000 0.000
#> SRR805733 2 0.0000 0.9758 0.000 1.000 0 0.000 0.000
#> SRR805735 5 0.3814 0.7146 0.000 0.276 0 0.004 0.720
#> SRR805736 5 0.0912 0.8180 0.016 0.012 0 0.000 0.972
#> SRR805737 5 0.0000 0.8268 0.000 0.000 0 0.000 1.000
#> SRR805738 5 0.0000 0.8268 0.000 0.000 0 0.000 1.000
#> SRR805739 5 0.2951 0.7128 0.028 0.112 0 0.000 0.860
#> SRR805740 5 0.0000 0.8268 0.000 0.000 0 0.000 1.000
#> SRR805741 5 0.0000 0.8268 0.000 0.000 0 0.000 1.000
#> SRR805742 5 0.0000 0.8268 0.000 0.000 0 0.000 1.000
#> SRR805743 5 0.0000 0.8268 0.000 0.000 0 0.000 1.000
#> SRR805744 5 0.0000 0.8268 0.000 0.000 0 0.000 1.000
#> SRR805745 5 0.0000 0.8268 0.000 0.000 0 0.000 1.000
#> SRR805746 5 0.0000 0.8268 0.000 0.000 0 0.000 1.000
#> SRR805747 4 0.0000 1.0000 0.000 0.000 0 1.000 0.000
#> SRR805748 4 0.0000 1.0000 0.000 0.000 0 1.000 0.000
#> SRR805749 4 0.0000 1.0000 0.000 0.000 0 1.000 0.000
#> SRR805750 4 0.0000 1.0000 0.000 0.000 0 1.000 0.000
#> SRR805751 4 0.0000 1.0000 0.000 0.000 0 1.000 0.000
#> SRR805752 2 0.0000 0.9758 0.000 1.000 0 0.000 0.000
#> SRR805753 2 0.0000 0.9758 0.000 1.000 0 0.000 0.000
#> SRR805754 4 0.0000 1.0000 0.000 0.000 0 1.000 0.000
#> SRR805755 4 0.0000 1.0000 0.000 0.000 0 1.000 0.000
#> SRR805756 4 0.0000 1.0000 0.000 0.000 0 1.000 0.000
#> SRR805757 4 0.0000 1.0000 0.000 0.000 0 1.000 0.000
#> SRR805758 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> SRR805759 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> SRR805760 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> SRR805761 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> SRR805762 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> SRR805763 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> SRR805764 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> SRR805765 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> SRR805766 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> SRR805767 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> SRR805768 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> SRR805769 1 0.3366 0.8027 0.768 0.000 0 0.000 0.232
#> SRR805770 1 0.2179 0.6420 0.888 0.112 0 0.000 0.000
#> SRR805771 1 0.2179 0.6420 0.888 0.112 0 0.000 0.000
#> SRR805772 1 0.3366 0.8027 0.768 0.000 0 0.000 0.232
#> SRR805773 1 0.3861 0.7669 0.728 0.008 0 0.000 0.264
#> SRR805774 1 0.3366 0.8027 0.768 0.000 0 0.000 0.232
#> SRR805775 1 0.4150 0.1986 0.612 0.000 0 0.000 0.388
#> SRR805776 5 0.4283 0.0431 0.456 0.000 0 0.000 0.544
#> SRR805777 1 0.3366 0.8027 0.768 0.000 0 0.000 0.232
#> SRR805778 1 0.2179 0.6420 0.888 0.112 0 0.000 0.000
#> SRR805779 1 0.3366 0.8027 0.768 0.000 0 0.000 0.232
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0.4827 0.999 0.000 0.632 0.000 0 0.276 0.092
#> SRR805726 2 0.4827 0.999 0.000 0.632 0.000 0 0.276 0.092
#> SRR805727 2 0.4827 0.999 0.000 0.632 0.000 0 0.276 0.092
#> SRR805728 2 0.4827 0.999 0.000 0.632 0.000 0 0.276 0.092
#> SRR805729 2 0.4827 0.999 0.000 0.632 0.000 0 0.276 0.092
#> SRR805730 6 0.1007 0.940 0.000 0.000 0.000 0 0.044 0.956
#> SRR805731 6 0.0547 0.969 0.000 0.000 0.000 0 0.020 0.980
#> SRR805732 6 0.0000 0.982 0.000 0.000 0.000 0 0.000 1.000
#> SRR805733 6 0.0000 0.982 0.000 0.000 0.000 0 0.000 1.000
#> SRR805735 2 0.4869 0.995 0.000 0.628 0.000 0 0.276 0.096
#> SRR805736 5 0.5791 -0.203 0.180 0.380 0.000 0 0.440 0.000
#> SRR805737 5 0.0000 0.869 0.000 0.000 0.000 0 1.000 0.000
#> SRR805738 5 0.0000 0.869 0.000 0.000 0.000 0 1.000 0.000
#> SRR805739 5 0.4845 0.363 0.280 0.092 0.000 0 0.628 0.000
#> SRR805740 5 0.0000 0.869 0.000 0.000 0.000 0 1.000 0.000
#> SRR805741 5 0.0000 0.869 0.000 0.000 0.000 0 1.000 0.000
#> SRR805742 5 0.0000 0.869 0.000 0.000 0.000 0 1.000 0.000
#> SRR805743 5 0.0000 0.869 0.000 0.000 0.000 0 1.000 0.000
#> SRR805744 5 0.0000 0.869 0.000 0.000 0.000 0 1.000 0.000
#> SRR805745 5 0.0146 0.865 0.004 0.000 0.000 0 0.996 0.000
#> SRR805746 5 0.0000 0.869 0.000 0.000 0.000 0 1.000 0.000
#> SRR805747 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> SRR805748 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> SRR805749 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> SRR805750 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> SRR805751 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> SRR805752 6 0.0000 0.982 0.000 0.000 0.000 0 0.000 1.000
#> SRR805753 6 0.0000 0.982 0.000 0.000 0.000 0 0.000 1.000
#> SRR805754 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> SRR805755 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> SRR805756 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> SRR805757 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> SRR805758 3 0.0000 0.980 0.000 0.000 1.000 0 0.000 0.000
#> SRR805759 3 0.0000 0.980 0.000 0.000 1.000 0 0.000 0.000
#> SRR805760 3 0.0000 0.980 0.000 0.000 1.000 0 0.000 0.000
#> SRR805761 3 0.0000 0.980 0.000 0.000 1.000 0 0.000 0.000
#> SRR805762 3 0.0000 0.980 0.000 0.000 1.000 0 0.000 0.000
#> SRR805763 3 0.1075 0.976 0.000 0.048 0.952 0 0.000 0.000
#> SRR805764 3 0.1075 0.976 0.000 0.048 0.952 0 0.000 0.000
#> SRR805765 3 0.1075 0.976 0.000 0.048 0.952 0 0.000 0.000
#> SRR805766 3 0.1075 0.976 0.000 0.048 0.952 0 0.000 0.000
#> SRR805767 3 0.1075 0.976 0.000 0.048 0.952 0 0.000 0.000
#> SRR805768 3 0.0000 0.980 0.000 0.000 1.000 0 0.000 0.000
#> SRR805769 1 0.3499 0.854 0.680 0.320 0.000 0 0.000 0.000
#> SRR805770 1 0.0000 0.824 1.000 0.000 0.000 0 0.000 0.000
#> SRR805771 1 0.0000 0.824 1.000 0.000 0.000 0 0.000 0.000
#> SRR805772 1 0.3499 0.854 0.680 0.320 0.000 0 0.000 0.000
#> SRR805773 1 0.4673 0.811 0.648 0.272 0.000 0 0.080 0.000
#> SRR805774 1 0.3499 0.854 0.680 0.320 0.000 0 0.000 0.000
#> SRR805775 1 0.0000 0.824 1.000 0.000 0.000 0 0.000 0.000
#> SRR805776 1 0.1075 0.812 0.952 0.000 0.000 0 0.048 0.000
#> SRR805777 1 0.3499 0.854 0.680 0.320 0.000 0 0.000 0.000
#> SRR805778 1 0.0000 0.824 1.000 0.000 0.000 0 0.000 0.000
#> SRR805779 1 0.3499 0.854 0.680 0.320 0.000 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 14939 rows and 54 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 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.996 0.998 0.2855 0.717 0.717
#> 3 3 0.935 0.907 0.953 1.1307 0.588 0.460
#> 4 4 0.780 0.857 0.922 0.1939 0.823 0.579
#> 5 5 0.868 0.883 0.893 0.0989 0.891 0.615
#> 6 6 0.911 0.894 0.911 0.0375 0.964 0.812
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 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
#> SRR805725 1 0.3879 0.918 0.924 0.076
#> SRR805726 1 0.0000 0.998 1.000 0.000
#> SRR805727 1 0.0672 0.991 0.992 0.008
#> SRR805728 2 0.0672 0.992 0.008 0.992
#> SRR805729 1 0.0000 0.998 1.000 0.000
#> SRR805730 2 0.0000 0.998 0.000 1.000
#> SRR805731 2 0.0000 0.998 0.000 1.000
#> SRR805732 2 0.0000 0.998 0.000 1.000
#> SRR805733 2 0.0000 0.998 0.000 1.000
#> SRR805735 2 0.0000 0.998 0.000 1.000
#> SRR805736 1 0.0000 0.998 1.000 0.000
#> SRR805737 1 0.0000 0.998 1.000 0.000
#> SRR805738 1 0.0000 0.998 1.000 0.000
#> SRR805739 1 0.0000 0.998 1.000 0.000
#> SRR805740 1 0.0000 0.998 1.000 0.000
#> SRR805741 1 0.0000 0.998 1.000 0.000
#> SRR805742 1 0.0000 0.998 1.000 0.000
#> SRR805743 2 0.0376 0.996 0.004 0.996
#> SRR805744 1 0.0000 0.998 1.000 0.000
#> SRR805745 1 0.0000 0.998 1.000 0.000
#> SRR805746 1 0.0000 0.998 1.000 0.000
#> SRR805747 1 0.0000 0.998 1.000 0.000
#> SRR805748 1 0.0000 0.998 1.000 0.000
#> SRR805749 1 0.0000 0.998 1.000 0.000
#> SRR805750 1 0.0000 0.998 1.000 0.000
#> SRR805751 1 0.0000 0.998 1.000 0.000
#> SRR805752 2 0.0000 0.998 0.000 1.000
#> SRR805753 2 0.0000 0.998 0.000 1.000
#> SRR805754 1 0.0000 0.998 1.000 0.000
#> SRR805755 1 0.0000 0.998 1.000 0.000
#> SRR805756 1 0.0000 0.998 1.000 0.000
#> SRR805757 1 0.0000 0.998 1.000 0.000
#> SRR805758 1 0.0000 0.998 1.000 0.000
#> SRR805759 1 0.0000 0.998 1.000 0.000
#> SRR805760 1 0.0000 0.998 1.000 0.000
#> SRR805761 1 0.0000 0.998 1.000 0.000
#> SRR805762 1 0.0000 0.998 1.000 0.000
#> SRR805763 1 0.0000 0.998 1.000 0.000
#> SRR805764 1 0.0000 0.998 1.000 0.000
#> SRR805765 1 0.0000 0.998 1.000 0.000
#> SRR805766 1 0.0000 0.998 1.000 0.000
#> SRR805767 1 0.0000 0.998 1.000 0.000
#> SRR805768 1 0.0000 0.998 1.000 0.000
#> SRR805769 1 0.0000 0.998 1.000 0.000
#> SRR805770 1 0.0000 0.998 1.000 0.000
#> SRR805771 1 0.0000 0.998 1.000 0.000
#> SRR805772 1 0.0000 0.998 1.000 0.000
#> SRR805773 1 0.0000 0.998 1.000 0.000
#> SRR805774 1 0.0000 0.998 1.000 0.000
#> SRR805775 1 0.0000 0.998 1.000 0.000
#> SRR805776 1 0.0000 0.998 1.000 0.000
#> SRR805777 1 0.0000 0.998 1.000 0.000
#> SRR805778 1 0.0000 0.998 1.000 0.000
#> SRR805779 1 0.0000 0.998 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805725 2 0.1529 0.924 0.040 0.960 0.000
#> SRR805726 2 0.1170 0.936 0.008 0.976 0.016
#> SRR805727 2 0.1585 0.930 0.028 0.964 0.008
#> SRR805728 2 0.6235 0.323 0.436 0.564 0.000
#> SRR805729 2 0.1411 0.938 0.000 0.964 0.036
#> SRR805730 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805731 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805732 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805733 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805735 2 0.4750 0.756 0.216 0.784 0.000
#> SRR805736 2 0.0747 0.932 0.000 0.984 0.016
#> SRR805737 2 0.1964 0.916 0.000 0.944 0.056
#> SRR805738 2 0.1031 0.932 0.000 0.976 0.024
#> SRR805739 3 0.5926 0.459 0.000 0.356 0.644
#> SRR805740 2 0.0424 0.931 0.000 0.992 0.008
#> SRR805741 2 0.1860 0.919 0.000 0.948 0.052
#> SRR805742 2 0.3715 0.839 0.004 0.868 0.128
#> SRR805743 2 0.2356 0.900 0.072 0.928 0.000
#> SRR805744 2 0.1999 0.925 0.012 0.952 0.036
#> SRR805745 2 0.1163 0.931 0.000 0.972 0.028
#> SRR805746 2 0.1163 0.931 0.000 0.972 0.028
#> SRR805747 2 0.1529 0.937 0.000 0.960 0.040
#> SRR805748 2 0.1529 0.937 0.000 0.960 0.040
#> SRR805749 2 0.1753 0.934 0.000 0.952 0.048
#> SRR805750 2 0.1529 0.937 0.000 0.960 0.040
#> SRR805751 2 0.1529 0.937 0.000 0.960 0.040
#> SRR805752 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805753 1 0.0000 1.000 1.000 0.000 0.000
#> SRR805754 2 0.1529 0.937 0.000 0.960 0.040
#> SRR805755 2 0.1643 0.936 0.000 0.956 0.044
#> SRR805756 2 0.1529 0.937 0.000 0.960 0.040
#> SRR805757 2 0.1529 0.937 0.000 0.960 0.040
#> SRR805758 3 0.0000 0.950 0.000 0.000 1.000
#> SRR805759 3 0.0000 0.950 0.000 0.000 1.000
#> SRR805760 3 0.0000 0.950 0.000 0.000 1.000
#> SRR805761 3 0.0000 0.950 0.000 0.000 1.000
#> SRR805762 3 0.0000 0.950 0.000 0.000 1.000
#> SRR805763 3 0.0000 0.950 0.000 0.000 1.000
#> SRR805764 3 0.0424 0.945 0.008 0.000 0.992
#> SRR805765 3 0.0000 0.950 0.000 0.000 1.000
#> SRR805766 3 0.0000 0.950 0.000 0.000 1.000
#> SRR805767 3 0.0000 0.950 0.000 0.000 1.000
#> SRR805768 3 0.0000 0.950 0.000 0.000 1.000
#> SRR805769 3 0.0424 0.945 0.000 0.008 0.992
#> SRR805770 3 0.0237 0.948 0.000 0.004 0.996
#> SRR805771 3 0.0592 0.943 0.000 0.012 0.988
#> SRR805772 3 0.0237 0.947 0.000 0.004 0.996
#> SRR805773 3 0.6140 0.292 0.000 0.404 0.596
#> SRR805774 3 0.1753 0.906 0.000 0.048 0.952
#> SRR805775 3 0.1031 0.933 0.000 0.024 0.976
#> SRR805776 3 0.0592 0.943 0.000 0.012 0.988
#> SRR805777 3 0.0000 0.950 0.000 0.000 1.000
#> SRR805778 3 0.0592 0.943 0.000 0.012 0.988
#> SRR805779 3 0.0000 0.950 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805725 4 0.2714 0.806 0.004 0.112 0.000 0.884
#> SRR805726 4 0.3444 0.747 0.000 0.184 0.000 0.816
#> SRR805727 4 0.4417 0.746 0.044 0.160 0.000 0.796
#> SRR805728 1 0.4188 0.775 0.824 0.112 0.000 0.064
#> SRR805729 4 0.5933 0.085 0.036 0.464 0.000 0.500
#> SRR805730 1 0.0000 0.921 1.000 0.000 0.000 0.000
#> SRR805731 1 0.0000 0.921 1.000 0.000 0.000 0.000
#> SRR805732 1 0.0000 0.921 1.000 0.000 0.000 0.000
#> SRR805733 1 0.0000 0.921 1.000 0.000 0.000 0.000
#> SRR805735 1 0.4679 0.461 0.648 0.000 0.000 0.352
#> SRR805736 2 0.1637 0.968 0.000 0.940 0.000 0.060
#> SRR805737 2 0.1576 0.976 0.000 0.948 0.004 0.048
#> SRR805738 2 0.1474 0.973 0.000 0.948 0.000 0.052
#> SRR805739 2 0.1576 0.920 0.000 0.948 0.048 0.004
#> SRR805740 2 0.1792 0.961 0.000 0.932 0.000 0.068
#> SRR805741 2 0.1576 0.976 0.000 0.948 0.004 0.048
#> SRR805742 2 0.1584 0.966 0.000 0.952 0.012 0.036
#> SRR805743 2 0.3037 0.883 0.100 0.880 0.000 0.020
#> SRR805744 2 0.1576 0.976 0.000 0.948 0.004 0.048
#> SRR805745 2 0.1576 0.976 0.000 0.948 0.004 0.048
#> SRR805746 2 0.1576 0.976 0.000 0.948 0.004 0.048
#> SRR805747 4 0.0188 0.866 0.000 0.004 0.000 0.996
#> SRR805748 4 0.0188 0.866 0.000 0.004 0.000 0.996
#> SRR805749 4 0.0000 0.863 0.000 0.000 0.000 1.000
#> SRR805750 4 0.0188 0.866 0.000 0.004 0.000 0.996
#> SRR805751 4 0.0000 0.863 0.000 0.000 0.000 1.000
#> SRR805752 1 0.0000 0.921 1.000 0.000 0.000 0.000
#> SRR805753 1 0.0000 0.921 1.000 0.000 0.000 0.000
#> SRR805754 4 0.0188 0.866 0.000 0.004 0.000 0.996
#> SRR805755 4 0.0188 0.866 0.000 0.004 0.000 0.996
#> SRR805756 4 0.0188 0.866 0.000 0.004 0.000 0.996
#> SRR805757 4 0.0188 0.866 0.000 0.004 0.000 0.996
#> SRR805758 3 0.0469 0.922 0.000 0.012 0.988 0.000
#> SRR805759 3 0.0000 0.925 0.000 0.000 1.000 0.000
#> SRR805760 3 0.0188 0.924 0.000 0.004 0.996 0.000
#> SRR805761 3 0.0000 0.925 0.000 0.000 1.000 0.000
#> SRR805762 3 0.0188 0.924 0.000 0.004 0.996 0.000
#> SRR805763 3 0.0000 0.925 0.000 0.000 1.000 0.000
#> SRR805764 3 0.0524 0.922 0.008 0.004 0.988 0.000
#> SRR805765 3 0.0188 0.924 0.004 0.000 0.996 0.000
#> SRR805766 3 0.0000 0.925 0.000 0.000 1.000 0.000
#> SRR805767 3 0.0000 0.925 0.000 0.000 1.000 0.000
#> SRR805768 3 0.0000 0.925 0.000 0.000 1.000 0.000
#> SRR805769 3 0.3552 0.875 0.000 0.128 0.848 0.024
#> SRR805770 3 0.1637 0.917 0.000 0.060 0.940 0.000
#> SRR805771 3 0.1557 0.918 0.000 0.056 0.944 0.000
#> SRR805772 3 0.3764 0.802 0.000 0.216 0.784 0.000
#> SRR805773 4 0.6087 0.142 0.000 0.048 0.412 0.540
#> SRR805774 3 0.6267 0.609 0.000 0.112 0.648 0.240
#> SRR805775 3 0.2530 0.895 0.000 0.112 0.888 0.000
#> SRR805776 3 0.3801 0.802 0.000 0.220 0.780 0.000
#> SRR805777 3 0.2704 0.884 0.000 0.124 0.876 0.000
#> SRR805778 3 0.1557 0.918 0.000 0.056 0.944 0.000
#> SRR805779 3 0.3311 0.847 0.000 0.172 0.828 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805725 4 0.7059 0.495 0.004 0.200 0.068 0.572 0.156
#> SRR805726 4 0.5299 0.347 0.000 0.012 0.036 0.588 0.364
#> SRR805727 4 0.8061 0.106 0.004 0.236 0.080 0.360 0.320
#> SRR805728 2 0.1989 0.929 0.000 0.932 0.016 0.020 0.032
#> SRR805729 5 0.7341 0.489 0.016 0.108 0.108 0.192 0.576
#> SRR805730 2 0.0451 0.961 0.000 0.988 0.008 0.000 0.004
#> SRR805731 2 0.0000 0.965 0.000 1.000 0.000 0.000 0.000
#> SRR805732 2 0.0451 0.966 0.008 0.988 0.004 0.000 0.000
#> SRR805733 2 0.0451 0.966 0.008 0.988 0.004 0.000 0.000
#> SRR805735 2 0.3209 0.857 0.000 0.860 0.060 0.076 0.004
#> SRR805736 5 0.2628 0.906 0.000 0.000 0.088 0.028 0.884
#> SRR805737 5 0.1934 0.929 0.008 0.000 0.040 0.020 0.932
#> SRR805738 5 0.1329 0.928 0.008 0.000 0.004 0.032 0.956
#> SRR805739 5 0.2124 0.902 0.004 0.000 0.096 0.000 0.900
#> SRR805740 5 0.1412 0.927 0.008 0.000 0.004 0.036 0.952
#> SRR805741 5 0.1686 0.930 0.008 0.000 0.028 0.020 0.944
#> SRR805742 5 0.1518 0.930 0.012 0.000 0.020 0.016 0.952
#> SRR805743 5 0.2416 0.895 0.008 0.056 0.008 0.016 0.912
#> SRR805744 5 0.1597 0.920 0.024 0.000 0.008 0.020 0.948
#> SRR805745 5 0.2027 0.928 0.008 0.000 0.040 0.024 0.928
#> SRR805746 5 0.1173 0.930 0.012 0.000 0.004 0.020 0.964
#> SRR805747 4 0.0486 0.861 0.004 0.000 0.004 0.988 0.004
#> SRR805748 4 0.0162 0.863 0.000 0.000 0.000 0.996 0.004
#> SRR805749 4 0.0609 0.857 0.000 0.000 0.020 0.980 0.000
#> SRR805750 4 0.0162 0.863 0.000 0.000 0.000 0.996 0.004
#> SRR805751 4 0.0162 0.861 0.000 0.000 0.004 0.996 0.000
#> SRR805752 2 0.0451 0.966 0.008 0.988 0.004 0.000 0.000
#> SRR805753 2 0.0451 0.966 0.008 0.988 0.004 0.000 0.000
#> SRR805754 4 0.0162 0.863 0.000 0.000 0.000 0.996 0.004
#> SRR805755 4 0.0609 0.857 0.000 0.000 0.020 0.980 0.000
#> SRR805756 4 0.0162 0.863 0.000 0.000 0.000 0.996 0.004
#> SRR805757 4 0.0324 0.862 0.000 0.000 0.004 0.992 0.004
#> SRR805758 3 0.3086 0.949 0.180 0.000 0.816 0.004 0.000
#> SRR805759 3 0.2719 0.964 0.144 0.000 0.852 0.000 0.004
#> SRR805760 3 0.2389 0.952 0.116 0.000 0.880 0.000 0.004
#> SRR805761 3 0.3074 0.933 0.196 0.000 0.804 0.000 0.000
#> SRR805762 3 0.2536 0.962 0.128 0.000 0.868 0.000 0.004
#> SRR805763 3 0.2411 0.952 0.108 0.000 0.884 0.000 0.008
#> SRR805764 3 0.2997 0.961 0.148 0.000 0.840 0.000 0.012
#> SRR805765 3 0.3280 0.945 0.184 0.004 0.808 0.000 0.004
#> SRR805766 3 0.2338 0.951 0.112 0.000 0.884 0.000 0.004
#> SRR805767 3 0.2971 0.962 0.156 0.000 0.836 0.000 0.008
#> SRR805768 3 0.2848 0.963 0.156 0.000 0.840 0.000 0.004
#> SRR805769 1 0.1364 0.950 0.952 0.000 0.036 0.000 0.012
#> SRR805770 1 0.1608 0.943 0.928 0.000 0.072 0.000 0.000
#> SRR805771 1 0.1764 0.946 0.928 0.000 0.064 0.000 0.008
#> SRR805772 1 0.1281 0.938 0.956 0.000 0.012 0.000 0.032
#> SRR805773 1 0.2760 0.862 0.892 0.000 0.016 0.064 0.028
#> SRR805774 1 0.0960 0.934 0.972 0.000 0.004 0.008 0.016
#> SRR805775 1 0.1914 0.951 0.924 0.000 0.060 0.000 0.016
#> SRR805776 1 0.1997 0.945 0.924 0.000 0.040 0.000 0.036
#> SRR805777 1 0.1341 0.950 0.944 0.000 0.056 0.000 0.000
#> SRR805778 1 0.1608 0.943 0.928 0.000 0.072 0.000 0.000
#> SRR805779 1 0.1701 0.953 0.936 0.000 0.048 0.000 0.016
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805725 2 0.7002 0.728 0.016 0.544 0.008 0.160 0.088 0.184
#> SRR805726 2 0.6925 0.677 0.072 0.488 0.000 0.264 0.164 0.012
#> SRR805727 2 0.6769 0.759 0.048 0.616 0.012 0.136 0.088 0.100
#> SRR805728 6 0.5503 0.185 0.000 0.308 0.000 0.036 0.072 0.584
#> SRR805729 2 0.5543 0.717 0.032 0.696 0.044 0.128 0.100 0.000
#> SRR805730 6 0.3104 0.703 0.000 0.184 0.000 0.000 0.016 0.800
#> SRR805731 6 0.2092 0.781 0.000 0.124 0.000 0.000 0.000 0.876
#> SRR805732 6 0.0000 0.840 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805733 6 0.0000 0.840 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805735 2 0.6462 0.410 0.000 0.448 0.004 0.120 0.052 0.376
#> SRR805736 5 0.2566 0.878 0.000 0.112 0.008 0.012 0.868 0.000
#> SRR805737 5 0.1010 0.946 0.004 0.036 0.000 0.000 0.960 0.000
#> SRR805738 5 0.0603 0.947 0.000 0.016 0.000 0.004 0.980 0.000
#> SRR805739 5 0.1707 0.936 0.004 0.056 0.012 0.000 0.928 0.000
#> SRR805740 5 0.1398 0.936 0.000 0.052 0.000 0.008 0.940 0.000
#> SRR805741 5 0.0858 0.947 0.004 0.028 0.000 0.000 0.968 0.000
#> SRR805742 5 0.0508 0.939 0.004 0.012 0.000 0.000 0.984 0.000
#> SRR805743 5 0.2295 0.885 0.016 0.028 0.000 0.000 0.904 0.052
#> SRR805744 5 0.1649 0.908 0.032 0.036 0.000 0.000 0.932 0.000
#> SRR805745 5 0.1285 0.941 0.004 0.052 0.000 0.000 0.944 0.000
#> SRR805746 5 0.0508 0.942 0.004 0.012 0.000 0.000 0.984 0.000
#> SRR805747 4 0.0632 0.964 0.000 0.024 0.000 0.976 0.000 0.000
#> SRR805748 4 0.0458 0.984 0.000 0.016 0.000 0.984 0.000 0.000
#> SRR805749 4 0.0458 0.985 0.000 0.016 0.000 0.984 0.000 0.000
#> SRR805750 4 0.0260 0.986 0.000 0.008 0.000 0.992 0.000 0.000
#> SRR805751 4 0.0000 0.986 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805752 6 0.0000 0.840 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805753 6 0.0000 0.840 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805754 4 0.0146 0.987 0.000 0.004 0.000 0.996 0.000 0.000
#> SRR805755 4 0.0260 0.987 0.000 0.008 0.000 0.992 0.000 0.000
#> SRR805756 4 0.0000 0.986 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805757 4 0.0547 0.981 0.000 0.020 0.000 0.980 0.000 0.000
#> SRR805758 3 0.2000 0.930 0.032 0.048 0.916 0.004 0.000 0.000
#> SRR805759 3 0.0779 0.959 0.008 0.000 0.976 0.008 0.008 0.000
#> SRR805760 3 0.1382 0.951 0.000 0.036 0.948 0.008 0.008 0.000
#> SRR805761 3 0.1794 0.938 0.036 0.040 0.924 0.000 0.000 0.000
#> SRR805762 3 0.1026 0.958 0.004 0.012 0.968 0.008 0.008 0.000
#> SRR805763 3 0.0717 0.957 0.000 0.008 0.976 0.000 0.016 0.000
#> SRR805764 3 0.2830 0.912 0.000 0.092 0.868 0.004 0.024 0.012
#> SRR805765 3 0.1913 0.943 0.012 0.060 0.920 0.000 0.004 0.004
#> SRR805766 3 0.0767 0.958 0.000 0.012 0.976 0.004 0.008 0.000
#> SRR805767 3 0.1346 0.956 0.008 0.024 0.952 0.000 0.016 0.000
#> SRR805768 3 0.1546 0.952 0.020 0.028 0.944 0.004 0.004 0.000
#> SRR805769 1 0.0891 0.959 0.968 0.024 0.008 0.000 0.000 0.000
#> SRR805770 1 0.1477 0.955 0.940 0.004 0.048 0.000 0.008 0.000
#> SRR805771 1 0.1606 0.948 0.932 0.004 0.056 0.000 0.008 0.000
#> SRR805772 1 0.0508 0.957 0.984 0.012 0.000 0.000 0.004 0.000
#> SRR805773 1 0.1890 0.926 0.924 0.044 0.000 0.024 0.008 0.000
#> SRR805774 1 0.0653 0.959 0.980 0.012 0.004 0.000 0.004 0.000
#> SRR805775 1 0.1483 0.957 0.944 0.008 0.036 0.000 0.012 0.000
#> SRR805776 1 0.1426 0.951 0.948 0.028 0.008 0.000 0.016 0.000
#> SRR805777 1 0.1562 0.955 0.940 0.032 0.024 0.000 0.004 0.000
#> SRR805778 1 0.1265 0.956 0.948 0.000 0.044 0.000 0.008 0.000
#> SRR805779 1 0.1078 0.961 0.964 0.016 0.012 0.000 0.008 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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