Date: 2019-12-25 23:50:35 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 17171 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] 17171 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:kmeans | 2 | 1.000 | 0.977 | 0.985 | ** | |
CV:NMF | 2 | 1.000 | 0.975 | 0.990 | ** | |
MAD:hclust | 3 | 1.000 | 0.964 | 0.983 | ** | |
MAD:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
MAD:pam | 2 | 1.000 | 1.000 | 1.000 | ** | |
MAD:mclust | 2 | 1.000 | 0.974 | 0.989 | ** | |
ATC:hclust | 3 | 1.000 | 0.987 | 0.994 | ** | 2 |
ATC:skmeans | 3 | 1.000 | 0.958 | 0.983 | ** | 2 |
ATC:mclust | 3 | 1.000 | 0.994 | 0.997 | ** | |
ATC:NMF | 2 | 1.000 | 0.974 | 0.991 | ** | |
SD:pam | 4 | 0.961 | 0.936 | 0.971 | ** | 2,3 |
CV:pam | 3 | 0.951 | 0.907 | 0.963 | ** | |
MAD:NMF | 4 | 0.944 | 0.907 | 0.955 | * | 2,3 |
CV:skmeans | 4 | 0.940 | 0.922 | 0.966 | * | 2,3 |
SD:NMF | 4 | 0.929 | 0.900 | 0.954 | * | 2,3 |
ATC:pam | 5 | 0.921 | 0.919 | 0.966 | * | 2,4 |
MAD:skmeans | 3 | 0.909 | 0.929 | 0.962 | * | 2 |
ATC:kmeans | 3 | 0.904 | 0.932 | 0.968 | * | 2 |
SD:skmeans | 4 | 0.902 | 0.861 | 0.937 | * | 2,3 |
CV:mclust | 4 | 0.887 | 0.893 | 0.928 | ||
CV:hclust | 4 | 0.839 | 0.882 | 0.920 | ||
SD:mclust | 4 | 0.800 | 0.899 | 0.920 | ||
CV:kmeans | 2 | 0.633 | 0.936 | 0.956 | ||
SD:hclust | 3 | 0.598 | 0.829 | 0.885 |
**: 1-PAC > 0.95, *: 1-PAC > 0.9
Cumulative distribution function curves of consensus matrix for all methods.
collect_plots(res_list, fun = plot_ecdf)
Consensus heatmaps for all methods. (What is a consensus heatmap?)
collect_plots(res_list, k = 2, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = consensus_heatmap, mc.cores = 4)
Membership heatmaps for all methods. (What is a membership heatmap?)
collect_plots(res_list, k = 2, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = membership_heatmap, mc.cores = 4)
Signature heatmaps for all methods. (What is a signature heatmap?)
Note in following heatmaps, rows are scaled.
collect_plots(res_list, k = 2, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 3, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 4, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 5, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 6, fun = get_signatures, mc.cores = 4)
The statistics used for measuring the stability of consensus partitioning. (How are they defined?)
get_stats(res_list, k = 2)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 2 1.000 0.944 0.980 0.506 0.493 0.493
#> CV:NMF 2 1.000 0.975 0.990 0.509 0.491 0.491
#> MAD:NMF 2 1.000 0.993 0.996 0.504 0.497 0.497
#> ATC:NMF 2 1.000 0.974 0.991 0.508 0.491 0.491
#> SD:skmeans 2 1.000 0.970 0.988 0.506 0.497 0.497
#> CV:skmeans 2 1.000 0.969 0.989 0.509 0.491 0.491
#> MAD:skmeans 2 1.000 0.991 0.996 0.504 0.497 0.497
#> ATC:skmeans 2 1.000 1.000 1.000 0.510 0.491 0.491
#> SD:mclust 2 0.547 0.933 0.938 0.450 0.547 0.547
#> CV:mclust 2 0.509 0.797 0.859 0.438 0.560 0.560
#> MAD:mclust 2 1.000 0.974 0.989 0.460 0.547 0.547
#> ATC:mclust 2 0.829 0.898 0.957 0.478 0.502 0.502
#> SD:kmeans 2 1.000 0.977 0.985 0.502 0.497 0.497
#> CV:kmeans 2 0.633 0.936 0.956 0.491 0.491 0.491
#> MAD:kmeans 2 1.000 1.000 1.000 0.504 0.497 0.497
#> ATC:kmeans 2 1.000 1.000 1.000 0.510 0.491 0.491
#> SD:pam 2 0.961 0.948 0.978 0.506 0.497 0.497
#> CV:pam 2 0.858 0.960 0.974 0.501 0.491 0.491
#> MAD:pam 2 1.000 1.000 1.000 0.504 0.497 0.497
#> ATC:pam 2 1.000 1.000 1.000 0.510 0.491 0.491
#> SD:hclust 2 0.280 0.407 0.750 0.365 0.628 0.628
#> CV:hclust 2 0.537 0.731 0.878 0.200 0.927 0.927
#> MAD:hclust 2 0.855 0.948 0.975 0.509 0.491 0.491
#> ATC:hclust 2 1.000 1.000 1.000 0.510 0.491 0.491
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 0.905 0.916 0.959 0.251 0.860 0.725
#> CV:NMF 3 0.862 0.857 0.930 0.254 0.840 0.682
#> MAD:NMF 3 1.000 0.968 0.987 0.244 0.867 0.734
#> ATC:NMF 3 0.807 0.782 0.894 0.198 0.911 0.821
#> SD:skmeans 3 0.925 0.926 0.966 0.302 0.843 0.685
#> CV:skmeans 3 1.000 0.950 0.978 0.288 0.820 0.646
#> MAD:skmeans 3 0.909 0.929 0.962 0.277 0.868 0.734
#> ATC:skmeans 3 1.000 0.958 0.983 0.155 0.929 0.857
#> SD:mclust 3 0.700 0.727 0.840 0.479 0.776 0.591
#> CV:mclust 3 0.595 0.792 0.861 0.464 0.762 0.584
#> MAD:mclust 3 0.738 0.857 0.929 0.425 0.808 0.649
#> ATC:mclust 3 1.000 0.994 0.997 0.384 0.781 0.586
#> SD:kmeans 3 0.722 0.834 0.872 0.266 0.843 0.685
#> CV:kmeans 3 0.781 0.860 0.890 0.309 0.772 0.568
#> MAD:kmeans 3 0.768 0.795 0.907 0.226 0.867 0.734
#> ATC:kmeans 3 0.904 0.932 0.968 0.166 0.929 0.857
#> SD:pam 3 0.940 0.891 0.959 0.287 0.820 0.650
#> CV:pam 3 0.951 0.907 0.963 0.278 0.877 0.749
#> MAD:pam 3 0.809 0.894 0.928 0.285 0.816 0.642
#> ATC:pam 3 0.856 0.829 0.917 0.160 0.965 0.929
#> SD:hclust 3 0.598 0.829 0.885 0.617 0.603 0.437
#> CV:hclust 3 0.586 0.683 0.814 1.359 0.706 0.683
#> MAD:hclust 3 1.000 0.964 0.983 0.138 0.936 0.869
#> ATC:hclust 3 1.000 0.987 0.994 0.078 0.965 0.929
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.929 0.900 0.954 0.05891 0.940 0.844
#> CV:NMF 4 0.851 0.836 0.921 0.08928 0.892 0.725
#> MAD:NMF 4 0.944 0.907 0.955 0.05484 0.956 0.884
#> ATC:NMF 4 0.799 0.828 0.902 0.13679 0.859 0.663
#> SD:skmeans 4 0.902 0.861 0.937 0.08852 0.918 0.769
#> CV:skmeans 4 0.940 0.922 0.966 0.11081 0.918 0.766
#> MAD:skmeans 4 0.781 0.756 0.889 0.08471 0.904 0.746
#> ATC:skmeans 4 0.898 0.845 0.929 0.12789 0.886 0.736
#> SD:mclust 4 0.800 0.899 0.920 0.10176 0.931 0.786
#> CV:mclust 4 0.887 0.893 0.928 0.15871 0.869 0.638
#> MAD:mclust 4 0.697 0.672 0.827 0.10130 0.825 0.564
#> ATC:mclust 4 0.857 0.778 0.895 0.07664 0.940 0.825
#> SD:kmeans 4 0.759 0.708 0.850 0.10559 0.918 0.780
#> CV:kmeans 4 0.761 0.729 0.851 0.10099 0.901 0.734
#> MAD:kmeans 4 0.671 0.666 0.822 0.12913 0.953 0.877
#> ATC:kmeans 4 0.815 0.846 0.892 0.12815 0.874 0.707
#> SD:pam 4 0.961 0.936 0.971 0.10167 0.855 0.625
#> CV:pam 4 0.794 0.731 0.855 0.10677 0.869 0.662
#> MAD:pam 4 0.797 0.811 0.895 0.11480 0.909 0.751
#> ATC:pam 4 0.981 0.936 0.977 0.13463 0.877 0.730
#> SD:hclust 4 0.772 0.873 0.923 0.07114 0.968 0.917
#> CV:hclust 4 0.839 0.882 0.920 0.40363 0.695 0.518
#> MAD:hclust 4 0.995 0.958 0.982 0.00636 0.997 0.993
#> ATC:hclust 4 0.821 0.761 0.857 0.15285 0.874 0.724
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 0.790 0.749 0.868 0.0966 0.928 0.788
#> CV:NMF 5 0.857 0.787 0.895 0.0834 0.923 0.762
#> MAD:NMF 5 0.824 0.759 0.838 0.0935 0.898 0.714
#> ATC:NMF 5 0.758 0.693 0.831 0.0405 0.954 0.850
#> SD:skmeans 5 0.815 0.695 0.838 0.0513 0.979 0.927
#> CV:skmeans 5 0.797 0.729 0.838 0.0586 0.994 0.980
#> MAD:skmeans 5 0.799 0.626 0.832 0.0722 0.948 0.833
#> ATC:skmeans 5 0.858 0.850 0.897 0.0507 0.939 0.815
#> SD:mclust 5 0.733 0.773 0.847 0.0273 0.892 0.638
#> CV:mclust 5 0.880 0.891 0.864 0.0499 0.966 0.860
#> MAD:mclust 5 0.732 0.601 0.793 0.0536 0.905 0.675
#> ATC:mclust 5 0.860 0.818 0.893 0.0607 0.899 0.673
#> SD:kmeans 5 0.691 0.633 0.791 0.0678 1.000 1.000
#> CV:kmeans 5 0.725 0.728 0.771 0.0688 0.957 0.862
#> MAD:kmeans 5 0.657 0.589 0.775 0.0843 0.908 0.743
#> ATC:kmeans 5 0.689 0.747 0.834 0.0824 0.954 0.854
#> SD:pam 5 0.892 0.785 0.894 0.0453 0.970 0.894
#> CV:pam 5 0.884 0.741 0.885 0.0513 0.932 0.773
#> MAD:pam 5 0.749 0.736 0.856 0.0323 0.918 0.749
#> ATC:pam 5 0.921 0.919 0.966 0.0490 0.968 0.903
#> SD:hclust 5 0.805 0.833 0.831 0.1193 0.922 0.779
#> CV:hclust 5 0.793 0.806 0.866 0.0850 0.951 0.851
#> MAD:hclust 5 0.778 0.780 0.878 0.1955 0.874 0.703
#> ATC:hclust 5 0.846 0.893 0.951 0.0785 0.904 0.741
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 0.773 0.724 0.827 0.0683 0.911 0.692
#> CV:NMF 6 0.732 0.550 0.741 0.0657 0.924 0.703
#> MAD:NMF 6 0.757 0.719 0.833 0.0724 0.928 0.743
#> ATC:NMF 6 0.729 0.676 0.826 0.0377 0.891 0.663
#> SD:skmeans 6 0.722 0.600 0.732 0.0442 0.943 0.794
#> CV:skmeans 6 0.779 0.694 0.731 0.0452 0.921 0.710
#> MAD:skmeans 6 0.722 0.628 0.772 0.0480 0.941 0.786
#> ATC:skmeans 6 0.889 0.865 0.932 0.0427 0.992 0.970
#> SD:mclust 6 0.787 0.742 0.825 0.0543 0.971 0.874
#> CV:mclust 6 0.831 0.813 0.868 0.0297 0.983 0.920
#> MAD:mclust 6 0.752 0.656 0.801 0.0407 0.920 0.674
#> ATC:mclust 6 0.778 0.652 0.814 0.0267 0.900 0.642
#> SD:kmeans 6 0.721 0.530 0.716 0.0545 0.927 0.784
#> CV:kmeans 6 0.722 0.437 0.659 0.0479 0.973 0.901
#> MAD:kmeans 6 0.718 0.533 0.736 0.0462 0.933 0.768
#> ATC:kmeans 6 0.731 0.710 0.813 0.0506 0.979 0.924
#> SD:pam 6 0.845 0.789 0.893 0.0400 0.964 0.866
#> CV:pam 6 0.889 0.736 0.895 0.0335 0.959 0.847
#> MAD:pam 6 0.740 0.712 0.812 0.0719 0.892 0.631
#> ATC:pam 6 0.893 0.912 0.928 0.0542 0.958 0.860
#> SD:hclust 6 0.867 0.813 0.899 0.0434 0.991 0.967
#> CV:hclust 6 0.863 0.781 0.881 0.0433 0.985 0.948
#> MAD:hclust 6 0.851 0.780 0.899 0.0495 0.948 0.838
#> ATC:hclust 6 0.746 0.752 0.871 0.0759 0.947 0.833
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 17171 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 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.280 0.407 0.750 0.3651 0.628 0.628
#> 3 3 0.598 0.829 0.885 0.6174 0.603 0.437
#> 4 4 0.772 0.873 0.923 0.0711 0.968 0.917
#> 5 5 0.805 0.833 0.831 0.1193 0.922 0.779
#> 6 6 0.867 0.813 0.899 0.0434 0.991 0.967
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
#> SRR975551 2 0.996 0.0475 0.464 0.536
#> SRR975552 2 0.996 0.0475 0.464 0.536
#> SRR975554 2 0.996 0.0475 0.464 0.536
#> SRR975553 2 0.000 0.6474 0.000 1.000
#> SRR975555 2 0.996 0.0475 0.464 0.536
#> SRR975556 2 0.000 0.6474 0.000 1.000
#> SRR975557 2 0.644 0.4167 0.164 0.836
#> SRR975558 2 0.973 0.1704 0.404 0.596
#> SRR975559 2 0.973 0.1704 0.404 0.596
#> SRR975560 2 0.000 0.6474 0.000 1.000
#> SRR975561 2 0.000 0.6474 0.000 1.000
#> SRR975562 2 0.996 0.0475 0.464 0.536
#> SRR975563 2 0.000 0.6474 0.000 1.000
#> SRR975564 2 0.996 0.0475 0.464 0.536
#> SRR975565 2 0.996 0.0475 0.464 0.536
#> SRR975566 2 0.996 0.0475 0.464 0.536
#> SRR975567 2 0.973 0.1704 0.404 0.596
#> SRR975568 2 0.996 0.0475 0.464 0.536
#> SRR975569 2 0.000 0.6474 0.000 1.000
#> SRR975570 2 0.000 0.6474 0.000 1.000
#> SRR975571 2 0.000 0.6474 0.000 1.000
#> SRR975572 2 0.000 0.6474 0.000 1.000
#> SRR975573 2 0.000 0.6474 0.000 1.000
#> SRR975574 2 0.000 0.6474 0.000 1.000
#> SRR975575 2 0.000 0.6474 0.000 1.000
#> SRR975576 2 0.000 0.6474 0.000 1.000
#> SRR975577 2 0.000 0.6474 0.000 1.000
#> SRR975578 2 0.000 0.6474 0.000 1.000
#> SRR975579 2 0.644 0.4167 0.164 0.836
#> SRR975580 2 0.000 0.6474 0.000 1.000
#> SRR975581 2 0.000 0.6474 0.000 1.000
#> SRR975582 2 0.000 0.6474 0.000 1.000
#> SRR975583 2 0.000 0.6474 0.000 1.000
#> SRR975584 2 0.000 0.6474 0.000 1.000
#> SRR975585 2 0.000 0.6474 0.000 1.000
#> SRR975586 2 0.000 0.6474 0.000 1.000
#> SRR975587 1 0.987 0.4589 0.568 0.432
#> SRR975588 2 0.000 0.6474 0.000 1.000
#> SRR975589 1 0.949 0.4103 0.632 0.368
#> SRR975590 1 0.975 0.3567 0.592 0.408
#> SRR975591 1 0.987 0.4589 0.568 0.432
#> SRR975592 1 0.855 0.4483 0.720 0.280
#> SRR975593 1 0.949 0.4103 0.632 0.368
#> SRR975594 1 0.980 0.2498 0.584 0.416
#> SRR975595 1 0.980 0.3421 0.584 0.416
#> SRR975597 1 0.980 0.3421 0.584 0.416
#> SRR975596 2 0.973 0.1704 0.404 0.596
#> SRR975598 1 0.980 0.3421 0.584 0.416
#> SRR975599 2 0.963 0.2043 0.388 0.612
#> SRR975600 2 0.992 -0.3257 0.448 0.552
#> SRR975601 1 0.987 0.4589 0.568 0.432
#> SRR975602 2 0.996 0.0475 0.464 0.536
#> SRR975603 1 0.987 0.4589 0.568 0.432
#> SRR975604 1 0.987 0.4589 0.568 0.432
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.312 0.824 0.892 0.108 0.000
#> SRR975552 1 0.312 0.824 0.892 0.108 0.000
#> SRR975554 1 0.216 0.820 0.936 0.064 0.000
#> SRR975553 2 0.000 0.963 0.000 1.000 0.000
#> SRR975555 1 0.348 0.815 0.872 0.128 0.000
#> SRR975556 2 0.000 0.963 0.000 1.000 0.000
#> SRR975557 2 0.934 0.374 0.208 0.512 0.280
#> SRR975558 1 0.493 0.697 0.768 0.232 0.000
#> SRR975559 1 0.341 0.797 0.876 0.124 0.000
#> SRR975560 2 0.000 0.963 0.000 1.000 0.000
#> SRR975561 2 0.000 0.963 0.000 1.000 0.000
#> SRR975562 1 0.216 0.820 0.936 0.064 0.000
#> SRR975563 2 0.000 0.963 0.000 1.000 0.000
#> SRR975564 1 0.348 0.815 0.872 0.128 0.000
#> SRR975565 1 0.341 0.817 0.876 0.124 0.000
#> SRR975566 1 0.216 0.820 0.936 0.064 0.000
#> SRR975567 1 0.493 0.697 0.768 0.232 0.000
#> SRR975568 1 0.348 0.815 0.872 0.128 0.000
#> SRR975569 2 0.000 0.963 0.000 1.000 0.000
#> SRR975570 2 0.000 0.963 0.000 1.000 0.000
#> SRR975571 2 0.000 0.963 0.000 1.000 0.000
#> SRR975572 2 0.000 0.963 0.000 1.000 0.000
#> SRR975573 2 0.000 0.963 0.000 1.000 0.000
#> SRR975574 2 0.000 0.963 0.000 1.000 0.000
#> SRR975575 2 0.000 0.963 0.000 1.000 0.000
#> SRR975576 2 0.000 0.963 0.000 1.000 0.000
#> SRR975577 2 0.000 0.963 0.000 1.000 0.000
#> SRR975578 2 0.000 0.963 0.000 1.000 0.000
#> SRR975579 2 0.934 0.374 0.208 0.512 0.280
#> SRR975580 2 0.000 0.963 0.000 1.000 0.000
#> SRR975581 2 0.000 0.963 0.000 1.000 0.000
#> SRR975582 2 0.000 0.963 0.000 1.000 0.000
#> SRR975583 2 0.000 0.963 0.000 1.000 0.000
#> SRR975584 2 0.000 0.963 0.000 1.000 0.000
#> SRR975585 2 0.000 0.963 0.000 1.000 0.000
#> SRR975586 2 0.000 0.963 0.000 1.000 0.000
#> SRR975587 3 0.573 0.875 0.324 0.000 0.676
#> SRR975588 2 0.000 0.963 0.000 1.000 0.000
#> SRR975589 1 0.355 0.683 0.868 0.000 0.132
#> SRR975590 1 0.393 0.744 0.880 0.028 0.092
#> SRR975591 3 0.573 0.875 0.324 0.000 0.676
#> SRR975592 1 0.480 0.532 0.780 0.000 0.220
#> SRR975593 1 0.355 0.683 0.868 0.000 0.132
#> SRR975594 3 0.141 0.590 0.036 0.000 0.964
#> SRR975595 1 0.377 0.752 0.888 0.028 0.084
#> SRR975597 1 0.377 0.752 0.888 0.028 0.084
#> SRR975596 1 0.341 0.797 0.876 0.124 0.000
#> SRR975598 1 0.377 0.752 0.888 0.028 0.084
#> SRR975599 1 0.806 0.247 0.532 0.068 0.400
#> SRR975600 3 0.629 0.593 0.468 0.000 0.532
#> SRR975601 3 0.573 0.875 0.324 0.000 0.676
#> SRR975602 1 0.216 0.820 0.936 0.064 0.000
#> SRR975603 3 0.573 0.875 0.324 0.000 0.676
#> SRR975604 3 0.573 0.875 0.324 0.000 0.676
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.130 0.836 0.956 0.044 0.000 0.00
#> SRR975552 1 0.130 0.836 0.956 0.044 0.000 0.00
#> SRR975554 1 0.000 0.834 1.000 0.000 0.000 0.00
#> SRR975553 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975555 1 0.172 0.826 0.936 0.064 0.000 0.00
#> SRR975556 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975557 4 0.000 1.000 0.000 0.000 0.000 1.00
#> SRR975558 1 0.406 0.748 0.832 0.108 0.000 0.06
#> SRR975559 1 0.164 0.811 0.940 0.000 0.000 0.06
#> SRR975560 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975561 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975562 1 0.000 0.834 1.000 0.000 0.000 0.00
#> SRR975563 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975564 1 0.172 0.826 0.936 0.064 0.000 0.00
#> SRR975565 1 0.164 0.829 0.940 0.060 0.000 0.00
#> SRR975566 1 0.000 0.834 1.000 0.000 0.000 0.00
#> SRR975567 1 0.406 0.748 0.832 0.108 0.000 0.06
#> SRR975568 1 0.172 0.826 0.936 0.064 0.000 0.00
#> SRR975569 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975570 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975571 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975572 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975573 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975574 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975575 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975576 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975577 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975578 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975579 4 0.000 1.000 0.000 0.000 0.000 1.00
#> SRR975580 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975581 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975582 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975583 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975584 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975585 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975586 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975587 3 0.433 0.876 0.288 0.000 0.712 0.00
#> SRR975588 2 0.000 1.000 0.000 1.000 0.000 0.00
#> SRR975589 1 0.327 0.724 0.832 0.000 0.168 0.00
#> SRR975590 1 0.276 0.770 0.872 0.000 0.128 0.00
#> SRR975591 3 0.433 0.876 0.288 0.000 0.712 0.00
#> SRR975592 1 0.410 0.576 0.744 0.000 0.256 0.00
#> SRR975593 1 0.327 0.724 0.832 0.000 0.168 0.00
#> SRR975594 3 0.000 0.353 0.000 0.000 1.000 0.00
#> SRR975595 1 0.265 0.777 0.880 0.000 0.120 0.00
#> SRR975597 1 0.265 0.777 0.880 0.000 0.120 0.00
#> SRR975596 1 0.164 0.811 0.940 0.000 0.000 0.06
#> SRR975598 1 0.265 0.777 0.880 0.000 0.120 0.00
#> SRR975599 1 0.503 0.246 0.596 0.004 0.400 0.00
#> SRR975600 3 0.493 0.586 0.432 0.000 0.568 0.00
#> SRR975601 3 0.433 0.876 0.288 0.000 0.712 0.00
#> SRR975602 1 0.000 0.834 1.000 0.000 0.000 0.00
#> SRR975603 3 0.433 0.876 0.288 0.000 0.712 0.00
#> SRR975604 3 0.433 0.876 0.288 0.000 0.712 0.00
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.418 0.583 0.600 0.000 0.000 0.00 0.400
#> SRR975552 1 0.418 0.583 0.600 0.000 0.000 0.00 0.400
#> SRR975554 1 0.400 0.640 0.656 0.000 0.000 0.00 0.344
#> SRR975553 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975555 5 0.260 0.776 0.148 0.000 0.000 0.00 0.852
#> SRR975556 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975557 4 0.141 1.000 0.000 0.000 0.000 0.94 0.060
#> SRR975558 5 0.128 0.744 0.004 0.044 0.000 0.00 0.952
#> SRR975559 5 0.238 0.744 0.128 0.000 0.000 0.00 0.872
#> SRR975560 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975561 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975562 5 0.366 0.628 0.276 0.000 0.000 0.00 0.724
#> SRR975563 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975564 5 0.260 0.776 0.148 0.000 0.000 0.00 0.852
#> SRR975565 1 0.423 0.554 0.580 0.000 0.000 0.00 0.420
#> SRR975566 1 0.356 0.697 0.740 0.000 0.000 0.00 0.260
#> SRR975567 5 0.128 0.744 0.004 0.044 0.000 0.00 0.952
#> SRR975568 5 0.260 0.776 0.148 0.000 0.000 0.00 0.852
#> SRR975569 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975570 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975571 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975572 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975573 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975574 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975575 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975576 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975577 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975578 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975579 4 0.141 1.000 0.000 0.000 0.000 0.94 0.060
#> SRR975580 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975581 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975582 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975583 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975584 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975585 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975586 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975587 3 0.428 0.837 0.032 0.000 0.724 0.00 0.244
#> SRR975588 2 0.000 1.000 0.000 1.000 0.000 0.00 0.000
#> SRR975589 1 0.407 0.628 0.752 0.000 0.032 0.00 0.216
#> SRR975590 1 0.304 0.736 0.836 0.000 0.012 0.00 0.152
#> SRR975591 3 0.509 0.850 0.084 0.000 0.672 0.00 0.244
#> SRR975592 1 0.455 0.645 0.752 0.000 0.124 0.00 0.124
#> SRR975593 1 0.407 0.628 0.752 0.000 0.032 0.00 0.216
#> SRR975594 3 0.328 0.348 0.092 0.000 0.848 0.06 0.000
#> SRR975595 1 0.281 0.738 0.844 0.000 0.004 0.00 0.152
#> SRR975597 1 0.281 0.738 0.844 0.000 0.004 0.00 0.152
#> SRR975596 5 0.238 0.744 0.128 0.000 0.000 0.00 0.872
#> SRR975598 1 0.281 0.738 0.844 0.000 0.004 0.00 0.152
#> SRR975599 1 0.693 0.264 0.556 0.000 0.244 0.06 0.140
#> SRR975600 3 0.655 0.617 0.248 0.000 0.476 0.00 0.276
#> SRR975601 3 0.428 0.837 0.032 0.000 0.724 0.00 0.244
#> SRR975602 1 0.356 0.697 0.740 0.000 0.000 0.00 0.260
#> SRR975603 3 0.509 0.850 0.084 0.000 0.672 0.00 0.244
#> SRR975604 3 0.509 0.850 0.084 0.000 0.672 0.00 0.244
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.5102 0.583 0.620 0.000 0.000 0.240 0.140 0
#> SRR975552 1 0.5102 0.583 0.620 0.000 0.000 0.240 0.140 0
#> SRR975554 1 0.4881 0.592 0.656 0.000 0.000 0.136 0.208 0
#> SRR975553 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975555 4 0.2340 0.774 0.148 0.000 0.000 0.852 0.000 0
#> SRR975556 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975557 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1
#> SRR975558 4 0.1007 0.733 0.000 0.044 0.000 0.956 0.000 0
#> SRR975559 4 0.3385 0.701 0.032 0.000 0.000 0.788 0.180 0
#> SRR975560 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975561 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975562 4 0.5067 0.659 0.184 0.000 0.000 0.636 0.180 0
#> SRR975563 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975564 4 0.2340 0.774 0.148 0.000 0.000 0.852 0.000 0
#> SRR975565 1 0.4951 0.571 0.620 0.000 0.000 0.276 0.104 0
#> SRR975566 1 0.3714 0.561 0.656 0.000 0.000 0.004 0.340 0
#> SRR975567 4 0.1007 0.733 0.000 0.044 0.000 0.956 0.000 0
#> SRR975568 4 0.2340 0.774 0.148 0.000 0.000 0.852 0.000 0
#> SRR975569 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975570 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975571 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975572 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975573 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975574 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975575 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975576 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975577 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975578 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975579 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1
#> SRR975580 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975581 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975582 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975583 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975584 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975585 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975586 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975587 3 0.1594 0.820 0.016 0.000 0.932 0.000 0.052 0
#> SRR975588 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0
#> SRR975589 1 0.3221 0.595 0.828 0.000 0.076 0.096 0.000 0
#> SRR975590 1 0.0777 0.698 0.972 0.000 0.024 0.000 0.004 0
#> SRR975591 3 0.0865 0.840 0.036 0.000 0.964 0.000 0.000 0
#> SRR975592 1 0.2668 0.624 0.828 0.000 0.168 0.004 0.000 0
#> SRR975593 1 0.3221 0.595 0.828 0.000 0.076 0.096 0.000 0
#> SRR975594 3 0.3854 0.212 0.000 0.000 0.536 0.000 0.464 0
#> SRR975595 1 0.0458 0.698 0.984 0.000 0.016 0.000 0.000 0
#> SRR975597 1 0.0458 0.698 0.984 0.000 0.016 0.000 0.000 0
#> SRR975596 4 0.3385 0.701 0.032 0.000 0.000 0.788 0.180 0
#> SRR975598 1 0.0458 0.698 0.984 0.000 0.016 0.000 0.000 0
#> SRR975599 5 0.2300 0.000 0.144 0.000 0.000 0.000 0.856 0
#> SRR975600 3 0.3163 0.624 0.232 0.000 0.764 0.004 0.000 0
#> SRR975601 3 0.1594 0.820 0.016 0.000 0.932 0.000 0.052 0
#> SRR975602 1 0.3714 0.561 0.656 0.000 0.000 0.004 0.340 0
#> SRR975603 3 0.0865 0.840 0.036 0.000 0.964 0.000 0.000 0
#> SRR975604 3 0.0865 0.840 0.036 0.000 0.964 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["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 17171 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 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.977 0.985 0.5016 0.497 0.497
#> 3 3 0.722 0.834 0.872 0.2656 0.843 0.685
#> 4 4 0.759 0.708 0.850 0.1056 0.918 0.780
#> 5 5 0.691 0.633 0.791 0.0678 1.000 1.000
#> 6 6 0.721 0.530 0.716 0.0545 0.927 0.784
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
#> SRR975551 1 0.204 0.971 0.968 0.032
#> SRR975552 1 0.204 0.971 0.968 0.032
#> SRR975554 1 0.204 0.971 0.968 0.032
#> SRR975553 2 0.000 1.000 0.000 1.000
#> SRR975555 1 0.204 0.971 0.968 0.032
#> SRR975556 2 0.000 1.000 0.000 1.000
#> SRR975557 1 0.204 0.971 0.968 0.032
#> SRR975558 1 0.722 0.785 0.800 0.200
#> SRR975559 1 0.204 0.971 0.968 0.032
#> SRR975560 2 0.000 1.000 0.000 1.000
#> SRR975561 2 0.000 1.000 0.000 1.000
#> SRR975562 1 0.204 0.971 0.968 0.032
#> SRR975563 2 0.000 1.000 0.000 1.000
#> SRR975564 1 0.204 0.971 0.968 0.032
#> SRR975565 1 0.204 0.971 0.968 0.032
#> SRR975566 1 0.204 0.971 0.968 0.032
#> SRR975567 1 0.722 0.785 0.800 0.200
#> SRR975568 1 0.204 0.971 0.968 0.032
#> SRR975569 2 0.000 1.000 0.000 1.000
#> SRR975570 2 0.000 1.000 0.000 1.000
#> SRR975571 2 0.000 1.000 0.000 1.000
#> SRR975572 2 0.000 1.000 0.000 1.000
#> SRR975573 2 0.000 1.000 0.000 1.000
#> SRR975574 2 0.000 1.000 0.000 1.000
#> SRR975575 2 0.000 1.000 0.000 1.000
#> SRR975576 2 0.000 1.000 0.000 1.000
#> SRR975577 2 0.000 1.000 0.000 1.000
#> SRR975578 2 0.000 1.000 0.000 1.000
#> SRR975579 2 0.000 1.000 0.000 1.000
#> SRR975580 2 0.000 1.000 0.000 1.000
#> SRR975581 2 0.000 1.000 0.000 1.000
#> SRR975582 2 0.000 1.000 0.000 1.000
#> SRR975583 2 0.000 1.000 0.000 1.000
#> SRR975584 2 0.000 1.000 0.000 1.000
#> SRR975585 2 0.000 1.000 0.000 1.000
#> SRR975586 2 0.000 1.000 0.000 1.000
#> SRR975587 1 0.000 0.972 1.000 0.000
#> SRR975588 2 0.000 1.000 0.000 1.000
#> SRR975589 1 0.000 0.972 1.000 0.000
#> SRR975590 1 0.000 0.972 1.000 0.000
#> SRR975591 1 0.000 0.972 1.000 0.000
#> SRR975592 1 0.000 0.972 1.000 0.000
#> SRR975593 1 0.000 0.972 1.000 0.000
#> SRR975594 1 0.000 0.972 1.000 0.000
#> SRR975595 1 0.000 0.972 1.000 0.000
#> SRR975597 1 0.000 0.972 1.000 0.000
#> SRR975596 1 0.204 0.971 0.968 0.032
#> SRR975598 1 0.000 0.972 1.000 0.000
#> SRR975599 1 0.000 0.972 1.000 0.000
#> SRR975600 1 0.000 0.972 1.000 0.000
#> SRR975601 1 0.000 0.972 1.000 0.000
#> SRR975602 1 0.204 0.971 0.968 0.032
#> SRR975603 1 0.000 0.972 1.000 0.000
#> SRR975604 1 0.000 0.972 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.5098 0.8809 0.752 0.000 0.248
#> SRR975552 1 0.5098 0.8809 0.752 0.000 0.248
#> SRR975554 1 0.5098 0.8809 0.752 0.000 0.248
#> SRR975553 2 0.0592 0.9769 0.012 0.988 0.000
#> SRR975555 1 0.5098 0.8809 0.752 0.000 0.248
#> SRR975556 2 0.0000 0.9787 0.000 1.000 0.000
#> SRR975557 1 0.5948 0.0912 0.640 0.000 0.360
#> SRR975558 1 0.3412 0.7549 0.876 0.000 0.124
#> SRR975559 1 0.4974 0.8760 0.764 0.000 0.236
#> SRR975560 2 0.3412 0.8908 0.124 0.876 0.000
#> SRR975561 2 0.3192 0.9007 0.112 0.888 0.000
#> SRR975562 1 0.4974 0.8760 0.764 0.000 0.236
#> SRR975563 2 0.0000 0.9787 0.000 1.000 0.000
#> SRR975564 1 0.5098 0.8809 0.752 0.000 0.248
#> SRR975565 1 0.5098 0.8809 0.752 0.000 0.248
#> SRR975566 1 0.5098 0.8809 0.752 0.000 0.248
#> SRR975567 1 0.3412 0.7549 0.876 0.000 0.124
#> SRR975568 1 0.5098 0.8809 0.752 0.000 0.248
#> SRR975569 2 0.0000 0.9787 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.9787 0.000 1.000 0.000
#> SRR975571 2 0.0592 0.9769 0.012 0.988 0.000
#> SRR975572 2 0.0000 0.9787 0.000 1.000 0.000
#> SRR975573 2 0.0592 0.9769 0.012 0.988 0.000
#> SRR975574 2 0.0592 0.9769 0.012 0.988 0.000
#> SRR975575 2 0.0000 0.9787 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.9787 0.000 1.000 0.000
#> SRR975577 2 0.0592 0.9769 0.012 0.988 0.000
#> SRR975578 2 0.0592 0.9769 0.012 0.988 0.000
#> SRR975579 2 0.4974 0.7868 0.236 0.764 0.000
#> SRR975580 2 0.0000 0.9787 0.000 1.000 0.000
#> SRR975581 2 0.0000 0.9787 0.000 1.000 0.000
#> SRR975582 2 0.0592 0.9769 0.012 0.988 0.000
#> SRR975583 2 0.0000 0.9787 0.000 1.000 0.000
#> SRR975584 2 0.0592 0.9769 0.012 0.988 0.000
#> SRR975585 2 0.0000 0.9787 0.000 1.000 0.000
#> SRR975586 2 0.0592 0.9732 0.012 0.988 0.000
#> SRR975587 3 0.0000 0.7550 0.000 0.000 1.000
#> SRR975588 2 0.0000 0.9787 0.000 1.000 0.000
#> SRR975589 3 0.4842 0.6797 0.224 0.000 0.776
#> SRR975590 3 0.5529 0.5856 0.296 0.000 0.704
#> SRR975591 3 0.0000 0.7550 0.000 0.000 1.000
#> SRR975592 3 0.4605 0.6923 0.204 0.000 0.796
#> SRR975593 3 0.4842 0.6797 0.224 0.000 0.776
#> SRR975594 3 0.3038 0.6460 0.104 0.000 0.896
#> SRR975595 3 0.5905 0.4783 0.352 0.000 0.648
#> SRR975597 3 0.5905 0.4783 0.352 0.000 0.648
#> SRR975596 1 0.4974 0.8760 0.764 0.000 0.236
#> SRR975598 3 0.5905 0.4783 0.352 0.000 0.648
#> SRR975599 1 0.5497 0.5423 0.708 0.000 0.292
#> SRR975600 3 0.0000 0.7550 0.000 0.000 1.000
#> SRR975601 3 0.0000 0.7550 0.000 0.000 1.000
#> SRR975602 1 0.5098 0.8809 0.752 0.000 0.248
#> SRR975603 3 0.0000 0.7550 0.000 0.000 1.000
#> SRR975604 3 0.0000 0.7550 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0000 0.7726 1.000 0.000 0.000 0.000
#> SRR975552 1 0.0000 0.7726 1.000 0.000 0.000 0.000
#> SRR975554 1 0.0000 0.7726 1.000 0.000 0.000 0.000
#> SRR975553 2 0.2596 0.8944 0.000 0.908 0.024 0.068
#> SRR975555 1 0.0000 0.7726 1.000 0.000 0.000 0.000
#> SRR975556 2 0.0000 0.9095 0.000 1.000 0.000 0.000
#> SRR975557 4 0.6563 0.2919 0.208 0.000 0.160 0.632
#> SRR975558 1 0.5155 0.1263 0.528 0.000 0.004 0.468
#> SRR975559 1 0.3444 0.6672 0.816 0.000 0.000 0.184
#> SRR975560 2 0.4977 0.0801 0.000 0.540 0.000 0.460
#> SRR975561 2 0.4431 0.5219 0.000 0.696 0.000 0.304
#> SRR975562 1 0.1474 0.7549 0.948 0.000 0.000 0.052
#> SRR975563 2 0.0000 0.9095 0.000 1.000 0.000 0.000
#> SRR975564 1 0.0000 0.7726 1.000 0.000 0.000 0.000
#> SRR975565 1 0.0000 0.7726 1.000 0.000 0.000 0.000
#> SRR975566 1 0.1557 0.7583 0.944 0.000 0.000 0.056
#> SRR975567 1 0.5155 0.1263 0.528 0.000 0.004 0.468
#> SRR975568 1 0.0000 0.7726 1.000 0.000 0.000 0.000
#> SRR975569 2 0.0188 0.9094 0.000 0.996 0.004 0.000
#> SRR975570 2 0.0188 0.9094 0.000 0.996 0.004 0.000
#> SRR975571 2 0.2596 0.8944 0.000 0.908 0.024 0.068
#> SRR975572 2 0.0000 0.9095 0.000 1.000 0.000 0.000
#> SRR975573 2 0.2596 0.8944 0.000 0.908 0.024 0.068
#> SRR975574 2 0.2596 0.8944 0.000 0.908 0.024 0.068
#> SRR975575 2 0.0000 0.9095 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.9095 0.000 1.000 0.000 0.000
#> SRR975577 2 0.2596 0.8944 0.000 0.908 0.024 0.068
#> SRR975578 2 0.2596 0.8944 0.000 0.908 0.024 0.068
#> SRR975579 4 0.5546 0.3825 0.000 0.292 0.044 0.664
#> SRR975580 2 0.2868 0.8342 0.000 0.864 0.000 0.136
#> SRR975581 2 0.0000 0.9095 0.000 1.000 0.000 0.000
#> SRR975582 2 0.2596 0.8944 0.000 0.908 0.024 0.068
#> SRR975583 2 0.0000 0.9095 0.000 1.000 0.000 0.000
#> SRR975584 2 0.2596 0.8944 0.000 0.908 0.024 0.068
#> SRR975585 2 0.0000 0.9095 0.000 1.000 0.000 0.000
#> SRR975586 2 0.2345 0.8303 0.000 0.900 0.000 0.100
#> SRR975587 3 0.3071 0.7970 0.068 0.000 0.888 0.044
#> SRR975588 2 0.0188 0.9094 0.000 0.996 0.004 0.000
#> SRR975589 3 0.6730 0.6168 0.276 0.000 0.592 0.132
#> SRR975590 3 0.7379 0.3850 0.364 0.000 0.468 0.168
#> SRR975591 3 0.1792 0.8041 0.068 0.000 0.932 0.000
#> SRR975592 3 0.6274 0.7091 0.184 0.000 0.664 0.152
#> SRR975593 3 0.6730 0.6168 0.276 0.000 0.592 0.132
#> SRR975594 3 0.2775 0.7224 0.020 0.000 0.896 0.084
#> SRR975595 1 0.7099 0.1741 0.552 0.000 0.280 0.168
#> SRR975597 1 0.7099 0.1741 0.552 0.000 0.280 0.168
#> SRR975596 1 0.3444 0.6672 0.816 0.000 0.000 0.184
#> SRR975598 1 0.7099 0.1741 0.552 0.000 0.280 0.168
#> SRR975599 1 0.5339 0.5115 0.688 0.000 0.040 0.272
#> SRR975600 3 0.3398 0.7958 0.068 0.000 0.872 0.060
#> SRR975601 3 0.3071 0.7970 0.068 0.000 0.888 0.044
#> SRR975602 1 0.2530 0.7238 0.888 0.000 0.000 0.112
#> SRR975603 3 0.1792 0.8041 0.068 0.000 0.932 0.000
#> SRR975604 3 0.1792 0.8041 0.068 0.000 0.932 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.0162 0.6907 0.996 0.000 0.000 0.000 NA
#> SRR975552 1 0.0324 0.6915 0.992 0.000 0.000 0.004 NA
#> SRR975554 1 0.1082 0.6900 0.964 0.000 0.000 0.008 NA
#> SRR975553 2 0.4003 0.7431 0.000 0.704 0.000 0.008 NA
#> SRR975555 1 0.1106 0.6880 0.964 0.000 0.000 0.012 NA
#> SRR975556 2 0.0898 0.7992 0.000 0.972 0.000 0.008 NA
#> SRR975557 4 0.4308 0.6762 0.104 0.000 0.040 0.804 NA
#> SRR975558 1 0.6696 -0.0634 0.388 0.000 0.000 0.372 NA
#> SRR975559 1 0.5107 0.5572 0.688 0.000 0.000 0.108 NA
#> SRR975560 2 0.6534 0.1266 0.000 0.460 0.000 0.328 NA
#> SRR975561 2 0.5197 0.5221 0.000 0.680 0.000 0.204 NA
#> SRR975562 1 0.3656 0.6384 0.800 0.000 0.000 0.032 NA
#> SRR975563 2 0.0000 0.8129 0.000 1.000 0.000 0.000 NA
#> SRR975564 1 0.1670 0.6858 0.936 0.000 0.000 0.012 NA
#> SRR975565 1 0.0324 0.6913 0.992 0.000 0.000 0.004 NA
#> SRR975566 1 0.3844 0.6376 0.792 0.000 0.000 0.044 NA
#> SRR975567 1 0.6696 -0.0634 0.388 0.000 0.000 0.372 NA
#> SRR975568 1 0.1012 0.6884 0.968 0.000 0.000 0.012 NA
#> SRR975569 2 0.0290 0.8130 0.000 0.992 0.000 0.000 NA
#> SRR975570 2 0.0290 0.8130 0.000 0.992 0.000 0.000 NA
#> SRR975571 2 0.4003 0.7431 0.000 0.704 0.000 0.008 NA
#> SRR975572 2 0.0000 0.8129 0.000 1.000 0.000 0.000 NA
#> SRR975573 2 0.3730 0.7469 0.000 0.712 0.000 0.000 NA
#> SRR975574 2 0.3730 0.7469 0.000 0.712 0.000 0.000 NA
#> SRR975575 2 0.0000 0.8129 0.000 1.000 0.000 0.000 NA
#> SRR975576 2 0.0000 0.8129 0.000 1.000 0.000 0.000 NA
#> SRR975577 2 0.3730 0.7469 0.000 0.712 0.000 0.000 NA
#> SRR975578 2 0.3730 0.7469 0.000 0.712 0.000 0.000 NA
#> SRR975579 4 0.2588 0.7165 0.000 0.100 0.008 0.884 NA
#> SRR975580 2 0.5264 0.6221 0.000 0.676 0.000 0.128 NA
#> SRR975581 2 0.0000 0.8129 0.000 1.000 0.000 0.000 NA
#> SRR975582 2 0.3730 0.7469 0.000 0.712 0.000 0.000 NA
#> SRR975583 2 0.0000 0.8129 0.000 1.000 0.000 0.000 NA
#> SRR975584 2 0.3730 0.7469 0.000 0.712 0.000 0.000 NA
#> SRR975585 2 0.0000 0.8129 0.000 1.000 0.000 0.000 NA
#> SRR975586 2 0.4450 0.6282 0.000 0.760 0.000 0.132 NA
#> SRR975587 3 0.3210 0.7474 0.008 0.000 0.860 0.040 NA
#> SRR975588 2 0.0290 0.8130 0.000 0.992 0.000 0.000 NA
#> SRR975589 3 0.5814 0.6080 0.136 0.000 0.652 0.016 NA
#> SRR975590 3 0.6902 0.1891 0.324 0.000 0.392 0.004 NA
#> SRR975591 3 0.0290 0.7749 0.008 0.000 0.992 0.000 NA
#> SRR975592 3 0.4818 0.6767 0.100 0.000 0.720 0.000 NA
#> SRR975593 3 0.5814 0.6080 0.136 0.000 0.652 0.016 NA
#> SRR975594 3 0.3579 0.7085 0.000 0.000 0.828 0.072 NA
#> SRR975595 1 0.6665 0.1948 0.480 0.000 0.244 0.004 NA
#> SRR975597 1 0.6665 0.1948 0.480 0.000 0.244 0.004 NA
#> SRR975596 1 0.5197 0.5486 0.680 0.000 0.000 0.116 NA
#> SRR975598 1 0.6665 0.1948 0.480 0.000 0.244 0.004 NA
#> SRR975599 1 0.6280 0.3902 0.560 0.000 0.008 0.160 NA
#> SRR975600 3 0.1628 0.7679 0.008 0.000 0.936 0.000 NA
#> SRR975601 3 0.3229 0.7465 0.008 0.000 0.860 0.044 NA
#> SRR975602 1 0.4104 0.5870 0.748 0.000 0.000 0.032 NA
#> SRR975603 3 0.0290 0.7749 0.008 0.000 0.992 0.000 NA
#> SRR975604 3 0.0290 0.7749 0.008 0.000 0.992 0.000 NA
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.0000 0.6382 1.000 0.000 0.000 0.000 NA 0.000
#> SRR975552 1 0.0146 0.6383 0.996 0.000 0.000 0.000 NA 0.004
#> SRR975554 1 0.1909 0.6283 0.920 0.000 0.000 0.004 NA 0.052
#> SRR975553 2 0.4169 0.5570 0.000 0.532 0.000 0.012 NA 0.000
#> SRR975555 1 0.1003 0.6333 0.964 0.000 0.000 0.004 NA 0.028
#> SRR975556 2 0.2803 0.5613 0.000 0.872 0.000 0.012 NA 0.052
#> SRR975557 4 0.3390 0.7994 0.032 0.000 0.008 0.808 NA 0.152
#> SRR975558 6 0.3473 0.2404 0.192 0.000 0.004 0.024 NA 0.780
#> SRR975559 1 0.6042 0.4033 0.532 0.000 0.004 0.108 NA 0.320
#> SRR975560 6 0.5610 0.3060 0.004 0.252 0.000 0.016 NA 0.600
#> SRR975561 2 0.5454 -0.2994 0.000 0.460 0.000 0.020 NA 0.452
#> SRR975562 1 0.5304 0.4770 0.620 0.000 0.000 0.060 NA 0.280
#> SRR975563 2 0.0291 0.6778 0.000 0.992 0.000 0.004 NA 0.000
#> SRR975564 1 0.2214 0.6170 0.892 0.000 0.000 0.004 NA 0.092
#> SRR975565 1 0.0551 0.6368 0.984 0.000 0.000 0.004 NA 0.008
#> SRR975566 1 0.5469 0.5087 0.640 0.000 0.004 0.096 NA 0.228
#> SRR975567 6 0.3534 0.2405 0.200 0.000 0.004 0.024 NA 0.772
#> SRR975568 1 0.1080 0.6330 0.960 0.000 0.000 0.004 NA 0.032
#> SRR975569 2 0.0260 0.6819 0.000 0.992 0.000 0.000 NA 0.000
#> SRR975570 2 0.0260 0.6819 0.000 0.992 0.000 0.000 NA 0.000
#> SRR975571 2 0.4169 0.5570 0.000 0.532 0.000 0.012 NA 0.000
#> SRR975572 2 0.0146 0.6802 0.000 0.996 0.000 0.004 NA 0.000
#> SRR975573 2 0.3851 0.5645 0.000 0.540 0.000 0.000 NA 0.000
#> SRR975574 2 0.3851 0.5645 0.000 0.540 0.000 0.000 NA 0.000
#> SRR975575 2 0.0146 0.6802 0.000 0.996 0.000 0.004 NA 0.000
#> SRR975576 2 0.0000 0.6812 0.000 1.000 0.000 0.000 NA 0.000
#> SRR975577 2 0.3851 0.5645 0.000 0.540 0.000 0.000 NA 0.000
#> SRR975578 2 0.3851 0.5645 0.000 0.540 0.000 0.000 NA 0.000
#> SRR975579 4 0.3678 0.7855 0.000 0.016 0.000 0.748 NA 0.228
#> SRR975580 6 0.6181 0.0654 0.000 0.396 0.000 0.016 NA 0.408
#> SRR975581 2 0.0146 0.6802 0.000 0.996 0.000 0.004 NA 0.000
#> SRR975582 2 0.3851 0.5645 0.000 0.540 0.000 0.000 NA 0.000
#> SRR975583 2 0.0146 0.6802 0.000 0.996 0.000 0.004 NA 0.000
#> SRR975584 2 0.3851 0.5645 0.000 0.540 0.000 0.000 NA 0.000
#> SRR975585 2 0.0000 0.6812 0.000 1.000 0.000 0.000 NA 0.000
#> SRR975586 2 0.5358 -0.1037 0.000 0.544 0.000 0.020 NA 0.368
#> SRR975587 3 0.2979 0.7452 0.000 0.000 0.868 0.044 NA 0.036
#> SRR975588 2 0.0260 0.6819 0.000 0.992 0.000 0.000 NA 0.000
#> SRR975589 3 0.7006 0.5061 0.064 0.000 0.544 0.068 NA 0.224
#> SRR975590 1 0.7900 0.0190 0.316 0.000 0.280 0.060 NA 0.060
#> SRR975591 3 0.0000 0.7786 0.000 0.000 1.000 0.000 NA 0.000
#> SRR975592 3 0.6089 0.5980 0.088 0.000 0.648 0.048 NA 0.052
#> SRR975593 3 0.7006 0.5061 0.064 0.000 0.544 0.068 NA 0.224
#> SRR975594 3 0.4235 0.6787 0.000 0.000 0.780 0.064 NA 0.052
#> SRR975595 1 0.7595 0.2593 0.400 0.000 0.196 0.060 NA 0.048
#> SRR975597 1 0.7539 0.2632 0.408 0.000 0.196 0.060 NA 0.044
#> SRR975596 1 0.6100 0.4000 0.528 0.000 0.004 0.108 NA 0.320
#> SRR975598 1 0.7595 0.2593 0.400 0.000 0.196 0.060 NA 0.048
#> SRR975599 1 0.6868 0.2921 0.452 0.000 0.000 0.120 NA 0.120
#> SRR975600 3 0.2345 0.7562 0.000 0.000 0.904 0.028 NA 0.028
#> SRR975601 3 0.2985 0.7435 0.000 0.000 0.868 0.048 NA 0.040
#> SRR975602 1 0.5389 0.5221 0.664 0.000 0.000 0.060 NA 0.084
#> SRR975603 3 0.0000 0.7786 0.000 0.000 1.000 0.000 NA 0.000
#> SRR975604 3 0.0000 0.7786 0.000 0.000 1.000 0.000 NA 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "skmeans"]
# you can also extract it by
# res = res_list["SD:skmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 17171 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 4.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.970 0.988 0.5056 0.497 0.497
#> 3 3 0.925 0.926 0.966 0.3025 0.843 0.685
#> 4 4 0.902 0.861 0.937 0.0885 0.918 0.769
#> 5 5 0.815 0.695 0.838 0.0513 0.979 0.927
#> 6 6 0.722 0.600 0.732 0.0442 0.943 0.794
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3
There is also optional best \(k\) = 2 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR975551 1 0.000 0.977 1.000 0.000
#> SRR975552 1 0.000 0.977 1.000 0.000
#> SRR975554 1 0.000 0.977 1.000 0.000
#> SRR975553 2 0.000 1.000 0.000 1.000
#> SRR975555 1 0.000 0.977 1.000 0.000
#> SRR975556 2 0.000 1.000 0.000 1.000
#> SRR975557 1 0.000 0.977 1.000 0.000
#> SRR975558 1 0.955 0.417 0.624 0.376
#> SRR975559 1 0.000 0.977 1.000 0.000
#> SRR975560 2 0.000 1.000 0.000 1.000
#> SRR975561 2 0.000 1.000 0.000 1.000
#> SRR975562 1 0.000 0.977 1.000 0.000
#> SRR975563 2 0.000 1.000 0.000 1.000
#> SRR975564 1 0.000 0.977 1.000 0.000
#> SRR975565 1 0.000 0.977 1.000 0.000
#> SRR975566 1 0.000 0.977 1.000 0.000
#> SRR975567 1 0.866 0.604 0.712 0.288
#> SRR975568 1 0.000 0.977 1.000 0.000
#> SRR975569 2 0.000 1.000 0.000 1.000
#> SRR975570 2 0.000 1.000 0.000 1.000
#> SRR975571 2 0.000 1.000 0.000 1.000
#> SRR975572 2 0.000 1.000 0.000 1.000
#> SRR975573 2 0.000 1.000 0.000 1.000
#> SRR975574 2 0.000 1.000 0.000 1.000
#> SRR975575 2 0.000 1.000 0.000 1.000
#> SRR975576 2 0.000 1.000 0.000 1.000
#> SRR975577 2 0.000 1.000 0.000 1.000
#> SRR975578 2 0.000 1.000 0.000 1.000
#> SRR975579 2 0.000 1.000 0.000 1.000
#> SRR975580 2 0.000 1.000 0.000 1.000
#> SRR975581 2 0.000 1.000 0.000 1.000
#> SRR975582 2 0.000 1.000 0.000 1.000
#> SRR975583 2 0.000 1.000 0.000 1.000
#> SRR975584 2 0.000 1.000 0.000 1.000
#> SRR975585 2 0.000 1.000 0.000 1.000
#> SRR975586 2 0.000 1.000 0.000 1.000
#> SRR975587 1 0.000 0.977 1.000 0.000
#> SRR975588 2 0.000 1.000 0.000 1.000
#> SRR975589 1 0.000 0.977 1.000 0.000
#> SRR975590 1 0.000 0.977 1.000 0.000
#> SRR975591 1 0.000 0.977 1.000 0.000
#> SRR975592 1 0.000 0.977 1.000 0.000
#> SRR975593 1 0.000 0.977 1.000 0.000
#> SRR975594 1 0.000 0.977 1.000 0.000
#> SRR975595 1 0.000 0.977 1.000 0.000
#> SRR975597 1 0.000 0.977 1.000 0.000
#> SRR975596 1 0.000 0.977 1.000 0.000
#> SRR975598 1 0.000 0.977 1.000 0.000
#> SRR975599 1 0.000 0.977 1.000 0.000
#> SRR975600 1 0.000 0.977 1.000 0.000
#> SRR975601 1 0.000 0.977 1.000 0.000
#> SRR975602 1 0.000 0.977 1.000 0.000
#> SRR975603 1 0.000 0.977 1.000 0.000
#> SRR975604 1 0.000 0.977 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.0000 1.000 1.000 0 0.000
#> SRR975552 1 0.0000 1.000 1.000 0 0.000
#> SRR975554 1 0.0000 1.000 1.000 0 0.000
#> SRR975553 2 0.0000 1.000 0.000 1 0.000
#> SRR975555 1 0.0000 1.000 1.000 0 0.000
#> SRR975556 2 0.0000 1.000 0.000 1 0.000
#> SRR975557 3 0.6062 0.380 0.384 0 0.616
#> SRR975558 1 0.0000 1.000 1.000 0 0.000
#> SRR975559 1 0.0000 1.000 1.000 0 0.000
#> SRR975560 2 0.0000 1.000 0.000 1 0.000
#> SRR975561 2 0.0000 1.000 0.000 1 0.000
#> SRR975562 1 0.0000 1.000 1.000 0 0.000
#> SRR975563 2 0.0000 1.000 0.000 1 0.000
#> SRR975564 1 0.0000 1.000 1.000 0 0.000
#> SRR975565 1 0.0000 1.000 1.000 0 0.000
#> SRR975566 1 0.0000 1.000 1.000 0 0.000
#> SRR975567 1 0.0000 1.000 1.000 0 0.000
#> SRR975568 1 0.0000 1.000 1.000 0 0.000
#> SRR975569 2 0.0000 1.000 0.000 1 0.000
#> SRR975570 2 0.0000 1.000 0.000 1 0.000
#> SRR975571 2 0.0000 1.000 0.000 1 0.000
#> SRR975572 2 0.0000 1.000 0.000 1 0.000
#> SRR975573 2 0.0000 1.000 0.000 1 0.000
#> SRR975574 2 0.0000 1.000 0.000 1 0.000
#> SRR975575 2 0.0000 1.000 0.000 1 0.000
#> SRR975576 2 0.0000 1.000 0.000 1 0.000
#> SRR975577 2 0.0000 1.000 0.000 1 0.000
#> SRR975578 2 0.0000 1.000 0.000 1 0.000
#> SRR975579 2 0.0000 1.000 0.000 1 0.000
#> SRR975580 2 0.0000 1.000 0.000 1 0.000
#> SRR975581 2 0.0000 1.000 0.000 1 0.000
#> SRR975582 2 0.0000 1.000 0.000 1 0.000
#> SRR975583 2 0.0000 1.000 0.000 1 0.000
#> SRR975584 2 0.0000 1.000 0.000 1 0.000
#> SRR975585 2 0.0000 1.000 0.000 1 0.000
#> SRR975586 2 0.0000 1.000 0.000 1 0.000
#> SRR975587 3 0.0000 0.868 0.000 0 1.000
#> SRR975588 2 0.0000 1.000 0.000 1 0.000
#> SRR975589 3 0.0747 0.865 0.016 0 0.984
#> SRR975590 3 0.4654 0.725 0.208 0 0.792
#> SRR975591 3 0.0000 0.868 0.000 0 1.000
#> SRR975592 3 0.0592 0.866 0.012 0 0.988
#> SRR975593 3 0.0592 0.866 0.012 0 0.988
#> SRR975594 3 0.0000 0.868 0.000 0 1.000
#> SRR975595 3 0.6126 0.464 0.400 0 0.600
#> SRR975597 3 0.6126 0.464 0.400 0 0.600
#> SRR975596 1 0.0000 1.000 1.000 0 0.000
#> SRR975598 3 0.6126 0.464 0.400 0 0.600
#> SRR975599 3 0.1031 0.858 0.024 0 0.976
#> SRR975600 3 0.0000 0.868 0.000 0 1.000
#> SRR975601 3 0.0000 0.868 0.000 0 1.000
#> SRR975602 1 0.0000 1.000 1.000 0 0.000
#> SRR975603 3 0.0000 0.868 0.000 0 1.000
#> SRR975604 3 0.0000 0.868 0.000 0 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0000 0.897 1.000 0.000 0.000 0.000
#> SRR975552 1 0.0000 0.897 1.000 0.000 0.000 0.000
#> SRR975554 1 0.0000 0.897 1.000 0.000 0.000 0.000
#> SRR975553 2 0.0336 0.982 0.000 0.992 0.000 0.008
#> SRR975555 1 0.0000 0.897 1.000 0.000 0.000 0.000
#> SRR975556 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975557 4 0.2676 0.862 0.092 0.000 0.012 0.896
#> SRR975558 4 0.1792 0.897 0.068 0.000 0.000 0.932
#> SRR975559 1 0.4804 0.345 0.616 0.000 0.000 0.384
#> SRR975560 4 0.1792 0.876 0.000 0.068 0.000 0.932
#> SRR975561 2 0.3610 0.751 0.000 0.800 0.000 0.200
#> SRR975562 1 0.0817 0.883 0.976 0.000 0.000 0.024
#> SRR975563 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975564 1 0.0000 0.897 1.000 0.000 0.000 0.000
#> SRR975565 1 0.0000 0.897 1.000 0.000 0.000 0.000
#> SRR975566 1 0.0469 0.891 0.988 0.000 0.000 0.012
#> SRR975567 4 0.1792 0.897 0.068 0.000 0.000 0.932
#> SRR975568 1 0.0000 0.897 1.000 0.000 0.000 0.000
#> SRR975569 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0336 0.982 0.000 0.992 0.000 0.008
#> SRR975572 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0336 0.982 0.000 0.992 0.000 0.008
#> SRR975574 2 0.0336 0.982 0.000 0.992 0.000 0.008
#> SRR975575 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0336 0.982 0.000 0.992 0.000 0.008
#> SRR975578 2 0.0336 0.982 0.000 0.992 0.000 0.008
#> SRR975579 4 0.2401 0.864 0.000 0.092 0.004 0.904
#> SRR975580 2 0.0336 0.982 0.000 0.992 0.000 0.008
#> SRR975581 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975582 2 0.0336 0.982 0.000 0.992 0.000 0.008
#> SRR975583 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0336 0.982 0.000 0.992 0.000 0.008
#> SRR975585 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975586 2 0.1867 0.917 0.000 0.928 0.000 0.072
#> SRR975587 3 0.0000 0.850 0.000 0.000 1.000 0.000
#> SRR975588 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975589 3 0.1059 0.841 0.016 0.000 0.972 0.012
#> SRR975590 3 0.4331 0.646 0.288 0.000 0.712 0.000
#> SRR975591 3 0.0000 0.850 0.000 0.000 1.000 0.000
#> SRR975592 3 0.0188 0.850 0.004 0.000 0.996 0.000
#> SRR975593 3 0.0657 0.845 0.004 0.000 0.984 0.012
#> SRR975594 3 0.0469 0.844 0.000 0.000 0.988 0.012
#> SRR975595 3 0.4916 0.455 0.424 0.000 0.576 0.000
#> SRR975597 3 0.4916 0.455 0.424 0.000 0.576 0.000
#> SRR975596 1 0.4817 0.335 0.612 0.000 0.000 0.388
#> SRR975598 3 0.4933 0.438 0.432 0.000 0.568 0.000
#> SRR975599 1 0.4761 0.659 0.764 0.000 0.192 0.044
#> SRR975600 3 0.0000 0.850 0.000 0.000 1.000 0.000
#> SRR975601 3 0.0000 0.850 0.000 0.000 1.000 0.000
#> SRR975602 1 0.0000 0.897 1.000 0.000 0.000 0.000
#> SRR975603 3 0.0000 0.850 0.000 0.000 1.000 0.000
#> SRR975604 3 0.0000 0.850 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.0404 0.7622 0.988 0.000 0.000 0.000 0.012
#> SRR975552 1 0.0162 0.7664 0.996 0.000 0.000 0.000 0.004
#> SRR975554 1 0.0794 0.7655 0.972 0.000 0.000 0.000 0.028
#> SRR975553 2 0.1851 0.9018 0.000 0.912 0.000 0.000 0.088
#> SRR975555 1 0.1041 0.7548 0.964 0.000 0.000 0.004 0.032
#> SRR975556 2 0.1485 0.8812 0.000 0.948 0.000 0.032 0.020
#> SRR975557 4 0.4295 0.1097 0.032 0.000 0.012 0.760 0.196
#> SRR975558 5 0.5525 0.9863 0.124 0.000 0.000 0.240 0.636
#> SRR975559 1 0.5032 0.1287 0.520 0.000 0.000 0.032 0.448
#> SRR975560 4 0.4227 0.1383 0.000 0.016 0.000 0.692 0.292
#> SRR975561 4 0.4900 0.1029 0.000 0.464 0.000 0.512 0.024
#> SRR975562 1 0.3928 0.5525 0.700 0.000 0.000 0.004 0.296
#> SRR975563 2 0.0162 0.9143 0.000 0.996 0.000 0.004 0.000
#> SRR975564 1 0.1357 0.7586 0.948 0.000 0.000 0.004 0.048
#> SRR975565 1 0.0566 0.7664 0.984 0.000 0.000 0.004 0.012
#> SRR975566 1 0.3508 0.5947 0.748 0.000 0.000 0.000 0.252
#> SRR975567 5 0.5531 0.9862 0.120 0.000 0.000 0.248 0.632
#> SRR975568 1 0.0955 0.7652 0.968 0.000 0.000 0.004 0.028
#> SRR975569 2 0.0000 0.9145 0.000 1.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.9145 0.000 1.000 0.000 0.000 0.000
#> SRR975571 2 0.1851 0.9018 0.000 0.912 0.000 0.000 0.088
#> SRR975572 2 0.0162 0.9143 0.000 0.996 0.000 0.004 0.000
#> SRR975573 2 0.1851 0.9018 0.000 0.912 0.000 0.000 0.088
#> SRR975574 2 0.1851 0.9018 0.000 0.912 0.000 0.000 0.088
#> SRR975575 2 0.0162 0.9143 0.000 0.996 0.000 0.004 0.000
#> SRR975576 2 0.0162 0.9143 0.000 0.996 0.000 0.004 0.000
#> SRR975577 2 0.1851 0.9018 0.000 0.912 0.000 0.000 0.088
#> SRR975578 2 0.1851 0.9018 0.000 0.912 0.000 0.000 0.088
#> SRR975579 4 0.2104 0.3985 0.000 0.060 0.000 0.916 0.024
#> SRR975580 2 0.4528 0.7364 0.000 0.752 0.000 0.144 0.104
#> SRR975581 2 0.0162 0.9143 0.000 0.996 0.000 0.004 0.000
#> SRR975582 2 0.1851 0.9018 0.000 0.912 0.000 0.000 0.088
#> SRR975583 2 0.0162 0.9143 0.000 0.996 0.000 0.004 0.000
#> SRR975584 2 0.1851 0.9018 0.000 0.912 0.000 0.000 0.088
#> SRR975585 2 0.0162 0.9143 0.000 0.996 0.000 0.004 0.000
#> SRR975586 2 0.4861 -0.0591 0.000 0.548 0.000 0.428 0.024
#> SRR975587 3 0.0510 0.7789 0.000 0.000 0.984 0.000 0.016
#> SRR975588 2 0.0000 0.9145 0.000 1.000 0.000 0.000 0.000
#> SRR975589 3 0.3086 0.6720 0.004 0.000 0.816 0.000 0.180
#> SRR975590 3 0.5864 0.5285 0.300 0.000 0.572 0.000 0.128
#> SRR975591 3 0.0000 0.7791 0.000 0.000 1.000 0.000 0.000
#> SRR975592 3 0.1582 0.7703 0.028 0.000 0.944 0.000 0.028
#> SRR975593 3 0.2891 0.6782 0.000 0.000 0.824 0.000 0.176
#> SRR975594 3 0.1300 0.7692 0.000 0.000 0.956 0.028 0.016
#> SRR975595 3 0.6567 0.3638 0.360 0.000 0.432 0.000 0.208
#> SRR975597 3 0.6567 0.3638 0.360 0.000 0.432 0.000 0.208
#> SRR975596 1 0.5100 0.1169 0.516 0.000 0.000 0.036 0.448
#> SRR975598 3 0.6582 0.3284 0.376 0.000 0.416 0.000 0.208
#> SRR975599 1 0.7572 0.3331 0.500 0.000 0.104 0.168 0.228
#> SRR975600 3 0.0000 0.7791 0.000 0.000 1.000 0.000 0.000
#> SRR975601 3 0.0510 0.7789 0.000 0.000 0.984 0.000 0.016
#> SRR975602 1 0.3003 0.6518 0.812 0.000 0.000 0.000 0.188
#> SRR975603 3 0.0000 0.7791 0.000 0.000 1.000 0.000 0.000
#> SRR975604 3 0.0000 0.7791 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.1141 0.715 0.948 0.000 0.000 0.000 0.052 0.000
#> SRR975552 1 0.1010 0.726 0.960 0.000 0.000 0.000 0.036 0.004
#> SRR975554 1 0.0865 0.729 0.964 0.000 0.000 0.000 0.036 0.000
#> SRR975553 2 0.0000 0.724 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975555 1 0.1812 0.702 0.912 0.000 0.000 0.000 0.080 0.008
#> SRR975556 2 0.3864 0.385 0.000 0.520 0.000 0.000 0.000 0.480
#> SRR975557 4 0.0551 0.827 0.000 0.000 0.004 0.984 0.008 0.004
#> SRR975558 5 0.6812 -0.108 0.048 0.000 0.008 0.180 0.436 0.328
#> SRR975559 1 0.7088 0.324 0.436 0.000 0.000 0.140 0.284 0.140
#> SRR975560 6 0.5409 -0.247 0.000 0.008 0.000 0.176 0.204 0.612
#> SRR975561 6 0.5542 0.526 0.000 0.232 0.000 0.188 0.004 0.576
#> SRR975562 1 0.6206 0.451 0.552 0.000 0.000 0.056 0.252 0.140
#> SRR975563 2 0.3330 0.751 0.000 0.716 0.000 0.000 0.000 0.284
#> SRR975564 1 0.2019 0.715 0.900 0.000 0.000 0.000 0.088 0.012
#> SRR975565 1 0.0632 0.727 0.976 0.000 0.000 0.000 0.024 0.000
#> SRR975566 1 0.4372 0.628 0.744 0.000 0.000 0.040 0.176 0.040
#> SRR975567 5 0.6716 -0.105 0.048 0.000 0.004 0.180 0.440 0.328
#> SRR975568 1 0.1434 0.719 0.940 0.000 0.000 0.000 0.048 0.012
#> SRR975569 2 0.3266 0.761 0.000 0.728 0.000 0.000 0.000 0.272
#> SRR975570 2 0.3266 0.761 0.000 0.728 0.000 0.000 0.000 0.272
#> SRR975571 2 0.0000 0.724 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975572 2 0.3266 0.761 0.000 0.728 0.000 0.000 0.000 0.272
#> SRR975573 2 0.0000 0.724 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975574 2 0.0000 0.724 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975575 2 0.3266 0.761 0.000 0.728 0.000 0.000 0.000 0.272
#> SRR975576 2 0.3309 0.755 0.000 0.720 0.000 0.000 0.000 0.280
#> SRR975577 2 0.0000 0.724 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975578 2 0.0000 0.724 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975579 4 0.2146 0.815 0.000 0.004 0.000 0.880 0.000 0.116
#> SRR975580 2 0.3872 -0.088 0.000 0.604 0.000 0.004 0.000 0.392
#> SRR975581 2 0.3288 0.758 0.000 0.724 0.000 0.000 0.000 0.276
#> SRR975582 2 0.0000 0.724 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975583 2 0.3266 0.761 0.000 0.728 0.000 0.000 0.000 0.272
#> SRR975584 2 0.0000 0.724 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975585 2 0.3266 0.761 0.000 0.728 0.000 0.000 0.000 0.272
#> SRR975586 6 0.4989 0.487 0.000 0.248 0.000 0.108 0.004 0.640
#> SRR975587 3 0.1806 0.842 0.000 0.000 0.908 0.000 0.088 0.004
#> SRR975588 2 0.3266 0.761 0.000 0.728 0.000 0.000 0.000 0.272
#> SRR975589 3 0.3182 0.774 0.012 0.000 0.852 0.016 0.096 0.024
#> SRR975590 3 0.5625 0.114 0.192 0.000 0.532 0.000 0.276 0.000
#> SRR975591 3 0.0000 0.862 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975592 3 0.1812 0.838 0.008 0.000 0.912 0.000 0.080 0.000
#> SRR975593 3 0.3131 0.773 0.008 0.000 0.852 0.016 0.100 0.024
#> SRR975594 3 0.2493 0.826 0.000 0.000 0.884 0.036 0.076 0.004
#> SRR975595 5 0.6034 0.290 0.260 0.000 0.328 0.000 0.412 0.000
#> SRR975597 5 0.6044 0.290 0.264 0.000 0.328 0.000 0.408 0.000
#> SRR975596 1 0.7198 0.319 0.432 0.000 0.004 0.136 0.288 0.140
#> SRR975598 5 0.6039 0.296 0.264 0.000 0.324 0.000 0.412 0.000
#> SRR975599 5 0.6740 -0.064 0.288 0.000 0.036 0.244 0.428 0.004
#> SRR975600 3 0.0000 0.862 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975601 3 0.2001 0.838 0.000 0.000 0.900 0.004 0.092 0.004
#> SRR975602 1 0.3508 0.493 0.704 0.000 0.000 0.004 0.292 0.000
#> SRR975603 3 0.0000 0.862 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975604 3 0.0000 0.862 0.000 0.000 1.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "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 17171 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 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.961 0.948 0.978 0.5062 0.497 0.497
#> 3 3 0.940 0.891 0.959 0.2866 0.820 0.650
#> 4 4 0.961 0.936 0.971 0.1017 0.855 0.625
#> 5 5 0.892 0.785 0.894 0.0453 0.970 0.894
#> 6 6 0.845 0.789 0.893 0.0400 0.964 0.866
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3
There is also optional best \(k\) = 2 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR975551 1 0.000 0.958 1.000 0.000
#> SRR975552 1 0.680 0.778 0.820 0.180
#> SRR975554 1 0.000 0.958 1.000 0.000
#> SRR975553 2 0.000 1.000 0.000 1.000
#> SRR975555 1 0.000 0.958 1.000 0.000
#> SRR975556 2 0.000 1.000 0.000 1.000
#> SRR975557 1 0.706 0.762 0.808 0.192
#> SRR975558 1 0.971 0.389 0.600 0.400
#> SRR975559 1 0.000 0.958 1.000 0.000
#> SRR975560 2 0.000 1.000 0.000 1.000
#> SRR975561 2 0.000 1.000 0.000 1.000
#> SRR975562 1 0.000 0.958 1.000 0.000
#> SRR975563 2 0.000 1.000 0.000 1.000
#> SRR975564 1 0.000 0.958 1.000 0.000
#> SRR975565 1 0.000 0.958 1.000 0.000
#> SRR975566 1 0.000 0.958 1.000 0.000
#> SRR975567 1 0.971 0.389 0.600 0.400
#> SRR975568 1 0.000 0.958 1.000 0.000
#> SRR975569 2 0.000 1.000 0.000 1.000
#> SRR975570 2 0.000 1.000 0.000 1.000
#> SRR975571 2 0.000 1.000 0.000 1.000
#> SRR975572 2 0.000 1.000 0.000 1.000
#> SRR975573 2 0.000 1.000 0.000 1.000
#> SRR975574 2 0.000 1.000 0.000 1.000
#> SRR975575 2 0.000 1.000 0.000 1.000
#> SRR975576 2 0.000 1.000 0.000 1.000
#> SRR975577 2 0.000 1.000 0.000 1.000
#> SRR975578 2 0.000 1.000 0.000 1.000
#> SRR975579 2 0.000 1.000 0.000 1.000
#> SRR975580 2 0.000 1.000 0.000 1.000
#> SRR975581 2 0.000 1.000 0.000 1.000
#> SRR975582 2 0.000 1.000 0.000 1.000
#> SRR975583 2 0.000 1.000 0.000 1.000
#> SRR975584 2 0.000 1.000 0.000 1.000
#> SRR975585 2 0.000 1.000 0.000 1.000
#> SRR975586 2 0.000 1.000 0.000 1.000
#> SRR975587 1 0.000 0.958 1.000 0.000
#> SRR975588 2 0.000 1.000 0.000 1.000
#> SRR975589 1 0.000 0.958 1.000 0.000
#> SRR975590 1 0.000 0.958 1.000 0.000
#> SRR975591 1 0.000 0.958 1.000 0.000
#> SRR975592 1 0.000 0.958 1.000 0.000
#> SRR975593 1 0.000 0.958 1.000 0.000
#> SRR975594 1 0.000 0.958 1.000 0.000
#> SRR975595 1 0.000 0.958 1.000 0.000
#> SRR975597 1 0.000 0.958 1.000 0.000
#> SRR975596 1 0.000 0.958 1.000 0.000
#> SRR975598 1 0.000 0.958 1.000 0.000
#> SRR975599 1 0.163 0.939 0.976 0.024
#> SRR975600 1 0.000 0.958 1.000 0.000
#> SRR975601 1 0.000 0.958 1.000 0.000
#> SRR975602 1 0.000 0.958 1.000 0.000
#> SRR975603 1 0.000 0.958 1.000 0.000
#> SRR975604 1 0.000 0.958 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.0000 0.929 1.000 0.000 0.000
#> SRR975552 1 0.0000 0.929 1.000 0.000 0.000
#> SRR975554 1 0.0000 0.929 1.000 0.000 0.000
#> SRR975553 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975555 1 0.0000 0.929 1.000 0.000 0.000
#> SRR975556 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975557 3 0.6126 0.292 0.400 0.000 0.600
#> SRR975558 2 0.6225 0.233 0.432 0.568 0.000
#> SRR975559 1 0.0000 0.929 1.000 0.000 0.000
#> SRR975560 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975561 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975562 1 0.0000 0.929 1.000 0.000 0.000
#> SRR975563 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975564 1 0.0000 0.929 1.000 0.000 0.000
#> SRR975565 1 0.0000 0.929 1.000 0.000 0.000
#> SRR975566 1 0.0000 0.929 1.000 0.000 0.000
#> SRR975567 1 0.1529 0.891 0.960 0.040 0.000
#> SRR975568 1 0.0000 0.929 1.000 0.000 0.000
#> SRR975569 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975571 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975572 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975573 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975574 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975575 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975577 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975578 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975579 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975580 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975581 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975582 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975583 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975584 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975585 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975586 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975587 3 0.0000 0.918 0.000 0.000 1.000
#> SRR975588 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975589 3 0.0000 0.918 0.000 0.000 1.000
#> SRR975590 3 0.6111 0.283 0.396 0.000 0.604
#> SRR975591 3 0.0000 0.918 0.000 0.000 1.000
#> SRR975592 3 0.0424 0.912 0.008 0.000 0.992
#> SRR975593 3 0.0000 0.918 0.000 0.000 1.000
#> SRR975594 3 0.0000 0.918 0.000 0.000 1.000
#> SRR975595 1 0.5327 0.602 0.728 0.000 0.272
#> SRR975597 1 0.6026 0.373 0.624 0.000 0.376
#> SRR975596 1 0.0592 0.922 0.988 0.000 0.012
#> SRR975598 1 0.2625 0.862 0.916 0.000 0.084
#> SRR975599 1 0.5470 0.718 0.796 0.036 0.168
#> SRR975600 3 0.0000 0.918 0.000 0.000 1.000
#> SRR975601 3 0.0000 0.918 0.000 0.000 1.000
#> SRR975602 1 0.0000 0.929 1.000 0.000 0.000
#> SRR975603 3 0.0000 0.918 0.000 0.000 1.000
#> SRR975604 3 0.0000 0.918 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 4 0.3569 0.798 0.196 0.000 0.000 0.804
#> SRR975552 1 0.0000 0.931 1.000 0.000 0.000 0.000
#> SRR975554 1 0.0336 0.926 0.992 0.000 0.000 0.008
#> SRR975553 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975555 4 0.4898 0.420 0.416 0.000 0.000 0.584
#> SRR975556 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975557 1 0.0000 0.931 1.000 0.000 0.000 0.000
#> SRR975558 1 0.0524 0.924 0.988 0.008 0.000 0.004
#> SRR975559 1 0.0000 0.931 1.000 0.000 0.000 0.000
#> SRR975560 1 0.3610 0.690 0.800 0.200 0.000 0.000
#> SRR975561 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975562 1 0.0000 0.931 1.000 0.000 0.000 0.000
#> SRR975563 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975564 1 0.3444 0.700 0.816 0.000 0.000 0.184
#> SRR975565 1 0.0188 0.930 0.996 0.000 0.000 0.004
#> SRR975566 1 0.0000 0.931 1.000 0.000 0.000 0.000
#> SRR975567 1 0.0000 0.931 1.000 0.000 0.000 0.000
#> SRR975568 1 0.0188 0.930 0.996 0.000 0.000 0.004
#> SRR975569 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975572 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975574 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975575 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975578 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975579 1 0.3610 0.690 0.800 0.200 0.000 0.000
#> SRR975580 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975581 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975582 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975583 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975585 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975586 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975587 3 0.0000 0.996 0.000 0.000 1.000 0.000
#> SRR975588 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975589 3 0.0000 0.996 0.000 0.000 1.000 0.000
#> SRR975590 4 0.0188 0.863 0.000 0.000 0.004 0.996
#> SRR975591 3 0.0000 0.996 0.000 0.000 1.000 0.000
#> SRR975592 3 0.1022 0.964 0.000 0.000 0.968 0.032
#> SRR975593 3 0.0000 0.996 0.000 0.000 1.000 0.000
#> SRR975594 3 0.0000 0.996 0.000 0.000 1.000 0.000
#> SRR975595 4 0.0188 0.863 0.000 0.000 0.004 0.996
#> SRR975597 4 0.0188 0.863 0.000 0.000 0.004 0.996
#> SRR975596 1 0.0000 0.931 1.000 0.000 0.000 0.000
#> SRR975598 4 0.0188 0.863 0.000 0.000 0.004 0.996
#> SRR975599 4 0.1940 0.856 0.076 0.000 0.000 0.924
#> SRR975600 3 0.0000 0.996 0.000 0.000 1.000 0.000
#> SRR975601 3 0.0000 0.996 0.000 0.000 1.000 0.000
#> SRR975602 4 0.3610 0.797 0.200 0.000 0.000 0.800
#> SRR975603 3 0.0000 0.996 0.000 0.000 1.000 0.000
#> SRR975604 3 0.0000 0.996 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 5 0.3707 0.669 0.284 0.000 0.000 0.000 0.716
#> SRR975552 1 0.4359 0.533 0.584 0.000 0.000 0.412 0.004
#> SRR975554 1 0.1831 0.548 0.920 0.000 0.000 0.076 0.004
#> SRR975553 2 0.1671 0.945 0.000 0.924 0.000 0.076 0.000
#> SRR975555 1 0.4287 -0.440 0.540 0.000 0.000 0.000 0.460
#> SRR975556 2 0.0000 0.959 0.000 1.000 0.000 0.000 0.000
#> SRR975557 4 0.2179 0.428 0.112 0.000 0.000 0.888 0.000
#> SRR975558 1 0.4283 0.492 0.644 0.008 0.000 0.348 0.000
#> SRR975559 1 0.4015 0.592 0.652 0.000 0.000 0.348 0.000
#> SRR975560 1 0.5995 0.142 0.468 0.112 0.000 0.420 0.000
#> SRR975561 2 0.1043 0.936 0.000 0.960 0.000 0.040 0.000
#> SRR975562 1 0.4015 0.592 0.652 0.000 0.000 0.348 0.000
#> SRR975563 2 0.0000 0.959 0.000 1.000 0.000 0.000 0.000
#> SRR975564 1 0.3318 0.339 0.800 0.000 0.000 0.008 0.192
#> SRR975565 1 0.0162 0.528 0.996 0.000 0.000 0.000 0.004
#> SRR975566 1 0.3752 0.596 0.708 0.000 0.000 0.292 0.000
#> SRR975567 1 0.4283 0.486 0.544 0.000 0.000 0.456 0.000
#> SRR975568 1 0.0162 0.528 0.996 0.000 0.000 0.000 0.004
#> SRR975569 2 0.0000 0.959 0.000 1.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.959 0.000 1.000 0.000 0.000 0.000
#> SRR975571 2 0.1671 0.945 0.000 0.924 0.000 0.076 0.000
#> SRR975572 2 0.0000 0.959 0.000 1.000 0.000 0.000 0.000
#> SRR975573 2 0.1671 0.945 0.000 0.924 0.000 0.076 0.000
#> SRR975574 2 0.1671 0.945 0.000 0.924 0.000 0.076 0.000
#> SRR975575 2 0.0000 0.959 0.000 1.000 0.000 0.000 0.000
#> SRR975576 2 0.0000 0.959 0.000 1.000 0.000 0.000 0.000
#> SRR975577 2 0.1671 0.945 0.000 0.924 0.000 0.076 0.000
#> SRR975578 2 0.1671 0.945 0.000 0.924 0.000 0.076 0.000
#> SRR975579 4 0.2377 0.555 0.000 0.128 0.000 0.872 0.000
#> SRR975580 2 0.2179 0.921 0.000 0.888 0.000 0.112 0.000
#> SRR975581 2 0.0000 0.959 0.000 1.000 0.000 0.000 0.000
#> SRR975582 2 0.1671 0.945 0.000 0.924 0.000 0.076 0.000
#> SRR975583 2 0.0000 0.959 0.000 1.000 0.000 0.000 0.000
#> SRR975584 2 0.1671 0.945 0.000 0.924 0.000 0.076 0.000
#> SRR975585 2 0.0000 0.959 0.000 1.000 0.000 0.000 0.000
#> SRR975586 2 0.0963 0.939 0.000 0.964 0.000 0.036 0.000
#> SRR975587 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000
#> SRR975588 2 0.0000 0.959 0.000 1.000 0.000 0.000 0.000
#> SRR975589 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000
#> SRR975590 5 0.0000 0.813 0.000 0.000 0.000 0.000 1.000
#> SRR975591 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000
#> SRR975592 3 0.0880 0.962 0.000 0.000 0.968 0.000 0.032
#> SRR975593 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000
#> SRR975594 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000
#> SRR975595 5 0.0000 0.813 0.000 0.000 0.000 0.000 1.000
#> SRR975597 5 0.0000 0.813 0.000 0.000 0.000 0.000 1.000
#> SRR975596 1 0.4015 0.592 0.652 0.000 0.000 0.348 0.000
#> SRR975598 5 0.0000 0.813 0.000 0.000 0.000 0.000 1.000
#> SRR975599 5 0.6031 0.452 0.352 0.000 0.000 0.128 0.520
#> SRR975600 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000
#> SRR975601 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000
#> SRR975602 5 0.3852 0.691 0.220 0.000 0.000 0.020 0.760
#> SRR975603 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000
#> SRR975604 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.3330 0.64464 0.716 0.000 0.000 0.000 0.284 0.000
#> SRR975552 6 0.3152 0.45098 0.196 0.000 0.000 0.004 0.008 0.792
#> SRR975554 5 0.3797 0.19283 0.000 0.000 0.000 0.000 0.580 0.420
#> SRR975553 2 0.3288 0.78836 0.000 0.724 0.000 0.276 0.000 0.000
#> SRR975555 5 0.0632 0.83083 0.024 0.000 0.000 0.000 0.976 0.000
#> SRR975556 2 0.0000 0.86621 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975557 4 0.3555 0.55434 0.000 0.000 0.000 0.712 0.008 0.280
#> SRR975558 6 0.3398 0.43403 0.000 0.000 0.000 0.008 0.252 0.740
#> SRR975559 6 0.2738 0.68486 0.000 0.000 0.000 0.004 0.176 0.820
#> SRR975560 6 0.5244 0.00469 0.000 0.336 0.000 0.112 0.000 0.552
#> SRR975561 2 0.0508 0.86089 0.000 0.984 0.000 0.012 0.000 0.004
#> SRR975562 6 0.2738 0.68486 0.000 0.000 0.000 0.004 0.176 0.820
#> SRR975563 2 0.0000 0.86621 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975564 5 0.0806 0.83365 0.020 0.000 0.000 0.000 0.972 0.008
#> SRR975565 5 0.0632 0.83471 0.000 0.000 0.000 0.000 0.976 0.024
#> SRR975566 6 0.2948 0.67124 0.000 0.000 0.000 0.008 0.188 0.804
#> SRR975567 6 0.0260 0.59209 0.000 0.000 0.000 0.008 0.000 0.992
#> SRR975568 5 0.0632 0.83471 0.000 0.000 0.000 0.000 0.976 0.024
#> SRR975569 2 0.0000 0.86621 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.86621 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975571 2 0.3288 0.78836 0.000 0.724 0.000 0.276 0.000 0.000
#> SRR975572 2 0.0000 0.86621 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975573 2 0.3221 0.79286 0.000 0.736 0.000 0.264 0.000 0.000
#> SRR975574 2 0.3266 0.79007 0.000 0.728 0.000 0.272 0.000 0.000
#> SRR975575 2 0.0000 0.86621 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975576 2 0.0000 0.86621 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975577 2 0.3288 0.78836 0.000 0.724 0.000 0.276 0.000 0.000
#> SRR975578 2 0.3288 0.78836 0.000 0.724 0.000 0.276 0.000 0.000
#> SRR975579 4 0.1251 0.62252 0.000 0.012 0.000 0.956 0.008 0.024
#> SRR975580 2 0.3448 0.78269 0.000 0.716 0.000 0.280 0.000 0.004
#> SRR975581 2 0.0000 0.86621 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975582 2 0.3266 0.79007 0.000 0.728 0.000 0.272 0.000 0.000
#> SRR975583 2 0.0000 0.86621 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975584 2 0.3288 0.78836 0.000 0.724 0.000 0.276 0.000 0.000
#> SRR975585 2 0.0000 0.86621 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975586 2 0.0291 0.86158 0.000 0.992 0.000 0.004 0.000 0.004
#> SRR975587 3 0.0000 0.99526 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975588 2 0.0000 0.86621 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975589 3 0.0000 0.99526 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975590 1 0.0000 0.86334 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR975591 3 0.0000 0.99526 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975592 3 0.0865 0.95631 0.036 0.000 0.964 0.000 0.000 0.000
#> SRR975593 3 0.0000 0.99526 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975594 3 0.0000 0.99526 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975595 1 0.0000 0.86334 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR975597 1 0.0000 0.86334 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR975596 6 0.2738 0.68486 0.000 0.000 0.000 0.004 0.176 0.820
#> SRR975598 1 0.0000 0.86334 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR975599 5 0.2915 0.65384 0.184 0.000 0.000 0.008 0.808 0.000
#> SRR975600 3 0.0000 0.99526 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975601 3 0.0000 0.99526 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975602 1 0.3652 0.70502 0.760 0.000 0.000 0.008 0.212 0.020
#> SRR975603 3 0.0000 0.99526 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975604 3 0.0000 0.99526 0.000 0.000 1.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "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 17171 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 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.547 0.933 0.938 0.4503 0.547 0.547
#> 3 3 0.700 0.727 0.840 0.4788 0.776 0.591
#> 4 4 0.800 0.899 0.920 0.1018 0.931 0.786
#> 5 5 0.733 0.773 0.847 0.0273 0.892 0.638
#> 6 6 0.787 0.742 0.825 0.0543 0.971 0.874
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
#> SRR975551 1 0.634 0.908 0.840 0.160
#> SRR975552 1 0.634 0.908 0.840 0.160
#> SRR975554 1 0.634 0.908 0.840 0.160
#> SRR975553 2 0.000 1.000 0.000 1.000
#> SRR975555 1 0.634 0.908 0.840 0.160
#> SRR975556 1 0.730 0.869 0.796 0.204
#> SRR975557 1 0.634 0.908 0.840 0.160
#> SRR975558 1 0.634 0.908 0.840 0.160
#> SRR975559 1 0.634 0.908 0.840 0.160
#> SRR975560 1 0.634 0.908 0.840 0.160
#> SRR975561 1 0.730 0.869 0.796 0.204
#> SRR975562 1 0.634 0.908 0.840 0.160
#> SRR975563 2 0.000 1.000 0.000 1.000
#> SRR975564 1 0.634 0.908 0.840 0.160
#> SRR975565 1 0.634 0.908 0.840 0.160
#> SRR975566 1 0.634 0.908 0.840 0.160
#> SRR975567 1 0.634 0.908 0.840 0.160
#> SRR975568 1 0.634 0.908 0.840 0.160
#> SRR975569 2 0.000 1.000 0.000 1.000
#> SRR975570 2 0.000 1.000 0.000 1.000
#> SRR975571 2 0.000 1.000 0.000 1.000
#> SRR975572 2 0.000 1.000 0.000 1.000
#> SRR975573 2 0.000 1.000 0.000 1.000
#> SRR975574 2 0.000 1.000 0.000 1.000
#> SRR975575 2 0.000 1.000 0.000 1.000
#> SRR975576 2 0.000 1.000 0.000 1.000
#> SRR975577 2 0.000 1.000 0.000 1.000
#> SRR975578 2 0.000 1.000 0.000 1.000
#> SRR975579 1 0.634 0.908 0.840 0.160
#> SRR975580 1 0.644 0.905 0.836 0.164
#> SRR975581 2 0.000 1.000 0.000 1.000
#> SRR975582 2 0.000 1.000 0.000 1.000
#> SRR975583 2 0.000 1.000 0.000 1.000
#> SRR975584 2 0.000 1.000 0.000 1.000
#> SRR975585 2 0.000 1.000 0.000 1.000
#> SRR975586 1 0.730 0.869 0.796 0.204
#> SRR975587 1 0.000 0.895 1.000 0.000
#> SRR975588 2 0.000 1.000 0.000 1.000
#> SRR975589 1 0.000 0.895 1.000 0.000
#> SRR975590 1 0.000 0.895 1.000 0.000
#> SRR975591 1 0.000 0.895 1.000 0.000
#> SRR975592 1 0.000 0.895 1.000 0.000
#> SRR975593 1 0.000 0.895 1.000 0.000
#> SRR975594 1 0.000 0.895 1.000 0.000
#> SRR975595 1 0.000 0.895 1.000 0.000
#> SRR975597 1 0.000 0.895 1.000 0.000
#> SRR975596 1 0.634 0.908 0.840 0.160
#> SRR975598 1 0.000 0.895 1.000 0.000
#> SRR975599 1 0.000 0.895 1.000 0.000
#> SRR975600 1 0.000 0.895 1.000 0.000
#> SRR975601 1 0.000 0.895 1.000 0.000
#> SRR975602 1 0.000 0.895 1.000 0.000
#> SRR975603 1 0.000 0.895 1.000 0.000
#> SRR975604 1 0.000 0.895 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.6062 0.614 0.616 0.000 0.384
#> SRR975552 1 0.6095 0.609 0.608 0.000 0.392
#> SRR975554 1 0.5138 0.646 0.748 0.000 0.252
#> SRR975553 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975555 1 0.6079 0.609 0.612 0.000 0.388
#> SRR975556 1 0.1643 0.615 0.956 0.000 0.044
#> SRR975557 1 0.6140 -0.365 0.596 0.000 0.404
#> SRR975558 1 0.1643 0.615 0.956 0.000 0.044
#> SRR975559 1 0.4750 0.647 0.784 0.000 0.216
#> SRR975560 1 0.1643 0.615 0.956 0.000 0.044
#> SRR975561 1 0.1950 0.613 0.952 0.008 0.040
#> SRR975562 1 0.4702 0.649 0.788 0.000 0.212
#> SRR975563 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975564 1 0.6079 0.606 0.612 0.000 0.388
#> SRR975565 1 0.6095 0.609 0.608 0.000 0.392
#> SRR975566 1 0.5968 0.438 0.636 0.000 0.364
#> SRR975567 1 0.1643 0.615 0.956 0.000 0.044
#> SRR975568 1 0.6154 0.602 0.592 0.000 0.408
#> SRR975569 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975571 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975572 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975573 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975574 2 0.2796 0.890 0.092 0.908 0.000
#> SRR975575 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975577 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975578 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975579 1 0.5835 -0.158 0.660 0.000 0.340
#> SRR975580 1 0.1643 0.615 0.956 0.000 0.044
#> SRR975581 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975582 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975583 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975584 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975585 2 0.0237 0.990 0.004 0.996 0.000
#> SRR975586 1 0.4092 0.543 0.876 0.088 0.036
#> SRR975587 3 0.6045 0.757 0.380 0.000 0.620
#> SRR975588 2 0.0000 0.994 0.000 1.000 0.000
#> SRR975589 3 0.4605 0.723 0.204 0.000 0.796
#> SRR975590 3 0.4452 0.721 0.192 0.000 0.808
#> SRR975591 3 0.6045 0.757 0.380 0.000 0.620
#> SRR975592 3 0.4452 0.721 0.192 0.000 0.808
#> SRR975593 3 0.4605 0.723 0.204 0.000 0.796
#> SRR975594 3 0.6062 0.753 0.384 0.000 0.616
#> SRR975595 3 0.1163 0.591 0.028 0.000 0.972
#> SRR975597 3 0.1163 0.591 0.028 0.000 0.972
#> SRR975596 1 0.4842 0.642 0.776 0.000 0.224
#> SRR975598 3 0.1163 0.591 0.028 0.000 0.972
#> SRR975599 3 0.6095 0.747 0.392 0.000 0.608
#> SRR975600 3 0.6045 0.757 0.380 0.000 0.620
#> SRR975601 3 0.6045 0.757 0.380 0.000 0.620
#> SRR975602 3 0.4002 0.413 0.160 0.000 0.840
#> SRR975603 3 0.6045 0.757 0.380 0.000 0.620
#> SRR975604 3 0.6045 0.757 0.380 0.000 0.620
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0000 0.940 1.000 0.000 0.000 0.000
#> SRR975552 1 0.0000 0.940 1.000 0.000 0.000 0.000
#> SRR975554 1 0.2759 0.921 0.904 0.000 0.044 0.052
#> SRR975553 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975555 1 0.0336 0.941 0.992 0.000 0.000 0.008
#> SRR975556 4 0.5657 0.855 0.220 0.048 0.016 0.716
#> SRR975557 4 0.1557 0.753 0.000 0.000 0.056 0.944
#> SRR975558 4 0.4399 0.874 0.224 0.000 0.016 0.760
#> SRR975559 1 0.3037 0.901 0.880 0.000 0.020 0.100
#> SRR975560 4 0.4364 0.876 0.220 0.000 0.016 0.764
#> SRR975561 4 0.5337 0.872 0.200 0.036 0.020 0.744
#> SRR975562 1 0.2271 0.926 0.916 0.000 0.008 0.076
#> SRR975563 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975564 1 0.0921 0.940 0.972 0.000 0.000 0.028
#> SRR975565 1 0.0000 0.940 1.000 0.000 0.000 0.000
#> SRR975566 1 0.2751 0.914 0.904 0.000 0.056 0.040
#> SRR975567 4 0.4399 0.874 0.224 0.000 0.016 0.760
#> SRR975568 1 0.0000 0.940 1.000 0.000 0.000 0.000
#> SRR975569 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975572 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975574 2 0.3048 0.838 0.108 0.876 0.000 0.016
#> SRR975575 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975578 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975579 4 0.1389 0.756 0.000 0.000 0.048 0.952
#> SRR975580 4 0.4364 0.876 0.220 0.000 0.016 0.764
#> SRR975581 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975582 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975583 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975585 2 0.1209 0.952 0.032 0.964 0.000 0.004
#> SRR975586 4 0.5515 0.813 0.120 0.104 0.016 0.760
#> SRR975587 3 0.0000 0.880 0.000 0.000 1.000 0.000
#> SRR975588 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975589 3 0.3444 0.822 0.184 0.000 0.816 0.000
#> SRR975590 3 0.1867 0.875 0.072 0.000 0.928 0.000
#> SRR975591 3 0.0000 0.880 0.000 0.000 1.000 0.000
#> SRR975592 3 0.1792 0.876 0.068 0.000 0.932 0.000
#> SRR975593 3 0.3311 0.829 0.172 0.000 0.828 0.000
#> SRR975594 3 0.0000 0.880 0.000 0.000 1.000 0.000
#> SRR975595 3 0.4252 0.781 0.252 0.000 0.744 0.004
#> SRR975597 3 0.4188 0.788 0.244 0.000 0.752 0.004
#> SRR975596 1 0.3215 0.900 0.876 0.000 0.032 0.092
#> SRR975598 3 0.4103 0.779 0.256 0.000 0.744 0.000
#> SRR975599 3 0.1411 0.872 0.020 0.000 0.960 0.020
#> SRR975600 3 0.0000 0.880 0.000 0.000 1.000 0.000
#> SRR975601 3 0.0000 0.880 0.000 0.000 1.000 0.000
#> SRR975602 3 0.4977 0.407 0.460 0.000 0.540 0.000
#> SRR975603 3 0.0000 0.880 0.000 0.000 1.000 0.000
#> SRR975604 3 0.0000 0.880 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.2648 0.682 0.848 0.000 0.000 0.000 0.152
#> SRR975552 1 0.2732 0.674 0.840 0.000 0.000 0.000 0.160
#> SRR975554 5 0.5926 0.630 0.164 0.000 0.204 0.008 0.624
#> SRR975553 2 0.0898 0.952 0.000 0.972 0.000 0.020 0.008
#> SRR975555 1 0.3857 0.394 0.688 0.000 0.000 0.000 0.312
#> SRR975556 5 0.1568 0.695 0.000 0.036 0.000 0.020 0.944
#> SRR975557 4 0.1750 1.000 0.000 0.000 0.028 0.936 0.036
#> SRR975558 5 0.1408 0.718 0.044 0.000 0.008 0.000 0.948
#> SRR975559 5 0.5809 0.647 0.164 0.000 0.188 0.008 0.640
#> SRR975560 5 0.0609 0.702 0.000 0.000 0.000 0.020 0.980
#> SRR975561 5 0.2270 0.662 0.000 0.076 0.000 0.020 0.904
#> SRR975562 5 0.5778 0.645 0.184 0.000 0.164 0.008 0.644
#> SRR975563 2 0.0290 0.963 0.000 0.992 0.000 0.000 0.008
#> SRR975564 5 0.5315 0.494 0.332 0.000 0.068 0.000 0.600
#> SRR975565 1 0.2648 0.682 0.848 0.000 0.000 0.000 0.152
#> SRR975566 5 0.6032 0.615 0.164 0.000 0.220 0.008 0.608
#> SRR975567 5 0.1408 0.718 0.044 0.000 0.008 0.000 0.948
#> SRR975568 1 0.2648 0.682 0.848 0.000 0.000 0.000 0.152
#> SRR975569 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000
#> SRR975571 2 0.0898 0.952 0.000 0.972 0.000 0.020 0.008
#> SRR975572 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000
#> SRR975573 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000
#> SRR975574 2 0.3366 0.685 0.000 0.768 0.000 0.000 0.232
#> SRR975575 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000
#> SRR975576 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000
#> SRR975577 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000
#> SRR975578 2 0.0290 0.964 0.000 0.992 0.000 0.000 0.008
#> SRR975579 4 0.1750 1.000 0.000 0.000 0.028 0.936 0.036
#> SRR975580 5 0.1568 0.695 0.000 0.036 0.000 0.020 0.944
#> SRR975581 2 0.0898 0.952 0.000 0.972 0.000 0.020 0.008
#> SRR975582 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000
#> SRR975583 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000
#> SRR975584 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000
#> SRR975585 2 0.2329 0.836 0.000 0.876 0.000 0.000 0.124
#> SRR975586 5 0.3106 0.562 0.000 0.140 0.000 0.020 0.840
#> SRR975587 3 0.1671 0.839 0.076 0.000 0.924 0.000 0.000
#> SRR975588 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000
#> SRR975589 3 0.4127 0.811 0.156 0.000 0.792 0.028 0.024
#> SRR975590 3 0.4021 0.780 0.200 0.000 0.764 0.036 0.000
#> SRR975591 3 0.0000 0.858 0.000 0.000 1.000 0.000 0.000
#> SRR975592 3 0.3099 0.840 0.124 0.000 0.848 0.028 0.000
#> SRR975593 3 0.4127 0.811 0.156 0.000 0.792 0.028 0.024
#> SRR975594 3 0.0162 0.856 0.004 0.000 0.996 0.000 0.000
#> SRR975595 1 0.4829 0.315 0.660 0.000 0.300 0.036 0.004
#> SRR975597 1 0.4829 0.315 0.660 0.000 0.300 0.036 0.004
#> SRR975596 5 0.5809 0.647 0.164 0.000 0.188 0.008 0.640
#> SRR975598 1 0.4809 0.323 0.664 0.000 0.296 0.036 0.004
#> SRR975599 3 0.5792 0.372 0.404 0.000 0.528 0.028 0.040
#> SRR975600 3 0.1671 0.862 0.076 0.000 0.924 0.000 0.000
#> SRR975601 3 0.0703 0.857 0.024 0.000 0.976 0.000 0.000
#> SRR975602 1 0.4228 0.673 0.788 0.000 0.068 0.008 0.136
#> SRR975603 3 0.1121 0.864 0.044 0.000 0.956 0.000 0.000
#> SRR975604 3 0.0000 0.858 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.4015 0.533 0.616 0.000 0.000 0.000 0.372 0.012
#> SRR975552 1 0.4277 0.530 0.616 0.000 0.000 0.000 0.356 0.028
#> SRR975554 5 0.0547 0.901 0.000 0.000 0.020 0.000 0.980 0.000
#> SRR975553 2 0.1863 0.875 0.000 0.896 0.000 0.000 0.000 0.104
#> SRR975555 1 0.4325 0.416 0.524 0.000 0.000 0.000 0.456 0.020
#> SRR975556 6 0.3345 0.847 0.000 0.028 0.000 0.000 0.184 0.788
#> SRR975557 4 0.0146 1.000 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR975558 6 0.3868 0.499 0.000 0.000 0.000 0.000 0.492 0.508
#> SRR975559 5 0.0692 0.907 0.000 0.000 0.004 0.000 0.976 0.020
#> SRR975560 6 0.3136 0.842 0.000 0.016 0.000 0.000 0.188 0.796
#> SRR975561 6 0.3377 0.846 0.000 0.028 0.000 0.000 0.188 0.784
#> SRR975562 5 0.0363 0.902 0.000 0.000 0.000 0.000 0.988 0.012
#> SRR975563 2 0.0458 0.935 0.000 0.984 0.000 0.000 0.000 0.016
#> SRR975564 5 0.3136 0.561 0.188 0.000 0.000 0.000 0.796 0.016
#> SRR975565 1 0.4015 0.533 0.616 0.000 0.000 0.000 0.372 0.012
#> SRR975566 5 0.1461 0.878 0.000 0.000 0.044 0.000 0.940 0.016
#> SRR975567 6 0.3868 0.499 0.000 0.000 0.000 0.000 0.492 0.508
#> SRR975568 1 0.4037 0.527 0.608 0.000 0.000 0.000 0.380 0.012
#> SRR975569 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975571 2 0.1863 0.875 0.000 0.896 0.000 0.000 0.000 0.104
#> SRR975572 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975573 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975574 2 0.4170 0.484 0.000 0.660 0.000 0.000 0.032 0.308
#> SRR975575 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975576 2 0.0146 0.942 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR975577 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975578 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975579 4 0.0146 1.000 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR975580 6 0.3269 0.847 0.000 0.024 0.000 0.000 0.184 0.792
#> SRR975581 2 0.1910 0.873 0.000 0.892 0.000 0.000 0.000 0.108
#> SRR975582 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975583 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975584 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975585 2 0.2942 0.792 0.000 0.836 0.000 0.000 0.032 0.132
#> SRR975586 6 0.3588 0.832 0.000 0.044 0.000 0.000 0.180 0.776
#> SRR975587 3 0.1434 0.755 0.048 0.000 0.940 0.000 0.000 0.012
#> SRR975588 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975589 3 0.6922 0.376 0.236 0.000 0.392 0.004 0.320 0.048
#> SRR975590 3 0.5495 0.659 0.208 0.000 0.652 0.004 0.044 0.092
#> SRR975591 3 0.0291 0.757 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR975592 3 0.4605 0.699 0.176 0.000 0.732 0.004 0.028 0.060
#> SRR975593 3 0.6912 0.391 0.236 0.000 0.400 0.004 0.312 0.048
#> SRR975594 3 0.0909 0.745 0.020 0.000 0.968 0.000 0.000 0.012
#> SRR975595 1 0.5419 0.238 0.648 0.000 0.140 0.004 0.020 0.188
#> SRR975597 1 0.5419 0.238 0.648 0.000 0.140 0.004 0.020 0.188
#> SRR975596 5 0.0692 0.907 0.000 0.000 0.004 0.000 0.976 0.020
#> SRR975598 1 0.5419 0.238 0.648 0.000 0.140 0.004 0.020 0.188
#> SRR975599 3 0.6944 0.458 0.292 0.000 0.456 0.004 0.084 0.164
#> SRR975600 3 0.2163 0.757 0.096 0.000 0.892 0.000 0.008 0.004
#> SRR975601 3 0.1074 0.749 0.028 0.000 0.960 0.000 0.000 0.012
#> SRR975602 1 0.4593 0.496 0.632 0.000 0.024 0.000 0.324 0.020
#> SRR975603 3 0.1410 0.762 0.044 0.000 0.944 0.000 0.008 0.004
#> SRR975604 3 0.0146 0.756 0.000 0.000 0.996 0.000 0.004 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 17171 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 4.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.944 0.980 0.5065 0.493 0.493
#> 3 3 0.905 0.916 0.959 0.2509 0.860 0.725
#> 4 4 0.929 0.900 0.954 0.0589 0.940 0.844
#> 5 5 0.790 0.749 0.868 0.0966 0.928 0.788
#> 6 6 0.773 0.724 0.827 0.0683 0.911 0.692
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3
There is also optional best \(k\) = 2 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR975551 1 0.000 0.9772 1.000 0.000
#> SRR975552 1 0.662 0.7828 0.828 0.172
#> SRR975554 1 0.000 0.9772 1.000 0.000
#> SRR975553 2 0.000 0.9794 0.000 1.000
#> SRR975555 1 0.184 0.9518 0.972 0.028
#> SRR975556 2 0.000 0.9794 0.000 1.000
#> SRR975557 1 0.000 0.9772 1.000 0.000
#> SRR975558 2 0.998 0.0535 0.472 0.528
#> SRR975559 1 0.000 0.9772 1.000 0.000
#> SRR975560 2 0.000 0.9794 0.000 1.000
#> SRR975561 2 0.000 0.9794 0.000 1.000
#> SRR975562 1 0.000 0.9772 1.000 0.000
#> SRR975563 2 0.000 0.9794 0.000 1.000
#> SRR975564 1 0.000 0.9772 1.000 0.000
#> SRR975565 1 0.000 0.9772 1.000 0.000
#> SRR975566 1 0.000 0.9772 1.000 0.000
#> SRR975567 1 0.980 0.2804 0.584 0.416
#> SRR975568 1 0.000 0.9772 1.000 0.000
#> SRR975569 2 0.000 0.9794 0.000 1.000
#> SRR975570 2 0.000 0.9794 0.000 1.000
#> SRR975571 2 0.000 0.9794 0.000 1.000
#> SRR975572 2 0.000 0.9794 0.000 1.000
#> SRR975573 2 0.000 0.9794 0.000 1.000
#> SRR975574 2 0.000 0.9794 0.000 1.000
#> SRR975575 2 0.000 0.9794 0.000 1.000
#> SRR975576 2 0.000 0.9794 0.000 1.000
#> SRR975577 2 0.000 0.9794 0.000 1.000
#> SRR975578 2 0.000 0.9794 0.000 1.000
#> SRR975579 2 0.000 0.9794 0.000 1.000
#> SRR975580 2 0.000 0.9794 0.000 1.000
#> SRR975581 2 0.000 0.9794 0.000 1.000
#> SRR975582 2 0.000 0.9794 0.000 1.000
#> SRR975583 2 0.000 0.9794 0.000 1.000
#> SRR975584 2 0.000 0.9794 0.000 1.000
#> SRR975585 2 0.000 0.9794 0.000 1.000
#> SRR975586 2 0.000 0.9794 0.000 1.000
#> SRR975587 1 0.000 0.9772 1.000 0.000
#> SRR975588 2 0.000 0.9794 0.000 1.000
#> SRR975589 1 0.000 0.9772 1.000 0.000
#> SRR975590 1 0.000 0.9772 1.000 0.000
#> SRR975591 1 0.000 0.9772 1.000 0.000
#> SRR975592 1 0.000 0.9772 1.000 0.000
#> SRR975593 1 0.000 0.9772 1.000 0.000
#> SRR975594 1 0.000 0.9772 1.000 0.000
#> SRR975595 1 0.000 0.9772 1.000 0.000
#> SRR975597 1 0.000 0.9772 1.000 0.000
#> SRR975596 1 0.000 0.9772 1.000 0.000
#> SRR975598 1 0.000 0.9772 1.000 0.000
#> SRR975599 1 0.000 0.9772 1.000 0.000
#> SRR975600 1 0.000 0.9772 1.000 0.000
#> SRR975601 1 0.000 0.9772 1.000 0.000
#> SRR975602 1 0.000 0.9772 1.000 0.000
#> SRR975603 1 0.000 0.9772 1.000 0.000
#> SRR975604 1 0.000 0.9772 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.0000 0.906 1.000 0.000 0.000
#> SRR975552 1 0.0000 0.906 1.000 0.000 0.000
#> SRR975554 1 0.0000 0.906 1.000 0.000 0.000
#> SRR975553 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975555 1 0.0000 0.906 1.000 0.000 0.000
#> SRR975556 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975557 1 0.6267 0.133 0.548 0.000 0.452
#> SRR975558 1 0.1031 0.890 0.976 0.024 0.000
#> SRR975559 1 0.0000 0.906 1.000 0.000 0.000
#> SRR975560 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975561 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975562 1 0.0000 0.906 1.000 0.000 0.000
#> SRR975563 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975564 1 0.0000 0.906 1.000 0.000 0.000
#> SRR975565 1 0.0000 0.906 1.000 0.000 0.000
#> SRR975566 1 0.0000 0.906 1.000 0.000 0.000
#> SRR975567 1 0.0237 0.903 0.996 0.004 0.000
#> SRR975568 1 0.0000 0.906 1.000 0.000 0.000
#> SRR975569 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975571 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975572 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975573 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975574 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975575 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975577 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975578 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975579 2 0.4796 0.718 0.000 0.780 0.220
#> SRR975580 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975581 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975582 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975583 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975584 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975585 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975586 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975587 3 0.0237 1.000 0.004 0.000 0.996
#> SRR975588 2 0.0000 0.990 0.000 1.000 0.000
#> SRR975589 1 0.1643 0.890 0.956 0.000 0.044
#> SRR975590 1 0.5216 0.711 0.740 0.000 0.260
#> SRR975591 3 0.0237 1.000 0.004 0.000 0.996
#> SRR975592 1 0.6062 0.498 0.616 0.000 0.384
#> SRR975593 1 0.1964 0.887 0.944 0.000 0.056
#> SRR975594 3 0.0237 1.000 0.004 0.000 0.996
#> SRR975595 1 0.4702 0.769 0.788 0.000 0.212
#> SRR975597 1 0.4555 0.781 0.800 0.000 0.200
#> SRR975596 1 0.0000 0.906 1.000 0.000 0.000
#> SRR975598 1 0.4555 0.781 0.800 0.000 0.200
#> SRR975599 1 0.3192 0.851 0.888 0.000 0.112
#> SRR975600 3 0.0237 1.000 0.004 0.000 0.996
#> SRR975601 3 0.0237 1.000 0.004 0.000 0.996
#> SRR975602 1 0.0000 0.906 1.000 0.000 0.000
#> SRR975603 3 0.0237 1.000 0.004 0.000 0.996
#> SRR975604 3 0.0237 1.000 0.004 0.000 0.996
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0000 0.892 1.000 0.000 0.000 0.000
#> SRR975552 1 0.0000 0.892 1.000 0.000 0.000 0.000
#> SRR975554 1 0.0000 0.892 1.000 0.000 0.000 0.000
#> SRR975553 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975555 1 0.0336 0.890 0.992 0.000 0.000 0.008
#> SRR975556 2 0.0336 0.992 0.000 0.992 0.000 0.008
#> SRR975557 4 0.0336 0.618 0.008 0.000 0.000 0.992
#> SRR975558 4 0.6714 0.550 0.360 0.100 0.000 0.540
#> SRR975559 1 0.2149 0.817 0.912 0.000 0.000 0.088
#> SRR975560 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975561 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975562 1 0.0000 0.892 1.000 0.000 0.000 0.000
#> SRR975563 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975564 1 0.0000 0.892 1.000 0.000 0.000 0.000
#> SRR975565 1 0.0000 0.892 1.000 0.000 0.000 0.000
#> SRR975566 1 0.0000 0.892 1.000 0.000 0.000 0.000
#> SRR975567 4 0.6233 0.507 0.388 0.060 0.000 0.552
#> SRR975568 1 0.0000 0.892 1.000 0.000 0.000 0.000
#> SRR975569 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975572 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975574 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975575 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975578 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975579 4 0.0592 0.616 0.000 0.016 0.000 0.984
#> SRR975580 2 0.0336 0.992 0.000 0.992 0.000 0.008
#> SRR975581 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975582 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975583 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975585 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975586 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975587 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR975588 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> SRR975589 1 0.1716 0.865 0.936 0.000 0.064 0.000
#> SRR975590 1 0.4431 0.580 0.696 0.000 0.304 0.000
#> SRR975591 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR975592 1 0.5000 0.170 0.504 0.000 0.496 0.000
#> SRR975593 1 0.2469 0.834 0.892 0.000 0.108 0.000
#> SRR975594 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR975595 1 0.3444 0.753 0.816 0.000 0.184 0.000
#> SRR975597 1 0.2760 0.816 0.872 0.000 0.128 0.000
#> SRR975596 1 0.1637 0.844 0.940 0.000 0.000 0.060
#> SRR975598 1 0.2011 0.856 0.920 0.000 0.080 0.000
#> SRR975599 1 0.0336 0.890 0.992 0.000 0.008 0.000
#> SRR975600 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR975601 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR975602 1 0.0000 0.892 1.000 0.000 0.000 0.000
#> SRR975603 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR975604 3 0.0000 1.000 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.2561 0.725 0.856 0.000 0.000 0.000 0.144
#> SRR975552 1 0.2852 0.722 0.828 0.000 0.000 0.000 0.172
#> SRR975554 1 0.4302 0.186 0.520 0.000 0.000 0.000 0.480
#> SRR975553 2 0.1121 0.943 0.000 0.956 0.000 0.000 0.044
#> SRR975555 1 0.4283 0.252 0.544 0.000 0.000 0.000 0.456
#> SRR975556 2 0.1908 0.912 0.000 0.908 0.000 0.000 0.092
#> SRR975557 4 0.0000 0.845 0.000 0.000 0.000 1.000 0.000
#> SRR975558 5 0.5025 0.144 0.020 0.028 0.000 0.288 0.664
#> SRR975559 1 0.4101 0.501 0.664 0.000 0.000 0.332 0.004
#> SRR975560 2 0.4360 0.743 0.184 0.752 0.000 0.000 0.064
#> SRR975561 2 0.1544 0.926 0.000 0.932 0.000 0.000 0.068
#> SRR975562 1 0.0162 0.705 0.996 0.000 0.000 0.000 0.004
#> SRR975563 2 0.1671 0.922 0.000 0.924 0.000 0.000 0.076
#> SRR975564 5 0.2605 0.650 0.148 0.000 0.000 0.000 0.852
#> SRR975565 1 0.2966 0.714 0.816 0.000 0.000 0.000 0.184
#> SRR975566 1 0.4503 0.554 0.664 0.000 0.000 0.024 0.312
#> SRR975567 4 0.5091 0.623 0.016 0.072 0.000 0.712 0.200
#> SRR975568 5 0.2690 0.648 0.156 0.000 0.000 0.000 0.844
#> SRR975569 2 0.0510 0.946 0.000 0.984 0.000 0.000 0.016
#> SRR975570 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> SRR975571 2 0.1121 0.943 0.000 0.956 0.000 0.000 0.044
#> SRR975572 2 0.0404 0.945 0.000 0.988 0.000 0.000 0.012
#> SRR975573 2 0.1121 0.943 0.000 0.956 0.000 0.000 0.044
#> SRR975574 2 0.1121 0.943 0.000 0.956 0.000 0.000 0.044
#> SRR975575 2 0.0404 0.945 0.000 0.988 0.000 0.000 0.012
#> SRR975576 2 0.0794 0.942 0.000 0.972 0.000 0.000 0.028
#> SRR975577 2 0.1121 0.943 0.000 0.956 0.000 0.000 0.044
#> SRR975578 2 0.1121 0.943 0.000 0.956 0.000 0.000 0.044
#> SRR975579 4 0.0000 0.845 0.000 0.000 0.000 1.000 0.000
#> SRR975580 2 0.4113 0.804 0.140 0.784 0.000 0.000 0.076
#> SRR975581 2 0.1043 0.938 0.000 0.960 0.000 0.000 0.040
#> SRR975582 2 0.1121 0.943 0.000 0.956 0.000 0.000 0.044
#> SRR975583 2 0.0404 0.945 0.000 0.988 0.000 0.000 0.012
#> SRR975584 2 0.1121 0.943 0.000 0.956 0.000 0.000 0.044
#> SRR975585 2 0.0510 0.945 0.000 0.984 0.000 0.000 0.016
#> SRR975586 2 0.1908 0.912 0.000 0.908 0.000 0.000 0.092
#> SRR975587 3 0.0000 0.916 0.000 0.000 1.000 0.000 0.000
#> SRR975588 2 0.0162 0.946 0.000 0.996 0.000 0.000 0.004
#> SRR975589 5 0.3163 0.645 0.164 0.000 0.012 0.000 0.824
#> SRR975590 1 0.5848 0.533 0.604 0.000 0.228 0.000 0.168
#> SRR975591 3 0.0000 0.916 0.000 0.000 1.000 0.000 0.000
#> SRR975592 3 0.5393 0.222 0.080 0.000 0.608 0.000 0.312
#> SRR975593 5 0.6949 0.160 0.388 0.000 0.144 0.032 0.436
#> SRR975594 3 0.0000 0.916 0.000 0.000 1.000 0.000 0.000
#> SRR975595 1 0.2583 0.640 0.864 0.000 0.132 0.000 0.004
#> SRR975597 1 0.3601 0.722 0.820 0.000 0.052 0.000 0.128
#> SRR975596 1 0.5334 0.395 0.672 0.000 0.000 0.148 0.180
#> SRR975598 1 0.1571 0.691 0.936 0.000 0.060 0.000 0.004
#> SRR975599 1 0.0324 0.705 0.992 0.000 0.004 0.000 0.004
#> SRR975600 5 0.4227 0.137 0.000 0.000 0.420 0.000 0.580
#> SRR975601 3 0.0000 0.916 0.000 0.000 1.000 0.000 0.000
#> SRR975602 1 0.2377 0.728 0.872 0.000 0.000 0.000 0.128
#> SRR975603 3 0.0290 0.909 0.000 0.000 0.992 0.000 0.008
#> SRR975604 3 0.0000 0.916 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.4439 0.847 0.540 0.000 0.000 0.000 0.432 0.028
#> SRR975552 1 0.4488 0.849 0.548 0.000 0.000 0.000 0.420 0.032
#> SRR975554 1 0.5887 0.367 0.404 0.000 0.000 0.000 0.200 0.396
#> SRR975553 2 0.1918 0.871 0.088 0.904 0.000 0.000 0.000 0.008
#> SRR975555 6 0.4591 0.329 0.040 0.000 0.000 0.000 0.408 0.552
#> SRR975556 2 0.3721 0.676 0.308 0.684 0.000 0.000 0.004 0.004
#> SRR975557 4 0.0000 0.745 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR975558 6 0.3100 0.768 0.012 0.004 0.000 0.028 0.108 0.848
#> SRR975559 4 0.4037 0.347 0.012 0.000 0.000 0.608 0.380 0.000
#> SRR975560 5 0.6163 0.294 0.176 0.256 0.000 0.020 0.540 0.008
#> SRR975561 2 0.3761 0.762 0.192 0.768 0.000 0.032 0.004 0.004
#> SRR975562 5 0.0508 0.449 0.004 0.000 0.000 0.000 0.984 0.012
#> SRR975563 2 0.3429 0.736 0.252 0.740 0.000 0.000 0.004 0.004
#> SRR975564 6 0.0717 0.787 0.016 0.000 0.000 0.000 0.008 0.976
#> SRR975565 1 0.4747 0.820 0.584 0.000 0.000 0.000 0.356 0.060
#> SRR975566 1 0.5277 0.829 0.528 0.000 0.000 0.008 0.384 0.080
#> SRR975567 4 0.5329 0.588 0.044 0.084 0.000 0.708 0.024 0.140
#> SRR975568 6 0.0508 0.790 0.004 0.000 0.000 0.000 0.012 0.984
#> SRR975569 2 0.0717 0.882 0.016 0.976 0.000 0.000 0.000 0.008
#> SRR975570 2 0.0508 0.884 0.012 0.984 0.000 0.000 0.004 0.000
#> SRR975571 2 0.1918 0.871 0.088 0.904 0.000 0.000 0.000 0.008
#> SRR975572 2 0.0935 0.881 0.032 0.964 0.000 0.000 0.004 0.000
#> SRR975573 2 0.1918 0.871 0.088 0.904 0.000 0.000 0.000 0.008
#> SRR975574 2 0.1918 0.871 0.088 0.904 0.000 0.000 0.000 0.008
#> SRR975575 2 0.0937 0.881 0.040 0.960 0.000 0.000 0.000 0.000
#> SRR975576 2 0.1493 0.874 0.056 0.936 0.000 0.000 0.004 0.004
#> SRR975577 2 0.1918 0.871 0.088 0.904 0.000 0.000 0.000 0.008
#> SRR975578 2 0.1918 0.871 0.088 0.904 0.000 0.000 0.000 0.008
#> SRR975579 4 0.0000 0.745 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR975580 5 0.5454 0.085 0.104 0.432 0.000 0.000 0.460 0.004
#> SRR975581 2 0.1674 0.869 0.068 0.924 0.000 0.000 0.004 0.004
#> SRR975582 2 0.1918 0.871 0.088 0.904 0.000 0.000 0.000 0.008
#> SRR975583 2 0.1364 0.877 0.048 0.944 0.000 0.000 0.004 0.004
#> SRR975584 2 0.1918 0.871 0.088 0.904 0.000 0.000 0.000 0.008
#> SRR975585 2 0.1296 0.878 0.044 0.948 0.000 0.000 0.004 0.004
#> SRR975586 2 0.3756 0.666 0.316 0.676 0.000 0.000 0.004 0.004
#> SRR975587 3 0.0146 0.914 0.004 0.000 0.996 0.000 0.000 0.000
#> SRR975588 2 0.0692 0.884 0.020 0.976 0.000 0.000 0.000 0.004
#> SRR975589 6 0.1578 0.793 0.012 0.000 0.004 0.000 0.048 0.936
#> SRR975590 1 0.5458 0.826 0.544 0.000 0.060 0.000 0.364 0.032
#> SRR975591 3 0.0260 0.912 0.000 0.000 0.992 0.000 0.000 0.008
#> SRR975592 3 0.4798 0.417 0.080 0.000 0.620 0.000 0.000 0.300
#> SRR975593 6 0.4712 0.724 0.012 0.000 0.100 0.004 0.168 0.716
#> SRR975594 3 0.0146 0.914 0.004 0.000 0.996 0.000 0.000 0.000
#> SRR975595 5 0.4293 0.184 0.164 0.000 0.096 0.000 0.736 0.004
#> SRR975597 1 0.5208 0.806 0.500 0.000 0.048 0.000 0.432 0.020
#> SRR975596 5 0.4411 0.341 0.004 0.000 0.000 0.080 0.712 0.204
#> SRR975598 5 0.2728 0.375 0.080 0.000 0.040 0.000 0.872 0.008
#> SRR975599 5 0.1036 0.437 0.024 0.000 0.004 0.000 0.964 0.008
#> SRR975600 6 0.3323 0.576 0.008 0.000 0.240 0.000 0.000 0.752
#> SRR975601 3 0.0146 0.914 0.004 0.000 0.996 0.000 0.000 0.000
#> SRR975602 1 0.4396 0.834 0.520 0.000 0.000 0.000 0.456 0.024
#> SRR975603 3 0.1471 0.871 0.004 0.000 0.932 0.000 0.000 0.064
#> SRR975604 3 0.0146 0.913 0.004 0.000 0.996 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", "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 17171 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 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.537 0.731 0.878 0.2001 0.927 0.927
#> 3 3 0.586 0.683 0.814 1.3586 0.706 0.683
#> 4 4 0.839 0.882 0.920 0.4036 0.695 0.518
#> 5 5 0.793 0.806 0.866 0.0850 0.951 0.851
#> 6 6 0.863 0.781 0.881 0.0433 0.985 0.948
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
#> SRR975551 1 0.2423 0.807 0.960 0.040
#> SRR975552 1 0.2423 0.807 0.960 0.040
#> SRR975554 1 0.2423 0.807 0.960 0.040
#> SRR975553 1 0.0000 0.806 1.000 0.000
#> SRR975555 1 0.2423 0.807 0.960 0.040
#> SRR975556 1 0.0000 0.806 1.000 0.000
#> SRR975557 2 0.9896 1.000 0.440 0.560
#> SRR975558 1 0.2423 0.807 0.960 0.040
#> SRR975559 1 0.2423 0.807 0.960 0.040
#> SRR975560 1 0.0000 0.806 1.000 0.000
#> SRR975561 1 0.0376 0.802 0.996 0.004
#> SRR975562 1 0.2423 0.807 0.960 0.040
#> SRR975563 1 0.0000 0.806 1.000 0.000
#> SRR975564 1 0.2423 0.807 0.960 0.040
#> SRR975565 1 0.2423 0.807 0.960 0.040
#> SRR975566 1 0.2423 0.807 0.960 0.040
#> SRR975567 1 0.2423 0.807 0.960 0.040
#> SRR975568 1 0.2423 0.807 0.960 0.040
#> SRR975569 1 0.0000 0.806 1.000 0.000
#> SRR975570 1 0.0000 0.806 1.000 0.000
#> SRR975571 1 0.0000 0.806 1.000 0.000
#> SRR975572 1 0.0000 0.806 1.000 0.000
#> SRR975573 1 0.0000 0.806 1.000 0.000
#> SRR975574 1 0.0000 0.806 1.000 0.000
#> SRR975575 1 0.0000 0.806 1.000 0.000
#> SRR975576 1 0.0000 0.806 1.000 0.000
#> SRR975577 1 0.0000 0.806 1.000 0.000
#> SRR975578 1 0.0000 0.806 1.000 0.000
#> SRR975579 2 0.9896 1.000 0.440 0.560
#> SRR975580 1 0.0000 0.806 1.000 0.000
#> SRR975581 1 0.0000 0.806 1.000 0.000
#> SRR975582 1 0.0000 0.806 1.000 0.000
#> SRR975583 1 0.0000 0.806 1.000 0.000
#> SRR975584 1 0.0000 0.806 1.000 0.000
#> SRR975585 1 0.0000 0.806 1.000 0.000
#> SRR975586 1 0.0000 0.806 1.000 0.000
#> SRR975587 1 0.9896 0.410 0.560 0.440
#> SRR975588 1 0.0000 0.806 1.000 0.000
#> SRR975589 1 0.9286 0.545 0.656 0.344
#> SRR975590 1 0.9000 0.571 0.684 0.316
#> SRR975591 1 0.9896 0.410 0.560 0.440
#> SRR975592 1 0.9286 0.545 0.656 0.344
#> SRR975593 1 0.9286 0.545 0.656 0.344
#> SRR975594 1 0.9896 0.410 0.560 0.440
#> SRR975595 1 0.9170 0.557 0.668 0.332
#> SRR975597 1 0.9170 0.557 0.668 0.332
#> SRR975596 1 0.2423 0.807 0.960 0.040
#> SRR975598 1 0.9170 0.557 0.668 0.332
#> SRR975599 1 0.5629 0.736 0.868 0.132
#> SRR975600 1 0.9286 0.545 0.656 0.344
#> SRR975601 1 0.9896 0.410 0.560 0.440
#> SRR975602 1 0.2423 0.807 0.960 0.040
#> SRR975603 1 0.9896 0.410 0.560 0.440
#> SRR975604 1 0.9896 0.410 0.560 0.440
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 2 0.6225 0.616 0.432 0.568 0.000
#> SRR975552 2 0.6225 0.616 0.432 0.568 0.000
#> SRR975554 2 0.6225 0.616 0.432 0.568 0.000
#> SRR975553 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975555 2 0.6225 0.616 0.432 0.568 0.000
#> SRR975556 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975557 1 0.6225 1.000 0.568 0.432 0.000
#> SRR975558 2 0.5948 0.632 0.360 0.640 0.000
#> SRR975559 2 0.6225 0.616 0.432 0.568 0.000
#> SRR975560 2 0.1964 0.666 0.056 0.944 0.000
#> SRR975561 2 0.0237 0.668 0.004 0.996 0.000
#> SRR975562 2 0.6225 0.616 0.432 0.568 0.000
#> SRR975563 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975564 2 0.6225 0.616 0.432 0.568 0.000
#> SRR975565 2 0.6225 0.616 0.432 0.568 0.000
#> SRR975566 2 0.6225 0.616 0.432 0.568 0.000
#> SRR975567 2 0.5835 0.635 0.340 0.660 0.000
#> SRR975568 2 0.6225 0.616 0.432 0.568 0.000
#> SRR975569 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975571 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975572 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975573 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975574 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975575 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975577 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975578 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975579 1 0.6225 1.000 0.568 0.432 0.000
#> SRR975580 2 0.1964 0.666 0.056 0.944 0.000
#> SRR975581 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975582 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975583 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975584 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975585 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975586 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975587 3 0.0000 0.834 0.000 0.000 1.000
#> SRR975588 2 0.0000 0.673 0.000 1.000 0.000
#> SRR975589 3 0.6286 0.790 0.136 0.092 0.772
#> SRR975590 2 0.8889 0.495 0.164 0.560 0.276
#> SRR975591 3 0.1289 0.853 0.000 0.032 0.968
#> SRR975592 3 0.6286 0.790 0.136 0.092 0.772
#> SRR975593 3 0.6286 0.790 0.136 0.092 0.772
#> SRR975594 3 0.0000 0.834 0.000 0.000 1.000
#> SRR975595 2 0.8801 0.485 0.148 0.560 0.292
#> SRR975597 2 0.8801 0.485 0.148 0.560 0.292
#> SRR975596 2 0.6225 0.616 0.432 0.568 0.000
#> SRR975598 2 0.8801 0.485 0.148 0.560 0.292
#> SRR975599 2 0.8297 0.588 0.348 0.560 0.092
#> SRR975600 3 0.6208 0.793 0.136 0.088 0.776
#> SRR975601 3 0.0000 0.834 0.000 0.000 1.000
#> SRR975602 2 0.6225 0.616 0.432 0.568 0.000
#> SRR975603 3 0.1289 0.853 0.000 0.032 0.968
#> SRR975604 3 0.1289 0.853 0.000 0.032 0.968
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.1022 0.895 0.968 0.032 0.000 0.000
#> SRR975552 1 0.1022 0.895 0.968 0.032 0.000 0.000
#> SRR975554 1 0.1022 0.895 0.968 0.032 0.000 0.000
#> SRR975553 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975555 1 0.1022 0.895 0.968 0.032 0.000 0.000
#> SRR975556 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975557 4 0.3610 1.000 0.000 0.200 0.000 0.800
#> SRR975558 1 0.2469 0.813 0.892 0.108 0.000 0.000
#> SRR975559 1 0.0707 0.877 0.980 0.020 0.000 0.000
#> SRR975560 2 0.1557 0.912 0.056 0.944 0.000 0.000
#> SRR975561 2 0.1211 0.944 0.000 0.960 0.000 0.040
#> SRR975562 1 0.1474 0.885 0.948 0.052 0.000 0.000
#> SRR975563 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975564 1 0.1022 0.895 0.968 0.032 0.000 0.000
#> SRR975565 1 0.1022 0.895 0.968 0.032 0.000 0.000
#> SRR975566 1 0.0707 0.877 0.980 0.020 0.000 0.000
#> SRR975567 1 0.2760 0.789 0.872 0.128 0.000 0.000
#> SRR975568 1 0.1022 0.895 0.968 0.032 0.000 0.000
#> SRR975569 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975572 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975574 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975575 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975578 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975579 4 0.3610 1.000 0.000 0.200 0.000 0.800
#> SRR975580 2 0.1557 0.912 0.056 0.944 0.000 0.000
#> SRR975581 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975582 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975583 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975585 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975586 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975587 3 0.0000 0.758 0.000 0.000 1.000 0.000
#> SRR975588 2 0.0000 0.990 0.000 1.000 0.000 0.000
#> SRR975589 3 0.7058 0.649 0.228 0.000 0.572 0.200
#> SRR975590 1 0.6367 0.697 0.692 0.032 0.076 0.200
#> SRR975591 3 0.1022 0.767 0.032 0.000 0.968 0.000
#> SRR975592 3 0.6790 0.666 0.228 0.000 0.604 0.168
#> SRR975593 3 0.7058 0.649 0.228 0.000 0.572 0.200
#> SRR975594 3 0.0000 0.758 0.000 0.000 1.000 0.000
#> SRR975595 1 0.6609 0.678 0.676 0.032 0.092 0.200
#> SRR975597 1 0.6609 0.678 0.676 0.032 0.092 0.200
#> SRR975596 1 0.0707 0.877 0.980 0.020 0.000 0.000
#> SRR975598 1 0.6609 0.678 0.676 0.032 0.092 0.200
#> SRR975599 1 0.3215 0.842 0.876 0.032 0.092 0.000
#> SRR975600 3 0.6761 0.669 0.224 0.000 0.608 0.168
#> SRR975601 3 0.0000 0.758 0.000 0.000 1.000 0.000
#> SRR975602 1 0.1022 0.895 0.968 0.032 0.000 0.000
#> SRR975603 3 0.1022 0.767 0.032 0.000 0.968 0.000
#> SRR975604 3 0.1022 0.767 0.032 0.000 0.968 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.0609 0.705 0.980 0.000 0.000 0.000 0.020
#> SRR975552 1 0.0609 0.705 0.980 0.000 0.000 0.000 0.020
#> SRR975554 1 0.0290 0.711 0.992 0.000 0.000 0.000 0.008
#> SRR975553 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975555 1 0.3395 0.586 0.764 0.000 0.000 0.000 0.236
#> SRR975556 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975557 4 0.2377 1.000 0.000 0.128 0.000 0.872 0.000
#> SRR975558 5 0.4280 0.726 0.140 0.088 0.000 0.000 0.772
#> SRR975559 5 0.4101 0.794 0.372 0.000 0.000 0.000 0.628
#> SRR975560 2 0.1484 0.927 0.008 0.944 0.000 0.000 0.048
#> SRR975561 2 0.2074 0.865 0.000 0.896 0.000 0.104 0.000
#> SRR975562 5 0.4201 0.756 0.408 0.000 0.000 0.000 0.592
#> SRR975563 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975564 1 0.3983 0.406 0.660 0.000 0.000 0.000 0.340
#> SRR975565 1 0.2516 0.678 0.860 0.000 0.000 0.000 0.140
#> SRR975566 1 0.3305 0.351 0.776 0.000 0.000 0.000 0.224
#> SRR975567 5 0.4617 0.715 0.148 0.108 0.000 0.000 0.744
#> SRR975568 1 0.3395 0.586 0.764 0.000 0.000 0.000 0.236
#> SRR975569 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975571 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975572 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975573 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975574 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975575 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975576 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975577 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975578 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975579 4 0.2377 1.000 0.000 0.128 0.000 0.872 0.000
#> SRR975580 2 0.1484 0.927 0.008 0.944 0.000 0.000 0.048
#> SRR975581 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975582 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975583 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975584 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975585 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975586 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975587 3 0.1732 0.682 0.000 0.000 0.920 0.000 0.080
#> SRR975588 2 0.0000 0.988 0.000 1.000 0.000 0.000 0.000
#> SRR975589 3 0.7586 0.576 0.160 0.000 0.512 0.128 0.200
#> SRR975590 1 0.5322 0.645 0.708 0.000 0.016 0.128 0.148
#> SRR975591 3 0.0880 0.713 0.000 0.000 0.968 0.000 0.032
#> SRR975592 3 0.7325 0.601 0.160 0.000 0.544 0.108 0.188
#> SRR975593 3 0.7586 0.576 0.160 0.000 0.512 0.128 0.200
#> SRR975594 3 0.1732 0.682 0.000 0.000 0.920 0.000 0.080
#> SRR975595 1 0.5620 0.641 0.696 0.000 0.032 0.128 0.144
#> SRR975597 1 0.5620 0.641 0.696 0.000 0.032 0.128 0.144
#> SRR975596 5 0.4114 0.792 0.376 0.000 0.000 0.000 0.624
#> SRR975598 1 0.5620 0.641 0.696 0.000 0.032 0.128 0.144
#> SRR975599 1 0.2473 0.702 0.896 0.000 0.032 0.000 0.072
#> SRR975600 3 0.7295 0.605 0.156 0.000 0.548 0.108 0.188
#> SRR975601 3 0.1732 0.682 0.000 0.000 0.920 0.000 0.080
#> SRR975602 1 0.0000 0.711 1.000 0.000 0.000 0.000 0.000
#> SRR975603 3 0.0880 0.713 0.000 0.000 0.968 0.000 0.032
#> SRR975604 3 0.0880 0.713 0.000 0.000 0.968 0.000 0.032
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.0790 0.644 0.968 0.000 0.000 0.032 0.000 0.000
#> SRR975552 1 0.0790 0.644 0.968 0.000 0.000 0.032 0.000 0.000
#> SRR975554 1 0.1528 0.651 0.936 0.000 0.048 0.016 0.000 0.000
#> SRR975553 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975555 1 0.3515 0.499 0.676 0.000 0.000 0.324 0.000 0.000
#> SRR975556 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975557 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR975558 4 0.0632 0.714 0.000 0.024 0.000 0.976 0.000 0.000
#> SRR975559 4 0.3126 0.816 0.248 0.000 0.000 0.752 0.000 0.000
#> SRR975560 2 0.1806 0.900 0.004 0.908 0.000 0.088 0.000 0.000
#> SRR975561 2 0.2969 0.726 0.000 0.776 0.000 0.000 0.224 0.000
#> SRR975562 4 0.3330 0.784 0.284 0.000 0.000 0.716 0.000 0.000
#> SRR975563 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975564 1 0.3810 0.370 0.572 0.000 0.000 0.428 0.000 0.000
#> SRR975565 1 0.2631 0.622 0.820 0.000 0.000 0.180 0.000 0.000
#> SRR975566 1 0.3076 0.334 0.760 0.000 0.000 0.240 0.000 0.000
#> SRR975567 4 0.1434 0.718 0.012 0.048 0.000 0.940 0.000 0.000
#> SRR975568 1 0.3515 0.499 0.676 0.000 0.000 0.324 0.000 0.000
#> SRR975569 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975571 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975572 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975573 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975574 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975575 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975576 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975577 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975578 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975579 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR975580 2 0.1753 0.904 0.004 0.912 0.000 0.084 0.000 0.000
#> SRR975581 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975582 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975583 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975584 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975585 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975586 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975587 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR975588 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975589 3 0.0000 0.665 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975590 1 0.3883 0.590 0.656 0.000 0.332 0.012 0.000 0.000
#> SRR975591 3 0.3867 0.295 0.000 0.000 0.512 0.000 0.000 0.488
#> SRR975592 3 0.0790 0.675 0.000 0.000 0.968 0.000 0.000 0.032
#> SRR975593 3 0.0000 0.665 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975594 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR975595 1 0.3843 0.507 0.548 0.000 0.452 0.000 0.000 0.000
#> SRR975597 1 0.3843 0.507 0.548 0.000 0.452 0.000 0.000 0.000
#> SRR975596 4 0.3151 0.815 0.252 0.000 0.000 0.748 0.000 0.000
#> SRR975598 1 0.3843 0.507 0.548 0.000 0.452 0.000 0.000 0.000
#> SRR975599 1 0.3151 0.613 0.748 0.000 0.252 0.000 0.000 0.000
#> SRR975600 3 0.0865 0.674 0.000 0.000 0.964 0.000 0.000 0.036
#> SRR975601 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR975602 1 0.0363 0.648 0.988 0.000 0.000 0.012 0.000 0.000
#> SRR975603 3 0.3867 0.295 0.000 0.000 0.512 0.000 0.000 0.488
#> SRR975604 3 0.3868 0.278 0.000 0.000 0.504 0.000 0.000 0.496
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 17171 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 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.633 0.936 0.956 0.4908 0.491 0.491
#> 3 3 0.781 0.860 0.890 0.3090 0.772 0.568
#> 4 4 0.761 0.729 0.851 0.1010 0.901 0.734
#> 5 5 0.725 0.728 0.771 0.0688 0.957 0.862
#> 6 6 0.722 0.437 0.659 0.0479 0.973 0.901
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
#> SRR975551 1 0.482 0.928 0.896 0.104
#> SRR975552 1 0.781 0.766 0.768 0.232
#> SRR975554 1 0.482 0.928 0.896 0.104
#> SRR975553 2 0.118 0.976 0.016 0.984
#> SRR975555 1 0.482 0.928 0.896 0.104
#> SRR975556 2 0.118 0.976 0.016 0.984
#> SRR975557 2 0.000 0.963 0.000 1.000
#> SRR975558 2 0.961 0.329 0.384 0.616
#> SRR975559 1 0.482 0.928 0.896 0.104
#> SRR975560 2 0.118 0.976 0.016 0.984
#> SRR975561 2 0.000 0.963 0.000 1.000
#> SRR975562 1 0.482 0.928 0.896 0.104
#> SRR975563 2 0.118 0.976 0.016 0.984
#> SRR975564 1 0.482 0.928 0.896 0.104
#> SRR975565 1 0.482 0.928 0.896 0.104
#> SRR975566 1 0.482 0.928 0.896 0.104
#> SRR975567 2 0.625 0.810 0.156 0.844
#> SRR975568 1 0.482 0.928 0.896 0.104
#> SRR975569 2 0.118 0.976 0.016 0.984
#> SRR975570 2 0.118 0.976 0.016 0.984
#> SRR975571 2 0.118 0.976 0.016 0.984
#> SRR975572 2 0.118 0.976 0.016 0.984
#> SRR975573 2 0.118 0.976 0.016 0.984
#> SRR975574 2 0.118 0.976 0.016 0.984
#> SRR975575 2 0.118 0.976 0.016 0.984
#> SRR975576 2 0.118 0.976 0.016 0.984
#> SRR975577 2 0.118 0.976 0.016 0.984
#> SRR975578 2 0.118 0.976 0.016 0.984
#> SRR975579 2 0.000 0.963 0.000 1.000
#> SRR975580 2 0.118 0.976 0.016 0.984
#> SRR975581 2 0.118 0.976 0.016 0.984
#> SRR975582 2 0.118 0.976 0.016 0.984
#> SRR975583 2 0.118 0.976 0.016 0.984
#> SRR975584 2 0.118 0.976 0.016 0.984
#> SRR975585 2 0.118 0.976 0.016 0.984
#> SRR975586 2 0.118 0.976 0.016 0.984
#> SRR975587 1 0.000 0.938 1.000 0.000
#> SRR975588 2 0.118 0.976 0.016 0.984
#> SRR975589 1 0.000 0.938 1.000 0.000
#> SRR975590 1 0.000 0.938 1.000 0.000
#> SRR975591 1 0.000 0.938 1.000 0.000
#> SRR975592 1 0.000 0.938 1.000 0.000
#> SRR975593 1 0.000 0.938 1.000 0.000
#> SRR975594 1 0.000 0.938 1.000 0.000
#> SRR975595 1 0.000 0.938 1.000 0.000
#> SRR975597 1 0.000 0.938 1.000 0.000
#> SRR975596 1 0.482 0.928 0.896 0.104
#> SRR975598 1 0.000 0.938 1.000 0.000
#> SRR975599 1 0.482 0.928 0.896 0.104
#> SRR975600 1 0.000 0.938 1.000 0.000
#> SRR975601 1 0.000 0.938 1.000 0.000
#> SRR975602 1 0.482 0.928 0.896 0.104
#> SRR975603 1 0.000 0.938 1.000 0.000
#> SRR975604 1 0.000 0.938 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.5201 0.8231 0.760 0.004 0.236
#> SRR975552 1 0.4575 0.8028 0.812 0.004 0.184
#> SRR975554 1 0.5201 0.8231 0.760 0.004 0.236
#> SRR975553 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975555 1 0.5201 0.8231 0.760 0.004 0.236
#> SRR975556 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975557 1 0.6215 -0.0177 0.572 0.428 0.000
#> SRR975558 1 0.2918 0.6919 0.924 0.044 0.032
#> SRR975559 1 0.1525 0.7112 0.964 0.004 0.032
#> SRR975560 1 0.5216 0.4752 0.740 0.260 0.000
#> SRR975561 2 0.4399 0.8082 0.188 0.812 0.000
#> SRR975562 1 0.5201 0.8231 0.760 0.004 0.236
#> SRR975563 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975564 1 0.5201 0.8231 0.760 0.004 0.236
#> SRR975565 1 0.5201 0.8231 0.760 0.004 0.236
#> SRR975566 1 0.5201 0.8231 0.760 0.004 0.236
#> SRR975567 1 0.2918 0.6919 0.924 0.044 0.032
#> SRR975568 1 0.5201 0.8231 0.760 0.004 0.236
#> SRR975569 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975571 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975572 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975573 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975574 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975575 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975577 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975578 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975579 2 0.4974 0.7604 0.236 0.764 0.000
#> SRR975580 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975581 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975582 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975583 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975584 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975585 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975586 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975587 3 0.0237 0.8998 0.004 0.000 0.996
#> SRR975588 2 0.0000 0.9824 0.000 1.000 0.000
#> SRR975589 3 0.1753 0.8888 0.048 0.000 0.952
#> SRR975590 3 0.4346 0.7792 0.184 0.000 0.816
#> SRR975591 3 0.0000 0.8997 0.000 0.000 1.000
#> SRR975592 3 0.1031 0.8968 0.024 0.000 0.976
#> SRR975593 3 0.1753 0.8888 0.048 0.000 0.952
#> SRR975594 3 0.0237 0.8998 0.004 0.000 0.996
#> SRR975595 3 0.4750 0.7400 0.216 0.000 0.784
#> SRR975597 3 0.4750 0.7400 0.216 0.000 0.784
#> SRR975596 1 0.4784 0.8108 0.796 0.004 0.200
#> SRR975598 3 0.5465 0.6004 0.288 0.000 0.712
#> SRR975599 1 0.5201 0.8231 0.760 0.004 0.236
#> SRR975600 3 0.0000 0.8997 0.000 0.000 1.000
#> SRR975601 3 0.0237 0.8998 0.004 0.000 0.996
#> SRR975602 1 0.5201 0.8231 0.760 0.004 0.236
#> SRR975603 3 0.0000 0.8997 0.000 0.000 1.000
#> SRR975604 3 0.0000 0.8997 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0188 0.769 0.996 0.000 0.000 0.004
#> SRR975552 1 0.0592 0.766 0.984 0.000 0.000 0.016
#> SRR975554 1 0.0188 0.769 0.996 0.000 0.000 0.004
#> SRR975553 2 0.3071 0.901 0.000 0.888 0.044 0.068
#> SRR975555 1 0.0188 0.769 0.996 0.000 0.000 0.004
#> SRR975556 2 0.0336 0.917 0.000 0.992 0.000 0.008
#> SRR975557 4 0.5977 0.360 0.220 0.080 0.008 0.692
#> SRR975558 1 0.5093 0.423 0.640 0.012 0.000 0.348
#> SRR975559 1 0.3801 0.606 0.780 0.000 0.000 0.220
#> SRR975560 1 0.5898 0.332 0.604 0.048 0.000 0.348
#> SRR975561 4 0.4999 0.368 0.000 0.492 0.000 0.508
#> SRR975562 1 0.0336 0.768 0.992 0.000 0.000 0.008
#> SRR975563 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> SRR975564 1 0.0707 0.768 0.980 0.000 0.000 0.020
#> SRR975565 1 0.0188 0.769 0.996 0.000 0.000 0.004
#> SRR975566 1 0.0336 0.768 0.992 0.000 0.000 0.008
#> SRR975567 1 0.5110 0.413 0.636 0.012 0.000 0.352
#> SRR975568 1 0.0707 0.768 0.980 0.000 0.000 0.020
#> SRR975569 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> SRR975571 2 0.3071 0.901 0.000 0.888 0.044 0.068
#> SRR975572 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> SRR975573 2 0.3071 0.901 0.000 0.888 0.044 0.068
#> SRR975574 2 0.3071 0.901 0.000 0.888 0.044 0.068
#> SRR975575 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> SRR975577 2 0.3071 0.901 0.000 0.888 0.044 0.068
#> SRR975578 2 0.3071 0.901 0.000 0.888 0.044 0.068
#> SRR975579 4 0.4836 0.635 0.000 0.320 0.008 0.672
#> SRR975580 2 0.3037 0.900 0.000 0.888 0.036 0.076
#> SRR975581 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> SRR975582 2 0.3071 0.901 0.000 0.888 0.044 0.068
#> SRR975583 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> SRR975584 2 0.3071 0.901 0.000 0.888 0.044 0.068
#> SRR975585 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> SRR975586 2 0.2149 0.810 0.000 0.912 0.000 0.088
#> SRR975587 3 0.2759 0.863 0.052 0.000 0.904 0.044
#> SRR975588 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> SRR975589 3 0.5376 0.813 0.088 0.000 0.736 0.176
#> SRR975590 3 0.7762 0.224 0.380 0.000 0.384 0.236
#> SRR975591 3 0.1474 0.864 0.052 0.000 0.948 0.000
#> SRR975592 3 0.5076 0.823 0.072 0.000 0.756 0.172
#> SRR975593 3 0.5334 0.814 0.088 0.000 0.740 0.172
#> SRR975594 3 0.2759 0.863 0.052 0.000 0.904 0.044
#> SRR975595 1 0.7745 -0.237 0.412 0.000 0.352 0.236
#> SRR975597 1 0.7745 -0.237 0.412 0.000 0.352 0.236
#> SRR975596 1 0.2281 0.723 0.904 0.000 0.000 0.096
#> SRR975598 1 0.7679 -0.137 0.448 0.000 0.316 0.236
#> SRR975599 1 0.2647 0.713 0.880 0.000 0.000 0.120
#> SRR975600 3 0.3312 0.859 0.052 0.000 0.876 0.072
#> SRR975601 3 0.2759 0.863 0.052 0.000 0.904 0.044
#> SRR975602 1 0.2149 0.734 0.912 0.000 0.000 0.088
#> SRR975603 3 0.1474 0.864 0.052 0.000 0.948 0.000
#> SRR975604 3 0.1474 0.864 0.052 0.000 0.948 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.0162 0.804 0.996 0.000 0.000 0.004 0.000
#> SRR975552 1 0.0898 0.808 0.972 0.000 0.000 0.008 0.020
#> SRR975554 1 0.0693 0.806 0.980 0.000 0.000 0.012 0.008
#> SRR975553 2 0.3999 0.711 0.000 0.656 0.000 0.000 0.344
#> SRR975555 1 0.2233 0.789 0.904 0.000 0.000 0.016 0.080
#> SRR975556 2 0.2280 0.688 0.000 0.880 0.000 0.000 0.120
#> SRR975557 4 0.2584 0.653 0.052 0.032 0.008 0.904 0.004
#> SRR975558 1 0.6120 0.568 0.580 0.004 0.000 0.172 0.244
#> SRR975559 1 0.3810 0.755 0.812 0.000 0.000 0.088 0.100
#> SRR975560 1 0.6841 0.494 0.552 0.044 0.000 0.156 0.248
#> SRR975561 4 0.5889 0.395 0.000 0.392 0.000 0.504 0.104
#> SRR975562 1 0.1768 0.804 0.924 0.000 0.000 0.004 0.072
#> SRR975563 2 0.0000 0.779 0.000 1.000 0.000 0.000 0.000
#> SRR975564 1 0.2208 0.804 0.908 0.000 0.000 0.020 0.072
#> SRR975565 1 0.1018 0.807 0.968 0.000 0.000 0.016 0.016
#> SRR975566 1 0.1638 0.804 0.932 0.000 0.000 0.004 0.064
#> SRR975567 1 0.6326 0.507 0.552 0.004 0.000 0.216 0.228
#> SRR975568 1 0.1943 0.801 0.924 0.000 0.000 0.020 0.056
#> SRR975569 2 0.0162 0.779 0.000 0.996 0.000 0.000 0.004
#> SRR975570 2 0.0162 0.779 0.000 0.996 0.000 0.000 0.004
#> SRR975571 2 0.3999 0.711 0.000 0.656 0.000 0.000 0.344
#> SRR975572 2 0.0000 0.779 0.000 1.000 0.000 0.000 0.000
#> SRR975573 2 0.3999 0.711 0.000 0.656 0.000 0.000 0.344
#> SRR975574 2 0.4015 0.710 0.000 0.652 0.000 0.000 0.348
#> SRR975575 2 0.0000 0.779 0.000 1.000 0.000 0.000 0.000
#> SRR975576 2 0.0000 0.779 0.000 1.000 0.000 0.000 0.000
#> SRR975577 2 0.4015 0.710 0.000 0.652 0.000 0.000 0.348
#> SRR975578 2 0.4015 0.710 0.000 0.652 0.000 0.000 0.348
#> SRR975579 4 0.2179 0.709 0.000 0.100 0.000 0.896 0.004
#> SRR975580 2 0.4150 0.642 0.000 0.612 0.000 0.000 0.388
#> SRR975581 2 0.0000 0.779 0.000 1.000 0.000 0.000 0.000
#> SRR975582 2 0.4015 0.710 0.000 0.652 0.000 0.000 0.348
#> SRR975583 2 0.0000 0.779 0.000 1.000 0.000 0.000 0.000
#> SRR975584 2 0.4015 0.710 0.000 0.652 0.000 0.000 0.348
#> SRR975585 2 0.0000 0.779 0.000 1.000 0.000 0.000 0.000
#> SRR975586 2 0.3184 0.614 0.000 0.852 0.000 0.048 0.100
#> SRR975587 3 0.2769 0.749 0.000 0.000 0.876 0.032 0.092
#> SRR975588 2 0.0162 0.779 0.000 0.996 0.000 0.000 0.004
#> SRR975589 3 0.5329 0.502 0.036 0.000 0.684 0.044 0.236
#> SRR975590 5 0.7547 0.917 0.268 0.000 0.324 0.040 0.368
#> SRR975591 3 0.0000 0.784 0.000 0.000 1.000 0.000 0.000
#> SRR975592 3 0.4775 0.575 0.028 0.000 0.740 0.040 0.192
#> SRR975593 3 0.5275 0.509 0.036 0.000 0.692 0.044 0.228
#> SRR975594 3 0.2769 0.749 0.000 0.000 0.876 0.032 0.092
#> SRR975595 5 0.7540 0.939 0.268 0.000 0.316 0.040 0.376
#> SRR975597 5 0.7540 0.939 0.268 0.000 0.316 0.040 0.376
#> SRR975596 1 0.3255 0.774 0.848 0.000 0.000 0.052 0.100
#> SRR975598 5 0.7534 0.857 0.328 0.000 0.260 0.040 0.372
#> SRR975599 1 0.3438 0.613 0.808 0.000 0.000 0.020 0.172
#> SRR975600 3 0.2409 0.749 0.000 0.000 0.900 0.032 0.068
#> SRR975601 3 0.2769 0.749 0.000 0.000 0.876 0.032 0.092
#> SRR975602 1 0.3399 0.620 0.812 0.000 0.000 0.020 0.168
#> SRR975603 3 0.0000 0.784 0.000 0.000 1.000 0.000 0.000
#> SRR975604 3 0.0000 0.784 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.1141 0.71619 0.948 0.000 0.000 0.000 0.052 0.000
#> SRR975552 1 0.2537 0.72346 0.872 0.000 0.000 0.000 0.096 0.032
#> SRR975554 1 0.1890 0.71520 0.916 0.000 0.000 0.000 0.060 0.024
#> SRR975553 2 0.0146 0.41600 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR975555 1 0.4261 0.68518 0.732 0.000 0.000 0.000 0.156 0.112
#> SRR975556 6 0.4334 0.67235 0.000 0.408 0.000 0.000 0.024 0.568
#> SRR975557 4 0.0508 0.64551 0.012 0.000 0.000 0.984 0.000 0.004
#> SRR975558 1 0.6375 0.45314 0.480 0.000 0.000 0.028 0.252 0.240
#> SRR975559 1 0.3956 0.68100 0.796 0.000 0.000 0.028 0.080 0.096
#> SRR975560 1 0.7152 0.36362 0.424 0.032 0.000 0.036 0.208 0.300
#> SRR975561 4 0.7053 -0.00791 0.000 0.164 0.000 0.404 0.104 0.328
#> SRR975562 1 0.3286 0.69940 0.832 0.000 0.000 0.012 0.044 0.112
#> SRR975563 2 0.3995 -0.19010 0.000 0.516 0.000 0.000 0.004 0.480
#> SRR975564 1 0.3878 0.70316 0.772 0.000 0.000 0.000 0.112 0.116
#> SRR975565 1 0.2586 0.72063 0.868 0.000 0.000 0.000 0.100 0.032
#> SRR975566 1 0.1767 0.71579 0.932 0.000 0.000 0.012 0.036 0.020
#> SRR975567 1 0.6990 0.39265 0.452 0.000 0.000 0.092 0.232 0.224
#> SRR975568 1 0.3958 0.70021 0.764 0.000 0.000 0.000 0.128 0.108
#> SRR975569 2 0.3991 -0.17453 0.000 0.524 0.000 0.000 0.004 0.472
#> SRR975570 2 0.3991 -0.17453 0.000 0.524 0.000 0.000 0.004 0.472
#> SRR975571 2 0.0146 0.41600 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR975572 2 0.3995 -0.19010 0.000 0.516 0.000 0.000 0.004 0.480
#> SRR975573 2 0.0000 0.41828 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975574 2 0.0000 0.41828 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975575 2 0.3995 -0.19010 0.000 0.516 0.000 0.000 0.004 0.480
#> SRR975576 2 0.3993 -0.18220 0.000 0.520 0.000 0.000 0.004 0.476
#> SRR975577 2 0.0000 0.41828 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975578 2 0.0146 0.41600 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR975579 4 0.0725 0.66084 0.000 0.012 0.000 0.976 0.000 0.012
#> SRR975580 2 0.4687 -0.02939 0.000 0.684 0.000 0.000 0.136 0.180
#> SRR975581 2 0.3866 -0.18860 0.000 0.516 0.000 0.000 0.000 0.484
#> SRR975582 2 0.0000 0.41828 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975583 2 0.3995 -0.19010 0.000 0.516 0.000 0.000 0.004 0.480
#> SRR975584 2 0.0000 0.41828 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975585 2 0.3995 -0.18792 0.000 0.516 0.000 0.000 0.004 0.480
#> SRR975586 6 0.5672 0.71644 0.000 0.360 0.000 0.020 0.100 0.520
#> SRR975587 3 0.3325 0.65979 0.000 0.000 0.820 0.000 0.096 0.084
#> SRR975588 2 0.3991 -0.17453 0.000 0.524 0.000 0.000 0.004 0.472
#> SRR975589 3 0.5871 0.38981 0.032 0.000 0.572 0.012 0.300 0.084
#> SRR975590 5 0.5204 0.93890 0.128 0.000 0.204 0.000 0.652 0.016
#> SRR975591 3 0.0000 0.71847 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975592 3 0.5421 0.38940 0.024 0.000 0.612 0.012 0.292 0.060
#> SRR975593 3 0.5798 0.39629 0.032 0.000 0.584 0.012 0.292 0.080
#> SRR975594 3 0.3325 0.65979 0.000 0.000 0.820 0.000 0.096 0.084
#> SRR975595 5 0.4653 0.96349 0.120 0.000 0.196 0.000 0.684 0.000
#> SRR975597 5 0.4653 0.96349 0.120 0.000 0.196 0.000 0.684 0.000
#> SRR975596 1 0.4061 0.68235 0.784 0.000 0.000 0.024 0.080 0.112
#> SRR975598 5 0.4701 0.93185 0.148 0.000 0.168 0.000 0.684 0.000
#> SRR975599 1 0.5074 0.31569 0.572 0.000 0.000 0.012 0.356 0.060
#> SRR975600 3 0.3646 0.63063 0.000 0.000 0.800 0.008 0.132 0.060
#> SRR975601 3 0.3325 0.65979 0.000 0.000 0.820 0.000 0.096 0.084
#> SRR975602 1 0.4917 0.41294 0.620 0.000 0.000 0.012 0.308 0.060
#> SRR975603 3 0.0000 0.71847 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975604 3 0.0000 0.71847 0.000 0.000 1.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 17171 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 4.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.969 0.989 0.5093 0.491 0.491
#> 3 3 1.000 0.950 0.978 0.2882 0.820 0.646
#> 4 4 0.940 0.922 0.966 0.1108 0.918 0.766
#> 5 5 0.797 0.729 0.838 0.0586 0.994 0.980
#> 6 6 0.779 0.694 0.731 0.0452 0.921 0.710
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3
There is also optional best \(k\) = 2 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR975551 1 0.000 0.999 1.000 0.000
#> SRR975552 1 0.224 0.961 0.964 0.036
#> SRR975554 1 0.000 0.999 1.000 0.000
#> SRR975553 2 0.000 0.977 0.000 1.000
#> SRR975555 1 0.000 0.999 1.000 0.000
#> SRR975556 2 0.000 0.977 0.000 1.000
#> SRR975557 2 0.000 0.977 0.000 1.000
#> SRR975558 2 0.998 0.116 0.472 0.528
#> SRR975559 1 0.000 0.999 1.000 0.000
#> SRR975560 2 0.000 0.977 0.000 1.000
#> SRR975561 2 0.000 0.977 0.000 1.000
#> SRR975562 1 0.000 0.999 1.000 0.000
#> SRR975563 2 0.000 0.977 0.000 1.000
#> SRR975564 1 0.000 0.999 1.000 0.000
#> SRR975565 1 0.000 0.999 1.000 0.000
#> SRR975566 1 0.000 0.999 1.000 0.000
#> SRR975567 2 0.506 0.861 0.112 0.888
#> SRR975568 1 0.000 0.999 1.000 0.000
#> SRR975569 2 0.000 0.977 0.000 1.000
#> SRR975570 2 0.000 0.977 0.000 1.000
#> SRR975571 2 0.000 0.977 0.000 1.000
#> SRR975572 2 0.000 0.977 0.000 1.000
#> SRR975573 2 0.000 0.977 0.000 1.000
#> SRR975574 2 0.000 0.977 0.000 1.000
#> SRR975575 2 0.000 0.977 0.000 1.000
#> SRR975576 2 0.000 0.977 0.000 1.000
#> SRR975577 2 0.000 0.977 0.000 1.000
#> SRR975578 2 0.000 0.977 0.000 1.000
#> SRR975579 2 0.000 0.977 0.000 1.000
#> SRR975580 2 0.000 0.977 0.000 1.000
#> SRR975581 2 0.000 0.977 0.000 1.000
#> SRR975582 2 0.000 0.977 0.000 1.000
#> SRR975583 2 0.000 0.977 0.000 1.000
#> SRR975584 2 0.000 0.977 0.000 1.000
#> SRR975585 2 0.000 0.977 0.000 1.000
#> SRR975586 2 0.000 0.977 0.000 1.000
#> SRR975587 1 0.000 0.999 1.000 0.000
#> SRR975588 2 0.000 0.977 0.000 1.000
#> SRR975589 1 0.000 0.999 1.000 0.000
#> SRR975590 1 0.000 0.999 1.000 0.000
#> SRR975591 1 0.000 0.999 1.000 0.000
#> SRR975592 1 0.000 0.999 1.000 0.000
#> SRR975593 1 0.000 0.999 1.000 0.000
#> SRR975594 1 0.000 0.999 1.000 0.000
#> SRR975595 1 0.000 0.999 1.000 0.000
#> SRR975597 1 0.000 0.999 1.000 0.000
#> SRR975596 1 0.000 0.999 1.000 0.000
#> SRR975598 1 0.000 0.999 1.000 0.000
#> SRR975599 1 0.000 0.999 1.000 0.000
#> SRR975600 1 0.000 0.999 1.000 0.000
#> SRR975601 1 0.000 0.999 1.000 0.000
#> SRR975602 1 0.000 0.999 1.000 0.000
#> SRR975603 1 0.000 0.999 1.000 0.000
#> SRR975604 1 0.000 0.999 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.0237 0.962 0.996 0.000 0.004
#> SRR975552 1 0.0237 0.962 0.996 0.000 0.004
#> SRR975554 1 0.0237 0.962 0.996 0.000 0.004
#> SRR975553 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975555 1 0.0237 0.962 0.996 0.000 0.004
#> SRR975556 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975557 2 0.6001 0.740 0.176 0.772 0.052
#> SRR975558 1 0.1163 0.941 0.972 0.000 0.028
#> SRR975559 1 0.0000 0.960 1.000 0.000 0.000
#> SRR975560 2 0.4796 0.729 0.220 0.780 0.000
#> SRR975561 2 0.0237 0.979 0.004 0.996 0.000
#> SRR975562 1 0.0237 0.962 0.996 0.000 0.004
#> SRR975563 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975564 1 0.0237 0.962 0.996 0.000 0.004
#> SRR975565 1 0.0237 0.962 0.996 0.000 0.004
#> SRR975566 1 0.0237 0.962 0.996 0.000 0.004
#> SRR975567 1 0.1163 0.941 0.972 0.000 0.028
#> SRR975568 1 0.0237 0.962 0.996 0.000 0.004
#> SRR975569 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975571 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975572 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975573 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975574 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975575 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975577 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975578 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975579 2 0.0237 0.979 0.004 0.996 0.000
#> SRR975580 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975581 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975582 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975583 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975584 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975585 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975586 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975587 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975588 2 0.0000 0.981 0.000 1.000 0.000
#> SRR975589 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975590 3 0.1163 0.970 0.028 0.000 0.972
#> SRR975591 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975592 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975593 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975594 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975595 3 0.1860 0.955 0.052 0.000 0.948
#> SRR975597 3 0.1860 0.955 0.052 0.000 0.948
#> SRR975596 1 0.0000 0.960 1.000 0.000 0.000
#> SRR975598 3 0.1860 0.955 0.052 0.000 0.948
#> SRR975599 1 0.6252 0.176 0.556 0.000 0.444
#> SRR975600 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975601 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975602 1 0.0237 0.962 0.996 0.000 0.004
#> SRR975603 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975604 3 0.0000 0.985 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0000 0.967 1.000 0.000 0.000 0.000
#> SRR975552 1 0.0188 0.965 0.996 0.000 0.000 0.004
#> SRR975554 1 0.0000 0.967 1.000 0.000 0.000 0.000
#> SRR975553 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975555 1 0.0188 0.965 0.996 0.000 0.000 0.004
#> SRR975556 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975557 4 0.0188 0.955 0.000 0.004 0.000 0.996
#> SRR975558 4 0.3400 0.770 0.180 0.000 0.000 0.820
#> SRR975559 1 0.3569 0.750 0.804 0.000 0.000 0.196
#> SRR975560 4 0.0188 0.955 0.000 0.004 0.000 0.996
#> SRR975561 4 0.0707 0.945 0.000 0.020 0.000 0.980
#> SRR975562 1 0.0000 0.967 1.000 0.000 0.000 0.000
#> SRR975563 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975564 1 0.0000 0.967 1.000 0.000 0.000 0.000
#> SRR975565 1 0.0000 0.967 1.000 0.000 0.000 0.000
#> SRR975566 1 0.0188 0.965 0.996 0.000 0.000 0.004
#> SRR975567 4 0.0188 0.953 0.004 0.000 0.000 0.996
#> SRR975568 1 0.0000 0.967 1.000 0.000 0.000 0.000
#> SRR975569 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975572 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975574 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975575 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975578 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975579 4 0.0336 0.954 0.000 0.008 0.000 0.992
#> SRR975580 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975581 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975582 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975583 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975585 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975586 2 0.4941 0.210 0.000 0.564 0.000 0.436
#> SRR975587 3 0.0000 0.929 0.000 0.000 1.000 0.000
#> SRR975588 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> SRR975589 3 0.0000 0.929 0.000 0.000 1.000 0.000
#> SRR975590 3 0.1022 0.910 0.032 0.000 0.968 0.000
#> SRR975591 3 0.0000 0.929 0.000 0.000 1.000 0.000
#> SRR975592 3 0.0000 0.929 0.000 0.000 1.000 0.000
#> SRR975593 3 0.0000 0.929 0.000 0.000 1.000 0.000
#> SRR975594 3 0.0000 0.929 0.000 0.000 1.000 0.000
#> SRR975595 3 0.4018 0.752 0.224 0.000 0.772 0.004
#> SRR975597 3 0.4018 0.752 0.224 0.000 0.772 0.004
#> SRR975596 1 0.2921 0.827 0.860 0.000 0.000 0.140
#> SRR975598 3 0.4699 0.605 0.320 0.000 0.676 0.004
#> SRR975599 1 0.0188 0.965 0.996 0.000 0.000 0.004
#> SRR975600 3 0.0000 0.929 0.000 0.000 1.000 0.000
#> SRR975601 3 0.0000 0.929 0.000 0.000 1.000 0.000
#> SRR975602 1 0.0188 0.965 0.996 0.000 0.000 0.004
#> SRR975603 3 0.0000 0.929 0.000 0.000 1.000 0.000
#> SRR975604 3 0.0000 0.929 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.0510 0.833 0.984 0.000 0.000 0.000 0.016
#> SRR975552 1 0.1410 0.835 0.940 0.000 0.000 0.000 0.060
#> SRR975554 1 0.0880 0.835 0.968 0.000 0.000 0.000 0.032
#> SRR975553 2 0.3857 0.778 0.000 0.688 0.000 0.312 0.000
#> SRR975555 1 0.3177 0.793 0.792 0.000 0.000 0.000 0.208
#> SRR975556 2 0.1792 0.768 0.000 0.916 0.000 0.084 0.000
#> SRR975557 4 0.4235 0.675 0.000 0.000 0.000 0.576 0.424
#> SRR975558 5 0.5283 0.202 0.188 0.000 0.000 0.136 0.676
#> SRR975559 1 0.4451 0.409 0.644 0.000 0.000 0.016 0.340
#> SRR975560 4 0.4268 0.467 0.000 0.000 0.000 0.556 0.444
#> SRR975561 4 0.5019 0.646 0.000 0.052 0.000 0.632 0.316
#> SRR975562 1 0.1704 0.823 0.928 0.000 0.000 0.004 0.068
#> SRR975563 2 0.0000 0.824 0.000 1.000 0.000 0.000 0.000
#> SRR975564 1 0.2732 0.806 0.840 0.000 0.000 0.000 0.160
#> SRR975565 1 0.1851 0.828 0.912 0.000 0.000 0.000 0.088
#> SRR975566 1 0.1792 0.801 0.916 0.000 0.000 0.000 0.084
#> SRR975567 5 0.4171 -0.531 0.000 0.000 0.000 0.396 0.604
#> SRR975568 1 0.2852 0.803 0.828 0.000 0.000 0.000 0.172
#> SRR975569 2 0.0000 0.824 0.000 1.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.824 0.000 1.000 0.000 0.000 0.000
#> SRR975571 2 0.3857 0.778 0.000 0.688 0.000 0.312 0.000
#> SRR975572 2 0.0000 0.824 0.000 1.000 0.000 0.000 0.000
#> SRR975573 2 0.3857 0.778 0.000 0.688 0.000 0.312 0.000
#> SRR975574 2 0.3857 0.778 0.000 0.688 0.000 0.312 0.000
#> SRR975575 2 0.0000 0.824 0.000 1.000 0.000 0.000 0.000
#> SRR975576 2 0.0000 0.824 0.000 1.000 0.000 0.000 0.000
#> SRR975577 2 0.3857 0.778 0.000 0.688 0.000 0.312 0.000
#> SRR975578 2 0.3857 0.778 0.000 0.688 0.000 0.312 0.000
#> SRR975579 4 0.4341 0.704 0.000 0.004 0.000 0.592 0.404
#> SRR975580 2 0.4367 0.723 0.000 0.620 0.000 0.372 0.008
#> SRR975581 2 0.0000 0.824 0.000 1.000 0.000 0.000 0.000
#> SRR975582 2 0.3857 0.778 0.000 0.688 0.000 0.312 0.000
#> SRR975583 2 0.0000 0.824 0.000 1.000 0.000 0.000 0.000
#> SRR975584 2 0.3857 0.778 0.000 0.688 0.000 0.312 0.000
#> SRR975585 2 0.0000 0.824 0.000 1.000 0.000 0.000 0.000
#> SRR975586 2 0.4235 0.129 0.000 0.576 0.000 0.424 0.000
#> SRR975587 3 0.0510 0.881 0.000 0.000 0.984 0.000 0.016
#> SRR975588 2 0.0000 0.824 0.000 1.000 0.000 0.000 0.000
#> SRR975589 3 0.0566 0.881 0.000 0.000 0.984 0.004 0.012
#> SRR975590 3 0.3229 0.805 0.032 0.000 0.840 0.000 0.128
#> SRR975591 3 0.0162 0.881 0.000 0.000 0.996 0.004 0.000
#> SRR975592 3 0.0404 0.881 0.000 0.000 0.988 0.000 0.012
#> SRR975593 3 0.0566 0.881 0.000 0.000 0.984 0.004 0.012
#> SRR975594 3 0.0510 0.881 0.000 0.000 0.984 0.000 0.016
#> SRR975595 3 0.5871 0.598 0.184 0.000 0.604 0.000 0.212
#> SRR975597 3 0.5841 0.602 0.180 0.000 0.608 0.000 0.212
#> SRR975596 1 0.3961 0.601 0.736 0.000 0.000 0.016 0.248
#> SRR975598 3 0.6315 0.463 0.260 0.000 0.528 0.000 0.212
#> SRR975599 1 0.3616 0.719 0.768 0.000 0.004 0.004 0.224
#> SRR975600 3 0.0162 0.881 0.000 0.000 0.996 0.004 0.000
#> SRR975601 3 0.0510 0.881 0.000 0.000 0.984 0.000 0.016
#> SRR975602 1 0.2773 0.771 0.836 0.000 0.000 0.000 0.164
#> SRR975603 3 0.0162 0.881 0.000 0.000 0.996 0.004 0.000
#> SRR975604 3 0.0162 0.881 0.000 0.000 0.996 0.004 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.0717 0.661 0.976 0.008 0.000 0.000 0.000 0.016
#> SRR975552 1 0.1588 0.647 0.924 0.004 0.000 0.000 0.000 0.072
#> SRR975554 1 0.1714 0.653 0.908 0.000 0.000 0.000 0.000 0.092
#> SRR975553 5 0.0146 0.954 0.000 0.000 0.000 0.004 0.996 0.000
#> SRR975555 1 0.4598 0.502 0.592 0.048 0.000 0.000 0.000 0.360
#> SRR975556 2 0.4018 0.683 0.000 0.656 0.000 0.000 0.324 0.020
#> SRR975557 4 0.0458 0.678 0.000 0.000 0.000 0.984 0.000 0.016
#> SRR975558 6 0.5225 0.000 0.112 0.012 0.000 0.248 0.000 0.628
#> SRR975559 1 0.5235 0.217 0.612 0.016 0.000 0.088 0.000 0.284
#> SRR975560 4 0.6374 0.288 0.004 0.184 0.000 0.492 0.028 0.292
#> SRR975561 4 0.1493 0.660 0.000 0.056 0.000 0.936 0.004 0.004
#> SRR975562 1 0.3829 0.601 0.760 0.060 0.000 0.000 0.000 0.180
#> SRR975563 2 0.3854 0.900 0.000 0.536 0.000 0.000 0.464 0.000
#> SRR975564 1 0.3938 0.515 0.660 0.016 0.000 0.000 0.000 0.324
#> SRR975565 1 0.2558 0.625 0.840 0.004 0.000 0.000 0.000 0.156
#> SRR975566 1 0.1765 0.642 0.924 0.024 0.000 0.000 0.000 0.052
#> SRR975567 4 0.4399 0.210 0.004 0.028 0.000 0.616 0.000 0.352
#> SRR975568 1 0.3867 0.512 0.660 0.012 0.000 0.000 0.000 0.328
#> SRR975569 2 0.3857 0.904 0.000 0.532 0.000 0.000 0.468 0.000
#> SRR975570 2 0.3857 0.904 0.000 0.532 0.000 0.000 0.468 0.000
#> SRR975571 5 0.0146 0.954 0.000 0.000 0.000 0.004 0.996 0.000
#> SRR975572 2 0.3857 0.904 0.000 0.532 0.000 0.000 0.468 0.000
#> SRR975573 5 0.0000 0.957 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR975574 5 0.0000 0.957 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR975575 2 0.3857 0.904 0.000 0.532 0.000 0.000 0.468 0.000
#> SRR975576 2 0.3857 0.904 0.000 0.532 0.000 0.000 0.468 0.000
#> SRR975577 5 0.0000 0.957 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR975578 5 0.0146 0.954 0.000 0.004 0.000 0.000 0.996 0.000
#> SRR975579 4 0.0000 0.683 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR975580 5 0.3695 0.648 0.000 0.184 0.000 0.004 0.772 0.040
#> SRR975581 2 0.3857 0.904 0.000 0.532 0.000 0.000 0.468 0.000
#> SRR975582 5 0.0000 0.957 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR975583 2 0.3857 0.904 0.000 0.532 0.000 0.000 0.468 0.000
#> SRR975584 5 0.0000 0.957 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR975585 2 0.3857 0.904 0.000 0.532 0.000 0.000 0.468 0.000
#> SRR975586 2 0.5583 0.327 0.000 0.600 0.000 0.244 0.136 0.020
#> SRR975587 3 0.1334 0.806 0.000 0.020 0.948 0.000 0.000 0.032
#> SRR975588 2 0.3857 0.904 0.000 0.532 0.000 0.000 0.468 0.000
#> SRR975589 3 0.1838 0.787 0.000 0.016 0.916 0.000 0.000 0.068
#> SRR975590 3 0.5761 0.617 0.052 0.156 0.628 0.000 0.000 0.164
#> SRR975591 3 0.0146 0.806 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR975592 3 0.1257 0.807 0.000 0.020 0.952 0.000 0.000 0.028
#> SRR975593 3 0.2030 0.786 0.000 0.028 0.908 0.000 0.000 0.064
#> SRR975594 3 0.0891 0.808 0.000 0.008 0.968 0.000 0.000 0.024
#> SRR975595 3 0.7050 0.416 0.080 0.244 0.412 0.000 0.000 0.264
#> SRR975597 3 0.7040 0.419 0.080 0.244 0.416 0.000 0.000 0.260
#> SRR975596 1 0.4907 0.361 0.636 0.020 0.000 0.052 0.000 0.292
#> SRR975598 3 0.7234 0.373 0.100 0.244 0.384 0.000 0.000 0.272
#> SRR975599 1 0.5894 0.303 0.472 0.244 0.000 0.000 0.000 0.284
#> SRR975600 3 0.0000 0.807 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975601 3 0.1168 0.807 0.000 0.016 0.956 0.000 0.000 0.028
#> SRR975602 1 0.4792 0.521 0.668 0.132 0.000 0.000 0.000 0.200
#> SRR975603 3 0.0146 0.806 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR975604 3 0.0146 0.806 0.000 0.004 0.996 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 17171 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 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.858 0.960 0.974 0.5014 0.491 0.491
#> 3 3 0.951 0.907 0.963 0.2779 0.877 0.749
#> 4 4 0.794 0.731 0.855 0.1068 0.869 0.662
#> 5 5 0.884 0.741 0.885 0.0513 0.932 0.773
#> 6 6 0.889 0.736 0.895 0.0335 0.959 0.847
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
#> SRR975551 1 0.295 0.940 0.948 0.052
#> SRR975552 1 0.730 0.811 0.796 0.204
#> SRR975554 1 0.295 0.940 0.948 0.052
#> SRR975553 2 0.000 1.000 0.000 1.000
#> SRR975555 1 0.722 0.816 0.800 0.200
#> SRR975556 2 0.000 1.000 0.000 1.000
#> SRR975557 2 0.000 1.000 0.000 1.000
#> SRR975558 2 0.000 1.000 0.000 1.000
#> SRR975559 1 0.295 0.940 0.948 0.052
#> SRR975560 2 0.000 1.000 0.000 1.000
#> SRR975561 2 0.000 1.000 0.000 1.000
#> SRR975562 1 0.295 0.940 0.948 0.052
#> SRR975563 2 0.000 1.000 0.000 1.000
#> SRR975564 1 0.689 0.832 0.816 0.184
#> SRR975565 1 0.722 0.816 0.800 0.200
#> SRR975566 1 0.295 0.940 0.948 0.052
#> SRR975567 2 0.000 1.000 0.000 1.000
#> SRR975568 1 0.722 0.816 0.800 0.200
#> SRR975569 2 0.000 1.000 0.000 1.000
#> SRR975570 2 0.000 1.000 0.000 1.000
#> SRR975571 2 0.000 1.000 0.000 1.000
#> SRR975572 2 0.000 1.000 0.000 1.000
#> SRR975573 2 0.000 1.000 0.000 1.000
#> SRR975574 2 0.000 1.000 0.000 1.000
#> SRR975575 2 0.000 1.000 0.000 1.000
#> SRR975576 2 0.000 1.000 0.000 1.000
#> SRR975577 2 0.000 1.000 0.000 1.000
#> SRR975578 2 0.000 1.000 0.000 1.000
#> SRR975579 2 0.000 1.000 0.000 1.000
#> SRR975580 2 0.000 1.000 0.000 1.000
#> SRR975581 2 0.000 1.000 0.000 1.000
#> SRR975582 2 0.000 1.000 0.000 1.000
#> SRR975583 2 0.000 1.000 0.000 1.000
#> SRR975584 2 0.000 1.000 0.000 1.000
#> SRR975585 2 0.000 1.000 0.000 1.000
#> SRR975586 2 0.000 1.000 0.000 1.000
#> SRR975587 1 0.000 0.946 1.000 0.000
#> SRR975588 2 0.000 1.000 0.000 1.000
#> SRR975589 1 0.000 0.946 1.000 0.000
#> SRR975590 1 0.000 0.946 1.000 0.000
#> SRR975591 1 0.000 0.946 1.000 0.000
#> SRR975592 1 0.000 0.946 1.000 0.000
#> SRR975593 1 0.000 0.946 1.000 0.000
#> SRR975594 1 0.000 0.946 1.000 0.000
#> SRR975595 1 0.000 0.946 1.000 0.000
#> SRR975597 1 0.000 0.946 1.000 0.000
#> SRR975596 1 0.295 0.940 0.948 0.052
#> SRR975598 1 0.000 0.946 1.000 0.000
#> SRR975599 1 0.295 0.940 0.948 0.052
#> SRR975600 1 0.000 0.946 1.000 0.000
#> SRR975601 1 0.000 0.946 1.000 0.000
#> SRR975602 1 0.295 0.940 0.948 0.052
#> SRR975603 1 0.000 0.946 1.000 0.000
#> SRR975604 1 0.000 0.946 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.0000 0.927 1.000 0.000 0.000
#> SRR975552 1 0.0000 0.927 1.000 0.000 0.000
#> SRR975554 1 0.0000 0.927 1.000 0.000 0.000
#> SRR975553 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975555 1 0.0000 0.927 1.000 0.000 0.000
#> SRR975556 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975557 2 0.1289 0.939 0.032 0.968 0.000
#> SRR975558 2 0.6305 0.109 0.484 0.516 0.000
#> SRR975559 1 0.0000 0.927 1.000 0.000 0.000
#> SRR975560 2 0.0424 0.960 0.008 0.992 0.000
#> SRR975561 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975562 1 0.0000 0.927 1.000 0.000 0.000
#> SRR975563 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975564 1 0.0000 0.927 1.000 0.000 0.000
#> SRR975565 1 0.0000 0.927 1.000 0.000 0.000
#> SRR975566 1 0.0000 0.927 1.000 0.000 0.000
#> SRR975567 2 0.5678 0.550 0.316 0.684 0.000
#> SRR975568 1 0.0000 0.927 1.000 0.000 0.000
#> SRR975569 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975571 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975572 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975573 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975574 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975575 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975577 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975578 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975579 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975580 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975581 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975582 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975583 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975584 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975585 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975586 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975587 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975588 2 0.0000 0.966 0.000 1.000 0.000
#> SRR975589 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975590 3 0.2261 0.927 0.068 0.000 0.932
#> SRR975591 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975592 3 0.2261 0.927 0.068 0.000 0.932
#> SRR975593 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975594 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975595 1 0.6154 0.344 0.592 0.000 0.408
#> SRR975597 1 0.6204 0.300 0.576 0.000 0.424
#> SRR975596 1 0.2356 0.871 0.928 0.000 0.072
#> SRR975598 1 0.3482 0.817 0.872 0.000 0.128
#> SRR975599 1 0.0000 0.927 1.000 0.000 0.000
#> SRR975600 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975601 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975602 1 0.0000 0.927 1.000 0.000 0.000
#> SRR975603 3 0.0000 0.985 0.000 0.000 1.000
#> SRR975604 3 0.0000 0.985 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0000 0.6070 1.000 0.000 0.000 0.000
#> SRR975552 1 0.4072 0.3172 0.748 0.000 0.000 0.252
#> SRR975554 1 0.2469 0.5292 0.892 0.000 0.000 0.108
#> SRR975553 2 0.0188 0.9907 0.000 0.996 0.000 0.004
#> SRR975555 1 0.0188 0.6066 0.996 0.000 0.000 0.004
#> SRR975556 2 0.0000 0.9912 0.000 1.000 0.000 0.000
#> SRR975557 4 0.5792 0.5280 0.056 0.296 0.000 0.648
#> SRR975558 4 0.6454 0.4893 0.380 0.076 0.000 0.544
#> SRR975559 4 0.4985 0.4032 0.468 0.000 0.000 0.532
#> SRR975560 4 0.5263 0.3676 0.008 0.448 0.000 0.544
#> SRR975561 2 0.2647 0.8545 0.000 0.880 0.000 0.120
#> SRR975562 1 0.4697 -0.0233 0.644 0.000 0.000 0.356
#> SRR975563 2 0.0000 0.9912 0.000 1.000 0.000 0.000
#> SRR975564 1 0.1022 0.5938 0.968 0.000 0.000 0.032
#> SRR975565 1 0.4877 -0.2027 0.592 0.000 0.000 0.408
#> SRR975566 4 0.4985 0.4032 0.468 0.000 0.000 0.532
#> SRR975567 4 0.7152 0.5397 0.284 0.172 0.000 0.544
#> SRR975568 1 0.3610 0.4075 0.800 0.000 0.000 0.200
#> SRR975569 2 0.0000 0.9912 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.9912 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0188 0.9907 0.000 0.996 0.000 0.004
#> SRR975572 2 0.0000 0.9912 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0188 0.9907 0.000 0.996 0.000 0.004
#> SRR975574 2 0.0188 0.9907 0.000 0.996 0.000 0.004
#> SRR975575 2 0.0000 0.9912 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.9912 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0188 0.9907 0.000 0.996 0.000 0.004
#> SRR975578 2 0.0188 0.9907 0.000 0.996 0.000 0.004
#> SRR975579 4 0.4713 0.5010 0.000 0.360 0.000 0.640
#> SRR975580 2 0.0336 0.9875 0.000 0.992 0.000 0.008
#> SRR975581 2 0.0000 0.9912 0.000 1.000 0.000 0.000
#> SRR975582 2 0.0188 0.9907 0.000 0.996 0.000 0.004
#> SRR975583 2 0.0000 0.9912 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0188 0.9907 0.000 0.996 0.000 0.004
#> SRR975585 2 0.0000 0.9912 0.000 1.000 0.000 0.000
#> SRR975586 2 0.0336 0.9849 0.000 0.992 0.000 0.008
#> SRR975587 3 0.0000 0.9181 0.000 0.000 1.000 0.000
#> SRR975588 2 0.0000 0.9912 0.000 1.000 0.000 0.000
#> SRR975589 3 0.3074 0.8440 0.000 0.000 0.848 0.152
#> SRR975590 1 0.7760 0.1637 0.408 0.000 0.240 0.352
#> SRR975591 3 0.0000 0.9181 0.000 0.000 1.000 0.000
#> SRR975592 3 0.6893 0.3924 0.300 0.000 0.564 0.136
#> SRR975593 3 0.3172 0.8390 0.000 0.000 0.840 0.160
#> SRR975594 3 0.0000 0.9181 0.000 0.000 1.000 0.000
#> SRR975595 1 0.6426 0.4791 0.568 0.000 0.080 0.352
#> SRR975597 1 0.6186 0.4960 0.584 0.000 0.064 0.352
#> SRR975596 4 0.4981 0.4041 0.464 0.000 0.000 0.536
#> SRR975598 1 0.5420 0.5226 0.624 0.000 0.024 0.352
#> SRR975599 1 0.3726 0.5710 0.788 0.000 0.000 0.212
#> SRR975600 3 0.0592 0.9131 0.000 0.000 0.984 0.016
#> SRR975601 3 0.0000 0.9181 0.000 0.000 1.000 0.000
#> SRR975602 1 0.0000 0.6070 1.000 0.000 0.000 0.000
#> SRR975603 3 0.0000 0.9181 0.000 0.000 1.000 0.000
#> SRR975604 3 0.0000 0.9181 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.4397 0.5263 0.696 0.000 0.000 0.028 0.276
#> SRR975552 1 0.5642 0.3954 0.636 0.000 0.000 0.184 0.180
#> SRR975554 1 0.0865 0.7152 0.972 0.000 0.000 0.004 0.024
#> SRR975553 2 0.0404 0.9479 0.000 0.988 0.000 0.012 0.000
#> SRR975555 1 0.1444 0.7131 0.948 0.000 0.000 0.012 0.040
#> SRR975556 2 0.0000 0.9493 0.000 1.000 0.000 0.000 0.000
#> SRR975557 4 0.0404 0.4371 0.000 0.012 0.000 0.988 0.000
#> SRR975558 1 0.5557 -0.5187 0.468 0.068 0.000 0.464 0.000
#> SRR975559 4 0.4452 0.4753 0.496 0.000 0.000 0.500 0.004
#> SRR975560 2 0.5177 -0.0111 0.040 0.488 0.000 0.472 0.000
#> SRR975561 2 0.4287 0.3165 0.000 0.540 0.000 0.460 0.000
#> SRR975562 1 0.2519 0.6486 0.884 0.000 0.000 0.100 0.016
#> SRR975563 2 0.0000 0.9493 0.000 1.000 0.000 0.000 0.000
#> SRR975564 1 0.1106 0.7161 0.964 0.000 0.000 0.012 0.024
#> SRR975565 1 0.0000 0.7010 1.000 0.000 0.000 0.000 0.000
#> SRR975566 4 0.4307 0.4713 0.500 0.000 0.000 0.500 0.000
#> SRR975567 4 0.5276 0.4765 0.436 0.048 0.000 0.516 0.000
#> SRR975568 1 0.1106 0.7161 0.964 0.000 0.000 0.012 0.024
#> SRR975569 2 0.0000 0.9493 0.000 1.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.9493 0.000 1.000 0.000 0.000 0.000
#> SRR975571 2 0.0404 0.9479 0.000 0.988 0.000 0.012 0.000
#> SRR975572 2 0.0000 0.9493 0.000 1.000 0.000 0.000 0.000
#> SRR975573 2 0.0404 0.9479 0.000 0.988 0.000 0.012 0.000
#> SRR975574 2 0.0404 0.9479 0.000 0.988 0.000 0.012 0.000
#> SRR975575 2 0.0000 0.9493 0.000 1.000 0.000 0.000 0.000
#> SRR975576 2 0.0000 0.9493 0.000 1.000 0.000 0.000 0.000
#> SRR975577 2 0.0404 0.9479 0.000 0.988 0.000 0.012 0.000
#> SRR975578 2 0.0404 0.9479 0.000 0.988 0.000 0.012 0.000
#> SRR975579 4 0.1792 0.4138 0.000 0.084 0.000 0.916 0.000
#> SRR975580 2 0.0510 0.9456 0.000 0.984 0.000 0.016 0.000
#> SRR975581 2 0.0000 0.9493 0.000 1.000 0.000 0.000 0.000
#> SRR975582 2 0.0404 0.9479 0.000 0.988 0.000 0.012 0.000
#> SRR975583 2 0.0000 0.9493 0.000 1.000 0.000 0.000 0.000
#> SRR975584 2 0.0404 0.9479 0.000 0.988 0.000 0.012 0.000
#> SRR975585 2 0.0000 0.9493 0.000 1.000 0.000 0.000 0.000
#> SRR975586 2 0.0404 0.9421 0.000 0.988 0.000 0.012 0.000
#> SRR975587 3 0.0000 0.9458 0.000 0.000 1.000 0.000 0.000
#> SRR975588 2 0.0000 0.9493 0.000 1.000 0.000 0.000 0.000
#> SRR975589 3 0.2891 0.7921 0.000 0.000 0.824 0.000 0.176
#> SRR975590 5 0.0162 0.8515 0.004 0.000 0.000 0.000 0.996
#> SRR975591 3 0.0000 0.9458 0.000 0.000 1.000 0.000 0.000
#> SRR975592 5 0.4300 -0.0282 0.000 0.000 0.476 0.000 0.524
#> SRR975593 3 0.2966 0.7829 0.000 0.000 0.816 0.000 0.184
#> SRR975594 3 0.0000 0.9458 0.000 0.000 1.000 0.000 0.000
#> SRR975595 5 0.0000 0.8544 0.000 0.000 0.000 0.000 1.000
#> SRR975597 5 0.0000 0.8544 0.000 0.000 0.000 0.000 1.000
#> SRR975596 4 0.4306 0.4734 0.492 0.000 0.000 0.508 0.000
#> SRR975598 5 0.0000 0.8544 0.000 0.000 0.000 0.000 1.000
#> SRR975599 1 0.4731 0.1912 0.528 0.000 0.000 0.016 0.456
#> SRR975600 3 0.0510 0.9372 0.000 0.000 0.984 0.000 0.016
#> SRR975601 3 0.0000 0.9458 0.000 0.000 1.000 0.000 0.000
#> SRR975602 1 0.3214 0.6763 0.844 0.000 0.000 0.036 0.120
#> SRR975603 3 0.0000 0.9458 0.000 0.000 1.000 0.000 0.000
#> SRR975604 3 0.0000 0.9458 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.6116 0.0408 0.360 0.000 0.000 0.000 0.340 0.300
#> SRR975552 6 0.5554 0.2888 0.276 0.000 0.000 0.000 0.180 0.544
#> SRR975554 1 0.2793 0.4694 0.800 0.000 0.000 0.000 0.000 0.200
#> SRR975553 2 0.1176 0.9463 0.000 0.956 0.000 0.024 0.000 0.020
#> SRR975555 1 0.0000 0.6310 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR975556 2 0.0146 0.9531 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR975557 4 0.0547 0.6416 0.000 0.000 0.000 0.980 0.000 0.020
#> SRR975558 1 0.3944 -0.0195 0.568 0.004 0.000 0.000 0.000 0.428
#> SRR975559 6 0.0547 0.7149 0.020 0.000 0.000 0.000 0.000 0.980
#> SRR975560 2 0.4623 0.2170 0.016 0.540 0.000 0.016 0.000 0.428
#> SRR975561 4 0.3727 0.3755 0.000 0.388 0.000 0.612 0.000 0.000
#> SRR975562 6 0.4095 -0.0227 0.480 0.000 0.000 0.000 0.008 0.512
#> SRR975563 2 0.0000 0.9536 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975564 1 0.0000 0.6310 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR975565 1 0.0000 0.6310 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR975566 6 0.0632 0.7155 0.024 0.000 0.000 0.000 0.000 0.976
#> SRR975567 6 0.3618 0.6191 0.124 0.032 0.000 0.032 0.000 0.812
#> SRR975568 1 0.0000 0.6310 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR975569 2 0.0000 0.9536 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.9536 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975571 2 0.1176 0.9463 0.000 0.956 0.000 0.024 0.000 0.020
#> SRR975572 2 0.0000 0.9536 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975573 2 0.0993 0.9479 0.000 0.964 0.000 0.024 0.000 0.012
#> SRR975574 2 0.1176 0.9463 0.000 0.956 0.000 0.024 0.000 0.020
#> SRR975575 2 0.0000 0.9536 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975576 2 0.0000 0.9536 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975577 2 0.1176 0.9463 0.000 0.956 0.000 0.024 0.000 0.020
#> SRR975578 2 0.1176 0.9463 0.000 0.956 0.000 0.024 0.000 0.020
#> SRR975579 4 0.0692 0.6424 0.000 0.004 0.000 0.976 0.000 0.020
#> SRR975580 2 0.1261 0.9439 0.000 0.952 0.000 0.024 0.000 0.024
#> SRR975581 2 0.0000 0.9536 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975582 2 0.1176 0.9463 0.000 0.956 0.000 0.024 0.000 0.020
#> SRR975583 2 0.0000 0.9536 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975584 2 0.1176 0.9463 0.000 0.956 0.000 0.024 0.000 0.020
#> SRR975585 2 0.0000 0.9536 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975586 2 0.0000 0.9536 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975587 3 0.0000 0.9463 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975588 2 0.0000 0.9536 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975589 3 0.2703 0.7948 0.004 0.000 0.824 0.000 0.172 0.000
#> SRR975590 5 0.0000 0.8351 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR975591 3 0.0000 0.9463 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975592 5 0.3862 -0.0346 0.000 0.000 0.476 0.000 0.524 0.000
#> SRR975593 3 0.2664 0.7835 0.000 0.000 0.816 0.000 0.184 0.000
#> SRR975594 3 0.0000 0.9463 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975595 5 0.0000 0.8351 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR975597 5 0.0000 0.8351 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR975596 6 0.0713 0.7158 0.028 0.000 0.000 0.000 0.000 0.972
#> SRR975598 5 0.0000 0.8351 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR975599 1 0.4385 0.2997 0.532 0.000 0.000 0.000 0.444 0.024
#> SRR975600 3 0.0458 0.9378 0.000 0.000 0.984 0.000 0.016 0.000
#> SRR975601 3 0.0000 0.9463 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975602 1 0.5877 0.0819 0.428 0.000 0.000 0.000 0.200 0.372
#> SRR975603 3 0.0000 0.9463 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975604 3 0.0000 0.9463 0.000 0.000 1.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 17171 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 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.509 0.797 0.859 0.4384 0.560 0.560
#> 3 3 0.595 0.792 0.861 0.4645 0.762 0.584
#> 4 4 0.887 0.893 0.928 0.1587 0.869 0.638
#> 5 5 0.880 0.891 0.864 0.0499 0.966 0.860
#> 6 6 0.831 0.813 0.868 0.0297 0.983 0.920
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
#> SRR975551 1 0.000 0.766 1.000 0.000
#> SRR975552 1 0.000 0.766 1.000 0.000
#> SRR975554 1 0.000 0.766 1.000 0.000
#> SRR975553 2 0.973 0.870 0.404 0.596
#> SRR975555 1 0.000 0.766 1.000 0.000
#> SRR975556 1 0.358 0.681 0.932 0.068
#> SRR975557 1 0.000 0.766 1.000 0.000
#> SRR975558 1 0.000 0.766 1.000 0.000
#> SRR975559 1 0.000 0.766 1.000 0.000
#> SRR975560 1 0.118 0.751 0.984 0.016
#> SRR975561 1 0.184 0.737 0.972 0.028
#> SRR975562 1 0.000 0.766 1.000 0.000
#> SRR975563 2 0.900 0.984 0.316 0.684
#> SRR975564 1 0.000 0.766 1.000 0.000
#> SRR975565 1 0.000 0.766 1.000 0.000
#> SRR975566 1 0.000 0.766 1.000 0.000
#> SRR975567 1 0.000 0.766 1.000 0.000
#> SRR975568 1 0.000 0.766 1.000 0.000
#> SRR975569 2 0.900 0.984 0.316 0.684
#> SRR975570 2 0.900 0.984 0.316 0.684
#> SRR975571 2 0.973 0.870 0.404 0.596
#> SRR975572 2 0.900 0.984 0.316 0.684
#> SRR975573 2 0.900 0.984 0.316 0.684
#> SRR975574 1 0.992 -0.560 0.552 0.448
#> SRR975575 2 0.900 0.984 0.316 0.684
#> SRR975576 2 0.900 0.984 0.316 0.684
#> SRR975577 2 0.900 0.984 0.316 0.684
#> SRR975578 2 0.900 0.984 0.316 0.684
#> SRR975579 1 0.141 0.747 0.980 0.020
#> SRR975580 1 0.141 0.747 0.980 0.020
#> SRR975581 2 0.904 0.980 0.320 0.680
#> SRR975582 2 0.900 0.984 0.316 0.684
#> SRR975583 2 0.900 0.984 0.316 0.684
#> SRR975584 2 0.900 0.984 0.316 0.684
#> SRR975585 2 0.900 0.984 0.316 0.684
#> SRR975586 1 0.358 0.681 0.932 0.068
#> SRR975587 1 0.900 0.750 0.684 0.316
#> SRR975588 2 0.900 0.984 0.316 0.684
#> SRR975589 1 0.900 0.750 0.684 0.316
#> SRR975590 1 0.900 0.750 0.684 0.316
#> SRR975591 1 0.900 0.750 0.684 0.316
#> SRR975592 1 0.900 0.750 0.684 0.316
#> SRR975593 1 0.900 0.750 0.684 0.316
#> SRR975594 1 0.900 0.750 0.684 0.316
#> SRR975595 1 0.900 0.750 0.684 0.316
#> SRR975597 1 0.900 0.750 0.684 0.316
#> SRR975596 1 0.000 0.766 1.000 0.000
#> SRR975598 1 0.900 0.750 0.684 0.316
#> SRR975599 1 0.900 0.750 0.684 0.316
#> SRR975600 1 0.900 0.750 0.684 0.316
#> SRR975601 1 0.900 0.750 0.684 0.316
#> SRR975602 1 0.653 0.760 0.832 0.168
#> SRR975603 1 0.900 0.750 0.684 0.316
#> SRR975604 1 0.900 0.750 0.684 0.316
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.0237 0.833 0.996 0.004 0.000
#> SRR975552 1 0.4477 0.856 0.864 0.068 0.068
#> SRR975554 1 0.2496 0.889 0.928 0.068 0.004
#> SRR975553 2 0.1525 0.949 0.004 0.964 0.032
#> SRR975555 1 0.2261 0.888 0.932 0.068 0.000
#> SRR975556 3 0.7983 0.518 0.104 0.264 0.632
#> SRR975557 3 0.6148 0.672 0.076 0.148 0.776
#> SRR975558 3 0.6252 0.662 0.144 0.084 0.772
#> SRR975559 1 0.7176 0.582 0.684 0.068 0.248
#> SRR975560 3 0.6252 0.662 0.144 0.084 0.772
#> SRR975561 3 0.6208 0.669 0.076 0.152 0.772
#> SRR975562 1 0.2496 0.889 0.928 0.068 0.004
#> SRR975563 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975564 1 0.2496 0.889 0.928 0.068 0.004
#> SRR975565 1 0.2261 0.888 0.932 0.068 0.000
#> SRR975566 1 0.5153 0.824 0.832 0.068 0.100
#> SRR975567 3 0.6252 0.662 0.144 0.084 0.772
#> SRR975568 1 0.2261 0.888 0.932 0.068 0.000
#> SRR975569 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975571 2 0.1525 0.949 0.004 0.964 0.032
#> SRR975572 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975573 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975574 2 0.3879 0.780 0.000 0.848 0.152
#> SRR975575 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975577 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975578 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975579 3 0.6122 0.671 0.072 0.152 0.776
#> SRR975580 3 0.7692 0.581 0.136 0.184 0.680
#> SRR975581 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975582 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975583 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975584 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975585 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975586 3 0.7764 0.472 0.068 0.328 0.604
#> SRR975587 3 0.3038 0.733 0.104 0.000 0.896
#> SRR975588 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975589 3 0.5327 0.583 0.272 0.000 0.728
#> SRR975590 3 0.5835 0.572 0.340 0.000 0.660
#> SRR975591 3 0.1529 0.736 0.040 0.000 0.960
#> SRR975592 3 0.5327 0.583 0.272 0.000 0.728
#> SRR975593 3 0.5327 0.583 0.272 0.000 0.728
#> SRR975594 3 0.1753 0.736 0.048 0.000 0.952
#> SRR975595 3 0.5835 0.572 0.340 0.000 0.660
#> SRR975597 3 0.5835 0.572 0.340 0.000 0.660
#> SRR975596 1 0.7022 0.617 0.700 0.068 0.232
#> SRR975598 3 0.5835 0.572 0.340 0.000 0.660
#> SRR975599 3 0.4062 0.727 0.164 0.000 0.836
#> SRR975600 3 0.1529 0.736 0.040 0.000 0.960
#> SRR975601 3 0.3038 0.733 0.104 0.000 0.896
#> SRR975602 1 0.2448 0.807 0.924 0.000 0.076
#> SRR975603 3 0.1529 0.736 0.040 0.000 0.960
#> SRR975604 3 0.1529 0.736 0.040 0.000 0.960
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0188 0.930 0.996 0.000 0.000 0.004
#> SRR975552 1 0.1211 0.926 0.960 0.000 0.000 0.040
#> SRR975554 1 0.0937 0.936 0.976 0.000 0.012 0.012
#> SRR975553 2 0.1022 0.969 0.000 0.968 0.000 0.032
#> SRR975555 1 0.0469 0.937 0.988 0.000 0.000 0.012
#> SRR975556 4 0.2313 0.906 0.044 0.032 0.000 0.924
#> SRR975557 4 0.1792 0.924 0.068 0.000 0.000 0.932
#> SRR975558 4 0.1792 0.924 0.068 0.000 0.000 0.932
#> SRR975559 1 0.2300 0.910 0.924 0.000 0.028 0.048
#> SRR975560 4 0.1792 0.924 0.068 0.000 0.000 0.932
#> SRR975561 4 0.1792 0.924 0.068 0.000 0.000 0.932
#> SRR975562 1 0.0937 0.936 0.976 0.000 0.012 0.012
#> SRR975563 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> SRR975564 1 0.0469 0.937 0.988 0.000 0.000 0.012
#> SRR975565 1 0.0469 0.937 0.988 0.000 0.000 0.012
#> SRR975566 1 0.0469 0.937 0.988 0.000 0.000 0.012
#> SRR975567 4 0.1792 0.924 0.068 0.000 0.000 0.932
#> SRR975568 1 0.0469 0.937 0.988 0.000 0.000 0.012
#> SRR975569 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> SRR975571 2 0.1022 0.969 0.000 0.968 0.000 0.032
#> SRR975572 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> SRR975574 4 0.4898 0.303 0.000 0.416 0.000 0.584
#> SRR975575 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> SRR975578 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> SRR975579 4 0.1902 0.923 0.064 0.004 0.000 0.932
#> SRR975580 4 0.1902 0.923 0.064 0.004 0.000 0.932
#> SRR975581 2 0.1022 0.969 0.000 0.968 0.000 0.032
#> SRR975582 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> SRR975583 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> SRR975585 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> SRR975586 4 0.3082 0.862 0.032 0.084 0.000 0.884
#> SRR975587 3 0.0469 0.848 0.000 0.000 0.988 0.012
#> SRR975588 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> SRR975589 3 0.3908 0.816 0.212 0.000 0.784 0.004
#> SRR975590 3 0.5500 0.795 0.224 0.000 0.708 0.068
#> SRR975591 3 0.0000 0.850 0.000 0.000 1.000 0.000
#> SRR975592 3 0.3908 0.816 0.212 0.000 0.784 0.004
#> SRR975593 3 0.3908 0.816 0.212 0.000 0.784 0.004
#> SRR975594 3 0.0000 0.850 0.000 0.000 1.000 0.000
#> SRR975595 3 0.5500 0.795 0.224 0.000 0.708 0.068
#> SRR975597 3 0.5500 0.795 0.224 0.000 0.708 0.068
#> SRR975596 1 0.1733 0.924 0.948 0.000 0.024 0.028
#> SRR975598 3 0.5500 0.795 0.224 0.000 0.708 0.068
#> SRR975599 1 0.7638 0.150 0.448 0.000 0.220 0.332
#> SRR975600 3 0.0000 0.850 0.000 0.000 1.000 0.000
#> SRR975601 3 0.0336 0.849 0.000 0.000 0.992 0.008
#> SRR975602 1 0.1209 0.914 0.964 0.000 0.032 0.004
#> SRR975603 3 0.0000 0.850 0.000 0.000 1.000 0.000
#> SRR975604 3 0.0000 0.850 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.0693 0.864 0.980 0.000 0.000 0.012 0.008
#> SRR975552 1 0.2605 0.866 0.852 0.000 0.000 0.148 0.000
#> SRR975554 1 0.2233 0.902 0.904 0.000 0.000 0.080 0.016
#> SRR975553 2 0.1800 0.958 0.000 0.932 0.048 0.020 0.000
#> SRR975555 1 0.1478 0.900 0.936 0.000 0.000 0.064 0.000
#> SRR975556 4 0.4256 0.809 0.004 0.052 0.160 0.780 0.004
#> SRR975557 4 0.1612 0.852 0.024 0.000 0.016 0.948 0.012
#> SRR975558 4 0.1124 0.856 0.036 0.000 0.000 0.960 0.004
#> SRR975559 1 0.3656 0.803 0.784 0.000 0.000 0.196 0.020
#> SRR975560 4 0.1285 0.856 0.036 0.000 0.004 0.956 0.004
#> SRR975561 4 0.3545 0.835 0.020 0.008 0.140 0.828 0.004
#> SRR975562 1 0.2110 0.902 0.912 0.000 0.000 0.072 0.016
#> SRR975563 2 0.0290 0.980 0.000 0.992 0.008 0.000 0.000
#> SRR975564 1 0.2020 0.899 0.900 0.000 0.000 0.100 0.000
#> SRR975565 1 0.1608 0.901 0.928 0.000 0.000 0.072 0.000
#> SRR975566 1 0.2017 0.903 0.912 0.000 0.000 0.080 0.008
#> SRR975567 4 0.1124 0.856 0.036 0.000 0.000 0.960 0.004
#> SRR975568 1 0.1732 0.901 0.920 0.000 0.000 0.080 0.000
#> SRR975569 2 0.0693 0.977 0.000 0.980 0.008 0.012 0.000
#> SRR975570 2 0.0404 0.979 0.000 0.988 0.012 0.000 0.000
#> SRR975571 2 0.1800 0.958 0.000 0.932 0.048 0.020 0.000
#> SRR975572 2 0.0000 0.979 0.000 1.000 0.000 0.000 0.000
#> SRR975573 2 0.0693 0.977 0.000 0.980 0.008 0.012 0.000
#> SRR975574 4 0.6333 0.424 0.000 0.328 0.176 0.496 0.000
#> SRR975575 2 0.0000 0.979 0.000 1.000 0.000 0.000 0.000
#> SRR975576 2 0.0162 0.979 0.000 0.996 0.004 0.000 0.000
#> SRR975577 2 0.0807 0.977 0.000 0.976 0.012 0.012 0.000
#> SRR975578 2 0.1907 0.956 0.000 0.928 0.044 0.028 0.000
#> SRR975579 4 0.1679 0.856 0.020 0.004 0.016 0.948 0.012
#> SRR975580 4 0.2426 0.854 0.008 0.016 0.064 0.908 0.004
#> SRR975581 2 0.1626 0.962 0.000 0.940 0.044 0.016 0.000
#> SRR975582 2 0.0703 0.977 0.000 0.976 0.024 0.000 0.000
#> SRR975583 2 0.0000 0.979 0.000 1.000 0.000 0.000 0.000
#> SRR975584 2 0.1106 0.974 0.000 0.964 0.024 0.012 0.000
#> SRR975585 2 0.0000 0.979 0.000 1.000 0.000 0.000 0.000
#> SRR975586 4 0.5065 0.769 0.004 0.120 0.148 0.724 0.004
#> SRR975587 3 0.3274 0.992 0.000 0.000 0.780 0.000 0.220
#> SRR975588 2 0.0404 0.979 0.000 0.988 0.012 0.000 0.000
#> SRR975589 5 0.3482 0.813 0.012 0.000 0.168 0.008 0.812
#> SRR975590 5 0.0404 0.881 0.012 0.000 0.000 0.000 0.988
#> SRR975591 3 0.3242 0.994 0.000 0.000 0.784 0.000 0.216
#> SRR975592 5 0.3399 0.809 0.012 0.000 0.172 0.004 0.812
#> SRR975593 5 0.3482 0.813 0.012 0.000 0.168 0.008 0.812
#> SRR975594 3 0.3242 0.994 0.000 0.000 0.784 0.000 0.216
#> SRR975595 5 0.0404 0.881 0.012 0.000 0.000 0.000 0.988
#> SRR975597 5 0.0404 0.881 0.012 0.000 0.000 0.000 0.988
#> SRR975596 1 0.2616 0.893 0.880 0.000 0.000 0.100 0.020
#> SRR975598 5 0.0404 0.881 0.012 0.000 0.000 0.000 0.988
#> SRR975599 1 0.7213 0.120 0.448 0.000 0.028 0.248 0.276
#> SRR975600 3 0.3491 0.977 0.000 0.000 0.768 0.004 0.228
#> SRR975601 3 0.3274 0.992 0.000 0.000 0.780 0.000 0.220
#> SRR975602 1 0.0992 0.862 0.968 0.000 0.000 0.008 0.024
#> SRR975603 3 0.3242 0.994 0.000 0.000 0.784 0.000 0.216
#> SRR975604 3 0.3242 0.994 0.000 0.000 0.784 0.000 0.216
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.1075 0.894 0.952 0.000 0.000 0.048 0.000 0.000
#> SRR975552 1 0.2121 0.890 0.892 0.000 0.000 0.096 0.012 0.000
#> SRR975554 1 0.1267 0.916 0.940 0.000 0.000 0.060 0.000 0.000
#> SRR975553 2 0.2664 0.838 0.000 0.816 0.000 0.000 0.184 0.000
#> SRR975555 1 0.0713 0.916 0.972 0.000 0.000 0.028 0.000 0.000
#> SRR975556 5 0.4189 0.163 0.000 0.020 0.000 0.376 0.604 0.000
#> SRR975557 4 0.3954 0.664 0.056 0.000 0.000 0.740 0.204 0.000
#> SRR975558 4 0.1204 0.759 0.056 0.000 0.000 0.944 0.000 0.000
#> SRR975559 1 0.2020 0.890 0.896 0.000 0.000 0.096 0.008 0.000
#> SRR975560 4 0.2978 0.729 0.056 0.012 0.000 0.860 0.072 0.000
#> SRR975561 5 0.6666 0.364 0.052 0.176 0.000 0.384 0.388 0.000
#> SRR975562 1 0.0937 0.917 0.960 0.000 0.000 0.040 0.000 0.000
#> SRR975563 2 0.1765 0.892 0.000 0.904 0.000 0.000 0.096 0.000
#> SRR975564 1 0.1267 0.915 0.940 0.000 0.000 0.060 0.000 0.000
#> SRR975565 1 0.0458 0.918 0.984 0.000 0.000 0.016 0.000 0.000
#> SRR975566 1 0.0858 0.917 0.968 0.000 0.000 0.028 0.004 0.000
#> SRR975567 4 0.1204 0.759 0.056 0.000 0.000 0.944 0.000 0.000
#> SRR975568 1 0.1075 0.918 0.952 0.000 0.000 0.048 0.000 0.000
#> SRR975569 2 0.0547 0.900 0.000 0.980 0.000 0.000 0.020 0.000
#> SRR975570 2 0.0632 0.897 0.000 0.976 0.000 0.000 0.024 0.000
#> SRR975571 2 0.2664 0.838 0.000 0.816 0.000 0.000 0.184 0.000
#> SRR975572 2 0.0632 0.897 0.000 0.976 0.000 0.000 0.024 0.000
#> SRR975573 2 0.0547 0.901 0.000 0.980 0.000 0.000 0.020 0.000
#> SRR975574 5 0.5095 0.506 0.000 0.312 0.000 0.104 0.584 0.000
#> SRR975575 2 0.0632 0.897 0.000 0.976 0.000 0.000 0.024 0.000
#> SRR975576 2 0.1765 0.892 0.000 0.904 0.000 0.000 0.096 0.000
#> SRR975577 2 0.2219 0.874 0.000 0.864 0.000 0.000 0.136 0.000
#> SRR975578 2 0.3198 0.731 0.000 0.740 0.000 0.000 0.260 0.000
#> SRR975579 4 0.5725 0.450 0.052 0.064 0.000 0.548 0.336 0.000
#> SRR975580 4 0.3809 0.485 0.008 0.012 0.000 0.716 0.264 0.000
#> SRR975581 2 0.1141 0.893 0.000 0.948 0.000 0.000 0.052 0.000
#> SRR975582 2 0.1910 0.887 0.000 0.892 0.000 0.000 0.108 0.000
#> SRR975583 2 0.0632 0.897 0.000 0.976 0.000 0.000 0.024 0.000
#> SRR975584 2 0.2219 0.874 0.000 0.864 0.000 0.000 0.136 0.000
#> SRR975585 2 0.0632 0.897 0.000 0.976 0.000 0.000 0.024 0.000
#> SRR975586 5 0.6057 0.573 0.008 0.268 0.000 0.240 0.484 0.000
#> SRR975587 3 0.0713 0.968 0.000 0.000 0.972 0.000 0.028 0.000
#> SRR975588 2 0.0632 0.897 0.000 0.976 0.000 0.000 0.024 0.000
#> SRR975589 6 0.4225 0.780 0.000 0.000 0.192 0.064 0.008 0.736
#> SRR975590 6 0.0363 0.855 0.000 0.000 0.012 0.000 0.000 0.988
#> SRR975591 3 0.0000 0.969 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975592 6 0.3337 0.738 0.000 0.000 0.260 0.000 0.004 0.736
#> SRR975593 6 0.4172 0.779 0.000 0.000 0.200 0.056 0.008 0.736
#> SRR975594 3 0.0713 0.968 0.000 0.000 0.972 0.000 0.028 0.000
#> SRR975595 6 0.0260 0.853 0.000 0.000 0.000 0.000 0.008 0.992
#> SRR975597 6 0.0260 0.853 0.000 0.000 0.000 0.000 0.008 0.992
#> SRR975596 1 0.1812 0.903 0.912 0.000 0.000 0.080 0.008 0.000
#> SRR975598 6 0.0405 0.851 0.004 0.000 0.000 0.000 0.008 0.988
#> SRR975599 1 0.5204 0.258 0.536 0.000 0.000 0.364 0.000 0.100
#> SRR975600 3 0.1858 0.871 0.000 0.000 0.904 0.000 0.004 0.092
#> SRR975601 3 0.0713 0.968 0.000 0.000 0.972 0.000 0.028 0.000
#> SRR975602 1 0.1141 0.896 0.948 0.000 0.000 0.052 0.000 0.000
#> SRR975603 3 0.0000 0.969 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975604 3 0.0000 0.969 0.000 0.000 1.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 17171 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 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.975 0.990 0.5092 0.491 0.491
#> 3 3 0.862 0.857 0.930 0.2541 0.840 0.682
#> 4 4 0.851 0.836 0.921 0.0893 0.892 0.725
#> 5 5 0.857 0.787 0.895 0.0834 0.923 0.762
#> 6 6 0.732 0.550 0.741 0.0657 0.924 0.703
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
#> SRR975551 1 0.000 0.984 1.000 0.000
#> SRR975552 1 0.204 0.954 0.968 0.032
#> SRR975554 1 0.000 0.984 1.000 0.000
#> SRR975553 2 0.000 0.995 0.000 1.000
#> SRR975555 1 0.000 0.984 1.000 0.000
#> SRR975556 2 0.000 0.995 0.000 1.000
#> SRR975557 2 0.000 0.995 0.000 1.000
#> SRR975558 1 0.966 0.350 0.608 0.392
#> SRR975559 1 0.000 0.984 1.000 0.000
#> SRR975560 2 0.000 0.995 0.000 1.000
#> SRR975561 2 0.000 0.995 0.000 1.000
#> SRR975562 1 0.000 0.984 1.000 0.000
#> SRR975563 2 0.000 0.995 0.000 1.000
#> SRR975564 1 0.000 0.984 1.000 0.000
#> SRR975565 1 0.000 0.984 1.000 0.000
#> SRR975566 1 0.000 0.984 1.000 0.000
#> SRR975567 2 0.529 0.860 0.120 0.880
#> SRR975568 1 0.000 0.984 1.000 0.000
#> SRR975569 2 0.000 0.995 0.000 1.000
#> SRR975570 2 0.000 0.995 0.000 1.000
#> SRR975571 2 0.000 0.995 0.000 1.000
#> SRR975572 2 0.000 0.995 0.000 1.000
#> SRR975573 2 0.000 0.995 0.000 1.000
#> SRR975574 2 0.000 0.995 0.000 1.000
#> SRR975575 2 0.000 0.995 0.000 1.000
#> SRR975576 2 0.000 0.995 0.000 1.000
#> SRR975577 2 0.000 0.995 0.000 1.000
#> SRR975578 2 0.000 0.995 0.000 1.000
#> SRR975579 2 0.000 0.995 0.000 1.000
#> SRR975580 2 0.000 0.995 0.000 1.000
#> SRR975581 2 0.000 0.995 0.000 1.000
#> SRR975582 2 0.000 0.995 0.000 1.000
#> SRR975583 2 0.000 0.995 0.000 1.000
#> SRR975584 2 0.000 0.995 0.000 1.000
#> SRR975585 2 0.000 0.995 0.000 1.000
#> SRR975586 2 0.000 0.995 0.000 1.000
#> SRR975587 1 0.000 0.984 1.000 0.000
#> SRR975588 2 0.000 0.995 0.000 1.000
#> SRR975589 1 0.000 0.984 1.000 0.000
#> SRR975590 1 0.000 0.984 1.000 0.000
#> SRR975591 1 0.000 0.984 1.000 0.000
#> SRR975592 1 0.000 0.984 1.000 0.000
#> SRR975593 1 0.000 0.984 1.000 0.000
#> SRR975594 1 0.000 0.984 1.000 0.000
#> SRR975595 1 0.000 0.984 1.000 0.000
#> SRR975597 1 0.000 0.984 1.000 0.000
#> SRR975596 1 0.000 0.984 1.000 0.000
#> SRR975598 1 0.000 0.984 1.000 0.000
#> SRR975599 1 0.000 0.984 1.000 0.000
#> SRR975600 1 0.000 0.984 1.000 0.000
#> SRR975601 1 0.000 0.984 1.000 0.000
#> SRR975602 1 0.000 0.984 1.000 0.000
#> SRR975603 1 0.000 0.984 1.000 0.000
#> SRR975604 1 0.000 0.984 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.2356 0.890 0.928 0.000 0.072
#> SRR975552 1 0.2356 0.890 0.928 0.000 0.072
#> SRR975554 1 0.2356 0.890 0.928 0.000 0.072
#> SRR975553 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975555 1 0.2356 0.890 0.928 0.000 0.072
#> SRR975556 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975557 2 0.4291 0.815 0.180 0.820 0.000
#> SRR975558 1 0.0000 0.853 1.000 0.000 0.000
#> SRR975559 1 0.0000 0.853 1.000 0.000 0.000
#> SRR975560 2 0.4002 0.821 0.160 0.840 0.000
#> SRR975561 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975562 1 0.2356 0.890 0.928 0.000 0.072
#> SRR975563 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975564 1 0.2356 0.890 0.928 0.000 0.072
#> SRR975565 1 0.2356 0.890 0.928 0.000 0.072
#> SRR975566 1 0.1289 0.872 0.968 0.000 0.032
#> SRR975567 1 0.0000 0.853 1.000 0.000 0.000
#> SRR975568 1 0.2356 0.890 0.928 0.000 0.072
#> SRR975569 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975571 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975572 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975573 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975574 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975575 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975577 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975578 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975579 2 0.2356 0.926 0.072 0.928 0.000
#> SRR975580 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975581 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975582 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975583 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975584 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975585 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975586 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975587 3 0.0000 0.846 0.000 0.000 1.000
#> SRR975588 2 0.0000 0.983 0.000 1.000 0.000
#> SRR975589 1 0.5216 0.686 0.740 0.000 0.260
#> SRR975590 3 0.5882 0.430 0.348 0.000 0.652
#> SRR975591 3 0.0237 0.843 0.004 0.000 0.996
#> SRR975592 3 0.2261 0.805 0.068 0.000 0.932
#> SRR975593 1 0.5678 0.590 0.684 0.000 0.316
#> SRR975594 3 0.0000 0.846 0.000 0.000 1.000
#> SRR975595 3 0.6062 0.342 0.384 0.000 0.616
#> SRR975597 3 0.6168 0.255 0.412 0.000 0.588
#> SRR975596 1 0.0000 0.853 1.000 0.000 0.000
#> SRR975598 1 0.6274 0.186 0.544 0.000 0.456
#> SRR975599 1 0.5650 0.598 0.688 0.000 0.312
#> SRR975600 3 0.0000 0.846 0.000 0.000 1.000
#> SRR975601 3 0.0000 0.846 0.000 0.000 1.000
#> SRR975602 1 0.2356 0.890 0.928 0.000 0.072
#> SRR975603 3 0.0000 0.846 0.000 0.000 1.000
#> SRR975604 3 0.0000 0.846 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0000 0.791 1.000 0.000 0.000 0.000
#> SRR975552 1 0.0000 0.791 1.000 0.000 0.000 0.000
#> SRR975554 1 0.0000 0.791 1.000 0.000 0.000 0.000
#> SRR975553 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975555 1 0.2469 0.779 0.892 0.000 0.000 0.108
#> SRR975556 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975557 4 0.0000 0.736 0.000 0.000 0.000 1.000
#> SRR975558 1 0.3688 0.704 0.792 0.000 0.000 0.208
#> SRR975559 4 0.4804 0.491 0.384 0.000 0.000 0.616
#> SRR975560 2 0.2761 0.869 0.048 0.904 0.000 0.048
#> SRR975561 2 0.4916 0.273 0.000 0.576 0.000 0.424
#> SRR975562 1 0.0000 0.791 1.000 0.000 0.000 0.000
#> SRR975563 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975564 1 0.2760 0.771 0.872 0.000 0.000 0.128
#> SRR975565 1 0.2011 0.786 0.920 0.000 0.000 0.080
#> SRR975566 1 0.1211 0.774 0.960 0.000 0.000 0.040
#> SRR975567 4 0.3074 0.725 0.152 0.000 0.000 0.848
#> SRR975568 1 0.2760 0.771 0.872 0.000 0.000 0.128
#> SRR975569 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975572 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975574 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975575 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975578 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975579 4 0.2760 0.662 0.000 0.128 0.000 0.872
#> SRR975580 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975581 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975582 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975583 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975585 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975586 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975587 3 0.0000 0.998 0.000 0.000 1.000 0.000
#> SRR975588 2 0.0000 0.975 0.000 1.000 0.000 0.000
#> SRR975589 1 0.4017 0.770 0.828 0.000 0.044 0.128
#> SRR975590 1 0.4985 0.324 0.532 0.000 0.468 0.000
#> SRR975591 3 0.0000 0.998 0.000 0.000 1.000 0.000
#> SRR975592 3 0.0469 0.982 0.012 0.000 0.988 0.000
#> SRR975593 1 0.4720 0.662 0.720 0.000 0.264 0.016
#> SRR975594 3 0.0000 0.998 0.000 0.000 1.000 0.000
#> SRR975595 1 0.4898 0.448 0.584 0.000 0.416 0.000
#> SRR975597 1 0.4830 0.492 0.608 0.000 0.392 0.000
#> SRR975596 1 0.4933 0.216 0.568 0.000 0.000 0.432
#> SRR975598 1 0.3486 0.719 0.812 0.000 0.188 0.000
#> SRR975599 1 0.1389 0.782 0.952 0.000 0.048 0.000
#> SRR975600 3 0.0000 0.998 0.000 0.000 1.000 0.000
#> SRR975601 3 0.0000 0.998 0.000 0.000 1.000 0.000
#> SRR975602 1 0.0000 0.791 1.000 0.000 0.000 0.000
#> SRR975603 3 0.0000 0.998 0.000 0.000 1.000 0.000
#> SRR975604 3 0.0000 0.998 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.0000 0.8137 1.000 0.000 0.000 0.000 0.000
#> SRR975552 1 0.0000 0.8137 1.000 0.000 0.000 0.000 0.000
#> SRR975554 1 0.2648 0.6866 0.848 0.000 0.000 0.000 0.152
#> SRR975553 2 0.1851 0.9377 0.000 0.912 0.000 0.000 0.088
#> SRR975555 5 0.4201 0.3772 0.408 0.000 0.000 0.000 0.592
#> SRR975556 2 0.0162 0.9488 0.000 0.996 0.000 0.000 0.004
#> SRR975557 4 0.0000 0.7432 0.000 0.000 0.000 1.000 0.000
#> SRR975558 5 0.2130 0.7841 0.080 0.012 0.000 0.000 0.908
#> SRR975559 4 0.3932 0.5119 0.328 0.000 0.000 0.672 0.000
#> SRR975560 2 0.4703 0.6513 0.024 0.732 0.000 0.212 0.032
#> SRR975561 4 0.2068 0.7012 0.000 0.092 0.000 0.904 0.004
#> SRR975562 1 0.0000 0.8137 1.000 0.000 0.000 0.000 0.000
#> SRR975563 2 0.0162 0.9488 0.000 0.996 0.000 0.000 0.004
#> SRR975564 5 0.1965 0.7949 0.096 0.000 0.000 0.000 0.904
#> SRR975565 1 0.3039 0.6585 0.808 0.000 0.000 0.000 0.192
#> SRR975566 1 0.4227 0.0616 0.580 0.000 0.000 0.000 0.420
#> SRR975567 4 0.4828 0.1765 0.012 0.008 0.000 0.572 0.408
#> SRR975568 5 0.2020 0.7955 0.100 0.000 0.000 0.000 0.900
#> SRR975569 2 0.0609 0.9475 0.000 0.980 0.000 0.000 0.020
#> SRR975570 2 0.0162 0.9488 0.000 0.996 0.000 0.000 0.004
#> SRR975571 2 0.1851 0.9377 0.000 0.912 0.000 0.000 0.088
#> SRR975572 2 0.0000 0.9489 0.000 1.000 0.000 0.000 0.000
#> SRR975573 2 0.1851 0.9377 0.000 0.912 0.000 0.000 0.088
#> SRR975574 2 0.1851 0.9377 0.000 0.912 0.000 0.000 0.088
#> SRR975575 2 0.0000 0.9489 0.000 1.000 0.000 0.000 0.000
#> SRR975576 2 0.0162 0.9488 0.000 0.996 0.000 0.000 0.004
#> SRR975577 2 0.1792 0.9388 0.000 0.916 0.000 0.000 0.084
#> SRR975578 2 0.1792 0.9388 0.000 0.916 0.000 0.000 0.084
#> SRR975579 4 0.0000 0.7432 0.000 0.000 0.000 1.000 0.000
#> SRR975580 2 0.1792 0.9388 0.000 0.916 0.000 0.000 0.084
#> SRR975581 2 0.0162 0.9488 0.000 0.996 0.000 0.000 0.004
#> SRR975582 2 0.1851 0.9377 0.000 0.912 0.000 0.000 0.088
#> SRR975583 2 0.0162 0.9488 0.000 0.996 0.000 0.000 0.004
#> SRR975584 2 0.1851 0.9377 0.000 0.912 0.000 0.000 0.088
#> SRR975585 2 0.0162 0.9488 0.000 0.996 0.000 0.000 0.004
#> SRR975586 2 0.0162 0.9488 0.000 0.996 0.000 0.000 0.004
#> SRR975587 3 0.0000 0.8969 0.000 0.000 1.000 0.000 0.000
#> SRR975588 2 0.0162 0.9488 0.000 0.996 0.000 0.000 0.004
#> SRR975589 5 0.2124 0.7956 0.096 0.000 0.004 0.000 0.900
#> SRR975590 1 0.3177 0.7384 0.792 0.000 0.208 0.000 0.000
#> SRR975591 3 0.0000 0.8969 0.000 0.000 1.000 0.000 0.000
#> SRR975592 3 0.3003 0.7413 0.000 0.000 0.812 0.000 0.188
#> SRR975593 5 0.4069 0.7098 0.096 0.000 0.112 0.000 0.792
#> SRR975594 3 0.0000 0.8969 0.000 0.000 1.000 0.000 0.000
#> SRR975595 1 0.3366 0.7138 0.768 0.000 0.232 0.000 0.000
#> SRR975597 1 0.3143 0.7405 0.796 0.000 0.204 0.000 0.000
#> SRR975596 5 0.6137 0.0714 0.132 0.000 0.000 0.392 0.476
#> SRR975598 1 0.2329 0.7851 0.876 0.000 0.124 0.000 0.000
#> SRR975599 1 0.0162 0.8137 0.996 0.000 0.004 0.000 0.000
#> SRR975600 3 0.4287 0.2579 0.000 0.000 0.540 0.000 0.460
#> SRR975601 3 0.0000 0.8969 0.000 0.000 1.000 0.000 0.000
#> SRR975602 1 0.0000 0.8137 1.000 0.000 0.000 0.000 0.000
#> SRR975603 3 0.0000 0.8969 0.000 0.000 1.000 0.000 0.000
#> SRR975604 3 0.0000 0.8969 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.0000 0.7900 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR975552 1 0.0260 0.7908 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR975554 1 0.2340 0.7254 0.852 0.000 0.000 0.000 0.148 0.000
#> SRR975553 2 0.0000 0.6605 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975555 5 0.3912 0.4915 0.224 0.000 0.000 0.000 0.732 0.044
#> SRR975556 6 0.3864 0.1211 0.000 0.480 0.000 0.000 0.000 0.520
#> SRR975557 4 0.0000 0.7541 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR975558 5 0.0547 0.7234 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR975559 4 0.4074 0.6559 0.140 0.000 0.000 0.752 0.000 0.108
#> SRR975560 6 0.4779 0.0911 0.000 0.308 0.000 0.016 0.044 0.632
#> SRR975561 4 0.2841 0.6830 0.000 0.012 0.000 0.824 0.000 0.164
#> SRR975562 1 0.3916 0.6578 0.680 0.000 0.000 0.000 0.020 0.300
#> SRR975563 6 0.3864 0.1211 0.000 0.480 0.000 0.000 0.000 0.520
#> SRR975564 5 0.0000 0.7232 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR975565 1 0.2941 0.6817 0.780 0.000 0.000 0.000 0.220 0.000
#> SRR975566 1 0.5168 0.2672 0.552 0.000 0.000 0.004 0.360 0.084
#> SRR975567 4 0.5911 0.3202 0.000 0.000 0.000 0.456 0.228 0.316
#> SRR975568 5 0.0260 0.7208 0.000 0.000 0.000 0.000 0.992 0.008
#> SRR975569 2 0.2996 0.5105 0.000 0.772 0.000 0.000 0.000 0.228
#> SRR975570 2 0.3330 0.4456 0.000 0.716 0.000 0.000 0.000 0.284
#> SRR975571 2 0.0000 0.6605 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975572 2 0.3737 0.2319 0.000 0.608 0.000 0.000 0.000 0.392
#> SRR975573 2 0.0000 0.6605 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975574 2 0.0146 0.6603 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR975575 2 0.3774 0.1806 0.000 0.592 0.000 0.000 0.000 0.408
#> SRR975576 2 0.3862 -0.1501 0.000 0.524 0.000 0.000 0.000 0.476
#> SRR975577 2 0.0000 0.6605 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975578 2 0.0146 0.6603 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR975579 4 0.0000 0.7541 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR975580 2 0.1967 0.5442 0.012 0.904 0.000 0.000 0.000 0.084
#> SRR975581 2 0.3727 0.2405 0.000 0.612 0.000 0.000 0.000 0.388
#> SRR975582 2 0.0000 0.6605 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975583 6 0.3868 0.0591 0.000 0.496 0.000 0.000 0.000 0.504
#> SRR975584 2 0.0632 0.6376 0.000 0.976 0.000 0.000 0.000 0.024
#> SRR975585 2 0.3823 0.0661 0.000 0.564 0.000 0.000 0.000 0.436
#> SRR975586 6 0.3864 0.1211 0.000 0.480 0.000 0.000 0.000 0.520
#> SRR975587 3 0.0000 0.9615 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975588 2 0.3482 0.3970 0.000 0.684 0.000 0.000 0.000 0.316
#> SRR975589 5 0.2941 0.6429 0.000 0.000 0.000 0.000 0.780 0.220
#> SRR975590 1 0.2219 0.7713 0.864 0.000 0.136 0.000 0.000 0.000
#> SRR975591 3 0.0000 0.9615 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975592 3 0.2871 0.7160 0.000 0.000 0.804 0.000 0.192 0.004
#> SRR975593 5 0.4585 0.5849 0.000 0.000 0.068 0.000 0.648 0.284
#> SRR975594 3 0.0000 0.9615 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975595 1 0.4386 0.7211 0.708 0.000 0.200 0.000 0.000 0.092
#> SRR975597 1 0.3971 0.7432 0.748 0.000 0.184 0.000 0.000 0.068
#> SRR975596 6 0.6641 -0.5347 0.032 0.000 0.000 0.248 0.336 0.384
#> SRR975598 1 0.3747 0.7757 0.784 0.000 0.104 0.000 0.000 0.112
#> SRR975599 1 0.2703 0.7661 0.824 0.000 0.000 0.000 0.004 0.172
#> SRR975600 5 0.4184 -0.0456 0.000 0.000 0.484 0.000 0.504 0.012
#> SRR975601 3 0.0000 0.9615 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975602 1 0.1075 0.7896 0.952 0.000 0.000 0.000 0.000 0.048
#> SRR975603 3 0.0000 0.9615 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975604 3 0.0000 0.9615 0.000 0.000 1.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "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 17171 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 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.855 0.948 0.975 0.50852 0.491 0.491
#> 3 3 1.000 0.964 0.983 0.13771 0.936 0.869
#> 4 4 0.995 0.958 0.982 0.00636 0.997 0.993
#> 5 5 0.778 0.780 0.878 0.19555 0.874 0.703
#> 6 6 0.851 0.780 0.899 0.04948 0.948 0.838
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
#> SRR975551 1 0.000 0.977 1.000 0.000
#> SRR975552 1 0.000 0.977 1.000 0.000
#> SRR975554 1 0.000 0.977 1.000 0.000
#> SRR975553 2 0.000 0.967 0.000 1.000
#> SRR975555 1 0.000 0.977 1.000 0.000
#> SRR975556 2 0.000 0.967 0.000 1.000
#> SRR975557 2 0.722 0.774 0.200 0.800
#> SRR975558 1 0.714 0.763 0.804 0.196
#> SRR975559 1 0.000 0.977 1.000 0.000
#> SRR975560 2 0.000 0.967 0.000 1.000
#> SRR975561 2 0.000 0.967 0.000 1.000
#> SRR975562 1 0.000 0.977 1.000 0.000
#> SRR975563 2 0.000 0.967 0.000 1.000
#> SRR975564 1 0.000 0.977 1.000 0.000
#> SRR975565 1 0.000 0.977 1.000 0.000
#> SRR975566 1 0.000 0.977 1.000 0.000
#> SRR975567 1 0.714 0.763 0.804 0.196
#> SRR975568 1 0.000 0.977 1.000 0.000
#> SRR975569 2 0.000 0.967 0.000 1.000
#> SRR975570 2 0.000 0.967 0.000 1.000
#> SRR975571 2 0.000 0.967 0.000 1.000
#> SRR975572 2 0.000 0.967 0.000 1.000
#> SRR975573 2 0.000 0.967 0.000 1.000
#> SRR975574 2 0.000 0.967 0.000 1.000
#> SRR975575 2 0.000 0.967 0.000 1.000
#> SRR975576 2 0.000 0.967 0.000 1.000
#> SRR975577 2 0.000 0.967 0.000 1.000
#> SRR975578 2 0.000 0.967 0.000 1.000
#> SRR975579 2 0.722 0.774 0.200 0.800
#> SRR975580 2 0.000 0.967 0.000 1.000
#> SRR975581 2 0.000 0.967 0.000 1.000
#> SRR975582 2 0.000 0.967 0.000 1.000
#> SRR975583 2 0.000 0.967 0.000 1.000
#> SRR975584 2 0.000 0.967 0.000 1.000
#> SRR975585 2 0.000 0.967 0.000 1.000
#> SRR975586 2 0.000 0.967 0.000 1.000
#> SRR975587 1 0.184 0.962 0.972 0.028
#> SRR975588 2 0.000 0.967 0.000 1.000
#> SRR975589 1 0.000 0.977 1.000 0.000
#> SRR975590 1 0.000 0.977 1.000 0.000
#> SRR975591 1 0.184 0.962 0.972 0.028
#> SRR975592 1 0.000 0.977 1.000 0.000
#> SRR975593 1 0.000 0.977 1.000 0.000
#> SRR975594 2 0.722 0.774 0.200 0.800
#> SRR975595 1 0.000 0.977 1.000 0.000
#> SRR975597 1 0.000 0.977 1.000 0.000
#> SRR975596 1 0.000 0.977 1.000 0.000
#> SRR975598 1 0.000 0.977 1.000 0.000
#> SRR975599 2 0.722 0.774 0.200 0.800
#> SRR975600 1 0.184 0.962 0.972 0.028
#> SRR975601 1 0.184 0.962 0.972 0.028
#> SRR975602 1 0.000 0.977 1.000 0.000
#> SRR975603 1 0.184 0.962 0.972 0.028
#> SRR975604 1 0.184 0.962 0.972 0.028
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.000 0.962 1.000 0.000 0.000
#> SRR975552 1 0.000 0.962 1.000 0.000 0.000
#> SRR975554 1 0.000 0.962 1.000 0.000 0.000
#> SRR975553 2 0.000 1.000 0.000 1.000 0.000
#> SRR975555 1 0.000 0.962 1.000 0.000 0.000
#> SRR975556 2 0.000 1.000 0.000 1.000 0.000
#> SRR975557 3 0.000 0.974 0.000 0.000 1.000
#> SRR975558 1 0.450 0.721 0.804 0.196 0.000
#> SRR975559 1 0.000 0.962 1.000 0.000 0.000
#> SRR975560 2 0.000 1.000 0.000 1.000 0.000
#> SRR975561 2 0.000 1.000 0.000 1.000 0.000
#> SRR975562 1 0.000 0.962 1.000 0.000 0.000
#> SRR975563 2 0.000 1.000 0.000 1.000 0.000
#> SRR975564 1 0.000 0.962 1.000 0.000 0.000
#> SRR975565 1 0.000 0.962 1.000 0.000 0.000
#> SRR975566 1 0.000 0.962 1.000 0.000 0.000
#> SRR975567 1 0.450 0.721 0.804 0.196 0.000
#> SRR975568 1 0.000 0.962 1.000 0.000 0.000
#> SRR975569 2 0.000 1.000 0.000 1.000 0.000
#> SRR975570 2 0.000 1.000 0.000 1.000 0.000
#> SRR975571 2 0.000 1.000 0.000 1.000 0.000
#> SRR975572 2 0.000 1.000 0.000 1.000 0.000
#> SRR975573 2 0.000 1.000 0.000 1.000 0.000
#> SRR975574 2 0.000 1.000 0.000 1.000 0.000
#> SRR975575 2 0.000 1.000 0.000 1.000 0.000
#> SRR975576 2 0.000 1.000 0.000 1.000 0.000
#> SRR975577 2 0.000 1.000 0.000 1.000 0.000
#> SRR975578 2 0.000 1.000 0.000 1.000 0.000
#> SRR975579 3 0.000 0.974 0.000 0.000 1.000
#> SRR975580 2 0.000 1.000 0.000 1.000 0.000
#> SRR975581 2 0.000 1.000 0.000 1.000 0.000
#> SRR975582 2 0.000 1.000 0.000 1.000 0.000
#> SRR975583 2 0.000 1.000 0.000 1.000 0.000
#> SRR975584 2 0.000 1.000 0.000 1.000 0.000
#> SRR975585 2 0.000 1.000 0.000 1.000 0.000
#> SRR975586 2 0.000 1.000 0.000 1.000 0.000
#> SRR975587 1 0.245 0.920 0.924 0.000 0.076
#> SRR975588 2 0.000 1.000 0.000 1.000 0.000
#> SRR975589 1 0.000 0.962 1.000 0.000 0.000
#> SRR975590 1 0.000 0.962 1.000 0.000 0.000
#> SRR975591 1 0.245 0.920 0.924 0.000 0.076
#> SRR975592 1 0.000 0.962 1.000 0.000 0.000
#> SRR975593 1 0.000 0.962 1.000 0.000 0.000
#> SRR975594 3 0.000 0.974 0.000 0.000 1.000
#> SRR975595 1 0.000 0.962 1.000 0.000 0.000
#> SRR975597 1 0.000 0.962 1.000 0.000 0.000
#> SRR975596 1 0.000 0.962 1.000 0.000 0.000
#> SRR975598 1 0.000 0.962 1.000 0.000 0.000
#> SRR975599 3 0.245 0.917 0.076 0.000 0.924
#> SRR975600 1 0.245 0.920 0.924 0.000 0.076
#> SRR975601 1 0.245 0.920 0.924 0.000 0.076
#> SRR975602 1 0.000 0.962 1.000 0.000 0.000
#> SRR975603 1 0.245 0.920 0.924 0.000 0.076
#> SRR975604 1 0.245 0.920 0.924 0.000 0.076
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0000 0.959 1.000 0.000 0.000 0.000
#> SRR975552 1 0.0000 0.959 1.000 0.000 0.000 0.000
#> SRR975554 1 0.0000 0.959 1.000 0.000 0.000 0.000
#> SRR975553 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975555 1 0.0188 0.958 0.996 0.000 0.004 0.000
#> SRR975556 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975557 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR975558 1 0.3751 0.700 0.800 0.196 0.004 0.000
#> SRR975559 1 0.0188 0.958 0.996 0.000 0.004 0.000
#> SRR975560 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975561 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975562 1 0.0188 0.958 0.996 0.000 0.004 0.000
#> SRR975563 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975564 1 0.0188 0.958 0.996 0.000 0.004 0.000
#> SRR975565 1 0.0000 0.959 1.000 0.000 0.000 0.000
#> SRR975566 1 0.0000 0.959 1.000 0.000 0.000 0.000
#> SRR975567 1 0.3751 0.700 0.800 0.196 0.004 0.000
#> SRR975568 1 0.0188 0.958 0.996 0.000 0.004 0.000
#> SRR975569 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975572 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975574 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975575 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975578 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975579 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR975580 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975581 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975582 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975583 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975585 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975586 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975587 1 0.1940 0.918 0.924 0.000 0.076 0.000
#> SRR975588 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR975589 1 0.0000 0.959 1.000 0.000 0.000 0.000
#> SRR975590 1 0.0000 0.959 1.000 0.000 0.000 0.000
#> SRR975591 1 0.1940 0.918 0.924 0.000 0.076 0.000
#> SRR975592 1 0.0000 0.959 1.000 0.000 0.000 0.000
#> SRR975593 1 0.0000 0.959 1.000 0.000 0.000 0.000
#> SRR975594 3 0.0188 0.803 0.000 0.000 0.996 0.004
#> SRR975595 1 0.0000 0.959 1.000 0.000 0.000 0.000
#> SRR975597 1 0.0000 0.959 1.000 0.000 0.000 0.000
#> SRR975596 1 0.0188 0.958 0.996 0.000 0.004 0.000
#> SRR975598 1 0.0000 0.959 1.000 0.000 0.000 0.000
#> SRR975599 3 0.2125 0.808 0.076 0.000 0.920 0.004
#> SRR975600 1 0.1940 0.918 0.924 0.000 0.076 0.000
#> SRR975601 1 0.1940 0.918 0.924 0.000 0.076 0.000
#> SRR975602 1 0.0000 0.959 1.000 0.000 0.000 0.000
#> SRR975603 1 0.1940 0.918 0.924 0.000 0.076 0.000
#> SRR975604 1 0.1940 0.918 0.924 0.000 0.076 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.130 0.720 0.956 0.000 0.028 0 0.016
#> SRR975552 1 0.130 0.720 0.956 0.000 0.028 0 0.016
#> SRR975554 1 0.191 0.740 0.908 0.000 0.092 0 0.000
#> SRR975553 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975555 1 0.460 0.436 0.656 0.000 0.316 0 0.028
#> SRR975556 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975557 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> SRR975558 3 0.587 0.429 0.092 0.140 0.692 0 0.076
#> SRR975559 3 0.482 0.319 0.456 0.000 0.524 0 0.020
#> SRR975560 2 0.152 0.944 0.000 0.944 0.012 0 0.044
#> SRR975561 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975562 1 0.332 0.624 0.820 0.000 0.160 0 0.020
#> SRR975563 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975564 1 0.472 0.381 0.628 0.000 0.344 0 0.028
#> SRR975565 1 0.177 0.706 0.932 0.000 0.052 0 0.016
#> SRR975566 1 0.191 0.740 0.908 0.000 0.092 0 0.000
#> SRR975567 3 0.587 0.429 0.092 0.140 0.692 0 0.076
#> SRR975568 1 0.460 0.436 0.656 0.000 0.316 0 0.028
#> SRR975569 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975570 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975571 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975572 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975573 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975574 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975575 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975576 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975577 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975578 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975579 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> SRR975580 2 0.152 0.944 0.000 0.944 0.012 0 0.044
#> SRR975581 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975582 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975583 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975584 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975585 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975586 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975587 3 0.161 0.706 0.072 0.000 0.928 0 0.000
#> SRR975588 2 0.000 0.995 0.000 1.000 0.000 0 0.000
#> SRR975589 3 0.428 0.155 0.452 0.000 0.548 0 0.000
#> SRR975590 1 0.223 0.731 0.884 0.000 0.116 0 0.000
#> SRR975591 3 0.161 0.706 0.072 0.000 0.928 0 0.000
#> SRR975592 1 0.366 0.598 0.724 0.000 0.276 0 0.000
#> SRR975593 3 0.428 0.155 0.452 0.000 0.548 0 0.000
#> SRR975594 5 0.167 0.870 0.000 0.000 0.076 0 0.924
#> SRR975595 1 0.337 0.656 0.768 0.000 0.232 0 0.000
#> SRR975597 1 0.337 0.656 0.768 0.000 0.232 0 0.000
#> SRR975596 3 0.482 0.319 0.456 0.000 0.524 0 0.020
#> SRR975598 1 0.334 0.657 0.772 0.000 0.228 0 0.000
#> SRR975599 5 0.311 0.872 0.036 0.000 0.112 0 0.852
#> SRR975600 3 0.161 0.706 0.072 0.000 0.928 0 0.000
#> SRR975601 3 0.161 0.706 0.072 0.000 0.928 0 0.000
#> SRR975602 1 0.191 0.740 0.908 0.000 0.092 0 0.000
#> SRR975603 3 0.161 0.706 0.072 0.000 0.928 0 0.000
#> SRR975604 3 0.161 0.706 0.072 0.000 0.928 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.2219 0.591 0.864 0.000 0.000 0.136 0.000 0
#> SRR975552 1 0.2219 0.591 0.864 0.000 0.000 0.136 0.000 0
#> SRR975554 1 0.0291 0.631 0.992 0.000 0.004 0.000 0.004 0
#> SRR975553 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975555 1 0.3823 0.196 0.564 0.000 0.000 0.436 0.000 0
#> SRR975556 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975557 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1
#> SRR975558 4 0.0000 0.601 0.000 0.000 0.000 1.000 0.000 0
#> SRR975559 4 0.3706 0.529 0.380 0.000 0.000 0.620 0.000 0
#> SRR975560 2 0.2730 0.782 0.000 0.808 0.000 0.192 0.000 0
#> SRR975561 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975562 1 0.3175 0.444 0.744 0.000 0.000 0.256 0.000 0
#> SRR975563 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975564 1 0.3854 0.130 0.536 0.000 0.000 0.464 0.000 0
#> SRR975565 1 0.2454 0.579 0.840 0.000 0.000 0.160 0.000 0
#> SRR975566 1 0.0291 0.631 0.992 0.000 0.004 0.000 0.004 0
#> SRR975567 4 0.0000 0.601 0.000 0.000 0.000 1.000 0.000 0
#> SRR975568 1 0.3823 0.196 0.564 0.000 0.000 0.436 0.000 0
#> SRR975569 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975570 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975571 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975572 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975573 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975574 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975575 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975576 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975577 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975578 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975579 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1
#> SRR975580 2 0.2730 0.782 0.000 0.808 0.000 0.192 0.000 0
#> SRR975581 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975582 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975583 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975584 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975585 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975586 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975587 3 0.0000 0.993 0.000 0.000 1.000 0.000 0.000 0
#> SRR975588 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0
#> SRR975589 1 0.5974 0.191 0.440 0.000 0.312 0.248 0.000 0
#> SRR975590 1 0.0858 0.631 0.968 0.000 0.028 0.000 0.004 0
#> SRR975591 3 0.0000 0.993 0.000 0.000 1.000 0.000 0.000 0
#> SRR975592 1 0.3351 0.545 0.712 0.000 0.288 0.000 0.000 0
#> SRR975593 1 0.5974 0.191 0.440 0.000 0.312 0.248 0.000 0
#> SRR975594 5 0.0632 0.887 0.000 0.000 0.024 0.000 0.976 0
#> SRR975595 1 0.3050 0.588 0.764 0.000 0.236 0.000 0.000 0
#> SRR975597 1 0.3050 0.588 0.764 0.000 0.236 0.000 0.000 0
#> SRR975596 4 0.3706 0.529 0.380 0.000 0.000 0.620 0.000 0
#> SRR975598 1 0.3023 0.589 0.768 0.000 0.232 0.000 0.000 0
#> SRR975599 5 0.1863 0.888 0.036 0.000 0.044 0.000 0.920 0
#> SRR975600 3 0.0713 0.965 0.000 0.000 0.972 0.028 0.000 0
#> SRR975601 3 0.0000 0.993 0.000 0.000 1.000 0.000 0.000 0
#> SRR975602 1 0.0291 0.631 0.992 0.000 0.004 0.000 0.004 0
#> SRR975603 3 0.0000 0.993 0.000 0.000 1.000 0.000 0.000 0
#> SRR975604 3 0.0000 0.993 0.000 0.000 1.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["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 17171 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 1.000 1.000 1.000 0.5036 0.497 0.497
#> 3 3 0.768 0.795 0.907 0.2259 0.867 0.734
#> 4 4 0.671 0.666 0.822 0.1291 0.953 0.877
#> 5 5 0.657 0.589 0.775 0.0843 0.908 0.743
#> 6 6 0.718 0.533 0.736 0.0462 0.933 0.768
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
#> SRR975551 1 0 1 1 0
#> SRR975552 1 0 1 1 0
#> SRR975554 1 0 1 1 0
#> SRR975553 2 0 1 0 1
#> SRR975555 1 0 1 1 0
#> SRR975556 2 0 1 0 1
#> SRR975557 1 0 1 1 0
#> SRR975558 1 0 1 1 0
#> SRR975559 1 0 1 1 0
#> SRR975560 2 0 1 0 1
#> SRR975561 2 0 1 0 1
#> SRR975562 1 0 1 1 0
#> SRR975563 2 0 1 0 1
#> SRR975564 1 0 1 1 0
#> SRR975565 1 0 1 1 0
#> SRR975566 1 0 1 1 0
#> SRR975567 1 0 1 1 0
#> SRR975568 1 0 1 1 0
#> SRR975569 2 0 1 0 1
#> SRR975570 2 0 1 0 1
#> SRR975571 2 0 1 0 1
#> SRR975572 2 0 1 0 1
#> SRR975573 2 0 1 0 1
#> SRR975574 2 0 1 0 1
#> SRR975575 2 0 1 0 1
#> SRR975576 2 0 1 0 1
#> SRR975577 2 0 1 0 1
#> SRR975578 2 0 1 0 1
#> SRR975579 2 0 1 0 1
#> SRR975580 2 0 1 0 1
#> SRR975581 2 0 1 0 1
#> SRR975582 2 0 1 0 1
#> SRR975583 2 0 1 0 1
#> SRR975584 2 0 1 0 1
#> SRR975585 2 0 1 0 1
#> SRR975586 2 0 1 0 1
#> SRR975587 1 0 1 1 0
#> SRR975588 2 0 1 0 1
#> SRR975589 1 0 1 1 0
#> SRR975590 1 0 1 1 0
#> SRR975591 1 0 1 1 0
#> SRR975592 1 0 1 1 0
#> SRR975593 1 0 1 1 0
#> SRR975594 1 0 1 1 0
#> SRR975595 1 0 1 1 0
#> SRR975597 1 0 1 1 0
#> SRR975596 1 0 1 1 0
#> SRR975598 1 0 1 1 0
#> SRR975599 1 0 1 1 0
#> SRR975600 1 0 1 1 0
#> SRR975601 1 0 1 1 0
#> SRR975602 1 0 1 1 0
#> SRR975603 1 0 1 1 0
#> SRR975604 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.0000 0.876 1.000 0.000 0.000
#> SRR975552 1 0.0000 0.876 1.000 0.000 0.000
#> SRR975554 1 0.0000 0.876 1.000 0.000 0.000
#> SRR975553 2 0.0237 0.978 0.000 0.996 0.004
#> SRR975555 1 0.0000 0.876 1.000 0.000 0.000
#> SRR975556 2 0.1163 0.962 0.000 0.972 0.028
#> SRR975557 3 0.1860 0.585 0.052 0.000 0.948
#> SRR975558 1 0.3412 0.739 0.876 0.000 0.124
#> SRR975559 1 0.0000 0.876 1.000 0.000 0.000
#> SRR975560 2 0.3412 0.888 0.000 0.876 0.124
#> SRR975561 2 0.3038 0.907 0.000 0.896 0.104
#> SRR975562 1 0.0000 0.876 1.000 0.000 0.000
#> SRR975563 2 0.0000 0.978 0.000 1.000 0.000
#> SRR975564 1 0.0000 0.876 1.000 0.000 0.000
#> SRR975565 1 0.0000 0.876 1.000 0.000 0.000
#> SRR975566 1 0.0000 0.876 1.000 0.000 0.000
#> SRR975567 1 0.3412 0.739 0.876 0.000 0.124
#> SRR975568 1 0.0000 0.876 1.000 0.000 0.000
#> SRR975569 2 0.0000 0.978 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.978 0.000 1.000 0.000
#> SRR975571 2 0.0237 0.978 0.000 0.996 0.004
#> SRR975572 2 0.0000 0.978 0.000 1.000 0.000
#> SRR975573 2 0.0237 0.978 0.000 0.996 0.004
#> SRR975574 2 0.0237 0.978 0.000 0.996 0.004
#> SRR975575 2 0.0000 0.978 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.978 0.000 1.000 0.000
#> SRR975577 2 0.0237 0.978 0.000 0.996 0.004
#> SRR975578 2 0.0237 0.978 0.000 0.996 0.004
#> SRR975579 3 0.6305 -0.315 0.000 0.484 0.516
#> SRR975580 2 0.2878 0.913 0.000 0.904 0.096
#> SRR975581 2 0.0000 0.978 0.000 1.000 0.000
#> SRR975582 2 0.0237 0.978 0.000 0.996 0.004
#> SRR975583 2 0.0000 0.978 0.000 1.000 0.000
#> SRR975584 2 0.0237 0.978 0.000 0.996 0.004
#> SRR975585 2 0.0000 0.978 0.000 1.000 0.000
#> SRR975586 2 0.3038 0.907 0.000 0.896 0.104
#> SRR975587 1 0.6307 -0.266 0.512 0.000 0.488
#> SRR975588 2 0.0000 0.978 0.000 1.000 0.000
#> SRR975589 1 0.3412 0.793 0.876 0.000 0.124
#> SRR975590 1 0.3752 0.772 0.856 0.000 0.144
#> SRR975591 3 0.6140 0.523 0.404 0.000 0.596
#> SRR975592 1 0.3752 0.772 0.856 0.000 0.144
#> SRR975593 1 0.3619 0.779 0.864 0.000 0.136
#> SRR975594 3 0.3482 0.628 0.128 0.000 0.872
#> SRR975595 1 0.1964 0.853 0.944 0.000 0.056
#> SRR975597 1 0.1964 0.853 0.944 0.000 0.056
#> SRR975596 1 0.0000 0.876 1.000 0.000 0.000
#> SRR975598 1 0.1964 0.853 0.944 0.000 0.056
#> SRR975599 3 0.3686 0.630 0.140 0.000 0.860
#> SRR975600 1 0.6305 -0.260 0.516 0.000 0.484
#> SRR975601 3 0.6126 0.525 0.400 0.000 0.600
#> SRR975602 1 0.0237 0.875 0.996 0.000 0.004
#> SRR975603 3 0.6140 0.523 0.404 0.000 0.596
#> SRR975604 3 0.6126 0.525 0.400 0.000 0.600
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.1118 0.7421 0.964 0.000 0.000 0.036
#> SRR975552 1 0.0707 0.7445 0.980 0.000 0.000 0.020
#> SRR975554 1 0.0817 0.7441 0.976 0.000 0.000 0.024
#> SRR975553 2 0.2450 0.8752 0.000 0.912 0.072 0.016
#> SRR975555 1 0.0592 0.7447 0.984 0.000 0.000 0.016
#> SRR975556 2 0.3056 0.8158 0.000 0.888 0.072 0.040
#> SRR975557 4 0.4511 0.4855 0.008 0.000 0.268 0.724
#> SRR975558 1 0.7760 0.0728 0.392 0.000 0.236 0.372
#> SRR975559 1 0.4458 0.6678 0.808 0.000 0.116 0.076
#> SRR975560 2 0.6716 0.4338 0.000 0.568 0.112 0.320
#> SRR975561 2 0.6167 0.5478 0.000 0.648 0.096 0.256
#> SRR975562 1 0.2334 0.7302 0.908 0.000 0.004 0.088
#> SRR975563 2 0.0000 0.8867 0.000 1.000 0.000 0.000
#> SRR975564 1 0.0921 0.7450 0.972 0.000 0.000 0.028
#> SRR975565 1 0.0707 0.7445 0.980 0.000 0.000 0.020
#> SRR975566 1 0.4093 0.6845 0.832 0.000 0.096 0.072
#> SRR975567 1 0.7760 0.0728 0.392 0.000 0.236 0.372
#> SRR975568 1 0.0707 0.7448 0.980 0.000 0.000 0.020
#> SRR975569 2 0.0188 0.8863 0.000 0.996 0.004 0.000
#> SRR975570 2 0.0000 0.8867 0.000 1.000 0.000 0.000
#> SRR975571 2 0.2450 0.8752 0.000 0.912 0.072 0.016
#> SRR975572 2 0.0000 0.8867 0.000 1.000 0.000 0.000
#> SRR975573 2 0.2450 0.8752 0.000 0.912 0.072 0.016
#> SRR975574 2 0.2450 0.8752 0.000 0.912 0.072 0.016
#> SRR975575 2 0.0000 0.8867 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.8867 0.000 1.000 0.000 0.000
#> SRR975577 2 0.2450 0.8752 0.000 0.912 0.072 0.016
#> SRR975578 2 0.2450 0.8752 0.000 0.912 0.072 0.016
#> SRR975579 4 0.3400 0.4676 0.000 0.180 0.000 0.820
#> SRR975580 2 0.6521 0.5415 0.000 0.620 0.124 0.256
#> SRR975581 2 0.0000 0.8867 0.000 1.000 0.000 0.000
#> SRR975582 2 0.2450 0.8752 0.000 0.912 0.072 0.016
#> SRR975583 2 0.0000 0.8867 0.000 1.000 0.000 0.000
#> SRR975584 2 0.2450 0.8752 0.000 0.912 0.072 0.016
#> SRR975585 2 0.0000 0.8867 0.000 1.000 0.000 0.000
#> SRR975586 2 0.6140 0.5484 0.000 0.652 0.096 0.252
#> SRR975587 3 0.5337 0.7288 0.260 0.000 0.696 0.044
#> SRR975588 2 0.0000 0.8867 0.000 1.000 0.000 0.000
#> SRR975589 1 0.6393 0.0509 0.480 0.000 0.456 0.064
#> SRR975590 1 0.5374 0.4798 0.704 0.000 0.244 0.052
#> SRR975591 3 0.3311 0.8152 0.172 0.000 0.828 0.000
#> SRR975592 1 0.5807 0.2250 0.596 0.000 0.364 0.040
#> SRR975593 1 0.6395 0.0347 0.476 0.000 0.460 0.064
#> SRR975594 3 0.5992 -0.2641 0.040 0.000 0.516 0.444
#> SRR975595 1 0.3732 0.6823 0.852 0.000 0.092 0.056
#> SRR975597 1 0.3486 0.6858 0.864 0.000 0.092 0.044
#> SRR975596 1 0.4646 0.6629 0.796 0.000 0.120 0.084
#> SRR975598 1 0.3732 0.6823 0.852 0.000 0.092 0.056
#> SRR975599 4 0.6979 0.1039 0.120 0.000 0.376 0.504
#> SRR975600 3 0.3539 0.8110 0.176 0.000 0.820 0.004
#> SRR975601 3 0.4868 0.7475 0.256 0.000 0.720 0.024
#> SRR975602 1 0.1940 0.7285 0.924 0.000 0.000 0.076
#> SRR975603 3 0.3311 0.8152 0.172 0.000 0.828 0.000
#> SRR975604 3 0.3311 0.8152 0.172 0.000 0.828 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.0955 0.783 0.968 0.000 0.000 0.004 0.028
#> SRR975552 1 0.0324 0.784 0.992 0.000 0.000 0.004 0.004
#> SRR975554 1 0.1043 0.785 0.960 0.000 0.000 0.000 0.040
#> SRR975553 2 0.4465 0.726 0.000 0.736 0.060 0.000 0.204
#> SRR975555 1 0.0865 0.784 0.972 0.000 0.000 0.004 0.024
#> SRR975556 2 0.5025 0.420 0.000 0.704 0.000 0.124 0.172
#> SRR975557 4 0.4024 0.567 0.000 0.000 0.220 0.752 0.028
#> SRR975558 5 0.8003 0.528 0.228 0.000 0.108 0.248 0.416
#> SRR975559 1 0.5542 0.562 0.632 0.000 0.084 0.008 0.276
#> SRR975560 5 0.6756 0.171 0.000 0.268 0.000 0.344 0.388
#> SRR975561 2 0.6724 -0.216 0.000 0.420 0.000 0.284 0.296
#> SRR975562 1 0.4090 0.683 0.716 0.000 0.000 0.016 0.268
#> SRR975563 2 0.0000 0.770 0.000 1.000 0.000 0.000 0.000
#> SRR975564 1 0.1282 0.772 0.952 0.000 0.000 0.004 0.044
#> SRR975565 1 0.0324 0.784 0.992 0.000 0.000 0.004 0.004
#> SRR975566 1 0.4668 0.668 0.724 0.000 0.048 0.008 0.220
#> SRR975567 5 0.8003 0.528 0.228 0.000 0.108 0.248 0.416
#> SRR975568 1 0.0566 0.783 0.984 0.000 0.000 0.004 0.012
#> SRR975569 2 0.0162 0.769 0.000 0.996 0.000 0.000 0.004
#> SRR975570 2 0.0000 0.770 0.000 1.000 0.000 0.000 0.000
#> SRR975571 2 0.4465 0.726 0.000 0.736 0.060 0.000 0.204
#> SRR975572 2 0.0000 0.770 0.000 1.000 0.000 0.000 0.000
#> SRR975573 2 0.4434 0.726 0.000 0.736 0.056 0.000 0.208
#> SRR975574 2 0.4434 0.726 0.000 0.736 0.056 0.000 0.208
#> SRR975575 2 0.0000 0.770 0.000 1.000 0.000 0.000 0.000
#> SRR975576 2 0.0000 0.770 0.000 1.000 0.000 0.000 0.000
#> SRR975577 2 0.4434 0.726 0.000 0.736 0.056 0.000 0.208
#> SRR975578 2 0.4434 0.726 0.000 0.736 0.056 0.000 0.208
#> SRR975579 4 0.1549 0.336 0.000 0.040 0.000 0.944 0.016
#> SRR975580 2 0.6784 -0.247 0.000 0.368 0.000 0.280 0.352
#> SRR975581 2 0.0000 0.770 0.000 1.000 0.000 0.000 0.000
#> SRR975582 2 0.4434 0.726 0.000 0.736 0.056 0.000 0.208
#> SRR975583 2 0.0000 0.770 0.000 1.000 0.000 0.000 0.000
#> SRR975584 2 0.4434 0.726 0.000 0.736 0.056 0.000 0.208
#> SRR975585 2 0.0000 0.770 0.000 1.000 0.000 0.000 0.000
#> SRR975586 2 0.6715 -0.213 0.000 0.424 0.000 0.284 0.292
#> SRR975587 3 0.4695 0.621 0.124 0.000 0.764 0.016 0.096
#> SRR975588 2 0.0000 0.770 0.000 1.000 0.000 0.000 0.000
#> SRR975589 3 0.5957 0.507 0.236 0.000 0.588 0.000 0.176
#> SRR975590 1 0.6096 0.406 0.604 0.000 0.252 0.016 0.128
#> SRR975591 3 0.1478 0.679 0.064 0.000 0.936 0.000 0.000
#> SRR975592 3 0.6441 0.337 0.352 0.000 0.508 0.016 0.124
#> SRR975593 3 0.5957 0.507 0.236 0.000 0.588 0.000 0.176
#> SRR975594 3 0.5751 -0.301 0.004 0.000 0.516 0.404 0.076
#> SRR975595 1 0.5451 0.660 0.700 0.000 0.104 0.024 0.172
#> SRR975597 1 0.5009 0.671 0.736 0.000 0.104 0.016 0.144
#> SRR975596 1 0.5704 0.550 0.616 0.000 0.084 0.012 0.288
#> SRR975598 1 0.5451 0.660 0.700 0.000 0.104 0.024 0.172
#> SRR975599 4 0.7745 0.318 0.076 0.000 0.280 0.428 0.216
#> SRR975600 3 0.2426 0.672 0.064 0.000 0.900 0.000 0.036
#> SRR975601 3 0.3977 0.637 0.100 0.000 0.812 0.008 0.080
#> SRR975602 1 0.3944 0.734 0.768 0.000 0.000 0.032 0.200
#> SRR975603 3 0.1478 0.679 0.064 0.000 0.936 0.000 0.000
#> SRR975604 3 0.1638 0.678 0.064 0.000 0.932 0.004 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.0717 0.705 0.976 0.000 0.000 0.008 0.016 0.000
#> SRR975552 1 0.0260 0.707 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR975554 1 0.2186 0.701 0.908 0.000 0.000 0.008 0.048 0.036
#> SRR975553 2 0.0551 0.574 0.000 0.984 0.000 0.008 0.004 0.004
#> SRR975555 1 0.1552 0.701 0.940 0.000 0.000 0.004 0.020 0.036
#> SRR975556 5 0.6169 0.000 0.000 0.336 0.000 0.008 0.428 0.228
#> SRR975557 4 0.2448 0.607 0.000 0.000 0.052 0.884 0.000 0.064
#> SRR975558 6 0.4535 0.276 0.140 0.000 0.096 0.024 0.000 0.740
#> SRR975559 1 0.7663 0.435 0.448 0.000 0.084 0.064 0.144 0.260
#> SRR975560 6 0.4854 0.440 0.000 0.188 0.000 0.012 0.112 0.688
#> SRR975561 6 0.5956 0.151 0.000 0.256 0.000 0.012 0.208 0.524
#> SRR975562 1 0.6415 0.522 0.520 0.000 0.000 0.052 0.184 0.244
#> SRR975563 2 0.3647 0.522 0.000 0.640 0.000 0.000 0.360 0.000
#> SRR975564 1 0.2015 0.689 0.916 0.000 0.000 0.016 0.012 0.056
#> SRR975565 1 0.0146 0.706 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR975566 1 0.6844 0.547 0.576 0.000 0.060 0.060 0.136 0.168
#> SRR975567 6 0.4535 0.276 0.140 0.000 0.096 0.024 0.000 0.740
#> SRR975568 1 0.1590 0.694 0.936 0.000 0.000 0.008 0.008 0.048
#> SRR975569 2 0.3563 0.543 0.000 0.664 0.000 0.000 0.336 0.000
#> SRR975570 2 0.3578 0.541 0.000 0.660 0.000 0.000 0.340 0.000
#> SRR975571 2 0.0551 0.574 0.000 0.984 0.000 0.008 0.004 0.004
#> SRR975572 2 0.3634 0.530 0.000 0.644 0.000 0.000 0.356 0.000
#> SRR975573 2 0.0000 0.581 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975574 2 0.0000 0.581 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975575 2 0.3634 0.530 0.000 0.644 0.000 0.000 0.356 0.000
#> SRR975576 2 0.3647 0.522 0.000 0.640 0.000 0.000 0.360 0.000
#> SRR975577 2 0.0000 0.581 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975578 2 0.0000 0.581 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975579 4 0.3166 0.520 0.000 0.008 0.000 0.800 0.008 0.184
#> SRR975580 6 0.5539 0.273 0.000 0.292 0.000 0.008 0.136 0.564
#> SRR975581 2 0.3647 0.522 0.000 0.640 0.000 0.000 0.360 0.000
#> SRR975582 2 0.0000 0.581 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975583 2 0.3634 0.530 0.000 0.644 0.000 0.000 0.356 0.000
#> SRR975584 2 0.0000 0.581 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975585 2 0.3634 0.530 0.000 0.644 0.000 0.000 0.356 0.000
#> SRR975586 6 0.5918 0.165 0.000 0.252 0.000 0.012 0.204 0.532
#> SRR975587 3 0.4193 0.639 0.052 0.000 0.780 0.016 0.136 0.016
#> SRR975588 2 0.3578 0.541 0.000 0.660 0.000 0.000 0.340 0.000
#> SRR975589 3 0.5702 0.590 0.092 0.000 0.688 0.032 0.064 0.124
#> SRR975590 1 0.6713 0.134 0.436 0.000 0.300 0.024 0.228 0.012
#> SRR975591 3 0.0000 0.740 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975592 3 0.6105 0.476 0.220 0.000 0.560 0.016 0.192 0.012
#> SRR975593 3 0.5649 0.591 0.092 0.000 0.692 0.032 0.060 0.124
#> SRR975594 4 0.6213 0.326 0.000 0.000 0.400 0.444 0.108 0.048
#> SRR975595 1 0.5652 0.585 0.588 0.000 0.068 0.024 0.304 0.016
#> SRR975597 1 0.5124 0.602 0.644 0.000 0.068 0.020 0.264 0.004
#> SRR975596 1 0.7776 0.420 0.428 0.000 0.084 0.068 0.152 0.268
#> SRR975598 1 0.5652 0.585 0.588 0.000 0.068 0.024 0.304 0.016
#> SRR975599 4 0.7427 0.524 0.060 0.000 0.140 0.488 0.236 0.076
#> SRR975600 3 0.1269 0.732 0.000 0.000 0.956 0.012 0.012 0.020
#> SRR975601 3 0.4025 0.644 0.032 0.000 0.796 0.016 0.128 0.028
#> SRR975602 1 0.5125 0.634 0.656 0.000 0.000 0.060 0.244 0.040
#> SRR975603 3 0.0000 0.740 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975604 3 0.0146 0.738 0.000 0.000 0.996 0.000 0.004 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 17171 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 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.991 0.996 0.5044 0.497 0.497
#> 3 3 0.909 0.929 0.962 0.2770 0.868 0.734
#> 4 4 0.781 0.756 0.889 0.0847 0.904 0.746
#> 5 5 0.799 0.626 0.832 0.0722 0.948 0.833
#> 6 6 0.722 0.628 0.772 0.0480 0.941 0.786
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR975551 1 0.000 0.992 1.000 0.000
#> SRR975552 1 0.000 0.992 1.000 0.000
#> SRR975554 1 0.000 0.992 1.000 0.000
#> SRR975553 2 0.000 1.000 0.000 1.000
#> SRR975555 1 0.000 0.992 1.000 0.000
#> SRR975556 2 0.000 1.000 0.000 1.000
#> SRR975557 1 0.000 0.992 1.000 0.000
#> SRR975558 1 0.722 0.752 0.800 0.200
#> SRR975559 1 0.000 0.992 1.000 0.000
#> SRR975560 2 0.000 1.000 0.000 1.000
#> SRR975561 2 0.000 1.000 0.000 1.000
#> SRR975562 1 0.000 0.992 1.000 0.000
#> SRR975563 2 0.000 1.000 0.000 1.000
#> SRR975564 1 0.000 0.992 1.000 0.000
#> SRR975565 1 0.000 0.992 1.000 0.000
#> SRR975566 1 0.000 0.992 1.000 0.000
#> SRR975567 1 0.163 0.970 0.976 0.024
#> SRR975568 1 0.000 0.992 1.000 0.000
#> SRR975569 2 0.000 1.000 0.000 1.000
#> SRR975570 2 0.000 1.000 0.000 1.000
#> SRR975571 2 0.000 1.000 0.000 1.000
#> SRR975572 2 0.000 1.000 0.000 1.000
#> SRR975573 2 0.000 1.000 0.000 1.000
#> SRR975574 2 0.000 1.000 0.000 1.000
#> SRR975575 2 0.000 1.000 0.000 1.000
#> SRR975576 2 0.000 1.000 0.000 1.000
#> SRR975577 2 0.000 1.000 0.000 1.000
#> SRR975578 2 0.000 1.000 0.000 1.000
#> SRR975579 2 0.000 1.000 0.000 1.000
#> SRR975580 2 0.000 1.000 0.000 1.000
#> SRR975581 2 0.000 1.000 0.000 1.000
#> SRR975582 2 0.000 1.000 0.000 1.000
#> SRR975583 2 0.000 1.000 0.000 1.000
#> SRR975584 2 0.000 1.000 0.000 1.000
#> SRR975585 2 0.000 1.000 0.000 1.000
#> SRR975586 2 0.000 1.000 0.000 1.000
#> SRR975587 1 0.000 0.992 1.000 0.000
#> SRR975588 2 0.000 1.000 0.000 1.000
#> SRR975589 1 0.000 0.992 1.000 0.000
#> SRR975590 1 0.000 0.992 1.000 0.000
#> SRR975591 1 0.000 0.992 1.000 0.000
#> SRR975592 1 0.000 0.992 1.000 0.000
#> SRR975593 1 0.000 0.992 1.000 0.000
#> SRR975594 1 0.000 0.992 1.000 0.000
#> SRR975595 1 0.000 0.992 1.000 0.000
#> SRR975597 1 0.000 0.992 1.000 0.000
#> SRR975596 1 0.000 0.992 1.000 0.000
#> SRR975598 1 0.000 0.992 1.000 0.000
#> SRR975599 1 0.000 0.992 1.000 0.000
#> SRR975600 1 0.000 0.992 1.000 0.000
#> SRR975601 1 0.000 0.992 1.000 0.000
#> SRR975602 1 0.000 0.992 1.000 0.000
#> SRR975603 1 0.000 0.992 1.000 0.000
#> SRR975604 1 0.000 0.992 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.000 0.891 1.000 0 0.000
#> SRR975552 1 0.000 0.891 1.000 0 0.000
#> SRR975554 1 0.000 0.891 1.000 0 0.000
#> SRR975553 2 0.000 1.000 0.000 1 0.000
#> SRR975555 1 0.000 0.891 1.000 0 0.000
#> SRR975556 2 0.000 1.000 0.000 1 0.000
#> SRR975557 3 0.000 1.000 0.000 0 1.000
#> SRR975558 1 0.000 0.891 1.000 0 0.000
#> SRR975559 1 0.000 0.891 1.000 0 0.000
#> SRR975560 2 0.000 1.000 0.000 1 0.000
#> SRR975561 2 0.000 1.000 0.000 1 0.000
#> SRR975562 1 0.000 0.891 1.000 0 0.000
#> SRR975563 2 0.000 1.000 0.000 1 0.000
#> SRR975564 1 0.000 0.891 1.000 0 0.000
#> SRR975565 1 0.000 0.891 1.000 0 0.000
#> SRR975566 1 0.000 0.891 1.000 0 0.000
#> SRR975567 1 0.000 0.891 1.000 0 0.000
#> SRR975568 1 0.000 0.891 1.000 0 0.000
#> SRR975569 2 0.000 1.000 0.000 1 0.000
#> SRR975570 2 0.000 1.000 0.000 1 0.000
#> SRR975571 2 0.000 1.000 0.000 1 0.000
#> SRR975572 2 0.000 1.000 0.000 1 0.000
#> SRR975573 2 0.000 1.000 0.000 1 0.000
#> SRR975574 2 0.000 1.000 0.000 1 0.000
#> SRR975575 2 0.000 1.000 0.000 1 0.000
#> SRR975576 2 0.000 1.000 0.000 1 0.000
#> SRR975577 2 0.000 1.000 0.000 1 0.000
#> SRR975578 2 0.000 1.000 0.000 1 0.000
#> SRR975579 2 0.000 1.000 0.000 1 0.000
#> SRR975580 2 0.000 1.000 0.000 1 0.000
#> SRR975581 2 0.000 1.000 0.000 1 0.000
#> SRR975582 2 0.000 1.000 0.000 1 0.000
#> SRR975583 2 0.000 1.000 0.000 1 0.000
#> SRR975584 2 0.000 1.000 0.000 1 0.000
#> SRR975585 2 0.000 1.000 0.000 1 0.000
#> SRR975586 2 0.000 1.000 0.000 1 0.000
#> SRR975587 3 0.000 1.000 0.000 0 1.000
#> SRR975588 2 0.000 1.000 0.000 1 0.000
#> SRR975589 1 0.593 0.594 0.644 0 0.356
#> SRR975590 1 0.593 0.594 0.644 0 0.356
#> SRR975591 3 0.000 1.000 0.000 0 1.000
#> SRR975592 1 0.601 0.566 0.628 0 0.372
#> SRR975593 1 0.595 0.588 0.640 0 0.360
#> SRR975594 3 0.000 1.000 0.000 0 1.000
#> SRR975595 1 0.455 0.775 0.800 0 0.200
#> SRR975597 1 0.455 0.775 0.800 0 0.200
#> SRR975596 1 0.000 0.891 1.000 0 0.000
#> SRR975598 1 0.455 0.775 0.800 0 0.200
#> SRR975599 3 0.000 1.000 0.000 0 1.000
#> SRR975600 3 0.000 1.000 0.000 0 1.000
#> SRR975601 3 0.000 1.000 0.000 0 1.000
#> SRR975602 1 0.000 0.891 1.000 0 0.000
#> SRR975603 3 0.000 1.000 0.000 0 1.000
#> SRR975604 3 0.000 1.000 0.000 0 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0000 0.8472 1.000 0.000 0.000 0.000
#> SRR975552 1 0.0000 0.8472 1.000 0.000 0.000 0.000
#> SRR975554 1 0.0000 0.8472 1.000 0.000 0.000 0.000
#> SRR975553 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975555 1 0.0000 0.8472 1.000 0.000 0.000 0.000
#> SRR975556 2 0.0188 0.9554 0.000 0.996 0.000 0.004
#> SRR975557 3 0.5257 0.4567 0.008 0.000 0.548 0.444
#> SRR975558 4 0.7058 0.2481 0.344 0.000 0.136 0.520
#> SRR975559 1 0.3617 0.7455 0.860 0.000 0.076 0.064
#> SRR975560 4 0.4382 0.3675 0.000 0.296 0.000 0.704
#> SRR975561 2 0.4040 0.6649 0.000 0.752 0.000 0.248
#> SRR975562 1 0.1474 0.8233 0.948 0.000 0.000 0.052
#> SRR975563 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975564 1 0.0188 0.8460 0.996 0.000 0.000 0.004
#> SRR975565 1 0.0000 0.8472 1.000 0.000 0.000 0.000
#> SRR975566 1 0.2089 0.8133 0.932 0.000 0.020 0.048
#> SRR975567 4 0.6885 0.2023 0.372 0.000 0.112 0.516
#> SRR975568 1 0.0000 0.8472 1.000 0.000 0.000 0.000
#> SRR975569 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975572 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975574 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975575 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975578 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975579 4 0.4699 0.2809 0.000 0.320 0.004 0.676
#> SRR975580 2 0.3907 0.6891 0.000 0.768 0.000 0.232
#> SRR975581 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975582 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975583 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975585 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975586 2 0.4040 0.6649 0.000 0.752 0.000 0.248
#> SRR975587 3 0.2149 0.7302 0.088 0.000 0.912 0.000
#> SRR975588 2 0.0000 0.9587 0.000 1.000 0.000 0.000
#> SRR975589 3 0.6074 0.2339 0.340 0.000 0.600 0.060
#> SRR975590 1 0.4697 0.4321 0.644 0.000 0.356 0.000
#> SRR975591 3 0.0000 0.7630 0.000 0.000 1.000 0.000
#> SRR975592 1 0.4996 0.0432 0.516 0.000 0.484 0.000
#> SRR975593 3 0.5986 0.2898 0.320 0.000 0.620 0.060
#> SRR975594 3 0.3907 0.6834 0.000 0.000 0.768 0.232
#> SRR975595 1 0.3074 0.7548 0.848 0.000 0.152 0.000
#> SRR975597 1 0.3074 0.7548 0.848 0.000 0.152 0.000
#> SRR975596 1 0.3900 0.7270 0.844 0.000 0.084 0.072
#> SRR975598 1 0.3074 0.7548 0.848 0.000 0.152 0.000
#> SRR975599 3 0.4567 0.6699 0.016 0.000 0.740 0.244
#> SRR975600 3 0.0188 0.7621 0.000 0.000 0.996 0.004
#> SRR975601 3 0.2342 0.7500 0.008 0.000 0.912 0.080
#> SRR975602 1 0.0000 0.8472 1.000 0.000 0.000 0.000
#> SRR975603 3 0.0188 0.7621 0.000 0.000 0.996 0.004
#> SRR975604 3 0.0336 0.7635 0.000 0.000 0.992 0.008
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.0451 0.79049 0.988 0.000 0.000 0.004 0.008
#> SRR975552 1 0.0693 0.79090 0.980 0.000 0.000 0.008 0.012
#> SRR975554 1 0.0510 0.78916 0.984 0.000 0.000 0.000 0.016
#> SRR975553 2 0.1502 0.88258 0.000 0.940 0.000 0.056 0.004
#> SRR975555 1 0.0404 0.79064 0.988 0.000 0.000 0.000 0.012
#> SRR975556 2 0.2172 0.82742 0.000 0.908 0.000 0.076 0.016
#> SRR975557 4 0.6137 -0.06114 0.000 0.000 0.392 0.476 0.132
#> SRR975558 5 0.1281 0.38743 0.032 0.000 0.012 0.000 0.956
#> SRR975559 5 0.4907 0.32650 0.488 0.000 0.000 0.024 0.488
#> SRR975560 4 0.5456 0.25881 0.000 0.060 0.000 0.484 0.456
#> SRR975561 2 0.4978 0.11538 0.000 0.496 0.000 0.476 0.028
#> SRR975562 1 0.4243 0.35666 0.712 0.000 0.000 0.024 0.264
#> SRR975563 2 0.0162 0.89017 0.000 0.996 0.000 0.000 0.004
#> SRR975564 1 0.1768 0.74953 0.924 0.000 0.000 0.004 0.072
#> SRR975565 1 0.0404 0.79059 0.988 0.000 0.000 0.000 0.012
#> SRR975566 1 0.4404 0.24004 0.684 0.000 0.000 0.024 0.292
#> SRR975567 5 0.1444 0.39827 0.040 0.000 0.012 0.000 0.948
#> SRR975568 1 0.0703 0.78753 0.976 0.000 0.000 0.000 0.024
#> SRR975569 2 0.0000 0.89024 0.000 1.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.89024 0.000 1.000 0.000 0.000 0.000
#> SRR975571 2 0.1502 0.88258 0.000 0.940 0.000 0.056 0.004
#> SRR975572 2 0.0162 0.89017 0.000 0.996 0.000 0.000 0.004
#> SRR975573 2 0.1502 0.88258 0.000 0.940 0.000 0.056 0.004
#> SRR975574 2 0.1502 0.88258 0.000 0.940 0.000 0.056 0.004
#> SRR975575 2 0.0162 0.89017 0.000 0.996 0.000 0.000 0.004
#> SRR975576 2 0.0162 0.89017 0.000 0.996 0.000 0.000 0.004
#> SRR975577 2 0.1502 0.88258 0.000 0.940 0.000 0.056 0.004
#> SRR975578 2 0.1502 0.88258 0.000 0.940 0.000 0.056 0.004
#> SRR975579 4 0.3857 0.47069 0.000 0.088 0.052 0.832 0.028
#> SRR975580 2 0.5176 0.20955 0.000 0.492 0.000 0.468 0.040
#> SRR975581 2 0.0162 0.89017 0.000 0.996 0.000 0.000 0.004
#> SRR975582 2 0.1502 0.88258 0.000 0.940 0.000 0.056 0.004
#> SRR975583 2 0.0162 0.89017 0.000 0.996 0.000 0.000 0.004
#> SRR975584 2 0.1502 0.88258 0.000 0.940 0.000 0.056 0.004
#> SRR975585 2 0.0162 0.89017 0.000 0.996 0.000 0.000 0.004
#> SRR975586 2 0.5296 0.08208 0.000 0.484 0.000 0.468 0.048
#> SRR975587 3 0.1670 0.63818 0.052 0.000 0.936 0.012 0.000
#> SRR975588 2 0.0000 0.89024 0.000 1.000 0.000 0.000 0.000
#> SRR975589 3 0.5967 0.31990 0.056 0.000 0.508 0.024 0.412
#> SRR975590 1 0.4971 0.42452 0.628 0.000 0.332 0.036 0.004
#> SRR975591 3 0.2424 0.66811 0.000 0.000 0.868 0.000 0.132
#> SRR975592 3 0.5338 0.00385 0.456 0.000 0.504 0.024 0.016
#> SRR975593 3 0.5853 0.33424 0.048 0.000 0.516 0.024 0.412
#> SRR975594 3 0.3424 0.36759 0.000 0.000 0.760 0.240 0.000
#> SRR975595 1 0.4043 0.67792 0.792 0.000 0.160 0.036 0.012
#> SRR975597 1 0.4012 0.67098 0.788 0.000 0.168 0.036 0.008
#> SRR975596 5 0.4979 0.34455 0.480 0.000 0.000 0.028 0.492
#> SRR975598 1 0.3962 0.68501 0.800 0.000 0.152 0.036 0.012
#> SRR975599 3 0.4986 0.17863 0.032 0.000 0.608 0.356 0.004
#> SRR975600 3 0.2605 0.66359 0.000 0.000 0.852 0.000 0.148
#> SRR975601 3 0.0912 0.63177 0.012 0.000 0.972 0.016 0.000
#> SRR975602 1 0.1153 0.78001 0.964 0.000 0.004 0.024 0.008
#> SRR975603 3 0.2424 0.66811 0.000 0.000 0.868 0.000 0.132
#> SRR975604 3 0.1608 0.66177 0.000 0.000 0.928 0.000 0.072
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.0725 0.7243 0.976 0.000 0.000 0.012 0.000 0.012
#> SRR975552 1 0.1226 0.7221 0.952 0.000 0.000 0.040 0.004 0.004
#> SRR975554 1 0.1757 0.7075 0.916 0.000 0.000 0.076 0.000 0.008
#> SRR975553 2 0.0000 0.7498 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975555 1 0.1620 0.7190 0.940 0.000 0.000 0.024 0.012 0.024
#> SRR975556 2 0.3869 0.2617 0.000 0.500 0.000 0.000 0.000 0.500
#> SRR975557 5 0.2766 0.6280 0.000 0.000 0.124 0.020 0.852 0.004
#> SRR975558 4 0.4348 0.4367 0.024 0.000 0.056 0.788 0.032 0.100
#> SRR975559 4 0.4242 0.3029 0.412 0.000 0.012 0.572 0.004 0.000
#> SRR975560 6 0.4660 0.1884 0.000 0.008 0.000 0.308 0.048 0.636
#> SRR975561 6 0.4612 0.5245 0.000 0.284 0.000 0.008 0.052 0.656
#> SRR975562 1 0.4415 0.0674 0.556 0.000 0.000 0.420 0.020 0.004
#> SRR975563 2 0.3175 0.8007 0.000 0.744 0.000 0.000 0.000 0.256
#> SRR975564 1 0.2306 0.6779 0.888 0.000 0.000 0.092 0.004 0.016
#> SRR975565 1 0.0806 0.7216 0.972 0.000 0.000 0.020 0.000 0.008
#> SRR975566 1 0.4032 0.4539 0.696 0.000 0.012 0.280 0.008 0.004
#> SRR975567 4 0.4356 0.4560 0.040 0.000 0.044 0.792 0.032 0.092
#> SRR975568 1 0.1605 0.7114 0.936 0.000 0.000 0.044 0.004 0.016
#> SRR975569 2 0.3151 0.8002 0.000 0.748 0.000 0.000 0.000 0.252
#> SRR975570 2 0.3175 0.8007 0.000 0.744 0.000 0.000 0.000 0.256
#> SRR975571 2 0.0000 0.7498 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975572 2 0.3175 0.8007 0.000 0.744 0.000 0.000 0.000 0.256
#> SRR975573 2 0.0000 0.7498 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975574 2 0.0000 0.7498 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975575 2 0.3175 0.8007 0.000 0.744 0.000 0.000 0.000 0.256
#> SRR975576 2 0.3175 0.8007 0.000 0.744 0.000 0.000 0.000 0.256
#> SRR975577 2 0.0000 0.7498 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975578 2 0.0000 0.7498 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975579 5 0.2420 0.5230 0.000 0.004 0.000 0.004 0.864 0.128
#> SRR975580 6 0.4790 0.5998 0.000 0.368 0.000 0.016 0.032 0.584
#> SRR975581 2 0.3175 0.8007 0.000 0.744 0.000 0.000 0.000 0.256
#> SRR975582 2 0.0000 0.7498 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975583 2 0.3175 0.8007 0.000 0.744 0.000 0.000 0.000 0.256
#> SRR975584 2 0.0000 0.7498 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975585 2 0.3175 0.8007 0.000 0.744 0.000 0.000 0.000 0.256
#> SRR975586 6 0.4075 0.6487 0.000 0.204 0.000 0.016 0.036 0.744
#> SRR975587 3 0.3023 0.6768 0.008 0.000 0.872 0.032 0.052 0.036
#> SRR975588 2 0.3175 0.8007 0.000 0.744 0.000 0.000 0.000 0.256
#> SRR975589 3 0.4476 0.5929 0.012 0.000 0.680 0.276 0.012 0.020
#> SRR975590 1 0.6170 0.3186 0.540 0.000 0.324 0.072 0.024 0.040
#> SRR975591 3 0.0858 0.7484 0.000 0.000 0.968 0.028 0.004 0.000
#> SRR975592 3 0.5743 0.4024 0.288 0.000 0.588 0.088 0.020 0.016
#> SRR975593 3 0.4291 0.5834 0.008 0.000 0.676 0.292 0.012 0.012
#> SRR975594 5 0.4786 0.2934 0.000 0.000 0.468 0.012 0.492 0.028
#> SRR975595 1 0.6060 0.5973 0.664 0.000 0.116 0.104 0.048 0.068
#> SRR975597 1 0.5903 0.5992 0.676 0.000 0.124 0.088 0.044 0.068
#> SRR975596 4 0.4209 0.3078 0.396 0.000 0.012 0.588 0.004 0.000
#> SRR975598 1 0.6060 0.5973 0.664 0.000 0.116 0.104 0.048 0.068
#> SRR975599 5 0.5914 0.5501 0.032 0.000 0.228 0.068 0.628 0.044
#> SRR975600 3 0.1364 0.7457 0.000 0.000 0.944 0.048 0.004 0.004
#> SRR975601 3 0.3320 0.6388 0.000 0.000 0.844 0.032 0.076 0.048
#> SRR975602 1 0.3300 0.6873 0.832 0.000 0.000 0.116 0.032 0.020
#> SRR975603 3 0.0858 0.7484 0.000 0.000 0.968 0.028 0.004 0.000
#> SRR975604 3 0.0653 0.7367 0.000 0.000 0.980 0.004 0.012 0.004
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "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 17171 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 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5037 0.497 0.497
#> 3 3 0.809 0.894 0.928 0.2848 0.816 0.642
#> 4 4 0.797 0.811 0.895 0.1148 0.909 0.751
#> 5 5 0.749 0.736 0.856 0.0323 0.918 0.749
#> 6 6 0.740 0.712 0.812 0.0719 0.892 0.631
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
#> SRR975551 1 0.0000 1.000 1.000 0.000
#> SRR975552 1 0.0000 1.000 1.000 0.000
#> SRR975554 1 0.0000 1.000 1.000 0.000
#> SRR975553 2 0.0000 1.000 0.000 1.000
#> SRR975555 1 0.0000 1.000 1.000 0.000
#> SRR975556 2 0.0000 1.000 0.000 1.000
#> SRR975557 1 0.0000 1.000 1.000 0.000
#> SRR975558 1 0.0672 0.992 0.992 0.008
#> SRR975559 1 0.0000 1.000 1.000 0.000
#> SRR975560 2 0.0000 1.000 0.000 1.000
#> SRR975561 2 0.0000 1.000 0.000 1.000
#> SRR975562 1 0.0000 1.000 1.000 0.000
#> SRR975563 2 0.0000 1.000 0.000 1.000
#> SRR975564 1 0.0000 1.000 1.000 0.000
#> SRR975565 1 0.0000 1.000 1.000 0.000
#> SRR975566 1 0.0000 1.000 1.000 0.000
#> SRR975567 1 0.0000 1.000 1.000 0.000
#> SRR975568 1 0.0000 1.000 1.000 0.000
#> SRR975569 2 0.0000 1.000 0.000 1.000
#> SRR975570 2 0.0000 1.000 0.000 1.000
#> SRR975571 2 0.0000 1.000 0.000 1.000
#> SRR975572 2 0.0000 1.000 0.000 1.000
#> SRR975573 2 0.0000 1.000 0.000 1.000
#> SRR975574 2 0.0000 1.000 0.000 1.000
#> SRR975575 2 0.0000 1.000 0.000 1.000
#> SRR975576 2 0.0000 1.000 0.000 1.000
#> SRR975577 2 0.0000 1.000 0.000 1.000
#> SRR975578 2 0.0000 1.000 0.000 1.000
#> SRR975579 2 0.0000 1.000 0.000 1.000
#> SRR975580 2 0.0000 1.000 0.000 1.000
#> SRR975581 2 0.0000 1.000 0.000 1.000
#> SRR975582 2 0.0000 1.000 0.000 1.000
#> SRR975583 2 0.0000 1.000 0.000 1.000
#> SRR975584 2 0.0000 1.000 0.000 1.000
#> SRR975585 2 0.0000 1.000 0.000 1.000
#> SRR975586 2 0.0000 1.000 0.000 1.000
#> SRR975587 1 0.0000 1.000 1.000 0.000
#> SRR975588 2 0.0000 1.000 0.000 1.000
#> SRR975589 1 0.0000 1.000 1.000 0.000
#> SRR975590 1 0.0000 1.000 1.000 0.000
#> SRR975591 1 0.0000 1.000 1.000 0.000
#> SRR975592 1 0.0000 1.000 1.000 0.000
#> SRR975593 1 0.0000 1.000 1.000 0.000
#> SRR975594 1 0.0000 1.000 1.000 0.000
#> SRR975595 1 0.0000 1.000 1.000 0.000
#> SRR975597 1 0.0000 1.000 1.000 0.000
#> SRR975596 1 0.0000 1.000 1.000 0.000
#> SRR975598 1 0.0000 1.000 1.000 0.000
#> SRR975599 1 0.0000 1.000 1.000 0.000
#> SRR975600 1 0.0000 1.000 1.000 0.000
#> SRR975601 1 0.0000 1.000 1.000 0.000
#> SRR975602 1 0.0000 1.000 1.000 0.000
#> SRR975603 1 0.0000 1.000 1.000 0.000
#> SRR975604 1 0.0000 1.000 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.0000 0.788 1.000 0.000 0.000
#> SRR975552 1 0.0000 0.788 1.000 0.000 0.000
#> SRR975554 1 0.5058 0.859 0.756 0.000 0.244
#> SRR975553 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975555 1 0.0424 0.795 0.992 0.000 0.008
#> SRR975556 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975557 3 0.0237 0.896 0.004 0.000 0.996
#> SRR975558 2 0.7001 0.706 0.200 0.716 0.084
#> SRR975559 1 0.5216 0.844 0.740 0.000 0.260
#> SRR975560 2 0.4452 0.811 0.192 0.808 0.000
#> SRR975561 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975562 1 0.5098 0.857 0.752 0.000 0.248
#> SRR975563 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975564 1 0.4452 0.888 0.808 0.000 0.192
#> SRR975565 1 0.1163 0.809 0.972 0.000 0.028
#> SRR975566 3 0.3752 0.783 0.144 0.000 0.856
#> SRR975567 3 0.5465 0.645 0.288 0.000 0.712
#> SRR975568 1 0.4235 0.883 0.824 0.000 0.176
#> SRR975569 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975571 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975572 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975573 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975574 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975575 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975577 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975578 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975579 2 0.2261 0.928 0.068 0.932 0.000
#> SRR975580 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975581 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975582 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975583 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975584 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975585 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975586 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975587 3 0.1964 0.870 0.056 0.000 0.944
#> SRR975588 2 0.0000 0.980 0.000 1.000 0.000
#> SRR975589 3 0.0000 0.898 0.000 0.000 1.000
#> SRR975590 1 0.4605 0.885 0.796 0.000 0.204
#> SRR975591 3 0.0000 0.898 0.000 0.000 1.000
#> SRR975592 3 0.3192 0.811 0.112 0.000 0.888
#> SRR975593 3 0.0000 0.898 0.000 0.000 1.000
#> SRR975594 3 0.0000 0.898 0.000 0.000 1.000
#> SRR975595 1 0.4887 0.864 0.772 0.000 0.228
#> SRR975597 1 0.4555 0.886 0.800 0.000 0.200
#> SRR975596 3 0.4654 0.692 0.208 0.000 0.792
#> SRR975598 1 0.4504 0.887 0.804 0.000 0.196
#> SRR975599 3 0.5465 0.517 0.288 0.000 0.712
#> SRR975600 3 0.0000 0.898 0.000 0.000 1.000
#> SRR975601 3 0.1860 0.872 0.052 0.000 0.948
#> SRR975602 1 0.4504 0.887 0.804 0.000 0.196
#> SRR975603 3 0.0000 0.898 0.000 0.000 1.000
#> SRR975604 3 0.0000 0.898 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0000 0.8842 1.000 0.000 0.000 0.000
#> SRR975552 1 0.2149 0.8103 0.912 0.000 0.000 0.088
#> SRR975554 4 0.7072 0.6189 0.336 0.000 0.140 0.524
#> SRR975553 2 0.0336 0.9090 0.000 0.992 0.000 0.008
#> SRR975555 1 0.0000 0.8842 1.000 0.000 0.000 0.000
#> SRR975556 2 0.1716 0.8719 0.000 0.936 0.000 0.064
#> SRR975557 3 0.1302 0.9082 0.000 0.000 0.956 0.044
#> SRR975558 4 0.1474 0.6714 0.000 0.000 0.052 0.948
#> SRR975559 4 0.7096 0.6237 0.332 0.000 0.144 0.524
#> SRR975560 2 0.4941 0.5020 0.000 0.564 0.000 0.436
#> SRR975561 2 0.3907 0.7360 0.000 0.768 0.000 0.232
#> SRR975562 4 0.5985 0.7537 0.168 0.000 0.140 0.692
#> SRR975563 2 0.0000 0.9094 0.000 1.000 0.000 0.000
#> SRR975564 1 0.0895 0.8757 0.976 0.000 0.004 0.020
#> SRR975565 1 0.0376 0.8833 0.992 0.000 0.004 0.004
#> SRR975566 4 0.7109 0.5977 0.144 0.000 0.336 0.520
#> SRR975567 4 0.1474 0.6714 0.000 0.000 0.052 0.948
#> SRR975568 1 0.2053 0.8177 0.924 0.000 0.072 0.004
#> SRR975569 2 0.0000 0.9094 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.9094 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0336 0.9090 0.000 0.992 0.000 0.008
#> SRR975572 2 0.0000 0.9094 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0336 0.9090 0.000 0.992 0.000 0.008
#> SRR975574 2 0.0336 0.9090 0.000 0.992 0.000 0.008
#> SRR975575 2 0.0000 0.9094 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.9094 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0336 0.9090 0.000 0.992 0.000 0.008
#> SRR975578 2 0.0336 0.9090 0.000 0.992 0.000 0.008
#> SRR975579 2 0.4992 0.4428 0.000 0.524 0.000 0.476
#> SRR975580 2 0.4933 0.5081 0.000 0.568 0.000 0.432
#> SRR975581 2 0.0000 0.9094 0.000 1.000 0.000 0.000
#> SRR975582 2 0.0336 0.9090 0.000 0.992 0.000 0.008
#> SRR975583 2 0.0000 0.9094 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0336 0.9090 0.000 0.992 0.000 0.008
#> SRR975585 2 0.0000 0.9094 0.000 1.000 0.000 0.000
#> SRR975586 2 0.4916 0.5098 0.000 0.576 0.000 0.424
#> SRR975587 3 0.3074 0.8045 0.152 0.000 0.848 0.000
#> SRR975588 2 0.0000 0.9094 0.000 1.000 0.000 0.000
#> SRR975589 3 0.0000 0.9248 0.000 0.000 1.000 0.000
#> SRR975590 1 0.2469 0.7876 0.892 0.000 0.108 0.000
#> SRR975591 3 0.0000 0.9248 0.000 0.000 1.000 0.000
#> SRR975592 3 0.3074 0.7575 0.152 0.000 0.848 0.000
#> SRR975593 3 0.0000 0.9248 0.000 0.000 1.000 0.000
#> SRR975594 3 0.1489 0.9070 0.004 0.000 0.952 0.044
#> SRR975595 1 0.0707 0.8808 0.980 0.000 0.020 0.000
#> SRR975597 1 0.1211 0.8671 0.960 0.000 0.040 0.000
#> SRR975596 4 0.5948 0.7552 0.160 0.000 0.144 0.696
#> SRR975598 1 0.0469 0.8835 0.988 0.000 0.012 0.000
#> SRR975599 1 0.7450 -0.0201 0.424 0.000 0.404 0.172
#> SRR975600 3 0.0000 0.9248 0.000 0.000 1.000 0.000
#> SRR975601 3 0.2921 0.8164 0.140 0.000 0.860 0.000
#> SRR975602 1 0.0000 0.8842 1.000 0.000 0.000 0.000
#> SRR975603 3 0.0000 0.9248 0.000 0.000 1.000 0.000
#> SRR975604 3 0.0000 0.9248 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.0404 0.898 0.988 0.000 0.000 0.000 0.012
#> SRR975552 1 0.2471 0.832 0.864 0.000 0.000 0.000 0.136
#> SRR975554 3 0.6801 0.285 0.312 0.000 0.376 0.000 0.312
#> SRR975553 2 0.2719 0.867 0.000 0.852 0.000 0.144 0.004
#> SRR975555 1 0.0290 0.899 0.992 0.000 0.000 0.000 0.008
#> SRR975556 2 0.1197 0.872 0.000 0.952 0.000 0.048 0.000
#> SRR975557 4 0.5122 0.312 0.000 0.000 0.312 0.628 0.060
#> SRR975558 3 0.6572 0.351 0.000 0.000 0.460 0.228 0.312
#> SRR975559 3 0.4584 0.593 0.028 0.000 0.660 0.000 0.312
#> SRR975560 2 0.5172 0.624 0.000 0.616 0.000 0.324 0.060
#> SRR975561 2 0.2929 0.772 0.000 0.820 0.000 0.180 0.000
#> SRR975562 3 0.4348 0.595 0.016 0.000 0.668 0.000 0.316
#> SRR975563 2 0.0000 0.892 0.000 1.000 0.000 0.000 0.000
#> SRR975564 1 0.0880 0.894 0.968 0.000 0.000 0.000 0.032
#> SRR975565 1 0.3430 0.668 0.776 0.000 0.004 0.000 0.220
#> SRR975566 3 0.5672 0.538 0.104 0.000 0.584 0.000 0.312
#> SRR975567 3 0.6572 0.351 0.000 0.000 0.460 0.228 0.312
#> SRR975568 1 0.2344 0.854 0.904 0.000 0.064 0.000 0.032
#> SRR975569 2 0.0000 0.892 0.000 1.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.892 0.000 1.000 0.000 0.000 0.000
#> SRR975571 2 0.2719 0.867 0.000 0.852 0.000 0.144 0.004
#> SRR975572 2 0.0000 0.892 0.000 1.000 0.000 0.000 0.000
#> SRR975573 2 0.2329 0.874 0.000 0.876 0.000 0.124 0.000
#> SRR975574 2 0.2536 0.872 0.000 0.868 0.000 0.128 0.004
#> SRR975575 2 0.0000 0.892 0.000 1.000 0.000 0.000 0.000
#> SRR975576 2 0.0000 0.892 0.000 1.000 0.000 0.000 0.000
#> SRR975577 2 0.2719 0.867 0.000 0.852 0.000 0.144 0.004
#> SRR975578 2 0.2719 0.867 0.000 0.852 0.000 0.144 0.004
#> SRR975579 4 0.0404 0.422 0.000 0.000 0.000 0.988 0.012
#> SRR975580 2 0.4101 0.660 0.000 0.628 0.000 0.372 0.000
#> SRR975581 2 0.0000 0.892 0.000 1.000 0.000 0.000 0.000
#> SRR975582 2 0.2536 0.872 0.000 0.868 0.000 0.128 0.004
#> SRR975583 2 0.0000 0.892 0.000 1.000 0.000 0.000 0.000
#> SRR975584 2 0.2719 0.867 0.000 0.852 0.000 0.144 0.004
#> SRR975585 2 0.0000 0.892 0.000 1.000 0.000 0.000 0.000
#> SRR975586 2 0.3336 0.710 0.000 0.772 0.000 0.228 0.000
#> SRR975587 5 0.5441 0.803 0.080 0.000 0.324 0.000 0.596
#> SRR975588 2 0.0000 0.892 0.000 1.000 0.000 0.000 0.000
#> SRR975589 3 0.0000 0.620 0.000 0.000 1.000 0.000 0.000
#> SRR975590 1 0.1041 0.899 0.964 0.000 0.032 0.000 0.004
#> SRR975591 3 0.0000 0.620 0.000 0.000 1.000 0.000 0.000
#> SRR975592 3 0.3661 0.195 0.276 0.000 0.724 0.000 0.000
#> SRR975593 3 0.0000 0.620 0.000 0.000 1.000 0.000 0.000
#> SRR975594 5 0.4138 0.740 0.000 0.000 0.384 0.000 0.616
#> SRR975595 1 0.2077 0.870 0.908 0.000 0.084 0.000 0.008
#> SRR975597 1 0.2077 0.870 0.908 0.000 0.084 0.000 0.008
#> SRR975596 3 0.4419 0.595 0.020 0.000 0.668 0.000 0.312
#> SRR975598 1 0.2077 0.870 0.908 0.000 0.084 0.000 0.008
#> SRR975599 5 0.7316 0.492 0.188 0.000 0.196 0.084 0.532
#> SRR975600 3 0.0000 0.620 0.000 0.000 1.000 0.000 0.000
#> SRR975601 5 0.5315 0.805 0.068 0.000 0.332 0.000 0.600
#> SRR975602 1 0.0290 0.898 0.992 0.000 0.000 0.000 0.008
#> SRR975603 3 0.0000 0.620 0.000 0.000 1.000 0.000 0.000
#> SRR975604 3 0.0000 0.620 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.0000 0.800 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR975552 1 0.4022 0.706 0.792 0.064 0.000 0.108 0.036 0.000
#> SRR975554 1 0.6141 -0.250 0.400 0.000 0.352 0.004 0.244 0.000
#> SRR975553 6 0.0000 0.827 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR975555 1 0.0458 0.802 0.984 0.000 0.000 0.000 0.016 0.000
#> SRR975556 2 0.3911 0.925 0.000 0.624 0.000 0.008 0.000 0.368
#> SRR975557 4 0.2536 0.733 0.000 0.000 0.116 0.864 0.020 0.000
#> SRR975558 3 0.6976 0.230 0.000 0.372 0.380 0.144 0.104 0.000
#> SRR975559 3 0.4237 0.638 0.048 0.000 0.704 0.004 0.244 0.000
#> SRR975560 6 0.5571 0.150 0.000 0.372 0.000 0.144 0.000 0.484
#> SRR975561 2 0.4292 0.779 0.000 0.628 0.000 0.032 0.000 0.340
#> SRR975562 3 0.3872 0.642 0.020 0.000 0.712 0.004 0.264 0.000
#> SRR975563 2 0.3684 0.936 0.000 0.628 0.000 0.000 0.000 0.372
#> SRR975564 1 0.0603 0.799 0.980 0.000 0.004 0.000 0.016 0.000
#> SRR975565 1 0.3011 0.640 0.800 0.004 0.004 0.000 0.192 0.000
#> SRR975566 3 0.5576 0.517 0.184 0.000 0.568 0.004 0.244 0.000
#> SRR975567 3 0.7262 0.263 0.000 0.320 0.380 0.144 0.156 0.000
#> SRR975568 1 0.1659 0.790 0.940 0.020 0.028 0.004 0.008 0.000
#> SRR975569 2 0.3684 0.936 0.000 0.628 0.000 0.000 0.000 0.372
#> SRR975570 2 0.3684 0.936 0.000 0.628 0.000 0.000 0.000 0.372
#> SRR975571 6 0.0000 0.827 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR975572 2 0.3684 0.936 0.000 0.628 0.000 0.000 0.000 0.372
#> SRR975573 6 0.1444 0.765 0.000 0.072 0.000 0.000 0.000 0.928
#> SRR975574 6 0.1141 0.791 0.000 0.052 0.000 0.000 0.000 0.948
#> SRR975575 2 0.3684 0.936 0.000 0.628 0.000 0.000 0.000 0.372
#> SRR975576 2 0.3684 0.936 0.000 0.628 0.000 0.000 0.000 0.372
#> SRR975577 6 0.0000 0.827 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR975578 6 0.0000 0.827 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR975579 4 0.2100 0.749 0.000 0.004 0.000 0.884 0.000 0.112
#> SRR975580 6 0.4316 0.395 0.000 0.312 0.000 0.040 0.000 0.648
#> SRR975581 2 0.3684 0.936 0.000 0.628 0.000 0.000 0.000 0.372
#> SRR975582 6 0.1141 0.791 0.000 0.052 0.000 0.000 0.000 0.948
#> SRR975583 2 0.3684 0.936 0.000 0.628 0.000 0.000 0.000 0.372
#> SRR975584 6 0.0000 0.827 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR975585 2 0.3684 0.936 0.000 0.628 0.000 0.000 0.000 0.372
#> SRR975586 2 0.2250 0.440 0.000 0.896 0.000 0.040 0.000 0.064
#> SRR975587 5 0.3595 0.843 0.008 0.000 0.288 0.000 0.704 0.000
#> SRR975588 2 0.3684 0.936 0.000 0.628 0.000 0.000 0.000 0.372
#> SRR975589 3 0.0000 0.680 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975590 1 0.1124 0.807 0.956 0.000 0.036 0.000 0.008 0.000
#> SRR975591 3 0.0000 0.680 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975592 3 0.3309 0.310 0.280 0.000 0.720 0.000 0.000 0.000
#> SRR975593 3 0.0000 0.680 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975594 5 0.3351 0.843 0.000 0.000 0.288 0.000 0.712 0.000
#> SRR975595 1 0.3381 0.739 0.800 0.000 0.156 0.000 0.044 0.000
#> SRR975597 1 0.3381 0.739 0.800 0.000 0.156 0.000 0.044 0.000
#> SRR975596 3 0.4117 0.645 0.032 0.004 0.716 0.004 0.244 0.000
#> SRR975598 1 0.3381 0.739 0.800 0.000 0.156 0.000 0.044 0.000
#> SRR975599 5 0.6416 0.457 0.068 0.124 0.156 0.036 0.616 0.000
#> SRR975600 3 0.0000 0.680 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975601 5 0.3489 0.845 0.004 0.000 0.288 0.000 0.708 0.000
#> SRR975602 1 0.1549 0.801 0.936 0.000 0.020 0.000 0.044 0.000
#> SRR975603 3 0.0000 0.680 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975604 3 0.0000 0.680 0.000 0.000 1.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "mclust"]
# you can also extract it by
# res = res_list["MAD:mclust"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 17171 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 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.974 0.989 0.4602 0.547 0.547
#> 3 3 0.738 0.857 0.929 0.4250 0.808 0.649
#> 4 4 0.697 0.672 0.827 0.1013 0.825 0.564
#> 5 5 0.732 0.601 0.793 0.0536 0.905 0.675
#> 6 6 0.752 0.656 0.801 0.0407 0.920 0.674
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
#> SRR975551 1 0.000 0.982 1.000 0.000
#> SRR975552 1 0.000 0.982 1.000 0.000
#> SRR975554 1 0.000 0.982 1.000 0.000
#> SRR975553 2 0.000 1.000 0.000 1.000
#> SRR975555 1 0.000 0.982 1.000 0.000
#> SRR975556 1 0.541 0.858 0.876 0.124
#> SRR975557 1 0.000 0.982 1.000 0.000
#> SRR975558 1 0.000 0.982 1.000 0.000
#> SRR975559 1 0.000 0.982 1.000 0.000
#> SRR975560 1 0.000 0.982 1.000 0.000
#> SRR975561 1 0.917 0.523 0.668 0.332
#> SRR975562 1 0.000 0.982 1.000 0.000
#> SRR975563 2 0.000 1.000 0.000 1.000
#> SRR975564 1 0.000 0.982 1.000 0.000
#> SRR975565 1 0.000 0.982 1.000 0.000
#> SRR975566 1 0.000 0.982 1.000 0.000
#> SRR975567 1 0.000 0.982 1.000 0.000
#> SRR975568 1 0.000 0.982 1.000 0.000
#> SRR975569 2 0.000 1.000 0.000 1.000
#> SRR975570 2 0.000 1.000 0.000 1.000
#> SRR975571 2 0.000 1.000 0.000 1.000
#> SRR975572 2 0.000 1.000 0.000 1.000
#> SRR975573 2 0.000 1.000 0.000 1.000
#> SRR975574 2 0.000 1.000 0.000 1.000
#> SRR975575 2 0.000 1.000 0.000 1.000
#> SRR975576 2 0.000 1.000 0.000 1.000
#> SRR975577 2 0.000 1.000 0.000 1.000
#> SRR975578 2 0.000 1.000 0.000 1.000
#> SRR975579 1 0.000 0.982 1.000 0.000
#> SRR975580 1 0.000 0.982 1.000 0.000
#> SRR975581 2 0.000 1.000 0.000 1.000
#> SRR975582 2 0.000 1.000 0.000 1.000
#> SRR975583 2 0.000 1.000 0.000 1.000
#> SRR975584 2 0.000 1.000 0.000 1.000
#> SRR975585 2 0.000 1.000 0.000 1.000
#> SRR975586 1 0.644 0.808 0.836 0.164
#> SRR975587 1 0.000 0.982 1.000 0.000
#> SRR975588 2 0.000 1.000 0.000 1.000
#> SRR975589 1 0.000 0.982 1.000 0.000
#> SRR975590 1 0.000 0.982 1.000 0.000
#> SRR975591 1 0.000 0.982 1.000 0.000
#> SRR975592 1 0.000 0.982 1.000 0.000
#> SRR975593 1 0.000 0.982 1.000 0.000
#> SRR975594 1 0.000 0.982 1.000 0.000
#> SRR975595 1 0.000 0.982 1.000 0.000
#> SRR975597 1 0.000 0.982 1.000 0.000
#> SRR975596 1 0.000 0.982 1.000 0.000
#> SRR975598 1 0.000 0.982 1.000 0.000
#> SRR975599 1 0.000 0.982 1.000 0.000
#> SRR975600 1 0.000 0.982 1.000 0.000
#> SRR975601 1 0.000 0.982 1.000 0.000
#> SRR975602 1 0.000 0.982 1.000 0.000
#> SRR975603 1 0.000 0.982 1.000 0.000
#> SRR975604 1 0.000 0.982 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.3752 0.830 0.856 0.000 0.144
#> SRR975552 1 0.3752 0.830 0.856 0.000 0.144
#> SRR975554 1 0.3686 0.832 0.860 0.000 0.140
#> SRR975553 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975555 1 0.3752 0.830 0.856 0.000 0.144
#> SRR975556 3 0.0237 0.892 0.000 0.004 0.996
#> SRR975557 3 0.3752 0.822 0.144 0.000 0.856
#> SRR975558 3 0.0000 0.893 0.000 0.000 1.000
#> SRR975559 1 0.2356 0.860 0.928 0.000 0.072
#> SRR975560 3 0.0000 0.893 0.000 0.000 1.000
#> SRR975561 3 0.0592 0.886 0.000 0.012 0.988
#> SRR975562 1 0.3267 0.842 0.884 0.000 0.116
#> SRR975563 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975564 1 0.3752 0.830 0.856 0.000 0.144
#> SRR975565 1 0.3752 0.830 0.856 0.000 0.144
#> SRR975566 1 0.2261 0.860 0.932 0.000 0.068
#> SRR975567 3 0.0000 0.893 0.000 0.000 1.000
#> SRR975568 1 0.3752 0.830 0.856 0.000 0.144
#> SRR975569 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975571 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975572 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975573 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975574 2 0.1643 0.951 0.000 0.956 0.044
#> SRR975575 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975577 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975578 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975579 3 0.3686 0.825 0.140 0.000 0.860
#> SRR975580 3 0.0000 0.893 0.000 0.000 1.000
#> SRR975581 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975582 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975583 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975584 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975585 2 0.0237 0.993 0.000 0.996 0.004
#> SRR975586 3 0.0237 0.892 0.000 0.004 0.996
#> SRR975587 1 0.3192 0.798 0.888 0.000 0.112
#> SRR975588 2 0.0000 0.997 0.000 1.000 0.000
#> SRR975589 1 0.0592 0.857 0.988 0.000 0.012
#> SRR975590 1 0.0000 0.858 1.000 0.000 0.000
#> SRR975591 1 0.6026 0.337 0.624 0.000 0.376
#> SRR975592 1 0.0592 0.857 0.988 0.000 0.012
#> SRR975593 1 0.0592 0.857 0.988 0.000 0.012
#> SRR975594 3 0.3941 0.815 0.156 0.000 0.844
#> SRR975595 1 0.0000 0.858 1.000 0.000 0.000
#> SRR975597 1 0.0000 0.858 1.000 0.000 0.000
#> SRR975596 1 0.2356 0.860 0.928 0.000 0.072
#> SRR975598 1 0.0000 0.858 1.000 0.000 0.000
#> SRR975599 3 0.6286 0.171 0.464 0.000 0.536
#> SRR975600 1 0.3192 0.798 0.888 0.000 0.112
#> SRR975601 1 0.6026 0.337 0.624 0.000 0.376
#> SRR975602 1 0.0424 0.858 0.992 0.000 0.008
#> SRR975603 1 0.3192 0.798 0.888 0.000 0.112
#> SRR975604 1 0.6026 0.337 0.624 0.000 0.376
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.6621 0.575 0.628 0.000 0.184 0.188
#> SRR975552 1 0.6689 0.574 0.620 0.000 0.184 0.196
#> SRR975554 1 0.6709 0.358 0.616 0.000 0.172 0.212
#> SRR975553 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975555 1 0.6689 0.574 0.620 0.000 0.184 0.196
#> SRR975556 3 0.1302 0.601 0.000 0.044 0.956 0.000
#> SRR975557 3 0.3486 0.592 0.000 0.000 0.812 0.188
#> SRR975558 3 0.0188 0.621 0.000 0.000 0.996 0.004
#> SRR975559 4 0.6548 0.736 0.188 0.000 0.176 0.636
#> SRR975560 3 0.0188 0.622 0.000 0.004 0.996 0.000
#> SRR975561 3 0.3764 0.402 0.000 0.216 0.784 0.000
#> SRR975562 1 0.6805 0.348 0.604 0.000 0.176 0.220
#> SRR975563 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975564 1 0.6316 0.549 0.660 0.000 0.184 0.156
#> SRR975565 1 0.6689 0.574 0.620 0.000 0.184 0.196
#> SRR975566 4 0.6511 0.738 0.188 0.000 0.172 0.640
#> SRR975567 3 0.0188 0.621 0.000 0.000 0.996 0.004
#> SRR975568 1 0.6689 0.574 0.620 0.000 0.184 0.196
#> SRR975569 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975572 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975574 2 0.3024 0.794 0.000 0.852 0.148 0.000
#> SRR975575 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975578 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975579 3 0.3486 0.592 0.000 0.000 0.812 0.188
#> SRR975580 3 0.0188 0.622 0.000 0.004 0.996 0.000
#> SRR975581 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975582 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975583 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975585 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975586 3 0.1940 0.575 0.000 0.076 0.924 0.000
#> SRR975587 3 0.6666 0.493 0.404 0.000 0.508 0.088
#> SRR975588 2 0.0000 0.989 0.000 1.000 0.000 0.000
#> SRR975589 4 0.4888 0.636 0.412 0.000 0.000 0.588
#> SRR975590 1 0.2660 0.373 0.908 0.000 0.036 0.056
#> SRR975591 3 0.6417 0.530 0.388 0.000 0.540 0.072
#> SRR975592 1 0.6235 -0.425 0.524 0.000 0.420 0.056
#> SRR975593 4 0.4898 0.631 0.416 0.000 0.000 0.584
#> SRR975594 3 0.4988 0.605 0.236 0.000 0.728 0.036
#> SRR975595 1 0.0188 0.483 0.996 0.000 0.004 0.000
#> SRR975597 1 0.0376 0.480 0.992 0.000 0.004 0.004
#> SRR975596 4 0.6511 0.738 0.188 0.000 0.172 0.640
#> SRR975598 1 0.0188 0.483 0.996 0.000 0.004 0.000
#> SRR975599 3 0.6212 0.542 0.380 0.000 0.560 0.060
#> SRR975600 3 0.7701 0.289 0.388 0.000 0.392 0.220
#> SRR975601 3 0.6417 0.530 0.388 0.000 0.540 0.072
#> SRR975602 1 0.2222 0.402 0.924 0.000 0.060 0.016
#> SRR975603 3 0.6635 0.512 0.388 0.000 0.524 0.088
#> SRR975604 3 0.6417 0.530 0.388 0.000 0.540 0.072
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.1410 0.7166 0.940 0.000 0.000 0.000 0.060
#> SRR975552 1 0.1851 0.7082 0.912 0.000 0.000 0.000 0.088
#> SRR975554 1 0.6075 0.0631 0.476 0.000 0.428 0.012 0.084
#> SRR975553 2 0.0794 0.9578 0.000 0.972 0.000 0.000 0.028
#> SRR975555 1 0.1410 0.7166 0.940 0.000 0.000 0.000 0.060
#> SRR975556 5 0.4499 0.7861 0.004 0.136 0.000 0.096 0.764
#> SRR975557 4 0.2424 0.2698 0.000 0.000 0.000 0.868 0.132
#> SRR975558 5 0.5656 0.4167 0.008 0.000 0.064 0.376 0.552
#> SRR975559 3 0.3752 0.4495 0.200 0.000 0.780 0.004 0.016
#> SRR975560 5 0.4450 0.7841 0.004 0.080 0.000 0.152 0.764
#> SRR975561 5 0.4452 0.7592 0.004 0.164 0.000 0.072 0.760
#> SRR975562 1 0.6101 0.1938 0.520 0.000 0.380 0.016 0.084
#> SRR975563 2 0.0000 0.9799 0.000 1.000 0.000 0.000 0.000
#> SRR975564 1 0.2520 0.6963 0.896 0.000 0.056 0.000 0.048
#> SRR975565 1 0.1410 0.7166 0.940 0.000 0.000 0.000 0.060
#> SRR975566 3 0.3845 0.4371 0.224 0.000 0.760 0.004 0.012
#> SRR975567 5 0.5656 0.4167 0.008 0.000 0.064 0.376 0.552
#> SRR975568 1 0.1410 0.7166 0.940 0.000 0.000 0.000 0.060
#> SRR975569 2 0.0000 0.9799 0.000 1.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.9799 0.000 1.000 0.000 0.000 0.000
#> SRR975571 2 0.0794 0.9578 0.000 0.972 0.000 0.000 0.028
#> SRR975572 2 0.0000 0.9799 0.000 1.000 0.000 0.000 0.000
#> SRR975573 2 0.0000 0.9799 0.000 1.000 0.000 0.000 0.000
#> SRR975574 2 0.3491 0.6515 0.004 0.768 0.000 0.000 0.228
#> SRR975575 2 0.0000 0.9799 0.000 1.000 0.000 0.000 0.000
#> SRR975576 2 0.0162 0.9777 0.000 0.996 0.000 0.000 0.004
#> SRR975577 2 0.0000 0.9799 0.000 1.000 0.000 0.000 0.000
#> SRR975578 2 0.0162 0.9777 0.000 0.996 0.000 0.000 0.004
#> SRR975579 4 0.2424 0.2698 0.000 0.000 0.000 0.868 0.132
#> SRR975580 5 0.4450 0.7841 0.004 0.080 0.000 0.152 0.764
#> SRR975581 2 0.0000 0.9799 0.000 1.000 0.000 0.000 0.000
#> SRR975582 2 0.0000 0.9799 0.000 1.000 0.000 0.000 0.000
#> SRR975583 2 0.0000 0.9799 0.000 1.000 0.000 0.000 0.000
#> SRR975584 2 0.0162 0.9774 0.000 0.996 0.000 0.000 0.004
#> SRR975585 2 0.0000 0.9799 0.000 1.000 0.000 0.000 0.000
#> SRR975586 5 0.4478 0.7815 0.004 0.144 0.000 0.088 0.764
#> SRR975587 3 0.7019 -0.1085 0.080 0.000 0.456 0.384 0.080
#> SRR975588 2 0.0000 0.9799 0.000 1.000 0.000 0.000 0.000
#> SRR975589 3 0.1478 0.4606 0.064 0.000 0.936 0.000 0.000
#> SRR975590 1 0.7104 0.1684 0.460 0.000 0.368 0.104 0.068
#> SRR975591 4 0.5146 0.3326 0.012 0.000 0.432 0.536 0.020
#> SRR975592 3 0.7810 0.0898 0.240 0.000 0.400 0.288 0.072
#> SRR975593 3 0.1478 0.4606 0.064 0.000 0.936 0.000 0.000
#> SRR975594 4 0.5968 0.3985 0.000 0.000 0.268 0.576 0.156
#> SRR975595 1 0.4985 0.6557 0.744 0.000 0.152 0.028 0.076
#> SRR975597 1 0.4985 0.6557 0.744 0.000 0.152 0.028 0.076
#> SRR975596 3 0.3652 0.4512 0.200 0.000 0.784 0.004 0.012
#> SRR975598 1 0.4985 0.6557 0.744 0.000 0.152 0.028 0.076
#> SRR975599 3 0.6361 -0.4363 0.004 0.000 0.428 0.428 0.140
#> SRR975600 3 0.4538 -0.1015 0.016 0.000 0.620 0.364 0.000
#> SRR975601 4 0.6109 0.3289 0.016 0.000 0.416 0.488 0.080
#> SRR975602 1 0.5631 0.5839 0.660 0.000 0.240 0.028 0.072
#> SRR975603 3 0.4747 -0.3408 0.016 0.000 0.500 0.484 0.000
#> SRR975604 4 0.5187 0.2660 0.016 0.000 0.484 0.484 0.016
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.1010 0.699 0.960 0.000 0.000 0.000 0.036 0.004
#> SRR975552 1 0.0692 0.709 0.976 0.000 0.000 0.000 0.020 0.004
#> SRR975554 5 0.4085 0.708 0.092 0.000 0.108 0.000 0.780 0.020
#> SRR975553 2 0.0790 0.957 0.000 0.968 0.000 0.000 0.000 0.032
#> SRR975555 1 0.0692 0.709 0.976 0.000 0.000 0.000 0.020 0.004
#> SRR975556 6 0.1863 0.724 0.000 0.104 0.000 0.000 0.000 0.896
#> SRR975557 4 0.4228 0.514 0.000 0.000 0.072 0.716 0.000 0.212
#> SRR975558 6 0.5812 0.352 0.004 0.000 0.072 0.164 0.116 0.644
#> SRR975559 5 0.1257 0.779 0.020 0.000 0.000 0.000 0.952 0.028
#> SRR975560 6 0.1575 0.707 0.000 0.032 0.000 0.032 0.000 0.936
#> SRR975561 6 0.2597 0.641 0.000 0.176 0.000 0.000 0.000 0.824
#> SRR975562 5 0.5458 0.566 0.216 0.000 0.124 0.004 0.636 0.020
#> SRR975563 2 0.0000 0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975564 1 0.4935 0.109 0.556 0.000 0.044 0.000 0.388 0.012
#> SRR975565 1 0.0692 0.709 0.976 0.000 0.000 0.000 0.020 0.004
#> SRR975566 5 0.1078 0.780 0.016 0.000 0.012 0.000 0.964 0.008
#> SRR975567 6 0.5812 0.352 0.004 0.000 0.072 0.164 0.116 0.644
#> SRR975568 1 0.0692 0.709 0.976 0.000 0.000 0.000 0.020 0.004
#> SRR975569 2 0.0000 0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975571 2 0.0790 0.957 0.000 0.968 0.000 0.000 0.000 0.032
#> SRR975572 2 0.0000 0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975573 2 0.0000 0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975574 2 0.2823 0.713 0.000 0.796 0.000 0.000 0.000 0.204
#> SRR975575 2 0.0000 0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975576 2 0.0146 0.978 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR975577 2 0.0000 0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975578 2 0.0260 0.975 0.000 0.992 0.000 0.000 0.000 0.008
#> SRR975579 4 0.5348 0.479 0.000 0.056 0.068 0.652 0.000 0.224
#> SRR975580 6 0.0790 0.714 0.000 0.032 0.000 0.000 0.000 0.968
#> SRR975581 2 0.0000 0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975582 2 0.0000 0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975583 2 0.0000 0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975584 2 0.0632 0.962 0.000 0.976 0.000 0.000 0.000 0.024
#> SRR975585 2 0.0000 0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975586 6 0.1863 0.724 0.000 0.104 0.000 0.000 0.000 0.896
#> SRR975587 3 0.3638 0.487 0.040 0.000 0.836 0.044 0.068 0.012
#> SRR975588 2 0.0000 0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975589 5 0.2994 0.623 0.004 0.000 0.208 0.000 0.788 0.000
#> SRR975590 3 0.5361 0.394 0.180 0.000 0.620 0.008 0.192 0.000
#> SRR975591 3 0.6218 0.456 0.000 0.000 0.592 0.168 0.144 0.096
#> SRR975592 3 0.4819 0.453 0.132 0.000 0.664 0.000 0.204 0.000
#> SRR975593 5 0.2883 0.619 0.000 0.000 0.212 0.000 0.788 0.000
#> SRR975594 4 0.4300 -0.152 0.000 0.000 0.444 0.540 0.008 0.008
#> SRR975595 1 0.5574 0.377 0.480 0.000 0.428 0.044 0.048 0.000
#> SRR975597 1 0.5519 0.380 0.484 0.000 0.428 0.040 0.048 0.000
#> SRR975596 5 0.1232 0.781 0.016 0.000 0.004 0.000 0.956 0.024
#> SRR975598 1 0.5578 0.368 0.472 0.000 0.436 0.044 0.048 0.000
#> SRR975599 3 0.3728 0.249 0.000 0.000 0.652 0.344 0.000 0.004
#> SRR975600 3 0.5447 0.472 0.000 0.000 0.580 0.076 0.316 0.028
#> SRR975601 3 0.4857 0.313 0.000 0.000 0.688 0.200 0.016 0.096
#> SRR975602 3 0.5491 -0.327 0.400 0.000 0.512 0.048 0.040 0.000
#> SRR975603 3 0.6161 0.482 0.000 0.000 0.576 0.112 0.232 0.080
#> SRR975604 3 0.6168 0.457 0.000 0.000 0.600 0.160 0.140 0.100
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 17171 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 4.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.993 0.996 0.5043 0.497 0.497
#> 3 3 1.000 0.968 0.987 0.2443 0.867 0.734
#> 4 4 0.944 0.907 0.955 0.0548 0.956 0.884
#> 5 5 0.824 0.759 0.838 0.0935 0.898 0.714
#> 6 6 0.757 0.719 0.833 0.0724 0.928 0.743
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3
There is also optional best \(k\) = 2 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR975551 1 0.000 0.993 1.000 0.000
#> SRR975552 1 0.000 0.993 1.000 0.000
#> SRR975554 1 0.000 0.993 1.000 0.000
#> SRR975553 2 0.000 1.000 0.000 1.000
#> SRR975555 1 0.000 0.993 1.000 0.000
#> SRR975556 2 0.000 1.000 0.000 1.000
#> SRR975557 1 0.184 0.969 0.972 0.028
#> SRR975558 1 0.552 0.857 0.872 0.128
#> SRR975559 1 0.000 0.993 1.000 0.000
#> SRR975560 2 0.000 1.000 0.000 1.000
#> SRR975561 2 0.000 1.000 0.000 1.000
#> SRR975562 1 0.000 0.993 1.000 0.000
#> SRR975563 2 0.000 1.000 0.000 1.000
#> SRR975564 1 0.000 0.993 1.000 0.000
#> SRR975565 1 0.000 0.993 1.000 0.000
#> SRR975566 1 0.000 0.993 1.000 0.000
#> SRR975567 1 0.242 0.957 0.960 0.040
#> SRR975568 1 0.000 0.993 1.000 0.000
#> SRR975569 2 0.000 1.000 0.000 1.000
#> SRR975570 2 0.000 1.000 0.000 1.000
#> SRR975571 2 0.000 1.000 0.000 1.000
#> SRR975572 2 0.000 1.000 0.000 1.000
#> SRR975573 2 0.000 1.000 0.000 1.000
#> SRR975574 2 0.000 1.000 0.000 1.000
#> SRR975575 2 0.000 1.000 0.000 1.000
#> SRR975576 2 0.000 1.000 0.000 1.000
#> SRR975577 2 0.000 1.000 0.000 1.000
#> SRR975578 2 0.000 1.000 0.000 1.000
#> SRR975579 2 0.000 1.000 0.000 1.000
#> SRR975580 2 0.000 1.000 0.000 1.000
#> SRR975581 2 0.000 1.000 0.000 1.000
#> SRR975582 2 0.000 1.000 0.000 1.000
#> SRR975583 2 0.000 1.000 0.000 1.000
#> SRR975584 2 0.000 1.000 0.000 1.000
#> SRR975585 2 0.000 1.000 0.000 1.000
#> SRR975586 2 0.000 1.000 0.000 1.000
#> SRR975587 1 0.000 0.993 1.000 0.000
#> SRR975588 2 0.000 1.000 0.000 1.000
#> SRR975589 1 0.000 0.993 1.000 0.000
#> SRR975590 1 0.000 0.993 1.000 0.000
#> SRR975591 1 0.000 0.993 1.000 0.000
#> SRR975592 1 0.000 0.993 1.000 0.000
#> SRR975593 1 0.000 0.993 1.000 0.000
#> SRR975594 1 0.000 0.993 1.000 0.000
#> SRR975595 1 0.000 0.993 1.000 0.000
#> SRR975597 1 0.000 0.993 1.000 0.000
#> SRR975596 1 0.000 0.993 1.000 0.000
#> SRR975598 1 0.000 0.993 1.000 0.000
#> SRR975599 1 0.000 0.993 1.000 0.000
#> SRR975600 1 0.000 0.993 1.000 0.000
#> SRR975601 1 0.000 0.993 1.000 0.000
#> SRR975602 1 0.000 0.993 1.000 0.000
#> SRR975603 1 0.000 0.993 1.000 0.000
#> SRR975604 1 0.000 0.993 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975552 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975554 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975553 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975555 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975556 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975557 3 0.0000 0.955 0.000 0.000 1.000
#> SRR975558 1 0.2165 0.904 0.936 0.064 0.000
#> SRR975559 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975560 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975561 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975562 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975563 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975564 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975565 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975566 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975567 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975568 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975569 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975570 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975571 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975572 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975573 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975574 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975575 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975576 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975577 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975578 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975579 3 0.4504 0.751 0.000 0.196 0.804
#> SRR975580 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975581 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975582 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975583 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975584 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975585 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975586 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975587 1 0.5905 0.454 0.648 0.000 0.352
#> SRR975588 2 0.0000 1.000 0.000 1.000 0.000
#> SRR975589 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975590 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975591 3 0.0000 0.955 0.000 0.000 1.000
#> SRR975592 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975593 1 0.0424 0.973 0.992 0.000 0.008
#> SRR975594 3 0.0000 0.955 0.000 0.000 1.000
#> SRR975595 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975597 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975596 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975598 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975599 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975600 3 0.2356 0.903 0.072 0.000 0.928
#> SRR975601 3 0.1289 0.938 0.032 0.000 0.968
#> SRR975602 1 0.0000 0.980 1.000 0.000 0.000
#> SRR975603 3 0.0000 0.955 0.000 0.000 1.000
#> SRR975604 3 0.0000 0.955 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0817 0.936 0.976 0.000 0.000 0.024
#> SRR975552 1 0.0000 0.938 1.000 0.000 0.000 0.000
#> SRR975554 1 0.0336 0.937 0.992 0.000 0.000 0.008
#> SRR975553 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975555 1 0.0336 0.938 0.992 0.000 0.000 0.008
#> SRR975556 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975557 4 0.2469 0.556 0.000 0.000 0.108 0.892
#> SRR975558 4 0.7150 0.183 0.384 0.136 0.000 0.480
#> SRR975559 1 0.2973 0.839 0.856 0.000 0.000 0.144
#> SRR975560 2 0.1890 0.927 0.008 0.936 0.000 0.056
#> SRR975561 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975562 1 0.1637 0.914 0.940 0.000 0.000 0.060
#> SRR975563 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975564 1 0.0707 0.937 0.980 0.000 0.000 0.020
#> SRR975565 1 0.0188 0.938 0.996 0.000 0.000 0.004
#> SRR975566 1 0.0469 0.937 0.988 0.000 0.000 0.012
#> SRR975567 1 0.5300 0.483 0.664 0.028 0.000 0.308
#> SRR975568 1 0.0921 0.933 0.972 0.000 0.000 0.028
#> SRR975569 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975572 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975574 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975575 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975578 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975579 4 0.3435 0.569 0.000 0.036 0.100 0.864
#> SRR975580 2 0.1211 0.954 0.000 0.960 0.000 0.040
#> SRR975581 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975582 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975583 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975585 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975586 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975587 3 0.2546 0.858 0.060 0.000 0.912 0.028
#> SRR975588 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> SRR975589 1 0.0804 0.937 0.980 0.000 0.008 0.012
#> SRR975590 1 0.1545 0.928 0.952 0.000 0.008 0.040
#> SRR975591 3 0.0188 0.910 0.000 0.000 0.996 0.004
#> SRR975592 1 0.1488 0.925 0.956 0.000 0.032 0.012
#> SRR975593 1 0.1888 0.919 0.940 0.000 0.044 0.016
#> SRR975594 3 0.0188 0.910 0.000 0.000 0.996 0.004
#> SRR975595 1 0.1398 0.933 0.956 0.000 0.004 0.040
#> SRR975597 1 0.0895 0.934 0.976 0.000 0.004 0.020
#> SRR975596 1 0.3311 0.803 0.828 0.000 0.000 0.172
#> SRR975598 1 0.1661 0.929 0.944 0.000 0.004 0.052
#> SRR975599 1 0.2053 0.916 0.924 0.000 0.004 0.072
#> SRR975600 3 0.4182 0.631 0.180 0.000 0.796 0.024
#> SRR975601 3 0.1510 0.895 0.028 0.000 0.956 0.016
#> SRR975602 1 0.0707 0.938 0.980 0.000 0.000 0.020
#> SRR975603 3 0.0000 0.911 0.000 0.000 1.000 0.000
#> SRR975604 3 0.0000 0.911 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.1908 0.629 0.908 0.000 0.000 0.000 0.092
#> SRR975552 1 0.1270 0.671 0.948 0.000 0.000 0.000 0.052
#> SRR975554 1 0.1544 0.694 0.932 0.000 0.000 0.000 0.068
#> SRR975553 2 0.0703 0.957 0.000 0.976 0.000 0.000 0.024
#> SRR975555 1 0.2648 0.620 0.848 0.000 0.000 0.000 0.152
#> SRR975556 2 0.1608 0.922 0.000 0.928 0.000 0.000 0.072
#> SRR975557 4 0.0000 0.733 0.000 0.000 0.000 1.000 0.000
#> SRR975558 4 0.6603 0.669 0.108 0.108 0.000 0.628 0.156
#> SRR975559 1 0.6275 -0.185 0.480 0.000 0.000 0.364 0.156
#> SRR975560 5 0.4974 -0.154 0.028 0.464 0.000 0.000 0.508
#> SRR975561 2 0.0880 0.951 0.000 0.968 0.000 0.000 0.032
#> SRR975562 5 0.4300 0.689 0.476 0.000 0.000 0.000 0.524
#> SRR975563 2 0.0794 0.953 0.000 0.972 0.000 0.000 0.028
#> SRR975564 1 0.3895 0.557 0.680 0.000 0.000 0.000 0.320
#> SRR975565 1 0.0880 0.688 0.968 0.000 0.000 0.000 0.032
#> SRR975566 1 0.2124 0.693 0.916 0.000 0.000 0.028 0.056
#> SRR975567 4 0.5654 0.513 0.288 0.080 0.000 0.620 0.012
#> SRR975568 1 0.3796 0.579 0.700 0.000 0.000 0.000 0.300
#> SRR975569 2 0.0290 0.960 0.000 0.992 0.000 0.000 0.008
#> SRR975570 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000
#> SRR975571 2 0.0703 0.957 0.000 0.976 0.000 0.000 0.024
#> SRR975572 2 0.0162 0.960 0.000 0.996 0.000 0.000 0.004
#> SRR975573 2 0.0703 0.957 0.000 0.976 0.000 0.000 0.024
#> SRR975574 2 0.0703 0.957 0.000 0.976 0.000 0.000 0.024
#> SRR975575 2 0.0162 0.960 0.000 0.996 0.000 0.000 0.004
#> SRR975576 2 0.0703 0.954 0.000 0.976 0.000 0.000 0.024
#> SRR975577 2 0.0609 0.958 0.000 0.980 0.000 0.000 0.020
#> SRR975578 2 0.0880 0.957 0.000 0.968 0.000 0.000 0.032
#> SRR975579 4 0.0451 0.736 0.000 0.004 0.000 0.988 0.008
#> SRR975580 2 0.4161 0.417 0.000 0.608 0.000 0.000 0.392
#> SRR975581 2 0.0510 0.957 0.000 0.984 0.000 0.000 0.016
#> SRR975582 2 0.0609 0.958 0.000 0.980 0.000 0.000 0.020
#> SRR975583 2 0.0162 0.960 0.000 0.996 0.000 0.000 0.004
#> SRR975584 2 0.0794 0.956 0.000 0.972 0.000 0.000 0.028
#> SRR975585 2 0.0290 0.959 0.000 0.992 0.000 0.000 0.008
#> SRR975586 2 0.1671 0.920 0.000 0.924 0.000 0.000 0.076
#> SRR975587 3 0.0609 0.966 0.020 0.000 0.980 0.000 0.000
#> SRR975588 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000
#> SRR975589 1 0.3452 0.610 0.756 0.000 0.000 0.000 0.244
#> SRR975590 1 0.1768 0.693 0.924 0.000 0.004 0.000 0.072
#> SRR975591 3 0.0000 0.981 0.000 0.000 1.000 0.000 0.000
#> SRR975592 1 0.2378 0.687 0.904 0.000 0.048 0.000 0.048
#> SRR975593 1 0.3386 0.588 0.832 0.000 0.000 0.040 0.128
#> SRR975594 3 0.0000 0.981 0.000 0.000 1.000 0.000 0.000
#> SRR975595 5 0.4306 0.672 0.492 0.000 0.000 0.000 0.508
#> SRR975597 1 0.2813 0.512 0.832 0.000 0.000 0.000 0.168
#> SRR975596 5 0.4902 0.677 0.468 0.000 0.000 0.024 0.508
#> SRR975598 5 0.4297 0.690 0.472 0.000 0.000 0.000 0.528
#> SRR975599 5 0.4300 0.690 0.476 0.000 0.000 0.000 0.524
#> SRR975600 1 0.6433 0.264 0.488 0.000 0.200 0.000 0.312
#> SRR975601 3 0.0000 0.981 0.000 0.000 1.000 0.000 0.000
#> SRR975602 1 0.2813 0.510 0.832 0.000 0.000 0.000 0.168
#> SRR975603 3 0.1469 0.932 0.036 0.000 0.948 0.000 0.016
#> SRR975604 3 0.0000 0.981 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.0692 0.7325 0.976 0.000 0.000 0.000 0.004 0.020
#> SRR975552 1 0.1713 0.7179 0.928 0.000 0.000 0.000 0.028 0.044
#> SRR975554 1 0.3707 0.4258 0.680 0.000 0.000 0.000 0.312 0.008
#> SRR975553 2 0.1418 0.9147 0.000 0.944 0.000 0.000 0.024 0.032
#> SRR975555 1 0.6077 -0.0898 0.400 0.000 0.000 0.000 0.304 0.296
#> SRR975556 2 0.4853 0.6985 0.012 0.692 0.000 0.000 0.124 0.172
#> SRR975557 4 0.0000 0.7665 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR975558 5 0.4849 0.4916 0.000 0.016 0.000 0.156 0.700 0.128
#> SRR975559 4 0.4955 0.3630 0.296 0.000 0.000 0.608 0.000 0.096
#> SRR975560 6 0.4105 0.4629 0.008 0.196 0.000 0.012 0.032 0.752
#> SRR975561 2 0.2882 0.8641 0.000 0.860 0.000 0.004 0.060 0.076
#> SRR975562 6 0.3617 0.7066 0.244 0.000 0.000 0.000 0.020 0.736
#> SRR975563 2 0.3458 0.8225 0.000 0.808 0.000 0.000 0.080 0.112
#> SRR975564 5 0.3253 0.7560 0.192 0.000 0.000 0.000 0.788 0.020
#> SRR975565 1 0.2066 0.7125 0.904 0.000 0.000 0.000 0.072 0.024
#> SRR975566 1 0.2848 0.6587 0.828 0.000 0.000 0.004 0.160 0.008
#> SRR975567 4 0.4226 0.6790 0.036 0.088 0.000 0.796 0.064 0.016
#> SRR975568 5 0.3259 0.7448 0.216 0.000 0.000 0.000 0.772 0.012
#> SRR975569 2 0.0146 0.9210 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR975570 2 0.1074 0.9173 0.000 0.960 0.000 0.000 0.028 0.012
#> SRR975571 2 0.1418 0.9147 0.000 0.944 0.000 0.000 0.024 0.032
#> SRR975572 2 0.0405 0.9211 0.000 0.988 0.000 0.000 0.004 0.008
#> SRR975573 2 0.1341 0.9158 0.000 0.948 0.000 0.000 0.024 0.028
#> SRR975574 2 0.1341 0.9158 0.000 0.948 0.000 0.000 0.024 0.028
#> SRR975575 2 0.0508 0.9208 0.000 0.984 0.000 0.000 0.004 0.012
#> SRR975576 2 0.1720 0.9035 0.000 0.928 0.000 0.000 0.040 0.032
#> SRR975577 2 0.1341 0.9158 0.000 0.948 0.000 0.000 0.024 0.028
#> SRR975578 2 0.1418 0.9160 0.000 0.944 0.000 0.000 0.024 0.032
#> SRR975579 4 0.0000 0.7665 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR975580 6 0.4004 0.3797 0.012 0.328 0.000 0.000 0.004 0.656
#> SRR975581 2 0.1245 0.9153 0.000 0.952 0.000 0.000 0.016 0.032
#> SRR975582 2 0.1341 0.9158 0.000 0.948 0.000 0.000 0.024 0.028
#> SRR975583 2 0.0914 0.9193 0.000 0.968 0.000 0.000 0.016 0.016
#> SRR975584 2 0.1492 0.9131 0.000 0.940 0.000 0.000 0.024 0.036
#> SRR975585 2 0.0622 0.9205 0.000 0.980 0.000 0.000 0.012 0.008
#> SRR975586 2 0.4865 0.6740 0.004 0.672 0.000 0.000 0.128 0.196
#> SRR975587 3 0.3409 0.5723 0.300 0.000 0.700 0.000 0.000 0.000
#> SRR975588 2 0.1245 0.9157 0.000 0.952 0.000 0.000 0.032 0.016
#> SRR975589 5 0.3320 0.7494 0.212 0.000 0.000 0.000 0.772 0.016
#> SRR975590 1 0.1151 0.7366 0.956 0.000 0.012 0.000 0.032 0.000
#> SRR975591 3 0.1267 0.8292 0.000 0.000 0.940 0.000 0.060 0.000
#> SRR975592 1 0.4993 0.1568 0.572 0.000 0.084 0.000 0.344 0.000
#> SRR975593 5 0.6235 0.1480 0.364 0.000 0.000 0.016 0.424 0.196
#> SRR975594 3 0.0000 0.8430 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975595 6 0.3866 0.3584 0.484 0.000 0.000 0.000 0.000 0.516
#> SRR975597 1 0.1584 0.7120 0.928 0.000 0.000 0.000 0.008 0.064
#> SRR975596 6 0.4568 0.6950 0.232 0.000 0.000 0.036 0.032 0.700
#> SRR975598 6 0.3729 0.6763 0.296 0.000 0.000 0.000 0.012 0.692
#> SRR975599 6 0.3582 0.7057 0.252 0.000 0.000 0.000 0.016 0.732
#> SRR975600 5 0.3551 0.7238 0.148 0.000 0.060 0.000 0.792 0.000
#> SRR975601 3 0.0000 0.8430 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975602 1 0.1524 0.7190 0.932 0.000 0.000 0.000 0.008 0.060
#> SRR975603 3 0.3198 0.6132 0.000 0.000 0.740 0.000 0.260 0.000
#> SRR975604 3 0.0405 0.8410 0.000 0.000 0.988 0.000 0.008 0.004
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 17171 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 1.000 1.000 1.000 0.5099 0.491 0.491
#> 3 3 1.000 0.987 0.994 0.0780 0.965 0.929
#> 4 4 0.821 0.761 0.857 0.1529 0.874 0.724
#> 5 5 0.846 0.893 0.951 0.0785 0.904 0.741
#> 6 6 0.746 0.752 0.871 0.0759 0.947 0.833
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR975551 1 0 1 1 0
#> SRR975552 1 0 1 1 0
#> SRR975554 1 0 1 1 0
#> SRR975553 2 0 1 0 1
#> SRR975555 1 0 1 1 0
#> SRR975556 2 0 1 0 1
#> SRR975557 2 0 1 0 1
#> SRR975558 1 0 1 1 0
#> SRR975559 1 0 1 1 0
#> SRR975560 2 0 1 0 1
#> SRR975561 2 0 1 0 1
#> SRR975562 1 0 1 1 0
#> SRR975563 2 0 1 0 1
#> SRR975564 1 0 1 1 0
#> SRR975565 1 0 1 1 0
#> SRR975566 1 0 1 1 0
#> SRR975567 1 0 1 1 0
#> SRR975568 1 0 1 1 0
#> SRR975569 2 0 1 0 1
#> SRR975570 2 0 1 0 1
#> SRR975571 2 0 1 0 1
#> SRR975572 2 0 1 0 1
#> SRR975573 2 0 1 0 1
#> SRR975574 2 0 1 0 1
#> SRR975575 2 0 1 0 1
#> SRR975576 2 0 1 0 1
#> SRR975577 2 0 1 0 1
#> SRR975578 2 0 1 0 1
#> SRR975579 2 0 1 0 1
#> SRR975580 2 0 1 0 1
#> SRR975581 2 0 1 0 1
#> SRR975582 2 0 1 0 1
#> SRR975583 2 0 1 0 1
#> SRR975584 2 0 1 0 1
#> SRR975585 2 0 1 0 1
#> SRR975586 2 0 1 0 1
#> SRR975587 1 0 1 1 0
#> SRR975588 2 0 1 0 1
#> SRR975589 1 0 1 1 0
#> SRR975590 1 0 1 1 0
#> SRR975591 1 0 1 1 0
#> SRR975592 1 0 1 1 0
#> SRR975593 1 0 1 1 0
#> SRR975594 2 0 1 0 1
#> SRR975595 1 0 1 1 0
#> SRR975597 1 0 1 1 0
#> SRR975596 1 0 1 1 0
#> SRR975598 1 0 1 1 0
#> SRR975599 2 0 1 0 1
#> SRR975600 1 0 1 1 0
#> SRR975601 1 0 1 1 0
#> SRR975602 1 0 1 1 0
#> SRR975603 1 0 1 1 0
#> SRR975604 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.000 1.000 1 0.000 0.000
#> SRR975552 1 0.000 1.000 1 0.000 0.000
#> SRR975554 1 0.000 1.000 1 0.000 0.000
#> SRR975553 2 0.000 0.986 0 1.000 0.000
#> SRR975555 1 0.000 1.000 1 0.000 0.000
#> SRR975556 2 0.000 0.986 0 1.000 0.000
#> SRR975557 2 0.510 0.679 0 0.752 0.248
#> SRR975558 1 0.000 1.000 1 0.000 0.000
#> SRR975559 1 0.000 1.000 1 0.000 0.000
#> SRR975560 2 0.000 0.986 0 1.000 0.000
#> SRR975561 2 0.000 0.986 0 1.000 0.000
#> SRR975562 1 0.000 1.000 1 0.000 0.000
#> SRR975563 2 0.000 0.986 0 1.000 0.000
#> SRR975564 1 0.000 1.000 1 0.000 0.000
#> SRR975565 1 0.000 1.000 1 0.000 0.000
#> SRR975566 1 0.000 1.000 1 0.000 0.000
#> SRR975567 1 0.000 1.000 1 0.000 0.000
#> SRR975568 1 0.000 1.000 1 0.000 0.000
#> SRR975569 2 0.000 0.986 0 1.000 0.000
#> SRR975570 2 0.000 0.986 0 1.000 0.000
#> SRR975571 2 0.000 0.986 0 1.000 0.000
#> SRR975572 2 0.000 0.986 0 1.000 0.000
#> SRR975573 2 0.000 0.986 0 1.000 0.000
#> SRR975574 2 0.000 0.986 0 1.000 0.000
#> SRR975575 2 0.000 0.986 0 1.000 0.000
#> SRR975576 2 0.000 0.986 0 1.000 0.000
#> SRR975577 2 0.000 0.986 0 1.000 0.000
#> SRR975578 2 0.000 0.986 0 1.000 0.000
#> SRR975579 2 0.245 0.912 0 0.924 0.076
#> SRR975580 2 0.000 0.986 0 1.000 0.000
#> SRR975581 2 0.000 0.986 0 1.000 0.000
#> SRR975582 2 0.000 0.986 0 1.000 0.000
#> SRR975583 2 0.000 0.986 0 1.000 0.000
#> SRR975584 2 0.000 0.986 0 1.000 0.000
#> SRR975585 2 0.000 0.986 0 1.000 0.000
#> SRR975586 2 0.000 0.986 0 1.000 0.000
#> SRR975587 1 0.000 1.000 1 0.000 0.000
#> SRR975588 2 0.000 0.986 0 1.000 0.000
#> SRR975589 1 0.000 1.000 1 0.000 0.000
#> SRR975590 1 0.000 1.000 1 0.000 0.000
#> SRR975591 1 0.000 1.000 1 0.000 0.000
#> SRR975592 1 0.000 1.000 1 0.000 0.000
#> SRR975593 1 0.000 1.000 1 0.000 0.000
#> SRR975594 3 0.000 1.000 0 0.000 1.000
#> SRR975595 1 0.000 1.000 1 0.000 0.000
#> SRR975597 1 0.000 1.000 1 0.000 0.000
#> SRR975596 1 0.000 1.000 1 0.000 0.000
#> SRR975598 1 0.000 1.000 1 0.000 0.000
#> SRR975599 3 0.000 1.000 0 0.000 1.000
#> SRR975600 1 0.000 1.000 1 0.000 0.000
#> SRR975601 1 0.000 1.000 1 0.000 0.000
#> SRR975602 1 0.000 1.000 1 0.000 0.000
#> SRR975603 1 0.000 1.000 1 0.000 0.000
#> SRR975604 1 0.000 1.000 1 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.464 0.944 0.656 0.000 0.344 0.000
#> SRR975552 1 0.464 0.944 0.656 0.000 0.344 0.000
#> SRR975554 1 0.464 0.944 0.656 0.000 0.344 0.000
#> SRR975553 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975555 3 0.499 -0.539 0.476 0.000 0.524 0.000
#> SRR975556 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975557 2 0.778 -0.133 0.344 0.408 0.000 0.248
#> SRR975558 3 0.000 0.693 0.000 0.000 1.000 0.000
#> SRR975559 1 0.476 0.911 0.628 0.000 0.372 0.000
#> SRR975560 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975561 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975562 3 0.130 0.668 0.044 0.000 0.956 0.000
#> SRR975563 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975564 3 0.498 -0.502 0.464 0.000 0.536 0.000
#> SRR975565 1 0.464 0.944 0.656 0.000 0.344 0.000
#> SRR975566 1 0.464 0.944 0.656 0.000 0.344 0.000
#> SRR975567 3 0.000 0.693 0.000 0.000 1.000 0.000
#> SRR975568 3 0.499 -0.515 0.468 0.000 0.532 0.000
#> SRR975569 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975570 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975571 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975572 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975573 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975574 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975575 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975576 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975577 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975578 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975579 2 0.634 0.371 0.344 0.580 0.000 0.076
#> SRR975580 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975581 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975582 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975583 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975584 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975585 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975586 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975587 1 0.464 0.944 0.656 0.000 0.344 0.000
#> SRR975588 2 0.000 0.958 0.000 1.000 0.000 0.000
#> SRR975589 1 0.500 0.596 0.508 0.000 0.492 0.000
#> SRR975590 1 0.464 0.944 0.656 0.000 0.344 0.000
#> SRR975591 3 0.000 0.693 0.000 0.000 1.000 0.000
#> SRR975592 1 0.464 0.944 0.656 0.000 0.344 0.000
#> SRR975593 1 0.500 0.596 0.508 0.000 0.492 0.000
#> SRR975594 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR975595 1 0.476 0.911 0.628 0.000 0.372 0.000
#> SRR975597 1 0.464 0.944 0.656 0.000 0.344 0.000
#> SRR975596 3 0.130 0.668 0.044 0.000 0.956 0.000
#> SRR975598 1 0.468 0.934 0.648 0.000 0.352 0.000
#> SRR975599 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR975600 3 0.498 -0.502 0.464 0.000 0.536 0.000
#> SRR975601 3 0.000 0.693 0.000 0.000 1.000 0.000
#> SRR975602 1 0.464 0.944 0.656 0.000 0.344 0.000
#> SRR975603 3 0.000 0.693 0.000 0.000 1.000 0.000
#> SRR975604 3 0.000 0.693 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.000 0.874 1.000 0.00 0.000 0.00 0
#> SRR975552 1 0.000 0.874 1.000 0.00 0.000 0.00 0
#> SRR975554 1 0.000 0.874 1.000 0.00 0.000 0.00 0
#> SRR975553 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975555 1 0.377 0.680 0.704 0.00 0.296 0.00 0
#> SRR975556 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975557 4 0.000 0.530 0.000 0.00 0.000 1.00 0
#> SRR975558 3 0.000 0.892 0.000 0.00 1.000 0.00 0
#> SRR975559 1 0.265 0.806 0.848 0.00 0.152 0.00 0
#> SRR975560 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975561 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975562 3 0.337 0.672 0.232 0.00 0.768 0.00 0
#> SRR975563 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975564 1 0.386 0.660 0.688 0.00 0.312 0.00 0
#> SRR975565 1 0.000 0.874 1.000 0.00 0.000 0.00 0
#> SRR975566 1 0.000 0.874 1.000 0.00 0.000 0.00 0
#> SRR975567 3 0.000 0.892 0.000 0.00 1.000 0.00 0
#> SRR975568 1 0.384 0.666 0.692 0.00 0.308 0.00 0
#> SRR975569 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975570 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975571 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975572 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975573 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975574 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975575 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975576 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975577 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975578 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975579 4 0.293 0.572 0.000 0.18 0.000 0.82 0
#> SRR975580 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975581 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975582 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975583 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975584 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975585 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975586 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975587 1 0.000 0.874 1.000 0.00 0.000 0.00 0
#> SRR975588 2 0.000 1.000 0.000 1.00 0.000 0.00 0
#> SRR975589 1 0.307 0.775 0.804 0.00 0.196 0.00 0
#> SRR975590 1 0.000 0.874 1.000 0.00 0.000 0.00 0
#> SRR975591 3 0.000 0.892 0.000 0.00 1.000 0.00 0
#> SRR975592 1 0.000 0.874 1.000 0.00 0.000 0.00 0
#> SRR975593 1 0.307 0.775 0.804 0.00 0.196 0.00 0
#> SRR975594 5 0.000 1.000 0.000 0.00 0.000 0.00 1
#> SRR975595 1 0.265 0.806 0.848 0.00 0.152 0.00 0
#> SRR975597 1 0.000 0.874 1.000 0.00 0.000 0.00 0
#> SRR975596 3 0.337 0.672 0.232 0.00 0.768 0.00 0
#> SRR975598 1 0.154 0.851 0.932 0.00 0.068 0.00 0
#> SRR975599 5 0.000 1.000 0.000 0.00 0.000 0.00 1
#> SRR975600 1 0.386 0.660 0.688 0.00 0.312 0.00 0
#> SRR975601 3 0.000 0.892 0.000 0.00 1.000 0.00 0
#> SRR975602 1 0.000 0.874 1.000 0.00 0.000 0.00 0
#> SRR975603 3 0.000 0.892 0.000 0.00 1.000 0.00 0
#> SRR975604 3 0.000 0.892 0.000 0.00 1.000 0.00 0
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.2048 0.789 0.880 0.000 0.000 0.00 0 0.120
#> SRR975552 1 0.2048 0.789 0.880 0.000 0.000 0.00 0 0.120
#> SRR975554 1 0.2048 0.789 0.880 0.000 0.000 0.00 0 0.120
#> SRR975553 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975555 1 0.4281 0.668 0.704 0.000 0.228 0.00 0 0.068
#> SRR975556 6 0.3851 0.991 0.000 0.460 0.000 0.00 0 0.540
#> SRR975557 4 0.0000 0.530 0.000 0.000 0.000 1.00 0 0.000
#> SRR975558 3 0.3244 0.706 0.000 0.000 0.732 0.00 0 0.268
#> SRR975559 1 0.3626 0.736 0.788 0.000 0.144 0.00 0 0.068
#> SRR975560 6 0.3847 0.997 0.000 0.456 0.000 0.00 0 0.544
#> SRR975561 2 0.3620 -0.390 0.000 0.648 0.000 0.00 0 0.352
#> SRR975562 3 0.3874 0.685 0.172 0.000 0.760 0.00 0 0.068
#> SRR975563 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975564 1 0.4377 0.650 0.688 0.000 0.244 0.00 0 0.068
#> SRR975565 1 0.2048 0.789 0.880 0.000 0.000 0.00 0 0.120
#> SRR975566 1 0.0865 0.820 0.964 0.000 0.000 0.00 0 0.036
#> SRR975567 3 0.3244 0.706 0.000 0.000 0.732 0.00 0 0.268
#> SRR975568 1 0.4354 0.655 0.692 0.000 0.240 0.00 0 0.068
#> SRR975569 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975570 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975571 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975572 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975573 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975574 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975575 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975576 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975577 2 0.3620 -0.390 0.000 0.648 0.000 0.00 0 0.352
#> SRR975578 2 0.3620 -0.390 0.000 0.648 0.000 0.00 0 0.352
#> SRR975579 4 0.2631 0.572 0.000 0.180 0.000 0.82 0 0.000
#> SRR975580 6 0.3847 0.997 0.000 0.456 0.000 0.00 0 0.544
#> SRR975581 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975582 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975583 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975584 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975585 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975586 6 0.3847 0.997 0.000 0.456 0.000 0.00 0 0.544
#> SRR975587 1 0.0000 0.823 1.000 0.000 0.000 0.00 0 0.000
#> SRR975588 2 0.0000 0.885 0.000 1.000 0.000 0.00 0 0.000
#> SRR975589 1 0.3283 0.748 0.804 0.000 0.160 0.00 0 0.036
#> SRR975590 1 0.2048 0.789 0.880 0.000 0.000 0.00 0 0.120
#> SRR975591 3 0.0000 0.829 0.000 0.000 1.000 0.00 0 0.000
#> SRR975592 1 0.0000 0.823 1.000 0.000 0.000 0.00 0 0.000
#> SRR975593 1 0.3283 0.748 0.804 0.000 0.160 0.00 0 0.036
#> SRR975594 5 0.0000 1.000 0.000 0.000 0.000 0.00 1 0.000
#> SRR975595 1 0.3626 0.736 0.788 0.000 0.144 0.00 0 0.068
#> SRR975597 1 0.0363 0.822 0.988 0.000 0.000 0.00 0 0.012
#> SRR975596 3 0.3874 0.685 0.172 0.000 0.760 0.00 0 0.068
#> SRR975598 1 0.2629 0.796 0.872 0.000 0.060 0.00 0 0.068
#> SRR975599 5 0.0000 1.000 0.000 0.000 0.000 0.00 1 0.000
#> SRR975600 1 0.4377 0.650 0.688 0.000 0.244 0.00 0 0.068
#> SRR975601 3 0.0000 0.829 0.000 0.000 1.000 0.00 0 0.000
#> SRR975602 1 0.0865 0.820 0.964 0.000 0.000 0.00 0 0.036
#> SRR975603 3 0.0000 0.829 0.000 0.000 1.000 0.00 0 0.000
#> SRR975604 3 0.0000 0.829 0.000 0.000 1.000 0.00 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", "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 17171 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 1.000 1.000 1.000 0.5099 0.491 0.491
#> 3 3 0.904 0.932 0.968 0.1661 0.929 0.857
#> 4 4 0.815 0.846 0.892 0.1281 0.874 0.707
#> 5 5 0.689 0.747 0.834 0.0824 0.954 0.854
#> 6 6 0.731 0.710 0.813 0.0506 0.979 0.924
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR975551 1 0 1 1 0
#> SRR975552 1 0 1 1 0
#> SRR975554 1 0 1 1 0
#> SRR975553 2 0 1 0 1
#> SRR975555 1 0 1 1 0
#> SRR975556 2 0 1 0 1
#> SRR975557 2 0 1 0 1
#> SRR975558 1 0 1 1 0
#> SRR975559 1 0 1 1 0
#> SRR975560 2 0 1 0 1
#> SRR975561 2 0 1 0 1
#> SRR975562 1 0 1 1 0
#> SRR975563 2 0 1 0 1
#> SRR975564 1 0 1 1 0
#> SRR975565 1 0 1 1 0
#> SRR975566 1 0 1 1 0
#> SRR975567 1 0 1 1 0
#> SRR975568 1 0 1 1 0
#> SRR975569 2 0 1 0 1
#> SRR975570 2 0 1 0 1
#> SRR975571 2 0 1 0 1
#> SRR975572 2 0 1 0 1
#> SRR975573 2 0 1 0 1
#> SRR975574 2 0 1 0 1
#> SRR975575 2 0 1 0 1
#> SRR975576 2 0 1 0 1
#> SRR975577 2 0 1 0 1
#> SRR975578 2 0 1 0 1
#> SRR975579 2 0 1 0 1
#> SRR975580 2 0 1 0 1
#> SRR975581 2 0 1 0 1
#> SRR975582 2 0 1 0 1
#> SRR975583 2 0 1 0 1
#> SRR975584 2 0 1 0 1
#> SRR975585 2 0 1 0 1
#> SRR975586 2 0 1 0 1
#> SRR975587 1 0 1 1 0
#> SRR975588 2 0 1 0 1
#> SRR975589 1 0 1 1 0
#> SRR975590 1 0 1 1 0
#> SRR975591 1 0 1 1 0
#> SRR975592 1 0 1 1 0
#> SRR975593 1 0 1 1 0
#> SRR975594 2 0 1 0 1
#> SRR975595 1 0 1 1 0
#> SRR975597 1 0 1 1 0
#> SRR975596 1 0 1 1 0
#> SRR975598 1 0 1 1 0
#> SRR975599 2 0 1 0 1
#> SRR975600 1 0 1 1 0
#> SRR975601 1 0 1 1 0
#> SRR975602 1 0 1 1 0
#> SRR975603 1 0 1 1 0
#> SRR975604 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975552 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975554 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975553 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975555 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975556 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975557 3 0.0424 0.959 0.000 0.008 0.992
#> SRR975558 1 0.4002 0.819 0.840 0.000 0.160
#> SRR975559 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975560 2 0.3551 0.863 0.000 0.868 0.132
#> SRR975561 2 0.1529 0.955 0.000 0.960 0.040
#> SRR975562 1 0.3340 0.859 0.880 0.000 0.120
#> SRR975563 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975564 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975565 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975566 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975567 1 0.0424 0.942 0.992 0.000 0.008
#> SRR975568 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975569 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975571 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975572 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975573 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975574 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975575 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975577 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975578 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975579 2 0.3879 0.841 0.000 0.848 0.152
#> SRR975580 2 0.1529 0.955 0.000 0.960 0.040
#> SRR975581 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975582 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975583 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975584 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975585 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975586 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975587 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975588 2 0.0000 0.985 0.000 1.000 0.000
#> SRR975589 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975590 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975591 1 0.6008 0.475 0.628 0.000 0.372
#> SRR975592 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975593 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975594 3 0.0237 0.961 0.000 0.004 0.996
#> SRR975595 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975597 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975596 1 0.3340 0.859 0.880 0.000 0.120
#> SRR975598 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975599 3 0.0000 0.960 0.000 0.000 1.000
#> SRR975600 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975601 1 0.5988 0.483 0.632 0.000 0.368
#> SRR975602 1 0.0000 0.947 1.000 0.000 0.000
#> SRR975603 1 0.3340 0.859 0.880 0.000 0.120
#> SRR975604 3 0.2796 0.881 0.092 0.000 0.908
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0188 0.948 0.996 0.000 0.000 0.004
#> SRR975552 1 0.0188 0.948 0.996 0.000 0.000 0.004
#> SRR975554 1 0.0188 0.948 0.996 0.000 0.000 0.004
#> SRR975553 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> SRR975555 1 0.0188 0.947 0.996 0.000 0.004 0.000
#> SRR975556 2 0.3616 0.821 0.000 0.852 0.036 0.112
#> SRR975557 4 0.1398 0.723 0.000 0.004 0.040 0.956
#> SRR975558 3 0.4741 0.885 0.328 0.000 0.668 0.004
#> SRR975559 1 0.0524 0.944 0.988 0.000 0.008 0.004
#> SRR975560 2 0.5383 0.605 0.000 0.672 0.036 0.292
#> SRR975561 2 0.4621 0.651 0.000 0.708 0.008 0.284
#> SRR975562 3 0.4855 0.896 0.352 0.000 0.644 0.004
#> SRR975563 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> SRR975564 1 0.0188 0.947 0.996 0.000 0.004 0.000
#> SRR975565 1 0.0188 0.948 0.996 0.000 0.000 0.004
#> SRR975566 1 0.0000 0.949 1.000 0.000 0.000 0.000
#> SRR975567 3 0.4713 0.893 0.360 0.000 0.640 0.000
#> SRR975568 1 0.0188 0.947 0.996 0.000 0.004 0.000
#> SRR975569 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> SRR975572 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> SRR975574 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> SRR975575 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0524 0.926 0.000 0.988 0.004 0.008
#> SRR975577 2 0.0524 0.926 0.000 0.988 0.004 0.008
#> SRR975578 2 0.0524 0.926 0.000 0.988 0.004 0.008
#> SRR975579 4 0.4193 0.460 0.000 0.268 0.000 0.732
#> SRR975580 2 0.5383 0.605 0.000 0.672 0.036 0.292
#> SRR975581 2 0.0524 0.926 0.000 0.988 0.004 0.008
#> SRR975582 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> SRR975583 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> SRR975585 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> SRR975586 2 0.5052 0.677 0.000 0.720 0.036 0.244
#> SRR975587 1 0.0000 0.949 1.000 0.000 0.000 0.000
#> SRR975588 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> SRR975589 1 0.0817 0.924 0.976 0.000 0.024 0.000
#> SRR975590 1 0.0188 0.948 0.996 0.000 0.000 0.004
#> SRR975591 3 0.4836 0.890 0.320 0.000 0.672 0.008
#> SRR975592 1 0.0000 0.949 1.000 0.000 0.000 0.000
#> SRR975593 1 0.4994 -0.590 0.520 0.000 0.480 0.000
#> SRR975594 4 0.4677 0.749 0.000 0.004 0.316 0.680
#> SRR975595 1 0.0524 0.944 0.988 0.000 0.008 0.004
#> SRR975597 1 0.0000 0.949 1.000 0.000 0.000 0.000
#> SRR975596 3 0.4855 0.896 0.352 0.000 0.644 0.004
#> SRR975598 1 0.0524 0.944 0.988 0.000 0.008 0.004
#> SRR975599 4 0.4677 0.749 0.000 0.004 0.316 0.680
#> SRR975600 3 0.4817 0.856 0.388 0.000 0.612 0.000
#> SRR975601 3 0.4836 0.890 0.320 0.000 0.672 0.008
#> SRR975602 1 0.0524 0.944 0.988 0.000 0.008 0.004
#> SRR975603 3 0.4697 0.896 0.356 0.000 0.644 0.000
#> SRR975604 3 0.1820 0.326 0.020 0.000 0.944 0.036
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.3039 0.7996 0.808 0.000 0.000 0.000 0.192
#> SRR975552 1 0.3039 0.7996 0.808 0.000 0.000 0.000 0.192
#> SRR975554 1 0.3039 0.7996 0.808 0.000 0.000 0.000 0.192
#> SRR975553 2 0.0290 0.8861 0.000 0.992 0.008 0.000 0.000
#> SRR975555 1 0.2233 0.8163 0.904 0.000 0.016 0.000 0.080
#> SRR975556 2 0.4575 0.4695 0.000 0.736 0.040 0.012 0.212
#> SRR975557 4 0.5646 0.3859 0.000 0.000 0.076 0.480 0.444
#> SRR975558 3 0.4503 0.8272 0.124 0.000 0.756 0.000 0.120
#> SRR975559 1 0.2818 0.7926 0.856 0.000 0.012 0.000 0.132
#> SRR975560 5 0.4781 0.7583 0.000 0.428 0.000 0.020 0.552
#> SRR975561 2 0.5179 -0.7076 0.000 0.496 0.012 0.020 0.472
#> SRR975562 3 0.5109 0.7936 0.172 0.000 0.696 0.000 0.132
#> SRR975563 2 0.0880 0.8836 0.000 0.968 0.032 0.000 0.000
#> SRR975564 1 0.1872 0.8210 0.928 0.000 0.020 0.000 0.052
#> SRR975565 1 0.3039 0.7996 0.808 0.000 0.000 0.000 0.192
#> SRR975566 1 0.0609 0.8417 0.980 0.000 0.000 0.000 0.020
#> SRR975567 3 0.4469 0.8386 0.148 0.000 0.756 0.000 0.096
#> SRR975568 1 0.1800 0.8227 0.932 0.000 0.020 0.000 0.048
#> SRR975569 2 0.0609 0.8840 0.000 0.980 0.020 0.000 0.000
#> SRR975570 2 0.0609 0.8840 0.000 0.980 0.020 0.000 0.000
#> SRR975571 2 0.0290 0.8861 0.000 0.992 0.008 0.000 0.000
#> SRR975572 2 0.0609 0.8840 0.000 0.980 0.020 0.000 0.000
#> SRR975573 2 0.0000 0.8867 0.000 1.000 0.000 0.000 0.000
#> SRR975574 2 0.1168 0.8715 0.000 0.960 0.032 0.008 0.000
#> SRR975575 2 0.0404 0.8874 0.000 0.988 0.012 0.000 0.000
#> SRR975576 2 0.2584 0.8222 0.000 0.900 0.040 0.008 0.052
#> SRR975577 2 0.2584 0.8222 0.000 0.900 0.040 0.008 0.052
#> SRR975578 2 0.2584 0.8222 0.000 0.900 0.040 0.008 0.052
#> SRR975579 5 0.7686 0.0902 0.000 0.208 0.076 0.272 0.444
#> SRR975580 5 0.4781 0.7583 0.000 0.428 0.000 0.020 0.552
#> SRR975581 2 0.2584 0.8222 0.000 0.900 0.040 0.008 0.052
#> SRR975582 2 0.1168 0.8715 0.000 0.960 0.032 0.008 0.000
#> SRR975583 2 0.0404 0.8861 0.000 0.988 0.012 0.000 0.000
#> SRR975584 2 0.0000 0.8867 0.000 1.000 0.000 0.000 0.000
#> SRR975585 2 0.0404 0.8861 0.000 0.988 0.012 0.000 0.000
#> SRR975586 5 0.4443 0.6842 0.000 0.472 0.000 0.004 0.524
#> SRR975587 1 0.1197 0.8414 0.952 0.000 0.000 0.000 0.048
#> SRR975588 2 0.0609 0.8840 0.000 0.980 0.020 0.000 0.000
#> SRR975589 1 0.1399 0.8306 0.952 0.000 0.020 0.000 0.028
#> SRR975590 1 0.3039 0.7996 0.808 0.000 0.000 0.000 0.192
#> SRR975591 3 0.2865 0.8532 0.132 0.000 0.856 0.008 0.004
#> SRR975592 1 0.1965 0.8337 0.904 0.000 0.000 0.000 0.096
#> SRR975593 1 0.5631 -0.2939 0.500 0.000 0.424 0.000 0.076
#> SRR975594 4 0.0404 0.7701 0.000 0.000 0.012 0.988 0.000
#> SRR975595 1 0.2771 0.7951 0.860 0.000 0.012 0.000 0.128
#> SRR975597 1 0.0880 0.8429 0.968 0.000 0.000 0.000 0.032
#> SRR975596 3 0.5109 0.7936 0.172 0.000 0.696 0.000 0.132
#> SRR975598 1 0.2864 0.7962 0.852 0.000 0.012 0.000 0.136
#> SRR975599 4 0.0404 0.7701 0.000 0.000 0.012 0.988 0.000
#> SRR975600 3 0.5142 0.6387 0.348 0.000 0.600 0.000 0.052
#> SRR975601 3 0.2865 0.8532 0.132 0.000 0.856 0.008 0.004
#> SRR975602 1 0.2513 0.7967 0.876 0.000 0.008 0.000 0.116
#> SRR975603 3 0.2648 0.8544 0.152 0.000 0.848 0.000 0.000
#> SRR975604 3 0.3031 0.7046 0.020 0.000 0.856 0.120 0.004
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.3371 0.711 0.708 0.000 0.000 0.000 0.000 NA
#> SRR975552 1 0.3371 0.711 0.708 0.000 0.000 0.000 0.000 NA
#> SRR975554 1 0.3489 0.712 0.708 0.000 0.000 0.004 0.000 NA
#> SRR975553 2 0.0405 0.881 0.000 0.988 0.008 0.000 0.000 NA
#> SRR975555 1 0.3042 0.740 0.852 0.000 0.020 0.028 0.000 NA
#> SRR975556 2 0.5105 -0.115 0.000 0.488 0.000 0.432 0.000 NA
#> SRR975557 4 0.6906 -0.161 0.000 0.000 0.048 0.336 0.300 NA
#> SRR975558 3 0.4222 0.689 0.016 0.000 0.764 0.120 0.000 NA
#> SRR975559 1 0.4339 0.690 0.736 0.000 0.004 0.140 0.000 NA
#> SRR975560 4 0.3620 0.663 0.000 0.248 0.008 0.736 0.008 NA
#> SRR975561 4 0.5311 0.516 0.000 0.344 0.000 0.556 0.008 NA
#> SRR975562 3 0.5761 0.655 0.088 0.000 0.644 0.156 0.000 NA
#> SRR975563 2 0.1757 0.865 0.000 0.916 0.000 0.008 0.000 NA
#> SRR975564 1 0.2898 0.741 0.864 0.000 0.024 0.024 0.000 NA
#> SRR975565 1 0.3489 0.712 0.708 0.000 0.000 0.004 0.000 NA
#> SRR975566 1 0.0260 0.778 0.992 0.000 0.000 0.000 0.000 NA
#> SRR975567 3 0.4468 0.737 0.076 0.000 0.764 0.060 0.000 NA
#> SRR975568 1 0.2677 0.744 0.876 0.000 0.024 0.016 0.000 NA
#> SRR975569 2 0.0603 0.880 0.000 0.980 0.004 0.000 0.000 NA
#> SRR975570 2 0.0603 0.880 0.000 0.980 0.004 0.000 0.000 NA
#> SRR975571 2 0.0405 0.881 0.000 0.988 0.008 0.000 0.000 NA
#> SRR975572 2 0.0603 0.880 0.000 0.980 0.004 0.000 0.000 NA
#> SRR975573 2 0.0146 0.882 0.000 0.996 0.004 0.000 0.000 NA
#> SRR975574 2 0.2070 0.845 0.000 0.892 0.000 0.008 0.000 NA
#> SRR975575 2 0.0865 0.880 0.000 0.964 0.000 0.000 0.000 NA
#> SRR975576 2 0.3586 0.769 0.000 0.796 0.000 0.080 0.000 NA
#> SRR975577 2 0.3586 0.769 0.000 0.796 0.000 0.080 0.000 NA
#> SRR975578 2 0.3586 0.769 0.000 0.796 0.000 0.080 0.000 NA
#> SRR975579 4 0.7943 0.221 0.000 0.120 0.048 0.344 0.156 NA
#> SRR975580 4 0.3620 0.663 0.000 0.248 0.008 0.736 0.008 NA
#> SRR975581 2 0.3586 0.769 0.000 0.796 0.000 0.080 0.000 NA
#> SRR975582 2 0.1806 0.854 0.000 0.908 0.000 0.004 0.000 NA
#> SRR975583 2 0.0363 0.882 0.000 0.988 0.000 0.000 0.000 NA
#> SRR975584 2 0.0146 0.882 0.000 0.996 0.004 0.000 0.000 NA
#> SRR975585 2 0.0363 0.882 0.000 0.988 0.000 0.000 0.000 NA
#> SRR975586 4 0.3351 0.658 0.000 0.288 0.000 0.712 0.000 NA
#> SRR975587 1 0.1285 0.779 0.944 0.000 0.000 0.004 0.000 NA
#> SRR975588 2 0.0603 0.880 0.000 0.980 0.004 0.000 0.000 NA
#> SRR975589 1 0.2249 0.753 0.900 0.000 0.032 0.004 0.000 NA
#> SRR975590 1 0.3489 0.712 0.708 0.000 0.000 0.004 0.000 NA
#> SRR975591 3 0.1471 0.785 0.064 0.000 0.932 0.000 0.004 NA
#> SRR975592 1 0.2053 0.772 0.888 0.000 0.000 0.004 0.000 NA
#> SRR975593 1 0.5841 -0.039 0.516 0.000 0.364 0.056 0.000 NA
#> SRR975594 5 0.0458 0.998 0.000 0.000 0.016 0.000 0.984 NA
#> SRR975595 1 0.4339 0.690 0.736 0.000 0.004 0.140 0.000 NA
#> SRR975597 1 0.1297 0.781 0.948 0.000 0.000 0.012 0.000 NA
#> SRR975596 3 0.5761 0.655 0.088 0.000 0.644 0.156 0.000 NA
#> SRR975598 1 0.4563 0.687 0.712 0.000 0.004 0.152 0.000 NA
#> SRR975599 5 0.0603 0.998 0.000 0.000 0.016 0.000 0.980 NA
#> SRR975600 3 0.5652 0.393 0.372 0.000 0.516 0.024 0.000 NA
#> SRR975601 3 0.1615 0.785 0.064 0.000 0.928 0.000 0.004 NA
#> SRR975602 1 0.3660 0.705 0.800 0.000 0.004 0.096 0.000 NA
#> SRR975603 3 0.1556 0.785 0.080 0.000 0.920 0.000 0.000 NA
#> SRR975604 3 0.2187 0.725 0.004 0.000 0.908 0.012 0.064 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "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 17171 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 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5099 0.491 0.491
#> 3 3 1.000 0.958 0.983 0.1546 0.929 0.857
#> 4 4 0.898 0.845 0.929 0.1279 0.886 0.736
#> 5 5 0.858 0.850 0.897 0.0507 0.939 0.815
#> 6 6 0.889 0.865 0.932 0.0427 0.992 0.970
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR975551 1 0 1 1 0
#> SRR975552 1 0 1 1 0
#> SRR975554 1 0 1 1 0
#> SRR975553 2 0 1 0 1
#> SRR975555 1 0 1 1 0
#> SRR975556 2 0 1 0 1
#> SRR975557 2 0 1 0 1
#> SRR975558 1 0 1 1 0
#> SRR975559 1 0 1 1 0
#> SRR975560 2 0 1 0 1
#> SRR975561 2 0 1 0 1
#> SRR975562 1 0 1 1 0
#> SRR975563 2 0 1 0 1
#> SRR975564 1 0 1 1 0
#> SRR975565 1 0 1 1 0
#> SRR975566 1 0 1 1 0
#> SRR975567 1 0 1 1 0
#> SRR975568 1 0 1 1 0
#> SRR975569 2 0 1 0 1
#> SRR975570 2 0 1 0 1
#> SRR975571 2 0 1 0 1
#> SRR975572 2 0 1 0 1
#> SRR975573 2 0 1 0 1
#> SRR975574 2 0 1 0 1
#> SRR975575 2 0 1 0 1
#> SRR975576 2 0 1 0 1
#> SRR975577 2 0 1 0 1
#> SRR975578 2 0 1 0 1
#> SRR975579 2 0 1 0 1
#> SRR975580 2 0 1 0 1
#> SRR975581 2 0 1 0 1
#> SRR975582 2 0 1 0 1
#> SRR975583 2 0 1 0 1
#> SRR975584 2 0 1 0 1
#> SRR975585 2 0 1 0 1
#> SRR975586 2 0 1 0 1
#> SRR975587 1 0 1 1 0
#> SRR975588 2 0 1 0 1
#> SRR975589 1 0 1 1 0
#> SRR975590 1 0 1 1 0
#> SRR975591 1 0 1 1 0
#> SRR975592 1 0 1 1 0
#> SRR975593 1 0 1 1 0
#> SRR975594 2 0 1 0 1
#> SRR975595 1 0 1 1 0
#> SRR975597 1 0 1 1 0
#> SRR975596 1 0 1 1 0
#> SRR975598 1 0 1 1 0
#> SRR975599 2 0 1 0 1
#> SRR975600 1 0 1 1 0
#> SRR975601 1 0 1 1 0
#> SRR975602 1 0 1 1 0
#> SRR975603 1 0 1 1 0
#> SRR975604 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975552 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975554 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975553 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975555 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975556 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975557 3 0.0000 0.997 0.000 0.000 1.000
#> SRR975558 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975559 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975560 2 0.0424 0.993 0.000 0.992 0.008
#> SRR975561 2 0.0424 0.993 0.000 0.992 0.008
#> SRR975562 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975563 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975564 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975565 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975566 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975567 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975568 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975569 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975571 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975572 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975573 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975574 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975575 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975577 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975578 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975579 2 0.0424 0.993 0.000 0.992 0.008
#> SRR975580 2 0.0424 0.993 0.000 0.992 0.008
#> SRR975581 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975582 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975583 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975584 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975585 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975586 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975587 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975588 2 0.0000 0.999 0.000 1.000 0.000
#> SRR975589 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975590 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975591 1 0.6095 0.395 0.608 0.000 0.392
#> SRR975592 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975593 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975594 3 0.0000 0.997 0.000 0.000 1.000
#> SRR975595 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975597 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975596 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975598 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975599 3 0.0000 0.997 0.000 0.000 1.000
#> SRR975600 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975601 1 0.6095 0.395 0.608 0.000 0.392
#> SRR975602 1 0.0000 0.963 1.000 0.000 0.000
#> SRR975603 1 0.3267 0.850 0.884 0.000 0.116
#> SRR975604 3 0.0424 0.991 0.008 0.000 0.992
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975552 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975554 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975553 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975555 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975556 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975557 4 0.1118 0.529 0.000 0.000 0.036 0.964
#> SRR975558 1 0.2402 0.892 0.912 0.000 0.076 0.012
#> SRR975559 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975560 4 0.4955 0.106 0.000 0.444 0.000 0.556
#> SRR975561 2 0.4746 0.361 0.000 0.632 0.000 0.368
#> SRR975562 3 0.4817 0.634 0.388 0.000 0.612 0.000
#> SRR975563 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975564 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975565 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975566 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975567 1 0.2402 0.892 0.912 0.000 0.076 0.012
#> SRR975568 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975569 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975572 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975574 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975575 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975578 2 0.0188 0.937 0.000 0.996 0.000 0.004
#> SRR975579 4 0.4103 0.526 0.000 0.256 0.000 0.744
#> SRR975580 2 0.4817 0.311 0.000 0.612 0.000 0.388
#> SRR975581 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975582 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975583 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975585 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975586 2 0.4193 0.588 0.000 0.732 0.000 0.268
#> SRR975587 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975588 2 0.0000 0.941 0.000 1.000 0.000 0.000
#> SRR975589 1 0.0188 0.985 0.996 0.000 0.004 0.000
#> SRR975590 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975591 3 0.2216 0.679 0.092 0.000 0.908 0.000
#> SRR975592 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975593 1 0.0188 0.985 0.996 0.000 0.004 0.000
#> SRR975594 4 0.4356 0.460 0.000 0.000 0.292 0.708
#> SRR975595 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975597 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975596 3 0.4817 0.634 0.388 0.000 0.612 0.000
#> SRR975598 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975599 4 0.4356 0.460 0.000 0.000 0.292 0.708
#> SRR975600 1 0.0592 0.973 0.984 0.000 0.016 0.000
#> SRR975601 3 0.2281 0.681 0.096 0.000 0.904 0.000
#> SRR975602 1 0.0000 0.988 1.000 0.000 0.000 0.000
#> SRR975603 3 0.3975 0.708 0.240 0.000 0.760 0.000
#> SRR975604 3 0.1978 0.525 0.004 0.000 0.928 0.068
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.0162 0.977 0.996 0.000 0.000 0.000 0.004
#> SRR975552 1 0.0162 0.977 0.996 0.000 0.000 0.000 0.004
#> SRR975554 1 0.0162 0.977 0.996 0.000 0.000 0.000 0.004
#> SRR975553 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975555 1 0.0290 0.976 0.992 0.000 0.000 0.000 0.008
#> SRR975556 2 0.0609 0.954 0.000 0.980 0.000 0.020 0.000
#> SRR975557 4 0.5448 0.422 0.000 0.000 0.076 0.584 0.340
#> SRR975558 5 0.4060 0.992 0.360 0.000 0.000 0.000 0.640
#> SRR975559 1 0.0510 0.969 0.984 0.000 0.000 0.000 0.016
#> SRR975560 4 0.3561 0.499 0.000 0.260 0.000 0.740 0.000
#> SRR975561 2 0.3999 0.325 0.000 0.656 0.000 0.344 0.000
#> SRR975562 3 0.4384 0.566 0.324 0.000 0.660 0.000 0.016
#> SRR975563 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975564 1 0.0162 0.976 0.996 0.000 0.000 0.000 0.004
#> SRR975565 1 0.0162 0.977 0.996 0.000 0.000 0.000 0.004
#> SRR975566 1 0.0000 0.977 1.000 0.000 0.000 0.000 0.000
#> SRR975567 5 0.4074 0.992 0.364 0.000 0.000 0.000 0.636
#> SRR975568 1 0.0162 0.977 0.996 0.000 0.000 0.000 0.004
#> SRR975569 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975571 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975572 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975573 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975574 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975575 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975576 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975577 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975578 2 0.0880 0.941 0.000 0.968 0.000 0.032 0.000
#> SRR975579 4 0.6564 0.508 0.000 0.236 0.000 0.468 0.296
#> SRR975580 4 0.3966 0.452 0.000 0.336 0.000 0.664 0.000
#> SRR975581 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975582 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975583 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975584 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975585 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975586 4 0.4262 0.232 0.000 0.440 0.000 0.560 0.000
#> SRR975587 1 0.0404 0.970 0.988 0.000 0.012 0.000 0.000
#> SRR975588 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> SRR975589 1 0.0794 0.948 0.972 0.000 0.000 0.000 0.028
#> SRR975590 1 0.0162 0.977 0.996 0.000 0.000 0.000 0.004
#> SRR975591 3 0.2260 0.748 0.064 0.000 0.908 0.000 0.028
#> SRR975592 1 0.0000 0.977 1.000 0.000 0.000 0.000 0.000
#> SRR975593 1 0.0955 0.946 0.968 0.000 0.028 0.000 0.004
#> SRR975594 4 0.6691 0.343 0.000 0.000 0.260 0.428 0.312
#> SRR975595 1 0.0510 0.969 0.984 0.000 0.000 0.000 0.016
#> SRR975597 1 0.0000 0.977 1.000 0.000 0.000 0.000 0.000
#> SRR975596 3 0.4384 0.566 0.324 0.000 0.660 0.000 0.016
#> SRR975598 1 0.0510 0.969 0.984 0.000 0.000 0.000 0.016
#> SRR975599 4 0.6691 0.343 0.000 0.000 0.260 0.428 0.312
#> SRR975600 1 0.2193 0.851 0.912 0.000 0.060 0.000 0.028
#> SRR975601 3 0.1502 0.743 0.056 0.000 0.940 0.000 0.004
#> SRR975602 1 0.0566 0.970 0.984 0.000 0.004 0.000 0.012
#> SRR975603 3 0.3452 0.731 0.148 0.000 0.820 0.000 0.032
#> SRR975604 3 0.0290 0.657 0.000 0.000 0.992 0.000 0.008
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.0146 0.964 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR975552 1 0.0260 0.964 0.992 0.000 0.000 0.008 0.000 0.000
#> SRR975554 1 0.0146 0.964 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR975553 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975555 1 0.0547 0.963 0.980 0.000 0.000 0.020 0.000 0.000
#> SRR975556 2 0.1908 0.876 0.000 0.900 0.000 0.004 0.000 0.096
#> SRR975557 5 0.1411 0.649 0.000 0.000 0.004 0.000 0.936 0.060
#> SRR975558 4 0.1663 0.956 0.088 0.000 0.000 0.912 0.000 0.000
#> SRR975559 1 0.1936 0.934 0.928 0.000 0.028 0.028 0.008 0.008
#> SRR975560 6 0.0820 0.760 0.000 0.012 0.000 0.000 0.016 0.972
#> SRR975561 2 0.4187 0.367 0.000 0.624 0.000 0.004 0.016 0.356
#> SRR975562 3 0.5107 0.564 0.288 0.000 0.636 0.044 0.012 0.020
#> SRR975563 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975564 1 0.0692 0.959 0.976 0.000 0.004 0.020 0.000 0.000
#> SRR975565 1 0.0146 0.964 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR975566 1 0.0458 0.962 0.984 0.000 0.016 0.000 0.000 0.000
#> SRR975567 4 0.1957 0.956 0.112 0.000 0.000 0.888 0.000 0.000
#> SRR975568 1 0.0363 0.963 0.988 0.000 0.000 0.012 0.000 0.000
#> SRR975569 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975571 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975572 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975573 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975574 2 0.0146 0.958 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR975575 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975576 2 0.1010 0.933 0.000 0.960 0.000 0.004 0.000 0.036
#> SRR975577 2 0.0508 0.951 0.000 0.984 0.000 0.004 0.000 0.012
#> SRR975578 2 0.2442 0.818 0.000 0.852 0.000 0.004 0.000 0.144
#> SRR975579 5 0.4836 0.328 0.000 0.196 0.000 0.000 0.664 0.140
#> SRR975580 6 0.0806 0.770 0.000 0.020 0.000 0.000 0.008 0.972
#> SRR975581 2 0.0508 0.951 0.000 0.984 0.000 0.004 0.000 0.012
#> SRR975582 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975583 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975584 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975585 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975586 6 0.3052 0.574 0.000 0.216 0.000 0.004 0.000 0.780
#> SRR975587 1 0.0790 0.958 0.968 0.000 0.032 0.000 0.000 0.000
#> SRR975588 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975589 1 0.0993 0.955 0.964 0.000 0.024 0.012 0.000 0.000
#> SRR975590 1 0.0146 0.964 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR975591 3 0.1313 0.717 0.028 0.000 0.952 0.016 0.004 0.000
#> SRR975592 1 0.0458 0.962 0.984 0.000 0.016 0.000 0.000 0.000
#> SRR975593 1 0.1615 0.930 0.928 0.000 0.064 0.004 0.000 0.004
#> SRR975594 5 0.4147 0.703 0.000 0.000 0.136 0.044 0.776 0.044
#> SRR975595 1 0.1590 0.942 0.944 0.000 0.012 0.028 0.008 0.008
#> SRR975597 1 0.0260 0.964 0.992 0.000 0.000 0.008 0.000 0.000
#> SRR975596 3 0.5089 0.569 0.284 0.000 0.640 0.044 0.012 0.020
#> SRR975598 1 0.2202 0.921 0.916 0.000 0.016 0.040 0.012 0.016
#> SRR975599 5 0.4147 0.703 0.000 0.000 0.136 0.044 0.776 0.044
#> SRR975600 1 0.2487 0.862 0.876 0.000 0.092 0.032 0.000 0.000
#> SRR975601 3 0.1552 0.700 0.020 0.000 0.940 0.004 0.036 0.000
#> SRR975602 1 0.1503 0.945 0.944 0.000 0.016 0.032 0.008 0.000
#> SRR975603 3 0.2492 0.710 0.100 0.000 0.876 0.020 0.000 0.004
#> SRR975604 3 0.1297 0.662 0.000 0.000 0.948 0.012 0.040 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 17171 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 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5099 0.491 0.491
#> 3 3 0.856 0.829 0.917 0.1602 0.965 0.929
#> 4 4 0.981 0.936 0.977 0.1346 0.877 0.730
#> 5 5 0.921 0.919 0.966 0.0490 0.968 0.903
#> 6 6 0.893 0.912 0.928 0.0542 0.958 0.860
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 2 4
There is also optional best \(k\) = 2 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR975551 1 0 1 1 0
#> SRR975552 1 0 1 1 0
#> SRR975554 1 0 1 1 0
#> SRR975553 2 0 1 0 1
#> SRR975555 1 0 1 1 0
#> SRR975556 2 0 1 0 1
#> SRR975557 2 0 1 0 1
#> SRR975558 1 0 1 1 0
#> SRR975559 1 0 1 1 0
#> SRR975560 2 0 1 0 1
#> SRR975561 2 0 1 0 1
#> SRR975562 1 0 1 1 0
#> SRR975563 2 0 1 0 1
#> SRR975564 1 0 1 1 0
#> SRR975565 1 0 1 1 0
#> SRR975566 1 0 1 1 0
#> SRR975567 1 0 1 1 0
#> SRR975568 1 0 1 1 0
#> SRR975569 2 0 1 0 1
#> SRR975570 2 0 1 0 1
#> SRR975571 2 0 1 0 1
#> SRR975572 2 0 1 0 1
#> SRR975573 2 0 1 0 1
#> SRR975574 2 0 1 0 1
#> SRR975575 2 0 1 0 1
#> SRR975576 2 0 1 0 1
#> SRR975577 2 0 1 0 1
#> SRR975578 2 0 1 0 1
#> SRR975579 2 0 1 0 1
#> SRR975580 2 0 1 0 1
#> SRR975581 2 0 1 0 1
#> SRR975582 2 0 1 0 1
#> SRR975583 2 0 1 0 1
#> SRR975584 2 0 1 0 1
#> SRR975585 2 0 1 0 1
#> SRR975586 2 0 1 0 1
#> SRR975587 1 0 1 1 0
#> SRR975588 2 0 1 0 1
#> SRR975589 1 0 1 1 0
#> SRR975590 1 0 1 1 0
#> SRR975591 1 0 1 1 0
#> SRR975592 1 0 1 1 0
#> SRR975593 1 0 1 1 0
#> SRR975594 2 0 1 0 1
#> SRR975595 1 0 1 1 0
#> SRR975597 1 0 1 1 0
#> SRR975596 1 0 1 1 0
#> SRR975598 1 0 1 1 0
#> SRR975599 2 0 1 0 1
#> SRR975600 1 0 1 1 0
#> SRR975601 1 0 1 1 0
#> SRR975602 1 0 1 1 0
#> SRR975603 1 0 1 1 0
#> SRR975604 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.000 0.810 1.000 0.000 0.000
#> SRR975552 1 0.000 0.810 1.000 0.000 0.000
#> SRR975554 1 0.000 0.810 1.000 0.000 0.000
#> SRR975553 2 0.000 0.980 0.000 1.000 0.000
#> SRR975555 1 0.000 0.810 1.000 0.000 0.000
#> SRR975556 2 0.000 0.980 0.000 1.000 0.000
#> SRR975557 2 0.621 0.138 0.000 0.572 0.428
#> SRR975558 1 0.618 0.526 0.584 0.000 0.416
#> SRR975559 1 0.000 0.810 1.000 0.000 0.000
#> SRR975560 2 0.000 0.980 0.000 1.000 0.000
#> SRR975561 2 0.000 0.980 0.000 1.000 0.000
#> SRR975562 1 0.618 0.526 0.584 0.000 0.416
#> SRR975563 2 0.000 0.980 0.000 1.000 0.000
#> SRR975564 1 0.000 0.810 1.000 0.000 0.000
#> SRR975565 1 0.000 0.810 1.000 0.000 0.000
#> SRR975566 1 0.000 0.810 1.000 0.000 0.000
#> SRR975567 1 0.618 0.526 0.584 0.000 0.416
#> SRR975568 1 0.000 0.810 1.000 0.000 0.000
#> SRR975569 2 0.000 0.980 0.000 1.000 0.000
#> SRR975570 2 0.000 0.980 0.000 1.000 0.000
#> SRR975571 2 0.000 0.980 0.000 1.000 0.000
#> SRR975572 2 0.000 0.980 0.000 1.000 0.000
#> SRR975573 2 0.000 0.980 0.000 1.000 0.000
#> SRR975574 2 0.000 0.980 0.000 1.000 0.000
#> SRR975575 2 0.000 0.980 0.000 1.000 0.000
#> SRR975576 2 0.000 0.980 0.000 1.000 0.000
#> SRR975577 2 0.000 0.980 0.000 1.000 0.000
#> SRR975578 2 0.000 0.980 0.000 1.000 0.000
#> SRR975579 2 0.000 0.980 0.000 1.000 0.000
#> SRR975580 2 0.000 0.980 0.000 1.000 0.000
#> SRR975581 2 0.000 0.980 0.000 1.000 0.000
#> SRR975582 2 0.000 0.980 0.000 1.000 0.000
#> SRR975583 2 0.000 0.980 0.000 1.000 0.000
#> SRR975584 2 0.000 0.980 0.000 1.000 0.000
#> SRR975585 2 0.000 0.980 0.000 1.000 0.000
#> SRR975586 2 0.000 0.980 0.000 1.000 0.000
#> SRR975587 1 0.000 0.810 1.000 0.000 0.000
#> SRR975588 2 0.000 0.980 0.000 1.000 0.000
#> SRR975589 1 0.000 0.810 1.000 0.000 0.000
#> SRR975590 1 0.000 0.810 1.000 0.000 0.000
#> SRR975591 1 0.618 0.526 0.584 0.000 0.416
#> SRR975592 1 0.000 0.810 1.000 0.000 0.000
#> SRR975593 1 0.568 0.612 0.684 0.000 0.316
#> SRR975594 3 0.000 1.000 0.000 0.000 1.000
#> SRR975595 1 0.000 0.810 1.000 0.000 0.000
#> SRR975597 1 0.000 0.810 1.000 0.000 0.000
#> SRR975596 1 0.618 0.526 0.584 0.000 0.416
#> SRR975598 1 0.000 0.810 1.000 0.000 0.000
#> SRR975599 3 0.000 1.000 0.000 0.000 1.000
#> SRR975600 1 0.613 0.541 0.600 0.000 0.400
#> SRR975601 1 0.618 0.526 0.584 0.000 0.416
#> SRR975602 1 0.000 0.810 1.000 0.000 0.000
#> SRR975603 1 0.618 0.526 0.584 0.000 0.416
#> SRR975604 1 0.618 0.526 0.584 0.000 0.416
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0000 0.971 1.000 0.000 0.000 0.000
#> SRR975552 1 0.0000 0.971 1.000 0.000 0.000 0.000
#> SRR975554 1 0.0000 0.971 1.000 0.000 0.000 0.000
#> SRR975553 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975555 1 0.0000 0.971 1.000 0.000 0.000 0.000
#> SRR975556 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975557 2 0.6816 0.371 0.000 0.604 0.212 0.184
#> SRR975558 3 0.0000 0.927 0.000 0.000 1.000 0.000
#> SRR975559 1 0.0000 0.971 1.000 0.000 0.000 0.000
#> SRR975560 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975561 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975562 3 0.0000 0.927 0.000 0.000 1.000 0.000
#> SRR975563 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975564 1 0.0000 0.971 1.000 0.000 0.000 0.000
#> SRR975565 1 0.0000 0.971 1.000 0.000 0.000 0.000
#> SRR975566 1 0.1022 0.939 0.968 0.000 0.032 0.000
#> SRR975567 3 0.0000 0.927 0.000 0.000 1.000 0.000
#> SRR975568 1 0.0000 0.971 1.000 0.000 0.000 0.000
#> SRR975569 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975572 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975574 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975575 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975577 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975578 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975579 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975580 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975581 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975582 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975583 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975585 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975586 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975587 1 0.4500 0.497 0.684 0.000 0.316 0.000
#> SRR975588 2 0.0000 0.983 0.000 1.000 0.000 0.000
#> SRR975589 3 0.4790 0.377 0.380 0.000 0.620 0.000
#> SRR975590 1 0.0000 0.971 1.000 0.000 0.000 0.000
#> SRR975591 3 0.0000 0.927 0.000 0.000 1.000 0.000
#> SRR975592 1 0.0000 0.971 1.000 0.000 0.000 0.000
#> SRR975593 3 0.2345 0.819 0.100 0.000 0.900 0.000
#> SRR975594 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR975595 1 0.0000 0.971 1.000 0.000 0.000 0.000
#> SRR975597 1 0.0000 0.971 1.000 0.000 0.000 0.000
#> SRR975596 3 0.0000 0.927 0.000 0.000 1.000 0.000
#> SRR975598 1 0.0000 0.971 1.000 0.000 0.000 0.000
#> SRR975599 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR975600 3 0.0592 0.914 0.016 0.000 0.984 0.000
#> SRR975601 3 0.0000 0.927 0.000 0.000 1.000 0.000
#> SRR975602 1 0.0000 0.971 1.000 0.000 0.000 0.000
#> SRR975603 3 0.0000 0.927 0.000 0.000 1.000 0.000
#> SRR975604 3 0.0000 0.927 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.0794 0.955 0.972 0.000 0.000 0.028 0.000
#> SRR975552 1 0.0794 0.955 0.972 0.000 0.000 0.028 0.000
#> SRR975554 1 0.0794 0.955 0.972 0.000 0.000 0.028 0.000
#> SRR975553 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975555 1 0.0000 0.957 1.000 0.000 0.000 0.000 0.000
#> SRR975556 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975557 4 0.3183 0.444 0.000 0.000 0.016 0.828 0.156
#> SRR975558 3 0.0000 0.941 0.000 0.000 1.000 0.000 0.000
#> SRR975559 1 0.0000 0.957 1.000 0.000 0.000 0.000 0.000
#> SRR975560 2 0.2773 0.814 0.000 0.836 0.000 0.164 0.000
#> SRR975561 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975562 3 0.0000 0.941 0.000 0.000 1.000 0.000 0.000
#> SRR975563 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975564 1 0.0000 0.957 1.000 0.000 0.000 0.000 0.000
#> SRR975565 1 0.0794 0.955 0.972 0.000 0.000 0.028 0.000
#> SRR975566 1 0.0880 0.931 0.968 0.000 0.032 0.000 0.000
#> SRR975567 3 0.0000 0.941 0.000 0.000 1.000 0.000 0.000
#> SRR975568 1 0.0000 0.957 1.000 0.000 0.000 0.000 0.000
#> SRR975569 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975571 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975572 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975573 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975574 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975575 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975576 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975577 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975578 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975579 4 0.3039 0.545 0.000 0.192 0.000 0.808 0.000
#> SRR975580 2 0.2773 0.814 0.000 0.836 0.000 0.164 0.000
#> SRR975581 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975582 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975583 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975584 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975585 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975586 2 0.2773 0.814 0.000 0.836 0.000 0.164 0.000
#> SRR975587 1 0.3895 0.483 0.680 0.000 0.320 0.000 0.000
#> SRR975588 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000
#> SRR975589 3 0.3561 0.619 0.260 0.000 0.740 0.000 0.000
#> SRR975590 1 0.0794 0.955 0.972 0.000 0.000 0.028 0.000
#> SRR975591 3 0.0000 0.941 0.000 0.000 1.000 0.000 0.000
#> SRR975592 1 0.0794 0.955 0.972 0.000 0.000 0.028 0.000
#> SRR975593 3 0.2280 0.827 0.120 0.000 0.880 0.000 0.000
#> SRR975594 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000
#> SRR975595 1 0.0000 0.957 1.000 0.000 0.000 0.000 0.000
#> SRR975597 1 0.0000 0.957 1.000 0.000 0.000 0.000 0.000
#> SRR975596 3 0.0000 0.941 0.000 0.000 1.000 0.000 0.000
#> SRR975598 1 0.0794 0.955 0.972 0.000 0.000 0.028 0.000
#> SRR975599 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000
#> SRR975600 3 0.1121 0.910 0.044 0.000 0.956 0.000 0.000
#> SRR975601 3 0.0000 0.941 0.000 0.000 1.000 0.000 0.000
#> SRR975602 1 0.0000 0.957 1.000 0.000 0.000 0.000 0.000
#> SRR975603 3 0.0000 0.941 0.000 0.000 1.000 0.000 0.000
#> SRR975604 3 0.0000 0.941 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.3929 0.800 0.700 0.000 0.000 0.028 0.000 0.272
#> SRR975552 1 0.2784 0.837 0.848 0.000 0.000 0.028 0.000 0.124
#> SRR975554 1 0.3929 0.800 0.700 0.000 0.000 0.028 0.000 0.272
#> SRR975553 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975555 1 0.0260 0.846 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR975556 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975557 4 0.0713 0.929 0.000 0.000 0.000 0.972 0.028 0.000
#> SRR975558 3 0.2912 0.708 0.000 0.000 0.784 0.000 0.000 0.216
#> SRR975559 1 0.3244 0.808 0.732 0.000 0.000 0.000 0.000 0.268
#> SRR975560 6 0.3309 1.000 0.000 0.280 0.000 0.000 0.000 0.720
#> SRR975561 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975562 3 0.0405 0.913 0.004 0.000 0.988 0.000 0.000 0.008
#> SRR975563 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975564 1 0.0146 0.847 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR975565 1 0.3929 0.800 0.700 0.000 0.000 0.028 0.000 0.272
#> SRR975566 1 0.3512 0.801 0.720 0.000 0.008 0.000 0.000 0.272
#> SRR975567 3 0.0000 0.915 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975568 1 0.0547 0.850 0.980 0.000 0.000 0.000 0.000 0.020
#> SRR975569 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975570 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975571 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975572 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975573 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975574 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975575 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975576 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975577 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975578 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975579 4 0.0713 0.931 0.000 0.028 0.000 0.972 0.000 0.000
#> SRR975580 6 0.3309 1.000 0.000 0.280 0.000 0.000 0.000 0.720
#> SRR975581 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975582 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975583 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975584 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975585 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975586 6 0.3309 1.000 0.000 0.280 0.000 0.000 0.000 0.720
#> SRR975587 1 0.3565 0.533 0.692 0.000 0.304 0.000 0.000 0.004
#> SRR975588 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975589 3 0.3373 0.628 0.248 0.000 0.744 0.000 0.000 0.008
#> SRR975590 1 0.3929 0.800 0.700 0.000 0.000 0.028 0.000 0.272
#> SRR975591 3 0.0000 0.915 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975592 1 0.0858 0.845 0.968 0.000 0.000 0.028 0.000 0.004
#> SRR975593 3 0.2234 0.813 0.124 0.000 0.872 0.000 0.000 0.004
#> SRR975594 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR975595 1 0.0260 0.846 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR975597 1 0.0146 0.847 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR975596 3 0.0291 0.914 0.004 0.000 0.992 0.000 0.000 0.004
#> SRR975598 1 0.0858 0.845 0.968 0.000 0.000 0.028 0.000 0.004
#> SRR975599 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR975600 3 0.1152 0.891 0.044 0.000 0.952 0.000 0.000 0.004
#> SRR975601 3 0.0000 0.915 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975602 1 0.0146 0.847 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR975603 3 0.0000 0.915 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR975604 3 0.0000 0.915 0.000 0.000 1.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 17171 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 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.829 0.898 0.957 0.4777 0.502 0.502
#> 3 3 1.000 0.994 0.997 0.3840 0.781 0.586
#> 4 4 0.857 0.778 0.895 0.0766 0.940 0.825
#> 5 5 0.860 0.818 0.893 0.0607 0.899 0.673
#> 6 6 0.778 0.652 0.814 0.0267 0.900 0.642
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
#> SRR975551 1 0.000 1.000 1.000 0.000
#> SRR975552 1 0.000 1.000 1.000 0.000
#> SRR975554 1 0.000 1.000 1.000 0.000
#> SRR975553 2 0.000 0.889 0.000 1.000
#> SRR975555 1 0.000 1.000 1.000 0.000
#> SRR975556 2 0.996 0.292 0.464 0.536
#> SRR975557 1 0.000 1.000 1.000 0.000
#> SRR975558 1 0.000 1.000 1.000 0.000
#> SRR975559 1 0.000 1.000 1.000 0.000
#> SRR975560 2 0.996 0.292 0.464 0.536
#> SRR975561 2 0.996 0.292 0.464 0.536
#> SRR975562 1 0.000 1.000 1.000 0.000
#> SRR975563 2 0.000 0.889 0.000 1.000
#> SRR975564 1 0.000 1.000 1.000 0.000
#> SRR975565 1 0.000 1.000 1.000 0.000
#> SRR975566 1 0.000 1.000 1.000 0.000
#> SRR975567 1 0.000 1.000 1.000 0.000
#> SRR975568 1 0.000 1.000 1.000 0.000
#> SRR975569 2 0.000 0.889 0.000 1.000
#> SRR975570 2 0.000 0.889 0.000 1.000
#> SRR975571 2 0.000 0.889 0.000 1.000
#> SRR975572 2 0.000 0.889 0.000 1.000
#> SRR975573 2 0.000 0.889 0.000 1.000
#> SRR975574 2 0.000 0.889 0.000 1.000
#> SRR975575 2 0.000 0.889 0.000 1.000
#> SRR975576 2 0.000 0.889 0.000 1.000
#> SRR975577 2 0.000 0.889 0.000 1.000
#> SRR975578 2 0.000 0.889 0.000 1.000
#> SRR975579 1 0.000 1.000 1.000 0.000
#> SRR975580 2 0.996 0.292 0.464 0.536
#> SRR975581 2 0.000 0.889 0.000 1.000
#> SRR975582 2 0.000 0.889 0.000 1.000
#> SRR975583 2 0.000 0.889 0.000 1.000
#> SRR975584 2 0.000 0.889 0.000 1.000
#> SRR975585 2 0.000 0.889 0.000 1.000
#> SRR975586 2 0.996 0.292 0.464 0.536
#> SRR975587 1 0.000 1.000 1.000 0.000
#> SRR975588 2 0.000 0.889 0.000 1.000
#> SRR975589 1 0.000 1.000 1.000 0.000
#> SRR975590 1 0.000 1.000 1.000 0.000
#> SRR975591 1 0.000 1.000 1.000 0.000
#> SRR975592 1 0.000 1.000 1.000 0.000
#> SRR975593 1 0.000 1.000 1.000 0.000
#> SRR975594 1 0.000 1.000 1.000 0.000
#> SRR975595 1 0.000 1.000 1.000 0.000
#> SRR975597 1 0.000 1.000 1.000 0.000
#> SRR975596 1 0.000 1.000 1.000 0.000
#> SRR975598 1 0.000 1.000 1.000 0.000
#> SRR975599 1 0.000 1.000 1.000 0.000
#> SRR975600 1 0.000 1.000 1.000 0.000
#> SRR975601 1 0.000 1.000 1.000 0.000
#> SRR975602 1 0.000 1.000 1.000 0.000
#> SRR975603 1 0.000 1.000 1.000 0.000
#> SRR975604 1 0.000 1.000 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.0000 0.999 1.000 0 0.000
#> SRR975552 1 0.0000 0.999 1.000 0 0.000
#> SRR975554 1 0.0000 0.999 1.000 0 0.000
#> SRR975553 2 0.0000 1.000 0.000 1 0.000
#> SRR975555 1 0.0000 0.999 1.000 0 0.000
#> SRR975556 3 0.0000 0.988 0.000 0 1.000
#> SRR975557 3 0.0000 0.988 0.000 0 1.000
#> SRR975558 3 0.0000 0.988 0.000 0 1.000
#> SRR975559 1 0.0000 0.999 1.000 0 0.000
#> SRR975560 3 0.0000 0.988 0.000 0 1.000
#> SRR975561 3 0.0000 0.988 0.000 0 1.000
#> SRR975562 1 0.0000 0.999 1.000 0 0.000
#> SRR975563 2 0.0000 1.000 0.000 1 0.000
#> SRR975564 1 0.0000 0.999 1.000 0 0.000
#> SRR975565 1 0.0000 0.999 1.000 0 0.000
#> SRR975566 1 0.0000 0.999 1.000 0 0.000
#> SRR975567 3 0.0000 0.988 0.000 0 1.000
#> SRR975568 1 0.0000 0.999 1.000 0 0.000
#> SRR975569 2 0.0000 1.000 0.000 1 0.000
#> SRR975570 2 0.0000 1.000 0.000 1 0.000
#> SRR975571 2 0.0000 1.000 0.000 1 0.000
#> SRR975572 2 0.0000 1.000 0.000 1 0.000
#> SRR975573 2 0.0000 1.000 0.000 1 0.000
#> SRR975574 2 0.0000 1.000 0.000 1 0.000
#> SRR975575 2 0.0000 1.000 0.000 1 0.000
#> SRR975576 2 0.0000 1.000 0.000 1 0.000
#> SRR975577 2 0.0000 1.000 0.000 1 0.000
#> SRR975578 2 0.0000 1.000 0.000 1 0.000
#> SRR975579 3 0.0000 0.988 0.000 0 1.000
#> SRR975580 3 0.0000 0.988 0.000 0 1.000
#> SRR975581 2 0.0000 1.000 0.000 1 0.000
#> SRR975582 2 0.0000 1.000 0.000 1 0.000
#> SRR975583 2 0.0000 1.000 0.000 1 0.000
#> SRR975584 2 0.0000 1.000 0.000 1 0.000
#> SRR975585 2 0.0000 1.000 0.000 1 0.000
#> SRR975586 3 0.0000 0.988 0.000 0 1.000
#> SRR975587 1 0.0000 0.999 1.000 0 0.000
#> SRR975588 2 0.0000 1.000 0.000 1 0.000
#> SRR975589 1 0.0000 0.999 1.000 0 0.000
#> SRR975590 1 0.0000 0.999 1.000 0 0.000
#> SRR975591 3 0.1860 0.945 0.052 0 0.948
#> SRR975592 1 0.0000 0.999 1.000 0 0.000
#> SRR975593 1 0.0000 0.999 1.000 0 0.000
#> SRR975594 3 0.0000 0.988 0.000 0 1.000
#> SRR975595 1 0.0000 0.999 1.000 0 0.000
#> SRR975597 1 0.0000 0.999 1.000 0 0.000
#> SRR975596 1 0.0000 0.999 1.000 0 0.000
#> SRR975598 1 0.0000 0.999 1.000 0 0.000
#> SRR975599 3 0.0000 0.988 0.000 0 1.000
#> SRR975600 1 0.0000 0.999 1.000 0 0.000
#> SRR975601 1 0.0892 0.979 0.980 0 0.020
#> SRR975602 1 0.0000 0.999 1.000 0 0.000
#> SRR975603 1 0.0000 0.999 1.000 0 0.000
#> SRR975604 3 0.2537 0.917 0.080 0 0.920
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975552 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975554 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975553 2 0.0000 0.953 0.000 1.000 0.000 0.000
#> SRR975555 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975556 4 0.0000 0.717 0.000 0.000 0.000 1.000
#> SRR975557 4 0.4998 0.634 0.000 0.000 0.488 0.512
#> SRR975558 3 0.4245 0.345 0.020 0.000 0.784 0.196
#> SRR975559 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975560 4 0.2469 0.737 0.000 0.000 0.108 0.892
#> SRR975561 4 0.1022 0.695 0.000 0.032 0.000 0.968
#> SRR975562 1 0.4804 0.191 0.616 0.000 0.384 0.000
#> SRR975563 2 0.0188 0.952 0.000 0.996 0.004 0.000
#> SRR975564 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975565 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975566 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975567 3 0.4348 0.353 0.024 0.000 0.780 0.196
#> SRR975568 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975569 2 0.0000 0.953 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.953 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0000 0.953 0.000 1.000 0.000 0.000
#> SRR975572 2 0.0000 0.953 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 0.953 0.000 1.000 0.000 0.000
#> SRR975574 2 0.1902 0.916 0.000 0.932 0.004 0.064
#> SRR975575 2 0.0188 0.952 0.000 0.996 0.004 0.000
#> SRR975576 2 0.2197 0.904 0.000 0.916 0.004 0.080
#> SRR975577 2 0.2944 0.858 0.000 0.868 0.004 0.128
#> SRR975578 2 0.5167 0.139 0.000 0.508 0.004 0.488
#> SRR975579 4 0.4972 0.654 0.000 0.000 0.456 0.544
#> SRR975580 4 0.2469 0.737 0.000 0.000 0.108 0.892
#> SRR975581 2 0.1109 0.938 0.000 0.968 0.004 0.028
#> SRR975582 2 0.0188 0.952 0.000 0.996 0.004 0.000
#> SRR975583 2 0.0000 0.953 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 0.953 0.000 1.000 0.000 0.000
#> SRR975585 2 0.0000 0.953 0.000 1.000 0.000 0.000
#> SRR975586 4 0.0000 0.717 0.000 0.000 0.000 1.000
#> SRR975587 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975588 2 0.0000 0.953 0.000 1.000 0.000 0.000
#> SRR975589 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975590 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975591 3 0.3404 0.588 0.104 0.000 0.864 0.032
#> SRR975592 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975593 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975594 4 0.4972 0.637 0.000 0.000 0.456 0.544
#> SRR975595 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975597 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975596 1 0.4804 0.191 0.616 0.000 0.384 0.000
#> SRR975598 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975599 4 0.4972 0.637 0.000 0.000 0.456 0.544
#> SRR975600 1 0.4855 0.171 0.600 0.000 0.400 0.000
#> SRR975601 3 0.5649 0.390 0.392 0.000 0.580 0.028
#> SRR975602 1 0.0000 0.925 1.000 0.000 0.000 0.000
#> SRR975603 3 0.4961 0.241 0.448 0.000 0.552 0.000
#> SRR975604 3 0.3149 0.576 0.088 0.000 0.880 0.032
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 1 0.0000 0.960 1.000 0.000 0.000 0.000 0.000
#> SRR975552 1 0.0000 0.960 1.000 0.000 0.000 0.000 0.000
#> SRR975554 1 0.1341 0.960 0.944 0.000 0.056 0.000 0.000
#> SRR975553 2 0.0290 0.961 0.000 0.992 0.000 0.000 0.008
#> SRR975555 1 0.0162 0.959 0.996 0.000 0.004 0.000 0.000
#> SRR975556 5 0.4074 0.136 0.000 0.000 0.000 0.364 0.636
#> SRR975557 4 0.0000 0.865 0.000 0.000 0.000 1.000 0.000
#> SRR975558 3 0.3934 0.478 0.008 0.000 0.716 0.276 0.000
#> SRR975559 1 0.1341 0.960 0.944 0.000 0.056 0.000 0.000
#> SRR975560 4 0.3975 0.892 0.000 0.000 0.144 0.792 0.064
#> SRR975561 5 0.0404 0.473 0.000 0.000 0.000 0.012 0.988
#> SRR975562 3 0.3636 0.680 0.272 0.000 0.728 0.000 0.000
#> SRR975563 2 0.0000 0.962 0.000 1.000 0.000 0.000 0.000
#> SRR975564 1 0.0000 0.960 1.000 0.000 0.000 0.000 0.000
#> SRR975565 1 0.0000 0.960 1.000 0.000 0.000 0.000 0.000
#> SRR975566 1 0.1341 0.960 0.944 0.000 0.056 0.000 0.000
#> SRR975567 3 0.3934 0.478 0.008 0.000 0.716 0.276 0.000
#> SRR975568 1 0.0000 0.960 1.000 0.000 0.000 0.000 0.000
#> SRR975569 2 0.0290 0.961 0.000 0.992 0.000 0.000 0.008
#> SRR975570 2 0.0162 0.962 0.000 0.996 0.000 0.000 0.004
#> SRR975571 2 0.0290 0.961 0.000 0.992 0.000 0.000 0.008
#> SRR975572 2 0.0290 0.961 0.000 0.992 0.000 0.000 0.008
#> SRR975573 2 0.0000 0.962 0.000 1.000 0.000 0.000 0.000
#> SRR975574 2 0.3774 0.430 0.000 0.704 0.000 0.000 0.296
#> SRR975575 2 0.0000 0.962 0.000 1.000 0.000 0.000 0.000
#> SRR975576 5 0.4015 0.535 0.000 0.348 0.000 0.000 0.652
#> SRR975577 5 0.4015 0.535 0.000 0.348 0.000 0.000 0.652
#> SRR975578 5 0.4201 0.554 0.000 0.328 0.000 0.008 0.664
#> SRR975579 4 0.0000 0.865 0.000 0.000 0.000 1.000 0.000
#> SRR975580 4 0.3975 0.892 0.000 0.000 0.144 0.792 0.064
#> SRR975581 2 0.1544 0.885 0.000 0.932 0.000 0.000 0.068
#> SRR975582 2 0.0000 0.962 0.000 1.000 0.000 0.000 0.000
#> SRR975583 2 0.0000 0.962 0.000 1.000 0.000 0.000 0.000
#> SRR975584 2 0.0000 0.962 0.000 1.000 0.000 0.000 0.000
#> SRR975585 2 0.0000 0.962 0.000 1.000 0.000 0.000 0.000
#> SRR975586 5 0.4101 0.116 0.000 0.000 0.000 0.372 0.628
#> SRR975587 1 0.1341 0.960 0.944 0.000 0.056 0.000 0.000
#> SRR975588 2 0.0290 0.961 0.000 0.992 0.000 0.000 0.008
#> SRR975589 1 0.1341 0.960 0.944 0.000 0.056 0.000 0.000
#> SRR975590 1 0.1341 0.960 0.944 0.000 0.056 0.000 0.000
#> SRR975591 3 0.1408 0.658 0.008 0.000 0.948 0.044 0.000
#> SRR975592 1 0.1341 0.960 0.944 0.000 0.056 0.000 0.000
#> SRR975593 1 0.1410 0.958 0.940 0.000 0.060 0.000 0.000
#> SRR975594 4 0.2280 0.904 0.000 0.000 0.120 0.880 0.000
#> SRR975595 1 0.0162 0.959 0.996 0.000 0.004 0.000 0.000
#> SRR975597 1 0.0162 0.959 0.996 0.000 0.004 0.000 0.000
#> SRR975596 3 0.3684 0.676 0.280 0.000 0.720 0.000 0.000
#> SRR975598 1 0.0963 0.941 0.964 0.000 0.036 0.000 0.000
#> SRR975599 4 0.2424 0.901 0.000 0.000 0.132 0.868 0.000
#> SRR975600 3 0.4161 0.493 0.392 0.000 0.608 0.000 0.000
#> SRR975601 3 0.1399 0.667 0.020 0.000 0.952 0.028 0.000
#> SRR975602 1 0.1851 0.936 0.912 0.000 0.088 0.000 0.000
#> SRR975603 3 0.4114 0.689 0.272 0.000 0.712 0.016 0.000
#> SRR975604 3 0.1408 0.658 0.008 0.000 0.948 0.044 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.0291 0.662 0.992 0.000 0.004 0.000 0.000 0.004
#> SRR975552 1 0.0291 0.662 0.992 0.000 0.004 0.000 0.000 0.004
#> SRR975554 1 0.2473 0.637 0.856 0.000 0.136 0.000 0.000 0.008
#> SRR975553 2 0.0865 0.886 0.000 0.964 0.000 0.000 0.000 0.036
#> SRR975555 1 0.1492 0.664 0.940 0.000 0.036 0.000 0.000 0.024
#> SRR975556 5 0.1151 0.896 0.000 0.012 0.000 0.032 0.956 0.000
#> SRR975557 4 0.0000 0.661 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR975558 3 0.5915 0.152 0.000 0.000 0.428 0.212 0.000 0.360
#> SRR975559 1 0.4286 0.319 0.728 0.000 0.108 0.000 0.000 0.164
#> SRR975560 4 0.7492 0.499 0.000 0.000 0.156 0.360 0.220 0.264
#> SRR975561 5 0.1663 0.818 0.000 0.088 0.000 0.000 0.912 0.000
#> SRR975562 1 0.4589 0.203 0.504 0.000 0.460 0.000 0.000 0.036
#> SRR975563 2 0.0146 0.894 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR975564 1 0.0291 0.667 0.992 0.000 0.004 0.000 0.000 0.004
#> SRR975565 1 0.0291 0.662 0.992 0.000 0.004 0.000 0.000 0.004
#> SRR975566 6 0.4407 0.995 0.480 0.000 0.024 0.000 0.000 0.496
#> SRR975567 3 0.5915 0.152 0.000 0.000 0.428 0.212 0.000 0.360
#> SRR975568 1 0.0291 0.667 0.992 0.000 0.004 0.000 0.000 0.004
#> SRR975569 2 0.1610 0.867 0.000 0.916 0.000 0.000 0.000 0.084
#> SRR975570 2 0.0146 0.894 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR975571 2 0.0865 0.886 0.000 0.964 0.000 0.000 0.000 0.036
#> SRR975572 2 0.0363 0.892 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR975573 2 0.0000 0.894 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975574 2 0.3584 0.620 0.000 0.688 0.000 0.000 0.308 0.004
#> SRR975575 2 0.0146 0.894 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR975576 2 0.3578 0.590 0.000 0.660 0.000 0.000 0.340 0.000
#> SRR975577 2 0.3578 0.590 0.000 0.660 0.000 0.000 0.340 0.000
#> SRR975578 2 0.3672 0.542 0.000 0.632 0.000 0.000 0.368 0.000
#> SRR975579 4 0.0363 0.661 0.000 0.000 0.000 0.988 0.012 0.000
#> SRR975580 4 0.7492 0.499 0.000 0.000 0.156 0.360 0.220 0.264
#> SRR975581 2 0.1471 0.863 0.000 0.932 0.000 0.000 0.064 0.004
#> SRR975582 2 0.0146 0.894 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR975583 2 0.0000 0.894 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975584 2 0.0000 0.894 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975585 2 0.0000 0.894 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975586 5 0.0865 0.883 0.000 0.000 0.000 0.036 0.964 0.000
#> SRR975587 6 0.4407 0.990 0.484 0.000 0.024 0.000 0.000 0.492
#> SRR975588 2 0.1610 0.867 0.000 0.916 0.000 0.000 0.000 0.084
#> SRR975589 6 0.4407 0.995 0.480 0.000 0.024 0.000 0.000 0.496
#> SRR975590 1 0.2402 0.634 0.856 0.000 0.140 0.000 0.000 0.004
#> SRR975591 3 0.1814 0.582 0.000 0.000 0.900 0.100 0.000 0.000
#> SRR975592 1 0.2402 0.634 0.856 0.000 0.140 0.000 0.000 0.004
#> SRR975593 1 0.5313 -0.788 0.508 0.000 0.108 0.000 0.000 0.384
#> SRR975594 4 0.3027 0.671 0.000 0.000 0.148 0.824 0.000 0.028
#> SRR975595 1 0.1367 0.661 0.944 0.000 0.044 0.000 0.000 0.012
#> SRR975597 1 0.0363 0.669 0.988 0.000 0.012 0.000 0.000 0.000
#> SRR975596 1 0.4589 0.203 0.504 0.000 0.460 0.000 0.000 0.036
#> SRR975598 1 0.3168 0.614 0.804 0.000 0.172 0.000 0.000 0.024
#> SRR975599 4 0.3776 0.638 0.000 0.000 0.196 0.756 0.000 0.048
#> SRR975600 3 0.3742 0.083 0.348 0.000 0.648 0.000 0.000 0.004
#> SRR975601 3 0.0260 0.648 0.008 0.000 0.992 0.000 0.000 0.000
#> SRR975602 1 0.3261 0.578 0.780 0.000 0.204 0.000 0.000 0.016
#> SRR975603 3 0.0777 0.644 0.024 0.000 0.972 0.000 0.000 0.004
#> SRR975604 3 0.0405 0.646 0.004 0.000 0.988 0.008 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 17171 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 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.974 0.991 0.5082 0.491 0.491
#> 3 3 0.807 0.782 0.894 0.1976 0.911 0.821
#> 4 4 0.799 0.828 0.902 0.1368 0.859 0.663
#> 5 5 0.758 0.693 0.831 0.0405 0.954 0.850
#> 6 6 0.729 0.676 0.826 0.0377 0.891 0.663
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
#> SRR975551 1 0.000 1.000 1.000 0.000
#> SRR975552 1 0.000 1.000 1.000 0.000
#> SRR975554 1 0.000 1.000 1.000 0.000
#> SRR975553 2 0.000 0.980 0.000 1.000
#> SRR975555 1 0.000 1.000 1.000 0.000
#> SRR975556 2 0.000 0.980 0.000 1.000
#> SRR975557 2 0.000 0.980 0.000 1.000
#> SRR975558 1 0.000 1.000 1.000 0.000
#> SRR975559 1 0.000 1.000 1.000 0.000
#> SRR975560 2 0.000 0.980 0.000 1.000
#> SRR975561 2 0.000 0.980 0.000 1.000
#> SRR975562 1 0.000 1.000 1.000 0.000
#> SRR975563 2 0.000 0.980 0.000 1.000
#> SRR975564 1 0.000 1.000 1.000 0.000
#> SRR975565 1 0.000 1.000 1.000 0.000
#> SRR975566 1 0.000 1.000 1.000 0.000
#> SRR975567 1 0.000 1.000 1.000 0.000
#> SRR975568 1 0.000 1.000 1.000 0.000
#> SRR975569 2 0.000 0.980 0.000 1.000
#> SRR975570 2 0.000 0.980 0.000 1.000
#> SRR975571 2 0.000 0.980 0.000 1.000
#> SRR975572 2 0.000 0.980 0.000 1.000
#> SRR975573 2 0.000 0.980 0.000 1.000
#> SRR975574 2 0.000 0.980 0.000 1.000
#> SRR975575 2 0.000 0.980 0.000 1.000
#> SRR975576 2 0.000 0.980 0.000 1.000
#> SRR975577 2 0.000 0.980 0.000 1.000
#> SRR975578 2 0.000 0.980 0.000 1.000
#> SRR975579 2 0.000 0.980 0.000 1.000
#> SRR975580 2 0.000 0.980 0.000 1.000
#> SRR975581 2 0.000 0.980 0.000 1.000
#> SRR975582 2 0.000 0.980 0.000 1.000
#> SRR975583 2 0.000 0.980 0.000 1.000
#> SRR975584 2 0.000 0.980 0.000 1.000
#> SRR975585 2 0.000 0.980 0.000 1.000
#> SRR975586 2 0.000 0.980 0.000 1.000
#> SRR975587 1 0.000 1.000 1.000 0.000
#> SRR975588 2 0.000 0.980 0.000 1.000
#> SRR975589 1 0.000 1.000 1.000 0.000
#> SRR975590 1 0.000 1.000 1.000 0.000
#> SRR975591 1 0.000 1.000 1.000 0.000
#> SRR975592 1 0.000 1.000 1.000 0.000
#> SRR975593 1 0.000 1.000 1.000 0.000
#> SRR975594 2 0.999 0.062 0.484 0.516
#> SRR975595 1 0.000 1.000 1.000 0.000
#> SRR975597 1 0.000 1.000 1.000 0.000
#> SRR975596 1 0.000 1.000 1.000 0.000
#> SRR975598 1 0.000 1.000 1.000 0.000
#> SRR975599 1 0.000 1.000 1.000 0.000
#> SRR975600 1 0.000 1.000 1.000 0.000
#> SRR975601 1 0.000 1.000 1.000 0.000
#> SRR975602 1 0.000 1.000 1.000 0.000
#> SRR975603 1 0.000 1.000 1.000 0.000
#> SRR975604 1 0.000 1.000 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR975551 1 0.1289 0.8127 0.968 0.000 0.032
#> SRR975552 1 0.1289 0.8127 0.968 0.000 0.032
#> SRR975554 1 0.0747 0.8250 0.984 0.000 0.016
#> SRR975553 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975555 1 0.0892 0.8179 0.980 0.000 0.020
#> SRR975556 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975557 3 0.6421 0.2279 0.004 0.424 0.572
#> SRR975558 1 0.4887 0.7349 0.772 0.000 0.228
#> SRR975559 1 0.6154 0.5431 0.592 0.000 0.408
#> SRR975560 2 0.5899 0.5053 0.020 0.736 0.244
#> SRR975561 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975562 1 0.6260 0.4869 0.552 0.000 0.448
#> SRR975563 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975564 1 0.1031 0.8164 0.976 0.000 0.024
#> SRR975565 1 0.1289 0.8127 0.968 0.000 0.032
#> SRR975566 1 0.2356 0.8204 0.928 0.000 0.072
#> SRR975567 1 0.3038 0.8083 0.896 0.000 0.104
#> SRR975568 1 0.1163 0.8146 0.972 0.000 0.028
#> SRR975569 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975570 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975571 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975572 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975573 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975574 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975575 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975576 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975577 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975578 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975579 3 0.6309 0.0264 0.000 0.496 0.504
#> SRR975580 2 0.0592 0.9675 0.000 0.988 0.012
#> SRR975581 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975582 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975583 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975584 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975585 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975586 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975587 1 0.0237 0.8228 0.996 0.000 0.004
#> SRR975588 2 0.0000 0.9827 0.000 1.000 0.000
#> SRR975589 1 0.1964 0.8246 0.944 0.000 0.056
#> SRR975590 1 0.1289 0.8127 0.968 0.000 0.032
#> SRR975591 3 0.2625 0.4769 0.084 0.000 0.916
#> SRR975592 1 0.0892 0.8261 0.980 0.000 0.020
#> SRR975593 1 0.5988 0.5946 0.632 0.000 0.368
#> SRR975594 3 0.1647 0.5006 0.036 0.004 0.960
#> SRR975595 1 0.4399 0.7629 0.812 0.000 0.188
#> SRR975597 1 0.1289 0.8268 0.968 0.000 0.032
#> SRR975596 1 0.6267 0.4799 0.548 0.000 0.452
#> SRR975598 1 0.5363 0.6962 0.724 0.000 0.276
#> SRR975599 1 0.6280 0.4654 0.540 0.000 0.460
#> SRR975600 1 0.0424 0.8240 0.992 0.000 0.008
#> SRR975601 1 0.2165 0.8230 0.936 0.000 0.064
#> SRR975602 1 0.1753 0.8261 0.952 0.000 0.048
#> SRR975603 1 0.6267 0.4772 0.548 0.000 0.452
#> SRR975604 3 0.6154 -0.2976 0.408 0.000 0.592
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR975551 1 0.1109 0.8283 0.968 0.000 0.028 0.004
#> SRR975552 1 0.0657 0.8238 0.984 0.000 0.012 0.004
#> SRR975554 1 0.4992 0.0195 0.524 0.000 0.476 0.000
#> SRR975553 2 0.0000 0.9904 0.000 1.000 0.000 0.000
#> SRR975555 3 0.5055 0.4758 0.368 0.000 0.624 0.008
#> SRR975556 2 0.0188 0.9886 0.000 0.996 0.000 0.004
#> SRR975557 4 0.1114 0.8789 0.004 0.008 0.016 0.972
#> SRR975558 3 0.4304 0.6760 0.284 0.000 0.716 0.000
#> SRR975559 3 0.2530 0.8238 0.112 0.000 0.888 0.000
#> SRR975560 3 0.4875 0.4176 0.008 0.296 0.692 0.004
#> SRR975561 2 0.0336 0.9876 0.000 0.992 0.008 0.000
#> SRR975562 3 0.2081 0.8183 0.084 0.000 0.916 0.000
#> SRR975563 2 0.0000 0.9904 0.000 1.000 0.000 0.000
#> SRR975564 1 0.4920 0.4303 0.628 0.000 0.368 0.004
#> SRR975565 1 0.1004 0.8280 0.972 0.000 0.024 0.004
#> SRR975566 1 0.3356 0.7615 0.824 0.000 0.176 0.000
#> SRR975567 1 0.4222 0.6424 0.728 0.000 0.272 0.000
#> SRR975568 1 0.0336 0.8231 0.992 0.000 0.008 0.000
#> SRR975569 2 0.0000 0.9904 0.000 1.000 0.000 0.000
#> SRR975570 2 0.0000 0.9904 0.000 1.000 0.000 0.000
#> SRR975571 2 0.0000 0.9904 0.000 1.000 0.000 0.000
#> SRR975572 2 0.0000 0.9904 0.000 1.000 0.000 0.000
#> SRR975573 2 0.0000 0.9904 0.000 1.000 0.000 0.000
#> SRR975574 2 0.0000 0.9904 0.000 1.000 0.000 0.000
#> SRR975575 2 0.0000 0.9904 0.000 1.000 0.000 0.000
#> SRR975576 2 0.0336 0.9876 0.000 0.992 0.008 0.000
#> SRR975577 2 0.0336 0.9876 0.000 0.992 0.008 0.000
#> SRR975578 2 0.0336 0.9876 0.000 0.992 0.008 0.000
#> SRR975579 4 0.1406 0.8702 0.000 0.024 0.016 0.960
#> SRR975580 2 0.3128 0.8388 0.004 0.864 0.128 0.004
#> SRR975581 2 0.0336 0.9876 0.000 0.992 0.008 0.000
#> SRR975582 2 0.0000 0.9904 0.000 1.000 0.000 0.000
#> SRR975583 2 0.0000 0.9904 0.000 1.000 0.000 0.000
#> SRR975584 2 0.0000 0.9904 0.000 1.000 0.000 0.000
#> SRR975585 2 0.0000 0.9904 0.000 1.000 0.000 0.000
#> SRR975586 2 0.0524 0.9853 0.000 0.988 0.008 0.004
#> SRR975587 1 0.0921 0.8282 0.972 0.000 0.028 0.000
#> SRR975588 2 0.0188 0.9884 0.000 0.996 0.000 0.004
#> SRR975589 1 0.3219 0.7716 0.836 0.000 0.164 0.000
#> SRR975590 1 0.0000 0.8174 1.000 0.000 0.000 0.000
#> SRR975591 4 0.0817 0.8745 0.024 0.000 0.000 0.976
#> SRR975592 1 0.3837 0.7125 0.776 0.000 0.224 0.000
#> SRR975593 3 0.3764 0.7724 0.216 0.000 0.784 0.000
#> SRR975594 4 0.0672 0.8787 0.008 0.000 0.008 0.984
#> SRR975595 3 0.2921 0.8206 0.140 0.000 0.860 0.000
#> SRR975597 3 0.3668 0.7961 0.188 0.000 0.808 0.004
#> SRR975596 3 0.2149 0.8198 0.088 0.000 0.912 0.000
#> SRR975598 3 0.2216 0.8215 0.092 0.000 0.908 0.000
#> SRR975599 3 0.2011 0.8156 0.080 0.000 0.920 0.000
#> SRR975600 1 0.0376 0.8207 0.992 0.000 0.004 0.004
#> SRR975601 1 0.2494 0.8155 0.916 0.000 0.048 0.036
#> SRR975602 3 0.3219 0.8123 0.164 0.000 0.836 0.000
#> SRR975603 3 0.7236 0.4188 0.168 0.000 0.520 0.312
#> SRR975604 4 0.6116 0.3687 0.068 0.000 0.320 0.612
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR975551 3 0.2144 0.7061 0.020 0.000 0.912 0.000 NA
#> SRR975552 3 0.1341 0.7043 0.000 0.000 0.944 0.000 NA
#> SRR975554 3 0.3790 0.4881 0.272 0.000 0.724 0.000 NA
#> SRR975553 2 0.0000 0.9618 0.000 1.000 0.000 0.000 NA
#> SRR975555 1 0.5798 0.4793 0.608 0.000 0.236 0.000 NA
#> SRR975556 2 0.0703 0.9516 0.000 0.976 0.000 0.000 NA
#> SRR975557 4 0.4291 0.6216 0.000 0.000 0.000 0.536 NA
#> SRR975558 1 0.5752 0.4894 0.620 0.000 0.208 0.000 NA
#> SRR975559 1 0.4138 0.4497 0.616 0.000 0.384 0.000 NA
#> SRR975560 1 0.2992 0.5718 0.872 0.092 0.012 0.000 NA
#> SRR975561 2 0.0162 0.9615 0.000 0.996 0.000 0.000 NA
#> SRR975562 1 0.1502 0.6674 0.940 0.000 0.056 0.000 NA
#> SRR975563 2 0.0000 0.9618 0.000 1.000 0.000 0.000 NA
#> SRR975564 3 0.5990 0.4033 0.296 0.000 0.560 0.000 NA
#> SRR975565 3 0.2293 0.6966 0.016 0.000 0.900 0.000 NA
#> SRR975566 3 0.2127 0.6910 0.108 0.000 0.892 0.000 NA
#> SRR975567 3 0.5384 0.5412 0.196 0.000 0.664 0.000 NA
#> SRR975568 3 0.3123 0.6624 0.012 0.000 0.828 0.000 NA
#> SRR975569 2 0.1671 0.9099 0.000 0.924 0.000 0.000 NA
#> SRR975570 2 0.0000 0.9618 0.000 1.000 0.000 0.000 NA
#> SRR975571 2 0.0000 0.9618 0.000 1.000 0.000 0.000 NA
#> SRR975572 2 0.0000 0.9618 0.000 1.000 0.000 0.000 NA
#> SRR975573 2 0.0000 0.9618 0.000 1.000 0.000 0.000 NA
#> SRR975574 2 0.0162 0.9615 0.000 0.996 0.000 0.000 NA
#> SRR975575 2 0.0000 0.9618 0.000 1.000 0.000 0.000 NA
#> SRR975576 2 0.0162 0.9615 0.000 0.996 0.000 0.000 NA
#> SRR975577 2 0.0162 0.9615 0.000 0.996 0.000 0.000 NA
#> SRR975578 2 0.0162 0.9615 0.000 0.996 0.000 0.000 NA
#> SRR975579 4 0.4291 0.6216 0.000 0.000 0.000 0.536 NA
#> SRR975580 2 0.4794 0.2163 0.464 0.520 0.004 0.000 NA
#> SRR975581 2 0.0162 0.9615 0.000 0.996 0.000 0.000 NA
#> SRR975582 2 0.0162 0.9615 0.000 0.996 0.000 0.000 NA
#> SRR975583 2 0.0000 0.9618 0.000 1.000 0.000 0.000 NA
#> SRR975584 2 0.0290 0.9582 0.000 0.992 0.000 0.000 NA
#> SRR975585 2 0.0000 0.9618 0.000 1.000 0.000 0.000 NA
#> SRR975586 2 0.2067 0.9051 0.032 0.920 0.000 0.000 NA
#> SRR975587 3 0.1901 0.7109 0.004 0.000 0.932 0.024 NA
#> SRR975588 2 0.2127 0.8825 0.000 0.892 0.000 0.000 NA
#> SRR975589 3 0.4057 0.6772 0.120 0.000 0.792 0.000 NA
#> SRR975590 3 0.1502 0.7032 0.004 0.000 0.940 0.000 NA
#> SRR975591 4 0.0290 0.6892 0.000 0.000 0.008 0.992 NA
#> SRR975592 3 0.2900 0.6891 0.108 0.000 0.864 0.000 NA
#> SRR975593 3 0.4827 -0.1968 0.476 0.000 0.504 0.000 NA
#> SRR975594 4 0.0000 0.6892 0.000 0.000 0.000 1.000 NA
#> SRR975595 1 0.4127 0.5571 0.680 0.000 0.312 0.000 NA
#> SRR975597 1 0.4542 0.2844 0.536 0.000 0.456 0.000 NA
#> SRR975596 1 0.1341 0.6690 0.944 0.000 0.056 0.000 NA
#> SRR975598 1 0.3562 0.6458 0.788 0.000 0.196 0.000 NA
#> SRR975599 1 0.0960 0.6465 0.972 0.000 0.016 0.008 NA
#> SRR975600 3 0.4729 0.6214 0.024 0.000 0.748 0.048 NA
#> SRR975601 4 0.6426 0.0365 0.012 0.000 0.372 0.488 NA
#> SRR975602 1 0.4415 0.3318 0.552 0.000 0.444 0.000 NA
#> SRR975603 3 0.7369 0.1368 0.260 0.000 0.448 0.252 NA
#> SRR975604 4 0.5579 0.5144 0.172 0.000 0.084 0.700 NA
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR975551 1 0.1881 0.5889 0.924 0.000 0.004 0.004 0.052 0.016
#> SRR975552 1 0.1364 0.5855 0.944 0.000 0.004 0.004 0.048 0.000
#> SRR975554 1 0.2667 0.6179 0.852 0.000 0.000 0.000 0.020 0.128
#> SRR975553 2 0.0260 0.9576 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR975555 6 0.6268 0.3121 0.156 0.000 0.016 0.040 0.204 0.584
#> SRR975556 2 0.2730 0.9013 0.000 0.872 0.004 0.024 0.092 0.008
#> SRR975557 4 0.2932 0.9805 0.000 0.000 0.164 0.820 0.016 0.000
#> SRR975558 5 0.5491 0.2650 0.092 0.004 0.000 0.008 0.532 0.364
#> SRR975559 1 0.4253 0.4708 0.608 0.000 0.000 0.008 0.012 0.372
#> SRR975560 6 0.2078 0.6509 0.000 0.040 0.000 0.012 0.032 0.916
#> SRR975561 2 0.1297 0.9506 0.000 0.948 0.000 0.012 0.040 0.000
#> SRR975562 6 0.1908 0.6771 0.096 0.000 0.004 0.000 0.000 0.900
#> SRR975563 2 0.0363 0.9582 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR975564 5 0.6000 0.5786 0.332 0.000 0.004 0.004 0.476 0.184
#> SRR975565 1 0.2840 0.5413 0.872 0.000 0.008 0.032 0.080 0.008
#> SRR975566 1 0.2999 0.5846 0.840 0.000 0.000 0.000 0.112 0.048
#> SRR975567 1 0.5984 0.1980 0.600 0.000 0.004 0.112 0.228 0.056
#> SRR975568 5 0.3907 0.5186 0.408 0.000 0.004 0.000 0.588 0.000
#> SRR975569 2 0.2765 0.8751 0.000 0.876 0.016 0.044 0.064 0.000
#> SRR975570 2 0.0260 0.9560 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR975571 2 0.0260 0.9576 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR975572 2 0.0000 0.9573 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975573 2 0.0000 0.9573 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975574 2 0.0603 0.9574 0.000 0.980 0.000 0.004 0.016 0.000
#> SRR975575 2 0.0000 0.9573 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975576 2 0.1124 0.9527 0.000 0.956 0.000 0.008 0.036 0.000
#> SRR975577 2 0.1124 0.9527 0.000 0.956 0.000 0.008 0.036 0.000
#> SRR975578 2 0.1124 0.9527 0.000 0.956 0.000 0.008 0.036 0.000
#> SRR975579 4 0.2491 0.9805 0.000 0.000 0.164 0.836 0.000 0.000
#> SRR975580 6 0.3837 0.4700 0.000 0.224 0.000 0.016 0.016 0.744
#> SRR975581 2 0.1124 0.9527 0.000 0.956 0.000 0.008 0.036 0.000
#> SRR975582 2 0.1049 0.9535 0.000 0.960 0.000 0.008 0.032 0.000
#> SRR975583 2 0.0000 0.9573 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR975584 2 0.0622 0.9545 0.000 0.980 0.000 0.008 0.012 0.000
#> SRR975585 2 0.0146 0.9578 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR975586 2 0.3693 0.8066 0.000 0.800 0.000 0.016 0.136 0.048
#> SRR975587 1 0.0458 0.6010 0.984 0.000 0.016 0.000 0.000 0.000
#> SRR975588 2 0.3374 0.8345 0.000 0.836 0.024 0.048 0.092 0.000
#> SRR975589 1 0.5071 -0.1499 0.552 0.000 0.004 0.004 0.380 0.060
#> SRR975590 1 0.0972 0.6004 0.964 0.000 0.000 0.000 0.028 0.008
#> SRR975591 3 0.4225 0.6510 0.084 0.000 0.784 0.060 0.072 0.000
#> SRR975592 1 0.3062 0.5372 0.816 0.000 0.000 0.000 0.160 0.024
#> SRR975593 1 0.5408 0.4359 0.616 0.000 0.004 0.004 0.168 0.208
#> SRR975594 3 0.1204 0.5641 0.000 0.000 0.944 0.056 0.000 0.000
#> SRR975595 1 0.4227 0.1603 0.500 0.000 0.008 0.000 0.004 0.488
#> SRR975597 1 0.3895 0.5562 0.696 0.000 0.004 0.000 0.016 0.284
#> SRR975596 6 0.2211 0.6769 0.080 0.000 0.004 0.008 0.008 0.900
#> SRR975598 6 0.4118 0.0738 0.396 0.000 0.004 0.000 0.008 0.592
#> SRR975599 6 0.1862 0.6663 0.012 0.000 0.008 0.032 0.016 0.932
#> SRR975600 5 0.4273 0.5849 0.364 0.000 0.008 0.004 0.616 0.008
#> SRR975601 3 0.4000 0.5949 0.192 0.000 0.756 0.032 0.020 0.000
#> SRR975602 1 0.3738 0.5427 0.680 0.000 0.000 0.004 0.004 0.312
#> SRR975603 1 0.6950 0.1047 0.512 0.000 0.124 0.012 0.236 0.116
#> SRR975604 3 0.4668 0.6309 0.048 0.000 0.732 0.004 0.172 0.044
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