Date: 2019-12-25 23:33:09 CET, cola version: 1.3.2
Document is loading...
All available functions which can be applied to this res_list
object:
res_list
#> A 'ConsensusPartitionList' object with 24 methods.
#> On a matrix with 15291 rows and 53 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] 15291 53
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 | ||
---|---|---|---|---|---|---|
CV:pam | 5 | 1.000 | 1.000 | 1.000 | ** | 4 |
CV:NMF | 5 | 1.000 | 1.000 | 1.000 | ** | 4 |
ATC:hclust | 2 | 1.000 | 0.993 | 0.996 | ** | |
ATC:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
ATC:pam | 6 | 1.000 | 0.950 | 0.979 | ** | 2,5 |
ATC:mclust | 2 | 1.000 | 0.997 | 0.998 | ** | |
ATC:NMF | 2 | 1.000 | 0.999 | 1.000 | ** | |
MAD:NMF | 6 | 0.988 | 0.945 | 0.971 | ** | 3,4,5 |
SD:NMF | 6 | 0.981 | 0.935 | 0.967 | ** | 5 |
SD:mclust | 6 | 0.980 | 0.960 | 0.953 | ** | 5 |
SD:pam | 6 | 0.977 | 0.895 | 0.944 | ** | 2,4,5 |
MAD:pam | 6 | 0.977 | 0.960 | 0.945 | ** | 2,4,5 |
MAD:mclust | 6 | 0.976 | 0.949 | 0.941 | ** | 4,5 |
CV:hclust | 6 | 0.972 | 0.905 | 0.971 | ** | |
MAD:skmeans | 6 | 0.965 | 0.925 | 0.941 | ** | 2,4,5 |
CV:mclust | 6 | 0.955 | 0.888 | 0.943 | ** | 4,5 |
CV:skmeans | 6 | 0.954 | 0.836 | 0.922 | ** | 4,5 |
SD:skmeans | 6 | 0.953 | 0.935 | 0.948 | ** | 2,3,4,5 |
MAD:hclust | 2 | 0.939 | 0.967 | 0.969 | * | |
ATC:skmeans | 6 | 0.904 | 0.894 | 0.915 | * | 2,3,4 |
CV:kmeans | 5 | 0.815 | 0.962 | 0.853 | ||
MAD:kmeans | 5 | 0.789 | 0.940 | 0.889 | ||
SD:hclust | 2 | 0.649 | 0.919 | 0.875 | ||
SD:kmeans | 4 | 0.593 | 0.737 | 0.750 |
**: 1-PAC > 0.95, *: 1-PAC > 0.9
Cumulative distribution function curves of consensus matrix for all methods.
collect_plots(res_list, fun = plot_ecdf)
Consensus heatmaps for all methods. (What is a consensus heatmap?)
collect_plots(res_list, k = 2, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = consensus_heatmap, mc.cores = 4)
Membership heatmaps for all methods. (What is a membership heatmap?)
collect_plots(res_list, k = 2, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = membership_heatmap, mc.cores = 4)
Signature heatmaps for all methods. (What is a signature heatmap?)
Note in following heatmaps, rows are scaled.
collect_plots(res_list, k = 2, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 3, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 4, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 5, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 6, fun = get_signatures, mc.cores = 4)
The statistics used for measuring the stability of consensus partitioning. (How are they defined?)
get_stats(res_list, k = 2)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 2 0.780 0.860 0.943 0.4734 0.521 0.521
#> CV:NMF 2 0.704 0.803 0.924 0.4940 0.492 0.492
#> MAD:NMF 2 0.651 0.843 0.932 0.4799 0.512 0.512
#> ATC:NMF 2 1.000 0.999 1.000 0.3972 0.604 0.604
#> SD:skmeans 2 1.000 0.996 0.998 0.4804 0.521 0.521
#> CV:skmeans 2 0.683 0.914 0.951 0.4913 0.512 0.512
#> MAD:skmeans 2 1.000 0.999 0.999 0.4796 0.521 0.521
#> ATC:skmeans 2 1.000 0.997 0.999 0.4700 0.531 0.531
#> SD:mclust 2 0.265 0.742 0.824 0.4861 0.512 0.512
#> CV:mclust 2 0.505 0.904 0.919 0.4888 0.512 0.512
#> MAD:mclust 2 0.265 0.817 0.862 0.4895 0.512 0.512
#> ATC:mclust 2 1.000 0.997 0.998 0.4886 0.512 0.512
#> SD:kmeans 2 0.604 0.897 0.926 0.4342 0.556 0.556
#> CV:kmeans 2 0.191 0.671 0.781 0.4541 0.505 0.505
#> MAD:kmeans 2 0.641 0.915 0.941 0.4551 0.531 0.531
#> ATC:kmeans 2 1.000 1.000 1.000 0.3968 0.604 0.604
#> SD:pam 2 1.000 0.968 0.985 0.4161 0.586 0.586
#> CV:pam 2 0.331 0.655 0.825 0.4332 0.521 0.521
#> MAD:pam 2 0.926 0.931 0.968 0.4323 0.586 0.586
#> ATC:pam 2 0.960 0.923 0.971 0.4210 0.604 0.604
#> SD:hclust 2 0.649 0.919 0.875 0.4187 0.570 0.570
#> CV:hclust 2 0.509 0.913 0.936 0.0971 0.962 0.962
#> MAD:hclust 2 0.939 0.967 0.969 0.4342 0.570 0.570
#> ATC:hclust 2 1.000 0.993 0.996 0.3610 0.643 0.643
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 0.874 0.901 0.955 0.345 0.736 0.544
#> CV:NMF 3 0.883 0.913 0.960 0.310 0.795 0.612
#> MAD:NMF 3 0.937 0.909 0.961 0.332 0.762 0.574
#> ATC:NMF 3 0.647 0.929 0.913 0.587 0.703 0.519
#> SD:skmeans 3 1.000 0.958 0.976 0.346 0.833 0.680
#> CV:skmeans 3 0.827 0.957 0.961 0.322 0.840 0.688
#> MAD:skmeans 3 0.817 0.954 0.968 0.351 0.833 0.680
#> ATC:skmeans 3 1.000 0.981 0.982 0.350 0.837 0.693
#> SD:mclust 3 0.665 0.853 0.857 0.168 0.585 0.390
#> CV:mclust 3 0.753 0.964 0.976 0.183 0.585 0.390
#> MAD:mclust 3 0.665 0.915 0.907 0.161 0.585 0.390
#> ATC:mclust 3 0.802 0.805 0.806 0.336 0.814 0.637
#> SD:kmeans 3 0.501 0.640 0.758 0.442 0.724 0.550
#> CV:kmeans 3 0.436 0.764 0.760 0.369 0.817 0.649
#> MAD:kmeans 3 0.586 0.648 0.762 0.381 0.776 0.590
#> ATC:kmeans 3 0.670 0.853 0.912 0.613 0.679 0.492
#> SD:pam 3 0.632 0.645 0.841 0.562 0.764 0.598
#> CV:pam 3 0.651 0.738 0.841 0.470 0.819 0.663
#> MAD:pam 3 0.649 0.649 0.824 0.534 0.702 0.511
#> ATC:pam 3 0.781 0.841 0.937 0.499 0.692 0.519
#> SD:hclust 3 0.536 0.830 0.909 0.174 0.974 0.954
#> CV:hclust 3 0.328 0.741 0.865 1.480 0.963 0.962
#> MAD:hclust 3 0.689 0.832 0.910 0.190 0.974 0.954
#> ATC:hclust 3 0.663 0.820 0.745 0.663 0.736 0.589
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.860 0.901 0.927 0.1795 0.872 0.659
#> CV:NMF 4 0.984 0.951 0.952 0.1461 0.874 0.659
#> MAD:NMF 4 0.955 0.892 0.939 0.1734 0.856 0.621
#> ATC:NMF 4 0.549 0.798 0.821 0.1067 1.000 1.000
#> SD:skmeans 4 1.000 0.970 0.980 0.1512 0.882 0.674
#> CV:skmeans 4 1.000 0.980 0.975 0.1343 0.912 0.751
#> MAD:skmeans 4 1.000 0.969 0.978 0.1489 0.882 0.674
#> ATC:skmeans 4 0.909 0.927 0.928 0.1376 0.888 0.696
#> SD:mclust 4 0.850 0.920 0.949 0.2994 0.832 0.612
#> CV:mclust 4 1.000 1.000 1.000 0.2722 0.832 0.612
#> MAD:mclust 4 1.000 0.987 0.991 0.2968 0.832 0.612
#> ATC:mclust 4 0.793 0.838 0.847 0.0966 0.860 0.608
#> SD:kmeans 4 0.593 0.737 0.750 0.1517 0.861 0.655
#> CV:kmeans 4 0.587 0.786 0.594 0.1546 0.920 0.774
#> MAD:kmeans 4 0.580 0.691 0.720 0.1496 0.764 0.430
#> ATC:kmeans 4 0.681 0.754 0.785 0.1135 0.929 0.790
#> SD:pam 4 1.000 0.967 0.988 0.1609 0.837 0.569
#> CV:pam 4 0.938 0.939 0.968 0.1778 0.850 0.611
#> MAD:pam 4 1.000 0.959 0.985 0.1379 0.808 0.502
#> ATC:pam 4 0.740 0.538 0.695 0.1723 0.788 0.490
#> SD:hclust 4 0.562 0.806 0.871 0.1482 0.956 0.920
#> CV:hclust 4 0.474 0.734 0.866 1.2229 0.543 0.506
#> MAD:hclust 4 0.598 0.796 0.870 0.0463 0.989 0.980
#> ATC:hclust 4 0.655 0.763 0.862 0.0633 0.991 0.977
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 1.000 0.954 0.975 0.0847 0.895 0.608
#> CV:NMF 5 1.000 1.000 1.000 0.0988 0.912 0.669
#> MAD:NMF 5 0.973 0.938 0.960 0.0844 0.903 0.636
#> ATC:NMF 5 0.620 0.638 0.738 0.0782 0.861 0.612
#> SD:skmeans 5 1.000 0.984 0.992 0.0933 0.913 0.669
#> CV:skmeans 5 1.000 0.999 0.998 0.1060 0.920 0.699
#> MAD:skmeans 5 1.000 0.986 0.992 0.0932 0.913 0.669
#> ATC:skmeans 5 0.879 0.893 0.925 0.0812 0.936 0.754
#> SD:mclust 5 1.000 0.985 0.993 0.1043 0.920 0.699
#> CV:mclust 5 1.000 0.961 0.985 0.1062 0.922 0.704
#> MAD:mclust 5 1.000 0.974 0.990 0.1058 0.920 0.699
#> ATC:mclust 5 0.887 0.877 0.934 0.0837 0.980 0.918
#> SD:kmeans 5 0.696 0.933 0.872 0.0786 0.912 0.680
#> CV:kmeans 5 0.815 0.962 0.853 0.0697 0.912 0.678
#> MAD:kmeans 5 0.789 0.940 0.889 0.0843 0.919 0.690
#> ATC:kmeans 5 0.716 0.542 0.747 0.0805 0.832 0.518
#> SD:pam 5 1.000 0.997 0.998 0.0803 0.899 0.619
#> CV:pam 5 1.000 1.000 1.000 0.0866 0.894 0.606
#> MAD:pam 5 1.000 0.996 0.998 0.0801 0.903 0.633
#> ATC:pam 5 0.944 0.926 0.966 0.0940 0.898 0.625
#> SD:hclust 5 0.629 0.847 0.893 0.2169 0.811 0.623
#> CV:hclust 5 0.835 0.835 0.921 0.2116 0.920 0.829
#> MAD:hclust 5 0.697 0.869 0.935 0.2460 0.811 0.646
#> ATC:hclust 5 0.811 0.756 0.901 0.0775 0.869 0.674
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 0.981 0.935 0.967 0.02073 0.979 0.887
#> CV:NMF 6 0.988 0.962 0.968 0.01147 1.000 1.000
#> MAD:NMF 6 0.988 0.945 0.971 0.02469 0.979 0.887
#> ATC:NMF 6 0.602 0.759 0.763 0.05090 0.894 0.606
#> SD:skmeans 6 0.953 0.935 0.948 0.02630 0.968 0.833
#> CV:skmeans 6 0.954 0.836 0.922 0.02296 0.983 0.906
#> MAD:skmeans 6 0.965 0.925 0.941 0.02709 0.965 0.819
#> ATC:skmeans 6 0.904 0.894 0.915 0.04212 0.956 0.793
#> SD:mclust 6 0.980 0.960 0.953 0.02010 0.980 0.890
#> CV:mclust 6 0.955 0.888 0.943 0.01854 0.987 0.930
#> MAD:mclust 6 0.976 0.949 0.941 0.02044 0.980 0.890
#> ATC:mclust 6 0.812 0.732 0.836 0.04314 0.946 0.772
#> SD:kmeans 6 0.958 0.907 0.909 0.04912 1.000 1.000
#> CV:kmeans 6 0.787 0.935 0.887 0.04727 1.000 1.000
#> MAD:kmeans 6 0.897 0.912 0.908 0.03892 1.000 1.000
#> ATC:kmeans 6 0.821 0.821 0.854 0.05342 0.898 0.630
#> SD:pam 6 0.977 0.895 0.944 0.02140 0.985 0.922
#> CV:pam 6 1.000 0.981 1.000 0.00889 0.993 0.961
#> MAD:pam 6 0.977 0.960 0.945 0.02194 0.980 0.890
#> ATC:pam 6 1.000 0.950 0.979 0.03173 0.977 0.877
#> SD:hclust 6 0.726 0.689 0.794 0.09273 0.971 0.908
#> CV:hclust 6 0.972 0.905 0.971 0.16015 0.863 0.647
#> MAD:hclust 6 0.814 0.888 0.905 0.15391 0.880 0.653
#> ATC:hclust 6 0.817 0.801 0.916 0.07936 0.933 0.789
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 15291 rows and 53 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 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.649 0.919 0.875 0.4187 0.570 0.570
#> 3 3 0.536 0.830 0.909 0.1744 0.974 0.954
#> 4 4 0.562 0.806 0.871 0.1482 0.956 0.920
#> 5 5 0.629 0.847 0.893 0.2169 0.811 0.623
#> 6 6 0.726 0.689 0.794 0.0927 0.971 0.908
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
#> SRR805780 2 0.402 0.947 0.080 0.920
#> SRR805781 2 0.402 0.947 0.080 0.920
#> SRR805782 2 0.402 0.947 0.080 0.920
#> SRR805784 2 0.402 0.947 0.080 0.920
#> SRR805785 2 0.402 0.947 0.080 0.920
#> SRR805786 2 0.402 0.947 0.080 0.920
#> SRR805787 2 0.402 0.947 0.080 0.920
#> SRR805788 2 0.402 0.947 0.080 0.920
#> SRR805789 2 0.402 0.947 0.080 0.920
#> SRR805790 2 0.402 0.947 0.080 0.920
#> SRR805791 1 0.000 0.941 1.000 0.000
#> SRR805792 1 0.000 0.941 1.000 0.000
#> SRR805793 1 0.000 0.941 1.000 0.000
#> SRR805794 1 0.000 0.941 1.000 0.000
#> SRR805795 1 0.000 0.941 1.000 0.000
#> SRR805796 1 0.000 0.941 1.000 0.000
#> SRR805797 1 0.000 0.941 1.000 0.000
#> SRR805798 1 0.000 0.941 1.000 0.000
#> SRR805799 1 0.402 0.916 0.920 0.080
#> SRR805800 1 0.000 0.941 1.000 0.000
#> SRR805801 1 0.000 0.941 1.000 0.000
#> SRR805802 2 0.802 0.812 0.244 0.756
#> SRR805803 2 0.402 0.947 0.080 0.920
#> SRR805804 2 0.402 0.947 0.080 0.920
#> SRR805805 2 0.802 0.812 0.244 0.756
#> SRR805806 1 0.443 0.888 0.908 0.092
#> SRR805807 1 0.141 0.937 0.980 0.020
#> SRR805808 2 0.861 0.757 0.284 0.716
#> SRR805809 2 0.795 0.817 0.240 0.760
#> SRR805810 1 0.373 0.905 0.928 0.072
#> SRR805811 1 0.373 0.905 0.928 0.072
#> SRR805812 1 0.552 0.844 0.872 0.128
#> SRR805813 1 0.402 0.916 0.920 0.080
#> SRR805814 1 0.402 0.916 0.920 0.080
#> SRR805815 1 0.402 0.916 0.920 0.080
#> SRR805816 1 0.402 0.916 0.920 0.080
#> SRR805817 1 0.402 0.916 0.920 0.080
#> SRR805818 1 0.402 0.916 0.920 0.080
#> SRR805819 1 0.402 0.916 0.920 0.080
#> SRR805820 1 0.402 0.916 0.920 0.080
#> SRR805821 1 0.402 0.916 0.920 0.080
#> SRR805822 1 0.402 0.916 0.920 0.080
#> SRR805823 1 0.402 0.916 0.920 0.080
#> SRR805824 1 0.278 0.929 0.952 0.048
#> SRR805825 1 0.278 0.929 0.952 0.048
#> SRR805826 1 0.278 0.929 0.952 0.048
#> SRR805828 1 0.278 0.929 0.952 0.048
#> SRR805829 1 0.278 0.929 0.952 0.048
#> SRR805830 1 0.278 0.929 0.952 0.048
#> SRR805831 1 0.278 0.929 0.952 0.048
#> SRR805832 1 0.278 0.929 0.952 0.048
#> SRR805833 1 0.278 0.929 0.952 0.048
#> SRR805834 1 0.278 0.929 0.952 0.048
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.000 0.886 0.000 1.000 0.000
#> SRR805781 2 0.000 0.886 0.000 1.000 0.000
#> SRR805782 2 0.000 0.886 0.000 1.000 0.000
#> SRR805784 2 0.000 0.886 0.000 1.000 0.000
#> SRR805785 2 0.000 0.886 0.000 1.000 0.000
#> SRR805786 2 0.000 0.886 0.000 1.000 0.000
#> SRR805787 2 0.000 0.886 0.000 1.000 0.000
#> SRR805788 2 0.000 0.886 0.000 1.000 0.000
#> SRR805789 2 0.000 0.886 0.000 1.000 0.000
#> SRR805790 2 0.000 0.886 0.000 1.000 0.000
#> SRR805791 1 0.000 0.891 1.000 0.000 0.000
#> SRR805792 1 0.000 0.891 1.000 0.000 0.000
#> SRR805793 1 0.000 0.891 1.000 0.000 0.000
#> SRR805794 1 0.000 0.891 1.000 0.000 0.000
#> SRR805795 1 0.000 0.891 1.000 0.000 0.000
#> SRR805796 1 0.000 0.891 1.000 0.000 0.000
#> SRR805797 1 0.000 0.891 1.000 0.000 0.000
#> SRR805798 1 0.000 0.891 1.000 0.000 0.000
#> SRR805799 3 0.369 0.000 0.140 0.000 0.860
#> SRR805800 1 0.000 0.891 1.000 0.000 0.000
#> SRR805801 1 0.000 0.891 1.000 0.000 0.000
#> SRR805802 2 0.572 0.619 0.240 0.744 0.016
#> SRR805803 2 0.000 0.886 0.000 1.000 0.000
#> SRR805804 2 0.000 0.886 0.000 1.000 0.000
#> SRR805805 2 0.572 0.619 0.240 0.744 0.016
#> SRR805806 1 0.327 0.842 0.904 0.080 0.016
#> SRR805807 1 0.117 0.886 0.976 0.008 0.016
#> SRR805808 2 0.610 0.545 0.280 0.704 0.016
#> SRR805809 2 0.560 0.633 0.228 0.756 0.016
#> SRR805810 1 0.280 0.857 0.924 0.060 0.016
#> SRR805811 1 0.280 0.857 0.924 0.060 0.016
#> SRR805812 1 0.400 0.800 0.868 0.116 0.016
#> SRR805813 1 0.319 0.849 0.888 0.000 0.112
#> SRR805814 1 0.319 0.849 0.888 0.000 0.112
#> SRR805815 1 0.319 0.849 0.888 0.000 0.112
#> SRR805816 1 0.319 0.849 0.888 0.000 0.112
#> SRR805817 1 0.319 0.849 0.888 0.000 0.112
#> SRR805818 1 0.319 0.849 0.888 0.000 0.112
#> SRR805819 1 0.319 0.849 0.888 0.000 0.112
#> SRR805820 1 0.319 0.849 0.888 0.000 0.112
#> SRR805821 1 0.319 0.849 0.888 0.000 0.112
#> SRR805822 1 0.319 0.849 0.888 0.000 0.112
#> SRR805823 1 0.319 0.849 0.888 0.000 0.112
#> SRR805824 1 0.369 0.844 0.860 0.000 0.140
#> SRR805825 1 0.369 0.844 0.860 0.000 0.140
#> SRR805826 1 0.369 0.844 0.860 0.000 0.140
#> SRR805828 1 0.369 0.844 0.860 0.000 0.140
#> SRR805829 1 0.369 0.844 0.860 0.000 0.140
#> SRR805830 1 0.369 0.844 0.860 0.000 0.140
#> SRR805831 1 0.369 0.844 0.860 0.000 0.140
#> SRR805832 1 0.369 0.844 0.860 0.000 0.140
#> SRR805833 1 0.369 0.844 0.860 0.000 0.140
#> SRR805834 1 0.369 0.844 0.860 0.000 0.140
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.000 0.984 0.000 1.000 0.000 0.000
#> SRR805781 2 0.000 0.984 0.000 1.000 0.000 0.000
#> SRR805782 2 0.000 0.984 0.000 1.000 0.000 0.000
#> SRR805784 2 0.265 0.847 0.000 0.880 0.120 0.000
#> SRR805785 2 0.000 0.984 0.000 1.000 0.000 0.000
#> SRR805786 2 0.000 0.984 0.000 1.000 0.000 0.000
#> SRR805787 2 0.000 0.984 0.000 1.000 0.000 0.000
#> SRR805788 2 0.000 0.984 0.000 1.000 0.000 0.000
#> SRR805789 2 0.000 0.984 0.000 1.000 0.000 0.000
#> SRR805790 2 0.000 0.984 0.000 1.000 0.000 0.000
#> SRR805791 4 0.112 0.854 0.000 0.000 0.036 0.964
#> SRR805792 4 0.112 0.854 0.000 0.000 0.036 0.964
#> SRR805793 4 0.112 0.854 0.000 0.000 0.036 0.964
#> SRR805794 4 0.112 0.854 0.000 0.000 0.036 0.964
#> SRR805795 4 0.112 0.854 0.000 0.000 0.036 0.964
#> SRR805796 4 0.112 0.854 0.000 0.000 0.036 0.964
#> SRR805797 4 0.112 0.854 0.000 0.000 0.036 0.964
#> SRR805798 4 0.112 0.854 0.000 0.000 0.036 0.964
#> SRR805799 1 0.368 0.000 0.856 0.000 0.060 0.084
#> SRR805800 4 0.112 0.854 0.000 0.000 0.036 0.964
#> SRR805801 4 0.112 0.854 0.000 0.000 0.036 0.964
#> SRR805802 3 0.305 0.763 0.000 0.116 0.872 0.012
#> SRR805803 3 0.492 0.511 0.000 0.424 0.576 0.000
#> SRR805804 3 0.492 0.511 0.000 0.424 0.576 0.000
#> SRR805805 3 0.305 0.763 0.000 0.116 0.872 0.012
#> SRR805806 4 0.508 0.626 0.000 0.020 0.304 0.676
#> SRR805807 4 0.394 0.724 0.000 0.000 0.236 0.764
#> SRR805808 3 0.372 0.700 0.000 0.096 0.852 0.052
#> SRR805809 3 0.322 0.764 0.000 0.128 0.860 0.012
#> SRR805810 4 0.443 0.646 0.000 0.000 0.304 0.696
#> SRR805811 4 0.443 0.646 0.000 0.000 0.304 0.696
#> SRR805812 4 0.527 0.566 0.000 0.020 0.340 0.640
#> SRR805813 4 0.247 0.836 0.108 0.000 0.000 0.892
#> SRR805814 4 0.247 0.836 0.108 0.000 0.000 0.892
#> SRR805815 4 0.247 0.836 0.108 0.000 0.000 0.892
#> SRR805816 4 0.247 0.836 0.108 0.000 0.000 0.892
#> SRR805817 4 0.247 0.836 0.108 0.000 0.000 0.892
#> SRR805818 4 0.247 0.836 0.108 0.000 0.000 0.892
#> SRR805819 4 0.247 0.836 0.108 0.000 0.000 0.892
#> SRR805820 4 0.247 0.836 0.108 0.000 0.000 0.892
#> SRR805821 4 0.247 0.836 0.108 0.000 0.000 0.892
#> SRR805822 4 0.247 0.836 0.108 0.000 0.000 0.892
#> SRR805823 4 0.247 0.836 0.108 0.000 0.000 0.892
#> SRR805824 4 0.297 0.808 0.144 0.000 0.000 0.856
#> SRR805825 4 0.297 0.808 0.144 0.000 0.000 0.856
#> SRR805826 4 0.297 0.808 0.144 0.000 0.000 0.856
#> SRR805828 4 0.297 0.808 0.144 0.000 0.000 0.856
#> SRR805829 4 0.297 0.808 0.144 0.000 0.000 0.856
#> SRR805830 4 0.297 0.808 0.144 0.000 0.000 0.856
#> SRR805831 4 0.297 0.808 0.144 0.000 0.000 0.856
#> SRR805832 4 0.297 0.808 0.144 0.000 0.000 0.856
#> SRR805833 4 0.297 0.808 0.144 0.000 0.000 0.856
#> SRR805834 4 0.297 0.808 0.144 0.000 0.000 0.856
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR805781 2 0.000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR805782 2 0.000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR805784 2 0.456 0.714 0.016 0.776 0.100 0.000 0.108
#> SRR805785 2 0.000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR805786 2 0.000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR805787 2 0.000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR805788 2 0.000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR805789 2 0.000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR805790 2 0.000 0.973 0.000 1.000 0.000 0.000 0.000
#> SRR805791 4 0.254 0.850 0.000 0.000 0.128 0.868 0.004
#> SRR805792 4 0.254 0.850 0.000 0.000 0.128 0.868 0.004
#> SRR805793 4 0.254 0.850 0.000 0.000 0.128 0.868 0.004
#> SRR805794 4 0.254 0.850 0.000 0.000 0.128 0.868 0.004
#> SRR805795 4 0.254 0.850 0.000 0.000 0.128 0.868 0.004
#> SRR805796 4 0.254 0.850 0.000 0.000 0.128 0.868 0.004
#> SRR805797 4 0.254 0.850 0.000 0.000 0.128 0.868 0.004
#> SRR805798 4 0.254 0.850 0.000 0.000 0.128 0.868 0.004
#> SRR805799 1 0.051 0.000 0.984 0.000 0.000 0.016 0.000
#> SRR805800 4 0.254 0.850 0.000 0.000 0.128 0.868 0.004
#> SRR805801 4 0.254 0.850 0.000 0.000 0.128 0.868 0.004
#> SRR805802 5 0.245 0.761 0.000 0.056 0.000 0.044 0.900
#> SRR805803 5 0.407 0.552 0.000 0.364 0.000 0.000 0.636
#> SRR805804 5 0.407 0.552 0.000 0.364 0.000 0.000 0.636
#> SRR805805 5 0.245 0.761 0.000 0.056 0.000 0.044 0.900
#> SRR805806 4 0.375 0.657 0.000 0.000 0.000 0.708 0.292
#> SRR805807 4 0.376 0.754 0.000 0.000 0.016 0.764 0.220
#> SRR805808 5 0.289 0.711 0.000 0.044 0.000 0.084 0.872
#> SRR805809 5 0.265 0.761 0.000 0.068 0.000 0.044 0.888
#> SRR805810 4 0.364 0.682 0.000 0.000 0.000 0.728 0.272
#> SRR805811 4 0.364 0.682 0.000 0.000 0.000 0.728 0.272
#> SRR805812 4 0.393 0.606 0.000 0.000 0.000 0.672 0.328
#> SRR805813 4 0.112 0.860 0.000 0.000 0.044 0.956 0.000
#> SRR805814 4 0.112 0.860 0.000 0.000 0.044 0.956 0.000
#> SRR805815 4 0.112 0.860 0.000 0.000 0.044 0.956 0.000
#> SRR805816 4 0.112 0.860 0.000 0.000 0.044 0.956 0.000
#> SRR805817 4 0.112 0.860 0.000 0.000 0.044 0.956 0.000
#> SRR805818 4 0.112 0.860 0.000 0.000 0.044 0.956 0.000
#> SRR805819 4 0.112 0.860 0.000 0.000 0.044 0.956 0.000
#> SRR805820 4 0.112 0.860 0.000 0.000 0.044 0.956 0.000
#> SRR805821 4 0.112 0.860 0.000 0.000 0.044 0.956 0.000
#> SRR805822 4 0.112 0.860 0.000 0.000 0.044 0.956 0.000
#> SRR805823 4 0.112 0.860 0.000 0.000 0.044 0.956 0.000
#> SRR805824 3 0.202 1.000 0.000 0.000 0.900 0.100 0.000
#> SRR805825 3 0.202 1.000 0.000 0.000 0.900 0.100 0.000
#> SRR805826 3 0.202 1.000 0.000 0.000 0.900 0.100 0.000
#> SRR805828 3 0.202 1.000 0.000 0.000 0.900 0.100 0.000
#> SRR805829 3 0.202 1.000 0.000 0.000 0.900 0.100 0.000
#> SRR805830 3 0.202 1.000 0.000 0.000 0.900 0.100 0.000
#> SRR805831 3 0.202 1.000 0.000 0.000 0.900 0.100 0.000
#> SRR805832 3 0.202 1.000 0.000 0.000 0.900 0.100 0.000
#> SRR805833 3 0.202 1.000 0.000 0.000 0.900 0.100 0.000
#> SRR805834 3 0.202 1.000 0.000 0.000 0.900 0.100 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805781 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805782 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805784 6 0.3592 0.000 0.000 0.344 0.000 0.000 0.000 0.656
#> SRR805785 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805786 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805787 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805788 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805789 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805790 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805791 4 0.6250 0.646 0.332 0.000 0.132 0.492 0.044 0.000
#> SRR805792 4 0.6250 0.646 0.332 0.000 0.132 0.492 0.044 0.000
#> SRR805793 4 0.6250 0.646 0.332 0.000 0.132 0.492 0.044 0.000
#> SRR805794 4 0.6250 0.646 0.332 0.000 0.132 0.492 0.044 0.000
#> SRR805795 4 0.6250 0.646 0.332 0.000 0.132 0.492 0.044 0.000
#> SRR805796 4 0.6250 0.646 0.332 0.000 0.132 0.492 0.044 0.000
#> SRR805797 4 0.6250 0.646 0.332 0.000 0.132 0.492 0.044 0.000
#> SRR805798 4 0.6250 0.646 0.332 0.000 0.132 0.492 0.044 0.000
#> SRR805799 1 0.3758 0.000 0.668 0.000 0.000 0.000 0.008 0.324
#> SRR805800 4 0.6250 0.646 0.332 0.000 0.132 0.492 0.044 0.000
#> SRR805801 4 0.6250 0.646 0.332 0.000 0.132 0.492 0.044 0.000
#> SRR805802 5 0.0405 0.602 0.004 0.008 0.000 0.000 0.988 0.000
#> SRR805803 5 0.3916 0.316 0.000 0.300 0.000 0.000 0.680 0.020
#> SRR805804 5 0.3916 0.316 0.000 0.300 0.000 0.000 0.680 0.020
#> SRR805805 5 0.0405 0.602 0.004 0.008 0.000 0.000 0.988 0.000
#> SRR805806 4 0.6123 0.375 0.312 0.000 0.000 0.356 0.332 0.000
#> SRR805807 4 0.5994 0.486 0.332 0.000 0.000 0.424 0.244 0.000
#> SRR805808 5 0.1176 0.576 0.024 0.000 0.000 0.020 0.956 0.000
#> SRR805809 5 0.0603 0.599 0.000 0.016 0.000 0.000 0.980 0.004
#> SRR805810 4 0.6123 0.398 0.332 0.000 0.000 0.356 0.312 0.000
#> SRR805811 4 0.6123 0.398 0.332 0.000 0.000 0.356 0.312 0.000
#> SRR805812 5 0.6116 -0.419 0.312 0.000 0.000 0.320 0.368 0.000
#> SRR805813 4 0.0000 0.617 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805814 4 0.0000 0.617 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805815 4 0.0000 0.617 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805816 4 0.0000 0.617 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805817 4 0.0000 0.617 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805818 4 0.0000 0.617 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805819 4 0.0000 0.617 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805820 4 0.0000 0.617 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805821 4 0.0000 0.617 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805822 4 0.0000 0.617 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805823 4 0.0000 0.617 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805834 3 0.0000 1.000 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", "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 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 4.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.604 0.897 0.926 0.4342 0.556 0.556
#> 3 3 0.501 0.640 0.758 0.4416 0.724 0.550
#> 4 4 0.593 0.737 0.750 0.1517 0.861 0.655
#> 5 5 0.696 0.933 0.872 0.0786 0.912 0.680
#> 6 6 0.958 0.907 0.909 0.0491 1.000 1.000
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.0938 0.948 0.012 0.988
#> SRR805781 2 0.0938 0.948 0.012 0.988
#> SRR805782 2 0.0938 0.948 0.012 0.988
#> SRR805784 2 0.0938 0.948 0.012 0.988
#> SRR805785 2 0.0938 0.948 0.012 0.988
#> SRR805786 2 0.0938 0.948 0.012 0.988
#> SRR805787 2 0.0938 0.948 0.012 0.988
#> SRR805788 2 0.0938 0.948 0.012 0.988
#> SRR805789 2 0.0938 0.948 0.012 0.988
#> SRR805790 2 0.0938 0.948 0.012 0.988
#> SRR805791 1 0.2948 0.937 0.948 0.052
#> SRR805792 1 0.2948 0.937 0.948 0.052
#> SRR805793 1 0.2948 0.937 0.948 0.052
#> SRR805794 1 0.2948 0.937 0.948 0.052
#> SRR805795 1 0.2948 0.937 0.948 0.052
#> SRR805796 1 0.2948 0.937 0.948 0.052
#> SRR805797 1 0.2948 0.937 0.948 0.052
#> SRR805798 1 0.2948 0.937 0.948 0.052
#> SRR805799 1 0.3431 0.929 0.936 0.064
#> SRR805800 1 0.2948 0.937 0.948 0.052
#> SRR805801 1 0.2948 0.937 0.948 0.052
#> SRR805802 2 0.6973 0.756 0.188 0.812
#> SRR805803 2 0.0938 0.948 0.012 0.988
#> SRR805804 2 0.0938 0.948 0.012 0.988
#> SRR805805 2 0.0938 0.948 0.012 0.988
#> SRR805806 1 0.9732 0.444 0.596 0.404
#> SRR805807 1 0.2948 0.937 0.948 0.052
#> SRR805808 2 0.8443 0.613 0.272 0.728
#> SRR805809 2 0.0938 0.948 0.012 0.988
#> SRR805810 1 0.7950 0.770 0.760 0.240
#> SRR805811 1 0.7883 0.774 0.764 0.236
#> SRR805812 2 0.8443 0.613 0.272 0.728
#> SRR805813 1 0.2948 0.937 0.948 0.052
#> SRR805814 1 0.2948 0.937 0.948 0.052
#> SRR805815 1 0.2948 0.937 0.948 0.052
#> SRR805816 1 0.2948 0.937 0.948 0.052
#> SRR805817 1 0.2948 0.937 0.948 0.052
#> SRR805818 1 0.2948 0.937 0.948 0.052
#> SRR805819 1 0.2948 0.937 0.948 0.052
#> SRR805820 1 0.2948 0.937 0.948 0.052
#> SRR805821 1 0.2948 0.937 0.948 0.052
#> SRR805822 1 0.2948 0.937 0.948 0.052
#> SRR805823 1 0.2948 0.937 0.948 0.052
#> SRR805824 1 0.0000 0.905 1.000 0.000
#> SRR805825 1 0.4690 0.873 0.900 0.100
#> SRR805826 1 0.4690 0.873 0.900 0.100
#> SRR805828 1 0.4690 0.873 0.900 0.100
#> SRR805829 1 0.4690 0.873 0.900 0.100
#> SRR805830 1 0.4690 0.873 0.900 0.100
#> SRR805831 1 0.4690 0.873 0.900 0.100
#> SRR805832 1 0.4690 0.873 0.900 0.100
#> SRR805833 1 0.4690 0.873 0.900 0.100
#> SRR805834 1 0.4690 0.873 0.900 0.100
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.0000 0.937 0.000 1.000 0.000
#> SRR805781 2 0.0000 0.937 0.000 1.000 0.000
#> SRR805782 2 0.0000 0.937 0.000 1.000 0.000
#> SRR805784 2 0.0237 0.935 0.000 0.996 0.004
#> SRR805785 2 0.0000 0.937 0.000 1.000 0.000
#> SRR805786 2 0.0000 0.937 0.000 1.000 0.000
#> SRR805787 2 0.0000 0.937 0.000 1.000 0.000
#> SRR805788 2 0.0000 0.937 0.000 1.000 0.000
#> SRR805789 2 0.0000 0.937 0.000 1.000 0.000
#> SRR805790 2 0.0000 0.937 0.000 1.000 0.000
#> SRR805791 1 0.1753 0.482 0.952 0.000 0.048
#> SRR805792 1 0.1753 0.482 0.952 0.000 0.048
#> SRR805793 1 0.1753 0.482 0.952 0.000 0.048
#> SRR805794 1 0.1753 0.482 0.952 0.000 0.048
#> SRR805795 1 0.0000 0.517 1.000 0.000 0.000
#> SRR805796 1 0.0000 0.517 1.000 0.000 0.000
#> SRR805797 1 0.0000 0.517 1.000 0.000 0.000
#> SRR805798 1 0.0000 0.517 1.000 0.000 0.000
#> SRR805799 1 0.2878 0.518 0.904 0.000 0.096
#> SRR805800 1 0.0000 0.517 1.000 0.000 0.000
#> SRR805801 1 0.0000 0.517 1.000 0.000 0.000
#> SRR805802 1 0.9700 0.116 0.448 0.312 0.240
#> SRR805803 2 0.2711 0.895 0.000 0.912 0.088
#> SRR805804 2 0.2711 0.895 0.000 0.912 0.088
#> SRR805805 2 0.7902 0.660 0.132 0.660 0.208
#> SRR805806 1 0.8987 0.354 0.560 0.192 0.248
#> SRR805807 1 0.5098 0.487 0.752 0.000 0.248
#> SRR805808 1 0.9135 0.341 0.544 0.208 0.248
#> SRR805809 2 0.7902 0.660 0.132 0.660 0.208
#> SRR805810 1 0.8441 0.385 0.608 0.144 0.248
#> SRR805811 1 0.8132 0.401 0.612 0.104 0.284
#> SRR805812 1 0.9135 0.341 0.544 0.208 0.248
#> SRR805813 1 0.6291 0.329 0.532 0.000 0.468
#> SRR805814 1 0.6291 0.329 0.532 0.000 0.468
#> SRR805815 1 0.6291 0.329 0.532 0.000 0.468
#> SRR805816 1 0.6291 0.329 0.532 0.000 0.468
#> SRR805817 1 0.6291 0.329 0.532 0.000 0.468
#> SRR805818 1 0.6291 0.329 0.532 0.000 0.468
#> SRR805819 1 0.6291 0.329 0.532 0.000 0.468
#> SRR805820 1 0.6291 0.329 0.532 0.000 0.468
#> SRR805821 1 0.6291 0.329 0.532 0.000 0.468
#> SRR805822 1 0.6291 0.329 0.532 0.000 0.468
#> SRR805823 1 0.6291 0.329 0.532 0.000 0.468
#> SRR805824 3 0.7209 0.927 0.360 0.036 0.604
#> SRR805825 3 0.7962 0.992 0.352 0.072 0.576
#> SRR805826 3 0.7962 0.992 0.352 0.072 0.576
#> SRR805828 3 0.7962 0.992 0.352 0.072 0.576
#> SRR805829 3 0.7962 0.992 0.352 0.072 0.576
#> SRR805830 3 0.7962 0.992 0.352 0.072 0.576
#> SRR805831 3 0.7962 0.992 0.352 0.072 0.576
#> SRR805832 3 0.7962 0.992 0.352 0.072 0.576
#> SRR805833 3 0.7962 0.992 0.352 0.072 0.576
#> SRR805834 3 0.7962 0.992 0.352 0.072 0.576
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.000 0.943 0.000 1.000 0.000 0.000
#> SRR805781 2 0.000 0.943 0.000 1.000 0.000 0.000
#> SRR805782 2 0.000 0.943 0.000 1.000 0.000 0.000
#> SRR805784 2 0.151 0.915 0.008 0.960 0.020 0.012
#> SRR805785 2 0.000 0.943 0.000 1.000 0.000 0.000
#> SRR805786 2 0.000 0.943 0.000 1.000 0.000 0.000
#> SRR805787 2 0.000 0.943 0.000 1.000 0.000 0.000
#> SRR805788 2 0.000 0.943 0.000 1.000 0.000 0.000
#> SRR805789 2 0.000 0.943 0.000 1.000 0.000 0.000
#> SRR805790 2 0.000 0.943 0.000 1.000 0.000 0.000
#> SRR805791 1 0.725 0.479 0.472 0.000 0.148 0.380
#> SRR805792 1 0.725 0.479 0.472 0.000 0.148 0.380
#> SRR805793 1 0.725 0.479 0.472 0.000 0.148 0.380
#> SRR805794 1 0.725 0.479 0.472 0.000 0.148 0.380
#> SRR805795 1 0.694 0.516 0.520 0.000 0.120 0.360
#> SRR805796 1 0.694 0.516 0.520 0.000 0.120 0.360
#> SRR805797 1 0.694 0.516 0.520 0.000 0.120 0.360
#> SRR805798 1 0.694 0.516 0.520 0.000 0.120 0.360
#> SRR805799 1 0.671 0.464 0.508 0.000 0.092 0.400
#> SRR805800 1 0.694 0.516 0.520 0.000 0.120 0.360
#> SRR805801 1 0.694 0.516 0.520 0.000 0.120 0.360
#> SRR805802 4 0.543 0.838 0.044 0.156 0.036 0.764
#> SRR805803 2 0.447 0.656 0.000 0.760 0.020 0.220
#> SRR805804 2 0.451 0.648 0.000 0.756 0.020 0.224
#> SRR805805 4 0.558 0.559 0.000 0.348 0.032 0.620
#> SRR805806 4 0.554 0.860 0.076 0.124 0.032 0.768
#> SRR805807 4 0.490 0.552 0.236 0.000 0.032 0.732
#> SRR805808 4 0.552 0.860 0.072 0.128 0.032 0.768
#> SRR805809 4 0.558 0.559 0.000 0.348 0.032 0.620
#> SRR805810 4 0.550 0.857 0.080 0.116 0.032 0.772
#> SRR805811 4 0.553 0.823 0.112 0.080 0.036 0.772
#> SRR805812 4 0.552 0.860 0.072 0.128 0.032 0.768
#> SRR805813 1 0.336 0.559 0.824 0.000 0.176 0.000
#> SRR805814 1 0.336 0.559 0.824 0.000 0.176 0.000
#> SRR805815 1 0.336 0.559 0.824 0.000 0.176 0.000
#> SRR805816 1 0.336 0.559 0.824 0.000 0.176 0.000
#> SRR805817 1 0.336 0.559 0.824 0.000 0.176 0.000
#> SRR805818 1 0.336 0.559 0.824 0.000 0.176 0.000
#> SRR805819 1 0.336 0.559 0.824 0.000 0.176 0.000
#> SRR805820 1 0.336 0.559 0.824 0.000 0.176 0.000
#> SRR805821 1 0.336 0.559 0.824 0.000 0.176 0.000
#> SRR805822 1 0.336 0.559 0.824 0.000 0.176 0.000
#> SRR805823 1 0.336 0.559 0.824 0.000 0.176 0.000
#> SRR805824 3 0.199 0.994 0.052 0.008 0.936 0.004
#> SRR805825 3 0.214 0.994 0.052 0.008 0.932 0.008
#> SRR805826 3 0.181 0.995 0.052 0.008 0.940 0.000
#> SRR805828 3 0.181 0.995 0.052 0.008 0.940 0.000
#> SRR805829 3 0.181 0.995 0.052 0.008 0.940 0.000
#> SRR805830 3 0.181 0.995 0.052 0.008 0.940 0.000
#> SRR805831 3 0.199 0.995 0.052 0.008 0.936 0.004
#> SRR805832 3 0.227 0.994 0.052 0.008 0.928 0.012
#> SRR805833 3 0.227 0.994 0.052 0.008 0.928 0.012
#> SRR805834 3 0.227 0.994 0.052 0.008 0.928 0.012
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.0000 0.926 0.000 1.000 0.000 0.000 0.000
#> SRR805781 2 0.0000 0.926 0.000 1.000 0.000 0.000 0.000
#> SRR805782 2 0.0000 0.926 0.000 1.000 0.000 0.000 0.000
#> SRR805784 2 0.3003 0.851 0.064 0.880 0.016 0.000 0.040
#> SRR805785 2 0.0000 0.926 0.000 1.000 0.000 0.000 0.000
#> SRR805786 2 0.0000 0.926 0.000 1.000 0.000 0.000 0.000
#> SRR805787 2 0.0000 0.926 0.000 1.000 0.000 0.000 0.000
#> SRR805788 2 0.0000 0.926 0.000 1.000 0.000 0.000 0.000
#> SRR805789 2 0.0000 0.926 0.000 1.000 0.000 0.000 0.000
#> SRR805790 2 0.0000 0.926 0.000 1.000 0.000 0.000 0.000
#> SRR805791 1 0.5054 0.943 0.744 0.000 0.084 0.140 0.032
#> SRR805792 1 0.5054 0.943 0.744 0.000 0.084 0.140 0.032
#> SRR805793 1 0.5054 0.943 0.744 0.000 0.084 0.140 0.032
#> SRR805794 1 0.5054 0.943 0.744 0.000 0.084 0.140 0.032
#> SRR805795 1 0.4385 0.956 0.752 0.000 0.068 0.180 0.000
#> SRR805796 1 0.4385 0.956 0.752 0.000 0.068 0.180 0.000
#> SRR805797 1 0.4385 0.956 0.752 0.000 0.068 0.180 0.000
#> SRR805798 1 0.4385 0.956 0.752 0.000 0.068 0.180 0.000
#> SRR805799 1 0.5436 0.789 0.728 0.000 0.068 0.124 0.080
#> SRR805800 1 0.4385 0.956 0.752 0.000 0.068 0.180 0.000
#> SRR805801 1 0.4385 0.956 0.752 0.000 0.068 0.180 0.000
#> SRR805802 5 0.4199 0.930 0.156 0.044 0.008 0.004 0.788
#> SRR805803 2 0.6123 0.558 0.076 0.640 0.060 0.000 0.224
#> SRR805804 2 0.6148 0.550 0.076 0.636 0.060 0.000 0.228
#> SRR805805 5 0.4540 0.826 0.076 0.144 0.012 0.000 0.768
#> SRR805806 5 0.3887 0.935 0.148 0.040 0.000 0.008 0.804
#> SRR805807 5 0.4114 0.868 0.164 0.000 0.000 0.060 0.776
#> SRR805808 5 0.3887 0.935 0.148 0.040 0.000 0.008 0.804
#> SRR805809 5 0.4504 0.814 0.068 0.152 0.012 0.000 0.768
#> SRR805810 5 0.3853 0.933 0.152 0.036 0.000 0.008 0.804
#> SRR805811 5 0.3902 0.918 0.152 0.016 0.000 0.028 0.804
#> SRR805812 5 0.3887 0.935 0.148 0.040 0.000 0.008 0.804
#> SRR805813 4 0.0000 0.994 0.000 0.000 0.000 1.000 0.000
#> SRR805814 4 0.0880 0.977 0.000 0.000 0.000 0.968 0.032
#> SRR805815 4 0.0404 0.988 0.000 0.000 0.000 0.988 0.012
#> SRR805816 4 0.0880 0.977 0.000 0.000 0.000 0.968 0.032
#> SRR805817 4 0.0000 0.994 0.000 0.000 0.000 1.000 0.000
#> SRR805818 4 0.0000 0.994 0.000 0.000 0.000 1.000 0.000
#> SRR805819 4 0.0000 0.994 0.000 0.000 0.000 1.000 0.000
#> SRR805820 4 0.0000 0.994 0.000 0.000 0.000 1.000 0.000
#> SRR805821 4 0.0000 0.994 0.000 0.000 0.000 1.000 0.000
#> SRR805822 4 0.0000 0.994 0.000 0.000 0.000 1.000 0.000
#> SRR805823 4 0.0000 0.994 0.000 0.000 0.000 1.000 0.000
#> SRR805824 3 0.3313 0.965 0.012 0.004 0.856 0.104 0.024
#> SRR805825 3 0.2858 0.987 0.012 0.008 0.876 0.100 0.004
#> SRR805826 3 0.2463 0.988 0.004 0.008 0.888 0.100 0.000
#> SRR805828 3 0.2304 0.987 0.000 0.008 0.892 0.100 0.000
#> SRR805829 3 0.2304 0.987 0.000 0.008 0.892 0.100 0.000
#> SRR805830 3 0.2304 0.987 0.000 0.008 0.892 0.100 0.000
#> SRR805831 3 0.2699 0.987 0.000 0.008 0.880 0.100 0.012
#> SRR805832 3 0.3196 0.985 0.012 0.008 0.864 0.100 0.016
#> SRR805833 3 0.3196 0.985 0.012 0.008 0.864 0.100 0.016
#> SRR805834 3 0.3196 0.985 0.012 0.008 0.864 0.100 0.016
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0000 0.902 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805781 2 0.0000 0.902 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805782 2 0.0000 0.902 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805784 2 0.3256 0.823 0.036 0.852 0.012 0.000 0.016 0.084
#> SRR805785 2 0.0508 0.897 0.000 0.984 0.004 0.000 0.000 0.012
#> SRR805786 2 0.0508 0.897 0.000 0.984 0.004 0.000 0.000 0.012
#> SRR805787 2 0.0000 0.902 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805788 2 0.0000 0.902 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805789 2 0.0000 0.902 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805790 2 0.0000 0.902 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805791 1 0.4102 0.908 0.800 0.000 0.028 0.072 0.012 0.088
#> SRR805792 1 0.4102 0.908 0.800 0.000 0.028 0.072 0.012 0.088
#> SRR805793 1 0.4102 0.908 0.800 0.000 0.028 0.072 0.012 0.088
#> SRR805794 1 0.4102 0.908 0.800 0.000 0.028 0.072 0.012 0.088
#> SRR805795 1 0.2282 0.927 0.888 0.000 0.024 0.088 0.000 0.000
#> SRR805796 1 0.2282 0.927 0.888 0.000 0.024 0.088 0.000 0.000
#> SRR805797 1 0.2282 0.927 0.888 0.000 0.024 0.088 0.000 0.000
#> SRR805798 1 0.2282 0.927 0.888 0.000 0.024 0.088 0.000 0.000
#> SRR805799 1 0.4856 0.577 0.576 0.000 0.008 0.048 0.000 0.368
#> SRR805800 1 0.2199 0.927 0.892 0.000 0.020 0.088 0.000 0.000
#> SRR805801 1 0.2199 0.927 0.892 0.000 0.020 0.088 0.000 0.000
#> SRR805802 5 0.2631 0.933 0.044 0.008 0.000 0.000 0.880 0.068
#> SRR805803 2 0.5846 0.348 0.000 0.488 0.000 0.000 0.248 0.264
#> SRR805804 2 0.5875 0.329 0.000 0.480 0.000 0.000 0.256 0.264
#> SRR805805 5 0.3286 0.907 0.036 0.016 0.000 0.000 0.832 0.116
#> SRR805806 5 0.1196 0.952 0.040 0.008 0.000 0.000 0.952 0.000
#> SRR805807 5 0.2831 0.907 0.064 0.000 0.000 0.016 0.872 0.048
#> SRR805808 5 0.1196 0.952 0.040 0.008 0.000 0.000 0.952 0.000
#> SRR805809 5 0.3286 0.907 0.036 0.016 0.000 0.000 0.832 0.116
#> SRR805810 5 0.1737 0.948 0.040 0.008 0.000 0.000 0.932 0.020
#> SRR805811 5 0.1737 0.944 0.040 0.000 0.000 0.008 0.932 0.020
#> SRR805812 5 0.1196 0.952 0.040 0.008 0.000 0.000 0.952 0.000
#> SRR805813 4 0.0000 0.983 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805814 4 0.1913 0.935 0.000 0.000 0.000 0.908 0.012 0.080
#> SRR805815 4 0.0891 0.969 0.000 0.000 0.000 0.968 0.008 0.024
#> SRR805816 4 0.1913 0.935 0.000 0.000 0.000 0.908 0.012 0.080
#> SRR805817 4 0.0000 0.983 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805818 4 0.0000 0.983 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805819 4 0.0000 0.983 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805820 4 0.0000 0.983 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805821 4 0.0000 0.983 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805822 4 0.0000 0.983 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805823 4 0.0000 0.983 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805824 3 0.1994 0.943 0.008 0.000 0.924 0.020 0.008 0.040
#> SRR805825 3 0.1760 0.963 0.004 0.000 0.928 0.020 0.000 0.048
#> SRR805826 3 0.1237 0.968 0.004 0.000 0.956 0.020 0.000 0.020
#> SRR805828 3 0.0547 0.966 0.000 0.000 0.980 0.020 0.000 0.000
#> SRR805829 3 0.0547 0.966 0.000 0.000 0.980 0.020 0.000 0.000
#> SRR805830 3 0.0692 0.965 0.004 0.000 0.976 0.020 0.000 0.000
#> SRR805831 3 0.1760 0.965 0.004 0.000 0.936 0.020 0.012 0.028
#> SRR805832 3 0.2538 0.957 0.004 0.000 0.888 0.020 0.012 0.076
#> SRR805833 3 0.2538 0.957 0.004 0.000 0.888 0.020 0.012 0.076
#> SRR805834 3 0.2538 0.957 0.004 0.000 0.888 0.020 0.012 0.076
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 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.996 0.998 0.4804 0.521 0.521
#> 3 3 1.000 0.958 0.976 0.3462 0.833 0.680
#> 4 4 1.000 0.970 0.980 0.1512 0.882 0.674
#> 5 5 1.000 0.984 0.992 0.0933 0.913 0.669
#> 6 6 0.953 0.935 0.948 0.0263 0.968 0.833
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 4 5
There is also optional best \(k\) = 2 3 4 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.000 1.000 0.000 1.000
#> SRR805781 2 0.000 1.000 0.000 1.000
#> SRR805782 2 0.000 1.000 0.000 1.000
#> SRR805784 2 0.000 1.000 0.000 1.000
#> SRR805785 2 0.000 1.000 0.000 1.000
#> SRR805786 2 0.000 1.000 0.000 1.000
#> SRR805787 2 0.000 1.000 0.000 1.000
#> SRR805788 2 0.000 1.000 0.000 1.000
#> SRR805789 2 0.000 1.000 0.000 1.000
#> SRR805790 2 0.000 1.000 0.000 1.000
#> SRR805791 1 0.000 0.997 1.000 0.000
#> SRR805792 1 0.000 0.997 1.000 0.000
#> SRR805793 1 0.000 0.997 1.000 0.000
#> SRR805794 1 0.000 0.997 1.000 0.000
#> SRR805795 1 0.000 0.997 1.000 0.000
#> SRR805796 1 0.000 0.997 1.000 0.000
#> SRR805797 1 0.000 0.997 1.000 0.000
#> SRR805798 1 0.000 0.997 1.000 0.000
#> SRR805799 1 0.000 0.997 1.000 0.000
#> SRR805800 1 0.000 0.997 1.000 0.000
#> SRR805801 1 0.000 0.997 1.000 0.000
#> SRR805802 2 0.000 1.000 0.000 1.000
#> SRR805803 2 0.000 1.000 0.000 1.000
#> SRR805804 2 0.000 1.000 0.000 1.000
#> SRR805805 2 0.000 1.000 0.000 1.000
#> SRR805806 2 0.000 1.000 0.000 1.000
#> SRR805807 1 0.482 0.884 0.896 0.104
#> SRR805808 2 0.000 1.000 0.000 1.000
#> SRR805809 2 0.000 1.000 0.000 1.000
#> SRR805810 2 0.000 1.000 0.000 1.000
#> SRR805811 2 0.000 1.000 0.000 1.000
#> SRR805812 2 0.000 1.000 0.000 1.000
#> SRR805813 1 0.000 0.997 1.000 0.000
#> SRR805814 1 0.000 0.997 1.000 0.000
#> SRR805815 1 0.000 0.997 1.000 0.000
#> SRR805816 1 0.000 0.997 1.000 0.000
#> SRR805817 1 0.000 0.997 1.000 0.000
#> SRR805818 1 0.000 0.997 1.000 0.000
#> SRR805819 1 0.000 0.997 1.000 0.000
#> SRR805820 1 0.000 0.997 1.000 0.000
#> SRR805821 1 0.000 0.997 1.000 0.000
#> SRR805822 1 0.000 0.997 1.000 0.000
#> SRR805823 1 0.000 0.997 1.000 0.000
#> SRR805824 1 0.000 0.997 1.000 0.000
#> SRR805825 1 0.000 0.997 1.000 0.000
#> SRR805826 1 0.000 0.997 1.000 0.000
#> SRR805828 1 0.000 0.997 1.000 0.000
#> SRR805829 1 0.000 0.997 1.000 0.000
#> SRR805830 1 0.000 0.997 1.000 0.000
#> SRR805831 1 0.000 0.997 1.000 0.000
#> SRR805832 1 0.000 0.997 1.000 0.000
#> SRR805833 1 0.000 0.997 1.000 0.000
#> SRR805834 1 0.000 0.997 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.000 0.975 0.000 1.000 0.00
#> SRR805781 2 0.000 0.975 0.000 1.000 0.00
#> SRR805782 2 0.000 0.975 0.000 1.000 0.00
#> SRR805784 2 0.000 0.975 0.000 1.000 0.00
#> SRR805785 2 0.000 0.975 0.000 1.000 0.00
#> SRR805786 2 0.000 0.975 0.000 1.000 0.00
#> SRR805787 2 0.000 0.975 0.000 1.000 0.00
#> SRR805788 2 0.000 0.975 0.000 1.000 0.00
#> SRR805789 2 0.000 0.975 0.000 1.000 0.00
#> SRR805790 2 0.000 0.975 0.000 1.000 0.00
#> SRR805791 1 0.000 0.958 1.000 0.000 0.00
#> SRR805792 1 0.000 0.958 1.000 0.000 0.00
#> SRR805793 1 0.000 0.958 1.000 0.000 0.00
#> SRR805794 1 0.000 0.958 1.000 0.000 0.00
#> SRR805795 1 0.000 0.958 1.000 0.000 0.00
#> SRR805796 1 0.000 0.958 1.000 0.000 0.00
#> SRR805797 1 0.000 0.958 1.000 0.000 0.00
#> SRR805798 1 0.000 0.958 1.000 0.000 0.00
#> SRR805799 1 0.000 0.958 1.000 0.000 0.00
#> SRR805800 1 0.000 0.958 1.000 0.000 0.00
#> SRR805801 1 0.000 0.958 1.000 0.000 0.00
#> SRR805802 2 0.000 0.975 0.000 1.000 0.00
#> SRR805803 2 0.000 0.975 0.000 1.000 0.00
#> SRR805804 2 0.000 0.975 0.000 1.000 0.00
#> SRR805805 2 0.000 0.975 0.000 1.000 0.00
#> SRR805806 2 0.000 0.975 0.000 1.000 0.00
#> SRR805807 1 0.000 0.958 1.000 0.000 0.00
#> SRR805808 2 0.000 0.975 0.000 1.000 0.00
#> SRR805809 2 0.000 0.975 0.000 1.000 0.00
#> SRR805810 2 0.000 0.975 0.000 1.000 0.00
#> SRR805811 2 0.617 0.314 0.412 0.588 0.00
#> SRR805812 2 0.000 0.975 0.000 1.000 0.00
#> SRR805813 1 0.254 0.952 0.920 0.000 0.08
#> SRR805814 1 0.254 0.952 0.920 0.000 0.08
#> SRR805815 1 0.254 0.952 0.920 0.000 0.08
#> SRR805816 1 0.254 0.952 0.920 0.000 0.08
#> SRR805817 1 0.254 0.952 0.920 0.000 0.08
#> SRR805818 1 0.254 0.952 0.920 0.000 0.08
#> SRR805819 1 0.254 0.952 0.920 0.000 0.08
#> SRR805820 1 0.254 0.952 0.920 0.000 0.08
#> SRR805821 1 0.254 0.952 0.920 0.000 0.08
#> SRR805822 1 0.254 0.952 0.920 0.000 0.08
#> SRR805823 1 0.254 0.952 0.920 0.000 0.08
#> SRR805824 3 0.000 1.000 0.000 0.000 1.00
#> SRR805825 3 0.000 1.000 0.000 0.000 1.00
#> SRR805826 3 0.000 1.000 0.000 0.000 1.00
#> SRR805828 3 0.000 1.000 0.000 0.000 1.00
#> SRR805829 3 0.000 1.000 0.000 0.000 1.00
#> SRR805830 3 0.000 1.000 0.000 0.000 1.00
#> SRR805831 3 0.000 1.000 0.000 0.000 1.00
#> SRR805832 3 0.000 1.000 0.000 0.000 1.00
#> SRR805833 3 0.000 1.000 0.000 0.000 1.00
#> SRR805834 3 0.000 1.000 0.000 0.000 1.00
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.0000 0.988 0.000 1.000 0.00 0.000
#> SRR805781 2 0.0000 0.988 0.000 1.000 0.00 0.000
#> SRR805782 2 0.0000 0.988 0.000 1.000 0.00 0.000
#> SRR805784 2 0.0000 0.988 0.000 1.000 0.00 0.000
#> SRR805785 2 0.0000 0.988 0.000 1.000 0.00 0.000
#> SRR805786 2 0.0000 0.988 0.000 1.000 0.00 0.000
#> SRR805787 2 0.0000 0.988 0.000 1.000 0.00 0.000
#> SRR805788 2 0.0000 0.988 0.000 1.000 0.00 0.000
#> SRR805789 2 0.0000 0.988 0.000 1.000 0.00 0.000
#> SRR805790 2 0.0000 0.988 0.000 1.000 0.00 0.000
#> SRR805791 1 0.0000 1.000 1.000 0.000 0.00 0.000
#> SRR805792 1 0.0000 1.000 1.000 0.000 0.00 0.000
#> SRR805793 1 0.0000 1.000 1.000 0.000 0.00 0.000
#> SRR805794 1 0.0000 1.000 1.000 0.000 0.00 0.000
#> SRR805795 1 0.0000 1.000 1.000 0.000 0.00 0.000
#> SRR805796 1 0.0000 1.000 1.000 0.000 0.00 0.000
#> SRR805797 1 0.0000 1.000 1.000 0.000 0.00 0.000
#> SRR805798 1 0.0000 1.000 1.000 0.000 0.00 0.000
#> SRR805799 1 0.0000 1.000 1.000 0.000 0.00 0.000
#> SRR805800 1 0.0000 1.000 1.000 0.000 0.00 0.000
#> SRR805801 1 0.0000 1.000 1.000 0.000 0.00 0.000
#> SRR805802 2 0.1118 0.980 0.000 0.964 0.00 0.036
#> SRR805803 2 0.0188 0.987 0.000 0.996 0.00 0.004
#> SRR805804 2 0.0188 0.987 0.000 0.996 0.00 0.004
#> SRR805805 2 0.1118 0.980 0.000 0.964 0.00 0.036
#> SRR805806 2 0.1118 0.980 0.000 0.964 0.00 0.036
#> SRR805807 4 0.0000 0.924 0.000 0.000 0.00 1.000
#> SRR805808 2 0.1118 0.980 0.000 0.964 0.00 0.036
#> SRR805809 2 0.1118 0.980 0.000 0.964 0.00 0.036
#> SRR805810 2 0.1118 0.980 0.000 0.964 0.00 0.036
#> SRR805811 4 0.4830 0.287 0.000 0.392 0.00 0.608
#> SRR805812 2 0.1118 0.980 0.000 0.964 0.00 0.036
#> SRR805813 4 0.1297 0.955 0.016 0.000 0.02 0.964
#> SRR805814 4 0.1297 0.955 0.016 0.000 0.02 0.964
#> SRR805815 4 0.1297 0.955 0.016 0.000 0.02 0.964
#> SRR805816 4 0.1297 0.955 0.016 0.000 0.02 0.964
#> SRR805817 4 0.1297 0.955 0.016 0.000 0.02 0.964
#> SRR805818 4 0.1297 0.955 0.016 0.000 0.02 0.964
#> SRR805819 4 0.1297 0.955 0.016 0.000 0.02 0.964
#> SRR805820 4 0.1297 0.955 0.016 0.000 0.02 0.964
#> SRR805821 4 0.1297 0.955 0.016 0.000 0.02 0.964
#> SRR805822 4 0.1297 0.955 0.016 0.000 0.02 0.964
#> SRR805823 4 0.1297 0.955 0.016 0.000 0.02 0.964
#> SRR805824 3 0.0000 1.000 0.000 0.000 1.00 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1.00 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1.00 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1.00 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1.00 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1.00 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1.00 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1.00 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1.00 0.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1.00 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.000 0.962 0 1.000 0 0 0.000
#> SRR805781 2 0.000 0.962 0 1.000 0 0 0.000
#> SRR805782 2 0.000 0.962 0 1.000 0 0 0.000
#> SRR805784 2 0.000 0.962 0 1.000 0 0 0.000
#> SRR805785 2 0.000 0.962 0 1.000 0 0 0.000
#> SRR805786 2 0.000 0.962 0 1.000 0 0 0.000
#> SRR805787 2 0.000 0.962 0 1.000 0 0 0.000
#> SRR805788 2 0.000 0.962 0 1.000 0 0 0.000
#> SRR805789 2 0.000 0.962 0 1.000 0 0 0.000
#> SRR805790 2 0.000 0.962 0 1.000 0 0 0.000
#> SRR805791 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805792 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805793 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805794 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805795 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805796 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805797 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805798 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805799 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805800 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805801 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805802 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805803 2 0.311 0.772 0 0.800 0 0 0.200
#> SRR805804 2 0.318 0.761 0 0.792 0 0 0.208
#> SRR805805 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805806 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805807 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805808 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805809 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805810 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805811 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805812 5 0.000 1.000 0 0.000 0 0 1.000
#> SRR805813 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805814 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805815 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805816 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805817 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805818 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805819 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805820 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805821 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805822 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805823 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805824 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805825 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805826 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805828 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805829 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805830 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805831 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805832 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805833 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805834 3 0.000 1.000 0 0.000 1 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0000 0.999 0.000 1.000 0 0.000 0.000 0.000
#> SRR805781 2 0.0146 0.997 0.000 0.996 0 0.000 0.000 0.004
#> SRR805782 2 0.0146 0.997 0.000 0.996 0 0.000 0.000 0.004
#> SRR805784 2 0.0000 0.999 0.000 1.000 0 0.000 0.000 0.000
#> SRR805785 2 0.0000 0.999 0.000 1.000 0 0.000 0.000 0.000
#> SRR805786 2 0.0000 0.999 0.000 1.000 0 0.000 0.000 0.000
#> SRR805787 2 0.0146 0.997 0.000 0.996 0 0.000 0.000 0.004
#> SRR805788 2 0.0000 0.999 0.000 1.000 0 0.000 0.000 0.000
#> SRR805789 2 0.0000 0.999 0.000 1.000 0 0.000 0.000 0.000
#> SRR805790 2 0.0000 0.999 0.000 1.000 0 0.000 0.000 0.000
#> SRR805791 1 0.2854 0.863 0.792 0.000 0 0.000 0.000 0.208
#> SRR805792 1 0.2854 0.863 0.792 0.000 0 0.000 0.000 0.208
#> SRR805793 1 0.2854 0.863 0.792 0.000 0 0.000 0.000 0.208
#> SRR805794 1 0.2854 0.863 0.792 0.000 0 0.000 0.000 0.208
#> SRR805795 1 0.0000 0.916 1.000 0.000 0 0.000 0.000 0.000
#> SRR805796 1 0.0000 0.916 1.000 0.000 0 0.000 0.000 0.000
#> SRR805797 1 0.0000 0.916 1.000 0.000 0 0.000 0.000 0.000
#> SRR805798 1 0.0000 0.916 1.000 0.000 0 0.000 0.000 0.000
#> SRR805799 1 0.2294 0.849 0.892 0.000 0 0.000 0.036 0.072
#> SRR805800 1 0.0000 0.916 1.000 0.000 0 0.000 0.000 0.000
#> SRR805801 1 0.0000 0.916 1.000 0.000 0 0.000 0.000 0.000
#> SRR805802 6 0.3390 0.731 0.000 0.000 0 0.000 0.296 0.704
#> SRR805803 6 0.4239 0.677 0.000 0.248 0 0.000 0.056 0.696
#> SRR805804 6 0.4215 0.681 0.000 0.244 0 0.000 0.056 0.700
#> SRR805805 6 0.3390 0.731 0.000 0.000 0 0.000 0.296 0.704
#> SRR805806 5 0.1007 0.913 0.000 0.000 0 0.000 0.956 0.044
#> SRR805807 5 0.1444 0.849 0.000 0.000 0 0.000 0.928 0.072
#> SRR805808 5 0.2527 0.763 0.000 0.000 0 0.000 0.832 0.168
#> SRR805809 6 0.3390 0.731 0.000 0.000 0 0.000 0.296 0.704
#> SRR805810 5 0.0363 0.915 0.000 0.000 0 0.000 0.988 0.012
#> SRR805811 5 0.0146 0.913 0.000 0.000 0 0.000 0.996 0.004
#> SRR805812 5 0.1204 0.907 0.000 0.000 0 0.000 0.944 0.056
#> SRR805813 4 0.0000 0.998 0.000 0.000 0 1.000 0.000 0.000
#> SRR805814 4 0.0363 0.991 0.000 0.000 0 0.988 0.000 0.012
#> SRR805815 4 0.0000 0.998 0.000 0.000 0 1.000 0.000 0.000
#> SRR805816 4 0.0363 0.991 0.000 0.000 0 0.988 0.000 0.012
#> SRR805817 4 0.0000 0.998 0.000 0.000 0 1.000 0.000 0.000
#> SRR805818 4 0.0000 0.998 0.000 0.000 0 1.000 0.000 0.000
#> SRR805819 4 0.0000 0.998 0.000 0.000 0 1.000 0.000 0.000
#> SRR805820 4 0.0000 0.998 0.000 0.000 0 1.000 0.000 0.000
#> SRR805821 4 0.0000 0.998 0.000 0.000 0 1.000 0.000 0.000
#> SRR805822 4 0.0000 0.998 0.000 0.000 0 1.000 0.000 0.000
#> SRR805823 4 0.0000 0.998 0.000 0.000 0 1.000 0.000 0.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1 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 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.968 0.985 0.4161 0.586 0.586
#> 3 3 0.632 0.645 0.841 0.5619 0.764 0.598
#> 4 4 1.000 0.967 0.988 0.1609 0.837 0.569
#> 5 5 1.000 0.997 0.998 0.0803 0.899 0.619
#> 6 6 0.977 0.895 0.944 0.0214 0.985 0.922
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 4 5
There is also optional best \(k\) = 2 4 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.0000 0.980 0.000 1.000
#> SRR805781 2 0.0000 0.980 0.000 1.000
#> SRR805782 2 0.0000 0.980 0.000 1.000
#> SRR805784 2 0.0000 0.980 0.000 1.000
#> SRR805785 2 0.0000 0.980 0.000 1.000
#> SRR805786 2 0.0000 0.980 0.000 1.000
#> SRR805787 2 0.0000 0.980 0.000 1.000
#> SRR805788 2 0.0000 0.980 0.000 1.000
#> SRR805789 2 0.0000 0.980 0.000 1.000
#> SRR805790 2 0.0000 0.980 0.000 1.000
#> SRR805791 1 0.0376 0.986 0.996 0.004
#> SRR805792 1 0.0376 0.986 0.996 0.004
#> SRR805793 1 0.0672 0.984 0.992 0.008
#> SRR805794 1 0.0376 0.986 0.996 0.004
#> SRR805795 1 0.0376 0.986 0.996 0.004
#> SRR805796 1 0.0376 0.986 0.996 0.004
#> SRR805797 1 0.0376 0.986 0.996 0.004
#> SRR805798 1 0.0376 0.986 0.996 0.004
#> SRR805799 1 0.0000 0.986 1.000 0.000
#> SRR805800 1 0.0376 0.986 0.996 0.004
#> SRR805801 1 0.0376 0.986 0.996 0.004
#> SRR805802 2 0.8499 0.611 0.276 0.724
#> SRR805803 2 0.0000 0.980 0.000 1.000
#> SRR805804 2 0.0000 0.980 0.000 1.000
#> SRR805805 2 0.0000 0.980 0.000 1.000
#> SRR805806 1 0.0672 0.984 0.992 0.008
#> SRR805807 1 0.0000 0.986 1.000 0.000
#> SRR805808 1 0.8144 0.671 0.748 0.252
#> SRR805809 2 0.0000 0.980 0.000 1.000
#> SRR805810 1 0.0376 0.986 0.996 0.004
#> SRR805811 1 0.0376 0.986 0.996 0.004
#> SRR805812 1 0.4939 0.881 0.892 0.108
#> SRR805813 1 0.0000 0.986 1.000 0.000
#> SRR805814 1 0.0000 0.986 1.000 0.000
#> SRR805815 1 0.0000 0.986 1.000 0.000
#> SRR805816 1 0.0000 0.986 1.000 0.000
#> SRR805817 1 0.0000 0.986 1.000 0.000
#> SRR805818 1 0.0000 0.986 1.000 0.000
#> SRR805819 1 0.0000 0.986 1.000 0.000
#> SRR805820 1 0.0000 0.986 1.000 0.000
#> SRR805821 1 0.0000 0.986 1.000 0.000
#> SRR805822 1 0.0000 0.986 1.000 0.000
#> SRR805823 1 0.0000 0.986 1.000 0.000
#> SRR805824 1 0.0000 0.986 1.000 0.000
#> SRR805825 1 0.3114 0.940 0.944 0.056
#> SRR805826 1 0.0672 0.984 0.992 0.008
#> SRR805828 1 0.0376 0.986 0.996 0.004
#> SRR805829 1 0.0376 0.986 0.996 0.004
#> SRR805830 1 0.0376 0.986 0.996 0.004
#> SRR805831 1 0.0376 0.986 0.996 0.004
#> SRR805832 1 0.1414 0.975 0.980 0.020
#> SRR805833 1 0.0672 0.984 0.992 0.008
#> SRR805834 1 0.0376 0.986 0.996 0.004
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.0000 0.973 0.000 1.000 0.000
#> SRR805781 2 0.0000 0.973 0.000 1.000 0.000
#> SRR805782 2 0.0000 0.973 0.000 1.000 0.000
#> SRR805784 2 0.0000 0.973 0.000 1.000 0.000
#> SRR805785 2 0.0000 0.973 0.000 1.000 0.000
#> SRR805786 2 0.0000 0.973 0.000 1.000 0.000
#> SRR805787 2 0.0000 0.973 0.000 1.000 0.000
#> SRR805788 2 0.0000 0.973 0.000 1.000 0.000
#> SRR805789 2 0.0000 0.973 0.000 1.000 0.000
#> SRR805790 2 0.0000 0.973 0.000 1.000 0.000
#> SRR805791 1 0.6309 0.282 0.500 0.000 0.500
#> SRR805792 3 0.6291 -0.273 0.468 0.000 0.532
#> SRR805793 3 0.6291 -0.273 0.468 0.000 0.532
#> SRR805794 3 0.6291 -0.273 0.468 0.000 0.532
#> SRR805795 1 0.5591 0.652 0.696 0.000 0.304
#> SRR805796 1 0.5591 0.652 0.696 0.000 0.304
#> SRR805797 1 0.5591 0.652 0.696 0.000 0.304
#> SRR805798 1 0.5591 0.652 0.696 0.000 0.304
#> SRR805799 1 0.5591 0.652 0.696 0.000 0.304
#> SRR805800 1 0.5591 0.652 0.696 0.000 0.304
#> SRR805801 1 0.5591 0.652 0.696 0.000 0.304
#> SRR805802 2 0.5988 0.494 0.008 0.688 0.304
#> SRR805803 2 0.0000 0.973 0.000 1.000 0.000
#> SRR805804 2 0.0000 0.973 0.000 1.000 0.000
#> SRR805805 2 0.0000 0.973 0.000 1.000 0.000
#> SRR805806 1 0.7851 0.577 0.616 0.080 0.304
#> SRR805807 1 0.0000 0.674 1.000 0.000 0.000
#> SRR805808 1 0.9672 0.362 0.456 0.240 0.304
#> SRR805809 2 0.0000 0.973 0.000 1.000 0.000
#> SRR805810 1 0.5591 0.652 0.696 0.000 0.304
#> SRR805811 1 0.5138 0.663 0.748 0.000 0.252
#> SRR805812 1 0.9598 0.379 0.468 0.228 0.304
#> SRR805813 1 0.0000 0.674 1.000 0.000 0.000
#> SRR805814 1 0.5254 0.265 0.736 0.000 0.264
#> SRR805815 1 0.4842 0.354 0.776 0.000 0.224
#> SRR805816 1 0.2878 0.572 0.904 0.000 0.096
#> SRR805817 1 0.0000 0.674 1.000 0.000 0.000
#> SRR805818 1 0.0000 0.674 1.000 0.000 0.000
#> SRR805819 1 0.0747 0.661 0.984 0.000 0.016
#> SRR805820 1 0.0000 0.674 1.000 0.000 0.000
#> SRR805821 1 0.0000 0.674 1.000 0.000 0.000
#> SRR805822 1 0.0000 0.674 1.000 0.000 0.000
#> SRR805823 1 0.0000 0.674 1.000 0.000 0.000
#> SRR805824 3 0.5591 0.544 0.304 0.000 0.696
#> SRR805825 3 0.0000 0.657 0.000 0.000 1.000
#> SRR805826 3 0.0000 0.657 0.000 0.000 1.000
#> SRR805828 3 0.5397 0.567 0.280 0.000 0.720
#> SRR805829 3 0.3941 0.630 0.156 0.000 0.844
#> SRR805830 3 0.0000 0.657 0.000 0.000 1.000
#> SRR805831 3 0.4796 0.604 0.220 0.000 0.780
#> SRR805832 3 0.0000 0.657 0.000 0.000 1.000
#> SRR805833 3 0.0000 0.657 0.000 0.000 1.000
#> SRR805834 3 0.5497 0.557 0.292 0.000 0.708
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.0000 0.991 0.000 1.000 0 0.000
#> SRR805781 2 0.0000 0.991 0.000 1.000 0 0.000
#> SRR805782 2 0.0000 0.991 0.000 1.000 0 0.000
#> SRR805784 2 0.0000 0.991 0.000 1.000 0 0.000
#> SRR805785 2 0.0000 0.991 0.000 1.000 0 0.000
#> SRR805786 2 0.0000 0.991 0.000 1.000 0 0.000
#> SRR805787 2 0.0000 0.991 0.000 1.000 0 0.000
#> SRR805788 2 0.0000 0.991 0.000 1.000 0 0.000
#> SRR805789 2 0.0000 0.991 0.000 1.000 0 0.000
#> SRR805790 2 0.0000 0.991 0.000 1.000 0 0.000
#> SRR805791 1 0.0000 0.998 1.000 0.000 0 0.000
#> SRR805792 1 0.0000 0.998 1.000 0.000 0 0.000
#> SRR805793 1 0.0000 0.998 1.000 0.000 0 0.000
#> SRR805794 1 0.0000 0.998 1.000 0.000 0 0.000
#> SRR805795 1 0.0000 0.998 1.000 0.000 0 0.000
#> SRR805796 1 0.0000 0.998 1.000 0.000 0 0.000
#> SRR805797 1 0.0000 0.998 1.000 0.000 0 0.000
#> SRR805798 1 0.0000 0.998 1.000 0.000 0 0.000
#> SRR805799 1 0.0000 0.998 1.000 0.000 0 0.000
#> SRR805800 1 0.0000 0.998 1.000 0.000 0 0.000
#> SRR805801 1 0.0000 0.998 1.000 0.000 0 0.000
#> SRR805802 2 0.2589 0.862 0.116 0.884 0 0.000
#> SRR805803 2 0.0000 0.991 0.000 1.000 0 0.000
#> SRR805804 2 0.0000 0.991 0.000 1.000 0 0.000
#> SRR805805 2 0.0000 0.991 0.000 1.000 0 0.000
#> SRR805806 1 0.0000 0.998 1.000 0.000 0 0.000
#> SRR805807 4 0.4989 0.104 0.472 0.000 0 0.528
#> SRR805808 1 0.0817 0.973 0.976 0.024 0 0.000
#> SRR805809 2 0.0000 0.991 0.000 1.000 0 0.000
#> SRR805810 1 0.0000 0.998 1.000 0.000 0 0.000
#> SRR805811 1 0.0000 0.998 1.000 0.000 0 0.000
#> SRR805812 1 0.0000 0.998 1.000 0.000 0 0.000
#> SRR805813 4 0.0000 0.951 0.000 0.000 0 1.000
#> SRR805814 4 0.0000 0.951 0.000 0.000 0 1.000
#> SRR805815 4 0.0000 0.951 0.000 0.000 0 1.000
#> SRR805816 4 0.0000 0.951 0.000 0.000 0 1.000
#> SRR805817 4 0.0000 0.951 0.000 0.000 0 1.000
#> SRR805818 4 0.0000 0.951 0.000 0.000 0 1.000
#> SRR805819 4 0.0000 0.951 0.000 0.000 0 1.000
#> SRR805820 4 0.0000 0.951 0.000 0.000 0 1.000
#> SRR805821 4 0.0000 0.951 0.000 0.000 0 1.000
#> SRR805822 4 0.0000 0.951 0.000 0.000 0 1.000
#> SRR805823 4 0.0000 0.951 0.000 0.000 0 1.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.0000 0.995 0 1.000 0 0.000 0.000
#> SRR805781 2 0.0000 0.995 0 1.000 0 0.000 0.000
#> SRR805782 2 0.0000 0.995 0 1.000 0 0.000 0.000
#> SRR805784 2 0.0000 0.995 0 1.000 0 0.000 0.000
#> SRR805785 2 0.0000 0.995 0 1.000 0 0.000 0.000
#> SRR805786 2 0.0000 0.995 0 1.000 0 0.000 0.000
#> SRR805787 2 0.0000 0.995 0 1.000 0 0.000 0.000
#> SRR805788 2 0.0000 0.995 0 1.000 0 0.000 0.000
#> SRR805789 2 0.0000 0.995 0 1.000 0 0.000 0.000
#> SRR805790 2 0.0000 0.995 0 1.000 0 0.000 0.000
#> SRR805791 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805792 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805793 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805794 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805795 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805796 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805797 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805798 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805799 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805800 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805801 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> SRR805802 5 0.0000 0.997 0 0.000 0 0.000 1.000
#> SRR805803 2 0.1270 0.945 0 0.948 0 0.000 0.052
#> SRR805804 5 0.0703 0.975 0 0.024 0 0.000 0.976
#> SRR805805 5 0.0000 0.997 0 0.000 0 0.000 1.000
#> SRR805806 5 0.0000 0.997 0 0.000 0 0.000 1.000
#> SRR805807 5 0.0162 0.994 0 0.000 0 0.004 0.996
#> SRR805808 5 0.0000 0.997 0 0.000 0 0.000 1.000
#> SRR805809 5 0.0000 0.997 0 0.000 0 0.000 1.000
#> SRR805810 5 0.0000 0.997 0 0.000 0 0.000 1.000
#> SRR805811 5 0.0000 0.997 0 0.000 0 0.000 1.000
#> SRR805812 5 0.0000 0.997 0 0.000 0 0.000 1.000
#> SRR805813 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805814 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805815 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805816 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805817 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805818 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805819 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805820 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805821 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805822 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805823 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> SRR805824 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805825 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805826 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805828 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805829 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805830 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805831 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805832 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805833 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> SRR805834 3 0.0000 1.000 0 0.000 1 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.3843 1.0000 0.000 0.548 0 0 0.000 0.452
#> SRR805781 2 0.3843 1.0000 0.000 0.548 0 0 0.000 0.452
#> SRR805782 2 0.3843 1.0000 0.000 0.548 0 0 0.000 0.452
#> SRR805784 2 0.3843 1.0000 0.000 0.548 0 0 0.000 0.452
#> SRR805785 2 0.3843 1.0000 0.000 0.548 0 0 0.000 0.452
#> SRR805786 2 0.3843 1.0000 0.000 0.548 0 0 0.000 0.452
#> SRR805787 2 0.3843 1.0000 0.000 0.548 0 0 0.000 0.452
#> SRR805788 2 0.3843 1.0000 0.000 0.548 0 0 0.000 0.452
#> SRR805789 2 0.3843 1.0000 0.000 0.548 0 0 0.000 0.452
#> SRR805790 2 0.3843 1.0000 0.000 0.548 0 0 0.000 0.452
#> SRR805791 1 0.3843 0.6589 0.548 0.452 0 0 0.000 0.000
#> SRR805792 1 0.3843 0.6589 0.548 0.452 0 0 0.000 0.000
#> SRR805793 1 0.3843 0.6589 0.548 0.452 0 0 0.000 0.000
#> SRR805794 1 0.3843 0.6589 0.548 0.452 0 0 0.000 0.000
#> SRR805795 1 0.0000 0.8237 1.000 0.000 0 0 0.000 0.000
#> SRR805796 1 0.0000 0.8237 1.000 0.000 0 0 0.000 0.000
#> SRR805797 1 0.0000 0.8237 1.000 0.000 0 0 0.000 0.000
#> SRR805798 1 0.0000 0.8237 1.000 0.000 0 0 0.000 0.000
#> SRR805799 1 0.0000 0.8237 1.000 0.000 0 0 0.000 0.000
#> SRR805800 1 0.0000 0.8237 1.000 0.000 0 0 0.000 0.000
#> SRR805801 1 0.0000 0.8237 1.000 0.000 0 0 0.000 0.000
#> SRR805802 5 0.0146 0.9568 0.000 0.000 0 0 0.996 0.004
#> SRR805803 6 0.0000 -0.0327 0.000 0.000 0 0 0.000 1.000
#> SRR805804 6 0.3817 -0.1378 0.000 0.000 0 0 0.432 0.568
#> SRR805805 5 0.0146 0.9568 0.000 0.000 0 0 0.996 0.004
#> SRR805806 5 0.0146 0.9568 0.000 0.000 0 0 0.996 0.004
#> SRR805807 5 0.0000 0.9578 0.000 0.000 0 0 1.000 0.000
#> SRR805808 5 0.0000 0.9578 0.000 0.000 0 0 1.000 0.000
#> SRR805809 5 0.3151 0.5669 0.000 0.000 0 0 0.748 0.252
#> SRR805810 5 0.0000 0.9578 0.000 0.000 0 0 1.000 0.000
#> SRR805811 5 0.0000 0.9578 0.000 0.000 0 0 1.000 0.000
#> SRR805812 5 0.0000 0.9578 0.000 0.000 0 0 1.000 0.000
#> SRR805813 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805814 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805815 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805816 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805817 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805818 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805819 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805820 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805821 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805822 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805823 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805824 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805825 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805826 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805828 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805829 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805830 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805831 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805832 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805833 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805834 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "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 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.265 0.742 0.824 0.4861 0.512 0.512
#> 3 3 0.665 0.853 0.857 0.1683 0.585 0.390
#> 4 4 0.850 0.920 0.949 0.2994 0.832 0.612
#> 5 5 1.000 0.985 0.993 0.1043 0.920 0.699
#> 6 6 0.980 0.960 0.953 0.0201 0.980 0.890
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 5
There is also optional best \(k\) = 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.000 0.818 0.000 1.000
#> SRR805781 2 0.000 0.818 0.000 1.000
#> SRR805782 2 0.000 0.818 0.000 1.000
#> SRR805784 2 0.000 0.818 0.000 1.000
#> SRR805785 2 0.000 0.818 0.000 1.000
#> SRR805786 2 0.000 0.818 0.000 1.000
#> SRR805787 2 0.000 0.818 0.000 1.000
#> SRR805788 2 0.000 0.818 0.000 1.000
#> SRR805789 2 0.000 0.818 0.000 1.000
#> SRR805790 2 0.000 0.818 0.000 1.000
#> SRR805791 2 0.971 0.608 0.400 0.600
#> SRR805792 2 0.971 0.608 0.400 0.600
#> SRR805793 2 0.971 0.608 0.400 0.600
#> SRR805794 2 0.971 0.608 0.400 0.600
#> SRR805795 2 0.971 0.608 0.400 0.600
#> SRR805796 2 0.971 0.608 0.400 0.600
#> SRR805797 2 0.971 0.608 0.400 0.600
#> SRR805798 2 0.971 0.608 0.400 0.600
#> SRR805799 2 0.971 0.608 0.400 0.600
#> SRR805800 2 0.971 0.608 0.400 0.600
#> SRR805801 2 0.971 0.608 0.400 0.600
#> SRR805802 2 0.000 0.818 0.000 1.000
#> SRR805803 2 0.000 0.818 0.000 1.000
#> SRR805804 2 0.000 0.818 0.000 1.000
#> SRR805805 2 0.000 0.818 0.000 1.000
#> SRR805806 2 0.000 0.818 0.000 1.000
#> SRR805807 2 0.000 0.818 0.000 1.000
#> SRR805808 2 0.000 0.818 0.000 1.000
#> SRR805809 2 0.000 0.818 0.000 1.000
#> SRR805810 2 0.000 0.818 0.000 1.000
#> SRR805811 2 0.000 0.818 0.000 1.000
#> SRR805812 2 0.000 0.818 0.000 1.000
#> SRR805813 1 0.482 0.762 0.896 0.104
#> SRR805814 1 0.482 0.762 0.896 0.104
#> SRR805815 1 0.482 0.762 0.896 0.104
#> SRR805816 1 0.482 0.762 0.896 0.104
#> SRR805817 1 0.482 0.762 0.896 0.104
#> SRR805818 1 0.482 0.762 0.896 0.104
#> SRR805819 1 0.482 0.762 0.896 0.104
#> SRR805820 1 0.482 0.762 0.896 0.104
#> SRR805821 1 0.482 0.762 0.896 0.104
#> SRR805822 1 0.482 0.762 0.896 0.104
#> SRR805823 1 0.482 0.762 0.896 0.104
#> SRR805824 1 0.909 0.709 0.676 0.324
#> SRR805825 1 0.909 0.709 0.676 0.324
#> SRR805826 1 0.909 0.709 0.676 0.324
#> SRR805828 1 0.909 0.709 0.676 0.324
#> SRR805829 1 0.909 0.709 0.676 0.324
#> SRR805830 1 0.909 0.709 0.676 0.324
#> SRR805831 1 0.909 0.709 0.676 0.324
#> SRR805832 1 0.909 0.709 0.676 0.324
#> SRR805833 1 0.909 0.709 0.676 0.324
#> SRR805834 1 0.909 0.709 0.676 0.324
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.000 0.800 0.00 1.00 0.00
#> SRR805781 2 0.000 0.800 0.00 1.00 0.00
#> SRR805782 2 0.000 0.800 0.00 1.00 0.00
#> SRR805784 2 0.000 0.800 0.00 1.00 0.00
#> SRR805785 2 0.000 0.800 0.00 1.00 0.00
#> SRR805786 2 0.000 0.800 0.00 1.00 0.00
#> SRR805787 2 0.000 0.800 0.00 1.00 0.00
#> SRR805788 2 0.000 0.800 0.00 1.00 0.00
#> SRR805789 2 0.000 0.800 0.00 1.00 0.00
#> SRR805790 2 0.000 0.800 0.00 1.00 0.00
#> SRR805791 1 0.595 1.000 0.64 0.36 0.00
#> SRR805792 1 0.595 1.000 0.64 0.36 0.00
#> SRR805793 1 0.595 1.000 0.64 0.36 0.00
#> SRR805794 1 0.595 1.000 0.64 0.36 0.00
#> SRR805795 1 0.595 1.000 0.64 0.36 0.00
#> SRR805796 1 0.595 1.000 0.64 0.36 0.00
#> SRR805797 1 0.595 1.000 0.64 0.36 0.00
#> SRR805798 1 0.595 1.000 0.64 0.36 0.00
#> SRR805799 1 0.595 1.000 0.64 0.36 0.00
#> SRR805800 1 0.595 1.000 0.64 0.36 0.00
#> SRR805801 1 0.595 1.000 0.64 0.36 0.00
#> SRR805802 2 0.000 0.800 0.00 1.00 0.00
#> SRR805803 2 0.000 0.800 0.00 1.00 0.00
#> SRR805804 2 0.000 0.800 0.00 1.00 0.00
#> SRR805805 2 0.000 0.800 0.00 1.00 0.00
#> SRR805806 2 0.000 0.800 0.00 1.00 0.00
#> SRR805807 2 0.000 0.800 0.00 1.00 0.00
#> SRR805808 2 0.000 0.800 0.00 1.00 0.00
#> SRR805809 2 0.000 0.800 0.00 1.00 0.00
#> SRR805810 2 0.000 0.800 0.00 1.00 0.00
#> SRR805811 2 0.000 0.800 0.00 1.00 0.00
#> SRR805812 2 0.000 0.800 0.00 1.00 0.00
#> SRR805813 2 0.595 0.671 0.00 0.64 0.36
#> SRR805814 2 0.595 0.671 0.00 0.64 0.36
#> SRR805815 2 0.595 0.671 0.00 0.64 0.36
#> SRR805816 2 0.595 0.671 0.00 0.64 0.36
#> SRR805817 2 0.595 0.671 0.00 0.64 0.36
#> SRR805818 2 0.595 0.671 0.00 0.64 0.36
#> SRR805819 2 0.595 0.671 0.00 0.64 0.36
#> SRR805820 2 0.595 0.671 0.00 0.64 0.36
#> SRR805821 2 0.595 0.671 0.00 0.64 0.36
#> SRR805822 2 0.595 0.671 0.00 0.64 0.36
#> SRR805823 2 0.595 0.671 0.00 0.64 0.36
#> SRR805824 3 0.595 1.000 0.36 0.00 0.64
#> SRR805825 3 0.595 1.000 0.36 0.00 0.64
#> SRR805826 3 0.595 1.000 0.36 0.00 0.64
#> SRR805828 3 0.595 1.000 0.36 0.00 0.64
#> SRR805829 3 0.595 1.000 0.36 0.00 0.64
#> SRR805830 3 0.595 1.000 0.36 0.00 0.64
#> SRR805831 3 0.595 1.000 0.36 0.00 0.64
#> SRR805832 3 0.595 1.000 0.36 0.00 0.64
#> SRR805833 3 0.595 1.000 0.36 0.00 0.64
#> SRR805834 3 0.595 1.000 0.36 0.00 0.64
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.0000 0.849 0.000 1.000 0 0.000
#> SRR805781 2 0.0000 0.849 0.000 1.000 0 0.000
#> SRR805782 2 0.0000 0.849 0.000 1.000 0 0.000
#> SRR805784 2 0.0000 0.849 0.000 1.000 0 0.000
#> SRR805785 2 0.0000 0.849 0.000 1.000 0 0.000
#> SRR805786 2 0.0000 0.849 0.000 1.000 0 0.000
#> SRR805787 2 0.0000 0.849 0.000 1.000 0 0.000
#> SRR805788 2 0.0000 0.849 0.000 1.000 0 0.000
#> SRR805789 2 0.0000 0.849 0.000 1.000 0 0.000
#> SRR805790 2 0.0000 0.849 0.000 1.000 0 0.000
#> SRR805791 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805792 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805793 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805794 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805795 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805796 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805797 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805798 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805799 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805800 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805801 1 0.0000 1.000 1.000 0.000 0 0.000
#> SRR805802 2 0.4428 0.753 0.004 0.720 0 0.276
#> SRR805803 2 0.0188 0.848 0.004 0.996 0 0.000
#> SRR805804 2 0.0188 0.848 0.004 0.996 0 0.000
#> SRR805805 2 0.4428 0.753 0.004 0.720 0 0.276
#> SRR805806 2 0.4699 0.710 0.004 0.676 0 0.320
#> SRR805807 2 0.4699 0.710 0.004 0.676 0 0.320
#> SRR805808 2 0.4428 0.753 0.004 0.720 0 0.276
#> SRR805809 2 0.4428 0.753 0.004 0.720 0 0.276
#> SRR805810 2 0.4699 0.710 0.004 0.676 0 0.320
#> SRR805811 2 0.4699 0.710 0.004 0.676 0 0.320
#> SRR805812 2 0.4483 0.746 0.004 0.712 0 0.284
#> SRR805813 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805814 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805815 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805816 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805817 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805818 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805819 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805820 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805821 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805822 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805823 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.0000 0.978 0.000 1.000 0 0 0.000
#> SRR805781 2 0.0000 0.978 0.000 1.000 0 0 0.000
#> SRR805782 2 0.0000 0.978 0.000 1.000 0 0 0.000
#> SRR805784 2 0.0000 0.978 0.000 1.000 0 0 0.000
#> SRR805785 2 0.0000 0.978 0.000 1.000 0 0 0.000
#> SRR805786 2 0.0000 0.978 0.000 1.000 0 0 0.000
#> SRR805787 2 0.0000 0.978 0.000 1.000 0 0 0.000
#> SRR805788 2 0.0000 0.978 0.000 1.000 0 0 0.000
#> SRR805789 2 0.0000 0.978 0.000 1.000 0 0 0.000
#> SRR805790 2 0.0000 0.978 0.000 1.000 0 0 0.000
#> SRR805791 1 0.0000 1.000 1.000 0.000 0 0 0.000
#> SRR805792 1 0.0000 1.000 1.000 0.000 0 0 0.000
#> SRR805793 1 0.0000 1.000 1.000 0.000 0 0 0.000
#> SRR805794 1 0.0000 1.000 1.000 0.000 0 0 0.000
#> SRR805795 1 0.0000 1.000 1.000 0.000 0 0 0.000
#> SRR805796 1 0.0000 1.000 1.000 0.000 0 0 0.000
#> SRR805797 1 0.0000 1.000 1.000 0.000 0 0 0.000
#> SRR805798 1 0.0000 1.000 1.000 0.000 0 0 0.000
#> SRR805799 1 0.0162 0.996 0.996 0.000 0 0 0.004
#> SRR805800 1 0.0000 1.000 1.000 0.000 0 0 0.000
#> SRR805801 1 0.0000 1.000 1.000 0.000 0 0 0.000
#> SRR805802 5 0.0000 0.985 0.000 0.000 0 0 1.000
#> SRR805803 2 0.3210 0.723 0.000 0.788 0 0 0.212
#> SRR805804 5 0.2424 0.842 0.000 0.132 0 0 0.868
#> SRR805805 5 0.0000 0.985 0.000 0.000 0 0 1.000
#> SRR805806 5 0.0000 0.985 0.000 0.000 0 0 1.000
#> SRR805807 5 0.0000 0.985 0.000 0.000 0 0 1.000
#> SRR805808 5 0.0000 0.985 0.000 0.000 0 0 1.000
#> SRR805809 5 0.0000 0.985 0.000 0.000 0 0 1.000
#> SRR805810 5 0.0000 0.985 0.000 0.000 0 0 1.000
#> SRR805811 5 0.0000 0.985 0.000 0.000 0 0 1.000
#> SRR805812 5 0.0000 0.985 0.000 0.000 0 0 1.000
#> SRR805813 4 0.0000 1.000 0.000 0.000 0 1 0.000
#> SRR805814 4 0.0000 1.000 0.000 0.000 0 1 0.000
#> SRR805815 4 0.0000 1.000 0.000 0.000 0 1 0.000
#> SRR805816 4 0.0000 1.000 0.000 0.000 0 1 0.000
#> SRR805817 4 0.0000 1.000 0.000 0.000 0 1 0.000
#> SRR805818 4 0.0000 1.000 0.000 0.000 0 1 0.000
#> SRR805819 4 0.0000 1.000 0.000 0.000 0 1 0.000
#> SRR805820 4 0.0000 1.000 0.000 0.000 0 1 0.000
#> SRR805821 4 0.0000 1.000 0.000 0.000 0 1 0.000
#> SRR805822 4 0.0000 1.000 0.000 0.000 0 1 0.000
#> SRR805823 4 0.0000 1.000 0.000 0.000 0 1 0.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1 0 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1 0 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1 0 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1 0 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1 0 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1 0 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1 0 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1 0 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1 0 0.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0000 0.967 0.000 1.000 0 0.000 0.000 0.000
#> SRR805781 2 0.0000 0.967 0.000 1.000 0 0.000 0.000 0.000
#> SRR805782 2 0.0000 0.967 0.000 1.000 0 0.000 0.000 0.000
#> SRR805784 2 0.0000 0.967 0.000 1.000 0 0.000 0.000 0.000
#> SRR805785 2 0.0000 0.967 0.000 1.000 0 0.000 0.000 0.000
#> SRR805786 2 0.0000 0.967 0.000 1.000 0 0.000 0.000 0.000
#> SRR805787 2 0.0000 0.967 0.000 1.000 0 0.000 0.000 0.000
#> SRR805788 2 0.0000 0.967 0.000 1.000 0 0.000 0.000 0.000
#> SRR805789 2 0.0000 0.967 0.000 1.000 0 0.000 0.000 0.000
#> SRR805790 2 0.0000 0.967 0.000 1.000 0 0.000 0.000 0.000
#> SRR805791 6 0.3727 1.000 0.388 0.000 0 0.000 0.000 0.612
#> SRR805792 6 0.3727 1.000 0.388 0.000 0 0.000 0.000 0.612
#> SRR805793 6 0.3727 1.000 0.388 0.000 0 0.000 0.000 0.612
#> SRR805794 6 0.3727 1.000 0.388 0.000 0 0.000 0.000 0.612
#> SRR805795 1 0.0000 0.942 1.000 0.000 0 0.000 0.000 0.000
#> SRR805796 1 0.0000 0.942 1.000 0.000 0 0.000 0.000 0.000
#> SRR805797 1 0.0547 0.935 0.980 0.000 0 0.000 0.000 0.020
#> SRR805798 1 0.0547 0.935 0.980 0.000 0 0.000 0.000 0.020
#> SRR805799 1 0.2631 0.731 0.820 0.000 0 0.000 0.000 0.180
#> SRR805800 1 0.0000 0.942 1.000 0.000 0 0.000 0.000 0.000
#> SRR805801 1 0.0000 0.942 1.000 0.000 0 0.000 0.000 0.000
#> SRR805802 5 0.0000 0.958 0.000 0.000 0 0.000 1.000 0.000
#> SRR805803 2 0.4815 0.592 0.000 0.668 0 0.000 0.188 0.144
#> SRR805804 5 0.4603 0.684 0.000 0.148 0 0.000 0.696 0.156
#> SRR805805 5 0.1007 0.940 0.000 0.000 0 0.000 0.956 0.044
#> SRR805806 5 0.0000 0.958 0.000 0.000 0 0.000 1.000 0.000
#> SRR805807 5 0.0458 0.952 0.000 0.000 0 0.000 0.984 0.016
#> SRR805808 5 0.0000 0.958 0.000 0.000 0 0.000 1.000 0.000
#> SRR805809 5 0.1075 0.938 0.000 0.000 0 0.000 0.952 0.048
#> SRR805810 5 0.0000 0.958 0.000 0.000 0 0.000 1.000 0.000
#> SRR805811 5 0.0260 0.955 0.000 0.000 0 0.000 0.992 0.008
#> SRR805812 5 0.0000 0.958 0.000 0.000 0 0.000 1.000 0.000
#> SRR805813 4 0.0000 0.999 0.000 0.000 0 1.000 0.000 0.000
#> SRR805814 4 0.0146 0.997 0.000 0.000 0 0.996 0.000 0.004
#> SRR805815 4 0.0000 0.999 0.000 0.000 0 1.000 0.000 0.000
#> SRR805816 4 0.0146 0.997 0.000 0.000 0 0.996 0.000 0.004
#> SRR805817 4 0.0000 0.999 0.000 0.000 0 1.000 0.000 0.000
#> SRR805818 4 0.0000 0.999 0.000 0.000 0 1.000 0.000 0.000
#> SRR805819 4 0.0000 0.999 0.000 0.000 0 1.000 0.000 0.000
#> SRR805820 4 0.0000 0.999 0.000 0.000 0 1.000 0.000 0.000
#> SRR805821 4 0.0000 0.999 0.000 0.000 0 1.000 0.000 0.000
#> SRR805822 4 0.0000 0.999 0.000 0.000 0 1.000 0.000 0.000
#> SRR805823 4 0.0000 0.999 0.000 0.000 0 1.000 0.000 0.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1 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", "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 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.780 0.860 0.943 0.4734 0.521 0.521
#> 3 3 0.874 0.901 0.955 0.3451 0.736 0.544
#> 4 4 0.860 0.901 0.927 0.1795 0.872 0.659
#> 5 5 1.000 0.954 0.975 0.0847 0.895 0.608
#> 6 6 0.981 0.935 0.967 0.0207 0.979 0.887
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 5
There is also optional best \(k\) = 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.0000 0.924 0.000 1.000
#> SRR805781 2 0.0000 0.924 0.000 1.000
#> SRR805782 2 0.0000 0.924 0.000 1.000
#> SRR805784 2 0.0000 0.924 0.000 1.000
#> SRR805785 2 0.0000 0.924 0.000 1.000
#> SRR805786 2 0.0000 0.924 0.000 1.000
#> SRR805787 2 0.0000 0.924 0.000 1.000
#> SRR805788 2 0.0000 0.924 0.000 1.000
#> SRR805789 2 0.0000 0.924 0.000 1.000
#> SRR805790 2 0.0000 0.924 0.000 1.000
#> SRR805791 1 0.3274 0.908 0.940 0.060
#> SRR805792 1 0.3584 0.901 0.932 0.068
#> SRR805793 1 0.9491 0.435 0.632 0.368
#> SRR805794 1 0.6801 0.789 0.820 0.180
#> SRR805795 1 0.0000 0.940 1.000 0.000
#> SRR805796 1 0.0000 0.940 1.000 0.000
#> SRR805797 1 0.0000 0.940 1.000 0.000
#> SRR805798 1 0.0000 0.940 1.000 0.000
#> SRR805799 1 0.0000 0.940 1.000 0.000
#> SRR805800 1 0.0000 0.940 1.000 0.000
#> SRR805801 1 0.0000 0.940 1.000 0.000
#> SRR805802 2 0.0376 0.922 0.004 0.996
#> SRR805803 2 0.0000 0.924 0.000 1.000
#> SRR805804 2 0.0000 0.924 0.000 1.000
#> SRR805805 2 0.0000 0.924 0.000 1.000
#> SRR805806 2 0.9552 0.367 0.376 0.624
#> SRR805807 1 0.0000 0.940 1.000 0.000
#> SRR805808 2 0.0938 0.916 0.012 0.988
#> SRR805809 2 0.0000 0.924 0.000 1.000
#> SRR805810 2 0.9775 0.268 0.412 0.588
#> SRR805811 1 0.7376 0.749 0.792 0.208
#> SRR805812 2 0.1633 0.906 0.024 0.976
#> SRR805813 1 0.0000 0.940 1.000 0.000
#> SRR805814 1 0.0000 0.940 1.000 0.000
#> SRR805815 1 0.0000 0.940 1.000 0.000
#> SRR805816 1 0.0000 0.940 1.000 0.000
#> SRR805817 1 0.0000 0.940 1.000 0.000
#> SRR805818 1 0.0000 0.940 1.000 0.000
#> SRR805819 1 0.0000 0.940 1.000 0.000
#> SRR805820 1 0.0000 0.940 1.000 0.000
#> SRR805821 1 0.0000 0.940 1.000 0.000
#> SRR805822 1 0.0000 0.940 1.000 0.000
#> SRR805823 1 0.0000 0.940 1.000 0.000
#> SRR805824 1 0.0000 0.940 1.000 0.000
#> SRR805825 2 0.9933 0.133 0.452 0.548
#> SRR805826 1 0.5408 0.852 0.876 0.124
#> SRR805828 1 0.0376 0.939 0.996 0.004
#> SRR805829 1 0.0938 0.935 0.988 0.012
#> SRR805830 1 0.2948 0.912 0.948 0.052
#> SRR805831 1 0.0000 0.940 1.000 0.000
#> SRR805832 1 0.9866 0.249 0.568 0.432
#> SRR805833 1 0.6148 0.823 0.848 0.152
#> SRR805834 1 0.4161 0.889 0.916 0.084
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.0000 0.975 0.000 1.000 0.000
#> SRR805781 2 0.0000 0.975 0.000 1.000 0.000
#> SRR805782 2 0.0000 0.975 0.000 1.000 0.000
#> SRR805784 2 0.0000 0.975 0.000 1.000 0.000
#> SRR805785 2 0.0000 0.975 0.000 1.000 0.000
#> SRR805786 2 0.0000 0.975 0.000 1.000 0.000
#> SRR805787 2 0.0000 0.975 0.000 1.000 0.000
#> SRR805788 2 0.0000 0.975 0.000 1.000 0.000
#> SRR805789 2 0.0000 0.975 0.000 1.000 0.000
#> SRR805790 2 0.0000 0.975 0.000 1.000 0.000
#> SRR805791 1 0.0592 0.910 0.988 0.012 0.000
#> SRR805792 1 0.1129 0.905 0.976 0.004 0.020
#> SRR805793 1 0.7199 0.612 0.676 0.260 0.064
#> SRR805794 1 0.2356 0.874 0.928 0.072 0.000
#> SRR805795 1 0.0000 0.914 1.000 0.000 0.000
#> SRR805796 1 0.0000 0.914 1.000 0.000 0.000
#> SRR805797 1 0.0000 0.914 1.000 0.000 0.000
#> SRR805798 1 0.0000 0.914 1.000 0.000 0.000
#> SRR805799 1 0.0000 0.914 1.000 0.000 0.000
#> SRR805800 1 0.0000 0.914 1.000 0.000 0.000
#> SRR805801 1 0.0000 0.914 1.000 0.000 0.000
#> SRR805802 2 0.2165 0.907 0.064 0.936 0.000
#> SRR805803 2 0.0000 0.975 0.000 1.000 0.000
#> SRR805804 2 0.0000 0.975 0.000 1.000 0.000
#> SRR805805 2 0.0000 0.975 0.000 1.000 0.000
#> SRR805806 1 0.5465 0.631 0.712 0.288 0.000
#> SRR805807 1 0.0000 0.914 1.000 0.000 0.000
#> SRR805808 2 0.5016 0.648 0.240 0.760 0.000
#> SRR805809 2 0.0000 0.975 0.000 1.000 0.000
#> SRR805810 1 0.5291 0.662 0.732 0.268 0.000
#> SRR805811 1 0.3941 0.801 0.844 0.156 0.000
#> SRR805812 1 0.6252 0.273 0.556 0.444 0.000
#> SRR805813 1 0.0000 0.914 1.000 0.000 0.000
#> SRR805814 1 0.5560 0.562 0.700 0.000 0.300
#> SRR805815 1 0.2878 0.847 0.904 0.000 0.096
#> SRR805816 1 0.2537 0.861 0.920 0.000 0.080
#> SRR805817 1 0.0000 0.914 1.000 0.000 0.000
#> SRR805818 1 0.0000 0.914 1.000 0.000 0.000
#> SRR805819 1 0.0747 0.907 0.984 0.000 0.016
#> SRR805820 1 0.0592 0.909 0.988 0.000 0.012
#> SRR805821 1 0.0000 0.914 1.000 0.000 0.000
#> SRR805822 1 0.0000 0.914 1.000 0.000 0.000
#> SRR805823 1 0.0000 0.914 1.000 0.000 0.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.0000 0.946 0.000 1.000 0.000 0.000
#> SRR805781 2 0.0000 0.946 0.000 1.000 0.000 0.000
#> SRR805782 2 0.0000 0.946 0.000 1.000 0.000 0.000
#> SRR805784 2 0.0000 0.946 0.000 1.000 0.000 0.000
#> SRR805785 2 0.0000 0.946 0.000 1.000 0.000 0.000
#> SRR805786 2 0.0188 0.943 0.004 0.996 0.000 0.000
#> SRR805787 2 0.0000 0.946 0.000 1.000 0.000 0.000
#> SRR805788 2 0.0000 0.946 0.000 1.000 0.000 0.000
#> SRR805789 2 0.0000 0.946 0.000 1.000 0.000 0.000
#> SRR805790 2 0.0000 0.946 0.000 1.000 0.000 0.000
#> SRR805791 1 0.3307 0.857 0.868 0.028 0.000 0.104
#> SRR805792 1 0.3342 0.855 0.868 0.032 0.000 0.100
#> SRR805793 1 0.3453 0.845 0.868 0.052 0.000 0.080
#> SRR805794 1 0.3372 0.854 0.868 0.036 0.000 0.096
#> SRR805795 1 0.2814 0.860 0.868 0.000 0.000 0.132
#> SRR805796 1 0.2814 0.860 0.868 0.000 0.000 0.132
#> SRR805797 1 0.2814 0.860 0.868 0.000 0.000 0.132
#> SRR805798 1 0.2814 0.860 0.868 0.000 0.000 0.132
#> SRR805799 1 0.2814 0.860 0.868 0.000 0.000 0.132
#> SRR805800 1 0.2814 0.860 0.868 0.000 0.000 0.132
#> SRR805801 1 0.2814 0.860 0.868 0.000 0.000 0.132
#> SRR805802 2 0.2814 0.907 0.132 0.868 0.000 0.000
#> SRR805803 2 0.2814 0.907 0.132 0.868 0.000 0.000
#> SRR805804 2 0.2814 0.907 0.132 0.868 0.000 0.000
#> SRR805805 2 0.2814 0.907 0.132 0.868 0.000 0.000
#> SRR805806 1 0.5410 0.597 0.728 0.192 0.000 0.080
#> SRR805807 1 0.4382 0.622 0.704 0.000 0.000 0.296
#> SRR805808 2 0.3831 0.832 0.204 0.792 0.000 0.004
#> SRR805809 2 0.2814 0.907 0.132 0.868 0.000 0.000
#> SRR805810 1 0.4022 0.714 0.836 0.096 0.000 0.068
#> SRR805811 1 0.4818 0.623 0.748 0.036 0.000 0.216
#> SRR805812 1 0.5203 0.302 0.636 0.348 0.000 0.016
#> SRR805813 4 0.0000 0.977 0.000 0.000 0.000 1.000
#> SRR805814 4 0.2174 0.925 0.020 0.000 0.052 0.928
#> SRR805815 4 0.1211 0.956 0.000 0.000 0.040 0.960
#> SRR805816 4 0.1302 0.952 0.000 0.000 0.044 0.956
#> SRR805817 4 0.0336 0.977 0.000 0.000 0.008 0.992
#> SRR805818 4 0.0000 0.977 0.000 0.000 0.000 1.000
#> SRR805819 4 0.0336 0.977 0.000 0.000 0.008 0.992
#> SRR805820 4 0.0336 0.977 0.000 0.000 0.008 0.992
#> SRR805821 4 0.0000 0.977 0.000 0.000 0.000 1.000
#> SRR805822 4 0.0000 0.977 0.000 0.000 0.000 1.000
#> SRR805823 4 0.0000 0.977 0.000 0.000 0.000 1.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805834 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
#> SRR805780 2 0.0000 0.982 0.000 1.000 0 0.000 0.000
#> SRR805781 2 0.1671 0.925 0.000 0.924 0 0.000 0.076
#> SRR805782 2 0.1341 0.945 0.000 0.944 0 0.000 0.056
#> SRR805784 2 0.0000 0.982 0.000 1.000 0 0.000 0.000
#> SRR805785 2 0.0000 0.982 0.000 1.000 0 0.000 0.000
#> SRR805786 2 0.0000 0.982 0.000 1.000 0 0.000 0.000
#> SRR805787 2 0.0162 0.983 0.000 0.996 0 0.000 0.004
#> SRR805788 2 0.0162 0.983 0.000 0.996 0 0.000 0.004
#> SRR805789 2 0.0162 0.983 0.000 0.996 0 0.000 0.004
#> SRR805790 2 0.0290 0.981 0.000 0.992 0 0.000 0.008
#> SRR805791 1 0.1732 0.940 0.920 0.080 0 0.000 0.000
#> SRR805792 1 0.1608 0.945 0.928 0.072 0 0.000 0.000
#> SRR805793 1 0.1732 0.940 0.920 0.080 0 0.000 0.000
#> SRR805794 1 0.1544 0.947 0.932 0.068 0 0.000 0.000
#> SRR805795 1 0.0000 0.968 1.000 0.000 0 0.000 0.000
#> SRR805796 1 0.0000 0.968 1.000 0.000 0 0.000 0.000
#> SRR805797 1 0.0000 0.968 1.000 0.000 0 0.000 0.000
#> SRR805798 1 0.0000 0.968 1.000 0.000 0 0.000 0.000
#> SRR805799 1 0.0000 0.968 1.000 0.000 0 0.000 0.000
#> SRR805800 1 0.0162 0.968 0.996 0.004 0 0.000 0.000
#> SRR805801 1 0.0000 0.968 1.000 0.000 0 0.000 0.000
#> SRR805802 5 0.0000 0.916 0.000 0.000 0 0.000 1.000
#> SRR805803 5 0.4138 0.352 0.000 0.384 0 0.000 0.616
#> SRR805804 5 0.1478 0.876 0.000 0.064 0 0.000 0.936
#> SRR805805 5 0.0000 0.916 0.000 0.000 0 0.000 1.000
#> SRR805806 5 0.0794 0.912 0.028 0.000 0 0.000 0.972
#> SRR805807 5 0.4238 0.757 0.164 0.000 0 0.068 0.768
#> SRR805808 5 0.0000 0.916 0.000 0.000 0 0.000 1.000
#> SRR805809 5 0.0000 0.916 0.000 0.000 0 0.000 1.000
#> SRR805810 5 0.1121 0.906 0.044 0.000 0 0.000 0.956
#> SRR805811 5 0.2006 0.886 0.072 0.000 0 0.012 0.916
#> SRR805812 5 0.0290 0.916 0.008 0.000 0 0.000 0.992
#> SRR805813 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805814 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805815 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805816 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805817 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805818 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805819 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805820 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805821 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805822 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805823 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0146 0.950 0.000 0.996 0 0 0.000 0.004
#> SRR805781 6 0.3747 0.218 0.000 0.396 0 0 0.000 0.604
#> SRR805782 2 0.3221 0.561 0.000 0.736 0 0 0.000 0.264
#> SRR805784 2 0.0951 0.925 0.004 0.968 0 0 0.008 0.020
#> SRR805785 2 0.0000 0.950 0.000 1.000 0 0 0.000 0.000
#> SRR805786 2 0.0000 0.950 0.000 1.000 0 0 0.000 0.000
#> SRR805787 2 0.0363 0.947 0.000 0.988 0 0 0.000 0.012
#> SRR805788 2 0.0363 0.947 0.000 0.988 0 0 0.000 0.012
#> SRR805789 2 0.0146 0.950 0.000 0.996 0 0 0.000 0.004
#> SRR805790 2 0.0000 0.950 0.000 1.000 0 0 0.000 0.000
#> SRR805791 1 0.0000 0.980 1.000 0.000 0 0 0.000 0.000
#> SRR805792 1 0.0000 0.980 1.000 0.000 0 0 0.000 0.000
#> SRR805793 1 0.0000 0.980 1.000 0.000 0 0 0.000 0.000
#> SRR805794 1 0.0000 0.980 1.000 0.000 0 0 0.000 0.000
#> SRR805795 1 0.0000 0.980 1.000 0.000 0 0 0.000 0.000
#> SRR805796 1 0.0000 0.980 1.000 0.000 0 0 0.000 0.000
#> SRR805797 1 0.0000 0.980 1.000 0.000 0 0 0.000 0.000
#> SRR805798 1 0.0000 0.980 1.000 0.000 0 0 0.000 0.000
#> SRR805799 1 0.3542 0.773 0.788 0.000 0 0 0.052 0.160
#> SRR805800 1 0.0000 0.980 1.000 0.000 0 0 0.000 0.000
#> SRR805801 1 0.0000 0.980 1.000 0.000 0 0 0.000 0.000
#> SRR805802 5 0.1267 0.946 0.000 0.000 0 0 0.940 0.060
#> SRR805803 6 0.3254 0.653 0.000 0.048 0 0 0.136 0.816
#> SRR805804 6 0.3725 0.482 0.000 0.008 0 0 0.316 0.676
#> SRR805805 5 0.1267 0.946 0.000 0.000 0 0 0.940 0.060
#> SRR805806 5 0.0000 0.956 0.000 0.000 0 0 1.000 0.000
#> SRR805807 5 0.1411 0.910 0.004 0.000 0 0 0.936 0.060
#> SRR805808 5 0.1082 0.954 0.004 0.000 0 0 0.956 0.040
#> SRR805809 5 0.1075 0.951 0.000 0.000 0 0 0.952 0.048
#> SRR805810 5 0.0260 0.953 0.000 0.000 0 0 0.992 0.008
#> SRR805811 5 0.0547 0.947 0.000 0.000 0 0 0.980 0.020
#> SRR805812 5 0.0260 0.957 0.000 0.000 0 0 0.992 0.008
#> SRR805813 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805814 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805815 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805816 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805817 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805818 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805819 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805820 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805821 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805822 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805823 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "hclust"]
# you can also extract it by
# res = res_list["CV:hclust"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.509 0.913 0.936 0.0971 0.962 0.962
#> 3 3 0.328 0.741 0.865 1.4796 0.963 0.962
#> 4 4 0.474 0.734 0.866 1.2229 0.543 0.506
#> 5 5 0.835 0.835 0.921 0.2116 0.920 0.829
#> 6 6 0.972 0.905 0.971 0.1601 0.863 0.647
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
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
#> SRR805780 1 0.163 0.932 0.976 0.024
#> SRR805781 1 0.163 0.932 0.976 0.024
#> SRR805782 1 0.163 0.932 0.976 0.024
#> SRR805784 1 0.163 0.932 0.976 0.024
#> SRR805785 1 0.163 0.932 0.976 0.024
#> SRR805786 1 0.163 0.932 0.976 0.024
#> SRR805787 1 0.163 0.932 0.976 0.024
#> SRR805788 1 0.163 0.932 0.976 0.024
#> SRR805789 1 0.163 0.932 0.976 0.024
#> SRR805790 1 0.163 0.932 0.976 0.024
#> SRR805791 1 0.518 0.917 0.884 0.116
#> SRR805792 1 0.518 0.917 0.884 0.116
#> SRR805793 1 0.518 0.917 0.884 0.116
#> SRR805794 1 0.518 0.917 0.884 0.116
#> SRR805795 1 0.518 0.917 0.884 0.116
#> SRR805796 1 0.518 0.917 0.884 0.116
#> SRR805797 1 0.518 0.917 0.884 0.116
#> SRR805798 1 0.518 0.917 0.884 0.116
#> SRR805799 2 0.163 0.000 0.024 0.976
#> SRR805800 1 0.518 0.917 0.884 0.116
#> SRR805801 1 0.518 0.917 0.884 0.116
#> SRR805802 1 0.000 0.943 1.000 0.000
#> SRR805803 1 0.000 0.943 1.000 0.000
#> SRR805804 1 0.000 0.943 1.000 0.000
#> SRR805805 1 0.000 0.943 1.000 0.000
#> SRR805806 1 0.000 0.943 1.000 0.000
#> SRR805807 1 0.000 0.943 1.000 0.000
#> SRR805808 1 0.000 0.943 1.000 0.000
#> SRR805809 1 0.000 0.943 1.000 0.000
#> SRR805810 1 0.000 0.943 1.000 0.000
#> SRR805811 1 0.000 0.943 1.000 0.000
#> SRR805812 1 0.000 0.943 1.000 0.000
#> SRR805813 1 0.506 0.918 0.888 0.112
#> SRR805814 1 0.506 0.918 0.888 0.112
#> SRR805815 1 0.506 0.918 0.888 0.112
#> SRR805816 1 0.506 0.918 0.888 0.112
#> SRR805817 1 0.506 0.918 0.888 0.112
#> SRR805818 1 0.506 0.918 0.888 0.112
#> SRR805819 1 0.506 0.918 0.888 0.112
#> SRR805820 1 0.506 0.918 0.888 0.112
#> SRR805821 1 0.506 0.918 0.888 0.112
#> SRR805822 1 0.506 0.918 0.888 0.112
#> SRR805823 1 0.506 0.918 0.888 0.112
#> SRR805824 1 0.000 0.943 1.000 0.000
#> SRR805825 1 0.000 0.943 1.000 0.000
#> SRR805826 1 0.000 0.943 1.000 0.000
#> SRR805828 1 0.000 0.943 1.000 0.000
#> SRR805829 1 0.000 0.943 1.000 0.000
#> SRR805830 1 0.000 0.943 1.000 0.000
#> SRR805831 1 0.000 0.943 1.000 0.000
#> SRR805832 1 0.000 0.943 1.000 0.000
#> SRR805833 1 0.000 0.943 1.000 0.000
#> SRR805834 1 0.000 0.943 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 1 0.625 0.417 0.556 0.444 0.000
#> SRR805781 1 0.625 0.417 0.556 0.444 0.000
#> SRR805782 1 0.625 0.417 0.556 0.444 0.000
#> SRR805784 2 0.000 0.000 0.000 1.000 0.000
#> SRR805785 1 0.625 0.417 0.556 0.444 0.000
#> SRR805786 1 0.625 0.417 0.556 0.444 0.000
#> SRR805787 1 0.625 0.417 0.556 0.444 0.000
#> SRR805788 1 0.625 0.417 0.556 0.444 0.000
#> SRR805789 1 0.625 0.417 0.556 0.444 0.000
#> SRR805790 1 0.625 0.417 0.556 0.444 0.000
#> SRR805791 1 0.263 0.854 0.916 0.000 0.084
#> SRR805792 1 0.263 0.854 0.916 0.000 0.084
#> SRR805793 1 0.263 0.854 0.916 0.000 0.084
#> SRR805794 1 0.263 0.854 0.916 0.000 0.084
#> SRR805795 1 0.263 0.854 0.916 0.000 0.084
#> SRR805796 1 0.263 0.854 0.916 0.000 0.084
#> SRR805797 1 0.263 0.854 0.916 0.000 0.084
#> SRR805798 1 0.263 0.854 0.916 0.000 0.084
#> SRR805799 3 0.129 0.000 0.032 0.000 0.968
#> SRR805800 1 0.263 0.854 0.916 0.000 0.084
#> SRR805801 1 0.263 0.854 0.916 0.000 0.084
#> SRR805802 1 0.129 0.852 0.968 0.032 0.000
#> SRR805803 1 0.493 0.687 0.768 0.232 0.000
#> SRR805804 1 0.493 0.687 0.768 0.232 0.000
#> SRR805805 1 0.129 0.852 0.968 0.032 0.000
#> SRR805806 1 0.129 0.852 0.968 0.032 0.000
#> SRR805807 1 0.129 0.852 0.968 0.032 0.000
#> SRR805808 1 0.186 0.844 0.948 0.052 0.000
#> SRR805809 1 0.186 0.844 0.948 0.052 0.000
#> SRR805810 1 0.129 0.852 0.968 0.032 0.000
#> SRR805811 1 0.129 0.852 0.968 0.032 0.000
#> SRR805812 1 0.129 0.852 0.968 0.032 0.000
#> SRR805813 1 0.254 0.855 0.920 0.000 0.080
#> SRR805814 1 0.254 0.855 0.920 0.000 0.080
#> SRR805815 1 0.254 0.855 0.920 0.000 0.080
#> SRR805816 1 0.254 0.855 0.920 0.000 0.080
#> SRR805817 1 0.254 0.855 0.920 0.000 0.080
#> SRR805818 1 0.254 0.855 0.920 0.000 0.080
#> SRR805819 1 0.254 0.855 0.920 0.000 0.080
#> SRR805820 1 0.254 0.855 0.920 0.000 0.080
#> SRR805821 1 0.254 0.855 0.920 0.000 0.080
#> SRR805822 1 0.254 0.855 0.920 0.000 0.080
#> SRR805823 1 0.254 0.855 0.920 0.000 0.080
#> SRR805824 1 0.129 0.852 0.968 0.000 0.032
#> SRR805825 1 0.129 0.852 0.968 0.000 0.032
#> SRR805826 1 0.129 0.852 0.968 0.000 0.032
#> SRR805828 1 0.129 0.852 0.968 0.000 0.032
#> SRR805829 1 0.129 0.852 0.968 0.000 0.032
#> SRR805830 1 0.129 0.852 0.968 0.000 0.032
#> SRR805831 1 0.129 0.852 0.968 0.000 0.032
#> SRR805832 1 0.129 0.852 0.968 0.000 0.032
#> SRR805833 1 0.129 0.852 0.968 0.000 0.032
#> SRR805834 1 0.129 0.852 0.968 0.000 0.032
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.3569 0.571 0.000 0.804 0.196 0.000
#> SRR805781 2 0.3569 0.571 0.000 0.804 0.196 0.000
#> SRR805782 2 0.3569 0.571 0.000 0.804 0.196 0.000
#> SRR805784 3 0.1211 0.000 0.000 0.040 0.960 0.000
#> SRR805785 2 0.3569 0.571 0.000 0.804 0.196 0.000
#> SRR805786 2 0.3569 0.571 0.000 0.804 0.196 0.000
#> SRR805787 2 0.3569 0.571 0.000 0.804 0.196 0.000
#> SRR805788 2 0.3569 0.571 0.000 0.804 0.196 0.000
#> SRR805789 2 0.3569 0.571 0.000 0.804 0.196 0.000
#> SRR805790 2 0.3569 0.571 0.000 0.804 0.196 0.000
#> SRR805791 4 0.0188 0.923 0.004 0.000 0.000 0.996
#> SRR805792 4 0.0188 0.923 0.004 0.000 0.000 0.996
#> SRR805793 4 0.0188 0.923 0.004 0.000 0.000 0.996
#> SRR805794 4 0.0188 0.923 0.004 0.000 0.000 0.996
#> SRR805795 4 0.0188 0.923 0.004 0.000 0.000 0.996
#> SRR805796 4 0.0188 0.923 0.004 0.000 0.000 0.996
#> SRR805797 4 0.0188 0.923 0.004 0.000 0.000 0.996
#> SRR805798 4 0.0188 0.923 0.004 0.000 0.000 0.996
#> SRR805799 1 0.2530 0.000 0.888 0.000 0.000 0.112
#> SRR805800 4 0.0188 0.923 0.004 0.000 0.000 0.996
#> SRR805801 4 0.0188 0.923 0.004 0.000 0.000 0.996
#> SRR805802 4 0.4504 0.827 0.088 0.040 0.040 0.832
#> SRR805803 2 0.5689 0.510 0.088 0.764 0.040 0.108
#> SRR805804 2 0.5689 0.510 0.088 0.764 0.040 0.108
#> SRR805805 4 0.4504 0.827 0.088 0.040 0.040 0.832
#> SRR805806 4 0.4504 0.827 0.088 0.040 0.040 0.832
#> SRR805807 4 0.4504 0.827 0.088 0.040 0.040 0.832
#> SRR805808 4 0.5126 0.792 0.088 0.072 0.040 0.800
#> SRR805809 4 0.7512 0.243 0.088 0.332 0.040 0.540
#> SRR805810 4 0.4504 0.827 0.088 0.040 0.040 0.832
#> SRR805811 4 0.4504 0.827 0.088 0.040 0.040 0.832
#> SRR805812 4 0.4504 0.827 0.088 0.040 0.040 0.832
#> SRR805813 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> SRR805814 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> SRR805815 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> SRR805816 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> SRR805817 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> SRR805818 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> SRR805819 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> SRR805820 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> SRR805821 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> SRR805822 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> SRR805823 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> SRR805824 2 0.4868 0.654 0.024 0.720 0.000 0.256
#> SRR805825 2 0.4868 0.654 0.024 0.720 0.000 0.256
#> SRR805826 2 0.4868 0.654 0.024 0.720 0.000 0.256
#> SRR805828 2 0.4868 0.654 0.024 0.720 0.000 0.256
#> SRR805829 2 0.4868 0.654 0.024 0.720 0.000 0.256
#> SRR805830 2 0.4868 0.654 0.024 0.720 0.000 0.256
#> SRR805831 2 0.4868 0.654 0.024 0.720 0.000 0.256
#> SRR805832 2 0.4868 0.654 0.024 0.720 0.000 0.256
#> SRR805833 2 0.4868 0.654 0.024 0.720 0.000 0.256
#> SRR805834 2 0.4868 0.654 0.024 0.720 0.000 0.256
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.0000 0.920 0.000 1.000 0.000 0.000 0.000
#> SRR805781 2 0.0000 0.920 0.000 1.000 0.000 0.000 0.000
#> SRR805782 2 0.0000 0.920 0.000 1.000 0.000 0.000 0.000
#> SRR805784 5 0.4000 0.000 0.000 0.228 0.024 0.000 0.748
#> SRR805785 2 0.0000 0.920 0.000 1.000 0.000 0.000 0.000
#> SRR805786 2 0.0000 0.920 0.000 1.000 0.000 0.000 0.000
#> SRR805787 2 0.0000 0.920 0.000 1.000 0.000 0.000 0.000
#> SRR805788 2 0.0000 0.920 0.000 1.000 0.000 0.000 0.000
#> SRR805789 2 0.0000 0.920 0.000 1.000 0.000 0.000 0.000
#> SRR805790 2 0.0000 0.920 0.000 1.000 0.000 0.000 0.000
#> SRR805791 4 0.0324 0.890 0.004 0.000 0.000 0.992 0.004
#> SRR805792 4 0.0324 0.890 0.004 0.000 0.000 0.992 0.004
#> SRR805793 4 0.0324 0.890 0.004 0.000 0.000 0.992 0.004
#> SRR805794 4 0.0324 0.890 0.004 0.000 0.000 0.992 0.004
#> SRR805795 4 0.0324 0.890 0.004 0.000 0.000 0.992 0.004
#> SRR805796 4 0.0324 0.890 0.004 0.000 0.000 0.992 0.004
#> SRR805797 4 0.0324 0.890 0.004 0.000 0.000 0.992 0.004
#> SRR805798 4 0.0324 0.890 0.004 0.000 0.000 0.992 0.004
#> SRR805799 1 0.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805800 4 0.0324 0.890 0.004 0.000 0.000 0.992 0.004
#> SRR805801 4 0.0324 0.890 0.004 0.000 0.000 0.992 0.004
#> SRR805802 4 0.4141 0.738 0.000 0.024 0.000 0.728 0.248
#> SRR805803 2 0.3521 0.617 0.000 0.764 0.000 0.004 0.232
#> SRR805804 2 0.3521 0.617 0.000 0.764 0.000 0.004 0.232
#> SRR805805 4 0.4141 0.738 0.000 0.024 0.000 0.728 0.248
#> SRR805806 4 0.4141 0.738 0.000 0.024 0.000 0.728 0.248
#> SRR805807 4 0.4141 0.738 0.000 0.024 0.000 0.728 0.248
#> SRR805808 4 0.4719 0.702 0.000 0.056 0.000 0.696 0.248
#> SRR805809 4 0.6659 0.197 0.000 0.316 0.000 0.436 0.248
#> SRR805810 4 0.4141 0.738 0.000 0.024 0.000 0.728 0.248
#> SRR805811 4 0.4141 0.738 0.000 0.024 0.000 0.728 0.248
#> SRR805812 4 0.4141 0.738 0.000 0.024 0.000 0.728 0.248
#> SRR805813 4 0.0290 0.890 0.000 0.000 0.008 0.992 0.000
#> SRR805814 4 0.0290 0.890 0.000 0.000 0.008 0.992 0.000
#> SRR805815 4 0.0290 0.890 0.000 0.000 0.008 0.992 0.000
#> SRR805816 4 0.0290 0.890 0.000 0.000 0.008 0.992 0.000
#> SRR805817 4 0.0290 0.890 0.000 0.000 0.008 0.992 0.000
#> SRR805818 4 0.0290 0.890 0.000 0.000 0.008 0.992 0.000
#> SRR805819 4 0.0290 0.890 0.000 0.000 0.008 0.992 0.000
#> SRR805820 4 0.0290 0.890 0.000 0.000 0.008 0.992 0.000
#> SRR805821 4 0.0290 0.890 0.000 0.000 0.008 0.992 0.000
#> SRR805822 4 0.0290 0.890 0.000 0.000 0.008 0.992 0.000
#> SRR805823 4 0.0290 0.890 0.000 0.000 0.008 0.992 0.000
#> SRR805824 3 0.0703 1.000 0.000 0.000 0.976 0.024 0.000
#> SRR805825 3 0.0703 1.000 0.000 0.000 0.976 0.024 0.000
#> SRR805826 3 0.0703 1.000 0.000 0.000 0.976 0.024 0.000
#> SRR805828 3 0.0703 1.000 0.000 0.000 0.976 0.024 0.000
#> SRR805829 3 0.0703 1.000 0.000 0.000 0.976 0.024 0.000
#> SRR805830 3 0.0703 1.000 0.000 0.000 0.976 0.024 0.000
#> SRR805831 3 0.0703 1.000 0.000 0.000 0.976 0.024 0.000
#> SRR805832 3 0.0703 1.000 0.000 0.000 0.976 0.024 0.000
#> SRR805833 3 0.0703 1.000 0.000 0.000 0.976 0.024 0.000
#> SRR805834 3 0.0703 1.000 0.000 0.000 0.976 0.024 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0000 0.928 0.000 1.000 0 0.000 0.000 0.00
#> SRR805781 2 0.0000 0.928 0.000 1.000 0 0.000 0.000 0.00
#> SRR805782 2 0.0000 0.928 0.000 1.000 0 0.000 0.000 0.00
#> SRR805784 6 0.0937 0.000 0.000 0.040 0 0.000 0.000 0.96
#> SRR805785 2 0.0000 0.928 0.000 1.000 0 0.000 0.000 0.00
#> SRR805786 2 0.0000 0.928 0.000 1.000 0 0.000 0.000 0.00
#> SRR805787 2 0.0000 0.928 0.000 1.000 0 0.000 0.000 0.00
#> SRR805788 2 0.0000 0.928 0.000 1.000 0 0.000 0.000 0.00
#> SRR805789 2 0.0000 0.928 0.000 1.000 0 0.000 0.000 0.00
#> SRR805790 2 0.0000 0.928 0.000 1.000 0 0.000 0.000 0.00
#> SRR805791 4 0.1442 0.964 0.004 0.000 0 0.944 0.012 0.04
#> SRR805792 4 0.1442 0.964 0.004 0.000 0 0.944 0.012 0.04
#> SRR805793 4 0.1442 0.964 0.004 0.000 0 0.944 0.012 0.04
#> SRR805794 4 0.1442 0.964 0.004 0.000 0 0.944 0.012 0.04
#> SRR805795 4 0.1442 0.964 0.004 0.000 0 0.944 0.012 0.04
#> SRR805796 4 0.1442 0.964 0.004 0.000 0 0.944 0.012 0.04
#> SRR805797 4 0.1442 0.964 0.004 0.000 0 0.944 0.012 0.04
#> SRR805798 4 0.1442 0.964 0.004 0.000 0 0.944 0.012 0.04
#> SRR805799 1 0.0000 0.000 1.000 0.000 0 0.000 0.000 0.00
#> SRR805800 4 0.1442 0.964 0.004 0.000 0 0.944 0.012 0.04
#> SRR805801 4 0.1442 0.964 0.004 0.000 0 0.944 0.012 0.04
#> SRR805802 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.00
#> SRR805803 2 0.3198 0.636 0.000 0.740 0 0.000 0.260 0.00
#> SRR805804 2 0.3198 0.636 0.000 0.740 0 0.000 0.260 0.00
#> SRR805805 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.00
#> SRR805806 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.00
#> SRR805807 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.00
#> SRR805808 5 0.0790 0.911 0.000 0.032 0 0.000 0.968 0.00
#> SRR805809 5 0.3371 0.525 0.000 0.292 0 0.000 0.708 0.00
#> SRR805810 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.00
#> SRR805811 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.00
#> SRR805812 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.00
#> SRR805813 4 0.0260 0.968 0.000 0.000 0 0.992 0.008 0.00
#> SRR805814 4 0.0260 0.968 0.000 0.000 0 0.992 0.008 0.00
#> SRR805815 4 0.0260 0.968 0.000 0.000 0 0.992 0.008 0.00
#> SRR805816 4 0.0260 0.968 0.000 0.000 0 0.992 0.008 0.00
#> SRR805817 4 0.0260 0.968 0.000 0.000 0 0.992 0.008 0.00
#> SRR805818 4 0.0260 0.968 0.000 0.000 0 0.992 0.008 0.00
#> SRR805819 4 0.0260 0.968 0.000 0.000 0 0.992 0.008 0.00
#> SRR805820 4 0.0260 0.968 0.000 0.000 0 0.992 0.008 0.00
#> SRR805821 4 0.0260 0.968 0.000 0.000 0 0.992 0.008 0.00
#> SRR805822 4 0.0260 0.968 0.000 0.000 0 0.992 0.008 0.00
#> SRR805823 4 0.0260 0.968 0.000 0.000 0 0.992 0.008 0.00
#> SRR805824 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.00
#> SRR805825 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.00
#> SRR805826 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.00
#> SRR805828 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.00
#> SRR805829 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.00
#> SRR805830 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.00
#> SRR805831 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.00
#> SRR805832 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.00
#> SRR805833 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.00
#> SRR805834 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.00
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "kmeans"]
# you can also extract it by
# res = res_list["CV:kmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 15291 rows and 53 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 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.191 0.671 0.781 0.4541 0.505 0.505
#> 3 3 0.436 0.764 0.760 0.3689 0.817 0.649
#> 4 4 0.587 0.786 0.594 0.1546 0.920 0.774
#> 5 5 0.815 0.962 0.853 0.0697 0.912 0.678
#> 6 6 0.787 0.935 0.887 0.0473 1.000 1.000
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.946 0.813 0.364 0.636
#> SRR805781 2 0.946 0.813 0.364 0.636
#> SRR805782 2 0.946 0.813 0.364 0.636
#> SRR805784 2 0.946 0.813 0.364 0.636
#> SRR805785 2 0.946 0.813 0.364 0.636
#> SRR805786 2 0.946 0.813 0.364 0.636
#> SRR805787 2 0.946 0.813 0.364 0.636
#> SRR805788 2 0.946 0.813 0.364 0.636
#> SRR805789 2 0.946 0.813 0.364 0.636
#> SRR805790 2 0.946 0.813 0.364 0.636
#> SRR805791 1 1.000 0.715 0.508 0.492
#> SRR805792 1 1.000 0.715 0.508 0.492
#> SRR805793 1 1.000 0.715 0.508 0.492
#> SRR805794 1 1.000 0.715 0.508 0.492
#> SRR805795 1 1.000 0.715 0.508 0.492
#> SRR805796 1 1.000 0.715 0.508 0.492
#> SRR805797 1 1.000 0.715 0.508 0.492
#> SRR805798 1 1.000 0.715 0.508 0.492
#> SRR805799 2 1.000 -0.727 0.488 0.512
#> SRR805800 1 1.000 0.715 0.508 0.492
#> SRR805801 1 1.000 0.715 0.508 0.492
#> SRR805802 2 0.714 0.721 0.196 0.804
#> SRR805803 2 0.909 0.809 0.324 0.676
#> SRR805804 2 0.904 0.808 0.320 0.680
#> SRR805805 2 0.738 0.754 0.208 0.792
#> SRR805806 2 0.706 0.717 0.192 0.808
#> SRR805807 2 0.760 0.376 0.220 0.780
#> SRR805808 2 0.714 0.721 0.196 0.804
#> SRR805809 2 0.904 0.808 0.320 0.680
#> SRR805810 2 0.706 0.717 0.192 0.808
#> SRR805811 2 0.706 0.717 0.192 0.808
#> SRR805812 2 0.706 0.717 0.192 0.808
#> SRR805813 1 0.997 0.734 0.532 0.468
#> SRR805814 1 0.997 0.734 0.532 0.468
#> SRR805815 1 0.997 0.734 0.532 0.468
#> SRR805816 1 0.997 0.734 0.532 0.468
#> SRR805817 1 0.997 0.734 0.532 0.468
#> SRR805818 1 0.997 0.734 0.532 0.468
#> SRR805819 1 0.997 0.734 0.532 0.468
#> SRR805820 1 0.997 0.734 0.532 0.468
#> SRR805821 1 0.997 0.734 0.532 0.468
#> SRR805822 1 0.997 0.734 0.532 0.468
#> SRR805823 1 0.997 0.734 0.532 0.468
#> SRR805824 1 0.000 0.507 1.000 0.000
#> SRR805825 1 0.000 0.507 1.000 0.000
#> SRR805826 1 0.000 0.507 1.000 0.000
#> SRR805828 1 0.000 0.507 1.000 0.000
#> SRR805829 1 0.000 0.507 1.000 0.000
#> SRR805830 1 0.000 0.507 1.000 0.000
#> SRR805831 1 0.000 0.507 1.000 0.000
#> SRR805832 1 0.000 0.507 1.000 0.000
#> SRR805833 1 0.000 0.507 1.000 0.000
#> SRR805834 1 0.000 0.507 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.0661 0.735 0.004 0.988 0.008
#> SRR805781 2 0.0661 0.735 0.004 0.988 0.008
#> SRR805782 2 0.0661 0.735 0.004 0.988 0.008
#> SRR805784 2 0.0983 0.731 0.004 0.980 0.016
#> SRR805785 2 0.0661 0.735 0.004 0.988 0.008
#> SRR805786 2 0.0661 0.735 0.004 0.988 0.008
#> SRR805787 2 0.0661 0.735 0.004 0.988 0.008
#> SRR805788 2 0.0661 0.735 0.004 0.988 0.008
#> SRR805789 2 0.0661 0.735 0.004 0.988 0.008
#> SRR805790 2 0.0661 0.735 0.004 0.988 0.008
#> SRR805791 1 0.7141 0.693 0.600 0.032 0.368
#> SRR805792 1 0.7141 0.693 0.600 0.032 0.368
#> SRR805793 1 0.7141 0.693 0.600 0.032 0.368
#> SRR805794 1 0.7141 0.693 0.600 0.032 0.368
#> SRR805795 1 0.7141 0.693 0.600 0.032 0.368
#> SRR805796 1 0.7141 0.693 0.600 0.032 0.368
#> SRR805797 1 0.7141 0.693 0.600 0.032 0.368
#> SRR805798 1 0.7141 0.693 0.600 0.032 0.368
#> SRR805799 1 0.7083 0.683 0.592 0.028 0.380
#> SRR805800 1 0.7141 0.693 0.600 0.032 0.368
#> SRR805801 1 0.7141 0.693 0.600 0.032 0.368
#> SRR805802 2 0.8872 0.719 0.156 0.556 0.288
#> SRR805803 2 0.7376 0.745 0.076 0.672 0.252
#> SRR805804 2 0.7376 0.745 0.076 0.672 0.252
#> SRR805805 2 0.8094 0.738 0.100 0.612 0.288
#> SRR805806 2 0.8872 0.719 0.156 0.556 0.288
#> SRR805807 2 0.9838 0.509 0.288 0.424 0.288
#> SRR805808 2 0.8872 0.719 0.156 0.556 0.288
#> SRR805809 2 0.7666 0.741 0.076 0.636 0.288
#> SRR805810 2 0.8872 0.719 0.156 0.556 0.288
#> SRR805811 2 0.8872 0.719 0.156 0.556 0.288
#> SRR805812 2 0.8872 0.719 0.156 0.556 0.288
#> SRR805813 1 0.1163 0.706 0.972 0.028 0.000
#> SRR805814 1 0.1163 0.706 0.972 0.028 0.000
#> SRR805815 1 0.1163 0.706 0.972 0.028 0.000
#> SRR805816 1 0.1163 0.706 0.972 0.028 0.000
#> SRR805817 1 0.1163 0.706 0.972 0.028 0.000
#> SRR805818 1 0.1163 0.706 0.972 0.028 0.000
#> SRR805819 1 0.1163 0.706 0.972 0.028 0.000
#> SRR805820 1 0.1163 0.706 0.972 0.028 0.000
#> SRR805821 1 0.1163 0.706 0.972 0.028 0.000
#> SRR805822 1 0.1163 0.706 0.972 0.028 0.000
#> SRR805823 1 0.1163 0.706 0.972 0.028 0.000
#> SRR805824 3 0.9045 0.999 0.256 0.192 0.552
#> SRR805825 3 0.9083 0.997 0.256 0.196 0.548
#> SRR805826 3 0.9045 0.999 0.256 0.192 0.552
#> SRR805828 3 0.9083 0.997 0.256 0.196 0.548
#> SRR805829 3 0.9045 0.999 0.256 0.192 0.552
#> SRR805830 3 0.9045 0.999 0.256 0.192 0.552
#> SRR805831 3 0.9045 0.999 0.256 0.192 0.552
#> SRR805832 3 0.9045 0.999 0.256 0.192 0.552
#> SRR805833 3 0.9045 0.999 0.256 0.192 0.552
#> SRR805834 3 0.9083 0.997 0.256 0.196 0.548
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.6921 0.986 0.408 0.512 0.056 0.024
#> SRR805781 2 0.6921 0.986 0.408 0.512 0.056 0.024
#> SRR805782 2 0.6921 0.986 0.408 0.512 0.056 0.024
#> SRR805784 2 0.7077 0.872 0.340 0.560 0.072 0.028
#> SRR805785 2 0.6921 0.986 0.408 0.512 0.056 0.024
#> SRR805786 2 0.6921 0.986 0.408 0.512 0.056 0.024
#> SRR805787 2 0.6921 0.986 0.408 0.512 0.056 0.024
#> SRR805788 2 0.6921 0.986 0.408 0.512 0.056 0.024
#> SRR805789 2 0.6921 0.986 0.408 0.512 0.056 0.024
#> SRR805790 2 0.6921 0.986 0.408 0.512 0.056 0.024
#> SRR805791 4 0.4948 0.552 0.100 0.000 0.124 0.776
#> SRR805792 4 0.4948 0.552 0.100 0.000 0.124 0.776
#> SRR805793 4 0.4948 0.552 0.100 0.000 0.124 0.776
#> SRR805794 4 0.4948 0.552 0.100 0.000 0.124 0.776
#> SRR805795 4 0.4948 0.552 0.100 0.000 0.124 0.776
#> SRR805796 4 0.4948 0.552 0.100 0.000 0.124 0.776
#> SRR805797 4 0.4948 0.552 0.100 0.000 0.124 0.776
#> SRR805798 4 0.4948 0.552 0.100 0.000 0.124 0.776
#> SRR805799 4 0.6160 0.511 0.084 0.056 0.124 0.736
#> SRR805800 4 0.4948 0.552 0.100 0.000 0.124 0.776
#> SRR805801 4 0.4948 0.552 0.100 0.000 0.124 0.776
#> SRR805802 1 0.1182 0.933 0.968 0.000 0.016 0.016
#> SRR805803 1 0.2675 0.751 0.892 0.100 0.008 0.000
#> SRR805804 1 0.2675 0.751 0.892 0.100 0.008 0.000
#> SRR805805 1 0.0779 0.923 0.980 0.000 0.016 0.004
#> SRR805806 1 0.1182 0.933 0.968 0.000 0.016 0.016
#> SRR805807 1 0.2021 0.863 0.932 0.000 0.012 0.056
#> SRR805808 1 0.1182 0.933 0.968 0.000 0.016 0.016
#> SRR805809 1 0.1406 0.890 0.960 0.024 0.016 0.000
#> SRR805810 1 0.1182 0.933 0.968 0.000 0.016 0.016
#> SRR805811 1 0.1182 0.933 0.968 0.000 0.016 0.016
#> SRR805812 1 0.1182 0.933 0.968 0.000 0.016 0.016
#> SRR805813 4 0.8104 0.564 0.060 0.336 0.108 0.496
#> SRR805814 4 0.8104 0.564 0.060 0.336 0.108 0.496
#> SRR805815 4 0.8104 0.564 0.060 0.336 0.108 0.496
#> SRR805816 4 0.8104 0.564 0.060 0.336 0.108 0.496
#> SRR805817 4 0.8104 0.564 0.060 0.336 0.108 0.496
#> SRR805818 4 0.8104 0.564 0.060 0.336 0.108 0.496
#> SRR805819 4 0.8104 0.564 0.060 0.336 0.108 0.496
#> SRR805820 4 0.8104 0.564 0.060 0.336 0.108 0.496
#> SRR805821 4 0.8104 0.564 0.060 0.336 0.108 0.496
#> SRR805822 4 0.8104 0.564 0.060 0.336 0.108 0.496
#> SRR805823 4 0.8104 0.564 0.060 0.336 0.108 0.496
#> SRR805824 3 0.1377 0.991 0.008 0.008 0.964 0.020
#> SRR805825 3 0.1745 0.989 0.008 0.020 0.952 0.020
#> SRR805826 3 0.1042 0.993 0.008 0.000 0.972 0.020
#> SRR805828 3 0.1958 0.986 0.008 0.028 0.944 0.020
#> SRR805829 3 0.1377 0.992 0.008 0.008 0.964 0.020
#> SRR805830 3 0.1042 0.993 0.008 0.000 0.972 0.020
#> SRR805831 3 0.1042 0.993 0.008 0.000 0.972 0.020
#> SRR805832 3 0.1509 0.992 0.008 0.012 0.960 0.020
#> SRR805833 3 0.1229 0.992 0.008 0.004 0.968 0.020
#> SRR805834 3 0.1745 0.990 0.008 0.020 0.952 0.020
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.3724 0.978 0.000 0.776 0.020 0.000 0.204
#> SRR805781 2 0.3724 0.978 0.000 0.776 0.020 0.000 0.204
#> SRR805782 2 0.3724 0.978 0.000 0.776 0.020 0.000 0.204
#> SRR805784 2 0.5504 0.792 0.104 0.708 0.036 0.000 0.152
#> SRR805785 2 0.3724 0.978 0.000 0.776 0.020 0.000 0.204
#> SRR805786 2 0.3724 0.978 0.000 0.776 0.020 0.000 0.204
#> SRR805787 2 0.3724 0.978 0.000 0.776 0.020 0.000 0.204
#> SRR805788 2 0.3724 0.978 0.000 0.776 0.020 0.000 0.204
#> SRR805789 2 0.3724 0.978 0.000 0.776 0.020 0.000 0.204
#> SRR805790 2 0.3724 0.978 0.000 0.776 0.020 0.000 0.204
#> SRR805791 1 0.6019 0.978 0.660 0.012 0.060 0.224 0.044
#> SRR805792 1 0.6019 0.978 0.660 0.012 0.060 0.224 0.044
#> SRR805793 1 0.6019 0.978 0.660 0.012 0.060 0.224 0.044
#> SRR805794 1 0.6019 0.978 0.660 0.012 0.060 0.224 0.044
#> SRR805795 1 0.5914 0.978 0.664 0.008 0.060 0.224 0.044
#> SRR805796 1 0.5914 0.978 0.664 0.008 0.060 0.224 0.044
#> SRR805797 1 0.5914 0.978 0.664 0.008 0.060 0.224 0.044
#> SRR805798 1 0.5914 0.978 0.664 0.008 0.060 0.224 0.044
#> SRR805799 1 0.5570 0.791 0.732 0.052 0.048 0.144 0.024
#> SRR805800 1 0.5914 0.978 0.664 0.008 0.060 0.224 0.044
#> SRR805801 1 0.5914 0.978 0.664 0.008 0.060 0.224 0.044
#> SRR805802 5 0.1329 0.954 0.004 0.000 0.008 0.032 0.956
#> SRR805803 5 0.3226 0.895 0.028 0.056 0.036 0.004 0.876
#> SRR805804 5 0.3226 0.895 0.028 0.056 0.036 0.004 0.876
#> SRR805805 5 0.1770 0.942 0.008 0.028 0.008 0.012 0.944
#> SRR805806 5 0.1281 0.956 0.012 0.000 0.000 0.032 0.956
#> SRR805807 5 0.1522 0.943 0.012 0.000 0.000 0.044 0.944
#> SRR805808 5 0.0880 0.956 0.000 0.000 0.000 0.032 0.968
#> SRR805809 5 0.2029 0.933 0.016 0.036 0.012 0.004 0.932
#> SRR805810 5 0.1386 0.956 0.016 0.000 0.000 0.032 0.952
#> SRR805811 5 0.1281 0.956 0.012 0.000 0.000 0.032 0.956
#> SRR805812 5 0.1386 0.956 0.016 0.000 0.000 0.032 0.952
#> SRR805813 4 0.0000 0.991 0.000 0.000 0.000 1.000 0.000
#> SRR805814 4 0.0510 0.988 0.000 0.016 0.000 0.984 0.000
#> SRR805815 4 0.0609 0.989 0.000 0.020 0.000 0.980 0.000
#> SRR805816 4 0.0510 0.988 0.000 0.016 0.000 0.984 0.000
#> SRR805817 4 0.0404 0.991 0.000 0.012 0.000 0.988 0.000
#> SRR805818 4 0.0162 0.991 0.000 0.004 0.000 0.996 0.000
#> SRR805819 4 0.0404 0.990 0.000 0.012 0.000 0.988 0.000
#> SRR805820 4 0.0404 0.991 0.000 0.012 0.000 0.988 0.000
#> SRR805821 4 0.0404 0.990 0.000 0.012 0.000 0.988 0.000
#> SRR805822 4 0.0404 0.990 0.000 0.012 0.000 0.988 0.000
#> SRR805823 4 0.0290 0.990 0.000 0.008 0.000 0.992 0.000
#> SRR805824 3 0.2986 0.960 0.012 0.028 0.888 0.060 0.012
#> SRR805825 3 0.4280 0.940 0.052 0.052 0.824 0.060 0.012
#> SRR805826 3 0.1731 0.969 0.004 0.000 0.932 0.060 0.004
#> SRR805828 3 0.4280 0.940 0.052 0.052 0.824 0.060 0.012
#> SRR805829 3 0.2017 0.969 0.004 0.004 0.924 0.060 0.008
#> SRR805830 3 0.1857 0.969 0.008 0.000 0.928 0.060 0.004
#> SRR805831 3 0.1731 0.969 0.004 0.000 0.932 0.060 0.004
#> SRR805832 3 0.2255 0.966 0.004 0.012 0.916 0.060 0.008
#> SRR805833 3 0.2312 0.967 0.000 0.016 0.912 0.060 0.012
#> SRR805834 3 0.3754 0.951 0.048 0.028 0.852 0.060 0.012
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0000 0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805781 2 0.0458 0.965 0.016 0.984 0.000 0.000 0.000 0.000
#> SRR805782 2 0.0146 0.967 0.004 0.996 0.000 0.000 0.000 0.000
#> SRR805784 2 0.5193 0.724 0.048 0.700 0.004 0.000 0.100 0.148
#> SRR805785 2 0.0000 0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805786 2 0.0260 0.967 0.008 0.992 0.000 0.000 0.000 0.000
#> SRR805787 2 0.0260 0.967 0.008 0.992 0.000 0.000 0.000 0.000
#> SRR805788 2 0.0260 0.967 0.008 0.992 0.000 0.000 0.000 0.000
#> SRR805789 2 0.0000 0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805790 2 0.0146 0.967 0.004 0.996 0.000 0.000 0.000 0.000
#> SRR805791 1 0.3663 0.955 0.804 0.000 0.032 0.144 0.008 0.012
#> SRR805792 1 0.3663 0.955 0.804 0.000 0.032 0.144 0.008 0.012
#> SRR805793 1 0.3663 0.955 0.804 0.000 0.032 0.144 0.008 0.012
#> SRR805794 1 0.3663 0.955 0.804 0.000 0.032 0.144 0.008 0.012
#> SRR805795 1 0.3204 0.957 0.820 0.000 0.032 0.144 0.004 0.000
#> SRR805796 1 0.3204 0.957 0.820 0.000 0.032 0.144 0.004 0.000
#> SRR805797 1 0.3204 0.957 0.820 0.000 0.032 0.144 0.004 0.000
#> SRR805798 1 0.3455 0.956 0.812 0.000 0.032 0.144 0.004 0.008
#> SRR805799 1 0.5424 0.567 0.588 0.000 0.020 0.076 0.004 0.312
#> SRR805800 1 0.3204 0.957 0.820 0.000 0.032 0.144 0.004 0.000
#> SRR805801 1 0.3204 0.957 0.820 0.000 0.032 0.144 0.004 0.000
#> SRR805802 5 0.4128 0.931 0.016 0.116 0.000 0.012 0.788 0.068
#> SRR805803 5 0.4898 0.854 0.000 0.144 0.000 0.000 0.656 0.200
#> SRR805804 5 0.4898 0.854 0.000 0.144 0.000 0.000 0.656 0.200
#> SRR805805 5 0.4281 0.926 0.016 0.120 0.000 0.008 0.772 0.084
#> SRR805806 5 0.2803 0.940 0.016 0.116 0.000 0.012 0.856 0.000
#> SRR805807 5 0.2803 0.940 0.016 0.116 0.000 0.012 0.856 0.000
#> SRR805808 5 0.3155 0.940 0.016 0.116 0.000 0.012 0.844 0.012
#> SRR805809 5 0.4635 0.903 0.016 0.128 0.000 0.000 0.724 0.132
#> SRR805810 5 0.2803 0.940 0.016 0.116 0.000 0.012 0.856 0.000
#> SRR805811 5 0.2803 0.940 0.016 0.116 0.000 0.012 0.856 0.000
#> SRR805812 5 0.2803 0.940 0.016 0.116 0.000 0.012 0.856 0.000
#> SRR805813 4 0.0458 0.961 0.000 0.000 0.000 0.984 0.000 0.016
#> SRR805814 4 0.2006 0.939 0.000 0.000 0.000 0.904 0.016 0.080
#> SRR805815 4 0.1918 0.942 0.000 0.000 0.000 0.904 0.008 0.088
#> SRR805816 4 0.2006 0.939 0.000 0.000 0.000 0.904 0.016 0.080
#> SRR805817 4 0.0692 0.961 0.000 0.000 0.000 0.976 0.004 0.020
#> SRR805818 4 0.1082 0.956 0.000 0.000 0.000 0.956 0.004 0.040
#> SRR805819 4 0.1219 0.954 0.000 0.000 0.000 0.948 0.004 0.048
#> SRR805820 4 0.1049 0.960 0.000 0.000 0.000 0.960 0.008 0.032
#> SRR805821 4 0.0547 0.960 0.000 0.000 0.000 0.980 0.000 0.020
#> SRR805822 4 0.0632 0.959 0.000 0.000 0.000 0.976 0.000 0.024
#> SRR805823 4 0.1367 0.954 0.000 0.000 0.000 0.944 0.012 0.044
#> SRR805824 3 0.2125 0.940 0.004 0.000 0.908 0.016 0.004 0.068
#> SRR805825 3 0.2803 0.925 0.012 0.000 0.856 0.016 0.000 0.116
#> SRR805826 3 0.0717 0.954 0.000 0.000 0.976 0.016 0.000 0.008
#> SRR805828 3 0.3066 0.917 0.016 0.000 0.836 0.016 0.000 0.132
#> SRR805829 3 0.0717 0.955 0.000 0.000 0.976 0.016 0.000 0.008
#> SRR805830 3 0.0717 0.954 0.000 0.000 0.976 0.016 0.000 0.008
#> SRR805831 3 0.0914 0.954 0.000 0.000 0.968 0.016 0.000 0.016
#> SRR805832 3 0.1963 0.945 0.004 0.000 0.924 0.016 0.012 0.044
#> SRR805833 3 0.2095 0.945 0.004 0.000 0.916 0.016 0.012 0.052
#> SRR805834 3 0.2971 0.933 0.012 0.000 0.860 0.016 0.012 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["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 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.683 0.914 0.951 0.491 0.512 0.512
#> 3 3 0.827 0.957 0.961 0.322 0.840 0.688
#> 4 4 1.000 0.980 0.975 0.134 0.912 0.751
#> 5 5 1.000 0.999 0.998 0.106 0.920 0.699
#> 6 6 0.954 0.836 0.922 0.023 0.983 0.906
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 4 5
There is also optional best \(k\) = 4 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.0000 0.985 0.000 1.000
#> SRR805781 2 0.0000 0.985 0.000 1.000
#> SRR805782 2 0.0000 0.985 0.000 1.000
#> SRR805784 2 0.0000 0.985 0.000 1.000
#> SRR805785 2 0.0000 0.985 0.000 1.000
#> SRR805786 2 0.0000 0.985 0.000 1.000
#> SRR805787 2 0.0000 0.985 0.000 1.000
#> SRR805788 2 0.0000 0.985 0.000 1.000
#> SRR805789 2 0.0000 0.985 0.000 1.000
#> SRR805790 2 0.0000 0.985 0.000 1.000
#> SRR805791 1 0.0000 0.918 1.000 0.000
#> SRR805792 1 0.0000 0.918 1.000 0.000
#> SRR805793 1 0.0000 0.918 1.000 0.000
#> SRR805794 1 0.0000 0.918 1.000 0.000
#> SRR805795 1 0.0000 0.918 1.000 0.000
#> SRR805796 1 0.0000 0.918 1.000 0.000
#> SRR805797 1 0.0000 0.918 1.000 0.000
#> SRR805798 1 0.0000 0.918 1.000 0.000
#> SRR805799 1 0.0000 0.918 1.000 0.000
#> SRR805800 1 0.0000 0.918 1.000 0.000
#> SRR805801 1 0.0000 0.918 1.000 0.000
#> SRR805802 2 0.0376 0.983 0.004 0.996
#> SRR805803 2 0.0000 0.985 0.000 1.000
#> SRR805804 2 0.0000 0.985 0.000 1.000
#> SRR805805 2 0.0000 0.985 0.000 1.000
#> SRR805806 2 0.0376 0.983 0.004 0.996
#> SRR805807 2 0.7815 0.687 0.232 0.768
#> SRR805808 2 0.0376 0.983 0.004 0.996
#> SRR805809 2 0.0000 0.985 0.000 1.000
#> SRR805810 2 0.0376 0.983 0.004 0.996
#> SRR805811 2 0.0672 0.980 0.008 0.992
#> SRR805812 2 0.0376 0.983 0.004 0.996
#> SRR805813 1 0.0000 0.918 1.000 0.000
#> SRR805814 1 0.0000 0.918 1.000 0.000
#> SRR805815 1 0.0000 0.918 1.000 0.000
#> SRR805816 1 0.0000 0.918 1.000 0.000
#> SRR805817 1 0.0000 0.918 1.000 0.000
#> SRR805818 1 0.0000 0.918 1.000 0.000
#> SRR805819 1 0.0000 0.918 1.000 0.000
#> SRR805820 1 0.0000 0.918 1.000 0.000
#> SRR805821 1 0.0000 0.918 1.000 0.000
#> SRR805822 1 0.0000 0.918 1.000 0.000
#> SRR805823 1 0.0000 0.918 1.000 0.000
#> SRR805824 1 0.7815 0.785 0.768 0.232
#> SRR805825 1 0.7815 0.785 0.768 0.232
#> SRR805826 1 0.7815 0.785 0.768 0.232
#> SRR805828 1 0.7815 0.785 0.768 0.232
#> SRR805829 1 0.7815 0.785 0.768 0.232
#> SRR805830 1 0.7815 0.785 0.768 0.232
#> SRR805831 1 0.7815 0.785 0.768 0.232
#> SRR805832 1 0.7815 0.785 0.768 0.232
#> SRR805833 1 0.7815 0.785 0.768 0.232
#> SRR805834 1 0.7815 0.785 0.768 0.232
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.0424 0.990 0.000 0.992 0.008
#> SRR805781 2 0.0424 0.990 0.000 0.992 0.008
#> SRR805782 2 0.0424 0.990 0.000 0.992 0.008
#> SRR805784 2 0.0424 0.990 0.000 0.992 0.008
#> SRR805785 2 0.0424 0.990 0.000 0.992 0.008
#> SRR805786 2 0.0424 0.990 0.000 0.992 0.008
#> SRR805787 2 0.0424 0.990 0.000 0.992 0.008
#> SRR805788 2 0.0424 0.990 0.000 0.992 0.008
#> SRR805789 2 0.0424 0.990 0.000 0.992 0.008
#> SRR805790 2 0.0424 0.990 0.000 0.992 0.008
#> SRR805791 1 0.2261 0.911 0.932 0.000 0.068
#> SRR805792 1 0.2261 0.911 0.932 0.000 0.068
#> SRR805793 1 0.2261 0.911 0.932 0.000 0.068
#> SRR805794 1 0.2261 0.911 0.932 0.000 0.068
#> SRR805795 1 0.2261 0.911 0.932 0.000 0.068
#> SRR805796 1 0.2261 0.911 0.932 0.000 0.068
#> SRR805797 1 0.2261 0.911 0.932 0.000 0.068
#> SRR805798 1 0.2261 0.911 0.932 0.000 0.068
#> SRR805799 1 0.1753 0.909 0.952 0.000 0.048
#> SRR805800 1 0.2261 0.911 0.932 0.000 0.068
#> SRR805801 1 0.2261 0.911 0.932 0.000 0.068
#> SRR805802 2 0.0000 0.991 0.000 1.000 0.000
#> SRR805803 2 0.0000 0.991 0.000 1.000 0.000
#> SRR805804 2 0.0000 0.991 0.000 1.000 0.000
#> SRR805805 2 0.0000 0.991 0.000 1.000 0.000
#> SRR805806 2 0.0000 0.991 0.000 1.000 0.000
#> SRR805807 2 0.2796 0.887 0.092 0.908 0.000
#> SRR805808 2 0.0000 0.991 0.000 1.000 0.000
#> SRR805809 2 0.0000 0.991 0.000 1.000 0.000
#> SRR805810 2 0.0000 0.991 0.000 1.000 0.000
#> SRR805811 2 0.0000 0.991 0.000 1.000 0.000
#> SRR805812 2 0.0000 0.991 0.000 1.000 0.000
#> SRR805813 1 0.3272 0.911 0.892 0.004 0.104
#> SRR805814 1 0.3272 0.911 0.892 0.004 0.104
#> SRR805815 1 0.3272 0.911 0.892 0.004 0.104
#> SRR805816 1 0.3272 0.911 0.892 0.004 0.104
#> SRR805817 1 0.3272 0.911 0.892 0.004 0.104
#> SRR805818 1 0.3272 0.911 0.892 0.004 0.104
#> SRR805819 1 0.3272 0.911 0.892 0.004 0.104
#> SRR805820 1 0.3272 0.911 0.892 0.004 0.104
#> SRR805821 1 0.3272 0.911 0.892 0.004 0.104
#> SRR805822 1 0.3272 0.911 0.892 0.004 0.104
#> SRR805823 1 0.3272 0.911 0.892 0.004 0.104
#> SRR805824 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.223 0.957 0.036 0.928 0.036 0.000
#> SRR805781 2 0.223 0.957 0.036 0.928 0.036 0.000
#> SRR805782 2 0.223 0.957 0.036 0.928 0.036 0.000
#> SRR805784 2 0.223 0.957 0.036 0.928 0.036 0.000
#> SRR805785 2 0.223 0.957 0.036 0.928 0.036 0.000
#> SRR805786 2 0.223 0.957 0.036 0.928 0.036 0.000
#> SRR805787 2 0.223 0.957 0.036 0.928 0.036 0.000
#> SRR805788 2 0.223 0.957 0.036 0.928 0.036 0.000
#> SRR805789 2 0.223 0.957 0.036 0.928 0.036 0.000
#> SRR805790 2 0.223 0.957 0.036 0.928 0.036 0.000
#> SRR805791 1 0.112 1.000 0.964 0.000 0.000 0.036
#> SRR805792 1 0.112 1.000 0.964 0.000 0.000 0.036
#> SRR805793 1 0.112 1.000 0.964 0.000 0.000 0.036
#> SRR805794 1 0.112 1.000 0.964 0.000 0.000 0.036
#> SRR805795 1 0.112 1.000 0.964 0.000 0.000 0.036
#> SRR805796 1 0.112 1.000 0.964 0.000 0.000 0.036
#> SRR805797 1 0.112 1.000 0.964 0.000 0.000 0.036
#> SRR805798 1 0.112 1.000 0.964 0.000 0.000 0.036
#> SRR805799 1 0.112 1.000 0.964 0.000 0.000 0.036
#> SRR805800 1 0.112 1.000 0.964 0.000 0.000 0.036
#> SRR805801 1 0.112 1.000 0.964 0.000 0.000 0.036
#> SRR805802 2 0.000 0.959 0.000 1.000 0.000 0.000
#> SRR805803 2 0.000 0.959 0.000 1.000 0.000 0.000
#> SRR805804 2 0.000 0.959 0.000 1.000 0.000 0.000
#> SRR805805 2 0.000 0.959 0.000 1.000 0.000 0.000
#> SRR805806 2 0.000 0.959 0.000 1.000 0.000 0.000
#> SRR805807 2 0.363 0.785 0.012 0.828 0.000 0.160
#> SRR805808 2 0.000 0.959 0.000 1.000 0.000 0.000
#> SRR805809 2 0.000 0.959 0.000 1.000 0.000 0.000
#> SRR805810 2 0.000 0.959 0.000 1.000 0.000 0.000
#> SRR805811 2 0.000 0.959 0.000 1.000 0.000 0.000
#> SRR805812 2 0.000 0.959 0.000 1.000 0.000 0.000
#> SRR805813 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR805814 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR805815 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR805816 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR805817 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR805818 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR805819 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR805820 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR805821 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR805822 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR805823 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR805824 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR805825 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR805826 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR805828 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR805829 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR805830 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR805831 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR805832 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR805833 3 0.000 1.000 0.000 0.000 1.000 0.000
#> SRR805834 3 0.000 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
#> SRR805780 2 0.0290 1.000 0.000 0.992 0.000 0 0.008
#> SRR805781 2 0.0290 1.000 0.000 0.992 0.000 0 0.008
#> SRR805782 2 0.0290 1.000 0.000 0.992 0.000 0 0.008
#> SRR805784 2 0.0290 1.000 0.000 0.992 0.000 0 0.008
#> SRR805785 2 0.0290 1.000 0.000 0.992 0.000 0 0.008
#> SRR805786 2 0.0290 1.000 0.000 0.992 0.000 0 0.008
#> SRR805787 2 0.0290 1.000 0.000 0.992 0.000 0 0.008
#> SRR805788 2 0.0290 1.000 0.000 0.992 0.000 0 0.008
#> SRR805789 2 0.0290 1.000 0.000 0.992 0.000 0 0.008
#> SRR805790 2 0.0290 1.000 0.000 0.992 0.000 0 0.008
#> SRR805791 1 0.0000 0.999 1.000 0.000 0.000 0 0.000
#> SRR805792 1 0.0162 0.998 0.996 0.004 0.000 0 0.000
#> SRR805793 1 0.0162 0.998 0.996 0.004 0.000 0 0.000
#> SRR805794 1 0.0162 0.998 0.996 0.004 0.000 0 0.000
#> SRR805795 1 0.0000 0.999 1.000 0.000 0.000 0 0.000
#> SRR805796 1 0.0000 0.999 1.000 0.000 0.000 0 0.000
#> SRR805797 1 0.0000 0.999 1.000 0.000 0.000 0 0.000
#> SRR805798 1 0.0000 0.999 1.000 0.000 0.000 0 0.000
#> SRR805799 1 0.0000 0.999 1.000 0.000 0.000 0 0.000
#> SRR805800 1 0.0000 0.999 1.000 0.000 0.000 0 0.000
#> SRR805801 1 0.0000 0.999 1.000 0.000 0.000 0 0.000
#> SRR805802 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805803 5 0.0162 0.996 0.000 0.004 0.000 0 0.996
#> SRR805804 5 0.0162 0.996 0.000 0.004 0.000 0 0.996
#> SRR805805 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805806 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805807 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805808 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805809 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805810 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805811 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805812 5 0.0000 0.999 0.000 0.000 0.000 0 1.000
#> SRR805813 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805814 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805815 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805816 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805817 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805818 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805819 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805820 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805821 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805822 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805823 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> SRR805824 3 0.0162 0.998 0.000 0.004 0.996 0 0.000
#> SRR805825 3 0.0000 0.998 0.000 0.000 1.000 0 0.000
#> SRR805826 3 0.0162 0.998 0.000 0.004 0.996 0 0.000
#> SRR805828 3 0.0000 0.998 0.000 0.000 1.000 0 0.000
#> SRR805829 3 0.0000 0.998 0.000 0.000 1.000 0 0.000
#> SRR805830 3 0.0162 0.998 0.000 0.004 0.996 0 0.000
#> SRR805831 3 0.0162 0.998 0.000 0.004 0.996 0 0.000
#> SRR805832 3 0.0162 0.998 0.000 0.004 0.996 0 0.000
#> SRR805833 3 0.0000 0.998 0.000 0.000 1.000 0 0.000
#> SRR805834 3 0.0000 0.998 0.000 0.000 1.000 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0146 0.993 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR805781 2 0.0000 0.993 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805782 2 0.0260 0.992 0.000 0.992 0.000 0.000 0.000 0.008
#> SRR805784 2 0.0937 0.976 0.000 0.960 0.000 0.000 0.000 0.040
#> SRR805785 2 0.0363 0.992 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR805786 2 0.0146 0.993 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR805787 2 0.0000 0.993 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805788 2 0.0000 0.993 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805789 2 0.0260 0.993 0.000 0.992 0.000 0.000 0.000 0.008
#> SRR805790 2 0.0363 0.991 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR805791 1 0.1765 0.926 0.904 0.000 0.000 0.000 0.000 0.096
#> SRR805792 1 0.2135 0.917 0.872 0.000 0.000 0.000 0.000 0.128
#> SRR805793 1 0.2178 0.915 0.868 0.000 0.000 0.000 0.000 0.132
#> SRR805794 1 0.2092 0.917 0.876 0.000 0.000 0.000 0.000 0.124
#> SRR805795 1 0.0146 0.941 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR805796 1 0.0363 0.940 0.988 0.000 0.000 0.000 0.000 0.012
#> SRR805797 1 0.0458 0.939 0.984 0.000 0.000 0.000 0.000 0.016
#> SRR805798 1 0.0632 0.941 0.976 0.000 0.000 0.000 0.000 0.024
#> SRR805799 1 0.2697 0.820 0.812 0.000 0.000 0.000 0.000 0.188
#> SRR805800 1 0.0260 0.942 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR805801 1 0.0260 0.942 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR805802 5 0.2854 0.409 0.000 0.000 0.000 0.000 0.792 0.208
#> SRR805803 5 0.0405 0.554 0.000 0.004 0.000 0.000 0.988 0.008
#> SRR805804 5 0.0405 0.554 0.000 0.004 0.000 0.000 0.988 0.008
#> SRR805805 5 0.2219 0.504 0.000 0.000 0.000 0.000 0.864 0.136
#> SRR805806 6 0.3838 0.754 0.000 0.000 0.000 0.000 0.448 0.552
#> SRR805807 6 0.3499 0.661 0.000 0.000 0.000 0.000 0.320 0.680
#> SRR805808 5 0.3756 -0.278 0.000 0.000 0.000 0.000 0.600 0.400
#> SRR805809 5 0.0547 0.556 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR805810 5 0.3866 -0.672 0.000 0.000 0.000 0.000 0.516 0.484
#> SRR805811 6 0.3833 0.760 0.000 0.000 0.000 0.000 0.444 0.556
#> SRR805812 5 0.3774 -0.421 0.000 0.000 0.000 0.000 0.592 0.408
#> SRR805813 4 0.0000 0.996 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805814 4 0.0547 0.988 0.000 0.000 0.000 0.980 0.000 0.020
#> SRR805815 4 0.0260 0.993 0.000 0.000 0.000 0.992 0.000 0.008
#> SRR805816 4 0.0547 0.988 0.000 0.000 0.000 0.980 0.000 0.020
#> SRR805817 4 0.0000 0.996 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805818 4 0.0000 0.996 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805819 4 0.0000 0.996 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805820 4 0.0000 0.996 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805821 4 0.0000 0.996 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805822 4 0.0000 0.996 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805823 4 0.0260 0.993 0.000 0.000 0.000 0.992 0.000 0.008
#> SRR805824 3 0.0458 0.992 0.000 0.000 0.984 0.000 0.000 0.016
#> SRR805825 3 0.0363 0.992 0.000 0.000 0.988 0.000 0.000 0.012
#> SRR805826 3 0.0260 0.993 0.000 0.000 0.992 0.000 0.000 0.008
#> SRR805828 3 0.0363 0.992 0.000 0.000 0.988 0.000 0.000 0.012
#> SRR805829 3 0.0146 0.994 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR805830 3 0.0363 0.993 0.000 0.000 0.988 0.000 0.000 0.012
#> SRR805831 3 0.0260 0.993 0.000 0.000 0.992 0.000 0.000 0.008
#> SRR805832 3 0.0000 0.994 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805833 3 0.0146 0.994 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR805834 3 0.0146 0.994 0.000 0.000 0.996 0.000 0.000 0.004
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.331 0.655 0.825 0.43316 0.521 0.521
#> 3 3 0.651 0.738 0.841 0.47039 0.819 0.663
#> 4 4 0.938 0.939 0.968 0.17785 0.850 0.611
#> 5 5 1.000 1.000 1.000 0.08659 0.894 0.606
#> 6 6 1.000 0.981 1.000 0.00889 0.993 0.961
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 4
There is also optional best \(k\) = 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.000 0.8461 0.000 1.000
#> SRR805781 2 0.000 0.8461 0.000 1.000
#> SRR805782 2 0.000 0.8461 0.000 1.000
#> SRR805784 2 0.242 0.8048 0.040 0.960
#> SRR805785 2 0.000 0.8461 0.000 1.000
#> SRR805786 2 0.000 0.8461 0.000 1.000
#> SRR805787 2 0.000 0.8461 0.000 1.000
#> SRR805788 2 0.000 0.8461 0.000 1.000
#> SRR805789 2 0.000 0.8461 0.000 1.000
#> SRR805790 2 0.000 0.8461 0.000 1.000
#> SRR805791 1 0.973 0.6178 0.596 0.404
#> SRR805792 1 0.973 0.6178 0.596 0.404
#> SRR805793 1 0.973 0.6178 0.596 0.404
#> SRR805794 1 0.973 0.6178 0.596 0.404
#> SRR805795 1 0.781 0.7150 0.768 0.232
#> SRR805796 1 0.775 0.7156 0.772 0.228
#> SRR805797 1 0.881 0.6899 0.700 0.300
#> SRR805798 1 0.973 0.6178 0.596 0.404
#> SRR805799 1 0.775 0.7156 0.772 0.228
#> SRR805800 1 0.775 0.7156 0.772 0.228
#> SRR805801 1 0.802 0.7124 0.756 0.244
#> SRR805802 2 0.388 0.7875 0.076 0.924
#> SRR805803 2 0.000 0.8461 0.000 1.000
#> SRR805804 2 0.000 0.8461 0.000 1.000
#> SRR805805 2 0.000 0.8461 0.000 1.000
#> SRR805806 1 0.990 0.5512 0.560 0.440
#> SRR805807 1 0.760 0.7193 0.780 0.220
#> SRR805808 2 0.961 0.0163 0.384 0.616
#> SRR805809 2 0.000 0.8461 0.000 1.000
#> SRR805810 1 0.973 0.6178 0.596 0.404
#> SRR805811 1 0.745 0.6810 0.788 0.212
#> SRR805812 1 0.881 0.6685 0.700 0.300
#> SRR805813 1 0.000 0.6937 1.000 0.000
#> SRR805814 1 0.000 0.6937 1.000 0.000
#> SRR805815 1 0.000 0.6937 1.000 0.000
#> SRR805816 1 0.000 0.6937 1.000 0.000
#> SRR805817 1 0.000 0.6937 1.000 0.000
#> SRR805818 1 0.000 0.6937 1.000 0.000
#> SRR805819 1 0.000 0.6937 1.000 0.000
#> SRR805820 1 0.000 0.6937 1.000 0.000
#> SRR805821 1 0.000 0.6937 1.000 0.000
#> SRR805822 1 0.000 0.6937 1.000 0.000
#> SRR805823 1 0.000 0.6937 1.000 0.000
#> SRR805824 1 0.973 0.6178 0.596 0.404
#> SRR805825 2 0.788 0.5093 0.236 0.764
#> SRR805826 2 0.987 -0.1906 0.432 0.568
#> SRR805828 1 0.541 0.6983 0.876 0.124
#> SRR805829 1 0.973 0.6178 0.596 0.404
#> SRR805830 1 0.990 0.5507 0.560 0.440
#> SRR805831 1 0.983 0.5836 0.576 0.424
#> SRR805832 2 0.909 0.2553 0.324 0.676
#> SRR805833 2 0.990 -0.2215 0.440 0.560
#> SRR805834 1 0.998 0.4579 0.524 0.476
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.0000 0.953 0.000 1.000 0.000
#> SRR805781 2 0.0000 0.953 0.000 1.000 0.000
#> SRR805782 2 0.0000 0.953 0.000 1.000 0.000
#> SRR805784 2 0.0000 0.953 0.000 1.000 0.000
#> SRR805785 2 0.0000 0.953 0.000 1.000 0.000
#> SRR805786 2 0.0237 0.949 0.004 0.996 0.000
#> SRR805787 2 0.0000 0.953 0.000 1.000 0.000
#> SRR805788 2 0.0000 0.953 0.000 1.000 0.000
#> SRR805789 2 0.0000 0.953 0.000 1.000 0.000
#> SRR805790 2 0.0000 0.953 0.000 1.000 0.000
#> SRR805791 1 0.1031 0.585 0.976 0.024 0.000
#> SRR805792 1 0.1170 0.575 0.976 0.008 0.016
#> SRR805793 1 0.1170 0.581 0.976 0.016 0.008
#> SRR805794 1 0.1031 0.585 0.976 0.024 0.000
#> SRR805795 1 0.0424 0.592 0.992 0.008 0.000
#> SRR805796 1 0.0424 0.592 0.992 0.008 0.000
#> SRR805797 1 0.0747 0.589 0.984 0.016 0.000
#> SRR805798 1 0.1031 0.585 0.976 0.024 0.000
#> SRR805799 1 0.0424 0.592 0.992 0.008 0.000
#> SRR805800 1 0.0424 0.592 0.992 0.008 0.000
#> SRR805801 1 0.0424 0.592 0.992 0.008 0.000
#> SRR805802 2 0.1289 0.918 0.032 0.968 0.000
#> SRR805803 2 0.0000 0.953 0.000 1.000 0.000
#> SRR805804 2 0.0000 0.953 0.000 1.000 0.000
#> SRR805805 2 0.0000 0.953 0.000 1.000 0.000
#> SRR805806 1 0.6274 0.284 0.544 0.456 0.000
#> SRR805807 1 0.7770 0.674 0.628 0.080 0.292
#> SRR805808 2 0.6305 -0.115 0.484 0.516 0.000
#> SRR805809 2 0.0000 0.953 0.000 1.000 0.000
#> SRR805810 1 0.6597 0.500 0.664 0.312 0.024
#> SRR805811 1 0.9181 0.599 0.540 0.224 0.236
#> SRR805812 1 0.7970 0.531 0.612 0.300 0.088
#> SRR805813 1 0.6252 0.695 0.556 0.000 0.444
#> SRR805814 1 0.6252 0.695 0.556 0.000 0.444
#> SRR805815 1 0.6252 0.695 0.556 0.000 0.444
#> SRR805816 1 0.6252 0.695 0.556 0.000 0.444
#> SRR805817 1 0.6252 0.695 0.556 0.000 0.444
#> SRR805818 1 0.6252 0.695 0.556 0.000 0.444
#> SRR805819 1 0.6252 0.695 0.556 0.000 0.444
#> SRR805820 1 0.6252 0.695 0.556 0.000 0.444
#> SRR805821 1 0.6252 0.695 0.556 0.000 0.444
#> SRR805822 1 0.6252 0.695 0.556 0.000 0.444
#> SRR805823 1 0.6252 0.695 0.556 0.000 0.444
#> SRR805824 3 0.7102 0.861 0.420 0.024 0.556
#> SRR805825 3 0.9034 0.785 0.244 0.200 0.556
#> SRR805826 3 0.8102 0.883 0.368 0.076 0.556
#> SRR805828 3 0.5117 0.534 0.060 0.108 0.832
#> SRR805829 3 0.8102 0.883 0.368 0.076 0.556
#> SRR805830 3 0.7784 0.880 0.388 0.056 0.556
#> SRR805831 3 0.7102 0.861 0.420 0.024 0.556
#> SRR805832 3 0.6994 0.854 0.424 0.020 0.556
#> SRR805833 3 0.8452 0.873 0.340 0.104 0.556
#> SRR805834 3 0.8799 0.844 0.300 0.144 0.556
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.0000 0.998 0.000 1.000 0 0.000
#> SRR805781 2 0.0000 0.998 0.000 1.000 0 0.000
#> SRR805782 2 0.0000 0.998 0.000 1.000 0 0.000
#> SRR805784 2 0.0000 0.998 0.000 1.000 0 0.000
#> SRR805785 2 0.0000 0.998 0.000 1.000 0 0.000
#> SRR805786 2 0.0188 0.994 0.004 0.996 0 0.000
#> SRR805787 2 0.0000 0.998 0.000 1.000 0 0.000
#> SRR805788 2 0.0000 0.998 0.000 1.000 0 0.000
#> SRR805789 2 0.0000 0.998 0.000 1.000 0 0.000
#> SRR805790 2 0.0000 0.998 0.000 1.000 0 0.000
#> SRR805791 1 0.0000 0.889 1.000 0.000 0 0.000
#> SRR805792 1 0.0000 0.889 1.000 0.000 0 0.000
#> SRR805793 1 0.0000 0.889 1.000 0.000 0 0.000
#> SRR805794 1 0.0000 0.889 1.000 0.000 0 0.000
#> SRR805795 1 0.0000 0.889 1.000 0.000 0 0.000
#> SRR805796 1 0.0000 0.889 1.000 0.000 0 0.000
#> SRR805797 1 0.0000 0.889 1.000 0.000 0 0.000
#> SRR805798 1 0.0000 0.889 1.000 0.000 0 0.000
#> SRR805799 1 0.0000 0.889 1.000 0.000 0 0.000
#> SRR805800 1 0.0000 0.889 1.000 0.000 0 0.000
#> SRR805801 1 0.0000 0.889 1.000 0.000 0 0.000
#> SRR805802 2 0.0592 0.981 0.016 0.984 0 0.000
#> SRR805803 2 0.0000 0.998 0.000 1.000 0 0.000
#> SRR805804 2 0.0000 0.998 0.000 1.000 0 0.000
#> SRR805805 2 0.0000 0.998 0.000 1.000 0 0.000
#> SRR805806 1 0.4382 0.673 0.704 0.296 0 0.000
#> SRR805807 1 0.4756 0.772 0.784 0.072 0 0.144
#> SRR805808 1 0.4961 0.359 0.552 0.448 0 0.000
#> SRR805809 2 0.0000 0.998 0.000 1.000 0 0.000
#> SRR805810 1 0.3907 0.752 0.768 0.232 0 0.000
#> SRR805811 1 0.4904 0.751 0.744 0.216 0 0.040
#> SRR805812 1 0.4576 0.745 0.748 0.232 0 0.020
#> SRR805813 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805814 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805815 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805816 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805817 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805818 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805819 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805820 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805821 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805822 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805823 4 0.0000 1.000 0.000 0.000 0 1.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1 0.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0 1 0 1 0 0 0
#> SRR805781 2 0 1 0 1 0 0 0
#> SRR805782 2 0 1 0 1 0 0 0
#> SRR805784 2 0 1 0 1 0 0 0
#> SRR805785 2 0 1 0 1 0 0 0
#> SRR805786 2 0 1 0 1 0 0 0
#> SRR805787 2 0 1 0 1 0 0 0
#> SRR805788 2 0 1 0 1 0 0 0
#> SRR805789 2 0 1 0 1 0 0 0
#> SRR805790 2 0 1 0 1 0 0 0
#> SRR805791 1 0 1 1 0 0 0 0
#> SRR805792 1 0 1 1 0 0 0 0
#> SRR805793 1 0 1 1 0 0 0 0
#> SRR805794 1 0 1 1 0 0 0 0
#> SRR805795 1 0 1 1 0 0 0 0
#> SRR805796 1 0 1 1 0 0 0 0
#> SRR805797 1 0 1 1 0 0 0 0
#> SRR805798 1 0 1 1 0 0 0 0
#> SRR805799 1 0 1 1 0 0 0 0
#> SRR805800 1 0 1 1 0 0 0 0
#> SRR805801 1 0 1 1 0 0 0 0
#> SRR805802 5 0 1 0 0 0 0 1
#> SRR805803 5 0 1 0 0 0 0 1
#> SRR805804 5 0 1 0 0 0 0 1
#> SRR805805 5 0 1 0 0 0 0 1
#> SRR805806 5 0 1 0 0 0 0 1
#> SRR805807 5 0 1 0 0 0 0 1
#> SRR805808 5 0 1 0 0 0 0 1
#> SRR805809 5 0 1 0 0 0 0 1
#> SRR805810 5 0 1 0 0 0 0 1
#> SRR805811 5 0 1 0 0 0 0 1
#> SRR805812 5 0 1 0 0 0 0 1
#> SRR805813 4 0 1 0 0 0 1 0
#> SRR805814 4 0 1 0 0 0 1 0
#> SRR805815 4 0 1 0 0 0 1 0
#> SRR805816 4 0 1 0 0 0 1 0
#> SRR805817 4 0 1 0 0 0 1 0
#> SRR805818 4 0 1 0 0 0 1 0
#> SRR805819 4 0 1 0 0 0 1 0
#> SRR805820 4 0 1 0 0 0 1 0
#> SRR805821 4 0 1 0 0 0 1 0
#> SRR805822 4 0 1 0 0 0 1 0
#> SRR805823 4 0 1 0 0 0 1 0
#> SRR805824 3 0 1 0 0 1 0 0
#> SRR805825 3 0 1 0 0 1 0 0
#> SRR805826 3 0 1 0 0 1 0 0
#> SRR805828 3 0 1 0 0 1 0 0
#> SRR805829 3 0 1 0 0 1 0 0
#> SRR805830 3 0 1 0 0 1 0 0
#> SRR805831 3 0 1 0 0 1 0 0
#> SRR805832 3 0 1 0 0 1 0 0
#> SRR805833 3 0 1 0 0 1 0 0
#> SRR805834 3 0 1 0 0 1 0 0
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.000 0.999 0.000 1.000 0 0 0 0.000
#> SRR805781 2 0.000 0.999 0.000 1.000 0 0 0 0.000
#> SRR805782 2 0.000 0.999 0.000 1.000 0 0 0 0.000
#> SRR805784 2 0.026 0.992 0.000 0.992 0 0 0 0.008
#> SRR805785 2 0.000 0.999 0.000 1.000 0 0 0 0.000
#> SRR805786 2 0.000 0.999 0.000 1.000 0 0 0 0.000
#> SRR805787 2 0.000 0.999 0.000 1.000 0 0 0 0.000
#> SRR805788 2 0.000 0.999 0.000 1.000 0 0 0 0.000
#> SRR805789 2 0.000 0.999 0.000 1.000 0 0 0 0.000
#> SRR805790 2 0.000 0.999 0.000 1.000 0 0 0 0.000
#> SRR805791 1 0.000 1.000 1.000 0.000 0 0 0 0.000
#> SRR805792 1 0.000 1.000 1.000 0.000 0 0 0 0.000
#> SRR805793 1 0.000 1.000 1.000 0.000 0 0 0 0.000
#> SRR805794 1 0.000 1.000 1.000 0.000 0 0 0 0.000
#> SRR805795 1 0.000 1.000 1.000 0.000 0 0 0 0.000
#> SRR805796 1 0.000 1.000 1.000 0.000 0 0 0 0.000
#> SRR805797 1 0.000 1.000 1.000 0.000 0 0 0 0.000
#> SRR805798 1 0.000 1.000 1.000 0.000 0 0 0 0.000
#> SRR805799 6 0.026 0.000 0.008 0.000 0 0 0 0.992
#> SRR805800 1 0.000 1.000 1.000 0.000 0 0 0 0.000
#> SRR805801 1 0.000 1.000 1.000 0.000 0 0 0 0.000
#> SRR805802 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR805803 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR805804 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR805805 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR805806 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR805807 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR805808 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR805809 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR805810 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR805811 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR805812 5 0.000 1.000 0.000 0.000 0 0 1 0.000
#> SRR805813 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR805814 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR805815 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR805816 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR805817 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR805818 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR805819 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR805820 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR805821 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR805822 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR805823 4 0.000 1.000 0.000 0.000 0 1 0 0.000
#> SRR805824 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR805825 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR805826 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR805828 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR805829 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR805830 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR805831 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR805832 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR805833 3 0.000 1.000 0.000 0.000 1 0 0 0.000
#> SRR805834 3 0.000 1.000 0.000 0.000 1 0 0 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.505 0.904 0.919 0.4888 0.512 0.512
#> 3 3 0.753 0.964 0.976 0.1826 0.585 0.390
#> 4 4 1.000 1.000 1.000 0.2722 0.832 0.612
#> 5 5 1.000 0.961 0.985 0.1062 0.922 0.704
#> 6 6 0.955 0.888 0.943 0.0185 0.987 0.930
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 4 5
There is also optional best \(k\) = 4 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.615 0.928 0.152 0.848
#> SRR805781 2 0.615 0.928 0.152 0.848
#> SRR805782 2 0.615 0.928 0.152 0.848
#> SRR805784 2 0.595 0.925 0.144 0.856
#> SRR805785 2 0.615 0.928 0.152 0.848
#> SRR805786 2 0.615 0.928 0.152 0.848
#> SRR805787 2 0.615 0.928 0.152 0.848
#> SRR805788 2 0.615 0.928 0.152 0.848
#> SRR805789 2 0.615 0.928 0.152 0.848
#> SRR805790 2 0.615 0.928 0.152 0.848
#> SRR805791 1 0.000 0.908 1.000 0.000
#> SRR805792 1 0.000 0.908 1.000 0.000
#> SRR805793 1 0.000 0.908 1.000 0.000
#> SRR805794 1 0.000 0.908 1.000 0.000
#> SRR805795 1 0.000 0.908 1.000 0.000
#> SRR805796 1 0.000 0.908 1.000 0.000
#> SRR805797 1 0.000 0.908 1.000 0.000
#> SRR805798 1 0.000 0.908 1.000 0.000
#> SRR805799 1 0.000 0.908 1.000 0.000
#> SRR805800 1 0.000 0.908 1.000 0.000
#> SRR805801 1 0.000 0.908 1.000 0.000
#> SRR805802 2 0.615 0.928 0.152 0.848
#> SRR805803 2 0.615 0.928 0.152 0.848
#> SRR805804 2 0.615 0.928 0.152 0.848
#> SRR805805 2 0.615 0.928 0.152 0.848
#> SRR805806 2 0.615 0.928 0.152 0.848
#> SRR805807 2 0.615 0.928 0.152 0.848
#> SRR805808 2 0.615 0.928 0.152 0.848
#> SRR805809 2 0.615 0.928 0.152 0.848
#> SRR805810 2 0.615 0.928 0.152 0.848
#> SRR805811 2 0.615 0.928 0.152 0.848
#> SRR805812 2 0.615 0.928 0.152 0.848
#> SRR805813 2 0.260 0.858 0.044 0.956
#> SRR805814 2 0.260 0.858 0.044 0.956
#> SRR805815 2 0.260 0.858 0.044 0.956
#> SRR805816 2 0.260 0.858 0.044 0.956
#> SRR805817 2 0.260 0.858 0.044 0.956
#> SRR805818 2 0.260 0.858 0.044 0.956
#> SRR805819 2 0.260 0.858 0.044 0.956
#> SRR805820 2 0.260 0.858 0.044 0.956
#> SRR805821 2 0.260 0.858 0.044 0.956
#> SRR805822 2 0.260 0.858 0.044 0.956
#> SRR805823 2 0.260 0.858 0.044 0.956
#> SRR805824 1 0.714 0.901 0.804 0.196
#> SRR805825 1 0.714 0.901 0.804 0.196
#> SRR805826 1 0.714 0.901 0.804 0.196
#> SRR805828 1 0.714 0.901 0.804 0.196
#> SRR805829 1 0.714 0.901 0.804 0.196
#> SRR805830 1 0.714 0.901 0.804 0.196
#> SRR805831 1 0.714 0.901 0.804 0.196
#> SRR805832 1 0.714 0.901 0.804 0.196
#> SRR805833 1 0.714 0.901 0.804 0.196
#> SRR805834 1 0.714 0.901 0.804 0.196
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.000 0.956 0 1.000 0.000
#> SRR805781 2 0.000 0.956 0 1.000 0.000
#> SRR805782 2 0.000 0.956 0 1.000 0.000
#> SRR805784 2 0.000 0.956 0 1.000 0.000
#> SRR805785 2 0.000 0.956 0 1.000 0.000
#> SRR805786 2 0.000 0.956 0 1.000 0.000
#> SRR805787 2 0.000 0.956 0 1.000 0.000
#> SRR805788 2 0.000 0.956 0 1.000 0.000
#> SRR805789 2 0.000 0.956 0 1.000 0.000
#> SRR805790 2 0.000 0.956 0 1.000 0.000
#> SRR805791 2 0.327 0.911 0 0.884 0.116
#> SRR805792 2 0.327 0.911 0 0.884 0.116
#> SRR805793 2 0.327 0.911 0 0.884 0.116
#> SRR805794 2 0.327 0.911 0 0.884 0.116
#> SRR805795 2 0.327 0.911 0 0.884 0.116
#> SRR805796 2 0.327 0.911 0 0.884 0.116
#> SRR805797 2 0.327 0.911 0 0.884 0.116
#> SRR805798 2 0.327 0.911 0 0.884 0.116
#> SRR805799 2 0.327 0.911 0 0.884 0.116
#> SRR805800 2 0.327 0.911 0 0.884 0.116
#> SRR805801 2 0.327 0.911 0 0.884 0.116
#> SRR805802 2 0.000 0.956 0 1.000 0.000
#> SRR805803 2 0.000 0.956 0 1.000 0.000
#> SRR805804 2 0.000 0.956 0 1.000 0.000
#> SRR805805 2 0.000 0.956 0 1.000 0.000
#> SRR805806 2 0.000 0.956 0 1.000 0.000
#> SRR805807 2 0.000 0.956 0 1.000 0.000
#> SRR805808 2 0.000 0.956 0 1.000 0.000
#> SRR805809 2 0.000 0.956 0 1.000 0.000
#> SRR805810 2 0.000 0.956 0 1.000 0.000
#> SRR805811 2 0.000 0.956 0 1.000 0.000
#> SRR805812 2 0.000 0.956 0 1.000 0.000
#> SRR805813 1 0.000 1.000 1 0.000 0.000
#> SRR805814 1 0.000 1.000 1 0.000 0.000
#> SRR805815 1 0.000 1.000 1 0.000 0.000
#> SRR805816 1 0.000 1.000 1 0.000 0.000
#> SRR805817 1 0.000 1.000 1 0.000 0.000
#> SRR805818 1 0.000 1.000 1 0.000 0.000
#> SRR805819 1 0.000 1.000 1 0.000 0.000
#> SRR805820 1 0.000 1.000 1 0.000 0.000
#> SRR805821 1 0.000 1.000 1 0.000 0.000
#> SRR805822 1 0.000 1.000 1 0.000 0.000
#> SRR805823 1 0.000 1.000 1 0.000 0.000
#> SRR805824 3 0.000 1.000 0 0.000 1.000
#> SRR805825 3 0.000 1.000 0 0.000 1.000
#> SRR805826 3 0.000 1.000 0 0.000 1.000
#> SRR805828 3 0.000 1.000 0 0.000 1.000
#> SRR805829 3 0.000 1.000 0 0.000 1.000
#> SRR805830 3 0.000 1.000 0 0.000 1.000
#> SRR805831 3 0.000 1.000 0 0.000 1.000
#> SRR805832 3 0.000 1.000 0 0.000 1.000
#> SRR805833 3 0.000 1.000 0 0.000 1.000
#> SRR805834 3 0.000 1.000 0 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0 1 0 1 0 0
#> SRR805781 2 0 1 0 1 0 0
#> SRR805782 2 0 1 0 1 0 0
#> SRR805784 2 0 1 0 1 0 0
#> SRR805785 2 0 1 0 1 0 0
#> SRR805786 2 0 1 0 1 0 0
#> SRR805787 2 0 1 0 1 0 0
#> SRR805788 2 0 1 0 1 0 0
#> SRR805789 2 0 1 0 1 0 0
#> SRR805790 2 0 1 0 1 0 0
#> SRR805791 1 0 1 1 0 0 0
#> SRR805792 1 0 1 1 0 0 0
#> SRR805793 1 0 1 1 0 0 0
#> SRR805794 1 0 1 1 0 0 0
#> SRR805795 1 0 1 1 0 0 0
#> SRR805796 1 0 1 1 0 0 0
#> SRR805797 1 0 1 1 0 0 0
#> SRR805798 1 0 1 1 0 0 0
#> SRR805799 1 0 1 1 0 0 0
#> SRR805800 1 0 1 1 0 0 0
#> SRR805801 1 0 1 1 0 0 0
#> SRR805802 2 0 1 0 1 0 0
#> SRR805803 2 0 1 0 1 0 0
#> SRR805804 2 0 1 0 1 0 0
#> SRR805805 2 0 1 0 1 0 0
#> SRR805806 2 0 1 0 1 0 0
#> SRR805807 2 0 1 0 1 0 0
#> SRR805808 2 0 1 0 1 0 0
#> SRR805809 2 0 1 0 1 0 0
#> SRR805810 2 0 1 0 1 0 0
#> SRR805811 2 0 1 0 1 0 0
#> SRR805812 2 0 1 0 1 0 0
#> SRR805813 4 0 1 0 0 0 1
#> SRR805814 4 0 1 0 0 0 1
#> SRR805815 4 0 1 0 0 0 1
#> SRR805816 4 0 1 0 0 0 1
#> SRR805817 4 0 1 0 0 0 1
#> SRR805818 4 0 1 0 0 0 1
#> SRR805819 4 0 1 0 0 0 1
#> SRR805820 4 0 1 0 0 0 1
#> SRR805821 4 0 1 0 0 0 1
#> SRR805822 4 0 1 0 0 0 1
#> SRR805823 4 0 1 0 0 0 1
#> SRR805824 3 0 1 0 0 1 0
#> SRR805825 3 0 1 0 0 1 0
#> SRR805826 3 0 1 0 0 1 0
#> SRR805828 3 0 1 0 0 1 0
#> SRR805829 3 0 1 0 0 1 0
#> SRR805830 3 0 1 0 0 1 0
#> SRR805831 3 0 1 0 0 1 0
#> SRR805832 3 0 1 0 0 1 0
#> SRR805833 3 0 1 0 0 1 0
#> SRR805834 3 0 1 0 0 1 0
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.000 0.947 0 1.000 0 0 0.000
#> SRR805781 2 0.000 0.947 0 1.000 0 0 0.000
#> SRR805782 2 0.000 0.947 0 1.000 0 0 0.000
#> SRR805784 2 0.000 0.947 0 1.000 0 0 0.000
#> SRR805785 2 0.000 0.947 0 1.000 0 0 0.000
#> SRR805786 2 0.000 0.947 0 1.000 0 0 0.000
#> SRR805787 2 0.000 0.947 0 1.000 0 0 0.000
#> SRR805788 2 0.000 0.947 0 1.000 0 0 0.000
#> SRR805789 2 0.000 0.947 0 1.000 0 0 0.000
#> SRR805790 2 0.000 0.947 0 1.000 0 0 0.000
#> SRR805791 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805792 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805793 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805794 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805795 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805796 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805797 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805798 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805799 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805800 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805801 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805802 5 0.000 0.965 0 0.000 0 0 1.000
#> SRR805803 2 0.260 0.801 0 0.852 0 0 0.148
#> SRR805804 2 0.418 0.323 0 0.600 0 0 0.400
#> SRR805805 5 0.000 0.965 0 0.000 0 0 1.000
#> SRR805806 5 0.000 0.965 0 0.000 0 0 1.000
#> SRR805807 5 0.000 0.965 0 0.000 0 0 1.000
#> SRR805808 5 0.000 0.965 0 0.000 0 0 1.000
#> SRR805809 5 0.353 0.619 0 0.256 0 0 0.744
#> SRR805810 5 0.000 0.965 0 0.000 0 0 1.000
#> SRR805811 5 0.000 0.965 0 0.000 0 0 1.000
#> SRR805812 5 0.000 0.965 0 0.000 0 0 1.000
#> SRR805813 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805814 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805815 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805816 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805817 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805818 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805819 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805820 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805821 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805822 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805823 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805824 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805825 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805826 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805828 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805829 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805830 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805831 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805832 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805833 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805834 3 0.000 1.000 0 0.000 1 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0000 0.9405 0.000 1.000 0 0 0.000 0.000
#> SRR805781 2 0.0000 0.9405 0.000 1.000 0 0 0.000 0.000
#> SRR805782 2 0.0000 0.9405 0.000 1.000 0 0 0.000 0.000
#> SRR805784 2 0.0000 0.9405 0.000 1.000 0 0 0.000 0.000
#> SRR805785 2 0.0000 0.9405 0.000 1.000 0 0 0.000 0.000
#> SRR805786 2 0.0000 0.9405 0.000 1.000 0 0 0.000 0.000
#> SRR805787 2 0.0000 0.9405 0.000 1.000 0 0 0.000 0.000
#> SRR805788 2 0.0000 0.9405 0.000 1.000 0 0 0.000 0.000
#> SRR805789 2 0.0000 0.9405 0.000 1.000 0 0 0.000 0.000
#> SRR805790 2 0.0000 0.9405 0.000 1.000 0 0 0.000 0.000
#> SRR805791 1 0.3446 0.0133 0.692 0.000 0 0 0.000 0.308
#> SRR805792 6 0.3804 1.0000 0.424 0.000 0 0 0.000 0.576
#> SRR805793 6 0.3804 1.0000 0.424 0.000 0 0 0.000 0.576
#> SRR805794 1 0.3309 0.1568 0.720 0.000 0 0 0.000 0.280
#> SRR805795 1 0.0000 0.8139 1.000 0.000 0 0 0.000 0.000
#> SRR805796 1 0.0000 0.8139 1.000 0.000 0 0 0.000 0.000
#> SRR805797 1 0.0363 0.8113 0.988 0.000 0 0 0.000 0.012
#> SRR805798 1 0.0937 0.7897 0.960 0.000 0 0 0.000 0.040
#> SRR805799 1 0.2003 0.6950 0.884 0.000 0 0 0.000 0.116
#> SRR805800 1 0.0632 0.8068 0.976 0.000 0 0 0.000 0.024
#> SRR805801 1 0.0632 0.8068 0.976 0.000 0 0 0.000 0.024
#> SRR805802 5 0.0146 0.9336 0.000 0.000 0 0 0.996 0.004
#> SRR805803 2 0.2745 0.8277 0.000 0.864 0 0 0.068 0.068
#> SRR805804 2 0.5935 0.2124 0.000 0.456 0 0 0.244 0.300
#> SRR805805 5 0.1957 0.8647 0.000 0.000 0 0 0.888 0.112
#> SRR805806 5 0.0000 0.9350 0.000 0.000 0 0 1.000 0.000
#> SRR805807 5 0.0260 0.9314 0.000 0.000 0 0 0.992 0.008
#> SRR805808 5 0.0000 0.9350 0.000 0.000 0 0 1.000 0.000
#> SRR805809 5 0.5398 0.5320 0.000 0.204 0 0 0.584 0.212
#> SRR805810 5 0.0000 0.9350 0.000 0.000 0 0 1.000 0.000
#> SRR805811 5 0.0000 0.9350 0.000 0.000 0 0 1.000 0.000
#> SRR805812 5 0.0000 0.9350 0.000 0.000 0 0 1.000 0.000
#> SRR805813 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805814 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805815 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805816 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805817 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805818 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805819 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805820 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805821 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805822 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805823 4 0.0000 1.0000 0.000 0.000 0 1 0.000 0.000
#> SRR805824 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805825 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805826 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805828 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805829 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805830 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805831 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805832 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805833 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
#> SRR805834 3 0.0000 1.0000 0.000 0.000 1 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "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 15291 rows and 53 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 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.704 0.803 0.924 0.4940 0.492 0.492
#> 3 3 0.883 0.913 0.960 0.3103 0.795 0.612
#> 4 4 0.984 0.951 0.952 0.1461 0.874 0.659
#> 5 5 1.000 1.000 1.000 0.0988 0.912 0.669
#> 6 6 0.988 0.962 0.968 0.0115 1.000 1.000
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 4
There is also optional best \(k\) = 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.0000 0.8992 0.000 1.000
#> SRR805781 2 0.0000 0.8992 0.000 1.000
#> SRR805782 2 0.0000 0.8992 0.000 1.000
#> SRR805784 2 0.0000 0.8992 0.000 1.000
#> SRR805785 2 0.0000 0.8992 0.000 1.000
#> SRR805786 2 0.0000 0.8992 0.000 1.000
#> SRR805787 2 0.0000 0.8992 0.000 1.000
#> SRR805788 2 0.0000 0.8992 0.000 1.000
#> SRR805789 2 0.0000 0.8992 0.000 1.000
#> SRR805790 2 0.0000 0.8992 0.000 1.000
#> SRR805791 1 0.0000 0.9151 1.000 0.000
#> SRR805792 1 0.0376 0.9125 0.996 0.004
#> SRR805793 1 0.3584 0.8634 0.932 0.068
#> SRR805794 1 0.0000 0.9151 1.000 0.000
#> SRR805795 1 0.0000 0.9151 1.000 0.000
#> SRR805796 1 0.0000 0.9151 1.000 0.000
#> SRR805797 1 0.0000 0.9151 1.000 0.000
#> SRR805798 1 0.0000 0.9151 1.000 0.000
#> SRR805799 1 0.0000 0.9151 1.000 0.000
#> SRR805800 1 0.0000 0.9151 1.000 0.000
#> SRR805801 1 0.0000 0.9151 1.000 0.000
#> SRR805802 2 0.0000 0.8992 0.000 1.000
#> SRR805803 2 0.0000 0.8992 0.000 1.000
#> SRR805804 2 0.0000 0.8992 0.000 1.000
#> SRR805805 2 0.0000 0.8992 0.000 1.000
#> SRR805806 2 0.2236 0.8757 0.036 0.964
#> SRR805807 1 0.6531 0.7511 0.832 0.168
#> SRR805808 2 0.0000 0.8992 0.000 1.000
#> SRR805809 2 0.0000 0.8992 0.000 1.000
#> SRR805810 2 0.0938 0.8928 0.012 0.988
#> SRR805811 2 0.9710 0.3613 0.400 0.600
#> SRR805812 2 0.0000 0.8992 0.000 1.000
#> SRR805813 1 0.0000 0.9151 1.000 0.000
#> SRR805814 1 0.0000 0.9151 1.000 0.000
#> SRR805815 1 0.0000 0.9151 1.000 0.000
#> SRR805816 1 0.0000 0.9151 1.000 0.000
#> SRR805817 1 0.0000 0.9151 1.000 0.000
#> SRR805818 1 0.0000 0.9151 1.000 0.000
#> SRR805819 1 0.0000 0.9151 1.000 0.000
#> SRR805820 1 0.0000 0.9151 1.000 0.000
#> SRR805821 1 0.0000 0.9151 1.000 0.000
#> SRR805822 1 0.0000 0.9151 1.000 0.000
#> SRR805823 1 0.0000 0.9151 1.000 0.000
#> SRR805824 1 0.9358 0.4225 0.648 0.352
#> SRR805825 2 0.8763 0.5809 0.296 0.704
#> SRR805826 2 0.9491 0.4381 0.368 0.632
#> SRR805828 1 0.3733 0.8593 0.928 0.072
#> SRR805829 1 0.9608 0.3428 0.616 0.384
#> SRR805830 1 0.9954 0.0976 0.540 0.460
#> SRR805831 1 0.9922 0.1449 0.552 0.448
#> SRR805832 2 0.6887 0.7357 0.184 0.816
#> SRR805833 2 0.9427 0.4563 0.360 0.640
#> SRR805834 2 0.9896 0.2338 0.440 0.560
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.0000 0.966 0.000 1.000 0.000
#> SRR805781 2 0.0000 0.966 0.000 1.000 0.000
#> SRR805782 2 0.0000 0.966 0.000 1.000 0.000
#> SRR805784 2 0.0000 0.966 0.000 1.000 0.000
#> SRR805785 2 0.0000 0.966 0.000 1.000 0.000
#> SRR805786 2 0.0000 0.966 0.000 1.000 0.000
#> SRR805787 2 0.0000 0.966 0.000 1.000 0.000
#> SRR805788 2 0.0000 0.966 0.000 1.000 0.000
#> SRR805789 2 0.0000 0.966 0.000 1.000 0.000
#> SRR805790 2 0.0000 0.966 0.000 1.000 0.000
#> SRR805791 1 0.0237 0.931 0.996 0.000 0.004
#> SRR805792 1 0.4062 0.784 0.836 0.000 0.164
#> SRR805793 1 0.6154 0.338 0.592 0.000 0.408
#> SRR805794 1 0.0237 0.931 0.996 0.000 0.004
#> SRR805795 1 0.0237 0.931 0.996 0.000 0.004
#> SRR805796 1 0.0237 0.931 0.996 0.000 0.004
#> SRR805797 1 0.0237 0.931 0.996 0.000 0.004
#> SRR805798 1 0.0237 0.931 0.996 0.000 0.004
#> SRR805799 1 0.0237 0.931 0.996 0.000 0.004
#> SRR805800 1 0.0237 0.931 0.996 0.000 0.004
#> SRR805801 1 0.0237 0.931 0.996 0.000 0.004
#> SRR805802 2 0.0237 0.963 0.004 0.996 0.000
#> SRR805803 2 0.0000 0.966 0.000 1.000 0.000
#> SRR805804 2 0.0000 0.966 0.000 1.000 0.000
#> SRR805805 2 0.0000 0.966 0.000 1.000 0.000
#> SRR805806 2 0.4931 0.702 0.232 0.768 0.000
#> SRR805807 1 0.4235 0.759 0.824 0.176 0.000
#> SRR805808 2 0.0000 0.966 0.000 1.000 0.000
#> SRR805809 2 0.0000 0.966 0.000 1.000 0.000
#> SRR805810 2 0.3816 0.823 0.148 0.852 0.000
#> SRR805811 1 0.6286 0.118 0.536 0.464 0.000
#> SRR805812 2 0.3340 0.853 0.120 0.880 0.000
#> SRR805813 1 0.1031 0.933 0.976 0.000 0.024
#> SRR805814 1 0.1031 0.933 0.976 0.000 0.024
#> SRR805815 1 0.1031 0.933 0.976 0.000 0.024
#> SRR805816 1 0.1031 0.933 0.976 0.000 0.024
#> SRR805817 1 0.1031 0.933 0.976 0.000 0.024
#> SRR805818 1 0.1031 0.933 0.976 0.000 0.024
#> SRR805819 1 0.1031 0.933 0.976 0.000 0.024
#> SRR805820 1 0.1031 0.933 0.976 0.000 0.024
#> SRR805821 1 0.1031 0.933 0.976 0.000 0.024
#> SRR805822 1 0.1031 0.933 0.976 0.000 0.024
#> SRR805823 1 0.1031 0.933 0.976 0.000 0.024
#> SRR805824 3 0.0237 0.994 0.000 0.004 0.996
#> SRR805825 3 0.0424 0.996 0.000 0.008 0.992
#> SRR805826 3 0.0592 0.995 0.000 0.012 0.988
#> SRR805828 3 0.0000 0.990 0.000 0.000 1.000
#> SRR805829 3 0.0237 0.994 0.000 0.004 0.996
#> SRR805830 3 0.0424 0.996 0.000 0.008 0.992
#> SRR805831 3 0.0592 0.995 0.000 0.012 0.988
#> SRR805832 3 0.0592 0.995 0.000 0.012 0.988
#> SRR805833 3 0.0592 0.995 0.000 0.012 0.988
#> SRR805834 3 0.0424 0.996 0.000 0.008 0.992
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.2271 0.942 0.008 0.916 0.000 0.076
#> SRR805781 2 0.2271 0.942 0.008 0.916 0.000 0.076
#> SRR805782 2 0.2271 0.942 0.008 0.916 0.000 0.076
#> SRR805784 2 0.2271 0.942 0.008 0.916 0.000 0.076
#> SRR805785 2 0.2271 0.942 0.008 0.916 0.000 0.076
#> SRR805786 2 0.2271 0.942 0.008 0.916 0.000 0.076
#> SRR805787 2 0.2271 0.942 0.008 0.916 0.000 0.076
#> SRR805788 2 0.2271 0.942 0.008 0.916 0.000 0.076
#> SRR805789 2 0.2271 0.942 0.008 0.916 0.000 0.076
#> SRR805790 2 0.2271 0.942 0.008 0.916 0.000 0.076
#> SRR805791 1 0.0336 0.957 0.992 0.000 0.000 0.008
#> SRR805792 1 0.0188 0.950 0.996 0.000 0.004 0.000
#> SRR805793 1 0.0779 0.935 0.980 0.000 0.004 0.016
#> SRR805794 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> SRR805795 1 0.0336 0.957 0.992 0.000 0.000 0.008
#> SRR805796 1 0.0336 0.957 0.992 0.000 0.000 0.008
#> SRR805797 1 0.0336 0.957 0.992 0.000 0.000 0.008
#> SRR805798 1 0.0336 0.957 0.992 0.000 0.000 0.008
#> SRR805799 1 0.0336 0.957 0.992 0.000 0.000 0.008
#> SRR805800 1 0.0336 0.957 0.992 0.000 0.000 0.008
#> SRR805801 1 0.0336 0.957 0.992 0.000 0.000 0.008
#> SRR805802 2 0.0469 0.931 0.000 0.988 0.000 0.012
#> SRR805803 2 0.0000 0.935 0.000 1.000 0.000 0.000
#> SRR805804 2 0.0000 0.935 0.000 1.000 0.000 0.000
#> SRR805805 2 0.0000 0.935 0.000 1.000 0.000 0.000
#> SRR805806 2 0.2376 0.884 0.068 0.916 0.000 0.016
#> SRR805807 1 0.6466 0.514 0.608 0.288 0.000 0.104
#> SRR805808 2 0.0188 0.934 0.004 0.996 0.000 0.000
#> SRR805809 2 0.0000 0.935 0.000 1.000 0.000 0.000
#> SRR805810 2 0.2662 0.868 0.084 0.900 0.000 0.016
#> SRR805811 2 0.5604 0.668 0.116 0.724 0.000 0.160
#> SRR805812 2 0.0779 0.928 0.004 0.980 0.000 0.016
#> SRR805813 4 0.1940 1.000 0.076 0.000 0.000 0.924
#> SRR805814 4 0.1940 1.000 0.076 0.000 0.000 0.924
#> SRR805815 4 0.1940 1.000 0.076 0.000 0.000 0.924
#> SRR805816 4 0.1940 1.000 0.076 0.000 0.000 0.924
#> SRR805817 4 0.1940 1.000 0.076 0.000 0.000 0.924
#> SRR805818 4 0.1940 1.000 0.076 0.000 0.000 0.924
#> SRR805819 4 0.1940 1.000 0.076 0.000 0.000 0.924
#> SRR805820 4 0.1940 1.000 0.076 0.000 0.000 0.924
#> SRR805821 4 0.1940 1.000 0.076 0.000 0.000 0.924
#> SRR805822 4 0.1940 1.000 0.076 0.000 0.000 0.924
#> SRR805823 4 0.1940 1.000 0.076 0.000 0.000 0.924
#> SRR805824 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805834 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
#> SRR805780 2 0 1 0 1 0 0 0
#> SRR805781 2 0 1 0 1 0 0 0
#> SRR805782 2 0 1 0 1 0 0 0
#> SRR805784 2 0 1 0 1 0 0 0
#> SRR805785 2 0 1 0 1 0 0 0
#> SRR805786 2 0 1 0 1 0 0 0
#> SRR805787 2 0 1 0 1 0 0 0
#> SRR805788 2 0 1 0 1 0 0 0
#> SRR805789 2 0 1 0 1 0 0 0
#> SRR805790 2 0 1 0 1 0 0 0
#> SRR805791 1 0 1 1 0 0 0 0
#> SRR805792 1 0 1 1 0 0 0 0
#> SRR805793 1 0 1 1 0 0 0 0
#> SRR805794 1 0 1 1 0 0 0 0
#> SRR805795 1 0 1 1 0 0 0 0
#> SRR805796 1 0 1 1 0 0 0 0
#> SRR805797 1 0 1 1 0 0 0 0
#> SRR805798 1 0 1 1 0 0 0 0
#> SRR805799 1 0 1 1 0 0 0 0
#> SRR805800 1 0 1 1 0 0 0 0
#> SRR805801 1 0 1 1 0 0 0 0
#> SRR805802 5 0 1 0 0 0 0 1
#> SRR805803 5 0 1 0 0 0 0 1
#> SRR805804 5 0 1 0 0 0 0 1
#> SRR805805 5 0 1 0 0 0 0 1
#> SRR805806 5 0 1 0 0 0 0 1
#> SRR805807 5 0 1 0 0 0 0 1
#> SRR805808 5 0 1 0 0 0 0 1
#> SRR805809 5 0 1 0 0 0 0 1
#> SRR805810 5 0 1 0 0 0 0 1
#> SRR805811 5 0 1 0 0 0 0 1
#> SRR805812 5 0 1 0 0 0 0 1
#> SRR805813 4 0 1 0 0 0 1 0
#> SRR805814 4 0 1 0 0 0 1 0
#> SRR805815 4 0 1 0 0 0 1 0
#> SRR805816 4 0 1 0 0 0 1 0
#> SRR805817 4 0 1 0 0 0 1 0
#> SRR805818 4 0 1 0 0 0 1 0
#> SRR805819 4 0 1 0 0 0 1 0
#> SRR805820 4 0 1 0 0 0 1 0
#> SRR805821 4 0 1 0 0 0 1 0
#> SRR805822 4 0 1 0 0 0 1 0
#> SRR805823 4 0 1 0 0 0 1 0
#> SRR805824 3 0 1 0 0 1 0 0
#> SRR805825 3 0 1 0 0 1 0 0
#> SRR805826 3 0 1 0 0 1 0 0
#> SRR805828 3 0 1 0 0 1 0 0
#> SRR805829 3 0 1 0 0 1 0 0
#> SRR805830 3 0 1 0 0 1 0 0
#> SRR805831 3 0 1 0 0 1 0 0
#> SRR805832 3 0 1 0 0 1 0 0
#> SRR805833 3 0 1 0 0 1 0 0
#> SRR805834 3 0 1 0 0 1 0 0
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0547 0.925 0.000 0.980 0 0 0.000 NA
#> SRR805781 2 0.3221 0.835 0.000 0.736 0 0 0.000 NA
#> SRR805782 2 0.1957 0.918 0.000 0.888 0 0 0.000 NA
#> SRR805784 2 0.2941 0.845 0.000 0.780 0 0 0.000 NA
#> SRR805785 2 0.1610 0.913 0.000 0.916 0 0 0.000 NA
#> SRR805786 2 0.1141 0.919 0.000 0.948 0 0 0.000 NA
#> SRR805787 2 0.1957 0.911 0.000 0.888 0 0 0.000 NA
#> SRR805788 2 0.1957 0.910 0.000 0.888 0 0 0.000 NA
#> SRR805789 2 0.0547 0.924 0.000 0.980 0 0 0.000 NA
#> SRR805790 2 0.1501 0.915 0.000 0.924 0 0 0.000 NA
#> SRR805791 1 0.0000 0.962 1.000 0.000 0 0 0.000 NA
#> SRR805792 1 0.0146 0.960 0.996 0.000 0 0 0.000 NA
#> SRR805793 1 0.0363 0.955 0.988 0.000 0 0 0.000 NA
#> SRR805794 1 0.0000 0.962 1.000 0.000 0 0 0.000 NA
#> SRR805795 1 0.0000 0.962 1.000 0.000 0 0 0.000 NA
#> SRR805796 1 0.0000 0.962 1.000 0.000 0 0 0.000 NA
#> SRR805797 1 0.0000 0.962 1.000 0.000 0 0 0.000 NA
#> SRR805798 1 0.0000 0.962 1.000 0.000 0 0 0.000 NA
#> SRR805799 1 0.3857 0.537 0.532 0.000 0 0 0.000 NA
#> SRR805800 1 0.0000 0.962 1.000 0.000 0 0 0.000 NA
#> SRR805801 1 0.0000 0.962 1.000 0.000 0 0 0.000 NA
#> SRR805802 5 0.0146 0.990 0.000 0.000 0 0 0.996 NA
#> SRR805803 5 0.1779 0.933 0.000 0.016 0 0 0.920 NA
#> SRR805804 5 0.0458 0.984 0.000 0.000 0 0 0.984 NA
#> SRR805805 5 0.0146 0.990 0.000 0.000 0 0 0.996 NA
#> SRR805806 5 0.0146 0.989 0.000 0.000 0 0 0.996 NA
#> SRR805807 5 0.0260 0.988 0.000 0.000 0 0 0.992 NA
#> SRR805808 5 0.0000 0.990 0.000 0.000 0 0 1.000 NA
#> SRR805809 5 0.0146 0.990 0.000 0.000 0 0 0.996 NA
#> SRR805810 5 0.0000 0.990 0.000 0.000 0 0 1.000 NA
#> SRR805811 5 0.0146 0.989 0.000 0.000 0 0 0.996 NA
#> SRR805812 5 0.0000 0.990 0.000 0.000 0 0 1.000 NA
#> SRR805813 4 0.0000 1.000 0.000 0.000 0 1 0.000 NA
#> SRR805814 4 0.0000 1.000 0.000 0.000 0 1 0.000 NA
#> SRR805815 4 0.0000 1.000 0.000 0.000 0 1 0.000 NA
#> SRR805816 4 0.0000 1.000 0.000 0.000 0 1 0.000 NA
#> SRR805817 4 0.0000 1.000 0.000 0.000 0 1 0.000 NA
#> SRR805818 4 0.0000 1.000 0.000 0.000 0 1 0.000 NA
#> SRR805819 4 0.0000 1.000 0.000 0.000 0 1 0.000 NA
#> SRR805820 4 0.0000 1.000 0.000 0.000 0 1 0.000 NA
#> SRR805821 4 0.0000 1.000 0.000 0.000 0 1 0.000 NA
#> SRR805822 4 0.0000 1.000 0.000 0.000 0 1 0.000 NA
#> SRR805823 4 0.0000 1.000 0.000 0.000 0 1 0.000 NA
#> SRR805824 3 0.0000 1.000 0.000 0.000 1 0 0.000 NA
#> SRR805825 3 0.0000 1.000 0.000 0.000 1 0 0.000 NA
#> SRR805826 3 0.0000 1.000 0.000 0.000 1 0 0.000 NA
#> SRR805828 3 0.0000 1.000 0.000 0.000 1 0 0.000 NA
#> SRR805829 3 0.0000 1.000 0.000 0.000 1 0 0.000 NA
#> SRR805830 3 0.0000 1.000 0.000 0.000 1 0 0.000 NA
#> SRR805831 3 0.0000 1.000 0.000 0.000 1 0 0.000 NA
#> SRR805832 3 0.0000 1.000 0.000 0.000 1 0 0.000 NA
#> SRR805833 3 0.0000 1.000 0.000 0.000 1 0 0.000 NA
#> SRR805834 3 0.0000 1.000 0.000 0.000 1 0 0.000 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "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 15291 rows and 53 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 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.939 0.967 0.969 0.4342 0.570 0.570
#> 3 3 0.689 0.832 0.910 0.1904 0.974 0.954
#> 4 4 0.598 0.796 0.870 0.0463 0.989 0.980
#> 5 5 0.697 0.869 0.935 0.2460 0.811 0.646
#> 6 6 0.814 0.888 0.905 0.1539 0.880 0.653
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
#> SRR805780 2 0.0000 0.998 0.000 1.000
#> SRR805781 2 0.0000 0.998 0.000 1.000
#> SRR805782 2 0.0000 0.998 0.000 1.000
#> SRR805784 2 0.0000 0.998 0.000 1.000
#> SRR805785 2 0.0000 0.998 0.000 1.000
#> SRR805786 2 0.0000 0.998 0.000 1.000
#> SRR805787 2 0.0000 0.998 0.000 1.000
#> SRR805788 2 0.0000 0.998 0.000 1.000
#> SRR805789 2 0.0000 0.998 0.000 1.000
#> SRR805790 2 0.0000 0.998 0.000 1.000
#> SRR805791 1 0.2423 0.966 0.960 0.040
#> SRR805792 1 0.2423 0.966 0.960 0.040
#> SRR805793 1 0.2423 0.966 0.960 0.040
#> SRR805794 1 0.2423 0.966 0.960 0.040
#> SRR805795 1 0.2423 0.966 0.960 0.040
#> SRR805796 1 0.2423 0.966 0.960 0.040
#> SRR805797 1 0.2423 0.966 0.960 0.040
#> SRR805798 1 0.2423 0.966 0.960 0.040
#> SRR805799 1 0.0000 0.958 1.000 0.000
#> SRR805800 1 0.2423 0.966 0.960 0.040
#> SRR805801 1 0.2423 0.966 0.960 0.040
#> SRR805802 2 0.0376 0.996 0.004 0.996
#> SRR805803 2 0.0000 0.998 0.000 1.000
#> SRR805804 2 0.0000 0.998 0.000 1.000
#> SRR805805 2 0.0376 0.996 0.004 0.996
#> SRR805806 1 0.5629 0.899 0.868 0.132
#> SRR805807 1 0.0000 0.958 1.000 0.000
#> SRR805808 2 0.1184 0.984 0.016 0.984
#> SRR805809 2 0.0376 0.996 0.004 0.996
#> SRR805810 1 0.5408 0.905 0.876 0.124
#> SRR805811 1 0.5408 0.905 0.876 0.124
#> SRR805812 1 0.6048 0.881 0.852 0.148
#> SRR805813 1 0.0000 0.958 1.000 0.000
#> SRR805814 1 0.0000 0.958 1.000 0.000
#> SRR805815 1 0.0000 0.958 1.000 0.000
#> SRR805816 1 0.0000 0.958 1.000 0.000
#> SRR805817 1 0.0000 0.958 1.000 0.000
#> SRR805818 1 0.0000 0.958 1.000 0.000
#> SRR805819 1 0.0000 0.958 1.000 0.000
#> SRR805820 1 0.0000 0.958 1.000 0.000
#> SRR805821 1 0.0000 0.958 1.000 0.000
#> SRR805822 1 0.0000 0.958 1.000 0.000
#> SRR805823 1 0.0000 0.958 1.000 0.000
#> SRR805824 1 0.3584 0.959 0.932 0.068
#> SRR805825 1 0.3584 0.959 0.932 0.068
#> SRR805826 1 0.3584 0.959 0.932 0.068
#> SRR805828 1 0.3584 0.959 0.932 0.068
#> SRR805829 1 0.3584 0.959 0.932 0.068
#> SRR805830 1 0.3584 0.959 0.932 0.068
#> SRR805831 1 0.3584 0.959 0.932 0.068
#> SRR805832 1 0.3584 0.959 0.932 0.068
#> SRR805833 1 0.3584 0.959 0.932 0.068
#> SRR805834 1 0.3584 0.959 0.932 0.068
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.0000 0.997 0.000 1.000 0.000
#> SRR805781 2 0.0000 0.997 0.000 1.000 0.000
#> SRR805782 2 0.0000 0.997 0.000 1.000 0.000
#> SRR805784 2 0.0000 0.997 0.000 1.000 0.000
#> SRR805785 2 0.0000 0.997 0.000 1.000 0.000
#> SRR805786 2 0.0000 0.997 0.000 1.000 0.000
#> SRR805787 2 0.0000 0.997 0.000 1.000 0.000
#> SRR805788 2 0.0000 0.997 0.000 1.000 0.000
#> SRR805789 2 0.0000 0.997 0.000 1.000 0.000
#> SRR805790 2 0.0000 0.997 0.000 1.000 0.000
#> SRR805791 1 0.5216 0.839 0.740 0.000 0.260
#> SRR805792 1 0.5216 0.839 0.740 0.000 0.260
#> SRR805793 1 0.5216 0.839 0.740 0.000 0.260
#> SRR805794 1 0.5216 0.839 0.740 0.000 0.260
#> SRR805795 1 0.5216 0.839 0.740 0.000 0.260
#> SRR805796 1 0.5216 0.839 0.740 0.000 0.260
#> SRR805797 1 0.5216 0.839 0.740 0.000 0.260
#> SRR805798 1 0.5216 0.839 0.740 0.000 0.260
#> SRR805799 3 0.0000 0.000 0.000 0.000 1.000
#> SRR805800 1 0.5216 0.839 0.740 0.000 0.260
#> SRR805801 1 0.5216 0.839 0.740 0.000 0.260
#> SRR805802 2 0.0237 0.994 0.004 0.996 0.000
#> SRR805803 2 0.0000 0.997 0.000 1.000 0.000
#> SRR805804 2 0.0000 0.997 0.000 1.000 0.000
#> SRR805805 2 0.0237 0.994 0.004 0.996 0.000
#> SRR805806 1 0.8311 0.728 0.616 0.132 0.252
#> SRR805807 1 0.5733 0.827 0.676 0.000 0.324
#> SRR805808 2 0.0848 0.978 0.008 0.984 0.008
#> SRR805809 2 0.0237 0.994 0.004 0.996 0.000
#> SRR805810 1 0.8261 0.736 0.616 0.124 0.260
#> SRR805811 1 0.8261 0.736 0.616 0.124 0.260
#> SRR805812 1 0.8525 0.702 0.600 0.148 0.252
#> SRR805813 1 0.5678 0.831 0.684 0.000 0.316
#> SRR805814 1 0.5678 0.831 0.684 0.000 0.316
#> SRR805815 1 0.5678 0.831 0.684 0.000 0.316
#> SRR805816 1 0.5678 0.831 0.684 0.000 0.316
#> SRR805817 1 0.5678 0.831 0.684 0.000 0.316
#> SRR805818 1 0.5678 0.831 0.684 0.000 0.316
#> SRR805819 1 0.5678 0.831 0.684 0.000 0.316
#> SRR805820 1 0.5678 0.831 0.684 0.000 0.316
#> SRR805821 1 0.5678 0.831 0.684 0.000 0.316
#> SRR805822 1 0.5678 0.831 0.684 0.000 0.316
#> SRR805823 1 0.5678 0.831 0.684 0.000 0.316
#> SRR805824 1 0.0000 0.688 1.000 0.000 0.000
#> SRR805825 1 0.0000 0.688 1.000 0.000 0.000
#> SRR805826 1 0.0000 0.688 1.000 0.000 0.000
#> SRR805828 1 0.0000 0.688 1.000 0.000 0.000
#> SRR805829 1 0.0000 0.688 1.000 0.000 0.000
#> SRR805830 1 0.0000 0.688 1.000 0.000 0.000
#> SRR805831 1 0.0000 0.688 1.000 0.000 0.000
#> SRR805832 1 0.0000 0.688 1.000 0.000 0.000
#> SRR805833 1 0.0000 0.688 1.000 0.000 0.000
#> SRR805834 1 0.0000 0.688 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.0000 0.942 0.000 1.000 0.000 0.000
#> SRR805781 2 0.0000 0.942 0.000 1.000 0.000 0.000
#> SRR805782 2 0.0000 0.942 0.000 1.000 0.000 0.000
#> SRR805784 3 0.4040 0.000 0.000 0.248 0.752 0.000
#> SRR805785 2 0.0000 0.942 0.000 1.000 0.000 0.000
#> SRR805786 2 0.0000 0.942 0.000 1.000 0.000 0.000
#> SRR805787 2 0.0000 0.942 0.000 1.000 0.000 0.000
#> SRR805788 2 0.0000 0.942 0.000 1.000 0.000 0.000
#> SRR805789 2 0.0000 0.942 0.000 1.000 0.000 0.000
#> SRR805790 2 0.0000 0.942 0.000 1.000 0.000 0.000
#> SRR805791 4 0.0336 0.841 0.008 0.000 0.000 0.992
#> SRR805792 4 0.0336 0.841 0.008 0.000 0.000 0.992
#> SRR805793 4 0.0336 0.841 0.008 0.000 0.000 0.992
#> SRR805794 4 0.0336 0.841 0.008 0.000 0.000 0.992
#> SRR805795 4 0.0336 0.841 0.008 0.000 0.000 0.992
#> SRR805796 4 0.0336 0.841 0.008 0.000 0.000 0.992
#> SRR805797 4 0.0336 0.841 0.008 0.000 0.000 0.992
#> SRR805798 4 0.0336 0.841 0.008 0.000 0.000 0.992
#> SRR805799 1 0.4829 0.000 0.776 0.000 0.068 0.156
#> SRR805800 4 0.0336 0.841 0.008 0.000 0.000 0.992
#> SRR805801 4 0.0336 0.841 0.008 0.000 0.000 0.992
#> SRR805802 2 0.2647 0.883 0.000 0.880 0.120 0.000
#> SRR805803 2 0.1792 0.915 0.000 0.932 0.068 0.000
#> SRR805804 2 0.1792 0.915 0.000 0.932 0.068 0.000
#> SRR805805 2 0.2647 0.883 0.000 0.880 0.120 0.000
#> SRR805806 4 0.3849 0.769 0.008 0.084 0.052 0.856
#> SRR805807 4 0.2530 0.826 0.100 0.000 0.004 0.896
#> SRR805808 2 0.3160 0.868 0.004 0.868 0.120 0.008
#> SRR805809 2 0.2647 0.883 0.000 0.880 0.120 0.000
#> SRR805810 4 0.3711 0.776 0.008 0.076 0.052 0.864
#> SRR805811 4 0.3711 0.776 0.008 0.076 0.052 0.864
#> SRR805812 4 0.4122 0.750 0.008 0.096 0.056 0.840
#> SRR805813 4 0.2216 0.831 0.092 0.000 0.000 0.908
#> SRR805814 4 0.2216 0.831 0.092 0.000 0.000 0.908
#> SRR805815 4 0.2216 0.831 0.092 0.000 0.000 0.908
#> SRR805816 4 0.2216 0.831 0.092 0.000 0.000 0.908
#> SRR805817 4 0.2216 0.831 0.092 0.000 0.000 0.908
#> SRR805818 4 0.2216 0.831 0.092 0.000 0.000 0.908
#> SRR805819 4 0.2216 0.831 0.092 0.000 0.000 0.908
#> SRR805820 4 0.2216 0.831 0.092 0.000 0.000 0.908
#> SRR805821 4 0.2216 0.831 0.092 0.000 0.000 0.908
#> SRR805822 4 0.2216 0.831 0.092 0.000 0.000 0.908
#> SRR805823 4 0.2216 0.831 0.092 0.000 0.000 0.908
#> SRR805824 4 0.5452 0.692 0.156 0.000 0.108 0.736
#> SRR805825 4 0.5452 0.692 0.156 0.000 0.108 0.736
#> SRR805826 4 0.5452 0.692 0.156 0.000 0.108 0.736
#> SRR805828 4 0.5452 0.692 0.156 0.000 0.108 0.736
#> SRR805829 4 0.5452 0.692 0.156 0.000 0.108 0.736
#> SRR805830 4 0.5452 0.692 0.156 0.000 0.108 0.736
#> SRR805831 4 0.5452 0.692 0.156 0.000 0.108 0.736
#> SRR805832 4 0.5452 0.692 0.156 0.000 0.108 0.736
#> SRR805833 4 0.5452 0.692 0.156 0.000 0.108 0.736
#> SRR805834 4 0.5452 0.692 0.156 0.000 0.108 0.736
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.0000 0.874 0 1.000 0.000 0.000 0.000
#> SRR805781 2 0.0000 0.874 0 1.000 0.000 0.000 0.000
#> SRR805782 2 0.0000 0.874 0 1.000 0.000 0.000 0.000
#> SRR805784 5 0.2813 0.000 0 0.168 0.000 0.000 0.832
#> SRR805785 2 0.0000 0.874 0 1.000 0.000 0.000 0.000
#> SRR805786 2 0.0000 0.874 0 1.000 0.000 0.000 0.000
#> SRR805787 2 0.0000 0.874 0 1.000 0.000 0.000 0.000
#> SRR805788 2 0.0000 0.874 0 1.000 0.000 0.000 0.000
#> SRR805789 2 0.0000 0.874 0 1.000 0.000 0.000 0.000
#> SRR805790 2 0.0000 0.874 0 1.000 0.000 0.000 0.000
#> SRR805791 4 0.2127 0.912 0 0.000 0.108 0.892 0.000
#> SRR805792 4 0.2127 0.912 0 0.000 0.108 0.892 0.000
#> SRR805793 4 0.2127 0.912 0 0.000 0.108 0.892 0.000
#> SRR805794 4 0.2127 0.912 0 0.000 0.108 0.892 0.000
#> SRR805795 4 0.2127 0.912 0 0.000 0.108 0.892 0.000
#> SRR805796 4 0.2127 0.912 0 0.000 0.108 0.892 0.000
#> SRR805797 4 0.2127 0.912 0 0.000 0.108 0.892 0.000
#> SRR805798 4 0.2127 0.912 0 0.000 0.108 0.892 0.000
#> SRR805799 1 0.0000 0.000 1 0.000 0.000 0.000 0.000
#> SRR805800 4 0.2127 0.912 0 0.000 0.108 0.892 0.000
#> SRR805801 4 0.2127 0.912 0 0.000 0.108 0.892 0.000
#> SRR805802 2 0.3707 0.728 0 0.716 0.000 0.000 0.284
#> SRR805803 2 0.2690 0.814 0 0.844 0.000 0.000 0.156
#> SRR805804 2 0.2690 0.814 0 0.844 0.000 0.000 0.156
#> SRR805805 2 0.3707 0.728 0 0.716 0.000 0.000 0.284
#> SRR805806 4 0.2471 0.867 0 0.000 0.000 0.864 0.136
#> SRR805807 4 0.0162 0.920 0 0.000 0.000 0.996 0.004
#> SRR805808 2 0.4086 0.712 0 0.704 0.000 0.012 0.284
#> SRR805809 2 0.3707 0.728 0 0.716 0.000 0.000 0.284
#> SRR805810 4 0.2377 0.873 0 0.000 0.000 0.872 0.128
#> SRR805811 4 0.2377 0.873 0 0.000 0.000 0.872 0.128
#> SRR805812 4 0.2909 0.852 0 0.012 0.000 0.848 0.140
#> SRR805813 4 0.0579 0.922 0 0.000 0.008 0.984 0.008
#> SRR805814 4 0.0579 0.922 0 0.000 0.008 0.984 0.008
#> SRR805815 4 0.0579 0.922 0 0.000 0.008 0.984 0.008
#> SRR805816 4 0.0579 0.922 0 0.000 0.008 0.984 0.008
#> SRR805817 4 0.0579 0.922 0 0.000 0.008 0.984 0.008
#> SRR805818 4 0.0579 0.922 0 0.000 0.008 0.984 0.008
#> SRR805819 4 0.0579 0.922 0 0.000 0.008 0.984 0.008
#> SRR805820 4 0.0579 0.922 0 0.000 0.008 0.984 0.008
#> SRR805821 4 0.0579 0.922 0 0.000 0.008 0.984 0.008
#> SRR805822 4 0.0579 0.922 0 0.000 0.008 0.984 0.008
#> SRR805823 4 0.0579 0.922 0 0.000 0.008 0.984 0.008
#> SRR805824 3 0.0000 1.000 0 0.000 1.000 0.000 0.000
#> SRR805825 3 0.0000 1.000 0 0.000 1.000 0.000 0.000
#> SRR805826 3 0.0000 1.000 0 0.000 1.000 0.000 0.000
#> SRR805828 3 0.0000 1.000 0 0.000 1.000 0.000 0.000
#> SRR805829 3 0.0000 1.000 0 0.000 1.000 0.000 0.000
#> SRR805830 3 0.0000 1.000 0 0.000 1.000 0.000 0.000
#> SRR805831 3 0.0000 1.000 0 0.000 1.000 0.000 0.000
#> SRR805832 3 0.0000 1.000 0 0.000 1.000 0.000 0.000
#> SRR805833 3 0.0000 1.000 0 0.000 1.000 0.000 0.000
#> SRR805834 3 0.0000 1.000 0 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
#> SRR805780 2 0.0000 0.871 0.000 1.000 0.000 0.000 0 0.000
#> SRR805781 2 0.0000 0.871 0.000 1.000 0.000 0.000 0 0.000
#> SRR805782 2 0.0000 0.871 0.000 1.000 0.000 0.000 0 0.000
#> SRR805784 6 0.2491 0.000 0.000 0.164 0.000 0.000 0 0.836
#> SRR805785 2 0.0000 0.871 0.000 1.000 0.000 0.000 0 0.000
#> SRR805786 2 0.0000 0.871 0.000 1.000 0.000 0.000 0 0.000
#> SRR805787 2 0.0000 0.871 0.000 1.000 0.000 0.000 0 0.000
#> SRR805788 2 0.0000 0.871 0.000 1.000 0.000 0.000 0 0.000
#> SRR805789 2 0.0000 0.871 0.000 1.000 0.000 0.000 0 0.000
#> SRR805790 2 0.0000 0.871 0.000 1.000 0.000 0.000 0 0.000
#> SRR805791 1 0.2527 0.939 0.868 0.000 0.108 0.024 0 0.000
#> SRR805792 1 0.2527 0.939 0.868 0.000 0.108 0.024 0 0.000
#> SRR805793 1 0.2527 0.939 0.868 0.000 0.108 0.024 0 0.000
#> SRR805794 1 0.2527 0.939 0.868 0.000 0.108 0.024 0 0.000
#> SRR805795 1 0.2527 0.939 0.868 0.000 0.108 0.024 0 0.000
#> SRR805796 1 0.2527 0.939 0.868 0.000 0.108 0.024 0 0.000
#> SRR805797 1 0.2527 0.939 0.868 0.000 0.108 0.024 0 0.000
#> SRR805798 1 0.2527 0.939 0.868 0.000 0.108 0.024 0 0.000
#> SRR805799 5 0.0000 0.000 0.000 0.000 0.000 0.000 1 0.000
#> SRR805800 1 0.2527 0.939 0.868 0.000 0.108 0.024 0 0.000
#> SRR805801 1 0.2527 0.939 0.868 0.000 0.108 0.024 0 0.000
#> SRR805802 2 0.4526 0.736 0.132 0.704 0.000 0.000 0 0.164
#> SRR805803 2 0.2632 0.813 0.004 0.832 0.000 0.000 0 0.164
#> SRR805804 2 0.2632 0.813 0.004 0.832 0.000 0.000 0 0.164
#> SRR805805 2 0.4526 0.736 0.132 0.704 0.000 0.000 0 0.164
#> SRR805806 1 0.0405 0.855 0.988 0.000 0.000 0.004 0 0.008
#> SRR805807 1 0.2135 0.834 0.872 0.000 0.000 0.128 0 0.000
#> SRR805808 2 0.4602 0.726 0.144 0.696 0.000 0.000 0 0.160
#> SRR805809 2 0.4526 0.736 0.132 0.704 0.000 0.000 0 0.164
#> SRR805810 1 0.0146 0.860 0.996 0.000 0.000 0.004 0 0.000
#> SRR805811 1 0.0146 0.860 0.996 0.000 0.000 0.004 0 0.000
#> SRR805812 1 0.0622 0.840 0.980 0.008 0.000 0.000 0 0.012
#> SRR805813 4 0.0000 1.000 0.000 0.000 0.000 1.000 0 0.000
#> SRR805814 4 0.0000 1.000 0.000 0.000 0.000 1.000 0 0.000
#> SRR805815 4 0.0000 1.000 0.000 0.000 0.000 1.000 0 0.000
#> SRR805816 4 0.0000 1.000 0.000 0.000 0.000 1.000 0 0.000
#> SRR805817 4 0.0000 1.000 0.000 0.000 0.000 1.000 0 0.000
#> SRR805818 4 0.0000 1.000 0.000 0.000 0.000 1.000 0 0.000
#> SRR805819 4 0.0000 1.000 0.000 0.000 0.000 1.000 0 0.000
#> SRR805820 4 0.0000 1.000 0.000 0.000 0.000 1.000 0 0.000
#> SRR805821 4 0.0000 1.000 0.000 0.000 0.000 1.000 0 0.000
#> SRR805822 4 0.0000 1.000 0.000 0.000 0.000 1.000 0 0.000
#> SRR805823 4 0.0000 1.000 0.000 0.000 0.000 1.000 0 0.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "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 15291 rows and 53 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 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.641 0.915 0.941 0.4551 0.531 0.531
#> 3 3 0.586 0.648 0.762 0.3806 0.776 0.590
#> 4 4 0.580 0.691 0.720 0.1496 0.764 0.430
#> 5 5 0.789 0.940 0.889 0.0843 0.919 0.690
#> 6 6 0.897 0.912 0.908 0.0389 1.000 1.000
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.2948 0.9485 0.052 0.948
#> SRR805781 2 0.2948 0.9485 0.052 0.948
#> SRR805782 2 0.2948 0.9485 0.052 0.948
#> SRR805784 2 0.2948 0.9485 0.052 0.948
#> SRR805785 2 0.2948 0.9485 0.052 0.948
#> SRR805786 2 0.2948 0.9485 0.052 0.948
#> SRR805787 2 0.2948 0.9485 0.052 0.948
#> SRR805788 2 0.2948 0.9485 0.052 0.948
#> SRR805789 2 0.2948 0.9485 0.052 0.948
#> SRR805790 2 0.2948 0.9485 0.052 0.948
#> SRR805791 1 0.1184 0.9503 0.984 0.016
#> SRR805792 1 0.1184 0.9503 0.984 0.016
#> SRR805793 1 0.1184 0.9503 0.984 0.016
#> SRR805794 1 0.1184 0.9503 0.984 0.016
#> SRR805795 1 0.0376 0.9526 0.996 0.004
#> SRR805796 1 0.0376 0.9526 0.996 0.004
#> SRR805797 1 0.0376 0.9526 0.996 0.004
#> SRR805798 1 0.0376 0.9526 0.996 0.004
#> SRR805799 1 0.0672 0.9508 0.992 0.008
#> SRR805800 1 0.0376 0.9526 0.996 0.004
#> SRR805801 1 0.0376 0.9526 0.996 0.004
#> SRR805802 2 0.4431 0.9200 0.092 0.908
#> SRR805803 2 0.2778 0.9470 0.048 0.952
#> SRR805804 2 0.2778 0.9470 0.048 0.952
#> SRR805805 2 0.2778 0.9470 0.048 0.952
#> SRR805806 2 0.6343 0.8580 0.160 0.840
#> SRR805807 1 0.0376 0.9526 0.996 0.004
#> SRR805808 2 0.6048 0.8719 0.148 0.852
#> SRR805809 2 0.2778 0.9470 0.048 0.952
#> SRR805810 2 1.0000 0.0627 0.500 0.500
#> SRR805811 1 0.7219 0.7592 0.800 0.200
#> SRR805812 2 0.6048 0.8719 0.148 0.852
#> SRR805813 1 0.0000 0.9534 1.000 0.000
#> SRR805814 1 0.0000 0.9534 1.000 0.000
#> SRR805815 1 0.0000 0.9534 1.000 0.000
#> SRR805816 1 0.0000 0.9534 1.000 0.000
#> SRR805817 1 0.0000 0.9534 1.000 0.000
#> SRR805818 1 0.0000 0.9534 1.000 0.000
#> SRR805819 1 0.0000 0.9534 1.000 0.000
#> SRR805820 1 0.0000 0.9534 1.000 0.000
#> SRR805821 1 0.0000 0.9534 1.000 0.000
#> SRR805822 1 0.0000 0.9534 1.000 0.000
#> SRR805823 1 0.0000 0.9534 1.000 0.000
#> SRR805824 1 0.2603 0.9272 0.956 0.044
#> SRR805825 1 0.5842 0.8947 0.860 0.140
#> SRR805826 1 0.5842 0.8947 0.860 0.140
#> SRR805828 1 0.5842 0.8947 0.860 0.140
#> SRR805829 1 0.5842 0.8947 0.860 0.140
#> SRR805830 1 0.5842 0.8947 0.860 0.140
#> SRR805831 1 0.5842 0.8947 0.860 0.140
#> SRR805832 1 0.5842 0.8947 0.860 0.140
#> SRR805833 1 0.5842 0.8947 0.860 0.140
#> SRR805834 1 0.5842 0.8947 0.860 0.140
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.000 0.8746 0.000 1.000 0.000
#> SRR805781 2 0.000 0.8746 0.000 1.000 0.000
#> SRR805782 2 0.000 0.8746 0.000 1.000 0.000
#> SRR805784 2 0.103 0.8633 0.000 0.976 0.024
#> SRR805785 2 0.000 0.8746 0.000 1.000 0.000
#> SRR805786 2 0.000 0.8746 0.000 1.000 0.000
#> SRR805787 2 0.000 0.8746 0.000 1.000 0.000
#> SRR805788 2 0.000 0.8746 0.000 1.000 0.000
#> SRR805789 2 0.000 0.8746 0.000 1.000 0.000
#> SRR805790 2 0.000 0.8746 0.000 1.000 0.000
#> SRR805791 1 0.644 0.6096 0.564 0.004 0.432
#> SRR805792 1 0.644 0.6096 0.564 0.004 0.432
#> SRR805793 1 0.644 0.6096 0.564 0.004 0.432
#> SRR805794 1 0.644 0.6096 0.564 0.004 0.432
#> SRR805795 1 0.604 0.6610 0.620 0.000 0.380
#> SRR805796 1 0.604 0.6610 0.620 0.000 0.380
#> SRR805797 1 0.604 0.6610 0.620 0.000 0.380
#> SRR805798 1 0.604 0.6610 0.620 0.000 0.380
#> SRR805799 1 0.590 0.6451 0.648 0.000 0.352
#> SRR805800 1 0.604 0.6610 0.620 0.000 0.380
#> SRR805801 1 0.604 0.6610 0.620 0.000 0.380
#> SRR805802 2 0.651 0.5662 0.008 0.592 0.400
#> SRR805803 2 0.288 0.8471 0.000 0.904 0.096
#> SRR805804 2 0.288 0.8471 0.000 0.904 0.096
#> SRR805805 2 0.429 0.8049 0.000 0.820 0.180
#> SRR805806 3 0.915 -0.3342 0.144 0.416 0.440
#> SRR805807 1 0.601 0.5542 0.628 0.000 0.372
#> SRR805808 2 0.819 0.4173 0.072 0.496 0.432
#> SRR805809 2 0.429 0.8049 0.000 0.820 0.180
#> SRR805810 3 0.963 -0.0753 0.260 0.268 0.472
#> SRR805811 3 0.899 -0.2588 0.392 0.132 0.476
#> SRR805812 2 0.820 0.4062 0.072 0.488 0.440
#> SRR805813 1 0.000 0.6492 1.000 0.000 0.000
#> SRR805814 1 0.000 0.6492 1.000 0.000 0.000
#> SRR805815 1 0.000 0.6492 1.000 0.000 0.000
#> SRR805816 1 0.000 0.6492 1.000 0.000 0.000
#> SRR805817 1 0.000 0.6492 1.000 0.000 0.000
#> SRR805818 1 0.000 0.6492 1.000 0.000 0.000
#> SRR805819 1 0.000 0.6492 1.000 0.000 0.000
#> SRR805820 1 0.000 0.6492 1.000 0.000 0.000
#> SRR805821 1 0.000 0.6492 1.000 0.000 0.000
#> SRR805822 1 0.000 0.6492 1.000 0.000 0.000
#> SRR805823 1 0.000 0.6492 1.000 0.000 0.000
#> SRR805824 3 0.652 0.5636 0.492 0.004 0.504
#> SRR805825 3 0.830 0.6990 0.416 0.080 0.504
#> SRR805826 3 0.830 0.6990 0.416 0.080 0.504
#> SRR805828 3 0.830 0.6990 0.416 0.080 0.504
#> SRR805829 3 0.830 0.6990 0.416 0.080 0.504
#> SRR805830 3 0.830 0.6990 0.416 0.080 0.504
#> SRR805831 3 0.830 0.6990 0.416 0.080 0.504
#> SRR805832 3 0.830 0.6990 0.416 0.080 0.504
#> SRR805833 3 0.830 0.6990 0.416 0.080 0.504
#> SRR805834 3 0.830 0.6990 0.416 0.080 0.504
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.000 0.961 0.000 1.000 0.000 0.000
#> SRR805781 2 0.000 0.961 0.000 1.000 0.000 0.000
#> SRR805782 2 0.000 0.961 0.000 1.000 0.000 0.000
#> SRR805784 2 0.200 0.920 0.020 0.936 0.000 0.044
#> SRR805785 2 0.000 0.961 0.000 1.000 0.000 0.000
#> SRR805786 2 0.000 0.961 0.000 1.000 0.000 0.000
#> SRR805787 2 0.000 0.961 0.000 1.000 0.000 0.000
#> SRR805788 2 0.000 0.961 0.000 1.000 0.000 0.000
#> SRR805789 2 0.000 0.961 0.000 1.000 0.000 0.000
#> SRR805790 2 0.000 0.961 0.000 1.000 0.000 0.000
#> SRR805791 1 0.769 0.420 0.444 0.000 0.236 0.320
#> SRR805792 1 0.769 0.420 0.444 0.000 0.236 0.320
#> SRR805793 1 0.769 0.420 0.444 0.000 0.236 0.320
#> SRR805794 1 0.769 0.420 0.444 0.000 0.236 0.320
#> SRR805795 1 0.763 0.379 0.404 0.000 0.204 0.392
#> SRR805796 1 0.763 0.379 0.404 0.000 0.204 0.392
#> SRR805797 1 0.763 0.379 0.404 0.000 0.204 0.392
#> SRR805798 1 0.763 0.379 0.404 0.000 0.204 0.392
#> SRR805799 4 0.728 -0.406 0.424 0.000 0.148 0.428
#> SRR805800 1 0.763 0.379 0.404 0.000 0.204 0.392
#> SRR805801 1 0.763 0.379 0.404 0.000 0.204 0.392
#> SRR805802 1 0.480 0.249 0.720 0.264 0.008 0.008
#> SRR805803 2 0.374 0.810 0.160 0.824 0.000 0.016
#> SRR805804 2 0.374 0.810 0.160 0.824 0.000 0.016
#> SRR805805 1 0.515 -0.244 0.532 0.464 0.000 0.004
#> SRR805806 1 0.535 0.348 0.736 0.204 0.008 0.052
#> SRR805807 1 0.481 0.288 0.676 0.000 0.008 0.316
#> SRR805808 1 0.512 0.320 0.736 0.224 0.008 0.032
#> SRR805809 1 0.516 -0.254 0.528 0.468 0.000 0.004
#> SRR805810 1 0.514 0.384 0.764 0.168 0.008 0.060
#> SRR805811 1 0.533 0.413 0.764 0.112 0.008 0.116
#> SRR805812 1 0.512 0.320 0.736 0.224 0.008 0.032
#> SRR805813 4 0.373 0.925 0.000 0.000 0.212 0.788
#> SRR805814 4 0.373 0.925 0.000 0.000 0.212 0.788
#> SRR805815 4 0.373 0.925 0.000 0.000 0.212 0.788
#> SRR805816 4 0.373 0.925 0.000 0.000 0.212 0.788
#> SRR805817 4 0.373 0.925 0.000 0.000 0.212 0.788
#> SRR805818 4 0.373 0.925 0.000 0.000 0.212 0.788
#> SRR805819 4 0.373 0.925 0.000 0.000 0.212 0.788
#> SRR805820 4 0.373 0.925 0.000 0.000 0.212 0.788
#> SRR805821 4 0.373 0.925 0.000 0.000 0.212 0.788
#> SRR805822 4 0.373 0.925 0.000 0.000 0.212 0.788
#> SRR805823 4 0.373 0.925 0.000 0.000 0.212 0.788
#> SRR805824 3 0.152 0.970 0.008 0.016 0.960 0.016
#> SRR805825 3 0.121 0.993 0.004 0.032 0.964 0.000
#> SRR805826 3 0.121 0.993 0.004 0.032 0.964 0.000
#> SRR805828 3 0.102 0.992 0.000 0.032 0.968 0.000
#> SRR805829 3 0.102 0.992 0.000 0.032 0.968 0.000
#> SRR805830 3 0.102 0.992 0.000 0.032 0.968 0.000
#> SRR805831 3 0.136 0.992 0.008 0.032 0.960 0.000
#> SRR805832 3 0.149 0.992 0.012 0.032 0.956 0.000
#> SRR805833 3 0.149 0.992 0.012 0.032 0.956 0.000
#> SRR805834 3 0.149 0.992 0.012 0.032 0.956 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.000 0.934 0.000 1.000 0.000 0.000 0.000
#> SRR805781 2 0.000 0.934 0.000 1.000 0.000 0.000 0.000
#> SRR805782 2 0.000 0.934 0.000 1.000 0.000 0.000 0.000
#> SRR805784 2 0.303 0.860 0.060 0.880 0.040 0.000 0.020
#> SRR805785 2 0.000 0.934 0.000 1.000 0.000 0.000 0.000
#> SRR805786 2 0.000 0.934 0.000 1.000 0.000 0.000 0.000
#> SRR805787 2 0.000 0.934 0.000 1.000 0.000 0.000 0.000
#> SRR805788 2 0.000 0.934 0.000 1.000 0.000 0.000 0.000
#> SRR805789 2 0.000 0.934 0.000 1.000 0.000 0.000 0.000
#> SRR805790 2 0.000 0.934 0.000 1.000 0.000 0.000 0.000
#> SRR805791 1 0.464 0.951 0.772 0.000 0.092 0.116 0.020
#> SRR805792 1 0.464 0.951 0.772 0.000 0.092 0.116 0.020
#> SRR805793 1 0.464 0.951 0.772 0.000 0.092 0.116 0.020
#> SRR805794 1 0.464 0.951 0.772 0.000 0.092 0.116 0.020
#> SRR805795 1 0.406 0.963 0.784 0.000 0.064 0.152 0.000
#> SRR805796 1 0.406 0.963 0.784 0.000 0.064 0.152 0.000
#> SRR805797 1 0.406 0.963 0.784 0.000 0.064 0.152 0.000
#> SRR805798 1 0.406 0.963 0.784 0.000 0.064 0.152 0.000
#> SRR805799 1 0.536 0.836 0.736 0.000 0.088 0.108 0.068
#> SRR805800 1 0.406 0.963 0.784 0.000 0.064 0.152 0.000
#> SRR805801 1 0.406 0.963 0.784 0.000 0.064 0.152 0.000
#> SRR805802 5 0.360 0.926 0.104 0.060 0.004 0.000 0.832
#> SRR805803 2 0.525 0.626 0.092 0.688 0.008 0.000 0.212
#> SRR805804 2 0.525 0.626 0.092 0.688 0.008 0.000 0.212
#> SRR805805 5 0.335 0.839 0.020 0.148 0.004 0.000 0.828
#> SRR805806 5 0.343 0.937 0.100 0.044 0.004 0.004 0.848
#> SRR805807 5 0.437 0.851 0.112 0.000 0.020 0.076 0.792
#> SRR805808 5 0.343 0.937 0.100 0.044 0.004 0.004 0.848
#> SRR805809 5 0.335 0.839 0.020 0.148 0.004 0.000 0.828
#> SRR805810 5 0.346 0.934 0.108 0.040 0.004 0.004 0.844
#> SRR805811 5 0.355 0.917 0.108 0.016 0.004 0.028 0.844
#> SRR805812 5 0.343 0.937 0.100 0.044 0.004 0.004 0.848
#> SRR805813 4 0.000 0.997 0.000 0.000 0.000 1.000 0.000
#> SRR805814 4 0.051 0.988 0.000 0.000 0.000 0.984 0.016
#> SRR805815 4 0.000 0.997 0.000 0.000 0.000 1.000 0.000
#> SRR805816 4 0.051 0.988 0.000 0.000 0.000 0.984 0.016
#> SRR805817 4 0.000 0.997 0.000 0.000 0.000 1.000 0.000
#> SRR805818 4 0.000 0.997 0.000 0.000 0.000 1.000 0.000
#> SRR805819 4 0.000 0.997 0.000 0.000 0.000 1.000 0.000
#> SRR805820 4 0.000 0.997 0.000 0.000 0.000 1.000 0.000
#> SRR805821 4 0.000 0.997 0.000 0.000 0.000 1.000 0.000
#> SRR805822 4 0.000 0.997 0.000 0.000 0.000 1.000 0.000
#> SRR805823 4 0.000 0.997 0.000 0.000 0.000 1.000 0.000
#> SRR805824 3 0.278 0.964 0.004 0.004 0.880 0.096 0.016
#> SRR805825 3 0.293 0.984 0.000 0.020 0.880 0.080 0.020
#> SRR805826 3 0.265 0.986 0.004 0.020 0.892 0.080 0.004
#> SRR805828 3 0.233 0.986 0.000 0.020 0.900 0.080 0.000
#> SRR805829 3 0.233 0.986 0.000 0.020 0.900 0.080 0.000
#> SRR805830 3 0.249 0.985 0.004 0.020 0.896 0.080 0.000
#> SRR805831 3 0.289 0.985 0.004 0.020 0.884 0.080 0.012
#> SRR805832 3 0.319 0.983 0.000 0.020 0.868 0.080 0.032
#> SRR805833 3 0.319 0.983 0.000 0.020 0.868 0.080 0.032
#> SRR805834 3 0.319 0.983 0.000 0.020 0.868 0.080 0.032
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0000 0.907 0.000 1.000 0.000 0.000 0.000 NA
#> SRR805781 2 0.0000 0.907 0.000 1.000 0.000 0.000 0.000 NA
#> SRR805782 2 0.0000 0.907 0.000 1.000 0.000 0.000 0.000 NA
#> SRR805784 2 0.4237 0.780 0.052 0.788 0.024 0.000 0.020 NA
#> SRR805785 2 0.0260 0.905 0.000 0.992 0.000 0.000 0.000 NA
#> SRR805786 2 0.0260 0.905 0.000 0.992 0.000 0.000 0.000 NA
#> SRR805787 2 0.0000 0.907 0.000 1.000 0.000 0.000 0.000 NA
#> SRR805788 2 0.0000 0.907 0.000 1.000 0.000 0.000 0.000 NA
#> SRR805789 2 0.0000 0.907 0.000 1.000 0.000 0.000 0.000 NA
#> SRR805790 2 0.0000 0.907 0.000 1.000 0.000 0.000 0.000 NA
#> SRR805791 1 0.4363 0.907 0.772 0.000 0.032 0.092 0.004 NA
#> SRR805792 1 0.4363 0.907 0.772 0.000 0.032 0.092 0.004 NA
#> SRR805793 1 0.4363 0.907 0.772 0.000 0.032 0.092 0.004 NA
#> SRR805794 1 0.4363 0.907 0.772 0.000 0.032 0.092 0.004 NA
#> SRR805795 1 0.2404 0.928 0.872 0.000 0.016 0.112 0.000 NA
#> SRR805796 1 0.2404 0.928 0.872 0.000 0.016 0.112 0.000 NA
#> SRR805797 1 0.2404 0.928 0.872 0.000 0.016 0.112 0.000 NA
#> SRR805798 1 0.2404 0.928 0.872 0.000 0.016 0.112 0.000 NA
#> SRR805799 1 0.4838 0.624 0.640 0.000 0.012 0.048 0.004 NA
#> SRR805800 1 0.2404 0.928 0.872 0.000 0.016 0.112 0.000 NA
#> SRR805801 1 0.2404 0.928 0.872 0.000 0.016 0.112 0.000 NA
#> SRR805802 5 0.2476 0.929 0.032 0.008 0.000 0.000 0.888 NA
#> SRR805803 2 0.5639 0.460 0.000 0.536 0.000 0.000 0.212 NA
#> SRR805804 2 0.5680 0.446 0.000 0.528 0.000 0.000 0.220 NA
#> SRR805805 5 0.2365 0.909 0.000 0.040 0.000 0.000 0.888 NA
#> SRR805806 5 0.1080 0.948 0.032 0.004 0.000 0.004 0.960 NA
#> SRR805807 5 0.3301 0.876 0.064 0.000 0.000 0.024 0.844 NA
#> SRR805808 5 0.1049 0.948 0.032 0.008 0.000 0.000 0.960 NA
#> SRR805809 5 0.2365 0.909 0.000 0.040 0.000 0.000 0.888 NA
#> SRR805810 5 0.1624 0.942 0.040 0.000 0.000 0.004 0.936 NA
#> SRR805811 5 0.1624 0.942 0.040 0.000 0.000 0.004 0.936 NA
#> SRR805812 5 0.1049 0.948 0.032 0.008 0.000 0.000 0.960 NA
#> SRR805813 4 0.0000 0.985 0.000 0.000 0.000 1.000 0.000 NA
#> SRR805814 4 0.1644 0.942 0.000 0.000 0.000 0.920 0.004 NA
#> SRR805815 4 0.0632 0.974 0.000 0.000 0.000 0.976 0.000 NA
#> SRR805816 4 0.1644 0.942 0.000 0.000 0.000 0.920 0.004 NA
#> SRR805817 4 0.0000 0.985 0.000 0.000 0.000 1.000 0.000 NA
#> SRR805818 4 0.0000 0.985 0.000 0.000 0.000 1.000 0.000 NA
#> SRR805819 4 0.0000 0.985 0.000 0.000 0.000 1.000 0.000 NA
#> SRR805820 4 0.0000 0.985 0.000 0.000 0.000 1.000 0.000 NA
#> SRR805821 4 0.0000 0.985 0.000 0.000 0.000 1.000 0.000 NA
#> SRR805822 4 0.0000 0.985 0.000 0.000 0.000 1.000 0.000 NA
#> SRR805823 4 0.0000 0.985 0.000 0.000 0.000 1.000 0.000 NA
#> SRR805824 3 0.2973 0.912 0.004 0.000 0.864 0.032 0.016 NA
#> SRR805825 3 0.1789 0.967 0.000 0.000 0.924 0.032 0.000 NA
#> SRR805826 3 0.1245 0.969 0.000 0.000 0.952 0.032 0.000 NA
#> SRR805828 3 0.0790 0.967 0.000 0.000 0.968 0.032 0.000 NA
#> SRR805829 3 0.0790 0.967 0.000 0.000 0.968 0.032 0.000 NA
#> SRR805830 3 0.0790 0.967 0.000 0.000 0.968 0.032 0.000 NA
#> SRR805831 3 0.1575 0.967 0.000 0.000 0.936 0.032 0.000 NA
#> SRR805832 3 0.2277 0.962 0.000 0.000 0.892 0.032 0.000 NA
#> SRR805833 3 0.2277 0.962 0.000 0.000 0.892 0.032 0.000 NA
#> SRR805834 3 0.2277 0.962 0.000 0.000 0.892 0.032 0.000 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "skmeans"]
# you can also extract it by
# res = res_list["MAD:skmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.999 0.999 0.4796 0.521 0.521
#> 3 3 0.817 0.954 0.968 0.3511 0.833 0.680
#> 4 4 1.000 0.969 0.978 0.1489 0.882 0.674
#> 5 5 1.000 0.986 0.992 0.0932 0.913 0.669
#> 6 6 0.965 0.925 0.941 0.0271 0.965 0.819
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 4 5
There is also optional best \(k\) = 2 4 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.0000 1.000 0.000 1.000
#> SRR805781 2 0.0000 1.000 0.000 1.000
#> SRR805782 2 0.0000 1.000 0.000 1.000
#> SRR805784 2 0.0000 1.000 0.000 1.000
#> SRR805785 2 0.0000 1.000 0.000 1.000
#> SRR805786 2 0.0000 1.000 0.000 1.000
#> SRR805787 2 0.0000 1.000 0.000 1.000
#> SRR805788 2 0.0000 1.000 0.000 1.000
#> SRR805789 2 0.0000 1.000 0.000 1.000
#> SRR805790 2 0.0000 1.000 0.000 1.000
#> SRR805791 1 0.0000 0.999 1.000 0.000
#> SRR805792 1 0.0000 0.999 1.000 0.000
#> SRR805793 1 0.0000 0.999 1.000 0.000
#> SRR805794 1 0.0000 0.999 1.000 0.000
#> SRR805795 1 0.0000 0.999 1.000 0.000
#> SRR805796 1 0.0000 0.999 1.000 0.000
#> SRR805797 1 0.0000 0.999 1.000 0.000
#> SRR805798 1 0.0000 0.999 1.000 0.000
#> SRR805799 1 0.0000 0.999 1.000 0.000
#> SRR805800 1 0.0000 0.999 1.000 0.000
#> SRR805801 1 0.0000 0.999 1.000 0.000
#> SRR805802 2 0.0000 1.000 0.000 1.000
#> SRR805803 2 0.0000 1.000 0.000 1.000
#> SRR805804 2 0.0000 1.000 0.000 1.000
#> SRR805805 2 0.0000 1.000 0.000 1.000
#> SRR805806 2 0.0000 1.000 0.000 1.000
#> SRR805807 1 0.0000 0.999 1.000 0.000
#> SRR805808 2 0.0000 1.000 0.000 1.000
#> SRR805809 2 0.0000 1.000 0.000 1.000
#> SRR805810 2 0.0000 1.000 0.000 1.000
#> SRR805811 2 0.0000 1.000 0.000 1.000
#> SRR805812 2 0.0000 1.000 0.000 1.000
#> SRR805813 1 0.0000 0.999 1.000 0.000
#> SRR805814 1 0.0000 0.999 1.000 0.000
#> SRR805815 1 0.0000 0.999 1.000 0.000
#> SRR805816 1 0.0000 0.999 1.000 0.000
#> SRR805817 1 0.0000 0.999 1.000 0.000
#> SRR805818 1 0.0000 0.999 1.000 0.000
#> SRR805819 1 0.0000 0.999 1.000 0.000
#> SRR805820 1 0.0000 0.999 1.000 0.000
#> SRR805821 1 0.0000 0.999 1.000 0.000
#> SRR805822 1 0.0000 0.999 1.000 0.000
#> SRR805823 1 0.0000 0.999 1.000 0.000
#> SRR805824 1 0.0000 0.999 1.000 0.000
#> SRR805825 1 0.0376 0.997 0.996 0.004
#> SRR805826 1 0.0376 0.997 0.996 0.004
#> SRR805828 1 0.0376 0.997 0.996 0.004
#> SRR805829 1 0.0376 0.997 0.996 0.004
#> SRR805830 1 0.0376 0.997 0.996 0.004
#> SRR805831 1 0.0376 0.997 0.996 0.004
#> SRR805832 1 0.0376 0.997 0.996 0.004
#> SRR805833 1 0.0376 0.997 0.996 0.004
#> SRR805834 1 0.0376 0.997 0.996 0.004
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805781 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805782 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805784 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805785 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805786 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805787 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805788 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805789 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805790 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805791 1 0.0237 0.934 0.996 0.000 0.004
#> SRR805792 1 0.0237 0.934 0.996 0.000 0.004
#> SRR805793 1 0.0237 0.934 0.996 0.000 0.004
#> SRR805794 1 0.0237 0.934 0.996 0.000 0.004
#> SRR805795 1 0.0237 0.934 0.996 0.000 0.004
#> SRR805796 1 0.0237 0.934 0.996 0.000 0.004
#> SRR805797 1 0.0237 0.934 0.996 0.000 0.004
#> SRR805798 1 0.0237 0.934 0.996 0.000 0.004
#> SRR805799 1 0.0237 0.934 0.996 0.000 0.004
#> SRR805800 1 0.0237 0.934 0.996 0.000 0.004
#> SRR805801 1 0.0237 0.934 0.996 0.000 0.004
#> SRR805802 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805803 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805804 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805805 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805806 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805807 1 0.0000 0.933 1.000 0.000 0.000
#> SRR805808 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805809 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805810 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805811 2 0.5733 0.541 0.324 0.676 0.000
#> SRR805812 2 0.0000 0.981 0.000 1.000 0.000
#> SRR805813 1 0.3340 0.924 0.880 0.000 0.120
#> SRR805814 1 0.3340 0.924 0.880 0.000 0.120
#> SRR805815 1 0.3340 0.924 0.880 0.000 0.120
#> SRR805816 1 0.3340 0.924 0.880 0.000 0.120
#> SRR805817 1 0.3340 0.924 0.880 0.000 0.120
#> SRR805818 1 0.3340 0.924 0.880 0.000 0.120
#> SRR805819 1 0.3340 0.924 0.880 0.000 0.120
#> SRR805820 1 0.3340 0.924 0.880 0.000 0.120
#> SRR805821 1 0.3340 0.924 0.880 0.000 0.120
#> SRR805822 1 0.3340 0.924 0.880 0.000 0.120
#> SRR805823 1 0.3340 0.924 0.880 0.000 0.120
#> SRR805824 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR805781 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR805782 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR805784 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR805785 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR805786 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR805787 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR805788 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR805789 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR805790 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR805791 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805792 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805793 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805794 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805795 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805796 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805797 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805798 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805799 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805800 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805801 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR805802 2 0.1211 0.979 0.000 0.960 0.000 0.040
#> SRR805803 2 0.0592 0.984 0.000 0.984 0.000 0.016
#> SRR805804 2 0.0592 0.984 0.000 0.984 0.000 0.016
#> SRR805805 2 0.1211 0.979 0.000 0.960 0.000 0.040
#> SRR805806 2 0.1211 0.979 0.000 0.960 0.000 0.040
#> SRR805807 4 0.0000 0.919 0.000 0.000 0.000 1.000
#> SRR805808 2 0.1211 0.979 0.000 0.960 0.000 0.040
#> SRR805809 2 0.1211 0.979 0.000 0.960 0.000 0.040
#> SRR805810 2 0.1211 0.979 0.000 0.960 0.000 0.040
#> SRR805811 4 0.4830 0.276 0.000 0.392 0.000 0.608
#> SRR805812 2 0.1211 0.979 0.000 0.960 0.000 0.040
#> SRR805813 4 0.1406 0.954 0.024 0.000 0.016 0.960
#> SRR805814 4 0.1406 0.954 0.024 0.000 0.016 0.960
#> SRR805815 4 0.1406 0.954 0.024 0.000 0.016 0.960
#> SRR805816 4 0.1406 0.954 0.024 0.000 0.016 0.960
#> SRR805817 4 0.1406 0.954 0.024 0.000 0.016 0.960
#> SRR805818 4 0.1406 0.954 0.024 0.000 0.016 0.960
#> SRR805819 4 0.1406 0.954 0.024 0.000 0.016 0.960
#> SRR805820 4 0.1406 0.954 0.024 0.000 0.016 0.960
#> SRR805821 4 0.1406 0.954 0.024 0.000 0.016 0.960
#> SRR805822 4 0.1406 0.954 0.024 0.000 0.016 0.960
#> SRR805823 4 0.1406 0.954 0.024 0.000 0.016 0.960
#> SRR805824 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805834 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
#> SRR805780 2 0.0000 0.966 0 1.000 0.000 0.000 0.000
#> SRR805781 2 0.0000 0.966 0 1.000 0.000 0.000 0.000
#> SRR805782 2 0.0000 0.966 0 1.000 0.000 0.000 0.000
#> SRR805784 2 0.0000 0.966 0 1.000 0.000 0.000 0.000
#> SRR805785 2 0.0000 0.966 0 1.000 0.000 0.000 0.000
#> SRR805786 2 0.0000 0.966 0 1.000 0.000 0.000 0.000
#> SRR805787 2 0.0000 0.966 0 1.000 0.000 0.000 0.000
#> SRR805788 2 0.0000 0.966 0 1.000 0.000 0.000 0.000
#> SRR805789 2 0.0000 0.966 0 1.000 0.000 0.000 0.000
#> SRR805790 2 0.0000 0.966 0 1.000 0.000 0.000 0.000
#> SRR805791 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> SRR805792 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> SRR805793 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> SRR805794 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> SRR805795 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> SRR805796 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> SRR805797 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> SRR805798 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> SRR805799 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> SRR805800 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> SRR805801 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> SRR805802 5 0.0162 0.999 0 0.004 0.000 0.000 0.996
#> SRR805803 2 0.2732 0.821 0 0.840 0.000 0.000 0.160
#> SRR805804 2 0.3109 0.771 0 0.800 0.000 0.000 0.200
#> SRR805805 5 0.0162 0.999 0 0.004 0.000 0.000 0.996
#> SRR805806 5 0.0162 0.999 0 0.004 0.000 0.000 0.996
#> SRR805807 5 0.0162 0.995 0 0.000 0.000 0.004 0.996
#> SRR805808 5 0.0162 0.999 0 0.004 0.000 0.000 0.996
#> SRR805809 5 0.0162 0.999 0 0.004 0.000 0.000 0.996
#> SRR805810 5 0.0162 0.999 0 0.004 0.000 0.000 0.996
#> SRR805811 5 0.0162 0.999 0 0.004 0.000 0.000 0.996
#> SRR805812 5 0.0162 0.999 0 0.004 0.000 0.000 0.996
#> SRR805813 4 0.0000 1.000 0 0.000 0.000 1.000 0.000
#> SRR805814 4 0.0000 1.000 0 0.000 0.000 1.000 0.000
#> SRR805815 4 0.0000 1.000 0 0.000 0.000 1.000 0.000
#> SRR805816 4 0.0000 1.000 0 0.000 0.000 1.000 0.000
#> SRR805817 4 0.0000 1.000 0 0.000 0.000 1.000 0.000
#> SRR805818 4 0.0000 1.000 0 0.000 0.000 1.000 0.000
#> SRR805819 4 0.0000 1.000 0 0.000 0.000 1.000 0.000
#> SRR805820 4 0.0000 1.000 0 0.000 0.000 1.000 0.000
#> SRR805821 4 0.0000 1.000 0 0.000 0.000 1.000 0.000
#> SRR805822 4 0.0000 1.000 0 0.000 0.000 1.000 0.000
#> SRR805823 4 0.0000 1.000 0 0.000 0.000 1.000 0.000
#> SRR805824 3 0.0162 0.997 0 0.000 0.996 0.000 0.004
#> SRR805825 3 0.0000 0.999 0 0.000 1.000 0.000 0.000
#> SRR805826 3 0.0000 0.999 0 0.000 1.000 0.000 0.000
#> SRR805828 3 0.0162 0.997 0 0.000 0.996 0.000 0.004
#> SRR805829 3 0.0000 0.999 0 0.000 1.000 0.000 0.000
#> SRR805830 3 0.0000 0.999 0 0.000 1.000 0.000 0.000
#> SRR805831 3 0.0000 0.999 0 0.000 1.000 0.000 0.000
#> SRR805832 3 0.0000 0.999 0 0.000 1.000 0.000 0.000
#> SRR805833 3 0.0000 0.999 0 0.000 1.000 0.000 0.000
#> SRR805834 3 0.0000 0.999 0 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
#> SRR805780 2 0.0000 1.000 0.000 1.000 0 0 0.000 0.000
#> SRR805781 2 0.0000 1.000 0.000 1.000 0 0 0.000 0.000
#> SRR805782 2 0.0000 1.000 0.000 1.000 0 0 0.000 0.000
#> SRR805784 2 0.0000 1.000 0.000 1.000 0 0 0.000 0.000
#> SRR805785 2 0.0000 1.000 0.000 1.000 0 0 0.000 0.000
#> SRR805786 2 0.0000 1.000 0.000 1.000 0 0 0.000 0.000
#> SRR805787 2 0.0000 1.000 0.000 1.000 0 0 0.000 0.000
#> SRR805788 2 0.0000 1.000 0.000 1.000 0 0 0.000 0.000
#> SRR805789 2 0.0000 1.000 0.000 1.000 0 0 0.000 0.000
#> SRR805790 2 0.0000 1.000 0.000 1.000 0 0 0.000 0.000
#> SRR805791 1 0.0000 0.835 1.000 0.000 0 0 0.000 0.000
#> SRR805792 1 0.0000 0.835 1.000 0.000 0 0 0.000 0.000
#> SRR805793 1 0.0000 0.835 1.000 0.000 0 0 0.000 0.000
#> SRR805794 1 0.0000 0.835 1.000 0.000 0 0 0.000 0.000
#> SRR805795 1 0.3151 0.903 0.748 0.000 0 0 0.252 0.000
#> SRR805796 1 0.3151 0.903 0.748 0.000 0 0 0.252 0.000
#> SRR805797 1 0.3151 0.903 0.748 0.000 0 0 0.252 0.000
#> SRR805798 1 0.3151 0.903 0.748 0.000 0 0 0.252 0.000
#> SRR805799 1 0.3563 0.852 0.664 0.000 0 0 0.336 0.000
#> SRR805800 1 0.3151 0.903 0.748 0.000 0 0 0.252 0.000
#> SRR805801 1 0.3151 0.903 0.748 0.000 0 0 0.252 0.000
#> SRR805802 6 0.0146 0.721 0.000 0.000 0 0 0.004 0.996
#> SRR805803 6 0.3175 0.619 0.000 0.256 0 0 0.000 0.744
#> SRR805804 6 0.3101 0.630 0.000 0.244 0 0 0.000 0.756
#> SRR805805 6 0.0000 0.724 0.000 0.000 0 0 0.000 1.000
#> SRR805806 5 0.3578 0.922 0.000 0.000 0 0 0.660 0.340
#> SRR805807 5 0.3198 0.926 0.000 0.000 0 0 0.740 0.260
#> SRR805808 6 0.2854 0.355 0.000 0.000 0 0 0.208 0.792
#> SRR805809 6 0.0000 0.724 0.000 0.000 0 0 0.000 1.000
#> SRR805810 5 0.3330 0.945 0.000 0.000 0 0 0.716 0.284
#> SRR805811 5 0.3330 0.945 0.000 0.000 0 0 0.716 0.284
#> SRR805812 5 0.3634 0.905 0.000 0.000 0 0 0.644 0.356
#> SRR805813 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805814 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805815 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805816 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805817 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805818 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805819 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805820 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805821 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805822 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805823 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "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 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.926 0.931 0.968 0.4323 0.586 0.586
#> 3 3 0.649 0.649 0.824 0.5342 0.702 0.511
#> 4 4 1.000 0.959 0.985 0.1379 0.808 0.502
#> 5 5 1.000 0.996 0.998 0.0801 0.903 0.633
#> 6 6 0.977 0.960 0.945 0.0219 0.980 0.890
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 4 5
There is also optional best \(k\) = 2 4 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.0000 0.989 0.000 1.000
#> SRR805781 2 0.0000 0.989 0.000 1.000
#> SRR805782 2 0.0000 0.989 0.000 1.000
#> SRR805784 2 0.0000 0.989 0.000 1.000
#> SRR805785 2 0.0000 0.989 0.000 1.000
#> SRR805786 2 0.0000 0.989 0.000 1.000
#> SRR805787 2 0.0000 0.989 0.000 1.000
#> SRR805788 2 0.0000 0.989 0.000 1.000
#> SRR805789 2 0.0000 0.989 0.000 1.000
#> SRR805790 2 0.0000 0.989 0.000 1.000
#> SRR805791 1 0.0938 0.952 0.988 0.012
#> SRR805792 1 0.2043 0.941 0.968 0.032
#> SRR805793 1 0.3584 0.915 0.932 0.068
#> SRR805794 1 0.2603 0.934 0.956 0.044
#> SRR805795 1 0.0000 0.958 1.000 0.000
#> SRR805796 1 0.0000 0.958 1.000 0.000
#> SRR805797 1 0.0000 0.958 1.000 0.000
#> SRR805798 1 0.0000 0.958 1.000 0.000
#> SRR805799 1 0.0000 0.958 1.000 0.000
#> SRR805800 1 0.0000 0.958 1.000 0.000
#> SRR805801 1 0.0000 0.958 1.000 0.000
#> SRR805802 2 0.5842 0.823 0.140 0.860
#> SRR805803 2 0.0000 0.989 0.000 1.000
#> SRR805804 2 0.0000 0.989 0.000 1.000
#> SRR805805 2 0.0000 0.989 0.000 1.000
#> SRR805806 1 0.3733 0.912 0.928 0.072
#> SRR805807 1 0.0000 0.958 1.000 0.000
#> SRR805808 1 0.9922 0.253 0.552 0.448
#> SRR805809 2 0.0000 0.989 0.000 1.000
#> SRR805810 1 0.0938 0.952 0.988 0.012
#> SRR805811 1 0.0000 0.958 1.000 0.000
#> SRR805812 1 0.9087 0.557 0.676 0.324
#> SRR805813 1 0.0000 0.958 1.000 0.000
#> SRR805814 1 0.0000 0.958 1.000 0.000
#> SRR805815 1 0.0000 0.958 1.000 0.000
#> SRR805816 1 0.0000 0.958 1.000 0.000
#> SRR805817 1 0.0000 0.958 1.000 0.000
#> SRR805818 1 0.0000 0.958 1.000 0.000
#> SRR805819 1 0.0000 0.958 1.000 0.000
#> SRR805820 1 0.0000 0.958 1.000 0.000
#> SRR805821 1 0.0000 0.958 1.000 0.000
#> SRR805822 1 0.0000 0.958 1.000 0.000
#> SRR805823 1 0.0000 0.958 1.000 0.000
#> SRR805824 1 0.0000 0.958 1.000 0.000
#> SRR805825 1 0.8861 0.600 0.696 0.304
#> SRR805826 1 0.2948 0.928 0.948 0.052
#> SRR805828 1 0.0000 0.958 1.000 0.000
#> SRR805829 1 0.0000 0.958 1.000 0.000
#> SRR805830 1 0.0000 0.958 1.000 0.000
#> SRR805831 1 0.0000 0.958 1.000 0.000
#> SRR805832 1 0.5408 0.863 0.876 0.124
#> SRR805833 1 0.2778 0.930 0.952 0.048
#> SRR805834 1 0.0000 0.958 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.0000 0.897 0.000 1.000 0.000
#> SRR805781 2 0.0000 0.897 0.000 1.000 0.000
#> SRR805782 2 0.0000 0.897 0.000 1.000 0.000
#> SRR805784 2 0.0000 0.897 0.000 1.000 0.000
#> SRR805785 2 0.0000 0.897 0.000 1.000 0.000
#> SRR805786 2 0.0000 0.897 0.000 1.000 0.000
#> SRR805787 2 0.0000 0.897 0.000 1.000 0.000
#> SRR805788 2 0.0000 0.897 0.000 1.000 0.000
#> SRR805789 2 0.0000 0.897 0.000 1.000 0.000
#> SRR805790 2 0.0000 0.897 0.000 1.000 0.000
#> SRR805791 3 0.4796 0.506 0.220 0.000 0.780
#> SRR805792 3 0.4605 0.533 0.204 0.000 0.796
#> SRR805793 3 0.4605 0.533 0.204 0.000 0.796
#> SRR805794 3 0.4883 0.524 0.208 0.004 0.788
#> SRR805795 1 0.6008 0.570 0.628 0.000 0.372
#> SRR805796 1 0.6008 0.570 0.628 0.000 0.372
#> SRR805797 1 0.6008 0.570 0.628 0.000 0.372
#> SRR805798 1 0.6008 0.570 0.628 0.000 0.372
#> SRR805799 1 0.6008 0.570 0.628 0.000 0.372
#> SRR805800 1 0.6008 0.570 0.628 0.000 0.372
#> SRR805801 1 0.6008 0.570 0.628 0.000 0.372
#> SRR805802 2 0.6008 0.416 0.000 0.628 0.372
#> SRR805803 2 0.0000 0.897 0.000 1.000 0.000
#> SRR805804 2 0.0000 0.897 0.000 1.000 0.000
#> SRR805805 2 0.0747 0.885 0.000 0.984 0.016
#> SRR805806 1 0.9810 0.192 0.388 0.240 0.372
#> SRR805807 1 0.0000 0.677 1.000 0.000 0.000
#> SRR805808 2 0.8688 0.218 0.112 0.516 0.372
#> SRR805809 2 0.0000 0.897 0.000 1.000 0.000
#> SRR805810 1 0.6008 0.570 0.628 0.000 0.372
#> SRR805811 1 0.5968 0.573 0.636 0.000 0.364
#> SRR805812 2 0.9252 0.115 0.160 0.468 0.372
#> SRR805813 1 0.0000 0.677 1.000 0.000 0.000
#> SRR805814 1 0.4605 0.417 0.796 0.000 0.204
#> SRR805815 1 0.3619 0.524 0.864 0.000 0.136
#> SRR805816 1 0.2796 0.586 0.908 0.000 0.092
#> SRR805817 1 0.0000 0.677 1.000 0.000 0.000
#> SRR805818 1 0.0000 0.677 1.000 0.000 0.000
#> SRR805819 1 0.0237 0.674 0.996 0.000 0.004
#> SRR805820 1 0.0000 0.677 1.000 0.000 0.000
#> SRR805821 1 0.0000 0.677 1.000 0.000 0.000
#> SRR805822 1 0.0000 0.677 1.000 0.000 0.000
#> SRR805823 1 0.0000 0.677 1.000 0.000 0.000
#> SRR805824 3 0.6008 0.487 0.372 0.000 0.628
#> SRR805825 3 0.0000 0.694 0.000 0.000 1.000
#> SRR805826 3 0.0000 0.694 0.000 0.000 1.000
#> SRR805828 3 0.5988 0.492 0.368 0.000 0.632
#> SRR805829 3 0.4555 0.610 0.200 0.000 0.800
#> SRR805830 3 0.0000 0.694 0.000 0.000 1.000
#> SRR805831 3 0.5905 0.506 0.352 0.000 0.648
#> SRR805832 3 0.0000 0.694 0.000 0.000 1.000
#> SRR805833 3 0.0000 0.694 0.000 0.000 1.000
#> SRR805834 3 0.6008 0.487 0.372 0.000 0.628
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.000 1.0000 0.000 1.000 0 0.000
#> SRR805781 2 0.000 1.0000 0.000 1.000 0 0.000
#> SRR805782 2 0.000 1.0000 0.000 1.000 0 0.000
#> SRR805784 2 0.000 1.0000 0.000 1.000 0 0.000
#> SRR805785 2 0.000 1.0000 0.000 1.000 0 0.000
#> SRR805786 2 0.000 1.0000 0.000 1.000 0 0.000
#> SRR805787 2 0.000 1.0000 0.000 1.000 0 0.000
#> SRR805788 2 0.000 1.0000 0.000 1.000 0 0.000
#> SRR805789 2 0.000 1.0000 0.000 1.000 0 0.000
#> SRR805790 2 0.000 1.0000 0.000 1.000 0 0.000
#> SRR805791 1 0.000 0.9478 1.000 0.000 0 0.000
#> SRR805792 1 0.000 0.9478 1.000 0.000 0 0.000
#> SRR805793 1 0.000 0.9478 1.000 0.000 0 0.000
#> SRR805794 1 0.000 0.9478 1.000 0.000 0 0.000
#> SRR805795 1 0.000 0.9478 1.000 0.000 0 0.000
#> SRR805796 1 0.000 0.9478 1.000 0.000 0 0.000
#> SRR805797 1 0.000 0.9478 1.000 0.000 0 0.000
#> SRR805798 1 0.000 0.9478 1.000 0.000 0 0.000
#> SRR805799 1 0.000 0.9478 1.000 0.000 0 0.000
#> SRR805800 1 0.000 0.9478 1.000 0.000 0 0.000
#> SRR805801 1 0.000 0.9478 1.000 0.000 0 0.000
#> SRR805802 2 0.000 1.0000 0.000 1.000 0 0.000
#> SRR805803 2 0.000 1.0000 0.000 1.000 0 0.000
#> SRR805804 2 0.000 1.0000 0.000 1.000 0 0.000
#> SRR805805 2 0.000 1.0000 0.000 1.000 0 0.000
#> SRR805806 1 0.000 0.9478 1.000 0.000 0 0.000
#> SRR805807 1 0.500 0.0655 0.512 0.000 0 0.488
#> SRR805808 1 0.443 0.5576 0.696 0.304 0 0.000
#> SRR805809 2 0.000 1.0000 0.000 1.000 0 0.000
#> SRR805810 1 0.000 0.9478 1.000 0.000 0 0.000
#> SRR805811 1 0.000 0.9478 1.000 0.000 0 0.000
#> SRR805812 1 0.000 0.9478 1.000 0.000 0 0.000
#> SRR805813 4 0.000 1.0000 0.000 0.000 0 1.000
#> SRR805814 4 0.000 1.0000 0.000 0.000 0 1.000
#> SRR805815 4 0.000 1.0000 0.000 0.000 0 1.000
#> SRR805816 4 0.000 1.0000 0.000 0.000 0 1.000
#> SRR805817 4 0.000 1.0000 0.000 0.000 0 1.000
#> SRR805818 4 0.000 1.0000 0.000 0.000 0 1.000
#> SRR805819 4 0.000 1.0000 0.000 0.000 0 1.000
#> SRR805820 4 0.000 1.0000 0.000 0.000 0 1.000
#> SRR805821 4 0.000 1.0000 0.000 0.000 0 1.000
#> SRR805822 4 0.000 1.0000 0.000 0.000 0 1.000
#> SRR805823 4 0.000 1.0000 0.000 0.000 0 1.000
#> SRR805824 3 0.000 1.0000 0.000 0.000 1 0.000
#> SRR805825 3 0.000 1.0000 0.000 0.000 1 0.000
#> SRR805826 3 0.000 1.0000 0.000 0.000 1 0.000
#> SRR805828 3 0.000 1.0000 0.000 0.000 1 0.000
#> SRR805829 3 0.000 1.0000 0.000 0.000 1 0.000
#> SRR805830 3 0.000 1.0000 0.000 0.000 1 0.000
#> SRR805831 3 0.000 1.0000 0.000 0.000 1 0.000
#> SRR805832 3 0.000 1.0000 0.000 0.000 1 0.000
#> SRR805833 3 0.000 1.0000 0.000 0.000 1 0.000
#> SRR805834 3 0.000 1.0000 0.000 0.000 1 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.000 1.000 0 1.000 0 0 0.000
#> SRR805781 2 0.000 1.000 0 1.000 0 0 0.000
#> SRR805782 2 0.000 1.000 0 1.000 0 0 0.000
#> SRR805784 2 0.000 1.000 0 1.000 0 0 0.000
#> SRR805785 2 0.000 1.000 0 1.000 0 0 0.000
#> SRR805786 2 0.000 1.000 0 1.000 0 0 0.000
#> SRR805787 2 0.000 1.000 0 1.000 0 0 0.000
#> SRR805788 2 0.000 1.000 0 1.000 0 0 0.000
#> SRR805789 2 0.000 1.000 0 1.000 0 0 0.000
#> SRR805790 2 0.000 1.000 0 1.000 0 0 0.000
#> SRR805791 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805792 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805793 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805794 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805795 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805796 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805797 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805798 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805799 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805800 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805801 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805802 5 0.000 0.989 0 0.000 0 0 1.000
#> SRR805803 2 0.000 1.000 0 1.000 0 0 0.000
#> SRR805804 5 0.196 0.894 0 0.096 0 0 0.904
#> SRR805805 5 0.000 0.989 0 0.000 0 0 1.000
#> SRR805806 5 0.000 0.989 0 0.000 0 0 1.000
#> SRR805807 5 0.000 0.989 0 0.000 0 0 1.000
#> SRR805808 5 0.000 0.989 0 0.000 0 0 1.000
#> SRR805809 5 0.000 0.989 0 0.000 0 0 1.000
#> SRR805810 5 0.000 0.989 0 0.000 0 0 1.000
#> SRR805811 5 0.000 0.989 0 0.000 0 0 1.000
#> SRR805812 5 0.000 0.989 0 0.000 0 0 1.000
#> SRR805813 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805814 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805815 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805816 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805817 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805818 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805819 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805820 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805821 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805822 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805823 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805824 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805825 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805826 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805828 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805829 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805830 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805831 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805832 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805833 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805834 3 0.000 1.000 0 0.000 1 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.000 0.961 0.000 1.000 0 0 0.000 0.000
#> SRR805781 2 0.000 0.961 0.000 1.000 0 0 0.000 0.000
#> SRR805782 2 0.000 0.961 0.000 1.000 0 0 0.000 0.000
#> SRR805784 2 0.000 0.961 0.000 1.000 0 0 0.000 0.000
#> SRR805785 2 0.000 0.961 0.000 1.000 0 0 0.000 0.000
#> SRR805786 2 0.000 0.961 0.000 1.000 0 0 0.000 0.000
#> SRR805787 2 0.000 0.961 0.000 1.000 0 0 0.000 0.000
#> SRR805788 2 0.000 0.961 0.000 1.000 0 0 0.000 0.000
#> SRR805789 2 0.000 0.961 0.000 1.000 0 0 0.000 0.000
#> SRR805790 2 0.000 0.961 0.000 1.000 0 0 0.000 0.000
#> SRR805791 6 0.384 1.000 0.448 0.000 0 0 0.000 0.552
#> SRR805792 6 0.384 1.000 0.448 0.000 0 0 0.000 0.552
#> SRR805793 6 0.384 1.000 0.448 0.000 0 0 0.000 0.552
#> SRR805794 6 0.384 1.000 0.448 0.000 0 0 0.000 0.552
#> SRR805795 1 0.000 1.000 1.000 0.000 0 0 0.000 0.000
#> SRR805796 1 0.000 1.000 1.000 0.000 0 0 0.000 0.000
#> SRR805797 1 0.000 1.000 1.000 0.000 0 0 0.000 0.000
#> SRR805798 1 0.000 1.000 1.000 0.000 0 0 0.000 0.000
#> SRR805799 1 0.000 1.000 1.000 0.000 0 0 0.000 0.000
#> SRR805800 1 0.000 1.000 1.000 0.000 0 0 0.000 0.000
#> SRR805801 1 0.000 1.000 1.000 0.000 0 0 0.000 0.000
#> SRR805802 5 0.000 0.934 0.000 0.000 0 0 1.000 0.000
#> SRR805803 2 0.384 0.500 0.000 0.552 0 0 0.000 0.448
#> SRR805804 5 0.499 0.469 0.000 0.068 0 0 0.484 0.448
#> SRR805805 5 0.000 0.934 0.000 0.000 0 0 1.000 0.000
#> SRR805806 5 0.000 0.934 0.000 0.000 0 0 1.000 0.000
#> SRR805807 5 0.000 0.934 0.000 0.000 0 0 1.000 0.000
#> SRR805808 5 0.000 0.934 0.000 0.000 0 0 1.000 0.000
#> SRR805809 5 0.263 0.812 0.000 0.000 0 0 0.820 0.180
#> SRR805810 5 0.000 0.934 0.000 0.000 0 0 1.000 0.000
#> SRR805811 5 0.000 0.934 0.000 0.000 0 0 1.000 0.000
#> SRR805812 5 0.000 0.934 0.000 0.000 0 0 1.000 0.000
#> SRR805813 4 0.000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805814 4 0.000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805815 4 0.000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805816 4 0.000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805817 4 0.000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805818 4 0.000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805819 4 0.000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805820 4 0.000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805821 4 0.000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805822 4 0.000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805823 4 0.000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805824 3 0.000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805825 3 0.000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805826 3 0.000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805828 3 0.000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805829 3 0.000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805830 3 0.000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805831 3 0.000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805832 3 0.000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805833 3 0.000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805834 3 0.000 1.000 0.000 0.000 1 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "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 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.265 0.817 0.862 0.4895 0.512 0.512
#> 3 3 0.665 0.915 0.907 0.1606 0.585 0.390
#> 4 4 1.000 0.987 0.991 0.2968 0.832 0.612
#> 5 5 1.000 0.974 0.990 0.1058 0.920 0.699
#> 6 6 0.976 0.949 0.941 0.0204 0.980 0.890
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 4 5
There is also optional best \(k\) = 4 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.000 0.865 0.000 1.000
#> SRR805781 2 0.000 0.865 0.000 1.000
#> SRR805782 2 0.000 0.865 0.000 1.000
#> SRR805784 2 0.000 0.865 0.000 1.000
#> SRR805785 2 0.000 0.865 0.000 1.000
#> SRR805786 2 0.000 0.865 0.000 1.000
#> SRR805787 2 0.000 0.865 0.000 1.000
#> SRR805788 2 0.000 0.865 0.000 1.000
#> SRR805789 2 0.000 0.865 0.000 1.000
#> SRR805790 2 0.000 0.865 0.000 1.000
#> SRR805791 2 0.921 0.716 0.336 0.664
#> SRR805792 2 0.921 0.716 0.336 0.664
#> SRR805793 2 0.921 0.716 0.336 0.664
#> SRR805794 2 0.921 0.716 0.336 0.664
#> SRR805795 2 0.921 0.716 0.336 0.664
#> SRR805796 2 0.921 0.716 0.336 0.664
#> SRR805797 2 0.921 0.716 0.336 0.664
#> SRR805798 2 0.921 0.716 0.336 0.664
#> SRR805799 2 0.921 0.716 0.336 0.664
#> SRR805800 2 0.921 0.716 0.336 0.664
#> SRR805801 2 0.921 0.716 0.336 0.664
#> SRR805802 2 0.000 0.865 0.000 1.000
#> SRR805803 2 0.000 0.865 0.000 1.000
#> SRR805804 2 0.000 0.865 0.000 1.000
#> SRR805805 2 0.000 0.865 0.000 1.000
#> SRR805806 2 0.000 0.865 0.000 1.000
#> SRR805807 2 0.000 0.865 0.000 1.000
#> SRR805808 2 0.000 0.865 0.000 1.000
#> SRR805809 2 0.000 0.865 0.000 1.000
#> SRR805810 2 0.000 0.865 0.000 1.000
#> SRR805811 2 0.000 0.865 0.000 1.000
#> SRR805812 2 0.000 0.865 0.000 1.000
#> SRR805813 1 0.482 0.835 0.896 0.104
#> SRR805814 1 0.482 0.835 0.896 0.104
#> SRR805815 1 0.482 0.835 0.896 0.104
#> SRR805816 1 0.482 0.835 0.896 0.104
#> SRR805817 1 0.482 0.835 0.896 0.104
#> SRR805818 1 0.482 0.835 0.896 0.104
#> SRR805819 1 0.482 0.835 0.896 0.104
#> SRR805820 1 0.482 0.835 0.896 0.104
#> SRR805821 1 0.482 0.835 0.896 0.104
#> SRR805822 1 0.482 0.835 0.896 0.104
#> SRR805823 1 0.482 0.835 0.896 0.104
#> SRR805824 1 0.788 0.807 0.764 0.236
#> SRR805825 1 0.788 0.807 0.764 0.236
#> SRR805826 1 0.788 0.807 0.764 0.236
#> SRR805828 1 0.788 0.807 0.764 0.236
#> SRR805829 1 0.788 0.807 0.764 0.236
#> SRR805830 1 0.788 0.807 0.764 0.236
#> SRR805831 1 0.788 0.807 0.764 0.236
#> SRR805832 1 0.788 0.807 0.764 0.236
#> SRR805833 1 0.788 0.807 0.764 0.236
#> SRR805834 1 0.788 0.807 0.764 0.236
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.0000 0.890 0.000 1.000 0
#> SRR805781 2 0.0000 0.890 0.000 1.000 0
#> SRR805782 2 0.0000 0.890 0.000 1.000 0
#> SRR805784 2 0.0000 0.890 0.000 1.000 0
#> SRR805785 2 0.0000 0.890 0.000 1.000 0
#> SRR805786 2 0.0000 0.890 0.000 1.000 0
#> SRR805787 2 0.0000 0.890 0.000 1.000 0
#> SRR805788 2 0.0000 0.890 0.000 1.000 0
#> SRR805789 2 0.0000 0.890 0.000 1.000 0
#> SRR805790 2 0.0000 0.890 0.000 1.000 0
#> SRR805791 1 0.4974 1.000 0.764 0.236 0
#> SRR805792 1 0.4974 1.000 0.764 0.236 0
#> SRR805793 1 0.4974 1.000 0.764 0.236 0
#> SRR805794 1 0.4974 1.000 0.764 0.236 0
#> SRR805795 1 0.4974 1.000 0.764 0.236 0
#> SRR805796 1 0.4974 1.000 0.764 0.236 0
#> SRR805797 1 0.4974 1.000 0.764 0.236 0
#> SRR805798 1 0.4974 1.000 0.764 0.236 0
#> SRR805799 1 0.4974 1.000 0.764 0.236 0
#> SRR805800 1 0.4974 1.000 0.764 0.236 0
#> SRR805801 1 0.4974 1.000 0.764 0.236 0
#> SRR805802 2 0.0000 0.890 0.000 1.000 0
#> SRR805803 2 0.0000 0.890 0.000 1.000 0
#> SRR805804 2 0.0000 0.890 0.000 1.000 0
#> SRR805805 2 0.0000 0.890 0.000 1.000 0
#> SRR805806 2 0.0000 0.890 0.000 1.000 0
#> SRR805807 2 0.0592 0.886 0.012 0.988 0
#> SRR805808 2 0.0000 0.890 0.000 1.000 0
#> SRR805809 2 0.0000 0.890 0.000 1.000 0
#> SRR805810 2 0.0000 0.890 0.000 1.000 0
#> SRR805811 2 0.0000 0.890 0.000 1.000 0
#> SRR805812 2 0.0000 0.890 0.000 1.000 0
#> SRR805813 2 0.4974 0.802 0.236 0.764 0
#> SRR805814 2 0.4974 0.802 0.236 0.764 0
#> SRR805815 2 0.4974 0.802 0.236 0.764 0
#> SRR805816 2 0.4974 0.802 0.236 0.764 0
#> SRR805817 2 0.4974 0.802 0.236 0.764 0
#> SRR805818 2 0.4974 0.802 0.236 0.764 0
#> SRR805819 2 0.4974 0.802 0.236 0.764 0
#> SRR805820 2 0.4974 0.802 0.236 0.764 0
#> SRR805821 2 0.4974 0.802 0.236 0.764 0
#> SRR805822 2 0.4974 0.802 0.236 0.764 0
#> SRR805823 2 0.4974 0.802 0.236 0.764 0
#> SRR805824 3 0.0000 1.000 0.000 0.000 1
#> SRR805825 3 0.0000 1.000 0.000 0.000 1
#> SRR805826 3 0.0000 1.000 0.000 0.000 1
#> SRR805828 3 0.0000 1.000 0.000 0.000 1
#> SRR805829 3 0.0000 1.000 0.000 0.000 1
#> SRR805830 3 0.0000 1.000 0.000 0.000 1
#> SRR805831 3 0.0000 1.000 0.000 0.000 1
#> SRR805832 3 0.0000 1.000 0.000 0.000 1
#> SRR805833 3 0.0000 1.000 0.000 0.000 1
#> SRR805834 3 0.0000 1.000 0.000 0.000 1
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.0000 0.977 0 1.000 0 0.000
#> SRR805781 2 0.0000 0.977 0 1.000 0 0.000
#> SRR805782 2 0.0000 0.977 0 1.000 0 0.000
#> SRR805784 2 0.0000 0.977 0 1.000 0 0.000
#> SRR805785 2 0.0000 0.977 0 1.000 0 0.000
#> SRR805786 2 0.0000 0.977 0 1.000 0 0.000
#> SRR805787 2 0.0000 0.977 0 1.000 0 0.000
#> SRR805788 2 0.0000 0.977 0 1.000 0 0.000
#> SRR805789 2 0.0000 0.977 0 1.000 0 0.000
#> SRR805790 2 0.0000 0.977 0 1.000 0 0.000
#> SRR805791 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805792 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805793 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805794 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805795 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805796 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805797 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805798 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805799 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805800 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805801 1 0.0000 1.000 1 0.000 0 0.000
#> SRR805802 2 0.0921 0.971 0 0.972 0 0.028
#> SRR805803 2 0.0000 0.977 0 1.000 0 0.000
#> SRR805804 2 0.0000 0.977 0 1.000 0 0.000
#> SRR805805 2 0.0921 0.971 0 0.972 0 0.028
#> SRR805806 2 0.1022 0.969 0 0.968 0 0.032
#> SRR805807 2 0.2469 0.906 0 0.892 0 0.108
#> SRR805808 2 0.0921 0.971 0 0.972 0 0.028
#> SRR805809 2 0.0921 0.971 0 0.972 0 0.028
#> SRR805810 2 0.2011 0.933 0 0.920 0 0.080
#> SRR805811 2 0.2469 0.906 0 0.892 0 0.108
#> SRR805812 2 0.0921 0.971 0 0.972 0 0.028
#> SRR805813 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805814 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805815 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805816 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805817 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805818 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805819 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805820 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805821 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805822 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805823 4 0.0000 1.000 0 0.000 0 1.000
#> SRR805824 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805825 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805826 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805828 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805829 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805830 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805831 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805832 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805833 3 0.0000 1.000 0 0.000 1 0.000
#> SRR805834 3 0.0000 1.000 0 0.000 1 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.000 0.979 0 1.000 0 0 0.000
#> SRR805781 2 0.000 0.979 0 1.000 0 0 0.000
#> SRR805782 2 0.000 0.979 0 1.000 0 0 0.000
#> SRR805784 2 0.000 0.979 0 1.000 0 0 0.000
#> SRR805785 2 0.000 0.979 0 1.000 0 0 0.000
#> SRR805786 2 0.000 0.979 0 1.000 0 0 0.000
#> SRR805787 2 0.000 0.979 0 1.000 0 0 0.000
#> SRR805788 2 0.000 0.979 0 1.000 0 0 0.000
#> SRR805789 2 0.000 0.979 0 1.000 0 0 0.000
#> SRR805790 2 0.000 0.979 0 1.000 0 0 0.000
#> SRR805791 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805792 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805793 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805794 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805795 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805796 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805797 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805798 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805799 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805800 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805801 1 0.000 1.000 1 0.000 0 0 0.000
#> SRR805802 5 0.000 0.960 0 0.000 0 0 1.000
#> SRR805803 2 0.307 0.740 0 0.804 0 0 0.196
#> SRR805804 5 0.400 0.451 0 0.344 0 0 0.656
#> SRR805805 5 0.000 0.960 0 0.000 0 0 1.000
#> SRR805806 5 0.000 0.960 0 0.000 0 0 1.000
#> SRR805807 5 0.000 0.960 0 0.000 0 0 1.000
#> SRR805808 5 0.000 0.960 0 0.000 0 0 1.000
#> SRR805809 5 0.000 0.960 0 0.000 0 0 1.000
#> SRR805810 5 0.000 0.960 0 0.000 0 0 1.000
#> SRR805811 5 0.000 0.960 0 0.000 0 0 1.000
#> SRR805812 5 0.000 0.960 0 0.000 0 0 1.000
#> SRR805813 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805814 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805815 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805816 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805817 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805818 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805819 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805820 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805821 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805822 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805823 4 0.000 1.000 0 0.000 0 1 0.000
#> SRR805824 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805825 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805826 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805828 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805829 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805830 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805831 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805832 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805833 3 0.000 1.000 0 0.000 1 0 0.000
#> SRR805834 3 0.000 1.000 0 0.000 1 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR805781 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR805782 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR805784 2 0.0146 0.971 0.000 0.996 0 0.000 0.000 0.004
#> SRR805785 2 0.0146 0.971 0.000 0.996 0 0.000 0.000 0.004
#> SRR805786 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR805787 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR805788 2 0.0000 0.972 0.000 1.000 0 0.000 0.000 0.000
#> SRR805789 2 0.0146 0.971 0.000 0.996 0 0.000 0.000 0.004
#> SRR805790 2 0.0146 0.971 0.000 0.996 0 0.000 0.000 0.004
#> SRR805791 6 0.3843 1.000 0.452 0.000 0 0.000 0.000 0.548
#> SRR805792 6 0.3843 1.000 0.452 0.000 0 0.000 0.000 0.548
#> SRR805793 6 0.3843 1.000 0.452 0.000 0 0.000 0.000 0.548
#> SRR805794 6 0.3843 1.000 0.452 0.000 0 0.000 0.000 0.548
#> SRR805795 1 0.0000 0.968 1.000 0.000 0 0.000 0.000 0.000
#> SRR805796 1 0.0000 0.968 1.000 0.000 0 0.000 0.000 0.000
#> SRR805797 1 0.0547 0.960 0.980 0.000 0 0.000 0.000 0.020
#> SRR805798 1 0.0547 0.960 0.980 0.000 0 0.000 0.000 0.020
#> SRR805799 1 0.1444 0.888 0.928 0.000 0 0.000 0.000 0.072
#> SRR805800 1 0.0000 0.968 1.000 0.000 0 0.000 0.000 0.000
#> SRR805801 1 0.0000 0.968 1.000 0.000 0 0.000 0.000 0.000
#> SRR805802 5 0.0000 0.909 0.000 0.000 0 0.000 1.000 0.000
#> SRR805803 2 0.4281 0.684 0.000 0.704 0 0.000 0.068 0.228
#> SRR805804 5 0.5955 0.195 0.000 0.332 0 0.000 0.436 0.232
#> SRR805805 5 0.1387 0.886 0.000 0.000 0 0.000 0.932 0.068
#> SRR805806 5 0.0000 0.909 0.000 0.000 0 0.000 1.000 0.000
#> SRR805807 5 0.1814 0.869 0.000 0.000 0 0.000 0.900 0.100
#> SRR805808 5 0.0000 0.909 0.000 0.000 0 0.000 1.000 0.000
#> SRR805809 5 0.1610 0.878 0.000 0.000 0 0.000 0.916 0.084
#> SRR805810 5 0.0000 0.909 0.000 0.000 0 0.000 1.000 0.000
#> SRR805811 5 0.1387 0.884 0.000 0.000 0 0.000 0.932 0.068
#> SRR805812 5 0.0000 0.909 0.000 0.000 0 0.000 1.000 0.000
#> SRR805813 4 0.0000 0.997 0.000 0.000 0 1.000 0.000 0.000
#> SRR805814 4 0.0547 0.985 0.000 0.000 0 0.980 0.000 0.020
#> SRR805815 4 0.0000 0.997 0.000 0.000 0 1.000 0.000 0.000
#> SRR805816 4 0.0363 0.990 0.000 0.000 0 0.988 0.000 0.012
#> SRR805817 4 0.0000 0.997 0.000 0.000 0 1.000 0.000 0.000
#> SRR805818 4 0.0000 0.997 0.000 0.000 0 1.000 0.000 0.000
#> SRR805819 4 0.0000 0.997 0.000 0.000 0 1.000 0.000 0.000
#> SRR805820 4 0.0000 0.997 0.000 0.000 0 1.000 0.000 0.000
#> SRR805821 4 0.0000 0.997 0.000 0.000 0 1.000 0.000 0.000
#> SRR805822 4 0.0000 0.997 0.000 0.000 0 1.000 0.000 0.000
#> SRR805823 4 0.0000 0.997 0.000 0.000 0 1.000 0.000 0.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1 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", "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 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.651 0.843 0.932 0.4799 0.512 0.512
#> 3 3 0.937 0.909 0.961 0.3320 0.762 0.574
#> 4 4 0.955 0.892 0.939 0.1734 0.856 0.621
#> 5 5 0.973 0.938 0.960 0.0844 0.903 0.636
#> 6 6 0.988 0.945 0.971 0.0247 0.979 0.887
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 3 4 5
There is also optional best \(k\) = 3 4 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.0000 0.9231 0.000 1.000
#> SRR805781 2 0.0000 0.9231 0.000 1.000
#> SRR805782 2 0.0000 0.9231 0.000 1.000
#> SRR805784 2 0.0000 0.9231 0.000 1.000
#> SRR805785 2 0.0000 0.9231 0.000 1.000
#> SRR805786 2 0.0000 0.9231 0.000 1.000
#> SRR805787 2 0.0000 0.9231 0.000 1.000
#> SRR805788 2 0.0000 0.9231 0.000 1.000
#> SRR805789 2 0.0000 0.9231 0.000 1.000
#> SRR805790 2 0.0000 0.9231 0.000 1.000
#> SRR805791 1 0.2603 0.8982 0.956 0.044
#> SRR805792 1 0.2778 0.8973 0.952 0.048
#> SRR805793 1 0.9944 0.2129 0.544 0.456
#> SRR805794 1 0.6148 0.8262 0.848 0.152
#> SRR805795 1 0.0000 0.9176 1.000 0.000
#> SRR805796 1 0.0000 0.9176 1.000 0.000
#> SRR805797 1 0.0000 0.9176 1.000 0.000
#> SRR805798 1 0.0000 0.9176 1.000 0.000
#> SRR805799 1 0.0000 0.9176 1.000 0.000
#> SRR805800 1 0.0000 0.9176 1.000 0.000
#> SRR805801 1 0.0000 0.9176 1.000 0.000
#> SRR805802 2 0.0000 0.9231 0.000 1.000
#> SRR805803 2 0.0000 0.9231 0.000 1.000
#> SRR805804 2 0.0000 0.9231 0.000 1.000
#> SRR805805 2 0.0000 0.9231 0.000 1.000
#> SRR805806 2 0.8016 0.6424 0.244 0.756
#> SRR805807 1 0.0000 0.9176 1.000 0.000
#> SRR805808 2 0.0000 0.9231 0.000 1.000
#> SRR805809 2 0.0000 0.9231 0.000 1.000
#> SRR805810 2 0.7883 0.6554 0.236 0.764
#> SRR805811 1 0.6247 0.8216 0.844 0.156
#> SRR805812 2 0.0000 0.9231 0.000 1.000
#> SRR805813 1 0.0000 0.9176 1.000 0.000
#> SRR805814 1 0.0000 0.9176 1.000 0.000
#> SRR805815 1 0.0000 0.9176 1.000 0.000
#> SRR805816 1 0.0000 0.9176 1.000 0.000
#> SRR805817 1 0.0000 0.9176 1.000 0.000
#> SRR805818 1 0.0000 0.9176 1.000 0.000
#> SRR805819 1 0.0000 0.9176 1.000 0.000
#> SRR805820 1 0.0000 0.9176 1.000 0.000
#> SRR805821 1 0.0000 0.9176 1.000 0.000
#> SRR805822 1 0.0000 0.9176 1.000 0.000
#> SRR805823 1 0.0000 0.9176 1.000 0.000
#> SRR805824 1 0.0376 0.9162 0.996 0.004
#> SRR805825 2 0.9580 0.3356 0.380 0.620
#> SRR805826 1 0.8661 0.6490 0.712 0.288
#> SRR805828 1 0.6712 0.8014 0.824 0.176
#> SRR805829 1 0.6887 0.7932 0.816 0.184
#> SRR805830 1 0.7883 0.7309 0.764 0.236
#> SRR805831 1 0.3584 0.8856 0.932 0.068
#> SRR805832 2 0.9954 0.0579 0.460 0.540
#> SRR805833 1 0.8443 0.6767 0.728 0.272
#> SRR805834 1 0.7376 0.7662 0.792 0.208
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.0000 0.961 0.000 1.000 0.000
#> SRR805781 2 0.0000 0.961 0.000 1.000 0.000
#> SRR805782 2 0.0000 0.961 0.000 1.000 0.000
#> SRR805784 2 0.0000 0.961 0.000 1.000 0.000
#> SRR805785 2 0.0000 0.961 0.000 1.000 0.000
#> SRR805786 2 0.0000 0.961 0.000 1.000 0.000
#> SRR805787 2 0.0000 0.961 0.000 1.000 0.000
#> SRR805788 2 0.0000 0.961 0.000 1.000 0.000
#> SRR805789 2 0.0000 0.961 0.000 1.000 0.000
#> SRR805790 2 0.0000 0.961 0.000 1.000 0.000
#> SRR805791 1 0.0237 0.932 0.996 0.004 0.000
#> SRR805792 1 0.1289 0.918 0.968 0.000 0.032
#> SRR805793 1 0.8186 0.465 0.604 0.292 0.104
#> SRR805794 1 0.1289 0.916 0.968 0.032 0.000
#> SRR805795 1 0.0000 0.933 1.000 0.000 0.000
#> SRR805796 1 0.0000 0.933 1.000 0.000 0.000
#> SRR805797 1 0.0000 0.933 1.000 0.000 0.000
#> SRR805798 1 0.0000 0.933 1.000 0.000 0.000
#> SRR805799 1 0.0000 0.933 1.000 0.000 0.000
#> SRR805800 1 0.0000 0.933 1.000 0.000 0.000
#> SRR805801 1 0.0000 0.933 1.000 0.000 0.000
#> SRR805802 2 0.0592 0.950 0.012 0.988 0.000
#> SRR805803 2 0.0000 0.961 0.000 1.000 0.000
#> SRR805804 2 0.0000 0.961 0.000 1.000 0.000
#> SRR805805 2 0.0000 0.961 0.000 1.000 0.000
#> SRR805806 1 0.5621 0.568 0.692 0.308 0.000
#> SRR805807 1 0.0000 0.933 1.000 0.000 0.000
#> SRR805808 2 0.2796 0.864 0.092 0.908 0.000
#> SRR805809 2 0.0000 0.961 0.000 1.000 0.000
#> SRR805810 1 0.5835 0.502 0.660 0.340 0.000
#> SRR805811 1 0.2356 0.886 0.928 0.072 0.000
#> SRR805812 2 0.6126 0.277 0.400 0.600 0.000
#> SRR805813 1 0.0000 0.933 1.000 0.000 0.000
#> SRR805814 1 0.4702 0.721 0.788 0.000 0.212
#> SRR805815 1 0.2261 0.891 0.932 0.000 0.068
#> SRR805816 1 0.1860 0.904 0.948 0.000 0.052
#> SRR805817 1 0.0237 0.932 0.996 0.000 0.004
#> SRR805818 1 0.0000 0.933 1.000 0.000 0.000
#> SRR805819 1 0.1031 0.923 0.976 0.000 0.024
#> SRR805820 1 0.1031 0.923 0.976 0.000 0.024
#> SRR805821 1 0.0237 0.932 0.996 0.000 0.004
#> SRR805822 1 0.0237 0.932 0.996 0.000 0.004
#> SRR805823 1 0.0237 0.932 0.996 0.000 0.004
#> SRR805824 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> SRR805781 2 0.0336 0.9391 0.008 0.992 0.000 0.000
#> SRR805782 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> SRR805784 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> SRR805785 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> SRR805786 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> SRR805787 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> SRR805788 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> SRR805789 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> SRR805790 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> SRR805791 1 0.1488 0.9139 0.956 0.012 0.000 0.032
#> SRR805792 1 0.1510 0.9119 0.956 0.016 0.000 0.028
#> SRR805793 1 0.1471 0.8997 0.960 0.024 0.004 0.012
#> SRR805794 1 0.1406 0.9101 0.960 0.016 0.000 0.024
#> SRR805795 1 0.1302 0.9173 0.956 0.000 0.000 0.044
#> SRR805796 1 0.1302 0.9173 0.956 0.000 0.000 0.044
#> SRR805797 1 0.1302 0.9173 0.956 0.000 0.000 0.044
#> SRR805798 1 0.1302 0.9173 0.956 0.000 0.000 0.044
#> SRR805799 1 0.1302 0.9173 0.956 0.000 0.000 0.044
#> SRR805800 1 0.1302 0.9173 0.956 0.000 0.000 0.044
#> SRR805801 1 0.1302 0.9173 0.956 0.000 0.000 0.044
#> SRR805802 2 0.2500 0.9209 0.044 0.916 0.000 0.040
#> SRR805803 2 0.1833 0.9305 0.032 0.944 0.000 0.024
#> SRR805804 2 0.2214 0.9260 0.044 0.928 0.000 0.028
#> SRR805805 2 0.2313 0.9247 0.044 0.924 0.000 0.032
#> SRR805806 2 0.6495 0.3951 0.356 0.560 0.000 0.084
#> SRR805807 4 0.4985 0.0708 0.468 0.000 0.000 0.532
#> SRR805808 2 0.2761 0.9140 0.048 0.904 0.000 0.048
#> SRR805809 2 0.2313 0.9247 0.044 0.924 0.000 0.032
#> SRR805810 1 0.5566 0.5537 0.704 0.224 0.000 0.072
#> SRR805811 1 0.6537 0.1302 0.500 0.076 0.000 0.424
#> SRR805812 2 0.4839 0.7706 0.184 0.764 0.000 0.052
#> SRR805813 4 0.1174 0.9481 0.020 0.000 0.012 0.968
#> SRR805814 4 0.0895 0.9309 0.004 0.000 0.020 0.976
#> SRR805815 4 0.1151 0.9405 0.008 0.000 0.024 0.968
#> SRR805816 4 0.1151 0.9405 0.008 0.000 0.024 0.968
#> SRR805817 4 0.1174 0.9481 0.020 0.000 0.012 0.968
#> SRR805818 4 0.1042 0.9451 0.020 0.000 0.008 0.972
#> SRR805819 4 0.1174 0.9481 0.020 0.000 0.012 0.968
#> SRR805820 4 0.1174 0.9481 0.020 0.000 0.012 0.968
#> SRR805821 4 0.1174 0.9481 0.020 0.000 0.012 0.968
#> SRR805822 4 0.1174 0.9481 0.020 0.000 0.012 0.968
#> SRR805823 4 0.1174 0.9481 0.020 0.000 0.012 0.968
#> SRR805824 3 0.0188 0.9977 0.000 0.000 0.996 0.004
#> SRR805825 3 0.0000 0.9977 0.000 0.000 1.000 0.000
#> SRR805826 3 0.0000 0.9977 0.000 0.000 1.000 0.000
#> SRR805828 3 0.0188 0.9977 0.000 0.000 0.996 0.004
#> SRR805829 3 0.0188 0.9977 0.000 0.000 0.996 0.004
#> SRR805830 3 0.0188 0.9977 0.000 0.000 0.996 0.004
#> SRR805831 3 0.0188 0.9977 0.000 0.000 0.996 0.004
#> SRR805832 3 0.0000 0.9977 0.000 0.000 1.000 0.000
#> SRR805833 3 0.0000 0.9977 0.000 0.000 1.000 0.000
#> SRR805834 3 0.0000 0.9977 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
#> SRR805780 2 0.0451 0.922 0.008 0.988 0 0.000 0.004
#> SRR805781 2 0.1908 0.891 0.000 0.908 0 0.000 0.092
#> SRR805782 2 0.1478 0.912 0.000 0.936 0 0.000 0.064
#> SRR805784 2 0.1168 0.926 0.008 0.960 0 0.000 0.032
#> SRR805785 2 0.0771 0.928 0.004 0.976 0 0.000 0.020
#> SRR805786 2 0.1195 0.892 0.028 0.960 0 0.000 0.012
#> SRR805787 2 0.0451 0.926 0.004 0.988 0 0.000 0.008
#> SRR805788 2 0.0451 0.926 0.004 0.988 0 0.000 0.008
#> SRR805789 2 0.0609 0.928 0.000 0.980 0 0.000 0.020
#> SRR805790 2 0.1197 0.919 0.000 0.952 0 0.000 0.048
#> SRR805791 1 0.1809 0.938 0.928 0.060 0 0.000 0.012
#> SRR805792 1 0.1670 0.943 0.936 0.052 0 0.000 0.012
#> SRR805793 1 0.1809 0.938 0.928 0.060 0 0.000 0.012
#> SRR805794 1 0.1597 0.945 0.940 0.048 0 0.000 0.012
#> SRR805795 1 0.0609 0.962 0.980 0.000 0 0.000 0.020
#> SRR805796 1 0.0880 0.960 0.968 0.000 0 0.000 0.032
#> SRR805797 1 0.0880 0.960 0.968 0.000 0 0.000 0.032
#> SRR805798 1 0.0794 0.961 0.972 0.000 0 0.000 0.028
#> SRR805799 1 0.0880 0.960 0.968 0.000 0 0.000 0.032
#> SRR805800 1 0.0162 0.959 0.996 0.004 0 0.000 0.000
#> SRR805801 1 0.0794 0.961 0.972 0.000 0 0.000 0.028
#> SRR805802 5 0.1121 0.918 0.000 0.044 0 0.000 0.956
#> SRR805803 2 0.4182 0.349 0.000 0.600 0 0.000 0.400
#> SRR805804 5 0.3366 0.687 0.000 0.232 0 0.000 0.768
#> SRR805805 5 0.1121 0.918 0.000 0.044 0 0.000 0.956
#> SRR805806 5 0.1568 0.915 0.020 0.036 0 0.000 0.944
#> SRR805807 5 0.4262 0.758 0.100 0.000 0 0.124 0.776
#> SRR805808 5 0.1043 0.919 0.000 0.040 0 0.000 0.960
#> SRR805809 5 0.1121 0.918 0.000 0.044 0 0.000 0.956
#> SRR805810 5 0.1725 0.900 0.044 0.020 0 0.000 0.936
#> SRR805811 5 0.2491 0.856 0.068 0.000 0 0.036 0.896
#> SRR805812 5 0.1124 0.919 0.004 0.036 0 0.000 0.960
#> SRR805813 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805814 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805815 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805816 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805817 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805818 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805819 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805820 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805821 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805822 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805823 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0458 0.927 0.000 0.984 0 0 0.000 0.016
#> SRR805781 6 0.2793 0.665 0.000 0.200 0 0 0.000 0.800
#> SRR805782 2 0.3684 0.356 0.000 0.628 0 0 0.000 0.372
#> SRR805784 2 0.0291 0.924 0.000 0.992 0 0 0.004 0.004
#> SRR805785 2 0.0000 0.928 0.000 1.000 0 0 0.000 0.000
#> SRR805786 2 0.0000 0.928 0.000 1.000 0 0 0.000 0.000
#> SRR805787 2 0.1075 0.911 0.000 0.952 0 0 0.000 0.048
#> SRR805788 2 0.1204 0.905 0.000 0.944 0 0 0.000 0.056
#> SRR805789 2 0.0260 0.929 0.000 0.992 0 0 0.000 0.008
#> SRR805790 2 0.0146 0.929 0.000 0.996 0 0 0.000 0.004
#> SRR805791 1 0.0260 0.977 0.992 0.008 0 0 0.000 0.000
#> SRR805792 1 0.0260 0.977 0.992 0.008 0 0 0.000 0.000
#> SRR805793 1 0.0260 0.977 0.992 0.008 0 0 0.000 0.000
#> SRR805794 1 0.0146 0.979 0.996 0.004 0 0 0.000 0.000
#> SRR805795 1 0.0000 0.979 1.000 0.000 0 0 0.000 0.000
#> SRR805796 1 0.0000 0.979 1.000 0.000 0 0 0.000 0.000
#> SRR805797 1 0.0000 0.979 1.000 0.000 0 0 0.000 0.000
#> SRR805798 1 0.0000 0.979 1.000 0.000 0 0 0.000 0.000
#> SRR805799 1 0.3278 0.809 0.824 0.000 0 0 0.088 0.088
#> SRR805800 1 0.0000 0.979 1.000 0.000 0 0 0.000 0.000
#> SRR805801 1 0.0146 0.978 0.996 0.000 0 0 0.004 0.000
#> SRR805802 5 0.1714 0.925 0.000 0.000 0 0 0.908 0.092
#> SRR805803 6 0.2201 0.796 0.000 0.048 0 0 0.052 0.900
#> SRR805804 6 0.3052 0.683 0.000 0.004 0 0 0.216 0.780
#> SRR805805 5 0.1387 0.944 0.000 0.000 0 0 0.932 0.068
#> SRR805806 5 0.0146 0.962 0.000 0.000 0 0 0.996 0.004
#> SRR805807 5 0.0363 0.957 0.000 0.000 0 0 0.988 0.012
#> SRR805808 5 0.0865 0.959 0.000 0.000 0 0 0.964 0.036
#> SRR805809 5 0.1267 0.949 0.000 0.000 0 0 0.940 0.060
#> SRR805810 5 0.0000 0.963 0.000 0.000 0 0 1.000 0.000
#> SRR805811 5 0.0146 0.962 0.000 0.000 0 0 0.996 0.004
#> SRR805812 5 0.0260 0.964 0.000 0.000 0 0 0.992 0.008
#> SRR805813 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805814 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805815 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805816 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805817 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805818 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805819 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805820 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805821 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805822 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805823 4 0.0000 1.000 0.000 0.000 0 1 0.000 0.000
#> SRR805824 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805825 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
#> SRR805834 3 0.0000 1.000 0.000 0.000 1 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "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 15291 rows and 53 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 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.993 0.996 0.3610 0.643 0.643
#> 3 3 0.663 0.820 0.745 0.6635 0.736 0.589
#> 4 4 0.655 0.763 0.862 0.0633 0.991 0.977
#> 5 5 0.811 0.756 0.901 0.0775 0.869 0.674
#> 6 6 0.817 0.801 0.916 0.0794 0.933 0.789
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
#> SRR805780 2 0.000 1.000 0.000 1.000
#> SRR805781 2 0.000 1.000 0.000 1.000
#> SRR805782 2 0.000 1.000 0.000 1.000
#> SRR805784 2 0.000 1.000 0.000 1.000
#> SRR805785 2 0.000 1.000 0.000 1.000
#> SRR805786 2 0.000 1.000 0.000 1.000
#> SRR805787 2 0.000 1.000 0.000 1.000
#> SRR805788 2 0.000 1.000 0.000 1.000
#> SRR805789 2 0.000 1.000 0.000 1.000
#> SRR805790 2 0.000 1.000 0.000 1.000
#> SRR805791 1 0.000 0.995 1.000 0.000
#> SRR805792 1 0.000 0.995 1.000 0.000
#> SRR805793 1 0.000 0.995 1.000 0.000
#> SRR805794 1 0.000 0.995 1.000 0.000
#> SRR805795 1 0.000 0.995 1.000 0.000
#> SRR805796 1 0.000 0.995 1.000 0.000
#> SRR805797 1 0.000 0.995 1.000 0.000
#> SRR805798 1 0.000 0.995 1.000 0.000
#> SRR805799 1 0.000 0.995 1.000 0.000
#> SRR805800 1 0.000 0.995 1.000 0.000
#> SRR805801 1 0.000 0.995 1.000 0.000
#> SRR805802 1 0.204 0.972 0.968 0.032
#> SRR805803 2 0.000 1.000 0.000 1.000
#> SRR805804 2 0.000 1.000 0.000 1.000
#> SRR805805 1 0.204 0.972 0.968 0.032
#> SRR805806 1 0.184 0.975 0.972 0.028
#> SRR805807 1 0.000 0.995 1.000 0.000
#> SRR805808 1 0.204 0.972 0.968 0.032
#> SRR805809 1 0.204 0.972 0.968 0.032
#> SRR805810 1 0.184 0.975 0.972 0.028
#> SRR805811 1 0.000 0.995 1.000 0.000
#> SRR805812 1 0.184 0.975 0.972 0.028
#> SRR805813 1 0.000 0.995 1.000 0.000
#> SRR805814 1 0.000 0.995 1.000 0.000
#> SRR805815 1 0.000 0.995 1.000 0.000
#> SRR805816 1 0.000 0.995 1.000 0.000
#> SRR805817 1 0.000 0.995 1.000 0.000
#> SRR805818 1 0.000 0.995 1.000 0.000
#> SRR805819 1 0.000 0.995 1.000 0.000
#> SRR805820 1 0.000 0.995 1.000 0.000
#> SRR805821 1 0.000 0.995 1.000 0.000
#> SRR805822 1 0.000 0.995 1.000 0.000
#> SRR805823 1 0.000 0.995 1.000 0.000
#> SRR805824 1 0.000 0.995 1.000 0.000
#> SRR805825 1 0.000 0.995 1.000 0.000
#> SRR805826 1 0.000 0.995 1.000 0.000
#> SRR805828 1 0.000 0.995 1.000 0.000
#> SRR805829 1 0.000 0.995 1.000 0.000
#> SRR805830 1 0.000 0.995 1.000 0.000
#> SRR805831 1 0.000 0.995 1.000 0.000
#> SRR805832 1 0.000 0.995 1.000 0.000
#> SRR805833 1 0.000 0.995 1.000 0.000
#> SRR805834 1 0.000 0.995 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR805781 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR805782 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR805784 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR805785 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR805786 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR805787 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR805788 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR805789 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR805790 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR805791 3 0.4796 0.8183 0.220 0.000 0.780
#> SRR805792 3 0.4796 0.8183 0.220 0.000 0.780
#> SRR805793 3 0.4796 0.8183 0.220 0.000 0.780
#> SRR805794 3 0.4796 0.8183 0.220 0.000 0.780
#> SRR805795 3 0.5968 0.7582 0.364 0.000 0.636
#> SRR805796 3 0.5968 0.7582 0.364 0.000 0.636
#> SRR805797 3 0.5968 0.7582 0.364 0.000 0.636
#> SRR805798 3 0.5968 0.7582 0.364 0.000 0.636
#> SRR805799 1 0.0237 0.9022 0.996 0.000 0.004
#> SRR805800 3 0.5968 0.7582 0.364 0.000 0.636
#> SRR805801 3 0.5968 0.7582 0.364 0.000 0.636
#> SRR805802 3 0.0237 0.7083 0.000 0.004 0.996
#> SRR805803 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR805804 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR805805 3 0.0237 0.7083 0.000 0.004 0.996
#> SRR805806 3 0.0000 0.7107 0.000 0.000 1.000
#> SRR805807 3 0.5785 0.7686 0.332 0.000 0.668
#> SRR805808 3 0.0237 0.7083 0.000 0.004 0.996
#> SRR805809 3 0.0237 0.7083 0.000 0.004 0.996
#> SRR805810 3 0.0000 0.7107 0.000 0.000 1.000
#> SRR805811 3 0.1163 0.7260 0.028 0.000 0.972
#> SRR805812 3 0.0000 0.7107 0.000 0.000 1.000
#> SRR805813 1 0.0000 0.9060 1.000 0.000 0.000
#> SRR805814 1 0.6126 -0.0384 0.600 0.000 0.400
#> SRR805815 1 0.0000 0.9060 1.000 0.000 0.000
#> SRR805816 1 0.6126 -0.0384 0.600 0.000 0.400
#> SRR805817 1 0.0000 0.9060 1.000 0.000 0.000
#> SRR805818 1 0.0000 0.9060 1.000 0.000 0.000
#> SRR805819 1 0.0000 0.9060 1.000 0.000 0.000
#> SRR805820 1 0.0000 0.9060 1.000 0.000 0.000
#> SRR805821 1 0.0000 0.9060 1.000 0.000 0.000
#> SRR805822 1 0.0000 0.9060 1.000 0.000 0.000
#> SRR805823 1 0.0000 0.9060 1.000 0.000 0.000
#> SRR805824 1 0.0000 0.9060 1.000 0.000 0.000
#> SRR805825 3 0.5058 0.8206 0.244 0.000 0.756
#> SRR805826 3 0.5560 0.8082 0.300 0.000 0.700
#> SRR805828 3 0.5560 0.8082 0.300 0.000 0.700
#> SRR805829 3 0.5560 0.8082 0.300 0.000 0.700
#> SRR805830 3 0.5560 0.8082 0.300 0.000 0.700
#> SRR805831 3 0.5560 0.8082 0.300 0.000 0.700
#> SRR805832 3 0.5058 0.8206 0.244 0.000 0.756
#> SRR805833 3 0.5497 0.8111 0.292 0.000 0.708
#> SRR805834 3 0.5058 0.8206 0.244 0.000 0.756
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.000 1.000 0.000 1 0.000 0.000
#> SRR805781 2 0.000 1.000 0.000 1 0.000 0.000
#> SRR805782 2 0.000 1.000 0.000 1 0.000 0.000
#> SRR805784 2 0.000 1.000 0.000 1 0.000 0.000
#> SRR805785 2 0.000 1.000 0.000 1 0.000 0.000
#> SRR805786 2 0.000 1.000 0.000 1 0.000 0.000
#> SRR805787 2 0.000 1.000 0.000 1 0.000 0.000
#> SRR805788 2 0.000 1.000 0.000 1 0.000 0.000
#> SRR805789 2 0.000 1.000 0.000 1 0.000 0.000
#> SRR805790 2 0.000 1.000 0.000 1 0.000 0.000
#> SRR805791 1 0.335 0.809 0.844 0 0.008 0.148
#> SRR805792 1 0.335 0.809 0.844 0 0.008 0.148
#> SRR805793 1 0.335 0.809 0.844 0 0.008 0.148
#> SRR805794 1 0.335 0.809 0.844 0 0.008 0.148
#> SRR805795 1 0.466 0.771 0.716 0 0.012 0.272
#> SRR805796 1 0.466 0.771 0.716 0 0.012 0.272
#> SRR805797 1 0.466 0.771 0.716 0 0.012 0.272
#> SRR805798 1 0.466 0.771 0.716 0 0.012 0.272
#> SRR805799 3 0.428 0.000 0.004 0 0.740 0.256
#> SRR805800 1 0.466 0.771 0.716 0 0.012 0.272
#> SRR805801 1 0.466 0.771 0.716 0 0.012 0.272
#> SRR805802 1 0.413 0.519 0.740 0 0.260 0.000
#> SRR805803 2 0.000 1.000 0.000 1 0.000 0.000
#> SRR805804 2 0.000 1.000 0.000 1 0.000 0.000
#> SRR805805 1 0.413 0.519 0.740 0 0.260 0.000
#> SRR805806 1 0.201 0.690 0.920 0 0.080 0.000
#> SRR805807 1 0.471 0.775 0.732 0 0.020 0.248
#> SRR805808 1 0.413 0.519 0.740 0 0.260 0.000
#> SRR805809 1 0.413 0.519 0.740 0 0.260 0.000
#> SRR805810 1 0.331 0.619 0.828 0 0.172 0.000
#> SRR805811 1 0.147 0.708 0.948 0 0.052 0.000
#> SRR805812 1 0.201 0.690 0.920 0 0.080 0.000
#> SRR805813 4 0.000 0.812 0.000 0 0.000 1.000
#> SRR805814 4 0.541 -0.172 0.480 0 0.012 0.508
#> SRR805815 4 0.000 0.812 0.000 0 0.000 1.000
#> SRR805816 4 0.541 -0.172 0.480 0 0.012 0.508
#> SRR805817 4 0.000 0.812 0.000 0 0.000 1.000
#> SRR805818 4 0.000 0.812 0.000 0 0.000 1.000
#> SRR805819 4 0.000 0.812 0.000 0 0.000 1.000
#> SRR805820 4 0.000 0.812 0.000 0 0.000 1.000
#> SRR805821 4 0.000 0.812 0.000 0 0.000 1.000
#> SRR805822 4 0.000 0.812 0.000 0 0.000 1.000
#> SRR805823 4 0.000 0.812 0.000 0 0.000 1.000
#> SRR805824 4 0.000 0.812 0.000 0 0.000 1.000
#> SRR805825 1 0.322 0.812 0.836 0 0.000 0.164
#> SRR805826 1 0.414 0.804 0.780 0 0.012 0.208
#> SRR805828 1 0.414 0.804 0.780 0 0.012 0.208
#> SRR805829 1 0.414 0.804 0.780 0 0.012 0.208
#> SRR805830 1 0.414 0.804 0.780 0 0.012 0.208
#> SRR805831 1 0.414 0.804 0.780 0 0.012 0.208
#> SRR805832 1 0.322 0.812 0.836 0 0.000 0.164
#> SRR805833 1 0.406 0.806 0.788 0 0.012 0.200
#> SRR805834 1 0.322 0.812 0.836 0 0.000 0.164
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.000 0.964 0.000 1.0 0 0.000 0.000
#> SRR805781 2 0.000 0.964 0.000 1.0 0 0.000 0.000
#> SRR805782 2 0.000 0.964 0.000 1.0 0 0.000 0.000
#> SRR805784 2 0.418 0.432 0.000 0.6 0 0.000 0.400
#> SRR805785 2 0.000 0.964 0.000 1.0 0 0.000 0.000
#> SRR805786 2 0.000 0.964 0.000 1.0 0 0.000 0.000
#> SRR805787 2 0.000 0.964 0.000 1.0 0 0.000 0.000
#> SRR805788 2 0.000 0.964 0.000 1.0 0 0.000 0.000
#> SRR805789 2 0.000 0.964 0.000 1.0 0 0.000 0.000
#> SRR805790 2 0.000 0.964 0.000 1.0 0 0.000 0.000
#> SRR805791 1 0.173 0.731 0.920 0.0 0 0.000 0.080
#> SRR805792 1 0.173 0.731 0.920 0.0 0 0.000 0.080
#> SRR805793 1 0.173 0.731 0.920 0.0 0 0.000 0.080
#> SRR805794 1 0.173 0.731 0.920 0.0 0 0.000 0.080
#> SRR805795 1 0.148 0.753 0.936 0.0 0 0.064 0.000
#> SRR805796 1 0.148 0.753 0.936 0.0 0 0.064 0.000
#> SRR805797 1 0.148 0.753 0.936 0.0 0 0.064 0.000
#> SRR805798 1 0.148 0.753 0.936 0.0 0 0.064 0.000
#> SRR805799 3 0.000 0.000 0.000 0.0 1 0.000 0.000
#> SRR805800 1 0.148 0.753 0.936 0.0 0 0.064 0.000
#> SRR805801 1 0.148 0.753 0.936 0.0 0 0.064 0.000
#> SRR805802 5 0.418 0.952 0.400 0.0 0 0.000 0.600
#> SRR805803 2 0.000 0.964 0.000 1.0 0 0.000 0.000
#> SRR805804 2 0.000 0.964 0.000 1.0 0 0.000 0.000
#> SRR805805 5 0.418 0.952 0.400 0.0 0 0.000 0.600
#> SRR805806 1 0.417 -0.478 0.604 0.0 0 0.000 0.396
#> SRR805807 1 0.234 0.726 0.904 0.0 0 0.064 0.032
#> SRR805808 5 0.418 0.952 0.400 0.0 0 0.000 0.600
#> SRR805809 5 0.418 0.952 0.400 0.0 0 0.000 0.600
#> SRR805810 5 0.430 0.776 0.488 0.0 0 0.000 0.512
#> SRR805811 1 0.409 -0.364 0.632 0.0 0 0.000 0.368
#> SRR805812 1 0.417 -0.478 0.604 0.0 0 0.000 0.396
#> SRR805813 4 0.000 1.000 0.000 0.0 0 1.000 0.000
#> SRR805814 1 0.380 0.338 0.700 0.0 0 0.300 0.000
#> SRR805815 4 0.000 1.000 0.000 0.0 0 1.000 0.000
#> SRR805816 1 0.380 0.338 0.700 0.0 0 0.300 0.000
#> SRR805817 4 0.000 1.000 0.000 0.0 0 1.000 0.000
#> SRR805818 4 0.000 1.000 0.000 0.0 0 1.000 0.000
#> SRR805819 4 0.000 1.000 0.000 0.0 0 1.000 0.000
#> SRR805820 4 0.000 1.000 0.000 0.0 0 1.000 0.000
#> SRR805821 4 0.000 1.000 0.000 0.0 0 1.000 0.000
#> SRR805822 4 0.000 1.000 0.000 0.0 0 1.000 0.000
#> SRR805823 4 0.000 1.000 0.000 0.0 0 1.000 0.000
#> SRR805824 4 0.000 1.000 0.000 0.0 0 1.000 0.000
#> SRR805825 1 0.134 0.753 0.944 0.0 0 0.000 0.056
#> SRR805826 1 0.000 0.774 1.000 0.0 0 0.000 0.000
#> SRR805828 1 0.000 0.774 1.000 0.0 0 0.000 0.000
#> SRR805829 1 0.000 0.774 1.000 0.0 0 0.000 0.000
#> SRR805830 1 0.000 0.774 1.000 0.0 0 0.000 0.000
#> SRR805831 1 0.000 0.774 1.000 0.0 0 0.000 0.000
#> SRR805832 1 0.134 0.753 0.944 0.0 0 0.000 0.056
#> SRR805833 1 0.029 0.773 0.992 0.0 0 0.000 0.008
#> SRR805834 1 0.134 0.753 0.944 0.0 0 0.000 0.056
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.1501 0.907 0.000 0.924 0 0.000 0.000 0.076
#> SRR805781 2 0.1863 0.839 0.000 0.896 0 0.000 0.000 0.104
#> SRR805782 2 0.1863 0.839 0.000 0.896 0 0.000 0.000 0.104
#> SRR805784 6 0.2912 0.000 0.000 0.216 0 0.000 0.000 0.784
#> SRR805785 2 0.1501 0.907 0.000 0.924 0 0.000 0.000 0.076
#> SRR805786 2 0.1501 0.907 0.000 0.924 0 0.000 0.000 0.076
#> SRR805787 2 0.0000 0.906 0.000 1.000 0 0.000 0.000 0.000
#> SRR805788 2 0.0000 0.906 0.000 1.000 0 0.000 0.000 0.000
#> SRR805789 2 0.0000 0.906 0.000 1.000 0 0.000 0.000 0.000
#> SRR805790 2 0.1863 0.839 0.000 0.896 0 0.000 0.000 0.104
#> SRR805791 1 0.2094 0.849 0.900 0.000 0 0.000 0.080 0.020
#> SRR805792 1 0.2094 0.849 0.900 0.000 0 0.000 0.080 0.020
#> SRR805793 1 0.2094 0.849 0.900 0.000 0 0.000 0.080 0.020
#> SRR805794 1 0.2094 0.849 0.900 0.000 0 0.000 0.080 0.020
#> SRR805795 1 0.1327 0.871 0.936 0.000 0 0.064 0.000 0.000
#> SRR805796 1 0.1327 0.871 0.936 0.000 0 0.064 0.000 0.000
#> SRR805797 1 0.1327 0.871 0.936 0.000 0 0.064 0.000 0.000
#> SRR805798 1 0.1327 0.871 0.936 0.000 0 0.064 0.000 0.000
#> SRR805799 3 0.0000 0.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR805800 1 0.1327 0.871 0.936 0.000 0 0.064 0.000 0.000
#> SRR805801 1 0.1327 0.871 0.936 0.000 0 0.064 0.000 0.000
#> SRR805802 5 0.0000 0.612 0.000 0.000 0 0.000 1.000 0.000
#> SRR805803 2 0.1501 0.907 0.000 0.924 0 0.000 0.000 0.076
#> SRR805804 2 0.1501 0.907 0.000 0.924 0 0.000 0.000 0.076
#> SRR805805 5 0.0000 0.612 0.000 0.000 0 0.000 1.000 0.000
#> SRR805806 5 0.5543 0.469 0.372 0.000 0 0.000 0.488 0.140
#> SRR805807 1 0.4219 0.716 0.776 0.000 0 0.064 0.040 0.120
#> SRR805808 5 0.0000 0.612 0.000 0.000 0 0.000 1.000 0.000
#> SRR805809 5 0.0000 0.612 0.000 0.000 0 0.000 1.000 0.000
#> SRR805810 5 0.2048 0.573 0.000 0.000 0 0.000 0.880 0.120
#> SRR805811 5 0.5575 0.402 0.400 0.000 0 0.000 0.460 0.140
#> SRR805812 5 0.5543 0.469 0.372 0.000 0 0.000 0.488 0.140
#> SRR805813 4 0.0000 1.000 0.000 0.000 0 1.000 0.000 0.000
#> SRR805814 1 0.3409 0.540 0.700 0.000 0 0.300 0.000 0.000
#> SRR805815 4 0.0000 1.000 0.000 0.000 0 1.000 0.000 0.000
#> SRR805816 1 0.3409 0.540 0.700 0.000 0 0.300 0.000 0.000
#> SRR805817 4 0.0000 1.000 0.000 0.000 0 1.000 0.000 0.000
#> SRR805818 4 0.0000 1.000 0.000 0.000 0 1.000 0.000 0.000
#> SRR805819 4 0.0000 1.000 0.000 0.000 0 1.000 0.000 0.000
#> SRR805820 4 0.0000 1.000 0.000 0.000 0 1.000 0.000 0.000
#> SRR805821 4 0.0000 1.000 0.000 0.000 0 1.000 0.000 0.000
#> SRR805822 4 0.0000 1.000 0.000 0.000 0 1.000 0.000 0.000
#> SRR805823 4 0.0000 1.000 0.000 0.000 0 1.000 0.000 0.000
#> SRR805824 4 0.0000 1.000 0.000 0.000 0 1.000 0.000 0.000
#> SRR805825 1 0.1745 0.865 0.924 0.000 0 0.000 0.056 0.020
#> SRR805826 1 0.0000 0.884 1.000 0.000 0 0.000 0.000 0.000
#> SRR805828 1 0.0000 0.884 1.000 0.000 0 0.000 0.000 0.000
#> SRR805829 1 0.0000 0.884 1.000 0.000 0 0.000 0.000 0.000
#> SRR805830 1 0.0000 0.884 1.000 0.000 0 0.000 0.000 0.000
#> SRR805831 1 0.0000 0.884 1.000 0.000 0 0.000 0.000 0.000
#> SRR805832 1 0.1745 0.865 0.924 0.000 0 0.000 0.056 0.020
#> SRR805833 1 0.0405 0.883 0.988 0.000 0 0.000 0.008 0.004
#> SRR805834 1 0.1745 0.865 0.924 0.000 0 0.000 0.056 0.020
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.3968 0.604 0.604
#> 3 3 0.670 0.853 0.912 0.6128 0.679 0.492
#> 4 4 0.681 0.754 0.785 0.1135 0.929 0.790
#> 5 5 0.716 0.542 0.747 0.0805 0.832 0.518
#> 6 6 0.821 0.821 0.854 0.0534 0.898 0.630
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 2
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0 1 0 1
#> SRR805781 2 0 1 0 1
#> SRR805782 2 0 1 0 1
#> SRR805784 2 0 1 0 1
#> SRR805785 2 0 1 0 1
#> SRR805786 2 0 1 0 1
#> SRR805787 2 0 1 0 1
#> SRR805788 2 0 1 0 1
#> SRR805789 2 0 1 0 1
#> SRR805790 2 0 1 0 1
#> SRR805791 1 0 1 1 0
#> SRR805792 1 0 1 1 0
#> SRR805793 1 0 1 1 0
#> SRR805794 1 0 1 1 0
#> SRR805795 1 0 1 1 0
#> SRR805796 1 0 1 1 0
#> SRR805797 1 0 1 1 0
#> SRR805798 1 0 1 1 0
#> SRR805799 1 0 1 1 0
#> SRR805800 1 0 1 1 0
#> SRR805801 1 0 1 1 0
#> SRR805802 1 0 1 1 0
#> SRR805803 2 0 1 0 1
#> SRR805804 2 0 1 0 1
#> SRR805805 2 0 1 0 1
#> SRR805806 1 0 1 1 0
#> SRR805807 1 0 1 1 0
#> SRR805808 1 0 1 1 0
#> SRR805809 2 0 1 0 1
#> SRR805810 1 0 1 1 0
#> SRR805811 1 0 1 1 0
#> SRR805812 1 0 1 1 0
#> SRR805813 1 0 1 1 0
#> SRR805814 1 0 1 1 0
#> SRR805815 1 0 1 1 0
#> SRR805816 1 0 1 1 0
#> SRR805817 1 0 1 1 0
#> SRR805818 1 0 1 1 0
#> SRR805819 1 0 1 1 0
#> SRR805820 1 0 1 1 0
#> SRR805821 1 0 1 1 0
#> SRR805822 1 0 1 1 0
#> SRR805823 1 0 1 1 0
#> SRR805824 1 0 1 1 0
#> SRR805825 1 0 1 1 0
#> SRR805826 1 0 1 1 0
#> SRR805828 1 0 1 1 0
#> SRR805829 1 0 1 1 0
#> SRR805830 1 0 1 1 0
#> SRR805831 1 0 1 1 0
#> SRR805832 1 0 1 1 0
#> SRR805833 1 0 1 1 0
#> SRR805834 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.0237 0.998 0.000 0.996 0.004
#> SRR805781 2 0.0000 0.998 0.000 1.000 0.000
#> SRR805782 2 0.0000 0.998 0.000 1.000 0.000
#> SRR805784 2 0.0424 0.993 0.000 0.992 0.008
#> SRR805785 2 0.0237 0.998 0.000 0.996 0.004
#> SRR805786 2 0.0237 0.998 0.000 0.996 0.004
#> SRR805787 2 0.0000 0.998 0.000 1.000 0.000
#> SRR805788 2 0.0000 0.998 0.000 1.000 0.000
#> SRR805789 2 0.0237 0.998 0.000 0.996 0.004
#> SRR805790 2 0.0000 0.998 0.000 1.000 0.000
#> SRR805791 3 0.3816 0.816 0.148 0.000 0.852
#> SRR805792 3 0.3816 0.816 0.148 0.000 0.852
#> SRR805793 3 0.3816 0.816 0.148 0.000 0.852
#> SRR805794 3 0.3816 0.816 0.148 0.000 0.852
#> SRR805795 1 0.2261 0.934 0.932 0.000 0.068
#> SRR805796 1 0.2261 0.934 0.932 0.000 0.068
#> SRR805797 1 0.2261 0.934 0.932 0.000 0.068
#> SRR805798 1 0.2261 0.934 0.932 0.000 0.068
#> SRR805799 1 0.2711 0.918 0.912 0.000 0.088
#> SRR805800 1 0.2261 0.934 0.932 0.000 0.068
#> SRR805801 1 0.2261 0.934 0.932 0.000 0.068
#> SRR805802 3 0.0747 0.799 0.016 0.000 0.984
#> SRR805803 2 0.0237 0.998 0.000 0.996 0.004
#> SRR805804 2 0.0237 0.998 0.000 0.996 0.004
#> SRR805805 3 0.0592 0.785 0.000 0.012 0.988
#> SRR805806 3 0.0747 0.799 0.016 0.000 0.984
#> SRR805807 1 0.3116 0.896 0.892 0.000 0.108
#> SRR805808 3 0.0747 0.799 0.016 0.000 0.984
#> SRR805809 3 0.5905 0.260 0.000 0.352 0.648
#> SRR805810 3 0.0747 0.799 0.016 0.000 0.984
#> SRR805811 3 0.0747 0.799 0.016 0.000 0.984
#> SRR805812 3 0.0747 0.799 0.016 0.000 0.984
#> SRR805813 1 0.0000 0.948 1.000 0.000 0.000
#> SRR805814 1 0.1031 0.937 0.976 0.000 0.024
#> SRR805815 1 0.0000 0.948 1.000 0.000 0.000
#> SRR805816 1 0.4121 0.736 0.832 0.000 0.168
#> SRR805817 1 0.0000 0.948 1.000 0.000 0.000
#> SRR805818 1 0.0000 0.948 1.000 0.000 0.000
#> SRR805819 1 0.0000 0.948 1.000 0.000 0.000
#> SRR805820 1 0.0000 0.948 1.000 0.000 0.000
#> SRR805821 1 0.0000 0.948 1.000 0.000 0.000
#> SRR805822 1 0.0000 0.948 1.000 0.000 0.000
#> SRR805823 1 0.0000 0.948 1.000 0.000 0.000
#> SRR805824 1 0.0237 0.945 0.996 0.000 0.004
#> SRR805825 3 0.4399 0.803 0.188 0.000 0.812
#> SRR805826 3 0.4399 0.803 0.188 0.000 0.812
#> SRR805828 3 0.6291 0.368 0.468 0.000 0.532
#> SRR805829 3 0.6291 0.368 0.468 0.000 0.532
#> SRR805830 3 0.6260 0.417 0.448 0.000 0.552
#> SRR805831 3 0.6291 0.368 0.468 0.000 0.532
#> SRR805832 3 0.4062 0.813 0.164 0.000 0.836
#> SRR805833 3 0.4399 0.803 0.188 0.000 0.812
#> SRR805834 3 0.4399 0.803 0.188 0.000 0.812
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.1743 0.966 0.056 0.940 0.004 0.000
#> SRR805781 2 0.0188 0.973 0.000 0.996 0.004 0.000
#> SRR805782 2 0.0188 0.973 0.000 0.996 0.004 0.000
#> SRR805784 2 0.1706 0.952 0.036 0.948 0.016 0.000
#> SRR805785 2 0.1256 0.972 0.028 0.964 0.008 0.000
#> SRR805786 2 0.1890 0.965 0.056 0.936 0.008 0.000
#> SRR805787 2 0.0000 0.973 0.000 1.000 0.000 0.000
#> SRR805788 2 0.0000 0.973 0.000 1.000 0.000 0.000
#> SRR805789 2 0.1004 0.973 0.024 0.972 0.004 0.000
#> SRR805790 2 0.0188 0.972 0.000 0.996 0.004 0.000
#> SRR805791 3 0.5596 0.572 0.236 0.000 0.696 0.068
#> SRR805792 3 0.5596 0.572 0.236 0.000 0.696 0.068
#> SRR805793 3 0.5596 0.572 0.236 0.000 0.696 0.068
#> SRR805794 3 0.5596 0.572 0.236 0.000 0.696 0.068
#> SRR805795 4 0.6104 0.718 0.180 0.000 0.140 0.680
#> SRR805796 4 0.6104 0.718 0.180 0.000 0.140 0.680
#> SRR805797 4 0.6104 0.718 0.180 0.000 0.140 0.680
#> SRR805798 4 0.6104 0.718 0.180 0.000 0.140 0.680
#> SRR805799 4 0.7314 0.581 0.336 0.000 0.168 0.496
#> SRR805800 4 0.6104 0.718 0.180 0.000 0.140 0.680
#> SRR805801 4 0.7138 0.566 0.180 0.000 0.268 0.552
#> SRR805802 1 0.4898 0.881 0.584 0.000 0.416 0.000
#> SRR805803 2 0.2376 0.956 0.068 0.916 0.016 0.000
#> SRR805804 2 0.2376 0.956 0.068 0.916 0.016 0.000
#> SRR805805 1 0.4697 0.827 0.644 0.000 0.356 0.000
#> SRR805806 1 0.4898 0.881 0.584 0.000 0.416 0.000
#> SRR805807 4 0.7235 0.517 0.180 0.000 0.288 0.532
#> SRR805808 1 0.4898 0.881 0.584 0.000 0.416 0.000
#> SRR805809 1 0.6646 0.576 0.624 0.172 0.204 0.000
#> SRR805810 1 0.4866 0.875 0.596 0.000 0.404 0.000
#> SRR805811 3 0.4961 -0.527 0.448 0.000 0.552 0.000
#> SRR805812 1 0.4898 0.881 0.584 0.000 0.416 0.000
#> SRR805813 4 0.0000 0.800 0.000 0.000 0.000 1.000
#> SRR805814 4 0.4454 0.518 0.000 0.000 0.308 0.692
#> SRR805815 4 0.0000 0.800 0.000 0.000 0.000 1.000
#> SRR805816 4 0.4843 0.295 0.000 0.000 0.396 0.604
#> SRR805817 4 0.0000 0.800 0.000 0.000 0.000 1.000
#> SRR805818 4 0.0000 0.800 0.000 0.000 0.000 1.000
#> SRR805819 4 0.0000 0.800 0.000 0.000 0.000 1.000
#> SRR805820 4 0.0000 0.800 0.000 0.000 0.000 1.000
#> SRR805821 4 0.0000 0.800 0.000 0.000 0.000 1.000
#> SRR805822 4 0.0000 0.800 0.000 0.000 0.000 1.000
#> SRR805823 4 0.0000 0.800 0.000 0.000 0.000 1.000
#> SRR805824 4 0.0000 0.800 0.000 0.000 0.000 1.000
#> SRR805825 3 0.2796 0.756 0.016 0.000 0.892 0.092
#> SRR805826 3 0.2216 0.759 0.000 0.000 0.908 0.092
#> SRR805828 3 0.3074 0.738 0.000 0.000 0.848 0.152
#> SRR805829 3 0.3074 0.738 0.000 0.000 0.848 0.152
#> SRR805830 3 0.2973 0.744 0.000 0.000 0.856 0.144
#> SRR805831 3 0.3074 0.738 0.000 0.000 0.848 0.152
#> SRR805832 3 0.2742 0.739 0.024 0.000 0.900 0.076
#> SRR805833 3 0.2676 0.758 0.012 0.000 0.896 0.092
#> SRR805834 3 0.2676 0.758 0.012 0.000 0.896 0.092
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.1282 0.9250 0.000 0.952 0.004 0.000 0.044
#> SRR805781 2 0.2286 0.9233 0.000 0.888 0.108 0.000 0.004
#> SRR805782 2 0.2286 0.9233 0.000 0.888 0.108 0.000 0.004
#> SRR805784 2 0.2956 0.9051 0.000 0.848 0.140 0.004 0.008
#> SRR805785 2 0.0992 0.9289 0.000 0.968 0.008 0.000 0.024
#> SRR805786 2 0.1408 0.9247 0.000 0.948 0.008 0.000 0.044
#> SRR805787 2 0.1121 0.9315 0.000 0.956 0.044 0.000 0.000
#> SRR805788 2 0.1792 0.9253 0.000 0.916 0.084 0.000 0.000
#> SRR805789 2 0.0771 0.9293 0.000 0.976 0.004 0.000 0.020
#> SRR805790 2 0.1851 0.9251 0.000 0.912 0.088 0.000 0.000
#> SRR805791 1 0.3010 0.1810 0.824 0.000 0.000 0.004 0.172
#> SRR805792 1 0.2970 0.1776 0.828 0.000 0.000 0.004 0.168
#> SRR805793 1 0.2970 0.1776 0.828 0.000 0.000 0.004 0.168
#> SRR805794 1 0.2970 0.1776 0.828 0.000 0.000 0.004 0.168
#> SRR805795 1 0.6727 -0.4999 0.492 0.000 0.196 0.300 0.012
#> SRR805796 1 0.6761 -0.5121 0.480 0.000 0.196 0.312 0.012
#> SRR805797 1 0.6727 -0.4999 0.492 0.000 0.196 0.300 0.012
#> SRR805798 1 0.6727 -0.4999 0.492 0.000 0.196 0.300 0.012
#> SRR805799 3 0.6905 0.0000 0.372 0.000 0.456 0.140 0.032
#> SRR805800 1 0.6714 -0.5010 0.496 0.000 0.196 0.296 0.012
#> SRR805801 1 0.6295 -0.4550 0.584 0.000 0.196 0.208 0.012
#> SRR805802 5 0.1952 0.9168 0.084 0.000 0.004 0.000 0.912
#> SRR805803 2 0.3506 0.8829 0.000 0.852 0.076 0.020 0.052
#> SRR805804 2 0.3506 0.8829 0.000 0.852 0.076 0.020 0.052
#> SRR805805 5 0.1310 0.8634 0.024 0.000 0.020 0.000 0.956
#> SRR805806 5 0.1792 0.9173 0.084 0.000 0.000 0.000 0.916
#> SRR805807 1 0.7221 -0.5282 0.532 0.000 0.196 0.204 0.068
#> SRR805808 5 0.1952 0.9172 0.084 0.000 0.004 0.000 0.912
#> SRR805809 5 0.2104 0.8137 0.008 0.044 0.024 0.000 0.924
#> SRR805810 5 0.1952 0.9172 0.084 0.000 0.004 0.000 0.912
#> SRR805811 5 0.3816 0.6230 0.304 0.000 0.000 0.000 0.696
#> SRR805812 5 0.1792 0.9173 0.084 0.000 0.000 0.000 0.916
#> SRR805813 4 0.0955 0.9297 0.028 0.000 0.004 0.968 0.000
#> SRR805814 4 0.5100 0.0752 0.448 0.000 0.036 0.516 0.000
#> SRR805815 4 0.0794 0.9301 0.028 0.000 0.000 0.972 0.000
#> SRR805816 1 0.5115 -0.0918 0.484 0.000 0.036 0.480 0.000
#> SRR805817 4 0.0794 0.9301 0.028 0.000 0.000 0.972 0.000
#> SRR805818 4 0.0955 0.9297 0.028 0.000 0.004 0.968 0.000
#> SRR805819 4 0.0794 0.9301 0.028 0.000 0.000 0.972 0.000
#> SRR805820 4 0.0955 0.9297 0.028 0.000 0.004 0.968 0.000
#> SRR805821 4 0.0794 0.9301 0.028 0.000 0.000 0.972 0.000
#> SRR805822 4 0.0794 0.9301 0.028 0.000 0.000 0.972 0.000
#> SRR805823 4 0.0955 0.9297 0.028 0.000 0.004 0.968 0.000
#> SRR805824 4 0.1082 0.9248 0.028 0.000 0.008 0.964 0.000
#> SRR805825 1 0.5196 0.4793 0.652 0.000 0.288 0.012 0.048
#> SRR805826 1 0.5225 0.4796 0.652 0.000 0.288 0.016 0.044
#> SRR805828 1 0.5340 0.4788 0.648 0.000 0.288 0.028 0.036
#> SRR805829 1 0.5340 0.4788 0.648 0.000 0.288 0.028 0.036
#> SRR805830 1 0.5340 0.4788 0.648 0.000 0.288 0.028 0.036
#> SRR805831 1 0.5340 0.4788 0.648 0.000 0.288 0.028 0.036
#> SRR805832 1 0.5196 0.4793 0.652 0.000 0.288 0.012 0.048
#> SRR805833 1 0.5196 0.4793 0.652 0.000 0.288 0.012 0.048
#> SRR805834 1 0.5196 0.4793 0.652 0.000 0.288 0.012 0.048
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0146 0.891 0.000 0.996 0.000 0.000 0.000 NA
#> SRR805781 2 0.3126 0.881 0.000 0.752 0.000 0.000 0.000 NA
#> SRR805782 2 0.3126 0.881 0.000 0.752 0.000 0.000 0.000 NA
#> SRR805784 2 0.3635 0.866 0.036 0.788 0.004 0.000 0.004 NA
#> SRR805785 2 0.0000 0.891 0.000 1.000 0.000 0.000 0.000 NA
#> SRR805786 2 0.0146 0.891 0.000 0.996 0.000 0.000 0.000 NA
#> SRR805787 2 0.2048 0.896 0.000 0.880 0.000 0.000 0.000 NA
#> SRR805788 2 0.2883 0.886 0.000 0.788 0.000 0.000 0.000 NA
#> SRR805789 2 0.0000 0.891 0.000 1.000 0.000 0.000 0.000 NA
#> SRR805790 2 0.2883 0.886 0.000 0.788 0.000 0.000 0.000 NA
#> SRR805791 1 0.6391 0.541 0.508 0.000 0.320 0.004 0.072 NA
#> SRR805792 1 0.6391 0.541 0.508 0.000 0.320 0.004 0.072 NA
#> SRR805793 1 0.6391 0.541 0.508 0.000 0.320 0.004 0.072 NA
#> SRR805794 1 0.6391 0.541 0.508 0.000 0.320 0.004 0.072 NA
#> SRR805795 1 0.3416 0.763 0.804 0.000 0.056 0.140 0.000 NA
#> SRR805796 1 0.3416 0.763 0.804 0.000 0.056 0.140 0.000 NA
#> SRR805797 1 0.3416 0.763 0.804 0.000 0.056 0.140 0.000 NA
#> SRR805798 1 0.3416 0.763 0.804 0.000 0.056 0.140 0.000 NA
#> SRR805799 1 0.5608 0.528 0.572 0.000 0.036 0.056 0.008 NA
#> SRR805800 1 0.3336 0.765 0.812 0.000 0.056 0.132 0.000 NA
#> SRR805801 1 0.3464 0.765 0.808 0.000 0.084 0.108 0.000 NA
#> SRR805802 5 0.0551 0.945 0.004 0.000 0.008 0.000 0.984 NA
#> SRR805803 2 0.3932 0.831 0.048 0.780 0.012 0.000 0.004 NA
#> SRR805804 2 0.3932 0.831 0.048 0.780 0.012 0.000 0.004 NA
#> SRR805805 5 0.0767 0.937 0.008 0.004 0.000 0.000 0.976 NA
#> SRR805806 5 0.0551 0.945 0.004 0.000 0.008 0.000 0.984 NA
#> SRR805807 1 0.5240 0.711 0.728 0.000 0.060 0.096 0.088 NA
#> SRR805808 5 0.0622 0.945 0.012 0.000 0.008 0.000 0.980 NA
#> SRR805809 5 0.1269 0.925 0.012 0.020 0.000 0.000 0.956 NA
#> SRR805810 5 0.0951 0.942 0.020 0.000 0.008 0.000 0.968 NA
#> SRR805811 5 0.4849 0.617 0.108 0.000 0.144 0.000 0.716 NA
#> SRR805812 5 0.0405 0.945 0.004 0.000 0.008 0.000 0.988 NA
#> SRR805813 4 0.0547 0.861 0.000 0.000 0.000 0.980 0.000 NA
#> SRR805814 4 0.6957 0.223 0.096 0.000 0.320 0.424 0.000 NA
#> SRR805815 4 0.0146 0.862 0.004 0.000 0.000 0.996 0.000 NA
#> SRR805816 4 0.6957 0.223 0.096 0.000 0.320 0.424 0.000 NA
#> SRR805817 4 0.0146 0.862 0.004 0.000 0.000 0.996 0.000 NA
#> SRR805818 4 0.1700 0.839 0.004 0.000 0.000 0.916 0.000 NA
#> SRR805819 4 0.0146 0.862 0.004 0.000 0.000 0.996 0.000 NA
#> SRR805820 4 0.0547 0.861 0.000 0.000 0.000 0.980 0.000 NA
#> SRR805821 4 0.1049 0.855 0.008 0.000 0.000 0.960 0.000 NA
#> SRR805822 4 0.1049 0.855 0.008 0.000 0.000 0.960 0.000 NA
#> SRR805823 4 0.1700 0.839 0.004 0.000 0.000 0.916 0.000 NA
#> SRR805824 4 0.1845 0.839 0.008 0.000 0.004 0.916 0.000 NA
#> SRR805825 3 0.0603 0.985 0.000 0.000 0.980 0.016 0.004 NA
#> SRR805826 3 0.0603 0.985 0.000 0.000 0.980 0.016 0.004 NA
#> SRR805828 3 0.1003 0.983 0.000 0.000 0.964 0.020 0.000 NA
#> SRR805829 3 0.1003 0.983 0.000 0.000 0.964 0.020 0.000 NA
#> SRR805830 3 0.1003 0.983 0.000 0.000 0.964 0.020 0.000 NA
#> SRR805831 3 0.1176 0.984 0.000 0.000 0.956 0.020 0.000 NA
#> SRR805832 3 0.0976 0.976 0.000 0.000 0.968 0.008 0.016 NA
#> SRR805833 3 0.0976 0.983 0.000 0.000 0.968 0.016 0.008 NA
#> SRR805834 3 0.0976 0.983 0.000 0.000 0.968 0.016 0.008 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.997 0.999 0.4700 0.531 0.531
#> 3 3 1.000 0.981 0.982 0.3502 0.837 0.693
#> 4 4 0.909 0.927 0.928 0.1376 0.888 0.696
#> 5 5 0.879 0.893 0.925 0.0812 0.936 0.754
#> 6 6 0.904 0.894 0.915 0.0421 0.956 0.793
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 4
There is also optional best \(k\) = 2 3 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.000 1.000 0.000 1.000
#> SRR805781 2 0.000 1.000 0.000 1.000
#> SRR805782 2 0.000 1.000 0.000 1.000
#> SRR805784 2 0.000 1.000 0.000 1.000
#> SRR805785 2 0.000 1.000 0.000 1.000
#> SRR805786 2 0.000 1.000 0.000 1.000
#> SRR805787 2 0.000 1.000 0.000 1.000
#> SRR805788 2 0.000 1.000 0.000 1.000
#> SRR805789 2 0.000 1.000 0.000 1.000
#> SRR805790 2 0.000 1.000 0.000 1.000
#> SRR805791 1 0.000 0.998 1.000 0.000
#> SRR805792 1 0.000 0.998 1.000 0.000
#> SRR805793 1 0.000 0.998 1.000 0.000
#> SRR805794 1 0.000 0.998 1.000 0.000
#> SRR805795 1 0.000 0.998 1.000 0.000
#> SRR805796 1 0.000 0.998 1.000 0.000
#> SRR805797 1 0.000 0.998 1.000 0.000
#> SRR805798 1 0.000 0.998 1.000 0.000
#> SRR805799 1 0.000 0.998 1.000 0.000
#> SRR805800 1 0.000 0.998 1.000 0.000
#> SRR805801 1 0.000 0.998 1.000 0.000
#> SRR805802 2 0.000 1.000 0.000 1.000
#> SRR805803 2 0.000 1.000 0.000 1.000
#> SRR805804 2 0.000 1.000 0.000 1.000
#> SRR805805 2 0.000 1.000 0.000 1.000
#> SRR805806 2 0.000 1.000 0.000 1.000
#> SRR805807 1 0.000 0.998 1.000 0.000
#> SRR805808 2 0.000 1.000 0.000 1.000
#> SRR805809 2 0.000 1.000 0.000 1.000
#> SRR805810 2 0.000 1.000 0.000 1.000
#> SRR805811 1 0.000 0.998 1.000 0.000
#> SRR805812 2 0.000 1.000 0.000 1.000
#> SRR805813 1 0.000 0.998 1.000 0.000
#> SRR805814 1 0.000 0.998 1.000 0.000
#> SRR805815 1 0.000 0.998 1.000 0.000
#> SRR805816 1 0.000 0.998 1.000 0.000
#> SRR805817 1 0.000 0.998 1.000 0.000
#> SRR805818 1 0.000 0.998 1.000 0.000
#> SRR805819 1 0.000 0.998 1.000 0.000
#> SRR805820 1 0.000 0.998 1.000 0.000
#> SRR805821 1 0.000 0.998 1.000 0.000
#> SRR805822 1 0.000 0.998 1.000 0.000
#> SRR805823 1 0.000 0.998 1.000 0.000
#> SRR805824 1 0.000 0.998 1.000 0.000
#> SRR805825 1 0.000 0.998 1.000 0.000
#> SRR805826 1 0.000 0.998 1.000 0.000
#> SRR805828 1 0.000 0.998 1.000 0.000
#> SRR805829 1 0.000 0.998 1.000 0.000
#> SRR805830 1 0.000 0.998 1.000 0.000
#> SRR805831 1 0.000 0.998 1.000 0.000
#> SRR805832 1 0.343 0.932 0.936 0.064
#> SRR805833 1 0.000 0.998 1.000 0.000
#> SRR805834 1 0.000 0.998 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR805780 2 0.0000 1.000 0.000 1 0.000
#> SRR805781 2 0.0000 1.000 0.000 1 0.000
#> SRR805782 2 0.0000 1.000 0.000 1 0.000
#> SRR805784 2 0.0000 1.000 0.000 1 0.000
#> SRR805785 2 0.0000 1.000 0.000 1 0.000
#> SRR805786 2 0.0000 1.000 0.000 1 0.000
#> SRR805787 2 0.0000 1.000 0.000 1 0.000
#> SRR805788 2 0.0000 1.000 0.000 1 0.000
#> SRR805789 2 0.0000 1.000 0.000 1 0.000
#> SRR805790 2 0.0000 1.000 0.000 1 0.000
#> SRR805791 1 0.0592 0.957 0.988 0 0.012
#> SRR805792 1 0.0592 0.957 0.988 0 0.012
#> SRR805793 1 0.0592 0.957 0.988 0 0.012
#> SRR805794 1 0.0592 0.957 0.988 0 0.012
#> SRR805795 1 0.0000 0.962 1.000 0 0.000
#> SRR805796 1 0.0000 0.962 1.000 0 0.000
#> SRR805797 1 0.0000 0.962 1.000 0 0.000
#> SRR805798 1 0.0000 0.962 1.000 0 0.000
#> SRR805799 1 0.0000 0.962 1.000 0 0.000
#> SRR805800 1 0.0000 0.962 1.000 0 0.000
#> SRR805801 1 0.0000 0.962 1.000 0 0.000
#> SRR805802 2 0.0000 1.000 0.000 1 0.000
#> SRR805803 2 0.0000 1.000 0.000 1 0.000
#> SRR805804 2 0.0000 1.000 0.000 1 0.000
#> SRR805805 2 0.0000 1.000 0.000 1 0.000
#> SRR805806 2 0.0000 1.000 0.000 1 0.000
#> SRR805807 1 0.0592 0.963 0.988 0 0.012
#> SRR805808 2 0.0000 1.000 0.000 1 0.000
#> SRR805809 2 0.0000 1.000 0.000 1 0.000
#> SRR805810 2 0.0000 1.000 0.000 1 0.000
#> SRR805811 1 0.0592 0.963 0.988 0 0.012
#> SRR805812 2 0.0000 1.000 0.000 1 0.000
#> SRR805813 1 0.2261 0.961 0.932 0 0.068
#> SRR805814 1 0.2261 0.961 0.932 0 0.068
#> SRR805815 1 0.2261 0.961 0.932 0 0.068
#> SRR805816 1 0.2261 0.961 0.932 0 0.068
#> SRR805817 1 0.2261 0.961 0.932 0 0.068
#> SRR805818 1 0.2261 0.961 0.932 0 0.068
#> SRR805819 1 0.2261 0.961 0.932 0 0.068
#> SRR805820 1 0.2261 0.961 0.932 0 0.068
#> SRR805821 1 0.2261 0.961 0.932 0 0.068
#> SRR805822 1 0.2261 0.961 0.932 0 0.068
#> SRR805823 1 0.2261 0.961 0.932 0 0.068
#> SRR805824 1 0.2261 0.961 0.932 0 0.068
#> SRR805825 3 0.0000 0.993 0.000 0 1.000
#> SRR805826 3 0.0237 0.996 0.004 0 0.996
#> SRR805828 3 0.0592 0.993 0.012 0 0.988
#> SRR805829 3 0.0424 0.995 0.008 0 0.992
#> SRR805830 3 0.0424 0.995 0.008 0 0.992
#> SRR805831 3 0.0592 0.993 0.012 0 0.988
#> SRR805832 3 0.0000 0.993 0.000 0 1.000
#> SRR805833 3 0.0237 0.996 0.004 0 0.996
#> SRR805834 3 0.0237 0.996 0.004 0 0.996
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.0000 0.984 0.000 1.000 0.000 0.000
#> SRR805781 2 0.0000 0.984 0.000 1.000 0.000 0.000
#> SRR805782 2 0.0000 0.984 0.000 1.000 0.000 0.000
#> SRR805784 2 0.0000 0.984 0.000 1.000 0.000 0.000
#> SRR805785 2 0.0000 0.984 0.000 1.000 0.000 0.000
#> SRR805786 2 0.0000 0.984 0.000 1.000 0.000 0.000
#> SRR805787 2 0.0000 0.984 0.000 1.000 0.000 0.000
#> SRR805788 2 0.0000 0.984 0.000 1.000 0.000 0.000
#> SRR805789 2 0.0000 0.984 0.000 1.000 0.000 0.000
#> SRR805790 2 0.0000 0.984 0.000 1.000 0.000 0.000
#> SRR805791 1 0.4776 0.668 0.624 0.000 0.000 0.376
#> SRR805792 1 0.4776 0.668 0.624 0.000 0.000 0.376
#> SRR805793 1 0.4776 0.668 0.624 0.000 0.000 0.376
#> SRR805794 1 0.4776 0.668 0.624 0.000 0.000 0.376
#> SRR805795 1 0.0000 0.730 1.000 0.000 0.000 0.000
#> SRR805796 1 0.0000 0.730 1.000 0.000 0.000 0.000
#> SRR805797 1 0.0000 0.730 1.000 0.000 0.000 0.000
#> SRR805798 1 0.0000 0.730 1.000 0.000 0.000 0.000
#> SRR805799 1 0.0188 0.723 0.996 0.000 0.000 0.004
#> SRR805800 1 0.0000 0.730 1.000 0.000 0.000 0.000
#> SRR805801 1 0.0000 0.730 1.000 0.000 0.000 0.000
#> SRR805802 2 0.1792 0.957 0.000 0.932 0.000 0.068
#> SRR805803 2 0.0000 0.984 0.000 1.000 0.000 0.000
#> SRR805804 2 0.0000 0.984 0.000 1.000 0.000 0.000
#> SRR805805 2 0.1557 0.963 0.000 0.944 0.000 0.056
#> SRR805806 2 0.1792 0.957 0.000 0.932 0.000 0.068
#> SRR805807 4 0.4948 0.987 0.440 0.000 0.000 0.560
#> SRR805808 2 0.1022 0.973 0.000 0.968 0.000 0.032
#> SRR805809 2 0.0000 0.984 0.000 1.000 0.000 0.000
#> SRR805810 2 0.1716 0.959 0.000 0.936 0.000 0.064
#> SRR805811 4 0.4817 0.908 0.388 0.000 0.000 0.612
#> SRR805812 2 0.1792 0.957 0.000 0.932 0.000 0.068
#> SRR805813 4 0.5119 0.992 0.440 0.000 0.004 0.556
#> SRR805814 4 0.5119 0.992 0.440 0.000 0.004 0.556
#> SRR805815 4 0.5119 0.992 0.440 0.000 0.004 0.556
#> SRR805816 4 0.5119 0.992 0.440 0.000 0.004 0.556
#> SRR805817 4 0.5119 0.992 0.440 0.000 0.004 0.556
#> SRR805818 4 0.5119 0.992 0.440 0.000 0.004 0.556
#> SRR805819 4 0.5119 0.992 0.440 0.000 0.004 0.556
#> SRR805820 4 0.5119 0.992 0.440 0.000 0.004 0.556
#> SRR805821 4 0.5119 0.992 0.440 0.000 0.004 0.556
#> SRR805822 4 0.5119 0.992 0.440 0.000 0.004 0.556
#> SRR805823 4 0.5119 0.992 0.440 0.000 0.004 0.556
#> SRR805824 4 0.5250 0.987 0.440 0.000 0.008 0.552
#> SRR805825 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805826 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805828 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805829 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805830 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805831 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805832 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805833 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR805834 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
#> SRR805780 2 0.0000 0.971 0.000 1.000 0.000 0.000 0.000
#> SRR805781 2 0.0000 0.971 0.000 1.000 0.000 0.000 0.000
#> SRR805782 2 0.0000 0.971 0.000 1.000 0.000 0.000 0.000
#> SRR805784 2 0.0000 0.971 0.000 1.000 0.000 0.000 0.000
#> SRR805785 2 0.0000 0.971 0.000 1.000 0.000 0.000 0.000
#> SRR805786 2 0.0000 0.971 0.000 1.000 0.000 0.000 0.000
#> SRR805787 2 0.0000 0.971 0.000 1.000 0.000 0.000 0.000
#> SRR805788 2 0.0000 0.971 0.000 1.000 0.000 0.000 0.000
#> SRR805789 2 0.0000 0.971 0.000 1.000 0.000 0.000 0.000
#> SRR805790 2 0.0000 0.971 0.000 1.000 0.000 0.000 0.000
#> SRR805791 1 0.1197 0.593 0.952 0.000 0.000 0.000 0.048
#> SRR805792 1 0.1197 0.593 0.952 0.000 0.000 0.000 0.048
#> SRR805793 1 0.1197 0.593 0.952 0.000 0.000 0.000 0.048
#> SRR805794 1 0.1197 0.593 0.952 0.000 0.000 0.000 0.048
#> SRR805795 1 0.4088 0.740 0.632 0.000 0.000 0.368 0.000
#> SRR805796 1 0.4088 0.740 0.632 0.000 0.000 0.368 0.000
#> SRR805797 1 0.4088 0.740 0.632 0.000 0.000 0.368 0.000
#> SRR805798 1 0.4088 0.740 0.632 0.000 0.000 0.368 0.000
#> SRR805799 1 0.4150 0.709 0.612 0.000 0.000 0.388 0.000
#> SRR805800 1 0.4088 0.740 0.632 0.000 0.000 0.368 0.000
#> SRR805801 1 0.4088 0.740 0.632 0.000 0.000 0.368 0.000
#> SRR805802 5 0.1341 0.891 0.000 0.056 0.000 0.000 0.944
#> SRR805803 2 0.0000 0.971 0.000 1.000 0.000 0.000 0.000
#> SRR805804 2 0.0000 0.971 0.000 1.000 0.000 0.000 0.000
#> SRR805805 5 0.3210 0.754 0.000 0.212 0.000 0.000 0.788
#> SRR805806 5 0.1270 0.890 0.000 0.052 0.000 0.000 0.948
#> SRR805807 4 0.1197 0.933 0.048 0.000 0.000 0.952 0.000
#> SRR805808 2 0.3949 0.426 0.000 0.668 0.000 0.000 0.332
#> SRR805809 2 0.0000 0.971 0.000 1.000 0.000 0.000 0.000
#> SRR805810 5 0.1908 0.879 0.000 0.092 0.000 0.000 0.908
#> SRR805811 5 0.4237 0.600 0.048 0.000 0.000 0.200 0.752
#> SRR805812 5 0.1270 0.890 0.000 0.052 0.000 0.000 0.948
#> SRR805813 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000
#> SRR805814 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000
#> SRR805815 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000
#> SRR805816 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000
#> SRR805817 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000
#> SRR805818 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000
#> SRR805819 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000
#> SRR805820 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000
#> SRR805821 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000
#> SRR805822 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000
#> SRR805823 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000
#> SRR805824 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000
#> SRR805825 3 0.0162 0.998 0.000 0.000 0.996 0.000 0.004
#> SRR805826 3 0.0000 0.998 0.000 0.000 1.000 0.000 0.000
#> SRR805828 3 0.0162 0.994 0.000 0.000 0.996 0.004 0.000
#> SRR805829 3 0.0000 0.998 0.000 0.000 1.000 0.000 0.000
#> SRR805830 3 0.0000 0.998 0.000 0.000 1.000 0.000 0.000
#> SRR805831 3 0.0000 0.998 0.000 0.000 1.000 0.000 0.000
#> SRR805832 3 0.0162 0.998 0.000 0.000 0.996 0.000 0.004
#> SRR805833 3 0.0162 0.998 0.000 0.000 0.996 0.000 0.004
#> SRR805834 3 0.0162 0.998 0.000 0.000 0.996 0.000 0.004
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0000 0.9596 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805781 2 0.0000 0.9596 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805782 2 0.0000 0.9596 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805784 2 0.0000 0.9596 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805785 2 0.0000 0.9596 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805786 2 0.0000 0.9596 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805787 2 0.0000 0.9596 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805788 2 0.0000 0.9596 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805789 2 0.0000 0.9596 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805790 2 0.0000 0.9596 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805791 6 0.0000 1.0000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805792 6 0.0000 1.0000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805793 6 0.0000 1.0000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805794 6 0.0000 1.0000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR805795 1 0.5618 0.7794 0.536 0.000 0.000 0.196 0.000 0.268
#> SRR805796 1 0.5618 0.7794 0.536 0.000 0.000 0.196 0.000 0.268
#> SRR805797 1 0.5618 0.7794 0.536 0.000 0.000 0.196 0.000 0.268
#> SRR805798 1 0.5618 0.7794 0.536 0.000 0.000 0.196 0.000 0.268
#> SRR805799 1 0.3469 0.6160 0.808 0.000 0.000 0.104 0.000 0.088
#> SRR805800 1 0.5618 0.7794 0.536 0.000 0.000 0.196 0.000 0.268
#> SRR805801 1 0.5618 0.7794 0.536 0.000 0.000 0.196 0.000 0.268
#> SRR805802 5 0.0520 0.9208 0.008 0.008 0.000 0.000 0.984 0.000
#> SRR805803 2 0.0000 0.9596 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805804 2 0.0000 0.9596 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR805805 5 0.1584 0.8835 0.008 0.064 0.000 0.000 0.928 0.000
#> SRR805806 5 0.0260 0.9210 0.008 0.000 0.000 0.000 0.992 0.000
#> SRR805807 1 0.2146 0.5466 0.880 0.000 0.000 0.116 0.004 0.000
#> SRR805808 2 0.4778 0.0837 0.052 0.524 0.000 0.000 0.424 0.000
#> SRR805809 2 0.0713 0.9349 0.000 0.972 0.000 0.000 0.028 0.000
#> SRR805810 5 0.3803 0.7943 0.184 0.056 0.000 0.000 0.760 0.000
#> SRR805811 1 0.4872 -0.2119 0.548 0.000 0.000 0.064 0.388 0.000
#> SRR805812 5 0.0146 0.9217 0.004 0.000 0.000 0.000 0.996 0.000
#> SRR805813 4 0.0000 0.9982 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805814 4 0.0000 0.9982 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805815 4 0.0000 0.9982 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805816 4 0.0000 0.9982 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805817 4 0.0000 0.9982 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805818 4 0.0000 0.9982 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805819 4 0.0000 0.9982 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805820 4 0.0000 0.9982 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805821 4 0.0000 0.9982 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805822 4 0.0000 0.9982 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805823 4 0.0000 0.9982 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR805824 4 0.0458 0.9801 0.000 0.000 0.016 0.984 0.000 0.000
#> SRR805825 3 0.0632 0.9821 0.024 0.000 0.976 0.000 0.000 0.000
#> SRR805826 3 0.0000 0.9845 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805828 3 0.0260 0.9795 0.000 0.000 0.992 0.008 0.000 0.000
#> SRR805829 3 0.0000 0.9845 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805830 3 0.0000 0.9845 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805831 3 0.0000 0.9845 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805832 3 0.0937 0.9784 0.040 0.000 0.960 0.000 0.000 0.000
#> SRR805833 3 0.0937 0.9784 0.040 0.000 0.960 0.000 0.000 0.000
#> SRR805834 3 0.0937 0.9784 0.040 0.000 0.960 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "pam"]
# you can also extract it by
# res = res_list["ATC:pam"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 15291 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.960 0.923 0.971 0.4210 0.604 0.604
#> 3 3 0.781 0.841 0.937 0.4990 0.692 0.519
#> 4 4 0.740 0.538 0.695 0.1723 0.788 0.490
#> 5 5 0.944 0.926 0.966 0.0940 0.898 0.625
#> 6 6 1.000 0.950 0.979 0.0317 0.977 0.877
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 5
There is also optional best \(k\) = 2 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR805780 2 0.000 1.000 0.000 1.000
#> SRR805781 2 0.000 1.000 0.000 1.000
#> SRR805782 2 0.000 1.000 0.000 1.000
#> SRR805784 2 0.000 1.000 0.000 1.000
#> SRR805785 2 0.000 1.000 0.000 1.000
#> SRR805786 2 0.000 1.000 0.000 1.000
#> SRR805787 2 0.000 1.000 0.000 1.000
#> SRR805788 2 0.000 1.000 0.000 1.000
#> SRR805789 2 0.000 1.000 0.000 1.000
#> SRR805790 2 0.000 1.000 0.000 1.000
#> SRR805791 1 0.000 0.958 1.000 0.000
#> SRR805792 1 0.000 0.958 1.000 0.000
#> SRR805793 1 0.000 0.958 1.000 0.000
#> SRR805794 1 0.000 0.958 1.000 0.000
#> SRR805795 1 0.000 0.958 1.000 0.000
#> SRR805796 1 0.000 0.958 1.000 0.000
#> SRR805797 1 0.000 0.958 1.000 0.000
#> SRR805798 1 0.000 0.958 1.000 0.000
#> SRR805799 1 0.000 0.958 1.000 0.000
#> SRR805800 1 0.000 0.958 1.000 0.000
#> SRR805801 1 0.000 0.958 1.000 0.000
#> SRR805802 1 0.605 0.805 0.852 0.148
#> SRR805803 2 0.000 1.000 0.000 1.000
#> SRR805804 2 0.000 1.000 0.000 1.000
#> SRR805805 2 0.000 1.000 0.000 1.000
#> SRR805806 1 0.000 0.958 1.000 0.000
#> SRR805807 1 0.000 0.958 1.000 0.000
#> SRR805808 1 0.997 0.181 0.532 0.468
#> SRR805809 2 0.000 1.000 0.000 1.000
#> SRR805810 1 0.996 0.193 0.536 0.464
#> SRR805811 1 0.000 0.958 1.000 0.000
#> SRR805812 1 0.996 0.193 0.536 0.464
#> SRR805813 1 0.000 0.958 1.000 0.000
#> SRR805814 1 0.000 0.958 1.000 0.000
#> SRR805815 1 0.000 0.958 1.000 0.000
#> SRR805816 1 0.000 0.958 1.000 0.000
#> SRR805817 1 0.000 0.958 1.000 0.000
#> SRR805818 1 0.000 0.958 1.000 0.000
#> SRR805819 1 0.000 0.958 1.000 0.000
#> SRR805820 1 0.000 0.958 1.000 0.000
#> SRR805821 1 0.000 0.958 1.000 0.000
#> SRR805822 1 0.000 0.958 1.000 0.000
#> SRR805823 1 0.000 0.958 1.000 0.000
#> SRR805824 1 0.000 0.958 1.000 0.000
#> SRR805825 1 0.000 0.958 1.000 0.000
#> SRR805826 1 0.000 0.958 1.000 0.000
#> SRR805828 1 0.000 0.958 1.000 0.000
#> SRR805829 1 0.000 0.958 1.000 0.000
#> SRR805830 1 0.000 0.958 1.000 0.000
#> SRR805831 1 0.000 0.958 1.000 0.000
#> SRR805832 1 0.000 0.958 1.000 0.000
#> SRR805833 1 0.000 0.958 1.000 0.000
#> SRR805834 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
#> SRR805780 2 0.0000 1.000 0.000 1.000 0.000
#> SRR805781 2 0.0000 1.000 0.000 1.000 0.000
#> SRR805782 2 0.0000 1.000 0.000 1.000 0.000
#> SRR805784 2 0.0000 1.000 0.000 1.000 0.000
#> SRR805785 2 0.0000 1.000 0.000 1.000 0.000
#> SRR805786 2 0.0000 1.000 0.000 1.000 0.000
#> SRR805787 2 0.0000 1.000 0.000 1.000 0.000
#> SRR805788 2 0.0000 1.000 0.000 1.000 0.000
#> SRR805789 2 0.0000 1.000 0.000 1.000 0.000
#> SRR805790 2 0.0000 1.000 0.000 1.000 0.000
#> SRR805791 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805792 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805793 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805794 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805795 3 0.6154 0.309 0.408 0.000 0.592
#> SRR805796 1 0.6154 0.223 0.592 0.000 0.408
#> SRR805797 3 0.5988 0.408 0.368 0.000 0.632
#> SRR805798 3 0.4504 0.726 0.196 0.000 0.804
#> SRR805799 3 0.4291 0.747 0.180 0.000 0.820
#> SRR805800 3 0.0592 0.916 0.012 0.000 0.988
#> SRR805801 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805802 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805803 2 0.0000 1.000 0.000 1.000 0.000
#> SRR805804 2 0.0000 1.000 0.000 1.000 0.000
#> SRR805805 3 0.3116 0.833 0.000 0.108 0.892
#> SRR805806 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805807 3 0.1031 0.907 0.024 0.000 0.976
#> SRR805808 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805809 3 0.4974 0.682 0.000 0.236 0.764
#> SRR805810 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805811 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805812 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805813 1 0.0000 0.840 1.000 0.000 0.000
#> SRR805814 1 0.5905 0.495 0.648 0.000 0.352
#> SRR805815 1 0.0000 0.840 1.000 0.000 0.000
#> SRR805816 1 0.6192 0.367 0.580 0.000 0.420
#> SRR805817 1 0.0000 0.840 1.000 0.000 0.000
#> SRR805818 1 0.0000 0.840 1.000 0.000 0.000
#> SRR805819 1 0.0000 0.840 1.000 0.000 0.000
#> SRR805820 1 0.0000 0.840 1.000 0.000 0.000
#> SRR805821 1 0.0000 0.840 1.000 0.000 0.000
#> SRR805822 1 0.0000 0.840 1.000 0.000 0.000
#> SRR805823 1 0.0000 0.840 1.000 0.000 0.000
#> SRR805824 1 0.0000 0.840 1.000 0.000 0.000
#> SRR805825 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805826 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805828 1 0.6307 0.184 0.512 0.000 0.488
#> SRR805829 3 0.3619 0.776 0.136 0.000 0.864
#> SRR805830 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805831 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805832 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805833 3 0.0000 0.923 0.000 0.000 1.000
#> SRR805834 3 0.0000 0.923 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR805781 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR805782 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR805784 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR805785 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR805786 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR805787 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR805788 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR805789 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR805790 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR805791 1 0.0592 0.588 0.984 0.000 0.016 0.000
#> SRR805792 1 0.0469 0.588 0.988 0.000 0.012 0.000
#> SRR805793 1 0.0592 0.588 0.984 0.000 0.016 0.000
#> SRR805794 1 0.0469 0.588 0.988 0.000 0.012 0.000
#> SRR805795 1 0.4967 -0.387 0.548 0.000 0.000 0.452
#> SRR805796 1 0.4967 -0.387 0.548 0.000 0.000 0.452
#> SRR805797 1 0.4961 -0.377 0.552 0.000 0.000 0.448
#> SRR805798 1 0.4933 -0.343 0.568 0.000 0.000 0.432
#> SRR805799 1 0.3837 0.274 0.776 0.000 0.000 0.224
#> SRR805800 1 0.2149 0.519 0.912 0.000 0.000 0.088
#> SRR805801 1 0.0000 0.588 1.000 0.000 0.000 0.000
#> SRR805802 3 0.7588 0.312 0.216 0.000 0.464 0.320
#> SRR805803 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR805804 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR805805 3 0.7732 0.312 0.212 0.004 0.464 0.320
#> SRR805806 3 0.7588 0.312 0.216 0.000 0.464 0.320
#> SRR805807 1 0.0921 0.582 0.972 0.000 0.028 0.000
#> SRR805808 3 0.7588 0.312 0.216 0.000 0.464 0.320
#> SRR805809 3 0.8023 0.308 0.204 0.016 0.460 0.320
#> SRR805810 3 0.7588 0.312 0.216 0.000 0.464 0.320
#> SRR805811 3 0.7588 0.312 0.216 0.000 0.464 0.320
#> SRR805812 3 0.7588 0.312 0.216 0.000 0.464 0.320
#> SRR805813 4 0.4522 1.000 0.320 0.000 0.000 0.680
#> SRR805814 1 0.7626 -0.113 0.448 0.000 0.336 0.216
#> SRR805815 4 0.4522 1.000 0.320 0.000 0.000 0.680
#> SRR805816 1 0.7659 -0.104 0.444 0.000 0.332 0.224
#> SRR805817 4 0.4522 1.000 0.320 0.000 0.000 0.680
#> SRR805818 4 0.4522 1.000 0.320 0.000 0.000 0.680
#> SRR805819 4 0.4522 1.000 0.320 0.000 0.000 0.680
#> SRR805820 4 0.4522 1.000 0.320 0.000 0.000 0.680
#> SRR805821 4 0.4522 1.000 0.320 0.000 0.000 0.680
#> SRR805822 4 0.4522 1.000 0.320 0.000 0.000 0.680
#> SRR805823 4 0.4522 1.000 0.320 0.000 0.000 0.680
#> SRR805824 3 0.5161 -0.189 0.004 0.000 0.520 0.476
#> SRR805825 3 0.4967 0.293 0.452 0.000 0.548 0.000
#> SRR805826 3 0.4967 0.293 0.452 0.000 0.548 0.000
#> SRR805828 3 0.4981 0.284 0.464 0.000 0.536 0.000
#> SRR805829 3 0.4977 0.288 0.460 0.000 0.540 0.000
#> SRR805830 3 0.4967 0.293 0.452 0.000 0.548 0.000
#> SRR805831 3 0.4981 0.284 0.464 0.000 0.536 0.000
#> SRR805832 3 0.4967 0.293 0.452 0.000 0.548 0.000
#> SRR805833 3 0.4967 0.293 0.452 0.000 0.548 0.000
#> SRR805834 3 0.4967 0.293 0.452 0.000 0.548 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.000 1.000 0.000 1 0.000 0.000 0
#> SRR805781 2 0.000 1.000 0.000 1 0.000 0.000 0
#> SRR805782 2 0.000 1.000 0.000 1 0.000 0.000 0
#> SRR805784 2 0.000 1.000 0.000 1 0.000 0.000 0
#> SRR805785 2 0.000 1.000 0.000 1 0.000 0.000 0
#> SRR805786 2 0.000 1.000 0.000 1 0.000 0.000 0
#> SRR805787 2 0.000 1.000 0.000 1 0.000 0.000 0
#> SRR805788 2 0.000 1.000 0.000 1 0.000 0.000 0
#> SRR805789 2 0.000 1.000 0.000 1 0.000 0.000 0
#> SRR805790 2 0.000 1.000 0.000 1 0.000 0.000 0
#> SRR805791 1 0.314 0.803 0.796 0 0.204 0.000 0
#> SRR805792 1 0.314 0.803 0.796 0 0.204 0.000 0
#> SRR805793 1 0.318 0.799 0.792 0 0.208 0.000 0
#> SRR805794 1 0.318 0.799 0.792 0 0.208 0.000 0
#> SRR805795 1 0.000 0.917 1.000 0 0.000 0.000 0
#> SRR805796 1 0.000 0.917 1.000 0 0.000 0.000 0
#> SRR805797 1 0.000 0.917 1.000 0 0.000 0.000 0
#> SRR805798 1 0.000 0.917 1.000 0 0.000 0.000 0
#> SRR805799 1 0.000 0.917 1.000 0 0.000 0.000 0
#> SRR805800 1 0.000 0.917 1.000 0 0.000 0.000 0
#> SRR805801 1 0.000 0.917 1.000 0 0.000 0.000 0
#> SRR805802 5 0.000 1.000 0.000 0 0.000 0.000 1
#> SRR805803 2 0.000 1.000 0.000 1 0.000 0.000 0
#> SRR805804 2 0.000 1.000 0.000 1 0.000 0.000 0
#> SRR805805 5 0.000 1.000 0.000 0 0.000 0.000 1
#> SRR805806 5 0.000 1.000 0.000 0 0.000 0.000 1
#> SRR805807 1 0.000 0.917 1.000 0 0.000 0.000 0
#> SRR805808 5 0.000 1.000 0.000 0 0.000 0.000 1
#> SRR805809 5 0.000 1.000 0.000 0 0.000 0.000 1
#> SRR805810 5 0.000 1.000 0.000 0 0.000 0.000 1
#> SRR805811 5 0.000 1.000 0.000 0 0.000 0.000 1
#> SRR805812 5 0.000 1.000 0.000 0 0.000 0.000 1
#> SRR805813 4 0.000 0.975 0.000 0 0.000 1.000 0
#> SRR805814 3 0.415 0.432 0.000 0 0.612 0.388 0
#> SRR805815 4 0.000 0.975 0.000 0 0.000 1.000 0
#> SRR805816 3 0.464 0.389 0.016 0 0.584 0.400 0
#> SRR805817 4 0.000 0.975 0.000 0 0.000 1.000 0
#> SRR805818 4 0.000 0.975 0.000 0 0.000 1.000 0
#> SRR805819 4 0.000 0.975 0.000 0 0.000 1.000 0
#> SRR805820 4 0.000 0.975 0.000 0 0.000 1.000 0
#> SRR805821 4 0.000 0.975 0.000 0 0.000 1.000 0
#> SRR805822 4 0.000 0.975 0.000 0 0.000 1.000 0
#> SRR805823 4 0.000 0.975 0.000 0 0.000 1.000 0
#> SRR805824 4 0.311 0.724 0.000 0 0.200 0.800 0
#> SRR805825 3 0.000 0.914 0.000 0 1.000 0.000 0
#> SRR805826 3 0.000 0.914 0.000 0 1.000 0.000 0
#> SRR805828 3 0.000 0.914 0.000 0 1.000 0.000 0
#> SRR805829 3 0.000 0.914 0.000 0 1.000 0.000 0
#> SRR805830 3 0.000 0.914 0.000 0 1.000 0.000 0
#> SRR805831 3 0.000 0.914 0.000 0 1.000 0.000 0
#> SRR805832 3 0.000 0.914 0.000 0 1.000 0.000 0
#> SRR805833 3 0.000 0.914 0.000 0 1.000 0.000 0
#> SRR805834 3 0.000 0.914 0.000 0 1.000 0.000 0
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> SRR805781 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> SRR805782 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> SRR805784 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> SRR805785 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> SRR805786 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> SRR805787 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> SRR805788 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> SRR805789 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> SRR805790 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> SRR805791 6 0.0000 1.000 0 0 0.000 0.000 0.000 1.000
#> SRR805792 6 0.0000 1.000 0 0 0.000 0.000 0.000 1.000
#> SRR805793 6 0.0000 1.000 0 0 0.000 0.000 0.000 1.000
#> SRR805794 6 0.0000 1.000 0 0 0.000 0.000 0.000 1.000
#> SRR805795 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> SRR805796 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> SRR805797 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> SRR805798 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> SRR805799 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> SRR805800 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> SRR805801 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> SRR805802 5 0.0000 0.997 0 0 0.000 0.000 1.000 0.000
#> SRR805803 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> SRR805804 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> SRR805805 5 0.0000 0.997 0 0 0.000 0.000 1.000 0.000
#> SRR805806 5 0.0000 0.997 0 0 0.000 0.000 1.000 0.000
#> SRR805807 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> SRR805808 5 0.0000 0.997 0 0 0.000 0.000 1.000 0.000
#> SRR805809 5 0.0000 0.997 0 0 0.000 0.000 1.000 0.000
#> SRR805810 5 0.0000 0.997 0 0 0.000 0.000 1.000 0.000
#> SRR805811 5 0.0632 0.975 0 0 0.000 0.000 0.976 0.024
#> SRR805812 5 0.0000 0.997 0 0 0.000 0.000 1.000 0.000
#> SRR805813 4 0.0000 0.973 0 0 0.000 1.000 0.000 0.000
#> SRR805814 3 0.4855 0.463 0 0 0.596 0.328 0.000 0.076
#> SRR805815 4 0.0000 0.973 0 0 0.000 1.000 0.000 0.000
#> SRR805816 3 0.4893 0.312 0 0 0.536 0.400 0.000 0.064
#> SRR805817 4 0.0000 0.973 0 0 0.000 1.000 0.000 0.000
#> SRR805818 4 0.0000 0.973 0 0 0.000 1.000 0.000 0.000
#> SRR805819 4 0.0000 0.973 0 0 0.000 1.000 0.000 0.000
#> SRR805820 4 0.0000 0.973 0 0 0.000 1.000 0.000 0.000
#> SRR805821 4 0.0000 0.973 0 0 0.000 1.000 0.000 0.000
#> SRR805822 4 0.0000 0.973 0 0 0.000 1.000 0.000 0.000
#> SRR805823 4 0.0000 0.973 0 0 0.000 1.000 0.000 0.000
#> SRR805824 4 0.2793 0.722 0 0 0.200 0.800 0.000 0.000
#> SRR805825 3 0.0000 0.903 0 0 1.000 0.000 0.000 0.000
#> SRR805826 3 0.0000 0.903 0 0 1.000 0.000 0.000 0.000
#> SRR805828 3 0.0000 0.903 0 0 1.000 0.000 0.000 0.000
#> SRR805829 3 0.0000 0.903 0 0 1.000 0.000 0.000 0.000
#> SRR805830 3 0.0000 0.903 0 0 1.000 0.000 0.000 0.000
#> SRR805831 3 0.0000 0.903 0 0 1.000 0.000 0.000 0.000
#> SRR805832 3 0.0000 0.903 0 0 1.000 0.000 0.000 0.000
#> SRR805833 3 0.0000 0.903 0 0 1.000 0.000 0.000 0.000
#> SRR805834 3 0.0000 0.903 0 0 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 15291 rows and 53 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 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.997 0.998 0.4886 0.512 0.512
#> 3 3 0.802 0.805 0.806 0.3362 0.814 0.637
#> 4 4 0.793 0.838 0.847 0.0966 0.860 0.608
#> 5 5 0.887 0.877 0.934 0.0837 0.980 0.918
#> 6 6 0.812 0.732 0.836 0.0431 0.946 0.772
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
#> SRR805780 2 0.0000 0.997 0.000 1.000
#> SRR805781 2 0.0000 0.997 0.000 1.000
#> SRR805782 2 0.0000 0.997 0.000 1.000
#> SRR805784 2 0.0000 0.997 0.000 1.000
#> SRR805785 2 0.0000 0.997 0.000 1.000
#> SRR805786 2 0.0000 0.997 0.000 1.000
#> SRR805787 2 0.0000 0.997 0.000 1.000
#> SRR805788 2 0.0000 0.997 0.000 1.000
#> SRR805789 2 0.0000 0.997 0.000 1.000
#> SRR805790 2 0.0000 0.997 0.000 1.000
#> SRR805791 2 0.0000 0.997 0.000 1.000
#> SRR805792 2 0.0000 0.997 0.000 1.000
#> SRR805793 2 0.0000 0.997 0.000 1.000
#> SRR805794 2 0.0000 0.997 0.000 1.000
#> SRR805795 2 0.0938 0.989 0.012 0.988
#> SRR805796 2 0.1633 0.979 0.024 0.976
#> SRR805797 2 0.0000 0.997 0.000 1.000
#> SRR805798 2 0.0000 0.997 0.000 1.000
#> SRR805799 2 0.1633 0.979 0.024 0.976
#> SRR805800 2 0.0000 0.997 0.000 1.000
#> SRR805801 2 0.0672 0.992 0.008 0.992
#> SRR805802 2 0.0000 0.997 0.000 1.000
#> SRR805803 2 0.0000 0.997 0.000 1.000
#> SRR805804 2 0.0000 0.997 0.000 1.000
#> SRR805805 2 0.0000 0.997 0.000 1.000
#> SRR805806 2 0.0000 0.997 0.000 1.000
#> SRR805807 2 0.1184 0.986 0.016 0.984
#> SRR805808 2 0.0000 0.997 0.000 1.000
#> SRR805809 2 0.0000 0.997 0.000 1.000
#> SRR805810 2 0.0938 0.989 0.012 0.988
#> SRR805811 2 0.0000 0.997 0.000 1.000
#> SRR805812 2 0.0000 0.997 0.000 1.000
#> SRR805813 1 0.0000 1.000 1.000 0.000
#> SRR805814 1 0.0000 1.000 1.000 0.000
#> SRR805815 1 0.0000 1.000 1.000 0.000
#> SRR805816 1 0.0000 1.000 1.000 0.000
#> SRR805817 1 0.0000 1.000 1.000 0.000
#> SRR805818 1 0.0000 1.000 1.000 0.000
#> SRR805819 1 0.0000 1.000 1.000 0.000
#> SRR805820 1 0.0000 1.000 1.000 0.000
#> SRR805821 1 0.0000 1.000 1.000 0.000
#> SRR805822 1 0.0000 1.000 1.000 0.000
#> SRR805823 1 0.0000 1.000 1.000 0.000
#> SRR805824 1 0.0000 1.000 1.000 0.000
#> SRR805825 1 0.0000 1.000 1.000 0.000
#> SRR805826 1 0.0000 1.000 1.000 0.000
#> SRR805828 1 0.0000 1.000 1.000 0.000
#> SRR805829 1 0.0000 1.000 1.000 0.000
#> SRR805830 1 0.0000 1.000 1.000 0.000
#> SRR805831 1 0.0000 1.000 1.000 0.000
#> SRR805832 1 0.0000 1.000 1.000 0.000
#> SRR805833 1 0.0000 1.000 1.000 0.000
#> SRR805834 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
#> SRR805780 2 0.3686 0.819 0.140 0.860 0.00
#> SRR805781 2 0.3551 0.821 0.132 0.868 0.00
#> SRR805782 2 0.3551 0.821 0.132 0.868 0.00
#> SRR805784 2 0.0892 0.777 0.020 0.980 0.00
#> SRR805785 2 0.1529 0.792 0.040 0.960 0.00
#> SRR805786 2 0.1860 0.800 0.052 0.948 0.00
#> SRR805787 2 0.3551 0.821 0.132 0.868 0.00
#> SRR805788 2 0.3551 0.821 0.132 0.868 0.00
#> SRR805789 2 0.1964 0.803 0.056 0.944 0.00
#> SRR805790 2 0.1964 0.802 0.056 0.944 0.00
#> SRR805791 1 0.0000 0.827 1.000 0.000 0.00
#> SRR805792 1 0.0000 0.827 1.000 0.000 0.00
#> SRR805793 1 0.0000 0.827 1.000 0.000 0.00
#> SRR805794 1 0.0000 0.827 1.000 0.000 0.00
#> SRR805795 1 0.0000 0.827 1.000 0.000 0.00
#> SRR805796 1 0.0000 0.827 1.000 0.000 0.00
#> SRR805797 1 0.0000 0.827 1.000 0.000 0.00
#> SRR805798 1 0.0000 0.827 1.000 0.000 0.00
#> SRR805799 2 0.5948 0.351 0.360 0.640 0.00
#> SRR805800 1 0.0000 0.827 1.000 0.000 0.00
#> SRR805801 1 0.0000 0.827 1.000 0.000 0.00
#> SRR805802 1 0.5760 0.455 0.672 0.328 0.00
#> SRR805803 2 0.3686 0.819 0.140 0.860 0.00
#> SRR805804 2 0.3686 0.819 0.140 0.860 0.00
#> SRR805805 2 0.6302 0.181 0.480 0.520 0.00
#> SRR805806 1 0.5968 0.365 0.636 0.364 0.00
#> SRR805807 1 0.5948 0.361 0.640 0.360 0.00
#> SRR805808 1 0.5968 0.365 0.636 0.364 0.00
#> SRR805809 2 0.6280 0.246 0.460 0.540 0.00
#> SRR805810 2 0.6026 0.339 0.376 0.624 0.00
#> SRR805811 1 0.2711 0.767 0.912 0.088 0.00
#> SRR805812 1 0.5785 0.446 0.668 0.332 0.00
#> SRR805813 3 0.0000 0.992 0.000 0.000 1.00
#> SRR805814 3 0.0000 0.992 0.000 0.000 1.00
#> SRR805815 3 0.0000 0.992 0.000 0.000 1.00
#> SRR805816 3 0.0000 0.992 0.000 0.000 1.00
#> SRR805817 3 0.0000 0.992 0.000 0.000 1.00
#> SRR805818 3 0.0000 0.992 0.000 0.000 1.00
#> SRR805819 3 0.0000 0.992 0.000 0.000 1.00
#> SRR805820 3 0.0000 0.992 0.000 0.000 1.00
#> SRR805821 3 0.0000 0.992 0.000 0.000 1.00
#> SRR805822 3 0.0000 0.992 0.000 0.000 1.00
#> SRR805823 3 0.0000 0.992 0.000 0.000 1.00
#> SRR805824 3 0.0892 0.991 0.000 0.020 0.98
#> SRR805825 3 0.0892 0.991 0.000 0.020 0.98
#> SRR805826 3 0.0892 0.991 0.000 0.020 0.98
#> SRR805828 3 0.0892 0.991 0.000 0.020 0.98
#> SRR805829 3 0.0892 0.991 0.000 0.020 0.98
#> SRR805830 3 0.0892 0.991 0.000 0.020 0.98
#> SRR805831 3 0.0892 0.991 0.000 0.020 0.98
#> SRR805832 3 0.0892 0.991 0.000 0.020 0.98
#> SRR805833 3 0.0892 0.991 0.000 0.020 0.98
#> SRR805834 3 0.0892 0.991 0.000 0.020 0.98
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR805781 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR805782 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR805784 2 0.2329 0.902 0.012 0.916 0.072 0.000
#> SRR805785 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR805786 2 0.0469 0.949 0.000 0.988 0.012 0.000
#> SRR805787 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR805788 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR805789 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR805790 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR805791 1 0.0188 0.865 0.996 0.004 0.000 0.000
#> SRR805792 1 0.0188 0.865 0.996 0.004 0.000 0.000
#> SRR805793 1 0.0188 0.865 0.996 0.004 0.000 0.000
#> SRR805794 1 0.0188 0.865 0.996 0.004 0.000 0.000
#> SRR805795 1 0.0188 0.865 0.996 0.004 0.000 0.000
#> SRR805796 1 0.0188 0.865 0.996 0.004 0.000 0.000
#> SRR805797 1 0.0000 0.863 1.000 0.000 0.000 0.000
#> SRR805798 1 0.0000 0.863 1.000 0.000 0.000 0.000
#> SRR805799 3 0.7681 -0.460 0.292 0.252 0.456 0.000
#> SRR805800 1 0.0188 0.865 0.996 0.004 0.000 0.000
#> SRR805801 1 0.0188 0.865 0.996 0.004 0.000 0.000
#> SRR805802 1 0.3801 0.767 0.780 0.220 0.000 0.000
#> SRR805803 2 0.0592 0.944 0.016 0.984 0.000 0.000
#> SRR805804 2 0.0469 0.947 0.012 0.988 0.000 0.000
#> SRR805805 1 0.4522 0.644 0.680 0.320 0.000 0.000
#> SRR805806 1 0.4008 0.748 0.756 0.244 0.000 0.000
#> SRR805807 1 0.6123 0.705 0.676 0.192 0.132 0.000
#> SRR805808 1 0.4008 0.748 0.756 0.244 0.000 0.000
#> SRR805809 2 0.5093 0.282 0.348 0.640 0.012 0.000
#> SRR805810 1 0.7478 0.356 0.468 0.344 0.188 0.000
#> SRR805811 1 0.1940 0.843 0.924 0.076 0.000 0.000
#> SRR805812 1 0.4008 0.748 0.756 0.244 0.000 0.000
#> SRR805813 4 0.0336 0.985 0.000 0.000 0.008 0.992
#> SRR805814 4 0.0592 0.971 0.000 0.000 0.016 0.984
#> SRR805815 4 0.0188 0.985 0.000 0.000 0.004 0.996
#> SRR805816 4 0.0707 0.971 0.000 0.000 0.020 0.980
#> SRR805817 4 0.0000 0.988 0.000 0.000 0.000 1.000
#> SRR805818 4 0.0336 0.985 0.000 0.000 0.008 0.992
#> SRR805819 4 0.0000 0.988 0.000 0.000 0.000 1.000
#> SRR805820 4 0.0336 0.985 0.000 0.000 0.008 0.992
#> SRR805821 4 0.0000 0.988 0.000 0.000 0.000 1.000
#> SRR805822 4 0.0000 0.988 0.000 0.000 0.000 1.000
#> SRR805823 4 0.0336 0.985 0.000 0.000 0.008 0.992
#> SRR805824 3 0.4996 0.789 0.000 0.000 0.516 0.484
#> SRR805825 3 0.4981 0.823 0.000 0.000 0.536 0.464
#> SRR805826 3 0.4981 0.823 0.000 0.000 0.536 0.464
#> SRR805828 3 0.4981 0.823 0.000 0.000 0.536 0.464
#> SRR805829 3 0.4981 0.823 0.000 0.000 0.536 0.464
#> SRR805830 3 0.4981 0.823 0.000 0.000 0.536 0.464
#> SRR805831 3 0.4981 0.823 0.000 0.000 0.536 0.464
#> SRR805832 3 0.4981 0.823 0.000 0.000 0.536 0.464
#> SRR805833 3 0.4981 0.823 0.000 0.000 0.536 0.464
#> SRR805834 3 0.4981 0.823 0.000 0.000 0.536 0.464
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.0451 0.955 0.000 0.988 0.004 0.000 0.008
#> SRR805781 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000
#> SRR805782 2 0.0162 0.958 0.000 0.996 0.000 0.000 0.004
#> SRR805784 2 0.1121 0.931 0.000 0.956 0.000 0.000 0.044
#> SRR805785 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000
#> SRR805786 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000
#> SRR805787 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000
#> SRR805788 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000
#> SRR805789 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000
#> SRR805790 2 0.0000 0.960 0.000 1.000 0.000 0.000 0.000
#> SRR805791 1 0.0000 0.900 1.000 0.000 0.000 0.000 0.000
#> SRR805792 1 0.0000 0.900 1.000 0.000 0.000 0.000 0.000
#> SRR805793 1 0.0000 0.900 1.000 0.000 0.000 0.000 0.000
#> SRR805794 1 0.0000 0.900 1.000 0.000 0.000 0.000 0.000
#> SRR805795 1 0.0162 0.900 0.996 0.000 0.000 0.004 0.000
#> SRR805796 1 0.0162 0.900 0.996 0.000 0.000 0.004 0.000
#> SRR805797 1 0.3087 0.780 0.836 0.000 0.004 0.008 0.152
#> SRR805798 1 0.3087 0.780 0.836 0.000 0.004 0.008 0.152
#> SRR805799 5 0.0404 0.668 0.000 0.000 0.012 0.000 0.988
#> SRR805800 1 0.0290 0.898 0.992 0.000 0.000 0.008 0.000
#> SRR805801 1 0.0000 0.900 1.000 0.000 0.000 0.000 0.000
#> SRR805802 1 0.0693 0.896 0.980 0.000 0.008 0.000 0.012
#> SRR805803 2 0.0854 0.947 0.012 0.976 0.004 0.000 0.008
#> SRR805804 2 0.0727 0.949 0.012 0.980 0.004 0.000 0.004
#> SRR805805 1 0.2522 0.852 0.880 0.000 0.012 0.000 0.108
#> SRR805806 1 0.2522 0.852 0.880 0.000 0.012 0.000 0.108
#> SRR805807 1 0.3616 0.776 0.804 0.032 0.000 0.000 0.164
#> SRR805808 1 0.3900 0.781 0.788 0.020 0.012 0.000 0.180
#> SRR805809 2 0.5439 0.479 0.088 0.668 0.012 0.000 0.232
#> SRR805810 5 0.4297 0.586 0.236 0.036 0.000 0.000 0.728
#> SRR805811 1 0.1965 0.864 0.904 0.000 0.000 0.000 0.096
#> SRR805812 1 0.3628 0.762 0.772 0.000 0.012 0.000 0.216
#> SRR805813 4 0.0290 0.926 0.000 0.000 0.008 0.992 0.000
#> SRR805814 4 0.3424 0.742 0.000 0.000 0.240 0.760 0.000
#> SRR805815 4 0.0963 0.932 0.000 0.000 0.036 0.964 0.000
#> SRR805816 4 0.3274 0.770 0.000 0.000 0.220 0.780 0.000
#> SRR805817 4 0.1121 0.932 0.000 0.000 0.044 0.956 0.000
#> SRR805818 4 0.0451 0.925 0.000 0.000 0.008 0.988 0.004
#> SRR805819 4 0.1121 0.932 0.000 0.000 0.044 0.956 0.000
#> SRR805820 4 0.0290 0.926 0.000 0.000 0.008 0.992 0.000
#> SRR805821 4 0.0963 0.932 0.000 0.000 0.036 0.964 0.000
#> SRR805822 4 0.0963 0.932 0.000 0.000 0.036 0.964 0.000
#> SRR805823 4 0.0451 0.925 0.000 0.000 0.008 0.988 0.004
#> SRR805824 3 0.4030 0.515 0.000 0.000 0.648 0.352 0.000
#> SRR805825 3 0.0794 0.940 0.000 0.000 0.972 0.028 0.000
#> SRR805826 3 0.0794 0.940 0.000 0.000 0.972 0.028 0.000
#> SRR805828 3 0.2230 0.860 0.000 0.000 0.884 0.116 0.000
#> SRR805829 3 0.0794 0.940 0.000 0.000 0.972 0.028 0.000
#> SRR805830 3 0.0794 0.940 0.000 0.000 0.972 0.028 0.000
#> SRR805831 3 0.1197 0.923 0.000 0.000 0.952 0.048 0.000
#> SRR805832 3 0.0794 0.940 0.000 0.000 0.972 0.028 0.000
#> SRR805833 3 0.0794 0.940 0.000 0.000 0.972 0.028 0.000
#> SRR805834 3 0.0794 0.940 0.000 0.000 0.972 0.028 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.3054 0.8476 0.000 0.828 0.000 0.000 0.036 0.136
#> SRR805781 2 0.2070 0.8393 0.000 0.908 0.000 0.000 0.048 0.044
#> SRR805782 2 0.2070 0.8384 0.000 0.908 0.000 0.000 0.044 0.048
#> SRR805784 2 0.3984 0.6808 0.000 0.596 0.000 0.000 0.008 0.396
#> SRR805785 2 0.3081 0.8207 0.000 0.776 0.000 0.000 0.004 0.220
#> SRR805786 2 0.2964 0.8322 0.000 0.792 0.000 0.000 0.004 0.204
#> SRR805787 2 0.1225 0.8514 0.000 0.952 0.000 0.000 0.036 0.012
#> SRR805788 2 0.1049 0.8571 0.000 0.960 0.000 0.000 0.008 0.032
#> SRR805789 2 0.3248 0.8203 0.004 0.768 0.000 0.000 0.004 0.224
#> SRR805790 2 0.2092 0.8520 0.000 0.876 0.000 0.000 0.000 0.124
#> SRR805791 1 0.0363 0.8328 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR805792 1 0.0363 0.8328 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR805793 1 0.0363 0.8328 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR805794 1 0.0363 0.8328 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR805795 1 0.0000 0.8326 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805796 1 0.0000 0.8326 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805797 1 0.2260 0.7118 0.860 0.000 0.000 0.000 0.140 0.000
#> SRR805798 1 0.2260 0.7118 0.860 0.000 0.000 0.000 0.140 0.000
#> SRR805799 6 0.3584 0.0000 0.004 0.000 0.000 0.000 0.308 0.688
#> SRR805800 1 0.1007 0.8046 0.956 0.000 0.000 0.000 0.044 0.000
#> SRR805801 1 0.0000 0.8326 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR805802 1 0.4253 -0.4317 0.572 0.008 0.000 0.000 0.412 0.008
#> SRR805803 2 0.2144 0.8421 0.004 0.908 0.000 0.000 0.048 0.040
#> SRR805804 2 0.2209 0.8399 0.004 0.904 0.000 0.000 0.052 0.040
#> SRR805805 5 0.4326 0.5292 0.488 0.008 0.000 0.000 0.496 0.008
#> SRR805806 5 0.4264 0.5238 0.488 0.000 0.000 0.000 0.496 0.016
#> SRR805807 1 0.4304 0.4821 0.740 0.004 0.000 0.000 0.128 0.128
#> SRR805808 5 0.4199 0.5729 0.444 0.008 0.000 0.000 0.544 0.004
#> SRR805809 5 0.5776 0.0549 0.064 0.336 0.000 0.000 0.544 0.056
#> SRR805810 5 0.6035 -0.2193 0.180 0.016 0.000 0.000 0.504 0.300
#> SRR805811 1 0.2892 0.6505 0.840 0.004 0.000 0.000 0.136 0.020
#> SRR805812 5 0.3966 0.5768 0.444 0.000 0.000 0.000 0.552 0.004
#> SRR805813 4 0.2135 0.8506 0.000 0.000 0.000 0.872 0.128 0.000
#> SRR805814 4 0.3373 0.7219 0.000 0.000 0.248 0.744 0.008 0.000
#> SRR805815 4 0.0713 0.8784 0.000 0.000 0.028 0.972 0.000 0.000
#> SRR805816 4 0.3076 0.7371 0.000 0.000 0.240 0.760 0.000 0.000
#> SRR805817 4 0.0713 0.8784 0.000 0.000 0.028 0.972 0.000 0.000
#> SRR805818 4 0.2355 0.8576 0.000 0.000 0.008 0.876 0.112 0.004
#> SRR805819 4 0.0713 0.8784 0.000 0.000 0.028 0.972 0.000 0.000
#> SRR805820 4 0.2664 0.8256 0.000 0.000 0.000 0.816 0.184 0.000
#> SRR805821 4 0.0632 0.8782 0.000 0.000 0.024 0.976 0.000 0.000
#> SRR805822 4 0.0632 0.8782 0.000 0.000 0.024 0.976 0.000 0.000
#> SRR805823 4 0.2915 0.8210 0.000 0.000 0.000 0.808 0.184 0.008
#> SRR805824 3 0.3847 0.4909 0.000 0.000 0.644 0.348 0.008 0.000
#> SRR805825 3 0.0146 0.9375 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR805826 3 0.0000 0.9401 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805828 3 0.1802 0.8701 0.000 0.000 0.916 0.072 0.012 0.000
#> SRR805829 3 0.0000 0.9401 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805830 3 0.0000 0.9401 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805831 3 0.0260 0.9334 0.000 0.000 0.992 0.008 0.000 0.000
#> SRR805832 3 0.0000 0.9401 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805833 3 0.0000 0.9401 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR805834 3 0.0000 0.9401 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", "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 15291 rows and 53 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.999 1.000 0.3972 0.604 0.604
#> 3 3 0.647 0.929 0.913 0.5869 0.703 0.519
#> 4 4 0.549 0.798 0.821 0.1067 1.000 1.000
#> 5 5 0.620 0.638 0.738 0.0782 0.861 0.612
#> 6 6 0.602 0.759 0.763 0.0509 0.894 0.606
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
#> SRR805780 2 0.000 1.000 0.000 1.000
#> SRR805781 2 0.000 1.000 0.000 1.000
#> SRR805782 2 0.000 1.000 0.000 1.000
#> SRR805784 2 0.000 1.000 0.000 1.000
#> SRR805785 2 0.000 1.000 0.000 1.000
#> SRR805786 2 0.000 1.000 0.000 1.000
#> SRR805787 2 0.000 1.000 0.000 1.000
#> SRR805788 2 0.000 1.000 0.000 1.000
#> SRR805789 2 0.000 1.000 0.000 1.000
#> SRR805790 2 0.000 1.000 0.000 1.000
#> SRR805791 1 0.000 0.999 1.000 0.000
#> SRR805792 1 0.000 0.999 1.000 0.000
#> SRR805793 1 0.000 0.999 1.000 0.000
#> SRR805794 1 0.000 0.999 1.000 0.000
#> SRR805795 1 0.000 0.999 1.000 0.000
#> SRR805796 1 0.000 0.999 1.000 0.000
#> SRR805797 1 0.000 0.999 1.000 0.000
#> SRR805798 1 0.000 0.999 1.000 0.000
#> SRR805799 1 0.000 0.999 1.000 0.000
#> SRR805800 1 0.000 0.999 1.000 0.000
#> SRR805801 1 0.000 0.999 1.000 0.000
#> SRR805802 1 0.163 0.975 0.976 0.024
#> SRR805803 2 0.000 1.000 0.000 1.000
#> SRR805804 2 0.000 1.000 0.000 1.000
#> SRR805805 2 0.000 1.000 0.000 1.000
#> SRR805806 1 0.000 0.999 1.000 0.000
#> SRR805807 1 0.000 0.999 1.000 0.000
#> SRR805808 1 0.000 0.999 1.000 0.000
#> SRR805809 2 0.000 1.000 0.000 1.000
#> SRR805810 1 0.000 0.999 1.000 0.000
#> SRR805811 1 0.000 0.999 1.000 0.000
#> SRR805812 1 0.000 0.999 1.000 0.000
#> SRR805813 1 0.000 0.999 1.000 0.000
#> SRR805814 1 0.000 0.999 1.000 0.000
#> SRR805815 1 0.000 0.999 1.000 0.000
#> SRR805816 1 0.000 0.999 1.000 0.000
#> SRR805817 1 0.000 0.999 1.000 0.000
#> SRR805818 1 0.000 0.999 1.000 0.000
#> SRR805819 1 0.000 0.999 1.000 0.000
#> SRR805820 1 0.000 0.999 1.000 0.000
#> SRR805821 1 0.000 0.999 1.000 0.000
#> SRR805822 1 0.000 0.999 1.000 0.000
#> SRR805823 1 0.000 0.999 1.000 0.000
#> SRR805824 1 0.000 0.999 1.000 0.000
#> SRR805825 1 0.000 0.999 1.000 0.000
#> SRR805826 1 0.000 0.999 1.000 0.000
#> SRR805828 1 0.000 0.999 1.000 0.000
#> SRR805829 1 0.000 0.999 1.000 0.000
#> SRR805830 1 0.000 0.999 1.000 0.000
#> SRR805831 1 0.000 0.999 1.000 0.000
#> SRR805832 1 0.000 0.999 1.000 0.000
#> SRR805833 1 0.000 0.999 1.000 0.000
#> SRR805834 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
#> SRR805780 2 0.0000 0.972 0.000 1.000 0.000
#> SRR805781 2 0.0000 0.972 0.000 1.000 0.000
#> SRR805782 2 0.0000 0.972 0.000 1.000 0.000
#> SRR805784 2 0.0747 0.969 0.016 0.984 0.000
#> SRR805785 2 0.0747 0.969 0.016 0.984 0.000
#> SRR805786 2 0.0424 0.970 0.008 0.992 0.000
#> SRR805787 2 0.0000 0.972 0.000 1.000 0.000
#> SRR805788 2 0.0000 0.972 0.000 1.000 0.000
#> SRR805789 2 0.0000 0.972 0.000 1.000 0.000
#> SRR805790 2 0.0747 0.969 0.016 0.984 0.000
#> SRR805791 1 0.2537 0.865 0.920 0.000 0.080
#> SRR805792 1 0.3686 0.895 0.860 0.000 0.140
#> SRR805793 1 0.1860 0.837 0.948 0.000 0.052
#> SRR805794 1 0.2796 0.868 0.908 0.000 0.092
#> SRR805795 1 0.5291 0.863 0.732 0.000 0.268
#> SRR805796 1 0.5431 0.846 0.716 0.000 0.284
#> SRR805797 1 0.4399 0.903 0.812 0.000 0.188
#> SRR805798 1 0.4121 0.903 0.832 0.000 0.168
#> SRR805799 1 0.4750 0.895 0.784 0.000 0.216
#> SRR805800 1 0.4931 0.890 0.768 0.000 0.232
#> SRR805801 1 0.5431 0.846 0.716 0.000 0.284
#> SRR805802 1 0.3987 0.886 0.872 0.020 0.108
#> SRR805803 2 0.4521 0.855 0.180 0.816 0.004
#> SRR805804 2 0.1529 0.955 0.040 0.960 0.000
#> SRR805805 1 0.4555 0.663 0.800 0.200 0.000
#> SRR805806 1 0.4575 0.903 0.812 0.004 0.184
#> SRR805807 1 0.5098 0.880 0.752 0.000 0.248
#> SRR805808 1 0.6297 0.889 0.756 0.060 0.184
#> SRR805809 2 0.3551 0.848 0.132 0.868 0.000
#> SRR805810 1 0.3267 0.890 0.884 0.000 0.116
#> SRR805811 1 0.5016 0.885 0.760 0.000 0.240
#> SRR805812 1 0.5891 0.895 0.780 0.052 0.168
#> SRR805813 3 0.2356 0.928 0.072 0.000 0.928
#> SRR805814 3 0.0892 0.977 0.020 0.000 0.980
#> SRR805815 3 0.0892 0.977 0.020 0.000 0.980
#> SRR805816 3 0.0747 0.978 0.016 0.000 0.984
#> SRR805817 3 0.1643 0.960 0.044 0.000 0.956
#> SRR805818 3 0.1964 0.948 0.056 0.000 0.944
#> SRR805819 3 0.0747 0.978 0.016 0.000 0.984
#> SRR805820 3 0.0747 0.978 0.016 0.000 0.984
#> SRR805821 3 0.1529 0.964 0.040 0.000 0.960
#> SRR805822 3 0.1860 0.953 0.052 0.000 0.948
#> SRR805823 3 0.0592 0.977 0.012 0.000 0.988
#> SRR805824 3 0.0892 0.977 0.020 0.000 0.980
#> SRR805825 3 0.1289 0.961 0.032 0.000 0.968
#> SRR805826 3 0.0592 0.975 0.012 0.000 0.988
#> SRR805828 3 0.0237 0.976 0.004 0.000 0.996
#> SRR805829 3 0.0424 0.976 0.008 0.000 0.992
#> SRR805830 3 0.0592 0.975 0.012 0.000 0.988
#> SRR805831 3 0.0000 0.974 0.000 0.000 1.000
#> SRR805832 3 0.0237 0.972 0.004 0.000 0.996
#> SRR805833 3 0.0237 0.972 0.004 0.000 0.996
#> SRR805834 3 0.0237 0.972 0.004 0.000 0.996
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR805780 2 0.0000 0.902 0.000 1.000 NA 0.000
#> SRR805781 2 0.0336 0.900 0.000 0.992 NA 0.000
#> SRR805782 2 0.0000 0.902 0.000 1.000 NA 0.000
#> SRR805784 2 0.2704 0.873 0.000 0.876 NA 0.000
#> SRR805785 2 0.2216 0.885 0.000 0.908 NA 0.000
#> SRR805786 2 0.1716 0.892 0.000 0.936 NA 0.000
#> SRR805787 2 0.0000 0.902 0.000 1.000 NA 0.000
#> SRR805788 2 0.0000 0.902 0.000 1.000 NA 0.000
#> SRR805789 2 0.0188 0.901 0.000 0.996 NA 0.000
#> SRR805790 2 0.2345 0.882 0.000 0.900 NA 0.000
#> SRR805791 1 0.5712 0.713 0.644 0.000 NA 0.048
#> SRR805792 1 0.4004 0.802 0.812 0.000 NA 0.024
#> SRR805793 1 0.5695 0.687 0.624 0.000 NA 0.040
#> SRR805794 1 0.5497 0.739 0.672 0.000 NA 0.044
#> SRR805795 1 0.3978 0.801 0.836 0.000 NA 0.108
#> SRR805796 1 0.4199 0.766 0.804 0.000 NA 0.164
#> SRR805797 1 0.2376 0.812 0.916 0.000 NA 0.016
#> SRR805798 1 0.2101 0.812 0.928 0.000 NA 0.012
#> SRR805799 1 0.3687 0.808 0.856 0.000 NA 0.064
#> SRR805800 1 0.4150 0.818 0.824 0.000 NA 0.056
#> SRR805801 1 0.4123 0.789 0.820 0.000 NA 0.136
#> SRR805802 1 0.2998 0.813 0.892 0.024 NA 0.004
#> SRR805803 2 0.6439 0.481 0.048 0.488 NA 0.008
#> SRR805804 2 0.4840 0.748 0.028 0.732 NA 0.000
#> SRR805805 1 0.5434 0.590 0.696 0.252 NA 0.000
#> SRR805806 1 0.3432 0.815 0.860 0.008 NA 0.012
#> SRR805807 1 0.5994 0.691 0.692 0.000 NA 0.152
#> SRR805808 1 0.7255 0.730 0.652 0.120 NA 0.064
#> SRR805809 2 0.4996 0.675 0.192 0.752 NA 0.000
#> SRR805810 1 0.3743 0.823 0.824 0.000 NA 0.016
#> SRR805811 1 0.5670 0.733 0.720 0.000 NA 0.128
#> SRR805812 1 0.5841 0.767 0.740 0.124 NA 0.020
#> SRR805813 4 0.6620 0.742 0.180 0.000 NA 0.628
#> SRR805814 4 0.4388 0.830 0.060 0.000 NA 0.808
#> SRR805815 4 0.5470 0.819 0.116 0.000 NA 0.736
#> SRR805816 4 0.5495 0.820 0.096 0.000 NA 0.728
#> SRR805817 4 0.6119 0.788 0.152 0.000 NA 0.680
#> SRR805818 4 0.6646 0.743 0.172 0.000 NA 0.624
#> SRR805819 4 0.5657 0.814 0.120 0.000 NA 0.720
#> SRR805820 4 0.6063 0.800 0.124 0.000 NA 0.680
#> SRR805821 4 0.5758 0.810 0.128 0.000 NA 0.712
#> SRR805822 4 0.6037 0.793 0.152 0.000 NA 0.688
#> SRR805823 4 0.6295 0.785 0.132 0.000 NA 0.656
#> SRR805824 4 0.2926 0.830 0.056 0.000 NA 0.896
#> SRR805825 4 0.1398 0.797 0.004 0.000 NA 0.956
#> SRR805826 4 0.0469 0.816 0.000 0.000 NA 0.988
#> SRR805828 4 0.0188 0.819 0.004 0.000 NA 0.996
#> SRR805829 4 0.0000 0.820 0.000 0.000 NA 1.000
#> SRR805830 4 0.0336 0.818 0.000 0.000 NA 0.992
#> SRR805831 4 0.1389 0.821 0.000 0.000 NA 0.952
#> SRR805832 4 0.1022 0.819 0.000 0.000 NA 0.968
#> SRR805833 4 0.0592 0.818 0.000 0.000 NA 0.984
#> SRR805834 4 0.0817 0.820 0.000 0.000 NA 0.976
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR805780 2 0.0566 0.856 0.004 0.984 0.000 0.000 0.012
#> SRR805781 2 0.0404 0.856 0.000 0.988 0.000 0.000 0.012
#> SRR805782 2 0.0290 0.857 0.000 0.992 0.000 0.000 0.008
#> SRR805784 2 0.5083 0.671 0.000 0.652 0.068 0.000 0.280
#> SRR805785 2 0.2067 0.838 0.000 0.920 0.032 0.000 0.048
#> SRR805786 2 0.1012 0.853 0.000 0.968 0.020 0.000 0.012
#> SRR805787 2 0.0000 0.858 0.000 1.000 0.000 0.000 0.000
#> SRR805788 2 0.0000 0.858 0.000 1.000 0.000 0.000 0.000
#> SRR805789 2 0.0290 0.857 0.000 0.992 0.000 0.000 0.008
#> SRR805790 2 0.3573 0.786 0.000 0.812 0.036 0.000 0.152
#> SRR805791 1 0.4642 0.615 0.780 0.000 0.120 0.044 0.056
#> SRR805792 1 0.3554 0.649 0.828 0.000 0.020 0.136 0.016
#> SRR805793 1 0.4430 0.617 0.784 0.000 0.136 0.056 0.024
#> SRR805794 1 0.4567 0.630 0.784 0.000 0.100 0.088 0.028
#> SRR805795 1 0.6461 0.581 0.540 0.000 0.012 0.284 0.164
#> SRR805796 1 0.5692 0.517 0.568 0.000 0.024 0.364 0.044
#> SRR805797 1 0.5795 0.626 0.572 0.000 0.008 0.084 0.336
#> SRR805798 1 0.5719 0.637 0.604 0.000 0.004 0.104 0.288
#> SRR805799 1 0.5447 0.574 0.512 0.000 0.012 0.036 0.440
#> SRR805800 1 0.4719 0.616 0.696 0.000 0.016 0.264 0.024
#> SRR805801 1 0.5383 0.536 0.592 0.000 0.020 0.356 0.032
#> SRR805802 1 0.7338 0.453 0.532 0.188 0.008 0.056 0.216
#> SRR805803 2 0.7369 0.389 0.304 0.484 0.124 0.000 0.088
#> SRR805804 2 0.6267 0.613 0.184 0.648 0.080 0.000 0.088
#> SRR805805 1 0.6959 0.259 0.500 0.312 0.020 0.008 0.160
#> SRR805806 1 0.7672 0.533 0.448 0.012 0.040 0.252 0.248
#> SRR805807 4 0.6974 -0.184 0.316 0.000 0.048 0.504 0.132
#> SRR805808 4 0.8641 -0.273 0.304 0.120 0.052 0.404 0.120
#> SRR805809 2 0.6135 0.577 0.172 0.664 0.036 0.008 0.120
#> SRR805810 1 0.6734 0.495 0.540 0.000 0.052 0.304 0.104
#> SRR805811 4 0.7473 -0.331 0.344 0.000 0.064 0.428 0.164
#> SRR805812 1 0.8385 0.408 0.412 0.088 0.048 0.328 0.124
#> SRR805813 4 0.0693 0.748 0.000 0.000 0.012 0.980 0.008
#> SRR805814 4 0.2020 0.648 0.000 0.000 0.100 0.900 0.000
#> SRR805815 4 0.1197 0.734 0.000 0.000 0.048 0.952 0.000
#> SRR805816 4 0.0794 0.746 0.000 0.000 0.028 0.972 0.000
#> SRR805817 4 0.0404 0.753 0.000 0.000 0.012 0.988 0.000
#> SRR805818 4 0.0693 0.749 0.000 0.000 0.012 0.980 0.008
#> SRR805819 4 0.0880 0.747 0.000 0.000 0.032 0.968 0.000
#> SRR805820 4 0.0451 0.752 0.000 0.000 0.008 0.988 0.004
#> SRR805821 4 0.0963 0.745 0.000 0.000 0.036 0.964 0.000
#> SRR805822 4 0.0794 0.749 0.000 0.000 0.028 0.972 0.000
#> SRR805823 4 0.0451 0.751 0.000 0.000 0.008 0.988 0.004
#> SRR805824 4 0.4297 -0.509 0.000 0.000 0.472 0.528 0.000
#> SRR805825 3 0.4004 0.894 0.008 0.000 0.760 0.216 0.016
#> SRR805826 3 0.3895 0.943 0.004 0.000 0.728 0.264 0.004
#> SRR805828 3 0.3684 0.946 0.000 0.000 0.720 0.280 0.000
#> SRR805829 3 0.3707 0.945 0.000 0.000 0.716 0.284 0.000
#> SRR805830 3 0.3790 0.946 0.004 0.000 0.724 0.272 0.000
#> SRR805831 3 0.5554 0.873 0.000 0.000 0.592 0.316 0.092
#> SRR805832 3 0.4479 0.940 0.000 0.000 0.700 0.264 0.036
#> SRR805833 3 0.4292 0.946 0.000 0.000 0.704 0.272 0.024
#> SRR805834 3 0.5353 0.919 0.000 0.000 0.636 0.272 0.092
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR805780 2 0.0000 0.850 0.000 1.000 0.000 0.000 0.000 NA
#> SRR805781 2 0.0146 0.849 0.000 0.996 0.000 0.000 0.004 NA
#> SRR805782 2 0.0000 0.850 0.000 1.000 0.000 0.000 0.000 NA
#> SRR805784 2 0.4563 0.466 0.000 0.504 0.008 0.000 0.020 NA
#> SRR805785 2 0.1829 0.827 0.004 0.920 0.000 0.000 0.012 NA
#> SRR805786 2 0.0935 0.842 0.000 0.964 0.000 0.000 0.004 NA
#> SRR805787 2 0.0000 0.850 0.000 1.000 0.000 0.000 0.000 NA
#> SRR805788 2 0.0146 0.850 0.000 0.996 0.000 0.000 0.000 NA
#> SRR805789 2 0.0260 0.850 0.000 0.992 0.000 0.000 0.000 NA
#> SRR805790 2 0.2489 0.794 0.000 0.860 0.000 0.000 0.012 NA
#> SRR805791 1 0.7330 0.611 0.548 0.004 0.152 0.084 0.136 NA
#> SRR805792 1 0.7263 0.683 0.468 0.000 0.052 0.196 0.244 NA
#> SRR805793 1 0.7758 0.612 0.416 0.000 0.120 0.116 0.292 NA
#> SRR805794 1 0.7848 0.647 0.420 0.000 0.108 0.156 0.260 NA
#> SRR805795 1 0.5266 0.653 0.616 0.000 0.008 0.272 0.100 NA
#> SRR805796 1 0.5930 0.635 0.508 0.000 0.008 0.320 0.160 NA
#> SRR805797 1 0.4637 0.578 0.732 0.000 0.000 0.092 0.148 NA
#> SRR805798 1 0.5062 0.628 0.704 0.000 0.012 0.104 0.160 NA
#> SRR805799 1 0.4862 0.214 0.704 0.000 0.020 0.000 0.128 NA
#> SRR805800 1 0.6799 0.659 0.440 0.000 0.044 0.248 0.264 NA
#> SRR805801 1 0.7071 0.626 0.412 0.000 0.024 0.240 0.292 NA
#> SRR805802 5 0.5327 0.680 0.092 0.116 0.000 0.028 0.716 NA
#> SRR805803 2 0.7426 0.305 0.044 0.472 0.072 0.000 0.224 NA
#> SRR805804 2 0.6251 0.335 0.024 0.540 0.016 0.000 0.280 NA
#> SRR805805 5 0.5162 0.647 0.072 0.192 0.004 0.004 0.692 NA
#> SRR805806 5 0.5782 0.692 0.100 0.024 0.008 0.124 0.688 NA
#> SRR805807 5 0.5687 0.475 0.064 0.000 0.012 0.360 0.540 NA
#> SRR805808 5 0.5259 0.724 0.024 0.040 0.024 0.128 0.736 NA
#> SRR805809 5 0.4113 0.625 0.004 0.244 0.000 0.000 0.712 NA
#> SRR805810 5 0.4229 0.710 0.052 0.004 0.004 0.124 0.784 NA
#> SRR805811 5 0.4946 0.672 0.056 0.000 0.000 0.204 0.692 NA
#> SRR805812 5 0.4651 0.740 0.036 0.072 0.000 0.108 0.764 NA
#> SRR805813 4 0.0748 0.930 0.004 0.000 0.004 0.976 0.016 NA
#> SRR805814 4 0.2425 0.900 0.008 0.000 0.100 0.880 0.012 NA
#> SRR805815 4 0.1644 0.953 0.012 0.000 0.052 0.932 0.004 NA
#> SRR805816 4 0.1265 0.953 0.000 0.000 0.044 0.948 0.008 NA
#> SRR805817 4 0.1382 0.955 0.008 0.000 0.036 0.948 0.008 NA
#> SRR805818 4 0.0881 0.919 0.008 0.000 0.000 0.972 0.012 NA
#> SRR805819 4 0.1410 0.955 0.008 0.000 0.044 0.944 0.004 NA
#> SRR805820 4 0.1049 0.952 0.000 0.000 0.032 0.960 0.008 NA
#> SRR805821 4 0.1820 0.951 0.012 0.000 0.056 0.924 0.008 NA
#> SRR805822 4 0.1757 0.953 0.012 0.000 0.052 0.928 0.008 NA
#> SRR805823 4 0.0508 0.932 0.000 0.000 0.000 0.984 0.012 NA
#> SRR805824 3 0.4063 0.490 0.004 0.000 0.572 0.420 0.004 NA
#> SRR805825 3 0.2859 0.886 0.012 0.000 0.868 0.092 0.008 NA
#> SRR805826 3 0.2420 0.919 0.004 0.000 0.864 0.128 0.000 NA
#> SRR805828 3 0.3007 0.920 0.004 0.000 0.836 0.140 0.008 NA
#> SRR805829 3 0.2520 0.919 0.004 0.000 0.844 0.152 0.000 NA
#> SRR805830 3 0.2695 0.920 0.004 0.000 0.844 0.144 0.000 NA
#> SRR805831 3 0.3980 0.898 0.004 0.000 0.760 0.168 0.000 NA
#> SRR805832 3 0.3352 0.915 0.000 0.000 0.820 0.120 0.004 NA
#> SRR805833 3 0.3417 0.918 0.000 0.000 0.812 0.132 0.004 NA
#> SRR805834 3 0.3773 0.910 0.004 0.000 0.796 0.120 0.004 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
sessionInfo()
#> R version 3.6.0 (2019-04-26)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: CentOS Linux 7 (Core)
#>
#> Matrix products: default
#> BLAS: /usr/lib64/libblas.so.3.4.2
#> LAPACK: /usr/lib64/liblapack.so.3.4.2
#>
#> locale:
#> [1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8
#> [4] LC_COLLATE=en_GB.UTF-8 LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
#> [7] LC_PAPER=en_GB.UTF-8 LC_NAME=C LC_ADDRESS=C
#> [10] LC_TELEPHONE=C LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] grid stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] genefilter_1.66.0 ComplexHeatmap_2.3.1 markdown_1.1 knitr_1.26
#> [5] GetoptLong_0.1.7 cola_1.3.2
#>
#> loaded via a namespace (and not attached):
#> [1] circlize_0.4.8 shape_1.4.4 xfun_0.11 slam_0.1-46
#> [5] lattice_0.20-38 splines_3.6.0 colorspace_1.4-1 vctrs_0.2.0
#> [9] stats4_3.6.0 blob_1.2.0 XML_3.98-1.20 survival_2.44-1.1
#> [13] rlang_0.4.2 pillar_1.4.2 DBI_1.0.0 BiocGenerics_0.30.0
#> [17] bit64_0.9-7 RColorBrewer_1.1-2 matrixStats_0.55.0 stringr_1.4.0
#> [21] GlobalOptions_0.1.1 evaluate_0.14 memoise_1.1.0 Biobase_2.44.0
#> [25] IRanges_2.18.3 parallel_3.6.0 AnnotationDbi_1.46.1 highr_0.8
#> [29] Rcpp_1.0.3 xtable_1.8-4 backports_1.1.5 S4Vectors_0.22.1
#> [33] annotate_1.62.0 skmeans_0.2-11 bit_1.1-14 microbenchmark_1.4-7
#> [37] brew_1.0-6 impute_1.58.0 rjson_0.2.20 png_0.1-7
#> [41] digest_0.6.23 stringi_1.4.3 polyclip_1.10-0 clue_0.3-57
#> [45] tools_3.6.0 bitops_1.0-6 magrittr_1.5 eulerr_6.0.0
#> [49] RCurl_1.95-4.12 RSQLite_2.1.4 tibble_2.1.3 cluster_2.1.0
#> [53] crayon_1.3.4 pkgconfig_2.0.3 zeallot_0.1.0 Matrix_1.2-17
#> [57] xml2_1.2.2 httr_1.4.1 R6_2.4.1 mclust_5.4.5
#> [61] compiler_3.6.0