Date: 2019-12-25 21:35:41 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 31632 rows and 50 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, anno = anno)
Dimension of the input matrix:
mat = get_matrix(res_list)
dim(mat)
#> [1] 31632 50
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, top_annotation = HeatmapAnnotation(df = get_anno(res_list),
col = get_anno_col(res_list)), ylab = "value", cluster_columns = TRUE, show_column_names = FALSE,
mc.cores = 4)
Folowing table shows the best k
(number of partitions) for each combination
of top-value methods and partition methods. Clicking on the method name in
the table goes to the section for a single combination of methods.
The cola vignette explains the definition of the metrics used for determining the best number of partitions.
suggest_best_k(res_list)
The best k | 1-PAC | Mean silhouette | Concordance | Optional k | ||
---|---|---|---|---|---|---|
SD:hclust | 5 | 1.000 | 0.954 | 0.978 | ** | 2,3,4 |
SD:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
SD:pam | 6 | 1.000 | 0.970 | 0.987 | ** | 2,3,4,5 |
CV:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
CV:pam | 6 | 1.000 | 0.966 | 0.981 | ** | 2,3,4,5 |
MAD:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
MAD:pam | 6 | 1.000 | 0.979 | 0.991 | ** | 2,3,4,5 |
ATC:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
ATC:skmeans | 5 | 1.000 | 0.990 | 0.993 | ** | 2,3,4 |
ATC:mclust | 5 | 1.000 | 0.995 | 0.995 | ** | 2,3,4 |
ATC:NMF | 2 | 1.000 | 1.000 | 1.000 | ** | |
MAD:mclust | 6 | 0.993 | 0.984 | 0.989 | ** | 2,3,4,5 |
SD:mclust | 6 | 0.980 | 0.927 | 0.969 | ** | 2,3,4,5 |
SD:skmeans | 5 | 0.976 | 0.954 | 0.970 | ** | 2,3,4 |
MAD:skmeans | 5 | 0.972 | 0.948 | 0.964 | ** | 2,3,4 |
ATC:pam | 6 | 0.969 | 0.937 | 0.968 | ** | 2,3,4,5 |
MAD:hclust | 5 | 0.961 | 0.914 | 0.950 | ** | 2,3,4 |
MAD:NMF | 5 | 0.960 | 0.944 | 0.952 | ** | 2,3,4 |
SD:NMF | 5 | 0.951 | 0.930 | 0.944 | ** | 2,3,4 |
CV:NMF | 5 | 0.939 | 0.915 | 0.934 | * | 2,3,4 |
ATC:hclust | 6 | 0.918 | 0.833 | 0.914 | * | 2 |
CV:skmeans | 6 | 0.914 | 0.812 | 0.869 | * | 2,3,4,5 |
CV:mclust | 5 | 0.907 | 0.762 | 0.901 | * | 2,3,4 |
CV:hclust | 5 | 0.904 | 0.782 | 0.857 | * | 2,3,4 |
**: 1-PAC > 0.95, *: 1-PAC > 0.9
Cumulative distribution function curves of consensus matrix for all methods.
collect_plots(res_list, fun = plot_ecdf)
Consensus heatmaps for all methods. (What is a consensus heatmap?)
collect_plots(res_list, k = 2, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = consensus_heatmap, mc.cores = 4)
Membership heatmaps for all methods. (What is a membership heatmap?)
collect_plots(res_list, k = 2, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = membership_heatmap, mc.cores = 4)
Signature heatmaps for all methods. (What is a signature heatmap?)
Note in following heatmaps, rows are scaled.
collect_plots(res_list, k = 2, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 3, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 4, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 5, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 6, fun = get_signatures, mc.cores = 4)
The statistics used for measuring the stability of consensus partitioning. (How are they defined?)
get_stats(res_list, k = 2)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 2 1 1 1 0.471 0.53 0.53
#> CV:NMF 2 1 1 1 0.471 0.53 0.53
#> MAD:NMF 2 1 1 1 0.471 0.53 0.53
#> ATC:NMF 2 1 1 1 0.471 0.53 0.53
#> SD:skmeans 2 1 1 1 0.471 0.53 0.53
#> CV:skmeans 2 1 1 1 0.471 0.53 0.53
#> MAD:skmeans 2 1 1 1 0.471 0.53 0.53
#> ATC:skmeans 2 1 1 1 0.471 0.53 0.53
#> SD:mclust 2 1 1 1 0.471 0.53 0.53
#> CV:mclust 2 1 1 1 0.471 0.53 0.53
#> MAD:mclust 2 1 1 1 0.471 0.53 0.53
#> ATC:mclust 2 1 1 1 0.471 0.53 0.53
#> SD:kmeans 2 1 1 1 0.471 0.53 0.53
#> CV:kmeans 2 1 1 1 0.471 0.53 0.53
#> MAD:kmeans 2 1 1 1 0.471 0.53 0.53
#> ATC:kmeans 2 1 1 1 0.471 0.53 0.53
#> SD:pam 2 1 1 1 0.471 0.53 0.53
#> CV:pam 2 1 1 1 0.471 0.53 0.53
#> MAD:pam 2 1 1 1 0.471 0.53 0.53
#> ATC:pam 2 1 1 1 0.471 0.53 0.53
#> SD:hclust 2 1 1 1 0.471 0.53 0.53
#> CV:hclust 2 1 1 1 0.471 0.53 0.53
#> MAD:hclust 2 1 1 1 0.471 0.53 0.53
#> ATC:hclust 2 1 1 1 0.471 0.53 0.53
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 0.927 0.922 0.966 0.434 0.792 0.607
#> CV:NMF 3 0.949 0.933 0.969 0.436 0.792 0.607
#> MAD:NMF 3 0.966 0.972 0.974 0.415 0.794 0.612
#> ATC:NMF 3 0.809 0.964 0.927 0.321 0.804 0.630
#> SD:skmeans 3 0.950 0.905 0.965 0.435 0.794 0.612
#> CV:skmeans 3 1.000 0.966 0.984 0.440 0.792 0.607
#> MAD:skmeans 3 1.000 0.989 0.995 0.438 0.794 0.612
#> ATC:skmeans 3 1.000 0.984 0.994 0.395 0.811 0.644
#> SD:mclust 3 1.000 1.000 1.000 0.416 0.804 0.630
#> CV:mclust 3 1.000 1.000 1.000 0.416 0.804 0.630
#> MAD:mclust 3 1.000 1.000 1.000 0.416 0.804 0.630
#> ATC:mclust 3 1.000 1.000 1.000 0.416 0.804 0.630
#> SD:kmeans 3 0.704 0.906 0.878 0.344 0.794 0.612
#> CV:kmeans 3 0.707 0.921 0.860 0.338 0.794 0.612
#> MAD:kmeans 3 0.699 0.874 0.856 0.338 0.794 0.612
#> ATC:kmeans 3 0.775 0.952 0.907 0.303 0.811 0.644
#> SD:pam 3 0.956 0.969 0.985 0.426 0.798 0.619
#> CV:pam 3 0.974 0.953 0.976 0.438 0.792 0.607
#> MAD:pam 3 0.952 0.959 0.981 0.436 0.794 0.612
#> ATC:pam 3 0.974 0.913 0.968 0.409 0.811 0.644
#> SD:hclust 3 1.000 0.958 0.982 0.432 0.794 0.612
#> CV:hclust 3 0.971 0.944 0.969 0.435 0.794 0.612
#> MAD:hclust 3 1.000 0.962 0.981 0.431 0.794 0.612
#> ATC:hclust 3 0.846 0.908 0.950 0.378 0.804 0.630
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.996 0.966 0.979 0.0990 0.909 0.729
#> CV:NMF 4 0.985 0.921 0.966 0.0935 0.922 0.762
#> MAD:NMF 4 1.000 0.975 0.981 0.1144 0.912 0.736
#> ATC:NMF 4 0.869 0.883 0.867 0.1320 0.919 0.758
#> SD:skmeans 4 1.000 0.985 0.993 0.1030 0.912 0.736
#> CV:skmeans 4 0.958 0.894 0.949 0.0974 0.899 0.700
#> MAD:skmeans 4 1.000 0.975 0.991 0.1020 0.912 0.736
#> ATC:skmeans 4 1.000 0.890 0.956 0.1358 0.882 0.670
#> SD:mclust 4 0.971 0.919 0.967 0.1192 0.919 0.758
#> CV:mclust 4 0.966 0.920 0.966 0.1189 0.918 0.756
#> MAD:mclust 4 0.959 0.920 0.966 0.1176 0.922 0.765
#> ATC:mclust 4 1.000 1.000 1.000 0.1174 0.922 0.765
#> SD:kmeans 4 0.794 0.794 0.824 0.1277 0.939 0.814
#> CV:kmeans 4 0.619 0.866 0.836 0.1225 0.928 0.783
#> MAD:kmeans 4 0.635 0.881 0.831 0.1311 0.912 0.736
#> ATC:kmeans 4 0.645 0.532 0.805 0.1402 0.984 0.952
#> SD:pam 4 1.000 0.987 0.994 0.1135 0.912 0.737
#> CV:pam 4 0.975 0.939 0.972 0.1002 0.899 0.700
#> MAD:pam 4 1.000 0.991 0.995 0.1049 0.900 0.704
#> ATC:pam 4 1.000 0.986 0.994 0.1247 0.900 0.714
#> SD:hclust 4 1.000 0.957 0.983 0.0933 0.941 0.819
#> CV:hclust 4 0.982 0.944 0.969 0.0511 0.980 0.940
#> MAD:hclust 4 1.000 0.956 0.976 0.0916 0.941 0.819
#> ATC:hclust 4 0.815 0.874 0.929 0.0799 0.974 0.922
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 0.951 0.930 0.944 0.0348 0.958 0.838
#> CV:NMF 5 0.939 0.915 0.934 0.0389 0.958 0.842
#> MAD:NMF 5 0.960 0.944 0.952 0.0360 0.958 0.838
#> ATC:NMF 5 0.846 0.904 0.897 0.0439 0.984 0.941
#> SD:skmeans 5 0.976 0.954 0.970 0.0372 0.958 0.838
#> CV:skmeans 5 0.971 0.870 0.924 0.0341 0.985 0.942
#> MAD:skmeans 5 0.972 0.948 0.964 0.0361 0.958 0.838
#> ATC:skmeans 5 1.000 0.990 0.993 0.0341 0.971 0.888
#> SD:mclust 5 1.000 0.992 0.996 0.0377 0.958 0.840
#> CV:mclust 5 0.907 0.762 0.901 0.0344 0.987 0.948
#> MAD:mclust 5 1.000 0.944 0.980 0.0395 0.965 0.864
#> ATC:mclust 5 1.000 0.995 0.995 0.0381 0.971 0.888
#> SD:kmeans 5 0.693 0.697 0.811 0.0628 0.958 0.850
#> CV:kmeans 5 0.736 0.691 0.822 0.0795 0.974 0.902
#> MAD:kmeans 5 0.693 0.756 0.820 0.0692 0.974 0.898
#> ATC:kmeans 5 0.764 0.840 0.823 0.0741 0.878 0.633
#> SD:pam 5 0.968 0.960 0.971 0.0348 0.958 0.840
#> CV:pam 5 0.999 0.966 0.984 0.0286 0.977 0.910
#> MAD:pam 5 1.000 0.966 0.980 0.0372 0.958 0.840
#> ATC:pam 5 0.926 0.880 0.909 0.0446 0.945 0.792
#> SD:hclust 5 1.000 0.954 0.978 0.0483 0.961 0.852
#> CV:hclust 5 0.904 0.782 0.857 0.0615 0.948 0.832
#> MAD:hclust 5 0.961 0.914 0.950 0.0457 0.963 0.862
#> ATC:hclust 5 0.863 0.796 0.866 0.0717 0.922 0.745
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 0.924 0.926 0.944 0.0139 1.000 1.000
#> CV:NMF 6 0.902 0.914 0.934 0.0198 1.000 1.000
#> MAD:NMF 6 0.973 0.934 0.951 0.0107 1.000 1.000
#> ATC:NMF 6 0.807 0.860 0.887 0.0263 1.000 1.000
#> SD:skmeans 6 0.962 0.901 0.926 0.0156 1.000 1.000
#> CV:skmeans 6 0.914 0.812 0.869 0.0239 0.980 0.918
#> MAD:skmeans 6 0.972 0.911 0.917 0.0164 1.000 1.000
#> ATC:skmeans 6 0.982 0.930 0.946 0.0143 0.990 0.957
#> SD:mclust 6 0.980 0.927 0.969 0.0279 0.978 0.903
#> CV:mclust 6 0.855 0.679 0.851 0.0342 0.984 0.932
#> MAD:mclust 6 0.993 0.984 0.989 0.0272 0.969 0.866
#> ATC:mclust 6 0.989 0.950 0.956 0.0268 0.990 0.957
#> SD:kmeans 6 0.762 0.693 0.803 0.0584 0.971 0.882
#> CV:kmeans 6 0.715 0.703 0.785 0.0485 0.974 0.892
#> MAD:kmeans 6 0.751 0.699 0.804 0.0509 1.000 1.000
#> ATC:kmeans 6 0.747 0.771 0.777 0.0570 0.962 0.832
#> SD:pam 6 1.000 0.970 0.987 0.0173 0.988 0.946
#> CV:pam 6 1.000 0.966 0.981 0.0297 0.953 0.810
#> MAD:pam 6 1.000 0.979 0.991 0.0162 0.988 0.946
#> ATC:pam 6 0.969 0.937 0.968 0.0397 0.971 0.869
#> SD:hclust 6 0.924 0.893 0.926 0.0239 1.000 1.000
#> CV:hclust 6 0.890 0.873 0.871 0.0398 0.947 0.802
#> MAD:hclust 6 0.936 0.787 0.871 0.0227 0.993 0.971
#> ATC:hclust 6 0.918 0.833 0.914 0.0588 0.949 0.780
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)
#> Error in valid.viewport(x, y, width, height, just, gp, clip, xscale, yscale, : invalid 'xscale' in viewport
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)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res_list, k = 2)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> SD:NMF 50 1 0.934 2.67e-07 0.00142 2
#> CV:NMF 50 1 0.934 2.67e-07 0.00142 2
#> MAD:NMF 50 1 0.934 2.67e-07 0.00142 2
#> ATC:NMF 50 1 0.934 2.67e-07 0.00142 2
#> SD:skmeans 50 1 0.934 2.67e-07 0.00142 2
#> CV:skmeans 50 1 0.934 2.67e-07 0.00142 2
#> MAD:skmeans 50 1 0.934 2.67e-07 0.00142 2
#> ATC:skmeans 50 1 0.934 2.67e-07 0.00142 2
#> SD:mclust 50 1 0.934 2.67e-07 0.00142 2
#> CV:mclust 50 1 0.934 2.67e-07 0.00142 2
#> MAD:mclust 50 1 0.934 2.67e-07 0.00142 2
#> ATC:mclust 50 1 0.934 2.67e-07 0.00142 2
#> SD:kmeans 50 1 0.934 2.67e-07 0.00142 2
#> CV:kmeans 50 1 0.934 2.67e-07 0.00142 2
#> MAD:kmeans 50 1 0.934 2.67e-07 0.00142 2
#> ATC:kmeans 50 1 0.934 2.67e-07 0.00142 2
#> SD:pam 50 1 0.934 2.67e-07 0.00142 2
#> CV:pam 50 1 0.934 2.67e-07 0.00142 2
#> MAD:pam 50 1 0.934 2.67e-07 0.00142 2
#> ATC:pam 50 1 0.934 2.67e-07 0.00142 2
#> SD:hclust 50 1 0.934 2.67e-07 0.00142 2
#> CV:hclust 50 1 0.934 2.67e-07 0.00142 2
#> MAD:hclust 50 1 0.934 2.67e-07 0.00142 2
#> ATC:hclust 50 1 0.934 2.67e-07 0.00142 2
test_to_known_factors(res_list, k = 3)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> SD:NMF 49 0.981 0.952 1.63e-11 6.57e-05 3
#> CV:NMF 50 0.939 0.875 8.67e-12 3.79e-05 3
#> MAD:NMF 50 1.000 0.931 1.69e-11 8.93e-05 3
#> ATC:NMF 50 1.000 0.931 1.26e-12 1.60e-05 3
#> SD:skmeans 47 0.847 0.875 1.47e-11 8.15e-05 3
#> CV:skmeans 50 0.939 0.875 8.67e-12 3.79e-05 3
#> MAD:skmeans 50 1.000 0.931 1.69e-11 8.93e-05 3
#> ATC:skmeans 50 0.933 0.869 1.06e-11 4.14e-05 3
#> SD:mclust 50 1.000 0.931 1.26e-12 1.60e-05 3
#> CV:mclust 50 1.000 0.931 1.26e-12 1.60e-05 3
#> MAD:mclust 50 1.000 0.931 1.26e-12 1.60e-05 3
#> ATC:mclust 50 1.000 0.931 1.26e-12 1.60e-05 3
#> SD:kmeans 49 0.870 0.944 1.68e-11 6.67e-05 3
#> CV:kmeans 50 0.776 0.931 1.69e-11 8.93e-05 3
#> MAD:kmeans 46 0.905 0.934 3.31e-11 1.38e-04 3
#> ATC:kmeans 50 0.933 0.869 1.06e-11 4.14e-05 3
#> SD:pam 50 0.937 0.873 9.23e-12 3.89e-05 3
#> CV:pam 50 0.939 0.875 8.67e-12 3.79e-05 3
#> MAD:pam 49 0.981 0.952 1.63e-11 6.57e-05 3
#> ATC:pam 46 1.000 0.871 3.31e-11 6.62e-05 3
#> SD:hclust 49 0.972 0.870 1.68e-11 6.67e-05 3
#> CV:hclust 50 0.776 0.931 1.69e-11 8.93e-05 3
#> MAD:hclust 50 1.000 0.931 1.69e-11 8.93e-05 3
#> ATC:hclust 50 1.000 0.931 1.26e-12 1.60e-05 3
test_to_known_factors(res_list, k = 4)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> SD:NMF 49 0.995 0.988 2.28e-17 4.54e-07 4
#> CV:NMF 48 1.000 0.987 7.68e-17 1.01e-06 4
#> MAD:NMF 50 1.000 0.986 6.71e-18 2.02e-07 4
#> ATC:NMF 49 0.995 0.961 2.28e-17 4.54e-07 4
#> SD:skmeans 50 1.000 0.986 6.71e-18 2.02e-07 4
#> CV:skmeans 46 0.957 0.891 2.21e-14 7.92e-06 4
#> MAD:skmeans 49 0.995 0.988 2.28e-17 4.54e-07 4
#> ATC:skmeans 47 0.993 0.986 2.58e-16 7.31e-07 4
#> SD:mclust 48 0.987 0.948 6.57e-16 1.01e-06 4
#> CV:mclust 48 0.974 0.948 1.91e-15 3.99e-06 4
#> MAD:mclust 48 0.985 0.946 7.68e-17 1.01e-06 4
#> ATC:mclust 50 1.000 0.986 6.71e-18 2.02e-07 4
#> SD:kmeans 46 1.000 0.987 8.58e-16 1.62e-06 4
#> CV:kmeans 48 1.000 0.987 4.74e-15 7.28e-06 4
#> MAD:kmeans 47 0.981 0.940 2.58e-16 2.20e-06 4
#> ATC:kmeans 41 0.967 0.954 7.24e-11 1.02e-04 4
#> SD:pam 50 0.977 0.951 1.45e-16 7.83e-07 4
#> CV:pam 49 0.995 0.988 1.32e-14 7.04e-06 4
#> MAD:pam 50 0.977 0.951 1.45e-16 7.83e-07 4
#> ATC:pam 50 0.979 0.866 8.76e-16 7.14e-07 4
#> SD:hclust 49 0.996 0.964 5.65e-16 2.18e-06 4
#> CV:hclust 50 0.528 0.986 4.32e-13 2.04e-04 4
#> MAD:hclust 50 1.000 0.986 8.26e-16 4.62e-06 4
#> ATC:hclust 49 0.998 0.993 2.28e-17 4.54e-07 4
test_to_known_factors(res_list, k = 5)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> SD:NMF 49 0.996 0.982 2.33e-20 7.98e-08 5
#> CV:NMF 50 1.000 0.998 3.06e-20 2.01e-07 5
#> MAD:NMF 50 1.000 0.998 3.06e-20 2.01e-07 5
#> ATC:NMF 50 1.000 0.986 6.71e-18 2.02e-07 5
#> SD:skmeans 50 1.000 0.998 3.06e-20 2.01e-07 5
#> CV:skmeans 44 0.970 0.955 1.80e-18 6.18e-07 5
#> MAD:skmeans 49 0.996 0.982 2.33e-20 7.98e-08 5
#> ATC:skmeans 50 1.000 0.998 3.76e-23 2.67e-09 5
#> SD:mclust 50 1.000 0.998 1.59e-16 6.55e-06 5
#> CV:mclust 40 0.592 0.989 1.08e-13 2.01e-05 5
#> MAD:mclust 48 0.992 0.975 8.94e-16 1.54e-06 5
#> ATC:mclust 50 0.987 0.975 6.70e-21 2.57e-08 5
#> SD:kmeans 45 1.000 0.614 2.70e-15 1.17e-07 5
#> CV:kmeans 43 0.999 0.719 1.42e-16 7.38e-07 5
#> MAD:kmeans 45 0.999 0.723 1.15e-19 2.75e-08 5
#> ATC:kmeans 48 0.982 0.532 5.15e-16 6.33e-08 5
#> SD:pam 50 1.000 0.998 3.06e-20 2.01e-07 5
#> CV:pam 50 0.979 0.964 3.20e-17 9.29e-07 5
#> MAD:pam 50 1.000 0.998 3.06e-20 2.01e-07 5
#> ATC:pam 46 0.982 0.560 3.62e-16 1.08e-07 5
#> SD:hclust 49 0.996 0.982 2.33e-20 7.98e-08 5
#> CV:hclust 41 0.554 0.958 3.28e-14 9.32e-06 5
#> MAD:hclust 49 0.996 0.993 2.50e-19 7.39e-07 5
#> ATC:hclust 46 0.922 0.927 2.35e-20 4.18e-08 5
test_to_known_factors(res_list, k = 6)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> SD:NMF 50 1.000 0.998 3.06e-20 2.01e-07 6
#> CV:NMF 50 1.000 0.998 3.06e-20 2.01e-07 6
#> MAD:NMF 50 1.000 0.998 3.06e-20 2.01e-07 6
#> ATC:NMF 48 1.000 0.962 7.68e-17 3.25e-07 6
#> SD:skmeans 49 0.996 0.982 2.33e-20 7.98e-08 6
#> CV:skmeans 43 0.860 0.987 2.10e-16 4.86e-06 6
#> MAD:skmeans 49 0.996 0.982 2.33e-20 7.98e-08 6
#> ATC:skmeans 48 1.000 0.863 1.22e-26 7.95e-11 6
#> SD:mclust 48 0.860 0.863 1.85e-13 3.25e-04 6
#> CV:mclust 39 0.691 0.980 4.22e-10 1.80e-03 6
#> MAD:mclust 50 0.994 0.989 5.92e-15 1.19e-04 6
#> ATC:mclust 49 0.692 0.996 8.70e-20 2.73e-06 6
#> SD:kmeans 46 0.998 0.586 7.36e-16 4.18e-08 6
#> CV:kmeans 43 0.999 0.420 5.80e-14 3.43e-06 6
#> MAD:kmeans 44 1.000 0.752 5.57e-19 7.88e-08 6
#> ATC:kmeans 43 0.998 0.998 2.92e-15 1.90e-06 6
#> SD:pam 50 0.991 0.984 4.62e-22 7.12e-08 6
#> CV:pam 50 0.979 0.969 1.52e-20 2.12e-07 6
#> MAD:pam 50 0.991 0.984 4.62e-22 7.12e-08 6
#> ATC:pam 48 0.986 0.666 6.76e-21 5.72e-09 6
#> SD:hclust 48 0.989 0.970 4.44e-20 2.22e-08 6
#> CV:hclust 50 0.549 0.990 7.86e-20 2.17e-06 6
#> MAD:hclust 45 0.703 0.994 1.15e-19 4.58e-07 6
#> ATC:hclust 45 0.970 1.000 1.15e-19 1.17e-07 6
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 31632 rows and 50 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 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 1.000 0.958 0.982 0.4316 0.794 0.612
#> 4 4 1.000 0.957 0.983 0.0933 0.941 0.819
#> 5 5 1.000 0.954 0.978 0.0483 0.961 0.852
#> 6 6 0.924 0.893 0.926 0.0239 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] 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
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.0000 0.950 0.000 0 1.000
#> GSM892345 1 0.0424 0.981 0.992 0 0.008
#> GSM892349 3 0.6126 0.337 0.400 0 0.600
#> GSM892353 1 0.0237 0.982 0.996 0 0.004
#> GSM892355 1 0.0000 0.984 1.000 0 0.000
#> GSM892361 1 0.0000 0.984 1.000 0 0.000
#> GSM892365 3 0.0000 0.950 0.000 0 1.000
#> GSM892369 3 0.0424 0.947 0.008 0 0.992
#> GSM892373 2 0.0000 1.000 0.000 1 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000
#> GSM892344 3 0.0000 0.950 0.000 0 1.000
#> GSM892347 1 0.0424 0.981 0.992 0 0.008
#> GSM892351 1 0.4750 0.710 0.784 0 0.216
#> GSM892357 1 0.0000 0.984 1.000 0 0.000
#> GSM892359 1 0.0000 0.984 1.000 0 0.000
#> GSM892363 1 0.0000 0.984 1.000 0 0.000
#> GSM892367 3 0.0000 0.950 0.000 0 1.000
#> GSM892371 3 0.0424 0.947 0.008 0 0.992
#> GSM892375 2 0.0000 1.000 0.000 1 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000
#> GSM892341 3 0.0000 0.950 0.000 0 1.000
#> GSM892346 1 0.0424 0.981 0.992 0 0.008
#> GSM892350 1 0.0424 0.981 0.992 0 0.008
#> GSM892354 1 0.0000 0.984 1.000 0 0.000
#> GSM892356 1 0.0000 0.984 1.000 0 0.000
#> GSM892362 1 0.0000 0.984 1.000 0 0.000
#> GSM892366 3 0.0000 0.950 0.000 0 1.000
#> GSM892370 3 0.0424 0.947 0.008 0 0.992
#> GSM892374 2 0.0000 1.000 0.000 1 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000
#> GSM892343 3 0.4504 0.750 0.196 0 0.804
#> GSM892348 1 0.0424 0.981 0.992 0 0.008
#> GSM892352 3 0.0000 0.950 0.000 0 1.000
#> GSM892358 1 0.0000 0.984 1.000 0 0.000
#> GSM892360 1 0.0000 0.984 1.000 0 0.000
#> GSM892364 1 0.0000 0.984 1.000 0 0.000
#> GSM892368 3 0.0000 0.950 0.000 0 1.000
#> GSM892372 3 0.0000 0.950 0.000 0 1.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.0000 0.949 0.000 0 1.000 0.000
#> GSM892345 4 0.0000 0.955 0.000 0 0.000 1.000
#> GSM892349 3 0.4877 0.287 0.000 0 0.592 0.408
#> GSM892353 1 0.0188 0.993 0.996 0 0.004 0.000
#> GSM892355 1 0.0000 0.997 1.000 0 0.000 0.000
#> GSM892361 1 0.0000 0.997 1.000 0 0.000 0.000
#> GSM892365 3 0.0000 0.949 0.000 0 1.000 0.000
#> GSM892369 3 0.0336 0.945 0.000 0 0.992 0.008
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892344 3 0.0000 0.949 0.000 0 1.000 0.000
#> GSM892347 4 0.0000 0.955 0.000 0 0.000 1.000
#> GSM892351 4 0.3688 0.715 0.000 0 0.208 0.792
#> GSM892357 1 0.0000 0.997 1.000 0 0.000 0.000
#> GSM892359 1 0.0000 0.997 1.000 0 0.000 0.000
#> GSM892363 1 0.0000 0.997 1.000 0 0.000 0.000
#> GSM892367 3 0.0000 0.949 0.000 0 1.000 0.000
#> GSM892371 3 0.0336 0.945 0.000 0 0.992 0.008
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892341 3 0.0000 0.949 0.000 0 1.000 0.000
#> GSM892346 4 0.0000 0.955 0.000 0 0.000 1.000
#> GSM892350 4 0.0000 0.955 0.000 0 0.000 1.000
#> GSM892354 1 0.0000 0.997 1.000 0 0.000 0.000
#> GSM892356 1 0.0000 0.997 1.000 0 0.000 0.000
#> GSM892362 1 0.0000 0.997 1.000 0 0.000 0.000
#> GSM892366 3 0.0000 0.949 0.000 0 1.000 0.000
#> GSM892370 3 0.0336 0.945 0.000 0 0.992 0.008
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892343 3 0.3895 0.747 0.012 0 0.804 0.184
#> GSM892348 4 0.0000 0.955 0.000 0 0.000 1.000
#> GSM892352 3 0.0000 0.949 0.000 0 1.000 0.000
#> GSM892358 1 0.0000 0.997 1.000 0 0.000 0.000
#> GSM892360 1 0.0000 0.997 1.000 0 0.000 0.000
#> GSM892364 1 0.0817 0.975 0.976 0 0.000 0.024
#> GSM892368 3 0.0000 0.949 0.000 0 1.000 0.000
#> GSM892372 3 0.0000 0.949 0.000 0 1.000 0.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 5 0.1197 0.852 0.000 0 0.048 0.000 0.952
#> GSM892345 4 0.0000 0.951 0.000 0 0.000 1.000 0.000
#> GSM892349 5 0.4192 0.279 0.000 0 0.000 0.404 0.596
#> GSM892353 1 0.0290 0.992 0.992 0 0.000 0.000 0.008
#> GSM892355 1 0.0162 0.995 0.996 0 0.000 0.000 0.004
#> GSM892361 1 0.0000 0.996 1.000 0 0.000 0.000 0.000
#> GSM892365 3 0.0290 0.996 0.000 0 0.992 0.000 0.008
#> GSM892369 3 0.0000 0.993 0.000 0 1.000 0.000 0.000
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892344 5 0.1197 0.852 0.000 0 0.048 0.000 0.952
#> GSM892347 4 0.0000 0.951 0.000 0 0.000 1.000 0.000
#> GSM892351 4 0.3210 0.700 0.000 0 0.000 0.788 0.212
#> GSM892357 1 0.0000 0.996 1.000 0 0.000 0.000 0.000
#> GSM892359 1 0.0000 0.996 1.000 0 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.996 1.000 0 0.000 0.000 0.000
#> GSM892367 3 0.0290 0.996 0.000 0 0.992 0.000 0.008
#> GSM892371 3 0.0000 0.993 0.000 0 1.000 0.000 0.000
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892341 5 0.1197 0.852 0.000 0 0.048 0.000 0.952
#> GSM892346 4 0.0000 0.951 0.000 0 0.000 1.000 0.000
#> GSM892350 4 0.0162 0.949 0.000 0 0.000 0.996 0.004
#> GSM892354 1 0.0000 0.996 1.000 0 0.000 0.000 0.000
#> GSM892356 1 0.0162 0.995 0.996 0 0.000 0.000 0.004
#> GSM892362 1 0.0000 0.996 1.000 0 0.000 0.000 0.000
#> GSM892366 3 0.0290 0.996 0.000 0 0.992 0.000 0.008
#> GSM892370 3 0.0000 0.993 0.000 0 1.000 0.000 0.000
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892343 5 0.4851 0.710 0.008 0 0.084 0.176 0.732
#> GSM892348 4 0.0000 0.951 0.000 0 0.000 1.000 0.000
#> GSM892352 5 0.0290 0.833 0.000 0 0.008 0.000 0.992
#> GSM892358 1 0.0000 0.996 1.000 0 0.000 0.000 0.000
#> GSM892360 1 0.0000 0.996 1.000 0 0.000 0.000 0.000
#> GSM892364 1 0.0865 0.972 0.972 0 0.000 0.024 0.004
#> GSM892368 3 0.0290 0.996 0.000 0 0.992 0.000 0.008
#> GSM892372 3 0.0290 0.996 0.000 0 0.992 0.000 0.008
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.1007 0.808 0.000 0.000 0.044 0.000 0.956 0.000
#> GSM892345 4 0.3390 0.807 0.000 0.000 0.000 0.704 0.000 0.296
#> GSM892349 5 0.5743 0.339 0.000 0.000 0.000 0.404 0.428 0.168
#> GSM892353 1 0.2482 0.895 0.848 0.000 0.000 0.000 0.004 0.148
#> GSM892355 1 0.2300 0.900 0.856 0.000 0.000 0.000 0.000 0.144
#> GSM892361 1 0.0260 0.956 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM892365 3 0.0146 0.972 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM892369 3 0.1267 0.955 0.000 0.000 0.940 0.000 0.000 0.060
#> GSM892373 2 0.2048 0.911 0.000 0.880 0.000 0.000 0.000 0.120
#> GSM892377 2 0.1387 0.942 0.000 0.932 0.000 0.000 0.000 0.068
#> GSM892381 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892383 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892387 2 0.0458 0.967 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM892344 5 0.1007 0.808 0.000 0.000 0.044 0.000 0.956 0.000
#> GSM892347 4 0.3390 0.807 0.000 0.000 0.000 0.704 0.000 0.296
#> GSM892351 4 0.3487 0.452 0.000 0.000 0.000 0.788 0.044 0.168
#> GSM892357 1 0.0260 0.956 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM892359 1 0.0363 0.954 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM892363 1 0.0790 0.953 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM892367 3 0.0146 0.972 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM892371 3 0.1267 0.955 0.000 0.000 0.940 0.000 0.000 0.060
#> GSM892375 2 0.0458 0.966 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM892379 2 0.0146 0.968 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM892385 2 0.1204 0.941 0.000 0.944 0.000 0.000 0.000 0.056
#> GSM892389 2 0.0260 0.967 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM892341 5 0.1007 0.808 0.000 0.000 0.044 0.000 0.956 0.000
#> GSM892346 4 0.3765 0.787 0.000 0.000 0.000 0.596 0.000 0.404
#> GSM892350 4 0.0000 0.666 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM892354 1 0.0260 0.956 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM892356 1 0.2260 0.901 0.860 0.000 0.000 0.000 0.000 0.140
#> GSM892362 1 0.0000 0.956 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892366 3 0.0146 0.972 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM892370 3 0.1267 0.955 0.000 0.000 0.940 0.000 0.000 0.060
#> GSM892374 2 0.2048 0.911 0.000 0.880 0.000 0.000 0.000 0.120
#> GSM892378 2 0.1387 0.942 0.000 0.932 0.000 0.000 0.000 0.068
#> GSM892382 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892384 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892388 2 0.2135 0.894 0.000 0.872 0.000 0.000 0.000 0.128
#> GSM892343 5 0.4634 0.693 0.000 0.000 0.020 0.160 0.724 0.096
#> GSM892348 4 0.3765 0.787 0.000 0.000 0.000 0.596 0.000 0.404
#> GSM892352 5 0.2454 0.742 0.000 0.000 0.000 0.000 0.840 0.160
#> GSM892358 1 0.0458 0.955 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM892360 1 0.0363 0.954 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM892364 1 0.1686 0.937 0.924 0.000 0.000 0.012 0.000 0.064
#> GSM892368 3 0.0146 0.972 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM892372 3 0.0000 0.972 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM892376 2 0.0458 0.966 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM892380 2 0.0146 0.968 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM892386 2 0.0146 0.968 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM892390 2 0.0260 0.967 0.000 0.992 0.000 0.000 0.000 0.008
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> SD:hclust 50 1.000 0.934 2.67e-07 1.42e-03 2
#> SD:hclust 49 0.972 0.870 1.68e-11 6.67e-05 3
#> SD:hclust 49 0.996 0.964 5.65e-16 2.18e-06 4
#> SD:hclust 49 0.996 0.982 2.33e-20 7.98e-08 5
#> SD:hclust 48 0.989 0.970 4.44e-20 2.22e-08 6
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 31632 rows and 50 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 0.704 0.906 0.878 0.3438 0.794 0.612
#> 4 4 0.794 0.794 0.824 0.1277 0.939 0.814
#> 5 5 0.693 0.697 0.811 0.0628 0.958 0.850
#> 6 6 0.762 0.693 0.803 0.0584 0.971 0.882
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
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.5327 0.956 0.272 0.000 0.728
#> GSM892345 3 0.6126 0.760 0.400 0.000 0.600
#> GSM892349 3 0.5178 0.944 0.256 0.000 0.744
#> GSM892353 1 0.0000 0.939 1.000 0.000 0.000
#> GSM892355 1 0.0000 0.939 1.000 0.000 0.000
#> GSM892361 1 0.0000 0.939 1.000 0.000 0.000
#> GSM892365 3 0.5327 0.956 0.272 0.000 0.728
#> GSM892369 3 0.5327 0.956 0.272 0.000 0.728
#> GSM892373 2 0.4796 0.867 0.000 0.780 0.220
#> GSM892377 2 0.3879 0.909 0.000 0.848 0.152
#> GSM892381 2 0.0424 0.958 0.000 0.992 0.008
#> GSM892383 2 0.1163 0.956 0.000 0.972 0.028
#> GSM892387 2 0.0424 0.958 0.000 0.992 0.008
#> GSM892344 3 0.5327 0.956 0.272 0.000 0.728
#> GSM892347 3 0.6126 0.760 0.400 0.000 0.600
#> GSM892351 3 0.5178 0.944 0.256 0.000 0.744
#> GSM892357 1 0.0000 0.939 1.000 0.000 0.000
#> GSM892359 1 0.0000 0.939 1.000 0.000 0.000
#> GSM892363 1 0.0000 0.939 1.000 0.000 0.000
#> GSM892367 3 0.5327 0.956 0.272 0.000 0.728
#> GSM892371 3 0.5327 0.956 0.272 0.000 0.728
#> GSM892375 2 0.0592 0.958 0.000 0.988 0.012
#> GSM892379 2 0.1411 0.957 0.000 0.964 0.036
#> GSM892385 2 0.1529 0.956 0.000 0.960 0.040
#> GSM892389 2 0.1031 0.958 0.000 0.976 0.024
#> GSM892341 3 0.5327 0.956 0.272 0.000 0.728
#> GSM892346 1 0.4062 0.700 0.836 0.000 0.164
#> GSM892350 3 0.6126 0.760 0.400 0.000 0.600
#> GSM892354 1 0.0000 0.939 1.000 0.000 0.000
#> GSM892356 1 0.0000 0.939 1.000 0.000 0.000
#> GSM892362 1 0.0000 0.939 1.000 0.000 0.000
#> GSM892366 3 0.5327 0.956 0.272 0.000 0.728
#> GSM892370 3 0.5327 0.956 0.272 0.000 0.728
#> GSM892374 2 0.4796 0.867 0.000 0.780 0.220
#> GSM892378 2 0.3879 0.909 0.000 0.848 0.152
#> GSM892382 2 0.0424 0.958 0.000 0.992 0.008
#> GSM892384 2 0.0424 0.958 0.000 0.992 0.008
#> GSM892388 2 0.3116 0.923 0.000 0.892 0.108
#> GSM892343 3 0.5327 0.956 0.272 0.000 0.728
#> GSM892348 1 0.6111 -0.154 0.604 0.000 0.396
#> GSM892352 3 0.5178 0.944 0.256 0.000 0.744
#> GSM892358 1 0.0000 0.939 1.000 0.000 0.000
#> GSM892360 1 0.0000 0.939 1.000 0.000 0.000
#> GSM892364 1 0.0000 0.939 1.000 0.000 0.000
#> GSM892368 3 0.5327 0.956 0.272 0.000 0.728
#> GSM892372 3 0.5327 0.956 0.272 0.000 0.728
#> GSM892376 2 0.0592 0.958 0.000 0.988 0.012
#> GSM892380 2 0.1163 0.958 0.000 0.972 0.028
#> GSM892386 2 0.0424 0.958 0.000 0.992 0.008
#> GSM892390 2 0.1289 0.958 0.000 0.968 0.032
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.0469 0.8081 0.000 0.000 0.988 0.012
#> GSM892345 4 0.6915 0.7632 0.108 0.000 0.416 0.476
#> GSM892349 3 0.4941 -0.2668 0.000 0.000 0.564 0.436
#> GSM892353 1 0.3550 0.9621 0.860 0.000 0.096 0.044
#> GSM892355 1 0.3463 0.9643 0.864 0.000 0.096 0.040
#> GSM892361 1 0.2611 0.9830 0.896 0.000 0.096 0.008
#> GSM892365 3 0.0000 0.8084 0.000 0.000 1.000 0.000
#> GSM892369 3 0.2081 0.7725 0.000 0.000 0.916 0.084
#> GSM892373 2 0.4898 0.7086 0.000 0.584 0.000 0.416
#> GSM892377 2 0.5198 0.8015 0.040 0.708 0.000 0.252
#> GSM892381 2 0.1284 0.9021 0.024 0.964 0.000 0.012
#> GSM892383 2 0.2319 0.8957 0.036 0.924 0.000 0.040
#> GSM892387 2 0.1406 0.9040 0.024 0.960 0.000 0.016
#> GSM892344 3 0.0469 0.8081 0.000 0.000 0.988 0.012
#> GSM892347 4 0.6915 0.7632 0.108 0.000 0.416 0.476
#> GSM892351 3 0.4992 -0.4096 0.000 0.000 0.524 0.476
#> GSM892357 1 0.2741 0.9829 0.892 0.000 0.096 0.012
#> GSM892359 1 0.2611 0.9830 0.896 0.000 0.096 0.008
#> GSM892363 1 0.2281 0.9823 0.904 0.000 0.096 0.000
#> GSM892367 3 0.0000 0.8084 0.000 0.000 1.000 0.000
#> GSM892371 3 0.2081 0.7725 0.000 0.000 0.916 0.084
#> GSM892375 2 0.1706 0.9035 0.016 0.948 0.000 0.036
#> GSM892379 2 0.2521 0.8997 0.024 0.912 0.000 0.064
#> GSM892385 2 0.2919 0.8925 0.044 0.896 0.000 0.060
#> GSM892389 2 0.1913 0.9034 0.020 0.940 0.000 0.040
#> GSM892341 3 0.0469 0.8081 0.000 0.000 0.988 0.012
#> GSM892346 4 0.7375 0.4872 0.348 0.000 0.172 0.480
#> GSM892350 4 0.6915 0.7632 0.108 0.000 0.416 0.476
#> GSM892354 1 0.2611 0.9830 0.896 0.000 0.096 0.008
#> GSM892356 1 0.3463 0.9643 0.864 0.000 0.096 0.040
#> GSM892362 1 0.2611 0.9830 0.896 0.000 0.096 0.008
#> GSM892366 3 0.0000 0.8084 0.000 0.000 1.000 0.000
#> GSM892370 3 0.2081 0.7725 0.000 0.000 0.916 0.084
#> GSM892374 2 0.4898 0.7086 0.000 0.584 0.000 0.416
#> GSM892378 2 0.5198 0.8015 0.040 0.708 0.000 0.252
#> GSM892382 2 0.1284 0.9021 0.024 0.964 0.000 0.012
#> GSM892384 2 0.1284 0.9021 0.024 0.964 0.000 0.012
#> GSM892388 2 0.4799 0.8131 0.032 0.744 0.000 0.224
#> GSM892343 3 0.2469 0.7504 0.000 0.000 0.892 0.108
#> GSM892348 4 0.7438 0.7386 0.188 0.000 0.328 0.484
#> GSM892352 3 0.4661 0.0688 0.000 0.000 0.652 0.348
#> GSM892358 1 0.2741 0.9784 0.892 0.000 0.096 0.012
#> GSM892360 1 0.2611 0.9830 0.896 0.000 0.096 0.008
#> GSM892364 1 0.2466 0.9817 0.900 0.000 0.096 0.004
#> GSM892368 3 0.0000 0.8084 0.000 0.000 1.000 0.000
#> GSM892372 3 0.0000 0.8084 0.000 0.000 1.000 0.000
#> GSM892376 2 0.1610 0.9037 0.016 0.952 0.000 0.032
#> GSM892380 2 0.1584 0.9028 0.012 0.952 0.000 0.036
#> GSM892386 2 0.1297 0.9029 0.020 0.964 0.000 0.016
#> GSM892390 2 0.1584 0.9031 0.012 0.952 0.000 0.036
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 3 0.0404 0.7327 0.000 0.000 0.988 0.012 0.000
#> GSM892345 4 0.4744 0.8927 0.056 0.000 0.252 0.692 0.000
#> GSM892349 3 0.4557 -0.4544 0.000 0.000 0.516 0.476 0.008
#> GSM892353 1 0.4536 0.8814 0.780 0.000 0.060 0.028 0.132
#> GSM892355 1 0.4451 0.8833 0.784 0.000 0.060 0.024 0.132
#> GSM892361 1 0.2193 0.9486 0.912 0.000 0.060 0.000 0.028
#> GSM892365 3 0.2648 0.7804 0.000 0.000 0.848 0.000 0.152
#> GSM892369 3 0.4637 0.7474 0.000 0.000 0.728 0.076 0.196
#> GSM892373 5 0.4235 1.0000 0.000 0.424 0.000 0.000 0.576
#> GSM892377 2 0.6103 -0.2892 0.008 0.532 0.000 0.108 0.352
#> GSM892381 2 0.0992 0.7092 0.000 0.968 0.000 0.024 0.008
#> GSM892383 2 0.3244 0.6662 0.008 0.860 0.000 0.084 0.048
#> GSM892387 2 0.2721 0.6933 0.012 0.892 0.000 0.068 0.028
#> GSM892344 3 0.0404 0.7327 0.000 0.000 0.988 0.012 0.000
#> GSM892347 4 0.4744 0.8927 0.056 0.000 0.252 0.692 0.000
#> GSM892351 4 0.4108 0.7749 0.000 0.000 0.308 0.684 0.008
#> GSM892357 1 0.2264 0.9501 0.912 0.000 0.060 0.004 0.024
#> GSM892359 1 0.1410 0.9524 0.940 0.000 0.060 0.000 0.000
#> GSM892363 1 0.1410 0.9524 0.940 0.000 0.060 0.000 0.000
#> GSM892367 3 0.3074 0.7717 0.000 0.000 0.804 0.000 0.196
#> GSM892371 3 0.4637 0.7474 0.000 0.000 0.728 0.076 0.196
#> GSM892375 2 0.3191 0.6587 0.016 0.868 0.000 0.040 0.076
#> GSM892379 2 0.4002 0.6486 0.000 0.796 0.000 0.120 0.084
#> GSM892385 2 0.3926 0.6363 0.008 0.808 0.000 0.132 0.052
#> GSM892389 2 0.3384 0.6868 0.004 0.848 0.000 0.088 0.060
#> GSM892341 3 0.0404 0.7327 0.000 0.000 0.988 0.012 0.000
#> GSM892346 4 0.5535 0.7317 0.188 0.000 0.124 0.676 0.012
#> GSM892350 4 0.4744 0.8927 0.056 0.000 0.252 0.692 0.000
#> GSM892354 1 0.2193 0.9486 0.912 0.000 0.060 0.000 0.028
#> GSM892356 1 0.4314 0.8894 0.796 0.000 0.060 0.024 0.120
#> GSM892362 1 0.1809 0.9507 0.928 0.000 0.060 0.000 0.012
#> GSM892366 3 0.2648 0.7804 0.000 0.000 0.848 0.000 0.152
#> GSM892370 3 0.4637 0.7474 0.000 0.000 0.728 0.076 0.196
#> GSM892374 5 0.4235 1.0000 0.000 0.424 0.000 0.000 0.576
#> GSM892378 2 0.6103 -0.2892 0.008 0.532 0.000 0.108 0.352
#> GSM892382 2 0.0992 0.7092 0.000 0.968 0.000 0.024 0.008
#> GSM892384 2 0.1082 0.7072 0.000 0.964 0.000 0.028 0.008
#> GSM892388 2 0.6277 -0.0681 0.028 0.604 0.000 0.128 0.240
#> GSM892343 3 0.2230 0.6652 0.000 0.000 0.884 0.116 0.000
#> GSM892348 4 0.5196 0.8600 0.100 0.000 0.208 0.688 0.004
#> GSM892352 3 0.4392 -0.1592 0.000 0.000 0.612 0.380 0.008
#> GSM892358 1 0.1571 0.9523 0.936 0.000 0.060 0.004 0.000
#> GSM892360 1 0.1410 0.9524 0.940 0.000 0.060 0.000 0.000
#> GSM892364 1 0.2519 0.9419 0.900 0.000 0.060 0.004 0.036
#> GSM892368 3 0.2648 0.7804 0.000 0.000 0.848 0.000 0.152
#> GSM892372 3 0.2891 0.7774 0.000 0.000 0.824 0.000 0.176
#> GSM892376 2 0.3067 0.6654 0.016 0.876 0.000 0.040 0.068
#> GSM892380 2 0.2992 0.6802 0.000 0.868 0.000 0.068 0.064
#> GSM892386 2 0.1843 0.7055 0.008 0.932 0.000 0.052 0.008
#> GSM892390 2 0.2843 0.6956 0.000 0.876 0.000 0.076 0.048
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 3 0.4224 0.635 0.016 0.000 0.660 0.012 0.312 0.000
#> GSM892345 4 0.2164 0.830 0.032 0.000 0.068 0.900 0.000 0.000
#> GSM892349 4 0.5970 0.510 0.016 0.000 0.128 0.528 0.320 0.008
#> GSM892353 1 0.3725 0.768 0.676 0.000 0.000 0.008 0.000 0.316
#> GSM892355 1 0.3601 0.771 0.684 0.000 0.000 0.004 0.000 0.312
#> GSM892361 1 0.2201 0.888 0.904 0.000 0.000 0.004 0.036 0.056
#> GSM892365 3 0.0458 0.778 0.016 0.000 0.984 0.000 0.000 0.000
#> GSM892369 3 0.4860 0.710 0.016 0.000 0.752 0.096 0.072 0.064
#> GSM892373 5 0.6125 1.000 0.000 0.312 0.000 0.000 0.348 0.340
#> GSM892377 2 0.5190 -0.167 0.000 0.460 0.000 0.000 0.452 0.088
#> GSM892381 2 0.1369 0.704 0.000 0.952 0.000 0.016 0.016 0.016
#> GSM892383 2 0.3583 0.672 0.000 0.820 0.000 0.032 0.108 0.040
#> GSM892387 2 0.3097 0.683 0.000 0.856 0.000 0.036 0.028 0.080
#> GSM892344 3 0.4224 0.635 0.016 0.000 0.660 0.012 0.312 0.000
#> GSM892347 4 0.2164 0.830 0.032 0.000 0.068 0.900 0.000 0.000
#> GSM892351 4 0.3085 0.810 0.016 0.000 0.084 0.860 0.032 0.008
#> GSM892357 1 0.2263 0.888 0.900 0.000 0.000 0.004 0.036 0.060
#> GSM892359 1 0.0146 0.897 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM892363 1 0.0436 0.896 0.988 0.000 0.000 0.004 0.004 0.004
#> GSM892367 3 0.2698 0.762 0.016 0.000 0.880 0.000 0.064 0.040
#> GSM892371 3 0.4860 0.710 0.016 0.000 0.752 0.096 0.072 0.064
#> GSM892375 2 0.2831 0.678 0.000 0.876 0.000 0.028 0.044 0.052
#> GSM892379 2 0.4485 0.645 0.000 0.724 0.000 0.012 0.180 0.084
#> GSM892385 2 0.4252 0.652 0.000 0.772 0.000 0.032 0.116 0.080
#> GSM892389 2 0.3992 0.681 0.000 0.788 0.000 0.020 0.088 0.104
#> GSM892341 3 0.4224 0.635 0.016 0.000 0.660 0.012 0.312 0.000
#> GSM892346 4 0.2936 0.786 0.080 0.000 0.024 0.868 0.004 0.024
#> GSM892350 4 0.2307 0.830 0.032 0.000 0.068 0.896 0.000 0.004
#> GSM892354 1 0.2263 0.888 0.900 0.000 0.000 0.004 0.036 0.060
#> GSM892356 1 0.3489 0.786 0.708 0.000 0.000 0.004 0.000 0.288
#> GSM892362 1 0.1194 0.891 0.956 0.000 0.000 0.004 0.008 0.032
#> GSM892366 3 0.0458 0.778 0.016 0.000 0.984 0.000 0.000 0.000
#> GSM892370 3 0.4860 0.710 0.016 0.000 0.752 0.096 0.072 0.064
#> GSM892374 5 0.6125 1.000 0.000 0.312 0.000 0.000 0.348 0.340
#> GSM892378 2 0.5190 -0.167 0.000 0.460 0.000 0.000 0.452 0.088
#> GSM892382 2 0.1369 0.704 0.000 0.952 0.000 0.016 0.016 0.016
#> GSM892384 2 0.1237 0.703 0.000 0.956 0.000 0.020 0.004 0.020
#> GSM892388 2 0.5723 -0.219 0.000 0.468 0.016 0.008 0.080 0.428
#> GSM892343 3 0.5866 0.501 0.016 0.000 0.524 0.148 0.312 0.000
#> GSM892348 4 0.2897 0.815 0.048 0.000 0.048 0.876 0.004 0.024
#> GSM892352 4 0.6576 0.189 0.016 0.000 0.276 0.364 0.340 0.004
#> GSM892358 1 0.0146 0.897 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM892360 1 0.0146 0.897 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM892364 1 0.2101 0.871 0.892 0.000 0.000 0.004 0.004 0.100
#> GSM892368 3 0.0458 0.778 0.016 0.000 0.984 0.000 0.000 0.000
#> GSM892372 3 0.1718 0.773 0.016 0.000 0.932 0.000 0.044 0.008
#> GSM892376 2 0.2769 0.680 0.000 0.880 0.000 0.032 0.036 0.052
#> GSM892380 2 0.3495 0.668 0.000 0.792 0.000 0.008 0.172 0.028
#> GSM892386 2 0.2231 0.699 0.000 0.908 0.000 0.028 0.016 0.048
#> GSM892390 2 0.3357 0.695 0.000 0.840 0.000 0.024 0.068 0.068
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)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> SD:kmeans 50 1.000 0.934 2.67e-07 1.42e-03 2
#> SD:kmeans 49 0.870 0.944 1.68e-11 6.67e-05 3
#> SD:kmeans 46 1.000 0.987 8.58e-16 1.62e-06 4
#> SD:kmeans 45 1.000 0.614 2.70e-15 1.17e-07 5
#> SD:kmeans 46 0.998 0.586 7.36e-16 4.18e-08 6
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 31632 rows and 50 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 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 0.950 0.905 0.965 0.4349 0.794 0.612
#> 4 4 1.000 0.985 0.993 0.1030 0.912 0.736
#> 5 5 0.976 0.954 0.970 0.0372 0.958 0.838
#> 6 6 0.962 0.901 0.926 0.0156 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] 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
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.000 0.911 0.000 0 1.000
#> GSM892345 3 0.628 0.186 0.460 0 0.540
#> GSM892349 3 0.000 0.911 0.000 0 1.000
#> GSM892353 1 0.000 0.965 1.000 0 0.000
#> GSM892355 1 0.000 0.965 1.000 0 0.000
#> GSM892361 1 0.000 0.965 1.000 0 0.000
#> GSM892365 3 0.000 0.911 0.000 0 1.000
#> GSM892369 3 0.000 0.911 0.000 0 1.000
#> GSM892373 2 0.000 1.000 0.000 1 0.000
#> GSM892377 2 0.000 1.000 0.000 1 0.000
#> GSM892381 2 0.000 1.000 0.000 1 0.000
#> GSM892383 2 0.000 1.000 0.000 1 0.000
#> GSM892387 2 0.000 1.000 0.000 1 0.000
#> GSM892344 3 0.000 0.911 0.000 0 1.000
#> GSM892347 3 0.628 0.186 0.460 0 0.540
#> GSM892351 3 0.000 0.911 0.000 0 1.000
#> GSM892357 1 0.000 0.965 1.000 0 0.000
#> GSM892359 1 0.000 0.965 1.000 0 0.000
#> GSM892363 1 0.000 0.965 1.000 0 0.000
#> GSM892367 3 0.000 0.911 0.000 0 1.000
#> GSM892371 3 0.000 0.911 0.000 0 1.000
#> GSM892375 2 0.000 1.000 0.000 1 0.000
#> GSM892379 2 0.000 1.000 0.000 1 0.000
#> GSM892385 2 0.000 1.000 0.000 1 0.000
#> GSM892389 2 0.000 1.000 0.000 1 0.000
#> GSM892341 3 0.000 0.911 0.000 0 1.000
#> GSM892346 1 0.440 0.751 0.812 0 0.188
#> GSM892350 3 0.628 0.186 0.460 0 0.540
#> GSM892354 1 0.000 0.965 1.000 0 0.000
#> GSM892356 1 0.000 0.965 1.000 0 0.000
#> GSM892362 1 0.000 0.965 1.000 0 0.000
#> GSM892366 3 0.000 0.911 0.000 0 1.000
#> GSM892370 3 0.000 0.911 0.000 0 1.000
#> GSM892374 2 0.000 1.000 0.000 1 0.000
#> GSM892378 2 0.000 1.000 0.000 1 0.000
#> GSM892382 2 0.000 1.000 0.000 1 0.000
#> GSM892384 2 0.000 1.000 0.000 1 0.000
#> GSM892388 2 0.000 1.000 0.000 1 0.000
#> GSM892343 3 0.000 0.911 0.000 0 1.000
#> GSM892348 1 0.460 0.726 0.796 0 0.204
#> GSM892352 3 0.000 0.911 0.000 0 1.000
#> GSM892358 1 0.000 0.965 1.000 0 0.000
#> GSM892360 1 0.000 0.965 1.000 0 0.000
#> GSM892364 1 0.000 0.965 1.000 0 0.000
#> GSM892368 3 0.000 0.911 0.000 0 1.000
#> GSM892372 3 0.000 0.911 0.000 0 1.000
#> GSM892376 2 0.000 1.000 0.000 1 0.000
#> GSM892380 2 0.000 1.000 0.000 1 0.000
#> GSM892386 2 0.000 1.000 0.000 1 0.000
#> GSM892390 2 0.000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.0336 0.973 0.000 0 0.992 0.008
#> GSM892345 4 0.0000 0.987 0.000 0 0.000 1.000
#> GSM892349 4 0.0000 0.987 0.000 0 0.000 1.000
#> GSM892353 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892355 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892361 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892365 3 0.0000 0.975 0.000 0 1.000 0.000
#> GSM892369 3 0.0336 0.973 0.000 0 0.992 0.008
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892344 3 0.0336 0.973 0.000 0 0.992 0.008
#> GSM892347 4 0.0000 0.987 0.000 0 0.000 1.000
#> GSM892351 4 0.0000 0.987 0.000 0 0.000 1.000
#> GSM892357 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892359 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892363 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892367 3 0.0000 0.975 0.000 0 1.000 0.000
#> GSM892371 3 0.0336 0.973 0.000 0 0.992 0.008
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892341 3 0.0336 0.973 0.000 0 0.992 0.008
#> GSM892346 4 0.0336 0.982 0.008 0 0.000 0.992
#> GSM892350 4 0.0000 0.987 0.000 0 0.000 1.000
#> GSM892354 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892356 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892362 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892366 3 0.0000 0.975 0.000 0 1.000 0.000
#> GSM892370 3 0.0336 0.973 0.000 0 0.992 0.008
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892343 3 0.3873 0.711 0.000 0 0.772 0.228
#> GSM892348 4 0.0188 0.985 0.004 0 0.000 0.996
#> GSM892352 4 0.1940 0.918 0.000 0 0.076 0.924
#> GSM892358 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892360 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892364 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892368 3 0.0000 0.975 0.000 0 1.000 0.000
#> GSM892372 3 0.0000 0.975 0.000 0 1.000 0.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 5 0.0703 0.875 0.000 0 0.024 0.000 0.976
#> GSM892345 4 0.0162 0.994 0.000 0 0.004 0.996 0.000
#> GSM892349 5 0.4047 0.561 0.000 0 0.004 0.320 0.676
#> GSM892353 1 0.0162 0.997 0.996 0 0.000 0.000 0.004
#> GSM892355 1 0.0162 0.997 0.996 0 0.000 0.000 0.004
#> GSM892361 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892365 3 0.3395 0.835 0.000 0 0.764 0.000 0.236
#> GSM892369 3 0.0000 0.870 0.000 0 1.000 0.000 0.000
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892344 5 0.0609 0.875 0.000 0 0.020 0.000 0.980
#> GSM892347 4 0.0162 0.994 0.000 0 0.000 0.996 0.004
#> GSM892351 4 0.0451 0.991 0.000 0 0.004 0.988 0.008
#> GSM892357 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892359 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892367 3 0.1270 0.878 0.000 0 0.948 0.000 0.052
#> GSM892371 3 0.0000 0.870 0.000 0 1.000 0.000 0.000
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892341 5 0.0703 0.875 0.000 0 0.024 0.000 0.976
#> GSM892346 4 0.0162 0.993 0.000 0 0.004 0.996 0.000
#> GSM892350 4 0.0162 0.994 0.000 0 0.000 0.996 0.004
#> GSM892354 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892356 1 0.0162 0.997 0.996 0 0.000 0.000 0.004
#> GSM892362 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892366 3 0.3424 0.831 0.000 0 0.760 0.000 0.240
#> GSM892370 3 0.0000 0.870 0.000 0 1.000 0.000 0.000
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892343 5 0.1774 0.873 0.000 0 0.016 0.052 0.932
#> GSM892348 4 0.0162 0.993 0.000 0 0.004 0.996 0.000
#> GSM892352 5 0.2338 0.839 0.000 0 0.004 0.112 0.884
#> GSM892358 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892360 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892364 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892368 3 0.3274 0.845 0.000 0 0.780 0.000 0.220
#> GSM892372 3 0.2605 0.872 0.000 0 0.852 0.000 0.148
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.1910 0.787 0.000 0.000 0.108 0.000 0.892 NA
#> GSM892345 4 0.0820 0.949 0.000 0.000 0.000 0.972 0.016 NA
#> GSM892349 5 0.5983 0.248 0.000 0.000 0.004 0.340 0.452 NA
#> GSM892353 1 0.1814 0.930 0.900 0.000 0.000 0.000 0.000 NA
#> GSM892355 1 0.1501 0.947 0.924 0.000 0.000 0.000 0.000 NA
#> GSM892361 1 0.0260 0.979 0.992 0.000 0.000 0.000 0.000 NA
#> GSM892365 3 0.1049 0.777 0.000 0.000 0.960 0.000 0.032 NA
#> GSM892369 3 0.3828 0.696 0.000 0.000 0.560 0.000 0.000 NA
#> GSM892373 2 0.0865 0.974 0.000 0.964 0.000 0.000 0.000 NA
#> GSM892377 2 0.0713 0.978 0.000 0.972 0.000 0.000 0.000 NA
#> GSM892381 2 0.0146 0.990 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892383 2 0.0000 0.990 0.000 1.000 0.000 0.000 0.000 NA
#> GSM892387 2 0.0146 0.990 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892344 5 0.1806 0.790 0.000 0.000 0.088 0.000 0.908 NA
#> GSM892347 4 0.0363 0.949 0.000 0.000 0.000 0.988 0.000 NA
#> GSM892351 4 0.2629 0.882 0.000 0.000 0.000 0.868 0.040 NA
#> GSM892357 1 0.0260 0.979 0.992 0.000 0.000 0.000 0.000 NA
#> GSM892359 1 0.0146 0.979 0.996 0.000 0.000 0.000 0.000 NA
#> GSM892363 1 0.0260 0.980 0.992 0.000 0.000 0.000 0.000 NA
#> GSM892367 3 0.2302 0.781 0.000 0.000 0.872 0.000 0.008 NA
#> GSM892371 3 0.3810 0.701 0.000 0.000 0.572 0.000 0.000 NA
#> GSM892375 2 0.0260 0.990 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892379 2 0.0363 0.988 0.000 0.988 0.000 0.000 0.000 NA
#> GSM892385 2 0.0000 0.990 0.000 1.000 0.000 0.000 0.000 NA
#> GSM892389 2 0.0260 0.990 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892341 5 0.1910 0.785 0.000 0.000 0.108 0.000 0.892 NA
#> GSM892346 4 0.0993 0.939 0.000 0.000 0.000 0.964 0.012 NA
#> GSM892350 4 0.1265 0.940 0.000 0.000 0.000 0.948 0.008 NA
#> GSM892354 1 0.0260 0.979 0.992 0.000 0.000 0.000 0.000 NA
#> GSM892356 1 0.1075 0.964 0.952 0.000 0.000 0.000 0.000 NA
#> GSM892362 1 0.0146 0.980 0.996 0.000 0.000 0.000 0.000 NA
#> GSM892366 3 0.0935 0.779 0.000 0.000 0.964 0.000 0.032 NA
#> GSM892370 3 0.3828 0.696 0.000 0.000 0.560 0.000 0.000 NA
#> GSM892374 2 0.0865 0.974 0.000 0.964 0.000 0.000 0.000 NA
#> GSM892378 2 0.0713 0.978 0.000 0.972 0.000 0.000 0.000 NA
#> GSM892382 2 0.0146 0.990 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892384 2 0.0146 0.990 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892388 2 0.0146 0.990 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892343 5 0.3694 0.755 0.000 0.000 0.044 0.032 0.812 NA
#> GSM892348 4 0.0891 0.940 0.000 0.000 0.000 0.968 0.008 NA
#> GSM892352 5 0.4534 0.654 0.000 0.000 0.008 0.052 0.672 NA
#> GSM892358 1 0.0146 0.979 0.996 0.000 0.000 0.000 0.000 NA
#> GSM892360 1 0.0146 0.979 0.996 0.000 0.000 0.000 0.000 NA
#> GSM892364 1 0.0458 0.978 0.984 0.000 0.000 0.000 0.000 NA
#> GSM892368 3 0.0935 0.781 0.000 0.000 0.964 0.000 0.032 NA
#> GSM892372 3 0.0914 0.787 0.000 0.000 0.968 0.000 0.016 NA
#> GSM892376 2 0.0260 0.990 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892380 2 0.0260 0.990 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892386 2 0.0260 0.990 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892390 2 0.0146 0.990 0.000 0.996 0.000 0.000 0.000 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> SD:skmeans 50 1.000 0.934 2.67e-07 1.42e-03 2
#> SD:skmeans 47 0.847 0.875 1.47e-11 8.15e-05 3
#> SD:skmeans 50 1.000 0.986 6.71e-18 2.02e-07 4
#> SD:skmeans 50 1.000 0.998 3.06e-20 2.01e-07 5
#> SD:skmeans 49 0.996 0.982 2.33e-20 7.98e-08 6
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 31632 rows and 50 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 1.000 1.000 0.4707 0.530 0.530
#> 3 3 0.956 0.969 0.985 0.4258 0.798 0.619
#> 4 4 1.000 0.987 0.994 0.1135 0.912 0.737
#> 5 5 0.968 0.960 0.971 0.0348 0.958 0.840
#> 6 6 1.000 0.970 0.987 0.0173 0.988 0.946
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
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.0000 0.974 0.000 0 1.000
#> GSM892345 3 0.3116 0.898 0.108 0 0.892
#> GSM892349 3 0.0000 0.974 0.000 0 1.000
#> GSM892353 1 0.0000 0.975 1.000 0 0.000
#> GSM892355 1 0.0000 0.975 1.000 0 0.000
#> GSM892361 1 0.0000 0.975 1.000 0 0.000
#> GSM892365 3 0.0000 0.974 0.000 0 1.000
#> GSM892369 3 0.0000 0.974 0.000 0 1.000
#> GSM892373 2 0.0000 1.000 0.000 1 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000
#> GSM892344 3 0.0000 0.974 0.000 0 1.000
#> GSM892347 3 0.2448 0.926 0.076 0 0.924
#> GSM892351 3 0.1163 0.960 0.028 0 0.972
#> GSM892357 1 0.0000 0.975 1.000 0 0.000
#> GSM892359 1 0.0000 0.975 1.000 0 0.000
#> GSM892363 1 0.0000 0.975 1.000 0 0.000
#> GSM892367 3 0.0000 0.974 0.000 0 1.000
#> GSM892371 3 0.0000 0.974 0.000 0 1.000
#> GSM892375 2 0.0000 1.000 0.000 1 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000
#> GSM892341 3 0.0000 0.974 0.000 0 1.000
#> GSM892346 1 0.5397 0.586 0.720 0 0.280
#> GSM892350 3 0.3116 0.898 0.108 0 0.892
#> GSM892354 1 0.0000 0.975 1.000 0 0.000
#> GSM892356 1 0.0000 0.975 1.000 0 0.000
#> GSM892362 1 0.0000 0.975 1.000 0 0.000
#> GSM892366 3 0.0000 0.974 0.000 0 1.000
#> GSM892370 3 0.0000 0.974 0.000 0 1.000
#> GSM892374 2 0.0000 1.000 0.000 1 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000
#> GSM892343 3 0.0747 0.966 0.016 0 0.984
#> GSM892348 3 0.3412 0.881 0.124 0 0.876
#> GSM892352 3 0.0000 0.974 0.000 0 1.000
#> GSM892358 1 0.0000 0.975 1.000 0 0.000
#> GSM892360 1 0.0000 0.975 1.000 0 0.000
#> GSM892364 1 0.0237 0.972 0.996 0 0.004
#> GSM892368 3 0.0000 0.974 0.000 0 1.000
#> GSM892372 3 0.0000 0.974 0.000 0 1.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.0000 0.970 0.000 0 1.000 0.000
#> GSM892345 4 0.0000 0.998 0.000 0 0.000 1.000
#> GSM892349 4 0.0000 0.998 0.000 0 0.000 1.000
#> GSM892353 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892355 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892361 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892365 3 0.0000 0.970 0.000 0 1.000 0.000
#> GSM892369 3 0.0000 0.970 0.000 0 1.000 0.000
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892344 3 0.3528 0.767 0.000 0 0.808 0.192
#> GSM892347 4 0.0000 0.998 0.000 0 0.000 1.000
#> GSM892351 4 0.0000 0.998 0.000 0 0.000 1.000
#> GSM892357 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892359 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892363 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892367 3 0.0000 0.970 0.000 0 1.000 0.000
#> GSM892371 3 0.2281 0.888 0.000 0 0.904 0.096
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892341 3 0.0000 0.970 0.000 0 1.000 0.000
#> GSM892346 4 0.0188 0.995 0.004 0 0.000 0.996
#> GSM892350 4 0.0000 0.998 0.000 0 0.000 1.000
#> GSM892354 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892356 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892362 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892366 3 0.0000 0.970 0.000 0 1.000 0.000
#> GSM892370 3 0.0000 0.970 0.000 0 1.000 0.000
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892343 4 0.0000 0.998 0.000 0 0.000 1.000
#> GSM892348 4 0.0000 0.998 0.000 0 0.000 1.000
#> GSM892352 4 0.0336 0.992 0.000 0 0.008 0.992
#> GSM892358 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892360 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892364 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892368 3 0.0000 0.970 0.000 0 1.000 0.000
#> GSM892372 3 0.0000 0.970 0.000 0 1.000 0.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 5 0.0000 0.849 0.000 0 0.000 0.000 1.000
#> GSM892345 4 0.0000 1.000 0.000 0 0.000 1.000 0.000
#> GSM892349 5 0.4060 0.561 0.000 0 0.000 0.360 0.640
#> GSM892353 1 0.2127 0.874 0.892 0 0.000 0.000 0.108
#> GSM892355 1 0.0000 0.990 1.000 0 0.000 0.000 0.000
#> GSM892361 1 0.0000 0.990 1.000 0 0.000 0.000 0.000
#> GSM892365 3 0.2471 0.936 0.000 0 0.864 0.000 0.136
#> GSM892369 3 0.0000 0.913 0.000 0 1.000 0.000 0.000
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892344 5 0.1121 0.862 0.000 0 0.000 0.044 0.956
#> GSM892347 4 0.0000 1.000 0.000 0 0.000 1.000 0.000
#> GSM892351 4 0.0000 1.000 0.000 0 0.000 1.000 0.000
#> GSM892357 1 0.0000 0.990 1.000 0 0.000 0.000 0.000
#> GSM892359 1 0.0000 0.990 1.000 0 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.990 1.000 0 0.000 0.000 0.000
#> GSM892367 3 0.1792 0.934 0.000 0 0.916 0.000 0.084
#> GSM892371 3 0.0771 0.902 0.000 0 0.976 0.020 0.004
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892341 5 0.0000 0.849 0.000 0 0.000 0.000 1.000
#> GSM892346 4 0.0000 1.000 0.000 0 0.000 1.000 0.000
#> GSM892350 4 0.0000 1.000 0.000 0 0.000 1.000 0.000
#> GSM892354 1 0.0000 0.990 1.000 0 0.000 0.000 0.000
#> GSM892356 1 0.0000 0.990 1.000 0 0.000 0.000 0.000
#> GSM892362 1 0.0000 0.990 1.000 0 0.000 0.000 0.000
#> GSM892366 3 0.2471 0.936 0.000 0 0.864 0.000 0.136
#> GSM892370 3 0.0000 0.913 0.000 0 1.000 0.000 0.000
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892343 5 0.2377 0.848 0.000 0 0.000 0.128 0.872
#> GSM892348 4 0.0000 1.000 0.000 0 0.000 1.000 0.000
#> GSM892352 5 0.2605 0.838 0.000 0 0.000 0.148 0.852
#> GSM892358 1 0.0000 0.990 1.000 0 0.000 0.000 0.000
#> GSM892360 1 0.0000 0.990 1.000 0 0.000 0.000 0.000
#> GSM892364 1 0.0000 0.990 1.000 0 0.000 0.000 0.000
#> GSM892368 3 0.2471 0.936 0.000 0 0.864 0.000 0.136
#> GSM892372 3 0.2471 0.936 0.000 0 0.864 0.000 0.136
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.0000 0.927 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM892345 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM892349 5 0.3330 0.616 0.000 0.000 0.000 0.284 0.716 0.000
#> GSM892353 1 0.1910 0.872 0.892 0.000 0.000 0.000 0.108 0.000
#> GSM892355 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892361 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892365 3 0.0000 0.951 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM892369 6 0.0260 1.000 0.000 0.000 0.008 0.000 0.000 0.992
#> GSM892373 2 0.0260 0.994 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM892377 2 0.0260 0.994 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM892381 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892383 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892387 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892344 5 0.0000 0.927 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM892347 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM892351 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM892357 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892359 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892367 3 0.2697 0.766 0.000 0.000 0.812 0.000 0.000 0.188
#> GSM892371 6 0.0260 1.000 0.000 0.000 0.008 0.000 0.000 0.992
#> GSM892375 2 0.0146 0.996 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM892379 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892385 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892389 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892341 5 0.0000 0.927 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM892346 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM892350 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM892354 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892356 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892362 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892366 3 0.0000 0.951 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM892370 6 0.0260 1.000 0.000 0.000 0.008 0.000 0.000 0.992
#> GSM892374 2 0.0260 0.994 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM892378 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892382 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892384 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892388 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892343 5 0.0000 0.927 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM892348 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM892352 5 0.0713 0.912 0.000 0.000 0.000 0.028 0.972 0.000
#> GSM892358 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892360 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892364 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892368 3 0.0000 0.951 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM892372 3 0.0000 0.951 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM892376 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892380 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892386 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892390 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> SD:pam 50 1.000 0.934 2.67e-07 1.42e-03 2
#> SD:pam 50 0.937 0.873 9.23e-12 3.89e-05 3
#> SD:pam 50 0.977 0.951 1.45e-16 7.83e-07 4
#> SD:pam 50 1.000 0.998 3.06e-20 2.01e-07 5
#> SD:pam 50 0.991 0.984 4.62e-22 7.12e-08 6
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 31632 rows and 50 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 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 1.000 1.000 1.000 0.4158 0.804 0.630
#> 4 4 0.971 0.919 0.967 0.1192 0.919 0.758
#> 5 5 1.000 0.992 0.996 0.0377 0.958 0.840
#> 6 6 0.980 0.927 0.969 0.0279 0.978 0.903
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
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0 1 0 0 1
#> GSM892345 3 0 1 0 0 1
#> GSM892349 3 0 1 0 0 1
#> GSM892353 1 0 1 1 0 0
#> GSM892355 1 0 1 1 0 0
#> GSM892361 1 0 1 1 0 0
#> GSM892365 3 0 1 0 0 1
#> GSM892369 3 0 1 0 0 1
#> GSM892373 2 0 1 0 1 0
#> GSM892377 2 0 1 0 1 0
#> GSM892381 2 0 1 0 1 0
#> GSM892383 2 0 1 0 1 0
#> GSM892387 2 0 1 0 1 0
#> GSM892344 3 0 1 0 0 1
#> GSM892347 3 0 1 0 0 1
#> GSM892351 3 0 1 0 0 1
#> GSM892357 1 0 1 1 0 0
#> GSM892359 1 0 1 1 0 0
#> GSM892363 1 0 1 1 0 0
#> GSM892367 3 0 1 0 0 1
#> GSM892371 3 0 1 0 0 1
#> GSM892375 2 0 1 0 1 0
#> GSM892379 2 0 1 0 1 0
#> GSM892385 2 0 1 0 1 0
#> GSM892389 2 0 1 0 1 0
#> GSM892341 3 0 1 0 0 1
#> GSM892346 3 0 1 0 0 1
#> GSM892350 3 0 1 0 0 1
#> GSM892354 1 0 1 1 0 0
#> GSM892356 1 0 1 1 0 0
#> GSM892362 1 0 1 1 0 0
#> GSM892366 3 0 1 0 0 1
#> GSM892370 3 0 1 0 0 1
#> GSM892374 2 0 1 0 1 0
#> GSM892378 2 0 1 0 1 0
#> GSM892382 2 0 1 0 1 0
#> GSM892384 2 0 1 0 1 0
#> GSM892388 2 0 1 0 1 0
#> GSM892343 3 0 1 0 0 1
#> GSM892348 3 0 1 0 0 1
#> GSM892352 3 0 1 0 0 1
#> GSM892358 1 0 1 1 0 0
#> GSM892360 1 0 1 1 0 0
#> GSM892364 1 0 1 1 0 0
#> GSM892368 3 0 1 0 0 1
#> GSM892372 3 0 1 0 0 1
#> GSM892376 2 0 1 0 1 0
#> GSM892380 2 0 1 0 1 0
#> GSM892386 2 0 1 0 1 0
#> GSM892390 2 0 1 0 1 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.0000 0.8782 0 0 1.000 0.000
#> GSM892345 4 0.0000 0.9167 0 0 0.000 1.000
#> GSM892349 4 0.0592 0.9079 0 0 0.016 0.984
#> GSM892353 1 0.0000 1.0000 1 0 0.000 0.000
#> GSM892355 1 0.0000 1.0000 1 0 0.000 0.000
#> GSM892361 1 0.0000 1.0000 1 0 0.000 0.000
#> GSM892365 3 0.0000 0.8782 0 0 1.000 0.000
#> GSM892369 3 0.4564 0.4888 0 0 0.672 0.328
#> GSM892373 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892377 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892381 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892383 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892387 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892344 3 0.0469 0.8769 0 0 0.988 0.012
#> GSM892347 4 0.0000 0.9167 0 0 0.000 1.000
#> GSM892351 4 0.0000 0.9167 0 0 0.000 1.000
#> GSM892357 1 0.0000 1.0000 1 0 0.000 0.000
#> GSM892359 1 0.0000 1.0000 1 0 0.000 0.000
#> GSM892363 1 0.0000 1.0000 1 0 0.000 0.000
#> GSM892367 3 0.1022 0.8624 0 0 0.968 0.032
#> GSM892371 3 0.4985 0.0974 0 0 0.532 0.468
#> GSM892375 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892379 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892385 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892389 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892341 3 0.0188 0.8785 0 0 0.996 0.004
#> GSM892346 4 0.0000 0.9167 0 0 0.000 1.000
#> GSM892350 4 0.0000 0.9167 0 0 0.000 1.000
#> GSM892354 1 0.0000 1.0000 1 0 0.000 0.000
#> GSM892356 1 0.0000 1.0000 1 0 0.000 0.000
#> GSM892362 1 0.0000 1.0000 1 0 0.000 0.000
#> GSM892366 3 0.0188 0.8782 0 0 0.996 0.004
#> GSM892370 4 0.4164 0.6298 0 0 0.264 0.736
#> GSM892374 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892378 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892382 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892384 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892388 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892343 3 0.3726 0.7082 0 0 0.788 0.212
#> GSM892348 4 0.0000 0.9167 0 0 0.000 1.000
#> GSM892352 4 0.4304 0.5967 0 0 0.284 0.716
#> GSM892358 1 0.0000 1.0000 1 0 0.000 0.000
#> GSM892360 1 0.0000 1.0000 1 0 0.000 0.000
#> GSM892364 1 0.0000 1.0000 1 0 0.000 0.000
#> GSM892368 3 0.0000 0.8782 0 0 1.000 0.000
#> GSM892372 3 0.0592 0.8744 0 0 0.984 0.016
#> GSM892376 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892380 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892386 2 0.0000 1.0000 0 1 0.000 0.000
#> GSM892390 2 0.0000 1.0000 0 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 3 0.0000 0.992 0 0 1.000 0.000 0.000
#> GSM892345 4 0.0000 1.000 0 0 0.000 1.000 0.000
#> GSM892349 5 0.2020 0.890 0 0 0.000 0.100 0.900
#> GSM892353 1 0.0000 1.000 1 0 0.000 0.000 0.000
#> GSM892355 1 0.0000 1.000 1 0 0.000 0.000 0.000
#> GSM892361 1 0.0000 1.000 1 0 0.000 0.000 0.000
#> GSM892365 3 0.0000 0.992 0 0 1.000 0.000 0.000
#> GSM892369 5 0.0609 0.965 0 0 0.020 0.000 0.980
#> GSM892373 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892377 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892381 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892383 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892387 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892344 3 0.1410 0.938 0 0 0.940 0.000 0.060
#> GSM892347 4 0.0000 1.000 0 0 0.000 1.000 0.000
#> GSM892351 4 0.0000 1.000 0 0 0.000 1.000 0.000
#> GSM892357 1 0.0000 1.000 1 0 0.000 0.000 0.000
#> GSM892359 1 0.0000 1.000 1 0 0.000 0.000 0.000
#> GSM892363 1 0.0000 1.000 1 0 0.000 0.000 0.000
#> GSM892367 3 0.0000 0.992 0 0 1.000 0.000 0.000
#> GSM892371 5 0.0000 0.973 0 0 0.000 0.000 1.000
#> GSM892375 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892379 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892385 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892389 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892341 3 0.0000 0.992 0 0 1.000 0.000 0.000
#> GSM892346 4 0.0000 1.000 0 0 0.000 1.000 0.000
#> GSM892350 4 0.0000 1.000 0 0 0.000 1.000 0.000
#> GSM892354 1 0.0000 1.000 1 0 0.000 0.000 0.000
#> GSM892356 1 0.0000 1.000 1 0 0.000 0.000 0.000
#> GSM892362 1 0.0000 1.000 1 0 0.000 0.000 0.000
#> GSM892366 3 0.0000 0.992 0 0 1.000 0.000 0.000
#> GSM892370 5 0.0290 0.972 0 0 0.008 0.000 0.992
#> GSM892374 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892378 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892382 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892384 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892388 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892343 5 0.0162 0.973 0 0 0.000 0.004 0.996
#> GSM892348 4 0.0000 1.000 0 0 0.000 1.000 0.000
#> GSM892352 5 0.0000 0.973 0 0 0.000 0.000 1.000
#> GSM892358 1 0.0000 1.000 1 0 0.000 0.000 0.000
#> GSM892360 1 0.0000 1.000 1 0 0.000 0.000 0.000
#> GSM892364 1 0.0000 1.000 1 0 0.000 0.000 0.000
#> GSM892368 3 0.0000 0.992 0 0 1.000 0.000 0.000
#> GSM892372 3 0.0000 0.992 0 0 1.000 0.000 0.000
#> GSM892376 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892380 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892386 2 0.0000 1.000 0 1 0.000 0.000 0.000
#> GSM892390 2 0.0000 1.000 0 1 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 3 0.0146 0.963 0.000 0 0.996 0.000 0.004 0.000
#> GSM892345 4 0.0260 0.989 0.000 0 0.000 0.992 0.000 0.008
#> GSM892349 5 0.0972 0.962 0.000 0 0.000 0.028 0.964 0.008
#> GSM892353 6 0.0632 0.657 0.024 0 0.000 0.000 0.000 0.976
#> GSM892355 6 0.3198 0.660 0.260 0 0.000 0.000 0.000 0.740
#> GSM892361 1 0.0000 0.905 1.000 0 0.000 0.000 0.000 0.000
#> GSM892365 3 0.0000 0.964 0.000 0 1.000 0.000 0.000 0.000
#> GSM892369 5 0.0146 0.988 0.000 0 0.004 0.000 0.996 0.000
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892344 3 0.2664 0.775 0.000 0 0.816 0.000 0.184 0.000
#> GSM892347 4 0.0000 0.991 0.000 0 0.000 1.000 0.000 0.000
#> GSM892351 4 0.0713 0.974 0.000 0 0.000 0.972 0.000 0.028
#> GSM892357 1 0.0000 0.905 1.000 0 0.000 0.000 0.000 0.000
#> GSM892359 1 0.0937 0.878 0.960 0 0.000 0.000 0.000 0.040
#> GSM892363 1 0.0146 0.904 0.996 0 0.000 0.000 0.000 0.004
#> GSM892367 3 0.0000 0.964 0.000 0 1.000 0.000 0.000 0.000
#> GSM892371 5 0.0000 0.988 0.000 0 0.000 0.000 1.000 0.000
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892341 3 0.0458 0.959 0.000 0 0.984 0.000 0.016 0.000
#> GSM892346 4 0.0260 0.989 0.000 0 0.000 0.992 0.000 0.008
#> GSM892350 4 0.0146 0.990 0.000 0 0.000 0.996 0.000 0.004
#> GSM892354 1 0.0363 0.900 0.988 0 0.000 0.000 0.000 0.012
#> GSM892356 1 0.1387 0.840 0.932 0 0.000 0.000 0.000 0.068
#> GSM892362 1 0.0000 0.905 1.000 0 0.000 0.000 0.000 0.000
#> GSM892366 3 0.0000 0.964 0.000 0 1.000 0.000 0.000 0.000
#> GSM892370 5 0.0146 0.988 0.000 0 0.004 0.000 0.996 0.000
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892343 5 0.0405 0.984 0.000 0 0.004 0.008 0.988 0.000
#> GSM892348 4 0.0000 0.991 0.000 0 0.000 1.000 0.000 0.000
#> GSM892352 5 0.0000 0.988 0.000 0 0.000 0.000 1.000 0.000
#> GSM892358 6 0.3672 0.500 0.368 0 0.000 0.000 0.000 0.632
#> GSM892360 1 0.0000 0.905 1.000 0 0.000 0.000 0.000 0.000
#> GSM892364 1 0.3854 0.049 0.536 0 0.000 0.000 0.000 0.464
#> GSM892368 3 0.0000 0.964 0.000 0 1.000 0.000 0.000 0.000
#> GSM892372 3 0.0547 0.956 0.000 0 0.980 0.000 0.020 0.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> SD:mclust 50 1.000 0.934 2.67e-07 1.42e-03 2
#> SD:mclust 50 1.000 0.931 1.26e-12 1.60e-05 3
#> SD:mclust 48 0.987 0.948 6.57e-16 1.01e-06 4
#> SD:mclust 50 1.000 0.998 1.59e-16 6.55e-06 5
#> SD:mclust 48 0.860 0.863 1.85e-13 3.25e-04 6
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 31632 rows and 50 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 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 0.927 0.922 0.966 0.4345 0.792 0.607
#> 4 4 0.996 0.966 0.979 0.0990 0.909 0.729
#> 5 5 0.951 0.930 0.944 0.0348 0.958 0.838
#> 6 6 0.924 0.926 0.944 0.0139 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] 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
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.000 0.967 0.000 0 1.000
#> GSM892345 1 0.536 0.673 0.724 0 0.276
#> GSM892349 3 0.000 0.967 0.000 0 1.000
#> GSM892353 1 0.000 0.910 1.000 0 0.000
#> GSM892355 1 0.000 0.910 1.000 0 0.000
#> GSM892361 1 0.000 0.910 1.000 0 0.000
#> GSM892365 3 0.000 0.967 0.000 0 1.000
#> GSM892369 3 0.000 0.967 0.000 0 1.000
#> GSM892373 2 0.000 1.000 0.000 1 0.000
#> GSM892377 2 0.000 1.000 0.000 1 0.000
#> GSM892381 2 0.000 1.000 0.000 1 0.000
#> GSM892383 2 0.000 1.000 0.000 1 0.000
#> GSM892387 2 0.000 1.000 0.000 1 0.000
#> GSM892344 3 0.000 0.967 0.000 0 1.000
#> GSM892347 1 0.581 0.575 0.664 0 0.336
#> GSM892351 3 0.593 0.337 0.356 0 0.644
#> GSM892357 1 0.000 0.910 1.000 0 0.000
#> GSM892359 1 0.000 0.910 1.000 0 0.000
#> GSM892363 1 0.000 0.910 1.000 0 0.000
#> GSM892367 3 0.000 0.967 0.000 0 1.000
#> GSM892371 3 0.000 0.967 0.000 0 1.000
#> GSM892375 2 0.000 1.000 0.000 1 0.000
#> GSM892379 2 0.000 1.000 0.000 1 0.000
#> GSM892385 2 0.000 1.000 0.000 1 0.000
#> GSM892389 2 0.000 1.000 0.000 1 0.000
#> GSM892341 3 0.000 0.967 0.000 0 1.000
#> GSM892346 1 0.382 0.812 0.852 0 0.148
#> GSM892350 1 0.590 0.543 0.648 0 0.352
#> GSM892354 1 0.000 0.910 1.000 0 0.000
#> GSM892356 1 0.000 0.910 1.000 0 0.000
#> GSM892362 1 0.000 0.910 1.000 0 0.000
#> GSM892366 3 0.000 0.967 0.000 0 1.000
#> GSM892370 3 0.000 0.967 0.000 0 1.000
#> GSM892374 2 0.000 1.000 0.000 1 0.000
#> GSM892378 2 0.000 1.000 0.000 1 0.000
#> GSM892382 2 0.000 1.000 0.000 1 0.000
#> GSM892384 2 0.000 1.000 0.000 1 0.000
#> GSM892388 2 0.000 1.000 0.000 1 0.000
#> GSM892343 3 0.153 0.927 0.040 0 0.960
#> GSM892348 1 0.475 0.748 0.784 0 0.216
#> GSM892352 3 0.000 0.967 0.000 0 1.000
#> GSM892358 1 0.000 0.910 1.000 0 0.000
#> GSM892360 1 0.000 0.910 1.000 0 0.000
#> GSM892364 1 0.000 0.910 1.000 0 0.000
#> GSM892368 3 0.000 0.967 0.000 0 1.000
#> GSM892372 3 0.000 0.967 0.000 0 1.000
#> GSM892376 2 0.000 1.000 0.000 1 0.000
#> GSM892380 2 0.000 1.000 0.000 1 0.000
#> GSM892386 2 0.000 1.000 0.000 1 0.000
#> GSM892390 2 0.000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.0376 0.948 0.004 0.000 0.992 0.004
#> GSM892345 4 0.1022 0.966 0.000 0.000 0.032 0.968
#> GSM892349 4 0.2530 0.910 0.000 0.000 0.112 0.888
#> GSM892353 1 0.0188 0.995 0.996 0.000 0.004 0.000
#> GSM892355 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM892361 1 0.0188 0.997 0.996 0.000 0.000 0.004
#> GSM892365 3 0.0188 0.947 0.004 0.000 0.996 0.000
#> GSM892369 3 0.0817 0.945 0.000 0.000 0.976 0.024
#> GSM892373 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892377 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892381 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892383 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892387 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892344 3 0.1489 0.933 0.004 0.000 0.952 0.044
#> GSM892347 4 0.1022 0.966 0.000 0.000 0.032 0.968
#> GSM892351 4 0.1118 0.965 0.000 0.000 0.036 0.964
#> GSM892357 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM892359 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM892367 3 0.0188 0.947 0.004 0.000 0.996 0.000
#> GSM892371 3 0.1792 0.913 0.000 0.000 0.932 0.068
#> GSM892375 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892379 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892385 2 0.0188 0.997 0.000 0.996 0.000 0.004
#> GSM892389 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892341 3 0.0779 0.947 0.004 0.000 0.980 0.016
#> GSM892346 4 0.0895 0.959 0.004 0.000 0.020 0.976
#> GSM892350 4 0.1022 0.966 0.000 0.000 0.032 0.968
#> GSM892354 1 0.0188 0.997 0.996 0.000 0.000 0.004
#> GSM892356 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM892362 1 0.0188 0.997 0.996 0.000 0.000 0.004
#> GSM892366 3 0.0188 0.947 0.004 0.000 0.996 0.000
#> GSM892370 3 0.0921 0.943 0.000 0.000 0.972 0.028
#> GSM892374 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892378 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892382 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892384 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892388 2 0.0188 0.997 0.000 0.996 0.000 0.004
#> GSM892343 3 0.4730 0.411 0.000 0.000 0.636 0.364
#> GSM892348 4 0.0817 0.962 0.000 0.000 0.024 0.976
#> GSM892352 4 0.2868 0.883 0.000 0.000 0.136 0.864
#> GSM892358 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM892360 1 0.0188 0.997 0.996 0.000 0.000 0.004
#> GSM892364 1 0.0188 0.997 0.996 0.000 0.000 0.004
#> GSM892368 3 0.0188 0.947 0.004 0.000 0.996 0.000
#> GSM892372 3 0.0524 0.948 0.004 0.000 0.988 0.008
#> GSM892376 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892380 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892386 2 0.0188 0.997 0.000 0.996 0.000 0.004
#> GSM892390 2 0.0188 0.997 0.000 0.996 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 5 0.3399 0.773 0.000 0.000 0.168 0.020 0.812
#> GSM892345 4 0.1608 0.937 0.000 0.000 0.000 0.928 0.072
#> GSM892349 5 0.4564 0.447 0.000 0.000 0.016 0.372 0.612
#> GSM892353 1 0.0703 0.977 0.976 0.000 0.000 0.000 0.024
#> GSM892355 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM892361 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM892365 3 0.3336 0.822 0.000 0.000 0.772 0.000 0.228
#> GSM892369 3 0.0671 0.831 0.000 0.000 0.980 0.004 0.016
#> GSM892373 2 0.0609 0.988 0.000 0.980 0.000 0.000 0.020
#> GSM892377 2 0.0404 0.990 0.000 0.988 0.000 0.000 0.012
#> GSM892381 2 0.0162 0.995 0.000 0.996 0.000 0.000 0.004
#> GSM892383 2 0.0162 0.995 0.000 0.996 0.000 0.000 0.004
#> GSM892387 2 0.0162 0.995 0.000 0.996 0.000 0.000 0.004
#> GSM892344 5 0.3432 0.805 0.000 0.000 0.132 0.040 0.828
#> GSM892347 4 0.0703 0.943 0.000 0.000 0.000 0.976 0.024
#> GSM892351 4 0.2286 0.900 0.000 0.000 0.004 0.888 0.108
#> GSM892357 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM892359 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM892367 3 0.1638 0.874 0.000 0.000 0.932 0.004 0.064
#> GSM892371 3 0.1877 0.874 0.000 0.000 0.924 0.012 0.064
#> GSM892375 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM892379 2 0.0162 0.994 0.000 0.996 0.000 0.000 0.004
#> GSM892385 2 0.0162 0.995 0.000 0.996 0.000 0.000 0.004
#> GSM892389 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM892341 5 0.3454 0.791 0.000 0.000 0.156 0.028 0.816
#> GSM892346 4 0.0566 0.924 0.000 0.000 0.004 0.984 0.012
#> GSM892350 4 0.1478 0.942 0.000 0.000 0.000 0.936 0.064
#> GSM892354 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM892356 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM892362 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM892366 3 0.3508 0.793 0.000 0.000 0.748 0.000 0.252
#> GSM892370 3 0.0162 0.843 0.000 0.000 0.996 0.004 0.000
#> GSM892374 2 0.0609 0.985 0.000 0.980 0.000 0.000 0.020
#> GSM892378 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM892382 2 0.0162 0.995 0.000 0.996 0.000 0.000 0.004
#> GSM892384 2 0.0162 0.995 0.000 0.996 0.000 0.000 0.004
#> GSM892388 2 0.0510 0.991 0.000 0.984 0.000 0.000 0.016
#> GSM892343 5 0.4364 0.802 0.000 0.000 0.112 0.120 0.768
#> GSM892348 4 0.0000 0.934 0.000 0.000 0.000 1.000 0.000
#> GSM892352 5 0.3852 0.710 0.000 0.000 0.020 0.220 0.760
#> GSM892358 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM892360 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM892364 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM892368 3 0.3010 0.866 0.000 0.000 0.824 0.004 0.172
#> GSM892372 3 0.2930 0.870 0.000 0.000 0.832 0.004 0.164
#> GSM892376 2 0.0162 0.995 0.000 0.996 0.000 0.000 0.004
#> GSM892380 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM892386 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM892390 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.2163 0.814 0.000 0.000 0.096 0.004 0.892 NA
#> GSM892345 4 0.2178 0.880 0.000 0.000 0.000 0.868 0.132 NA
#> GSM892349 5 0.3684 0.522 0.000 0.000 0.004 0.332 0.664 NA
#> GSM892353 1 0.0363 0.989 0.988 0.000 0.000 0.000 0.012 NA
#> GSM892355 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892361 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892365 3 0.1387 0.952 0.000 0.000 0.932 0.000 0.068 NA
#> GSM892369 3 0.1078 0.943 0.000 0.000 0.964 0.012 0.016 NA
#> GSM892373 2 0.2697 0.864 0.000 0.812 0.000 0.000 0.000 NA
#> GSM892377 2 0.2003 0.916 0.000 0.884 0.000 0.000 0.000 NA
#> GSM892381 2 0.0146 0.964 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892383 2 0.0146 0.964 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892387 2 0.0260 0.964 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892344 5 0.2138 0.835 0.000 0.000 0.052 0.036 0.908 NA
#> GSM892347 4 0.1387 0.891 0.000 0.000 0.000 0.932 0.068 NA
#> GSM892351 4 0.3287 0.768 0.000 0.000 0.000 0.768 0.220 NA
#> GSM892357 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892359 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892363 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892367 3 0.0806 0.961 0.000 0.000 0.972 0.000 0.020 NA
#> GSM892371 3 0.0779 0.961 0.000 0.000 0.976 0.008 0.008 NA
#> GSM892375 2 0.0937 0.956 0.000 0.960 0.000 0.000 0.000 NA
#> GSM892379 2 0.0790 0.959 0.000 0.968 0.000 0.000 0.000 NA
#> GSM892385 2 0.0146 0.964 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892389 2 0.0260 0.964 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892341 5 0.2121 0.825 0.000 0.000 0.096 0.012 0.892 NA
#> GSM892346 4 0.1219 0.821 0.000 0.000 0.004 0.948 0.000 NA
#> GSM892350 4 0.2146 0.887 0.000 0.000 0.000 0.880 0.116 NA
#> GSM892354 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892356 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892362 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892366 3 0.1700 0.942 0.000 0.000 0.916 0.000 0.080 NA
#> GSM892370 3 0.0508 0.955 0.000 0.000 0.984 0.004 0.000 NA
#> GSM892374 2 0.2762 0.859 0.000 0.804 0.000 0.000 0.000 NA
#> GSM892378 2 0.1267 0.948 0.000 0.940 0.000 0.000 0.000 NA
#> GSM892382 2 0.0146 0.964 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892384 2 0.0000 0.964 0.000 1.000 0.000 0.000 0.000 NA
#> GSM892388 2 0.1714 0.928 0.000 0.908 0.000 0.000 0.000 NA
#> GSM892343 5 0.3103 0.826 0.000 0.000 0.064 0.100 0.836 NA
#> GSM892348 4 0.0972 0.874 0.000 0.000 0.000 0.964 0.028 NA
#> GSM892352 5 0.3323 0.731 0.000 0.000 0.008 0.204 0.780 NA
#> GSM892358 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892360 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892364 1 0.0260 0.993 0.992 0.000 0.000 0.000 0.000 NA
#> GSM892368 3 0.1349 0.957 0.000 0.000 0.940 0.000 0.056 NA
#> GSM892372 3 0.1194 0.963 0.000 0.000 0.956 0.004 0.032 NA
#> GSM892376 2 0.0363 0.964 0.000 0.988 0.000 0.000 0.000 NA
#> GSM892380 2 0.0000 0.964 0.000 1.000 0.000 0.000 0.000 NA
#> GSM892386 2 0.0000 0.964 0.000 1.000 0.000 0.000 0.000 NA
#> GSM892390 2 0.0146 0.964 0.000 0.996 0.000 0.000 0.000 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> SD:NMF 50 1.000 0.934 2.67e-07 1.42e-03 2
#> SD:NMF 49 0.981 0.952 1.63e-11 6.57e-05 3
#> SD:NMF 49 0.995 0.988 2.28e-17 4.54e-07 4
#> SD:NMF 49 0.996 0.982 2.33e-20 7.98e-08 5
#> SD:NMF 50 1.000 0.998 3.06e-20 2.01e-07 6
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 31632 rows and 50 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 0.971 0.944 0.969 0.4350 0.794 0.612
#> 4 4 0.982 0.944 0.969 0.0511 0.980 0.940
#> 5 5 0.904 0.782 0.857 0.0615 0.948 0.832
#> 6 6 0.890 0.873 0.871 0.0398 0.947 0.802
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 2 3 4
There is also optional best \(k\) = 2 3 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.0000 0.908 0.000 0 1.000
#> GSM892345 3 0.5948 0.569 0.360 0 0.640
#> GSM892349 3 0.2796 0.869 0.092 0 0.908
#> GSM892353 1 0.0000 1.000 1.000 0 0.000
#> GSM892355 1 0.0000 1.000 1.000 0 0.000
#> GSM892361 1 0.0000 1.000 1.000 0 0.000
#> GSM892365 3 0.0000 0.908 0.000 0 1.000
#> GSM892369 3 0.2165 0.891 0.064 0 0.936
#> GSM892373 2 0.0000 1.000 0.000 1 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000
#> GSM892344 3 0.0000 0.908 0.000 0 1.000
#> GSM892347 3 0.5988 0.554 0.368 0 0.632
#> GSM892351 3 0.4555 0.778 0.200 0 0.800
#> GSM892357 1 0.0000 1.000 1.000 0 0.000
#> GSM892359 1 0.0000 1.000 1.000 0 0.000
#> GSM892363 1 0.0000 1.000 1.000 0 0.000
#> GSM892367 3 0.0000 0.908 0.000 0 1.000
#> GSM892371 3 0.2165 0.891 0.064 0 0.936
#> GSM892375 2 0.0000 1.000 0.000 1 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000
#> GSM892341 3 0.0000 0.908 0.000 0 1.000
#> GSM892346 1 0.0000 1.000 1.000 0 0.000
#> GSM892350 3 0.5560 0.667 0.300 0 0.700
#> GSM892354 1 0.0000 1.000 1.000 0 0.000
#> GSM892356 1 0.0000 1.000 1.000 0 0.000
#> GSM892362 1 0.0000 1.000 1.000 0 0.000
#> GSM892366 3 0.0000 0.908 0.000 0 1.000
#> GSM892370 3 0.2165 0.891 0.064 0 0.936
#> GSM892374 2 0.0000 1.000 0.000 1 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000
#> GSM892343 3 0.0892 0.905 0.020 0 0.980
#> GSM892348 1 0.0000 1.000 1.000 0 0.000
#> GSM892352 3 0.0000 0.908 0.000 0 1.000
#> GSM892358 1 0.0000 1.000 1.000 0 0.000
#> GSM892360 1 0.0000 1.000 1.000 0 0.000
#> GSM892364 1 0.0237 0.995 0.996 0 0.004
#> GSM892368 3 0.0000 0.908 0.000 0 1.000
#> GSM892372 3 0.0000 0.908 0.000 0 1.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.0000 0.907 0.000 0 1.000 0.000
#> GSM892345 3 0.4713 0.585 0.000 0 0.640 0.360
#> GSM892349 3 0.2216 0.862 0.000 0 0.908 0.092
#> GSM892353 1 0.0000 0.999 1.000 0 0.000 0.000
#> GSM892355 1 0.0000 0.999 1.000 0 0.000 0.000
#> GSM892361 1 0.0000 0.999 1.000 0 0.000 0.000
#> GSM892365 3 0.0000 0.907 0.000 0 1.000 0.000
#> GSM892369 3 0.1716 0.886 0.000 0 0.936 0.064
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892344 3 0.0000 0.907 0.000 0 1.000 0.000
#> GSM892347 3 0.4746 0.571 0.000 0 0.632 0.368
#> GSM892351 3 0.3610 0.774 0.000 0 0.800 0.200
#> GSM892357 1 0.0000 0.999 1.000 0 0.000 0.000
#> GSM892359 1 0.0000 0.999 1.000 0 0.000 0.000
#> GSM892363 1 0.0000 0.999 1.000 0 0.000 0.000
#> GSM892367 3 0.0000 0.907 0.000 0 1.000 0.000
#> GSM892371 3 0.1716 0.886 0.000 0 0.936 0.064
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892341 3 0.0000 0.907 0.000 0 1.000 0.000
#> GSM892346 4 0.0000 1.000 0.000 0 0.000 1.000
#> GSM892350 3 0.4406 0.675 0.000 0 0.700 0.300
#> GSM892354 1 0.0000 0.999 1.000 0 0.000 0.000
#> GSM892356 1 0.0000 0.999 1.000 0 0.000 0.000
#> GSM892362 1 0.0000 0.999 1.000 0 0.000 0.000
#> GSM892366 3 0.0000 0.907 0.000 0 1.000 0.000
#> GSM892370 3 0.1716 0.886 0.000 0 0.936 0.064
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892343 3 0.0707 0.903 0.000 0 0.980 0.020
#> GSM892348 4 0.0000 1.000 0.000 0 0.000 1.000
#> GSM892352 3 0.0000 0.907 0.000 0 1.000 0.000
#> GSM892358 1 0.0000 0.999 1.000 0 0.000 0.000
#> GSM892360 1 0.0000 0.999 1.000 0 0.000 0.000
#> GSM892364 1 0.0188 0.994 0.996 0 0.004 0.000
#> GSM892368 3 0.0000 0.907 0.000 0 1.000 0.000
#> GSM892372 3 0.0000 0.907 0.000 0 1.000 0.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 3 0.5534 0.478 0.000 0 0.508 0.068 NA
#> GSM892345 4 0.3857 0.532 0.000 0 0.312 0.688 NA
#> GSM892349 3 0.6127 -0.220 0.000 0 0.456 0.416 NA
#> GSM892353 1 0.0162 0.966 0.996 0 0.000 0.000 NA
#> GSM892355 1 0.0162 0.966 0.996 0 0.000 0.000 NA
#> GSM892361 1 0.1965 0.945 0.904 0 0.000 0.000 NA
#> GSM892365 3 0.0703 0.640 0.000 0 0.976 0.000 NA
#> GSM892369 3 0.3471 0.539 0.000 0 0.836 0.072 NA
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892344 3 0.5534 0.478 0.000 0 0.508 0.068 NA
#> GSM892347 4 0.3816 0.535 0.000 0 0.304 0.696 NA
#> GSM892351 4 0.4961 0.282 0.000 0 0.448 0.524 NA
#> GSM892357 1 0.1965 0.945 0.904 0 0.000 0.000 NA
#> GSM892359 1 0.1792 0.950 0.916 0 0.000 0.000 NA
#> GSM892363 1 0.0000 0.967 1.000 0 0.000 0.000 NA
#> GSM892367 3 0.0451 0.630 0.000 0 0.988 0.008 NA
#> GSM892371 3 0.3471 0.539 0.000 0 0.836 0.072 NA
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892341 3 0.5534 0.478 0.000 0 0.508 0.068 NA
#> GSM892346 4 0.4126 0.416 0.000 0 0.000 0.620 NA
#> GSM892350 4 0.4668 0.483 0.000 0 0.352 0.624 NA
#> GSM892354 1 0.1965 0.945 0.904 0 0.000 0.000 NA
#> GSM892356 1 0.0162 0.966 0.996 0 0.000 0.000 NA
#> GSM892362 1 0.1121 0.961 0.956 0 0.000 0.000 NA
#> GSM892366 3 0.0703 0.640 0.000 0 0.976 0.000 NA
#> GSM892370 3 0.3471 0.539 0.000 0 0.836 0.072 NA
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892343 3 0.5400 0.512 0.000 0 0.632 0.096 NA
#> GSM892348 4 0.4126 0.416 0.000 0 0.000 0.620 NA
#> GSM892352 3 0.6300 0.391 0.000 0 0.424 0.152 NA
#> GSM892358 1 0.0000 0.967 1.000 0 0.000 0.000 NA
#> GSM892360 1 0.0510 0.966 0.984 0 0.000 0.000 NA
#> GSM892364 1 0.0324 0.964 0.992 0 0.004 0.000 NA
#> GSM892368 3 0.0290 0.635 0.000 0 0.992 0.000 NA
#> GSM892372 3 0.0703 0.640 0.000 0 0.976 0.000 NA
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000 NA
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000 NA
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.5737 0.888 0.000 0 0.236 0.248 0.516 0.000
#> GSM892345 4 0.4215 0.797 0.000 0 0.056 0.700 0.000 0.244
#> GSM892349 4 0.2147 0.657 0.000 0 0.084 0.896 0.020 0.000
#> GSM892353 1 0.0976 0.801 0.968 0 0.000 0.016 0.008 0.008
#> GSM892355 1 0.0976 0.801 0.968 0 0.000 0.016 0.008 0.008
#> GSM892361 1 0.3838 0.677 0.552 0 0.000 0.000 0.448 0.000
#> GSM892365 3 0.2170 0.830 0.000 0 0.888 0.100 0.012 0.000
#> GSM892369 3 0.2764 0.776 0.000 0 0.864 0.100 0.028 0.008
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892344 5 0.5737 0.888 0.000 0 0.236 0.248 0.516 0.000
#> GSM892347 4 0.4145 0.788 0.000 0 0.048 0.700 0.000 0.252
#> GSM892351 4 0.2852 0.785 0.000 0 0.064 0.856 0.000 0.080
#> GSM892357 1 0.3833 0.679 0.556 0 0.000 0.000 0.444 0.000
#> GSM892359 1 0.3765 0.700 0.596 0 0.000 0.000 0.404 0.000
#> GSM892363 1 0.0713 0.815 0.972 0 0.000 0.000 0.028 0.000
#> GSM892367 3 0.2003 0.837 0.000 0 0.884 0.116 0.000 0.000
#> GSM892371 3 0.2764 0.776 0.000 0 0.864 0.100 0.028 0.008
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892341 5 0.5737 0.888 0.000 0 0.236 0.248 0.516 0.000
#> GSM892346 6 0.0260 1.000 0.000 0 0.000 0.008 0.000 0.992
#> GSM892350 4 0.3885 0.816 0.000 0 0.064 0.756 0.000 0.180
#> GSM892354 1 0.3838 0.677 0.552 0 0.000 0.000 0.448 0.000
#> GSM892356 1 0.0976 0.801 0.968 0 0.000 0.016 0.008 0.008
#> GSM892362 1 0.2854 0.779 0.792 0 0.000 0.000 0.208 0.000
#> GSM892366 3 0.2170 0.830 0.000 0 0.888 0.100 0.012 0.000
#> GSM892370 3 0.2764 0.776 0.000 0 0.864 0.100 0.028 0.008
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892343 5 0.6029 0.725 0.000 0 0.260 0.324 0.416 0.000
#> GSM892348 6 0.0260 1.000 0.000 0 0.000 0.008 0.000 0.992
#> GSM892352 5 0.5271 0.759 0.000 0 0.104 0.380 0.516 0.000
#> GSM892358 1 0.0363 0.813 0.988 0 0.000 0.000 0.012 0.000
#> GSM892360 1 0.1327 0.812 0.936 0 0.000 0.000 0.064 0.000
#> GSM892364 1 0.0820 0.811 0.972 0 0.000 0.012 0.016 0.000
#> GSM892368 3 0.2053 0.837 0.000 0 0.888 0.108 0.004 0.000
#> GSM892372 3 0.2170 0.830 0.000 0 0.888 0.100 0.012 0.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> CV:hclust 50 1.000 0.934 2.67e-07 1.42e-03 2
#> CV:hclust 50 0.776 0.931 1.69e-11 8.93e-05 3
#> CV:hclust 50 0.528 0.986 4.32e-13 2.04e-04 4
#> CV:hclust 41 0.554 0.958 3.28e-14 9.32e-06 5
#> CV:hclust 50 0.549 0.990 7.86e-20 2.17e-06 6
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 31632 rows and 50 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 0.707 0.921 0.860 0.3385 0.794 0.612
#> 4 4 0.619 0.866 0.836 0.1225 0.928 0.783
#> 5 5 0.736 0.691 0.822 0.0795 0.974 0.902
#> 6 6 0.715 0.703 0.785 0.0485 0.974 0.892
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
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.0000 0.935 0.000 0.000 1.000
#> GSM892345 3 0.5016 0.547 0.240 0.000 0.760
#> GSM892349 3 0.0424 0.929 0.008 0.000 0.992
#> GSM892353 1 0.5591 0.986 0.696 0.000 0.304
#> GSM892355 1 0.5591 0.986 0.696 0.000 0.304
#> GSM892361 1 0.5591 0.986 0.696 0.000 0.304
#> GSM892365 3 0.0000 0.935 0.000 0.000 1.000
#> GSM892369 3 0.0000 0.935 0.000 0.000 1.000
#> GSM892373 2 0.4452 0.909 0.192 0.808 0.000
#> GSM892377 2 0.4235 0.916 0.176 0.824 0.000
#> GSM892381 2 0.0000 0.945 0.000 1.000 0.000
#> GSM892383 2 0.1411 0.942 0.036 0.964 0.000
#> GSM892387 2 0.1860 0.945 0.052 0.948 0.000
#> GSM892344 3 0.0000 0.935 0.000 0.000 1.000
#> GSM892347 3 0.5016 0.547 0.240 0.000 0.760
#> GSM892351 3 0.0424 0.929 0.008 0.000 0.992
#> GSM892357 1 0.5591 0.986 0.696 0.000 0.304
#> GSM892359 1 0.5591 0.986 0.696 0.000 0.304
#> GSM892363 1 0.5591 0.986 0.696 0.000 0.304
#> GSM892367 3 0.0000 0.935 0.000 0.000 1.000
#> GSM892371 3 0.0000 0.935 0.000 0.000 1.000
#> GSM892375 2 0.3116 0.935 0.108 0.892 0.000
#> GSM892379 2 0.2261 0.945 0.068 0.932 0.000
#> GSM892385 2 0.3340 0.919 0.120 0.880 0.000
#> GSM892389 2 0.2165 0.947 0.064 0.936 0.000
#> GSM892341 3 0.0000 0.935 0.000 0.000 1.000
#> GSM892346 1 0.5529 0.975 0.704 0.000 0.296
#> GSM892350 3 0.5016 0.547 0.240 0.000 0.760
#> GSM892354 1 0.5591 0.986 0.696 0.000 0.304
#> GSM892356 1 0.5591 0.986 0.696 0.000 0.304
#> GSM892362 1 0.5591 0.986 0.696 0.000 0.304
#> GSM892366 3 0.0000 0.935 0.000 0.000 1.000
#> GSM892370 3 0.0000 0.935 0.000 0.000 1.000
#> GSM892374 2 0.4452 0.909 0.192 0.808 0.000
#> GSM892378 2 0.4235 0.916 0.176 0.824 0.000
#> GSM892382 2 0.0000 0.945 0.000 1.000 0.000
#> GSM892384 2 0.0237 0.945 0.004 0.996 0.000
#> GSM892388 2 0.3038 0.924 0.104 0.896 0.000
#> GSM892343 3 0.0000 0.935 0.000 0.000 1.000
#> GSM892348 1 0.6140 0.792 0.596 0.000 0.404
#> GSM892352 3 0.0424 0.929 0.008 0.000 0.992
#> GSM892358 1 0.5591 0.986 0.696 0.000 0.304
#> GSM892360 1 0.5591 0.986 0.696 0.000 0.304
#> GSM892364 1 0.5591 0.986 0.696 0.000 0.304
#> GSM892368 3 0.0000 0.935 0.000 0.000 1.000
#> GSM892372 3 0.0000 0.935 0.000 0.000 1.000
#> GSM892376 2 0.2959 0.937 0.100 0.900 0.000
#> GSM892380 2 0.0000 0.945 0.000 1.000 0.000
#> GSM892386 2 0.1964 0.934 0.056 0.944 0.000
#> GSM892390 2 0.2625 0.931 0.084 0.916 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.3763 0.905 0.144 0.000 0.832 0.024
#> GSM892345 4 0.7336 0.764 0.256 0.000 0.216 0.528
#> GSM892349 3 0.4307 0.895 0.144 0.000 0.808 0.048
#> GSM892353 1 0.0188 0.996 0.996 0.000 0.000 0.004
#> GSM892355 1 0.0188 0.996 0.996 0.000 0.000 0.004
#> GSM892361 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM892365 3 0.2973 0.905 0.144 0.000 0.856 0.000
#> GSM892369 3 0.6295 0.677 0.144 0.000 0.660 0.196
#> GSM892373 2 0.4605 0.814 0.000 0.664 0.000 0.336
#> GSM892377 2 0.4807 0.839 0.000 0.728 0.024 0.248
#> GSM892381 2 0.0524 0.891 0.000 0.988 0.008 0.004
#> GSM892383 2 0.2021 0.882 0.000 0.932 0.012 0.056
#> GSM892387 2 0.3307 0.887 0.000 0.868 0.028 0.104
#> GSM892344 3 0.3763 0.905 0.144 0.000 0.832 0.024
#> GSM892347 4 0.7336 0.764 0.256 0.000 0.216 0.528
#> GSM892351 4 0.7083 0.463 0.144 0.000 0.328 0.528
#> GSM892357 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM892359 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM892367 3 0.3300 0.902 0.144 0.000 0.848 0.008
#> GSM892371 3 0.6295 0.677 0.144 0.000 0.660 0.196
#> GSM892375 2 0.3910 0.875 0.000 0.820 0.024 0.156
#> GSM892379 2 0.2737 0.894 0.000 0.888 0.008 0.104
#> GSM892385 2 0.4817 0.829 0.000 0.784 0.088 0.128
#> GSM892389 2 0.2924 0.894 0.000 0.884 0.016 0.100
#> GSM892341 3 0.3763 0.905 0.144 0.000 0.832 0.024
#> GSM892346 4 0.5000 0.430 0.496 0.000 0.000 0.504
#> GSM892350 4 0.7336 0.764 0.256 0.000 0.216 0.528
#> GSM892354 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM892356 1 0.0188 0.996 0.996 0.000 0.000 0.004
#> GSM892362 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM892366 3 0.2973 0.905 0.144 0.000 0.856 0.000
#> GSM892370 3 0.6295 0.677 0.144 0.000 0.660 0.196
#> GSM892374 2 0.4605 0.814 0.000 0.664 0.000 0.336
#> GSM892378 2 0.4776 0.840 0.000 0.732 0.024 0.244
#> GSM892382 2 0.0524 0.891 0.000 0.988 0.008 0.004
#> GSM892384 2 0.0927 0.891 0.000 0.976 0.016 0.008
#> GSM892388 2 0.5080 0.830 0.000 0.764 0.092 0.144
#> GSM892343 3 0.4541 0.886 0.144 0.000 0.796 0.060
#> GSM892348 4 0.6229 0.631 0.416 0.000 0.056 0.528
#> GSM892352 3 0.3763 0.905 0.144 0.000 0.832 0.024
#> GSM892358 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM892360 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM892364 1 0.0188 0.996 0.996 0.000 0.000 0.004
#> GSM892368 3 0.2973 0.905 0.144 0.000 0.856 0.000
#> GSM892372 3 0.3300 0.902 0.144 0.000 0.848 0.008
#> GSM892376 2 0.3862 0.876 0.000 0.824 0.024 0.152
#> GSM892380 2 0.0817 0.893 0.000 0.976 0.000 0.024
#> GSM892386 2 0.3168 0.877 0.000 0.884 0.060 0.056
#> GSM892390 2 0.3652 0.867 0.000 0.856 0.052 0.092
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 3 0.2376 0.827 0.052 0.000 0.904 0.044 0.000
#> GSM892345 4 0.4280 0.850 0.088 0.000 0.140 0.772 0.000
#> GSM892349 3 0.3849 0.793 0.052 0.000 0.820 0.116 0.012
#> GSM892353 1 0.1478 0.925 0.936 0.000 0.000 0.000 0.064
#> GSM892355 1 0.1478 0.925 0.936 0.000 0.000 0.000 0.064
#> GSM892361 1 0.1671 0.938 0.924 0.000 0.000 0.000 0.076
#> GSM892365 3 0.2592 0.835 0.052 0.000 0.892 0.000 0.056
#> GSM892369 3 0.6737 0.596 0.052 0.000 0.584 0.208 0.156
#> GSM892373 5 0.4593 1.000 0.000 0.480 0.004 0.004 0.512
#> GSM892377 2 0.5392 -0.542 0.000 0.568 0.024 0.024 0.384
#> GSM892381 2 0.0324 0.619 0.000 0.992 0.004 0.004 0.000
#> GSM892383 2 0.2853 0.572 0.000 0.880 0.004 0.040 0.076
#> GSM892387 2 0.3707 0.470 0.000 0.828 0.016 0.036 0.120
#> GSM892344 3 0.2376 0.827 0.052 0.000 0.904 0.044 0.000
#> GSM892347 4 0.4280 0.850 0.088 0.000 0.140 0.772 0.000
#> GSM892351 4 0.4481 0.782 0.052 0.000 0.176 0.760 0.012
#> GSM892357 1 0.1671 0.938 0.924 0.000 0.000 0.000 0.076
#> GSM892359 1 0.1544 0.940 0.932 0.000 0.000 0.000 0.068
#> GSM892363 1 0.0510 0.939 0.984 0.000 0.000 0.000 0.016
#> GSM892367 3 0.3863 0.799 0.052 0.000 0.796 0.000 0.152
#> GSM892371 3 0.6737 0.596 0.052 0.000 0.584 0.208 0.156
#> GSM892375 2 0.4734 0.143 0.000 0.720 0.020 0.032 0.228
#> GSM892379 2 0.2957 0.533 0.000 0.860 0.008 0.012 0.120
#> GSM892385 2 0.5086 0.402 0.000 0.700 0.000 0.156 0.144
#> GSM892389 2 0.3155 0.563 0.000 0.852 0.008 0.020 0.120
#> GSM892341 3 0.2376 0.827 0.052 0.000 0.904 0.044 0.000
#> GSM892346 4 0.4576 0.688 0.268 0.000 0.000 0.692 0.040
#> GSM892350 4 0.4280 0.850 0.088 0.000 0.140 0.772 0.000
#> GSM892354 1 0.1671 0.938 0.924 0.000 0.000 0.000 0.076
#> GSM892356 1 0.1478 0.925 0.936 0.000 0.000 0.000 0.064
#> GSM892362 1 0.1608 0.939 0.928 0.000 0.000 0.000 0.072
#> GSM892366 3 0.2592 0.835 0.052 0.000 0.892 0.000 0.056
#> GSM892370 3 0.6737 0.596 0.052 0.000 0.584 0.208 0.156
#> GSM892374 5 0.4593 1.000 0.000 0.480 0.004 0.004 0.512
#> GSM892378 2 0.5392 -0.542 0.000 0.568 0.024 0.024 0.384
#> GSM892382 2 0.0324 0.619 0.000 0.992 0.004 0.004 0.000
#> GSM892384 2 0.0833 0.617 0.000 0.976 0.004 0.016 0.004
#> GSM892388 2 0.5032 0.399 0.000 0.704 0.000 0.168 0.128
#> GSM892343 3 0.3555 0.799 0.052 0.000 0.824 0.124 0.000
#> GSM892348 4 0.4288 0.758 0.224 0.000 0.004 0.740 0.032
#> GSM892352 3 0.3308 0.808 0.052 0.000 0.860 0.076 0.012
#> GSM892358 1 0.0162 0.940 0.996 0.000 0.000 0.000 0.004
#> GSM892360 1 0.1197 0.942 0.952 0.000 0.000 0.000 0.048
#> GSM892364 1 0.1410 0.927 0.940 0.000 0.000 0.000 0.060
#> GSM892368 3 0.2592 0.835 0.052 0.000 0.892 0.000 0.056
#> GSM892372 3 0.3359 0.820 0.052 0.000 0.840 0.000 0.108
#> GSM892376 2 0.4676 0.180 0.000 0.728 0.020 0.032 0.220
#> GSM892380 2 0.1106 0.613 0.000 0.964 0.000 0.012 0.024
#> GSM892386 2 0.3281 0.565 0.000 0.848 0.000 0.092 0.060
#> GSM892390 2 0.3682 0.543 0.000 0.820 0.000 0.072 0.108
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 3 0.3411 0.762 0.000 0.000 0.824 0.008 0.100 NA
#> GSM892345 4 0.2510 0.905 0.028 0.000 0.100 0.872 0.000 NA
#> GSM892349 3 0.5392 0.700 0.000 0.000 0.684 0.120 0.116 NA
#> GSM892353 1 0.4049 0.802 0.648 0.000 0.020 0.000 0.000 NA
#> GSM892355 1 0.4049 0.802 0.648 0.000 0.020 0.000 0.000 NA
#> GSM892361 1 0.1401 0.858 0.948 0.000 0.020 0.000 0.028 NA
#> GSM892365 3 0.0000 0.776 0.000 0.000 1.000 0.000 0.000 NA
#> GSM892369 3 0.6128 0.486 0.000 0.000 0.576 0.228 0.064 NA
#> GSM892373 5 0.3717 0.789 0.000 0.384 0.000 0.000 0.616 NA
#> GSM892377 5 0.5699 0.769 0.008 0.436 0.000 0.040 0.472 NA
#> GSM892381 2 0.0790 0.648 0.000 0.968 0.000 0.000 0.000 NA
#> GSM892383 2 0.3092 0.570 0.000 0.836 0.000 0.000 0.060 NA
#> GSM892387 2 0.3934 0.508 0.000 0.796 0.000 0.052 0.116 NA
#> GSM892344 3 0.3503 0.760 0.000 0.000 0.816 0.008 0.108 NA
#> GSM892347 4 0.2510 0.905 0.028 0.000 0.100 0.872 0.000 NA
#> GSM892351 4 0.3252 0.847 0.000 0.000 0.128 0.828 0.032 NA
#> GSM892357 1 0.1401 0.858 0.948 0.000 0.020 0.000 0.028 NA
#> GSM892359 1 0.0692 0.864 0.976 0.000 0.020 0.000 0.004 NA
#> GSM892363 1 0.3043 0.862 0.832 0.000 0.020 0.000 0.008 NA
#> GSM892367 3 0.3150 0.717 0.000 0.000 0.844 0.008 0.060 NA
#> GSM892371 3 0.6128 0.486 0.000 0.000 0.576 0.228 0.064 NA
#> GSM892375 2 0.4826 0.184 0.000 0.676 0.000 0.048 0.244 NA
#> GSM892379 2 0.3465 0.524 0.000 0.820 0.000 0.016 0.120 NA
#> GSM892385 2 0.5109 0.353 0.000 0.572 0.000 0.000 0.100 NA
#> GSM892389 2 0.3526 0.593 0.000 0.828 0.000 0.032 0.092 NA
#> GSM892341 3 0.3411 0.762 0.000 0.000 0.824 0.008 0.100 NA
#> GSM892346 4 0.4462 0.811 0.116 0.000 0.020 0.776 0.040 NA
#> GSM892350 4 0.2764 0.903 0.028 0.000 0.100 0.864 0.008 NA
#> GSM892354 1 0.1515 0.856 0.944 0.000 0.020 0.000 0.028 NA
#> GSM892356 1 0.4034 0.804 0.652 0.000 0.020 0.000 0.000 NA
#> GSM892362 1 0.0692 0.863 0.976 0.000 0.020 0.000 0.004 NA
#> GSM892366 3 0.0000 0.776 0.000 0.000 1.000 0.000 0.000 NA
#> GSM892370 3 0.6128 0.486 0.000 0.000 0.576 0.228 0.064 NA
#> GSM892374 5 0.3717 0.789 0.000 0.384 0.000 0.000 0.616 NA
#> GSM892378 5 0.5699 0.769 0.008 0.436 0.000 0.040 0.472 NA
#> GSM892382 2 0.0790 0.648 0.000 0.968 0.000 0.000 0.000 NA
#> GSM892384 2 0.1124 0.648 0.000 0.956 0.000 0.000 0.008 NA
#> GSM892388 2 0.5331 0.371 0.004 0.588 0.000 0.008 0.092 NA
#> GSM892343 3 0.4990 0.734 0.000 0.000 0.720 0.096 0.116 NA
#> GSM892348 4 0.4308 0.852 0.088 0.000 0.040 0.796 0.032 NA
#> GSM892352 3 0.4882 0.724 0.000 0.000 0.728 0.068 0.124 NA
#> GSM892358 1 0.2633 0.867 0.864 0.000 0.020 0.000 0.004 NA
#> GSM892360 1 0.1889 0.869 0.920 0.000 0.020 0.000 0.004 NA
#> GSM892364 1 0.4071 0.811 0.672 0.000 0.020 0.000 0.004 NA
#> GSM892368 3 0.0000 0.776 0.000 0.000 1.000 0.000 0.000 NA
#> GSM892372 3 0.1821 0.757 0.000 0.000 0.928 0.008 0.024 NA
#> GSM892376 2 0.4743 0.190 0.000 0.684 0.000 0.044 0.240 NA
#> GSM892380 2 0.1341 0.634 0.000 0.948 0.000 0.000 0.028 NA
#> GSM892386 2 0.4497 0.560 0.012 0.768 0.000 0.036 0.064 NA
#> GSM892390 2 0.4075 0.560 0.000 0.760 0.000 0.012 0.060 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)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> CV:kmeans 50 1.000 0.934 2.67e-07 1.42e-03 2
#> CV:kmeans 50 0.776 0.931 1.69e-11 8.93e-05 3
#> CV:kmeans 48 1.000 0.987 4.74e-15 7.28e-06 4
#> CV:kmeans 43 0.999 0.719 1.42e-16 7.38e-07 5
#> CV:kmeans 43 0.999 0.420 5.80e-14 3.43e-06 6
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 31632 rows and 50 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 1.000 0.966 0.984 0.4404 0.792 0.607
#> 4 4 0.958 0.894 0.949 0.0974 0.899 0.700
#> 5 5 0.971 0.870 0.924 0.0341 0.985 0.942
#> 6 6 0.914 0.812 0.869 0.0239 0.980 0.918
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 4 5
There is also optional best \(k\) = 2 3 4 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.000 1.000 0.000 0 1.000
#> GSM892345 1 0.529 0.680 0.732 0 0.268
#> GSM892349 3 0.000 1.000 0.000 0 1.000
#> GSM892353 1 0.000 0.948 1.000 0 0.000
#> GSM892355 1 0.000 0.948 1.000 0 0.000
#> GSM892361 1 0.000 0.948 1.000 0 0.000
#> GSM892365 3 0.000 1.000 0.000 0 1.000
#> GSM892369 3 0.000 1.000 0.000 0 1.000
#> GSM892373 2 0.000 1.000 0.000 1 0.000
#> GSM892377 2 0.000 1.000 0.000 1 0.000
#> GSM892381 2 0.000 1.000 0.000 1 0.000
#> GSM892383 2 0.000 1.000 0.000 1 0.000
#> GSM892387 2 0.000 1.000 0.000 1 0.000
#> GSM892344 3 0.000 1.000 0.000 0 1.000
#> GSM892347 1 0.529 0.680 0.732 0 0.268
#> GSM892351 3 0.000 1.000 0.000 0 1.000
#> GSM892357 1 0.000 0.948 1.000 0 0.000
#> GSM892359 1 0.000 0.948 1.000 0 0.000
#> GSM892363 1 0.000 0.948 1.000 0 0.000
#> GSM892367 3 0.000 1.000 0.000 0 1.000
#> GSM892371 3 0.000 1.000 0.000 0 1.000
#> GSM892375 2 0.000 1.000 0.000 1 0.000
#> GSM892379 2 0.000 1.000 0.000 1 0.000
#> GSM892385 2 0.000 1.000 0.000 1 0.000
#> GSM892389 2 0.000 1.000 0.000 1 0.000
#> GSM892341 3 0.000 1.000 0.000 0 1.000
#> GSM892346 1 0.000 0.948 1.000 0 0.000
#> GSM892350 1 0.529 0.680 0.732 0 0.268
#> GSM892354 1 0.000 0.948 1.000 0 0.000
#> GSM892356 1 0.000 0.948 1.000 0 0.000
#> GSM892362 1 0.000 0.948 1.000 0 0.000
#> GSM892366 3 0.000 1.000 0.000 0 1.000
#> GSM892370 3 0.000 1.000 0.000 0 1.000
#> GSM892374 2 0.000 1.000 0.000 1 0.000
#> GSM892378 2 0.000 1.000 0.000 1 0.000
#> GSM892382 2 0.000 1.000 0.000 1 0.000
#> GSM892384 2 0.000 1.000 0.000 1 0.000
#> GSM892388 2 0.000 1.000 0.000 1 0.000
#> GSM892343 3 0.000 1.000 0.000 0 1.000
#> GSM892348 1 0.000 0.948 1.000 0 0.000
#> GSM892352 3 0.000 1.000 0.000 0 1.000
#> GSM892358 1 0.000 0.948 1.000 0 0.000
#> GSM892360 1 0.000 0.948 1.000 0 0.000
#> GSM892364 1 0.000 0.948 1.000 0 0.000
#> GSM892368 3 0.000 1.000 0.000 0 1.000
#> GSM892372 3 0.000 1.000 0.000 0 1.000
#> GSM892376 2 0.000 1.000 0.000 1 0.000
#> GSM892380 2 0.000 1.000 0.000 1 0.000
#> GSM892386 2 0.000 1.000 0.000 1 0.000
#> GSM892390 2 0.000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.1302 0.886 0.000 0 0.956 0.044
#> GSM892345 4 0.0921 0.780 0.028 0 0.000 0.972
#> GSM892349 3 0.4877 0.365 0.000 0 0.592 0.408
#> GSM892353 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892355 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892361 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892365 3 0.0000 0.889 0.000 0 1.000 0.000
#> GSM892369 4 0.4977 0.363 0.000 0 0.460 0.540
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892344 3 0.1302 0.886 0.000 0 0.956 0.044
#> GSM892347 4 0.0921 0.781 0.028 0 0.000 0.972
#> GSM892351 4 0.0817 0.763 0.000 0 0.024 0.976
#> GSM892357 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892359 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892363 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892367 3 0.0469 0.883 0.000 0 0.988 0.012
#> GSM892371 4 0.4961 0.385 0.000 0 0.448 0.552
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892341 3 0.1302 0.886 0.000 0 0.956 0.044
#> GSM892346 4 0.1716 0.769 0.064 0 0.000 0.936
#> GSM892350 4 0.0817 0.781 0.024 0 0.000 0.976
#> GSM892354 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892356 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892362 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892366 3 0.0000 0.889 0.000 0 1.000 0.000
#> GSM892370 4 0.4977 0.363 0.000 0 0.460 0.540
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892343 3 0.3024 0.803 0.000 0 0.852 0.148
#> GSM892348 4 0.1637 0.772 0.060 0 0.000 0.940
#> GSM892352 3 0.3837 0.699 0.000 0 0.776 0.224
#> GSM892358 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892360 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892364 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892368 3 0.0000 0.889 0.000 0 1.000 0.000
#> GSM892372 3 0.0188 0.888 0.000 0 0.996 0.004
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 5 0.4101 0.653 0.000 0.000 0.372 0.000 0.628
#> GSM892345 4 0.0703 0.971 0.000 0.000 0.024 0.976 0.000
#> GSM892349 5 0.6775 0.426 0.000 0.000 0.348 0.276 0.376
#> GSM892353 1 0.1121 0.973 0.956 0.000 0.044 0.000 0.000
#> GSM892355 1 0.0880 0.981 0.968 0.000 0.032 0.000 0.000
#> GSM892361 1 0.0162 0.988 0.996 0.000 0.004 0.000 0.000
#> GSM892365 5 0.0162 0.482 0.000 0.000 0.004 0.000 0.996
#> GSM892369 3 0.5556 0.984 0.000 0.000 0.524 0.072 0.404
#> GSM892373 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892377 2 0.0162 0.998 0.000 0.996 0.004 0.000 0.000
#> GSM892381 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892383 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892387 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892344 5 0.4088 0.653 0.000 0.000 0.368 0.000 0.632
#> GSM892347 4 0.0404 0.974 0.000 0.000 0.012 0.988 0.000
#> GSM892351 4 0.1430 0.943 0.000 0.000 0.052 0.944 0.004
#> GSM892357 1 0.0162 0.988 0.996 0.000 0.004 0.000 0.000
#> GSM892359 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000
#> GSM892363 1 0.0162 0.989 0.996 0.000 0.004 0.000 0.000
#> GSM892367 5 0.3796 -0.378 0.000 0.000 0.300 0.000 0.700
#> GSM892371 3 0.5658 0.984 0.000 0.000 0.512 0.080 0.408
#> GSM892375 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892379 2 0.0162 0.998 0.000 0.996 0.004 0.000 0.000
#> GSM892385 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892389 2 0.0162 0.998 0.000 0.996 0.004 0.000 0.000
#> GSM892341 5 0.4101 0.653 0.000 0.000 0.372 0.000 0.628
#> GSM892346 4 0.1018 0.963 0.016 0.000 0.016 0.968 0.000
#> GSM892350 4 0.0162 0.974 0.000 0.000 0.004 0.996 0.000
#> GSM892354 1 0.0162 0.988 0.996 0.000 0.004 0.000 0.000
#> GSM892356 1 0.0794 0.982 0.972 0.000 0.028 0.000 0.000
#> GSM892362 1 0.0162 0.988 0.996 0.000 0.004 0.000 0.000
#> GSM892366 5 0.0000 0.479 0.000 0.000 0.000 0.000 1.000
#> GSM892370 3 0.5524 0.983 0.000 0.000 0.516 0.068 0.416
#> GSM892374 2 0.0162 0.998 0.000 0.996 0.004 0.000 0.000
#> GSM892378 2 0.0162 0.998 0.000 0.996 0.004 0.000 0.000
#> GSM892382 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892384 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892388 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892343 5 0.5691 0.607 0.000 0.000 0.400 0.084 0.516
#> GSM892348 4 0.0451 0.973 0.004 0.000 0.008 0.988 0.000
#> GSM892352 5 0.5281 0.625 0.000 0.000 0.400 0.052 0.548
#> GSM892358 1 0.0290 0.988 0.992 0.000 0.008 0.000 0.000
#> GSM892360 1 0.0162 0.989 0.996 0.000 0.004 0.000 0.000
#> GSM892364 1 0.0794 0.983 0.972 0.000 0.028 0.000 0.000
#> GSM892368 5 0.0290 0.469 0.000 0.000 0.008 0.000 0.992
#> GSM892372 5 0.2074 0.291 0.000 0.000 0.104 0.000 0.896
#> GSM892376 2 0.0162 0.998 0.000 0.996 0.004 0.000 0.000
#> GSM892380 2 0.0162 0.998 0.000 0.996 0.004 0.000 0.000
#> GSM892386 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892390 2 0.0162 0.998 0.000 0.996 0.004 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 3 0.3828 0.05925 0.000 0.000 0.560 0.000 0.440 0.000
#> GSM892345 4 0.0858 0.89632 0.000 0.000 0.000 0.968 0.028 0.004
#> GSM892349 5 0.6413 0.49984 0.000 0.000 0.180 0.296 0.484 0.040
#> GSM892353 1 0.3439 0.86303 0.808 0.000 0.000 0.000 0.120 0.072
#> GSM892355 1 0.2554 0.91079 0.876 0.000 0.000 0.000 0.076 0.048
#> GSM892361 1 0.0777 0.94319 0.972 0.000 0.000 0.000 0.024 0.004
#> GSM892365 3 0.0405 0.58541 0.000 0.000 0.988 0.000 0.008 0.004
#> GSM892369 6 0.3933 0.98230 0.000 0.000 0.248 0.036 0.000 0.716
#> GSM892373 2 0.1572 0.96683 0.000 0.936 0.000 0.000 0.036 0.028
#> GSM892377 2 0.1003 0.97371 0.000 0.964 0.000 0.000 0.016 0.020
#> GSM892381 2 0.0725 0.97726 0.000 0.976 0.000 0.000 0.012 0.012
#> GSM892383 2 0.0914 0.97617 0.000 0.968 0.000 0.000 0.016 0.016
#> GSM892387 2 0.0909 0.97790 0.000 0.968 0.000 0.000 0.020 0.012
#> GSM892344 3 0.3854 0.00777 0.000 0.000 0.536 0.000 0.464 0.000
#> GSM892347 4 0.1088 0.89610 0.000 0.000 0.000 0.960 0.024 0.016
#> GSM892351 4 0.2981 0.79421 0.000 0.000 0.000 0.820 0.160 0.020
#> GSM892357 1 0.0777 0.94319 0.972 0.000 0.000 0.000 0.024 0.004
#> GSM892359 1 0.0520 0.94550 0.984 0.000 0.000 0.000 0.008 0.008
#> GSM892363 1 0.1334 0.94027 0.948 0.000 0.000 0.000 0.020 0.032
#> GSM892367 3 0.3371 0.05566 0.000 0.000 0.708 0.000 0.000 0.292
#> GSM892371 6 0.4306 0.97453 0.000 0.000 0.248 0.044 0.008 0.700
#> GSM892375 2 0.1261 0.97399 0.000 0.952 0.000 0.000 0.024 0.024
#> GSM892379 2 0.0725 0.97777 0.000 0.976 0.000 0.000 0.012 0.012
#> GSM892385 2 0.1003 0.97267 0.000 0.964 0.000 0.000 0.016 0.020
#> GSM892389 2 0.0717 0.97828 0.000 0.976 0.000 0.000 0.016 0.008
#> GSM892341 3 0.3810 0.06891 0.000 0.000 0.572 0.000 0.428 0.000
#> GSM892346 4 0.2816 0.83584 0.036 0.000 0.000 0.876 0.028 0.060
#> GSM892350 4 0.1701 0.87652 0.000 0.000 0.000 0.920 0.072 0.008
#> GSM892354 1 0.0806 0.94354 0.972 0.000 0.000 0.000 0.020 0.008
#> GSM892356 1 0.2119 0.92274 0.904 0.000 0.000 0.000 0.060 0.036
#> GSM892362 1 0.0717 0.94442 0.976 0.000 0.000 0.000 0.016 0.008
#> GSM892366 3 0.0260 0.58402 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM892370 6 0.4049 0.97929 0.000 0.000 0.256 0.032 0.004 0.708
#> GSM892374 2 0.1261 0.96853 0.000 0.952 0.000 0.000 0.024 0.024
#> GSM892378 2 0.1003 0.97273 0.000 0.964 0.000 0.000 0.016 0.020
#> GSM892382 2 0.0909 0.97717 0.000 0.968 0.000 0.000 0.020 0.012
#> GSM892384 2 0.0508 0.97857 0.000 0.984 0.000 0.000 0.012 0.004
#> GSM892388 2 0.1088 0.97381 0.000 0.960 0.000 0.000 0.024 0.016
#> GSM892343 5 0.6286 0.47188 0.000 0.000 0.240 0.112 0.560 0.088
#> GSM892348 4 0.1624 0.88005 0.004 0.000 0.000 0.936 0.020 0.040
#> GSM892352 5 0.5575 0.37705 0.000 0.000 0.344 0.080 0.548 0.028
#> GSM892358 1 0.0820 0.94437 0.972 0.000 0.000 0.000 0.016 0.012
#> GSM892360 1 0.0508 0.94503 0.984 0.000 0.000 0.000 0.004 0.012
#> GSM892364 1 0.2905 0.90124 0.852 0.000 0.000 0.000 0.084 0.064
#> GSM892368 3 0.0146 0.58487 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM892372 3 0.2446 0.50087 0.000 0.000 0.864 0.000 0.012 0.124
#> GSM892376 2 0.0820 0.97679 0.000 0.972 0.000 0.000 0.012 0.016
#> GSM892380 2 0.0622 0.97831 0.000 0.980 0.000 0.000 0.012 0.008
#> GSM892386 2 0.0725 0.97656 0.000 0.976 0.000 0.000 0.012 0.012
#> GSM892390 2 0.1003 0.97352 0.000 0.964 0.000 0.000 0.016 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)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> CV:skmeans 50 1.000 0.934 2.67e-07 1.42e-03 2
#> CV:skmeans 50 0.939 0.875 8.67e-12 3.79e-05 3
#> CV:skmeans 46 0.957 0.891 2.21e-14 7.92e-06 4
#> CV:skmeans 44 0.970 0.955 1.80e-18 6.18e-07 5
#> CV:skmeans 43 0.860 0.987 2.10e-16 4.86e-06 6
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 31632 rows and 50 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 0.974 0.953 0.976 0.4381 0.792 0.607
#> 4 4 0.975 0.939 0.972 0.1002 0.899 0.700
#> 5 5 0.999 0.966 0.984 0.0286 0.977 0.910
#> 6 6 1.000 0.966 0.981 0.0297 0.953 0.810
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
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.0000 1.000 0.000 0 1.000
#> GSM892345 1 0.5760 0.606 0.672 0 0.328
#> GSM892349 3 0.0000 1.000 0.000 0 1.000
#> GSM892353 1 0.1643 0.901 0.956 0 0.044
#> GSM892355 1 0.0000 0.924 1.000 0 0.000
#> GSM892361 1 0.0000 0.924 1.000 0 0.000
#> GSM892365 3 0.0000 1.000 0.000 0 1.000
#> GSM892369 3 0.0000 1.000 0.000 0 1.000
#> GSM892373 2 0.0000 1.000 0.000 1 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000
#> GSM892344 3 0.0000 1.000 0.000 0 1.000
#> GSM892347 1 0.5431 0.676 0.716 0 0.284
#> GSM892351 3 0.0000 1.000 0.000 0 1.000
#> GSM892357 1 0.0000 0.924 1.000 0 0.000
#> GSM892359 1 0.0000 0.924 1.000 0 0.000
#> GSM892363 1 0.0000 0.924 1.000 0 0.000
#> GSM892367 3 0.0000 1.000 0.000 0 1.000
#> GSM892371 3 0.0000 1.000 0.000 0 1.000
#> GSM892375 2 0.0000 1.000 0.000 1 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000
#> GSM892341 3 0.0000 1.000 0.000 0 1.000
#> GSM892346 1 0.0424 0.921 0.992 0 0.008
#> GSM892350 1 0.5650 0.634 0.688 0 0.312
#> GSM892354 1 0.0000 0.924 1.000 0 0.000
#> GSM892356 1 0.0000 0.924 1.000 0 0.000
#> GSM892362 1 0.0000 0.924 1.000 0 0.000
#> GSM892366 3 0.0000 1.000 0.000 0 1.000
#> GSM892370 3 0.0000 1.000 0.000 0 1.000
#> GSM892374 2 0.0000 1.000 0.000 1 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000
#> GSM892343 3 0.0000 1.000 0.000 0 1.000
#> GSM892348 1 0.4605 0.769 0.796 0 0.204
#> GSM892352 3 0.0000 1.000 0.000 0 1.000
#> GSM892358 1 0.0000 0.924 1.000 0 0.000
#> GSM892360 1 0.0000 0.924 1.000 0 0.000
#> GSM892364 1 0.0237 0.923 0.996 0 0.004
#> GSM892368 3 0.0000 1.000 0.000 0 1.000
#> GSM892372 3 0.0000 1.000 0.000 0 1.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.0000 0.955 0.000 0 1.000 0.000
#> GSM892345 4 0.0000 0.864 0.000 0 0.000 1.000
#> GSM892349 4 0.4543 0.556 0.000 0 0.324 0.676
#> GSM892353 1 0.0188 0.995 0.996 0 0.000 0.004
#> GSM892355 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892361 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892365 3 0.0000 0.955 0.000 0 1.000 0.000
#> GSM892369 3 0.3074 0.831 0.000 0 0.848 0.152
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892344 3 0.0921 0.947 0.000 0 0.972 0.028
#> GSM892347 4 0.0000 0.864 0.000 0 0.000 1.000
#> GSM892351 4 0.0000 0.864 0.000 0 0.000 1.000
#> GSM892357 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892359 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892363 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892367 3 0.0000 0.955 0.000 0 1.000 0.000
#> GSM892371 4 0.4817 0.327 0.000 0 0.388 0.612
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892341 3 0.0817 0.948 0.000 0 0.976 0.024
#> GSM892346 4 0.1022 0.843 0.032 0 0.000 0.968
#> GSM892350 4 0.0000 0.864 0.000 0 0.000 1.000
#> GSM892354 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892356 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892362 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892366 3 0.0000 0.955 0.000 0 1.000 0.000
#> GSM892370 3 0.2408 0.887 0.000 0 0.896 0.104
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892343 4 0.3942 0.683 0.000 0 0.236 0.764
#> GSM892348 4 0.0000 0.864 0.000 0 0.000 1.000
#> GSM892352 3 0.2281 0.890 0.000 0 0.904 0.096
#> GSM892358 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892360 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892364 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892368 3 0.0000 0.955 0.000 0 1.000 0.000
#> GSM892372 3 0.0000 0.955 0.000 0 1.000 0.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 5 0.0000 0.974 0.00 0 0.000 0.000 1.000
#> GSM892345 4 0.0000 0.897 0.00 0 0.000 1.000 0.000
#> GSM892349 4 0.3661 0.659 0.00 0 0.000 0.724 0.276
#> GSM892353 1 0.0000 1.000 1.00 0 0.000 0.000 0.000
#> GSM892355 1 0.0000 1.000 1.00 0 0.000 0.000 0.000
#> GSM892361 1 0.0000 1.000 1.00 0 0.000 0.000 0.000
#> GSM892365 5 0.0000 0.974 0.00 0 0.000 0.000 1.000
#> GSM892369 3 0.0000 1.000 0.00 0 1.000 0.000 0.000
#> GSM892373 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892344 5 0.0000 0.974 0.00 0 0.000 0.000 1.000
#> GSM892347 4 0.0162 0.895 0.00 0 0.004 0.996 0.000
#> GSM892351 4 0.0000 0.897 0.00 0 0.000 1.000 0.000
#> GSM892357 1 0.0000 1.000 1.00 0 0.000 0.000 0.000
#> GSM892359 1 0.0000 1.000 1.00 0 0.000 0.000 0.000
#> GSM892363 1 0.0000 1.000 1.00 0 0.000 0.000 0.000
#> GSM892367 5 0.1908 0.896 0.00 0 0.092 0.000 0.908
#> GSM892371 3 0.0000 1.000 0.00 0 1.000 0.000 0.000
#> GSM892375 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892341 5 0.0000 0.974 0.00 0 0.000 0.000 1.000
#> GSM892346 4 0.0771 0.880 0.02 0 0.004 0.976 0.000
#> GSM892350 4 0.0000 0.897 0.00 0 0.000 1.000 0.000
#> GSM892354 1 0.0000 1.000 1.00 0 0.000 0.000 0.000
#> GSM892356 1 0.0000 1.000 1.00 0 0.000 0.000 0.000
#> GSM892362 1 0.0000 1.000 1.00 0 0.000 0.000 0.000
#> GSM892366 5 0.0000 0.974 0.00 0 0.000 0.000 1.000
#> GSM892370 3 0.0000 1.000 0.00 0 1.000 0.000 0.000
#> GSM892374 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892343 4 0.4354 0.668 0.00 0 0.032 0.712 0.256
#> GSM892348 4 0.0000 0.897 0.00 0 0.000 1.000 0.000
#> GSM892352 5 0.1908 0.887 0.00 0 0.000 0.092 0.908
#> GSM892358 1 0.0000 1.000 1.00 0 0.000 0.000 0.000
#> GSM892360 1 0.0000 1.000 1.00 0 0.000 0.000 0.000
#> GSM892364 1 0.0000 1.000 1.00 0 0.000 0.000 0.000
#> GSM892368 5 0.0000 0.974 0.00 0 0.000 0.000 1.000
#> GSM892372 5 0.0162 0.972 0.00 0 0.004 0.000 0.996
#> GSM892376 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.00 1 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.0937 0.870 0.000 0 0.040 0.000 0.960 0.000
#> GSM892345 4 0.0865 0.984 0.000 0 0.000 0.964 0.036 0.000
#> GSM892349 5 0.1633 0.844 0.000 0 0.024 0.044 0.932 0.000
#> GSM892353 5 0.3684 0.509 0.332 0 0.004 0.000 0.664 0.000
#> GSM892355 1 0.0146 0.998 0.996 0 0.004 0.000 0.000 0.000
#> GSM892361 1 0.0000 0.998 1.000 0 0.000 0.000 0.000 0.000
#> GSM892365 3 0.0146 0.983 0.000 0 0.996 0.000 0.004 0.000
#> GSM892369 6 0.0000 1.000 0.000 0 0.000 0.000 0.000 1.000
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892344 5 0.0937 0.870 0.000 0 0.040 0.000 0.960 0.000
#> GSM892347 4 0.0865 0.984 0.000 0 0.000 0.964 0.036 0.000
#> GSM892351 4 0.0865 0.984 0.000 0 0.000 0.964 0.036 0.000
#> GSM892357 1 0.0000 0.998 1.000 0 0.000 0.000 0.000 0.000
#> GSM892359 1 0.0146 0.998 0.996 0 0.004 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.998 1.000 0 0.000 0.000 0.000 0.000
#> GSM892367 3 0.1327 0.929 0.000 0 0.936 0.000 0.000 0.064
#> GSM892371 6 0.0000 1.000 0.000 0 0.000 0.000 0.000 1.000
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892341 5 0.2597 0.777 0.000 0 0.176 0.000 0.824 0.000
#> GSM892346 4 0.0146 0.968 0.000 0 0.000 0.996 0.004 0.000
#> GSM892350 4 0.0865 0.984 0.000 0 0.000 0.964 0.036 0.000
#> GSM892354 1 0.0000 0.998 1.000 0 0.000 0.000 0.000 0.000
#> GSM892356 1 0.0000 0.998 1.000 0 0.000 0.000 0.000 0.000
#> GSM892362 1 0.0000 0.998 1.000 0 0.000 0.000 0.000 0.000
#> GSM892366 3 0.0146 0.983 0.000 0 0.996 0.000 0.004 0.000
#> GSM892370 6 0.0000 1.000 0.000 0 0.000 0.000 0.000 1.000
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892343 5 0.0260 0.869 0.000 0 0.008 0.000 0.992 0.000
#> GSM892348 4 0.0146 0.968 0.000 0 0.000 0.996 0.004 0.000
#> GSM892352 5 0.0146 0.868 0.000 0 0.004 0.000 0.996 0.000
#> GSM892358 1 0.0146 0.998 0.996 0 0.004 0.000 0.000 0.000
#> GSM892360 1 0.0146 0.998 0.996 0 0.004 0.000 0.000 0.000
#> GSM892364 1 0.0146 0.998 0.996 0 0.004 0.000 0.000 0.000
#> GSM892368 3 0.0146 0.983 0.000 0 0.996 0.000 0.004 0.000
#> GSM892372 3 0.0146 0.983 0.000 0 0.996 0.000 0.004 0.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> CV:pam 50 1.000 0.934 2.67e-07 1.42e-03 2
#> CV:pam 50 0.939 0.875 8.67e-12 3.79e-05 3
#> CV:pam 49 0.995 0.988 1.32e-14 7.04e-06 4
#> CV:pam 50 0.979 0.964 3.20e-17 9.29e-07 5
#> CV:pam 50 0.979 0.969 1.52e-20 2.12e-07 6
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 31632 rows and 50 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 1.000 1.000 1.000 0.4158 0.804 0.630
#> 4 4 0.966 0.920 0.966 0.1189 0.918 0.756
#> 5 5 0.907 0.762 0.901 0.0344 0.987 0.948
#> 6 6 0.855 0.679 0.851 0.0342 0.984 0.932
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 2 3 4
There is also optional best \(k\) = 2 3 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0 1 0 0 1
#> GSM892345 3 0 1 0 0 1
#> GSM892349 3 0 1 0 0 1
#> GSM892353 1 0 1 1 0 0
#> GSM892355 1 0 1 1 0 0
#> GSM892361 1 0 1 1 0 0
#> GSM892365 3 0 1 0 0 1
#> GSM892369 3 0 1 0 0 1
#> GSM892373 2 0 1 0 1 0
#> GSM892377 2 0 1 0 1 0
#> GSM892381 2 0 1 0 1 0
#> GSM892383 2 0 1 0 1 0
#> GSM892387 2 0 1 0 1 0
#> GSM892344 3 0 1 0 0 1
#> GSM892347 3 0 1 0 0 1
#> GSM892351 3 0 1 0 0 1
#> GSM892357 1 0 1 1 0 0
#> GSM892359 1 0 1 1 0 0
#> GSM892363 1 0 1 1 0 0
#> GSM892367 3 0 1 0 0 1
#> GSM892371 3 0 1 0 0 1
#> GSM892375 2 0 1 0 1 0
#> GSM892379 2 0 1 0 1 0
#> GSM892385 2 0 1 0 1 0
#> GSM892389 2 0 1 0 1 0
#> GSM892341 3 0 1 0 0 1
#> GSM892346 3 0 1 0 0 1
#> GSM892350 3 0 1 0 0 1
#> GSM892354 1 0 1 1 0 0
#> GSM892356 1 0 1 1 0 0
#> GSM892362 1 0 1 1 0 0
#> GSM892366 3 0 1 0 0 1
#> GSM892370 3 0 1 0 0 1
#> GSM892374 2 0 1 0 1 0
#> GSM892378 2 0 1 0 1 0
#> GSM892382 2 0 1 0 1 0
#> GSM892384 2 0 1 0 1 0
#> GSM892388 2 0 1 0 1 0
#> GSM892343 3 0 1 0 0 1
#> GSM892348 3 0 1 0 0 1
#> GSM892352 3 0 1 0 0 1
#> GSM892358 1 0 1 1 0 0
#> GSM892360 1 0 1 1 0 0
#> GSM892364 1 0 1 1 0 0
#> GSM892368 3 0 1 0 0 1
#> GSM892372 3 0 1 0 0 1
#> GSM892376 2 0 1 0 1 0
#> GSM892380 2 0 1 0 1 0
#> GSM892386 2 0 1 0 1 0
#> GSM892390 2 0 1 0 1 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.0000 0.862 0 0 1.000 0.000
#> GSM892345 4 0.0000 0.921 0 0 0.000 1.000
#> GSM892349 4 0.4866 0.143 0 0 0.404 0.596
#> GSM892353 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892355 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892361 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892365 3 0.0921 0.860 0 0 0.972 0.028
#> GSM892369 4 0.2868 0.786 0 0 0.136 0.864
#> GSM892373 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892377 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892381 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892383 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892387 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892344 3 0.0188 0.863 0 0 0.996 0.004
#> GSM892347 4 0.0000 0.921 0 0 0.000 1.000
#> GSM892351 4 0.0000 0.921 0 0 0.000 1.000
#> GSM892357 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892359 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892363 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892367 3 0.2011 0.846 0 0 0.920 0.080
#> GSM892371 4 0.0817 0.909 0 0 0.024 0.976
#> GSM892375 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892379 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892385 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892389 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892341 3 0.0188 0.863 0 0 0.996 0.004
#> GSM892346 4 0.0000 0.921 0 0 0.000 1.000
#> GSM892350 4 0.0000 0.921 0 0 0.000 1.000
#> GSM892354 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892356 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892362 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892366 3 0.2149 0.837 0 0 0.912 0.088
#> GSM892370 4 0.0707 0.912 0 0 0.020 0.980
#> GSM892374 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892378 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892382 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892384 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892388 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892343 3 0.4250 0.630 0 0 0.724 0.276
#> GSM892348 4 0.0000 0.921 0 0 0.000 1.000
#> GSM892352 3 0.4843 0.391 0 0 0.604 0.396
#> GSM892358 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892360 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892364 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892368 3 0.0188 0.863 0 0 0.996 0.004
#> GSM892372 3 0.3942 0.721 0 0 0.764 0.236
#> GSM892376 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892380 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892386 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892390 2 0.0000 1.000 0 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 3 0.0404 0.862 0.000 0.000 0.988 0.000 0.012
#> GSM892345 4 0.4262 -0.208 0.000 0.000 0.000 0.560 0.440
#> GSM892349 4 0.5703 -0.274 0.000 0.000 0.408 0.508 0.084
#> GSM892353 1 0.0162 0.993 0.996 0.000 0.000 0.000 0.004
#> GSM892355 1 0.0290 0.992 0.992 0.000 0.000 0.000 0.008
#> GSM892361 1 0.0290 0.992 0.992 0.000 0.000 0.000 0.008
#> GSM892365 3 0.0451 0.864 0.000 0.000 0.988 0.004 0.008
#> GSM892369 4 0.0609 0.334 0.000 0.000 0.000 0.980 0.020
#> GSM892373 2 0.2891 0.853 0.000 0.824 0.000 0.000 0.176
#> GSM892377 2 0.0000 0.966 0.000 1.000 0.000 0.000 0.000
#> GSM892381 2 0.0000 0.966 0.000 1.000 0.000 0.000 0.000
#> GSM892383 2 0.0000 0.966 0.000 1.000 0.000 0.000 0.000
#> GSM892387 2 0.0000 0.966 0.000 1.000 0.000 0.000 0.000
#> GSM892344 3 0.1386 0.862 0.000 0.000 0.952 0.016 0.032
#> GSM892347 4 0.4268 -0.218 0.000 0.000 0.000 0.556 0.444
#> GSM892351 4 0.4262 -0.208 0.000 0.000 0.000 0.560 0.440
#> GSM892357 1 0.0290 0.992 0.992 0.000 0.000 0.000 0.008
#> GSM892359 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM892367 3 0.2694 0.818 0.000 0.000 0.884 0.040 0.076
#> GSM892371 4 0.1121 0.333 0.000 0.000 0.000 0.956 0.044
#> GSM892375 2 0.0000 0.966 0.000 1.000 0.000 0.000 0.000
#> GSM892379 2 0.0000 0.966 0.000 1.000 0.000 0.000 0.000
#> GSM892385 2 0.0000 0.966 0.000 1.000 0.000 0.000 0.000
#> GSM892389 2 0.0000 0.966 0.000 1.000 0.000 0.000 0.000
#> GSM892341 3 0.1281 0.863 0.000 0.000 0.956 0.012 0.032
#> GSM892346 5 0.3452 0.802 0.000 0.000 0.000 0.244 0.756
#> GSM892350 4 0.4273 -0.228 0.000 0.000 0.000 0.552 0.448
#> GSM892354 1 0.0290 0.992 0.992 0.000 0.000 0.000 0.008
#> GSM892356 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM892362 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM892366 3 0.0671 0.864 0.000 0.000 0.980 0.004 0.016
#> GSM892370 4 0.0510 0.339 0.000 0.000 0.000 0.984 0.016
#> GSM892374 2 0.2891 0.853 0.000 0.824 0.000 0.000 0.176
#> GSM892378 2 0.0000 0.966 0.000 1.000 0.000 0.000 0.000
#> GSM892382 2 0.0000 0.966 0.000 1.000 0.000 0.000 0.000
#> GSM892384 2 0.0000 0.966 0.000 1.000 0.000 0.000 0.000
#> GSM892388 2 0.2929 0.850 0.000 0.820 0.000 0.000 0.180
#> GSM892343 3 0.5267 0.448 0.000 0.000 0.524 0.428 0.048
#> GSM892348 5 0.3966 0.780 0.000 0.000 0.000 0.336 0.664
#> GSM892352 3 0.4937 0.464 0.000 0.000 0.544 0.428 0.028
#> GSM892358 1 0.0290 0.992 0.992 0.000 0.000 0.000 0.008
#> GSM892360 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM892364 1 0.1216 0.969 0.960 0.000 0.000 0.020 0.020
#> GSM892368 3 0.0566 0.865 0.000 0.000 0.984 0.004 0.012
#> GSM892372 3 0.2438 0.848 0.000 0.000 0.900 0.060 0.040
#> GSM892376 2 0.2127 0.902 0.000 0.892 0.000 0.000 0.108
#> GSM892380 2 0.0000 0.966 0.000 1.000 0.000 0.000 0.000
#> GSM892386 2 0.0000 0.966 0.000 1.000 0.000 0.000 0.000
#> GSM892390 2 0.0000 0.966 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.0146 0.8699 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM892345 3 0.3851 -0.0729 0.000 0.000 0.540 0.460 0.000 0.000
#> GSM892349 3 0.4453 -0.2003 0.000 0.000 0.592 0.036 0.372 0.000
#> GSM892353 6 0.5147 0.9293 0.436 0.000 0.000 0.084 0.000 0.480
#> GSM892355 1 0.3766 0.1570 0.736 0.000 0.000 0.032 0.000 0.232
#> GSM892361 1 0.1245 0.8153 0.952 0.000 0.000 0.032 0.000 0.016
#> GSM892365 5 0.0000 0.8698 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM892369 3 0.0692 0.4009 0.000 0.000 0.976 0.000 0.004 0.020
#> GSM892373 2 0.3838 0.5373 0.000 0.552 0.000 0.000 0.000 0.448
#> GSM892377 2 0.0146 0.9088 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM892381 2 0.0000 0.9089 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892383 2 0.0146 0.9088 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM892387 2 0.0146 0.9085 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM892344 5 0.0405 0.8688 0.000 0.000 0.000 0.004 0.988 0.008
#> GSM892347 3 0.3851 -0.0683 0.000 0.000 0.540 0.460 0.000 0.000
#> GSM892351 3 0.3838 -0.0496 0.000 0.000 0.552 0.448 0.000 0.000
#> GSM892357 1 0.0914 0.8246 0.968 0.000 0.000 0.016 0.000 0.016
#> GSM892359 1 0.1812 0.7342 0.912 0.000 0.000 0.008 0.000 0.080
#> GSM892363 1 0.0146 0.8315 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM892367 5 0.3224 0.8017 0.000 0.000 0.128 0.036 0.828 0.008
#> GSM892371 3 0.0547 0.4032 0.000 0.000 0.980 0.020 0.000 0.000
#> GSM892375 2 0.0260 0.9077 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM892379 2 0.0000 0.9089 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892385 2 0.0260 0.9076 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM892389 2 0.0260 0.9077 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM892341 5 0.0146 0.8699 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM892346 4 0.2562 0.8212 0.000 0.000 0.172 0.828 0.000 0.000
#> GSM892350 3 0.3854 -0.0820 0.000 0.000 0.536 0.464 0.000 0.000
#> GSM892354 1 0.1245 0.8153 0.952 0.000 0.000 0.032 0.000 0.016
#> GSM892356 1 0.0405 0.8286 0.988 0.000 0.000 0.004 0.000 0.008
#> GSM892362 1 0.0260 0.8288 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM892366 5 0.0520 0.8684 0.000 0.000 0.000 0.008 0.984 0.008
#> GSM892370 3 0.0622 0.3981 0.000 0.000 0.980 0.012 0.000 0.008
#> GSM892374 2 0.3838 0.5373 0.000 0.552 0.000 0.000 0.000 0.448
#> GSM892378 2 0.0363 0.9065 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM892382 2 0.0146 0.9088 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM892384 2 0.0146 0.9088 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM892388 2 0.4702 0.4619 0.000 0.496 0.000 0.044 0.000 0.460
#> GSM892343 5 0.5110 0.5940 0.000 0.000 0.316 0.020 0.604 0.060
#> GSM892348 4 0.3221 0.8030 0.000 0.000 0.264 0.736 0.000 0.000
#> GSM892352 5 0.4415 0.5014 0.000 0.000 0.420 0.004 0.556 0.020
#> GSM892358 6 0.5145 0.9299 0.432 0.000 0.000 0.084 0.000 0.484
#> GSM892360 1 0.0146 0.8300 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM892364 1 0.4152 0.1251 0.664 0.000 0.000 0.032 0.000 0.304
#> GSM892368 5 0.0291 0.8698 0.000 0.000 0.004 0.000 0.992 0.004
#> GSM892372 5 0.3043 0.8101 0.000 0.000 0.140 0.008 0.832 0.020
#> GSM892376 2 0.2730 0.7852 0.000 0.808 0.000 0.000 0.000 0.192
#> GSM892380 2 0.0146 0.9088 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM892386 2 0.0146 0.9088 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM892390 2 0.0547 0.9031 0.000 0.980 0.000 0.000 0.000 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)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> CV:mclust 50 1.000 0.934 2.67e-07 1.42e-03 2
#> CV:mclust 50 1.000 0.931 1.26e-12 1.60e-05 3
#> CV:mclust 48 0.974 0.948 1.91e-15 3.99e-06 4
#> CV:mclust 40 0.592 0.989 1.08e-13 2.01e-05 5
#> CV:mclust 39 0.691 0.980 4.22e-10 1.80e-03 6
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 31632 rows and 50 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 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 0.949 0.933 0.969 0.4361 0.792 0.607
#> 4 4 0.985 0.921 0.966 0.0935 0.922 0.762
#> 5 5 0.939 0.915 0.934 0.0389 0.958 0.842
#> 6 6 0.902 0.914 0.934 0.0198 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] 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
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.0000 0.984 0.000 0 1.000
#> GSM892345 1 0.5968 0.524 0.636 0 0.364
#> GSM892349 3 0.0000 0.984 0.000 0 1.000
#> GSM892353 1 0.0892 0.902 0.980 0 0.020
#> GSM892355 1 0.0424 0.907 0.992 0 0.008
#> GSM892361 1 0.0000 0.910 1.000 0 0.000
#> GSM892365 3 0.0000 0.984 0.000 0 1.000
#> GSM892369 3 0.0000 0.984 0.000 0 1.000
#> GSM892373 2 0.0000 1.000 0.000 1 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000
#> GSM892344 3 0.0000 0.984 0.000 0 1.000
#> GSM892347 1 0.5882 0.553 0.652 0 0.348
#> GSM892351 3 0.4346 0.738 0.184 0 0.816
#> GSM892357 1 0.0000 0.910 1.000 0 0.000
#> GSM892359 1 0.0000 0.910 1.000 0 0.000
#> GSM892363 1 0.0000 0.910 1.000 0 0.000
#> GSM892367 3 0.0000 0.984 0.000 0 1.000
#> GSM892371 3 0.0000 0.984 0.000 0 1.000
#> GSM892375 2 0.0000 1.000 0.000 1 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000
#> GSM892341 3 0.0000 0.984 0.000 0 1.000
#> GSM892346 1 0.2261 0.872 0.932 0 0.068
#> GSM892350 1 0.5968 0.524 0.636 0 0.364
#> GSM892354 1 0.0000 0.910 1.000 0 0.000
#> GSM892356 1 0.0000 0.910 1.000 0 0.000
#> GSM892362 1 0.0000 0.910 1.000 0 0.000
#> GSM892366 3 0.0000 0.984 0.000 0 1.000
#> GSM892370 3 0.0000 0.984 0.000 0 1.000
#> GSM892374 2 0.0000 1.000 0.000 1 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000
#> GSM892343 3 0.0747 0.968 0.016 0 0.984
#> GSM892348 1 0.4399 0.770 0.812 0 0.188
#> GSM892352 3 0.0000 0.984 0.000 0 1.000
#> GSM892358 1 0.0000 0.910 1.000 0 0.000
#> GSM892360 1 0.0000 0.910 1.000 0 0.000
#> GSM892364 1 0.0000 0.910 1.000 0 0.000
#> GSM892368 3 0.0000 0.984 0.000 0 1.000
#> GSM892372 3 0.0000 0.984 0.000 0 1.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.0592 0.9036 0.000 0 0.984 0.016
#> GSM892345 4 0.0817 0.9037 0.000 0 0.024 0.976
#> GSM892349 4 0.4933 0.0899 0.000 0 0.432 0.568
#> GSM892353 1 0.0000 0.9989 1.000 0 0.000 0.000
#> GSM892355 1 0.0000 0.9989 1.000 0 0.000 0.000
#> GSM892361 1 0.0188 0.9959 0.996 0 0.000 0.004
#> GSM892365 3 0.0000 0.8998 0.000 0 1.000 0.000
#> GSM892369 3 0.1637 0.8867 0.000 0 0.940 0.060
#> GSM892373 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892377 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892381 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892383 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892387 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892344 3 0.0921 0.9019 0.000 0 0.972 0.028
#> GSM892347 4 0.0895 0.9037 0.004 0 0.020 0.976
#> GSM892351 4 0.1211 0.8938 0.000 0 0.040 0.960
#> GSM892357 1 0.0000 0.9989 1.000 0 0.000 0.000
#> GSM892359 1 0.0000 0.9989 1.000 0 0.000 0.000
#> GSM892363 1 0.0000 0.9989 1.000 0 0.000 0.000
#> GSM892367 3 0.0188 0.8977 0.000 0 0.996 0.004
#> GSM892371 3 0.3074 0.8112 0.000 0 0.848 0.152
#> GSM892375 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892379 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892385 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892389 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892341 3 0.0592 0.9036 0.000 0 0.984 0.016
#> GSM892346 4 0.0804 0.8939 0.012 0 0.008 0.980
#> GSM892350 4 0.0817 0.9037 0.000 0 0.024 0.976
#> GSM892354 1 0.0000 0.9989 1.000 0 0.000 0.000
#> GSM892356 1 0.0000 0.9989 1.000 0 0.000 0.000
#> GSM892362 1 0.0000 0.9989 1.000 0 0.000 0.000
#> GSM892366 3 0.0336 0.9025 0.000 0 0.992 0.008
#> GSM892370 3 0.1792 0.8835 0.000 0 0.932 0.068
#> GSM892374 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892378 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892382 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892384 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892388 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892343 3 0.4164 0.6520 0.000 0 0.736 0.264
#> GSM892348 4 0.0804 0.9001 0.008 0 0.012 0.980
#> GSM892352 3 0.4981 0.1314 0.000 0 0.536 0.464
#> GSM892358 1 0.0000 0.9989 1.000 0 0.000 0.000
#> GSM892360 1 0.0000 0.9989 1.000 0 0.000 0.000
#> GSM892364 1 0.0336 0.9923 0.992 0 0.000 0.008
#> GSM892368 3 0.0188 0.8977 0.000 0 0.996 0.004
#> GSM892372 3 0.0592 0.9035 0.000 0 0.984 0.016
#> GSM892376 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892380 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892386 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM892390 2 0.0000 1.0000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 5 0.2732 0.851 0.000 0.000 0.160 0.000 0.840
#> GSM892345 4 0.2020 0.917 0.000 0.000 0.000 0.900 0.100
#> GSM892349 5 0.3764 0.783 0.000 0.000 0.044 0.156 0.800
#> GSM892353 1 0.0404 0.988 0.988 0.000 0.000 0.000 0.012
#> GSM892355 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892361 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892365 3 0.4060 0.621 0.000 0.000 0.640 0.000 0.360
#> GSM892369 3 0.0510 0.729 0.000 0.000 0.984 0.016 0.000
#> GSM892373 2 0.1270 0.960 0.000 0.948 0.000 0.000 0.052
#> GSM892377 2 0.0510 0.986 0.000 0.984 0.000 0.000 0.016
#> GSM892381 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM892383 2 0.0290 0.990 0.000 0.992 0.000 0.000 0.008
#> GSM892387 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM892344 5 0.2583 0.881 0.000 0.000 0.132 0.004 0.864
#> GSM892347 4 0.1544 0.920 0.000 0.000 0.000 0.932 0.068
#> GSM892351 4 0.3336 0.794 0.000 0.000 0.000 0.772 0.228
#> GSM892357 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892359 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892367 3 0.1544 0.764 0.000 0.000 0.932 0.000 0.068
#> GSM892371 3 0.2676 0.761 0.000 0.000 0.884 0.036 0.080
#> GSM892375 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM892379 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM892385 2 0.0290 0.990 0.000 0.992 0.000 0.000 0.008
#> GSM892389 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM892341 5 0.2561 0.873 0.000 0.000 0.144 0.000 0.856
#> GSM892346 4 0.0290 0.891 0.000 0.000 0.008 0.992 0.000
#> GSM892350 4 0.2230 0.910 0.000 0.000 0.000 0.884 0.116
#> GSM892354 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892356 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892362 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892366 3 0.4219 0.506 0.000 0.000 0.584 0.000 0.416
#> GSM892370 3 0.1012 0.746 0.000 0.000 0.968 0.012 0.020
#> GSM892374 2 0.1670 0.951 0.000 0.936 0.012 0.000 0.052
#> GSM892378 2 0.0510 0.986 0.000 0.984 0.000 0.000 0.016
#> GSM892382 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM892384 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM892388 2 0.0162 0.991 0.000 0.996 0.000 0.000 0.004
#> GSM892343 5 0.3037 0.883 0.000 0.000 0.100 0.040 0.860
#> GSM892348 4 0.0404 0.902 0.000 0.000 0.000 0.988 0.012
#> GSM892352 5 0.3159 0.849 0.000 0.000 0.056 0.088 0.856
#> GSM892358 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892360 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892364 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892368 3 0.3752 0.707 0.000 0.000 0.708 0.000 0.292
#> GSM892372 3 0.3508 0.735 0.000 0.000 0.748 0.000 0.252
#> GSM892376 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM892380 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM892386 2 0.0162 0.990 0.000 0.996 0.000 0.000 0.004
#> GSM892390 2 0.0290 0.990 0.000 0.992 0.000 0.000 0.008
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.1714 0.835 0.000 0.000 0.092 0.000 0.908 NA
#> GSM892345 4 0.2163 0.898 0.000 0.000 0.000 0.892 0.092 NA
#> GSM892349 5 0.3736 0.626 0.000 0.000 0.008 0.268 0.716 NA
#> GSM892353 1 0.0000 0.997 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892355 1 0.0146 0.996 0.996 0.000 0.000 0.000 0.000 NA
#> GSM892361 1 0.0000 0.997 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892365 3 0.2454 0.876 0.000 0.000 0.840 0.000 0.160 NA
#> GSM892369 3 0.0777 0.888 0.000 0.000 0.972 0.000 0.004 NA
#> GSM892373 2 0.2854 0.844 0.000 0.792 0.000 0.000 0.000 NA
#> GSM892377 2 0.2527 0.882 0.000 0.832 0.000 0.000 0.000 NA
#> GSM892381 2 0.0000 0.951 0.000 1.000 0.000 0.000 0.000 NA
#> GSM892383 2 0.0937 0.944 0.000 0.960 0.000 0.000 0.000 NA
#> GSM892387 2 0.0363 0.951 0.000 0.988 0.000 0.000 0.000 NA
#> GSM892344 5 0.1633 0.864 0.000 0.000 0.044 0.024 0.932 NA
#> GSM892347 4 0.1584 0.898 0.000 0.000 0.000 0.928 0.064 NA
#> GSM892351 4 0.3023 0.778 0.000 0.000 0.000 0.784 0.212 NA
#> GSM892357 1 0.0000 0.997 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892359 1 0.0146 0.997 0.996 0.000 0.000 0.000 0.000 NA
#> GSM892363 1 0.0146 0.997 0.996 0.000 0.000 0.000 0.000 NA
#> GSM892367 3 0.0972 0.908 0.000 0.000 0.964 0.000 0.028 NA
#> GSM892371 3 0.0964 0.905 0.000 0.000 0.968 0.012 0.016 NA
#> GSM892375 2 0.1007 0.944 0.000 0.956 0.000 0.000 0.000 NA
#> GSM892379 2 0.0865 0.948 0.000 0.964 0.000 0.000 0.000 NA
#> GSM892385 2 0.1007 0.944 0.000 0.956 0.000 0.000 0.000 NA
#> GSM892389 2 0.0363 0.952 0.000 0.988 0.000 0.000 0.000 NA
#> GSM892341 5 0.1387 0.855 0.000 0.000 0.068 0.000 0.932 NA
#> GSM892346 4 0.2151 0.812 0.000 0.000 0.008 0.904 0.016 NA
#> GSM892350 4 0.2048 0.883 0.000 0.000 0.000 0.880 0.120 NA
#> GSM892354 1 0.0146 0.996 0.996 0.000 0.000 0.000 0.000 NA
#> GSM892356 1 0.0000 0.997 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892362 1 0.0146 0.997 0.996 0.000 0.000 0.000 0.000 NA
#> GSM892366 3 0.3023 0.800 0.000 0.000 0.768 0.000 0.232 NA
#> GSM892370 3 0.0520 0.902 0.000 0.000 0.984 0.000 0.008 NA
#> GSM892374 2 0.3126 0.808 0.000 0.752 0.000 0.000 0.000 NA
#> GSM892378 2 0.2527 0.882 0.000 0.832 0.000 0.000 0.000 NA
#> GSM892382 2 0.0260 0.950 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892384 2 0.0260 0.950 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892388 2 0.0363 0.951 0.000 0.988 0.000 0.000 0.000 NA
#> GSM892343 5 0.2492 0.856 0.000 0.000 0.036 0.068 0.888 NA
#> GSM892348 4 0.1245 0.882 0.000 0.000 0.000 0.952 0.032 NA
#> GSM892352 5 0.2994 0.781 0.000 0.000 0.008 0.164 0.820 NA
#> GSM892358 1 0.0000 0.997 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892360 1 0.0146 0.997 0.996 0.000 0.000 0.000 0.000 NA
#> GSM892364 1 0.0458 0.989 0.984 0.000 0.000 0.000 0.000 NA
#> GSM892368 3 0.2212 0.900 0.000 0.000 0.880 0.000 0.112 NA
#> GSM892372 3 0.2003 0.901 0.000 0.000 0.884 0.000 0.116 NA
#> GSM892376 2 0.0790 0.948 0.000 0.968 0.000 0.000 0.000 NA
#> GSM892380 2 0.0260 0.951 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892386 2 0.0547 0.951 0.000 0.980 0.000 0.000 0.000 NA
#> GSM892390 2 0.0260 0.950 0.000 0.992 0.000 0.000 0.000 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> CV:NMF 50 1.000 0.934 2.67e-07 1.42e-03 2
#> CV:NMF 50 0.939 0.875 8.67e-12 3.79e-05 3
#> CV:NMF 48 1.000 0.987 7.68e-17 1.01e-06 4
#> CV:NMF 50 1.000 0.998 3.06e-20 2.01e-07 5
#> CV:NMF 50 1.000 0.998 3.06e-20 2.01e-07 6
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 31632 rows and 50 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 1.000 0.962 0.981 0.4312 0.794 0.612
#> 4 4 1.000 0.956 0.976 0.0916 0.941 0.819
#> 5 5 0.961 0.914 0.950 0.0457 0.963 0.862
#> 6 6 0.936 0.787 0.871 0.0227 0.993 0.971
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 2 3 4
There is also optional best \(k\) = 2 3 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.0000 0.951 0.000 0 1.000
#> GSM892345 1 0.0000 0.981 1.000 0 0.000
#> GSM892349 3 0.4002 0.828 0.160 0 0.840
#> GSM892353 1 0.0424 0.974 0.992 0 0.008
#> GSM892355 1 0.0000 0.981 1.000 0 0.000
#> GSM892361 1 0.0000 0.981 1.000 0 0.000
#> GSM892365 3 0.0000 0.951 0.000 0 1.000
#> GSM892369 3 0.2356 0.922 0.072 0 0.928
#> GSM892373 2 0.0000 1.000 0.000 1 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000
#> GSM892344 3 0.0000 0.951 0.000 0 1.000
#> GSM892347 1 0.0000 0.981 1.000 0 0.000
#> GSM892351 1 0.5560 0.549 0.700 0 0.300
#> GSM892357 1 0.0000 0.981 1.000 0 0.000
#> GSM892359 1 0.0000 0.981 1.000 0 0.000
#> GSM892363 1 0.0000 0.981 1.000 0 0.000
#> GSM892367 3 0.0000 0.951 0.000 0 1.000
#> GSM892371 3 0.2356 0.922 0.072 0 0.928
#> GSM892375 2 0.0000 1.000 0.000 1 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000
#> GSM892341 3 0.0000 0.951 0.000 0 1.000
#> GSM892346 1 0.0000 0.981 1.000 0 0.000
#> GSM892350 1 0.0000 0.981 1.000 0 0.000
#> GSM892354 1 0.0000 0.981 1.000 0 0.000
#> GSM892356 1 0.0000 0.981 1.000 0 0.000
#> GSM892362 1 0.0000 0.981 1.000 0 0.000
#> GSM892366 3 0.0000 0.951 0.000 0 1.000
#> GSM892370 3 0.2356 0.922 0.072 0 0.928
#> GSM892374 2 0.0000 1.000 0.000 1 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000
#> GSM892343 3 0.5016 0.727 0.240 0 0.760
#> GSM892348 1 0.0000 0.981 1.000 0 0.000
#> GSM892352 3 0.0424 0.949 0.008 0 0.992
#> GSM892358 1 0.0000 0.981 1.000 0 0.000
#> GSM892360 1 0.0000 0.981 1.000 0 0.000
#> GSM892364 1 0.0237 0.977 0.996 0 0.004
#> GSM892368 3 0.0000 0.951 0.000 0 1.000
#> GSM892372 3 0.0000 0.951 0.000 0 1.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.0336 0.946 0.000 0 0.992 0.008
#> GSM892345 4 0.0817 0.932 0.024 0 0.000 0.976
#> GSM892349 3 0.3266 0.815 0.000 0 0.832 0.168
#> GSM892353 1 0.0469 0.983 0.988 0 0.000 0.012
#> GSM892355 1 0.0188 0.987 0.996 0 0.000 0.004
#> GSM892361 1 0.0817 0.980 0.976 0 0.000 0.024
#> GSM892365 3 0.0000 0.948 0.000 0 1.000 0.000
#> GSM892369 3 0.1867 0.917 0.000 0 0.928 0.072
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892344 3 0.0336 0.946 0.000 0 0.992 0.008
#> GSM892347 4 0.0817 0.932 0.024 0 0.000 0.976
#> GSM892351 4 0.4908 0.556 0.016 0 0.292 0.692
#> GSM892357 1 0.0707 0.982 0.980 0 0.000 0.020
#> GSM892359 1 0.0000 0.988 1.000 0 0.000 0.000
#> GSM892363 1 0.0000 0.988 1.000 0 0.000 0.000
#> GSM892367 3 0.0000 0.948 0.000 0 1.000 0.000
#> GSM892371 3 0.1867 0.917 0.000 0 0.928 0.072
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892341 3 0.0336 0.946 0.000 0 0.992 0.008
#> GSM892346 4 0.0469 0.922 0.012 0 0.000 0.988
#> GSM892350 4 0.0817 0.932 0.024 0 0.000 0.976
#> GSM892354 1 0.0817 0.980 0.976 0 0.000 0.024
#> GSM892356 1 0.0188 0.987 0.996 0 0.000 0.004
#> GSM892362 1 0.0336 0.986 0.992 0 0.000 0.008
#> GSM892366 3 0.0000 0.948 0.000 0 1.000 0.000
#> GSM892370 3 0.1867 0.917 0.000 0 0.928 0.072
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892343 3 0.4538 0.733 0.024 0 0.760 0.216
#> GSM892348 4 0.0921 0.931 0.028 0 0.000 0.972
#> GSM892352 3 0.0592 0.944 0.000 0 0.984 0.016
#> GSM892358 1 0.0000 0.988 1.000 0 0.000 0.000
#> GSM892360 1 0.0000 0.988 1.000 0 0.000 0.000
#> GSM892364 1 0.1398 0.954 0.956 0 0.004 0.040
#> GSM892368 3 0.0000 0.948 0.000 0 1.000 0.000
#> GSM892372 3 0.0000 0.948 0.000 0 1.000 0.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 5 0.3876 0.775 0.000 0 0.316 0.000 0.684
#> GSM892345 4 0.0000 0.925 0.000 0 0.000 1.000 0.000
#> GSM892349 5 0.3197 0.567 0.000 0 0.024 0.140 0.836
#> GSM892353 1 0.0404 0.984 0.988 0 0.000 0.000 0.012
#> GSM892355 1 0.0162 0.988 0.996 0 0.000 0.000 0.004
#> GSM892361 1 0.0703 0.981 0.976 0 0.000 0.000 0.024
#> GSM892365 3 0.0162 0.870 0.000 0 0.996 0.000 0.004
#> GSM892369 3 0.2659 0.838 0.000 0 0.888 0.060 0.052
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892344 5 0.3876 0.775 0.000 0 0.316 0.000 0.684
#> GSM892347 4 0.0000 0.925 0.000 0 0.000 1.000 0.000
#> GSM892351 4 0.3895 0.619 0.000 0 0.000 0.680 0.320
#> GSM892357 1 0.0609 0.983 0.980 0 0.000 0.000 0.020
#> GSM892359 1 0.0000 0.988 1.000 0 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.988 1.000 0 0.000 0.000 0.000
#> GSM892367 3 0.0162 0.870 0.000 0 0.996 0.000 0.004
#> GSM892371 3 0.2659 0.838 0.000 0 0.888 0.060 0.052
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892341 5 0.3876 0.775 0.000 0 0.316 0.000 0.684
#> GSM892346 4 0.1124 0.910 0.004 0 0.000 0.960 0.036
#> GSM892350 4 0.0404 0.920 0.000 0 0.000 0.988 0.012
#> GSM892354 1 0.0703 0.981 0.976 0 0.000 0.000 0.024
#> GSM892356 1 0.0162 0.988 0.996 0 0.000 0.000 0.004
#> GSM892362 1 0.0290 0.987 0.992 0 0.000 0.000 0.008
#> GSM892366 3 0.0162 0.870 0.000 0 0.996 0.000 0.004
#> GSM892370 3 0.2659 0.838 0.000 0 0.888 0.060 0.052
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892343 3 0.6855 0.211 0.024 0 0.512 0.192 0.272
#> GSM892348 4 0.0566 0.921 0.004 0 0.000 0.984 0.012
#> GSM892352 5 0.1270 0.704 0.000 0 0.052 0.000 0.948
#> GSM892358 1 0.0000 0.988 1.000 0 0.000 0.000 0.000
#> GSM892360 1 0.0000 0.988 1.000 0 0.000 0.000 0.000
#> GSM892364 1 0.1300 0.957 0.956 0 0.000 0.028 0.016
#> GSM892368 3 0.0162 0.870 0.000 0 0.996 0.000 0.004
#> GSM892372 3 0.0162 0.870 0.000 0 0.996 0.000 0.004
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.0000 0.78930 0.000 0 0.000 0.000 1.000 0.000
#> GSM892345 4 0.3695 -0.14715 0.000 0 0.000 0.624 0.000 0.376
#> GSM892349 5 0.4289 0.56648 0.000 0 0.012 0.444 0.540 0.004
#> GSM892353 1 0.2389 0.91090 0.864 0 0.000 0.000 0.008 0.128
#> GSM892355 1 0.1501 0.93998 0.924 0 0.000 0.000 0.000 0.076
#> GSM892361 1 0.0937 0.94661 0.960 0 0.000 0.000 0.000 0.040
#> GSM892365 3 0.5839 0.65430 0.000 0 0.488 0.000 0.236 0.276
#> GSM892369 3 0.0458 0.55654 0.000 0 0.984 0.016 0.000 0.000
#> GSM892373 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892377 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892381 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892383 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892387 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892344 5 0.0000 0.78930 0.000 0 0.000 0.000 1.000 0.000
#> GSM892347 4 0.3765 -0.31004 0.000 0 0.000 0.596 0.000 0.404
#> GSM892351 4 0.0363 0.14729 0.000 0 0.012 0.988 0.000 0.000
#> GSM892357 1 0.0790 0.94925 0.968 0 0.000 0.000 0.000 0.032
#> GSM892359 1 0.0458 0.95329 0.984 0 0.000 0.000 0.000 0.016
#> GSM892363 1 0.1765 0.93077 0.904 0 0.000 0.000 0.000 0.096
#> GSM892367 3 0.5839 0.65430 0.000 0 0.488 0.000 0.236 0.276
#> GSM892371 3 0.0458 0.55654 0.000 0 0.984 0.016 0.000 0.000
#> GSM892375 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892379 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892385 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892389 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892341 5 0.0000 0.78930 0.000 0 0.000 0.000 1.000 0.000
#> GSM892346 6 0.3975 0.86878 0.004 0 0.000 0.452 0.000 0.544
#> GSM892350 4 0.3802 0.11642 0.000 0 0.012 0.676 0.000 0.312
#> GSM892354 1 0.0937 0.94661 0.960 0 0.000 0.000 0.000 0.040
#> GSM892356 1 0.0790 0.95114 0.968 0 0.000 0.000 0.000 0.032
#> GSM892362 1 0.0547 0.95149 0.980 0 0.000 0.000 0.000 0.020
#> GSM892366 3 0.5839 0.65430 0.000 0 0.488 0.000 0.236 0.276
#> GSM892370 3 0.0458 0.55654 0.000 0 0.984 0.016 0.000 0.000
#> GSM892374 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892378 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892382 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892384 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892388 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892343 3 0.6268 -0.00826 0.016 0 0.584 0.156 0.204 0.040
#> GSM892348 6 0.3995 0.86043 0.004 0 0.000 0.480 0.000 0.516
#> GSM892352 5 0.3446 0.68491 0.000 0 0.000 0.308 0.692 0.000
#> GSM892358 1 0.0146 0.95344 0.996 0 0.000 0.000 0.000 0.004
#> GSM892360 1 0.0458 0.95329 0.984 0 0.000 0.000 0.000 0.016
#> GSM892364 1 0.2664 0.89894 0.848 0 0.000 0.016 0.000 0.136
#> GSM892368 3 0.5839 0.65430 0.000 0 0.488 0.000 0.236 0.276
#> GSM892372 3 0.5839 0.65430 0.000 0 0.488 0.000 0.236 0.276
#> GSM892376 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892380 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892386 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892390 2 0.0000 1.00000 0.000 1 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> MAD:hclust 50 1.000 0.934 2.67e-07 1.42e-03 2
#> MAD:hclust 50 1.000 0.931 1.69e-11 8.93e-05 3
#> MAD:hclust 50 1.000 0.986 8.26e-16 4.62e-06 4
#> MAD:hclust 49 0.996 0.993 2.50e-19 7.39e-07 5
#> MAD:hclust 45 0.703 0.994 1.15e-19 4.58e-07 6
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 31632 rows and 50 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 0.699 0.874 0.856 0.3384 0.794 0.612
#> 4 4 0.635 0.881 0.831 0.1311 0.912 0.736
#> 5 5 0.693 0.756 0.820 0.0692 0.974 0.898
#> 6 6 0.751 0.699 0.804 0.0509 1.000 1.000
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 2
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.0000 0.884 0.000 0.000 1.000
#> GSM892345 3 0.5859 0.202 0.344 0.000 0.656
#> GSM892349 3 0.0424 0.877 0.008 0.000 0.992
#> GSM892353 1 0.5560 0.980 0.700 0.000 0.300
#> GSM892355 1 0.5560 0.980 0.700 0.000 0.300
#> GSM892361 1 0.5560 0.980 0.700 0.000 0.300
#> GSM892365 3 0.0000 0.884 0.000 0.000 1.000
#> GSM892369 3 0.0000 0.884 0.000 0.000 1.000
#> GSM892373 2 0.4750 0.897 0.216 0.784 0.000
#> GSM892377 2 0.3879 0.933 0.152 0.848 0.000
#> GSM892381 2 0.0000 0.949 0.000 1.000 0.000
#> GSM892383 2 0.1289 0.948 0.032 0.968 0.000
#> GSM892387 2 0.0747 0.949 0.016 0.984 0.000
#> GSM892344 3 0.0000 0.884 0.000 0.000 1.000
#> GSM892347 3 0.5859 0.202 0.344 0.000 0.656
#> GSM892351 3 0.5178 0.479 0.256 0.000 0.744
#> GSM892357 1 0.5560 0.980 0.700 0.000 0.300
#> GSM892359 1 0.5560 0.980 0.700 0.000 0.300
#> GSM892363 1 0.5560 0.980 0.700 0.000 0.300
#> GSM892367 3 0.0000 0.884 0.000 0.000 1.000
#> GSM892371 3 0.0000 0.884 0.000 0.000 1.000
#> GSM892375 2 0.2165 0.941 0.064 0.936 0.000
#> GSM892379 2 0.2878 0.946 0.096 0.904 0.000
#> GSM892385 2 0.3267 0.938 0.116 0.884 0.000
#> GSM892389 2 0.2878 0.943 0.096 0.904 0.000
#> GSM892341 3 0.0000 0.884 0.000 0.000 1.000
#> GSM892346 1 0.5497 0.969 0.708 0.000 0.292
#> GSM892350 3 0.5859 0.202 0.344 0.000 0.656
#> GSM892354 1 0.5560 0.980 0.700 0.000 0.300
#> GSM892356 1 0.5560 0.980 0.700 0.000 0.300
#> GSM892362 1 0.5560 0.980 0.700 0.000 0.300
#> GSM892366 3 0.0000 0.884 0.000 0.000 1.000
#> GSM892370 3 0.0000 0.884 0.000 0.000 1.000
#> GSM892374 2 0.4750 0.897 0.216 0.784 0.000
#> GSM892378 2 0.3879 0.933 0.152 0.848 0.000
#> GSM892382 2 0.0000 0.949 0.000 1.000 0.000
#> GSM892384 2 0.0000 0.949 0.000 1.000 0.000
#> GSM892388 2 0.4235 0.908 0.176 0.824 0.000
#> GSM892343 3 0.0000 0.884 0.000 0.000 1.000
#> GSM892348 1 0.6235 0.683 0.564 0.000 0.436
#> GSM892352 3 0.0424 0.877 0.008 0.000 0.992
#> GSM892358 1 0.5560 0.980 0.700 0.000 0.300
#> GSM892360 1 0.5560 0.980 0.700 0.000 0.300
#> GSM892364 1 0.5560 0.980 0.700 0.000 0.300
#> GSM892368 3 0.0000 0.884 0.000 0.000 1.000
#> GSM892372 3 0.0000 0.884 0.000 0.000 1.000
#> GSM892376 2 0.2066 0.942 0.060 0.940 0.000
#> GSM892380 2 0.1163 0.949 0.028 0.972 0.000
#> GSM892386 2 0.0424 0.948 0.008 0.992 0.000
#> GSM892390 2 0.2625 0.944 0.084 0.916 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.2647 0.972 0.120 0.000 0.880 0.000
#> GSM892345 4 0.7457 0.786 0.276 0.000 0.220 0.504
#> GSM892349 4 0.7026 0.475 0.120 0.000 0.404 0.476
#> GSM892353 1 0.0707 0.979 0.980 0.000 0.000 0.020
#> GSM892355 1 0.0707 0.979 0.980 0.000 0.000 0.020
#> GSM892361 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM892365 3 0.2647 0.972 0.120 0.000 0.880 0.000
#> GSM892369 3 0.3907 0.943 0.120 0.000 0.836 0.044
#> GSM892373 2 0.4907 0.756 0.000 0.580 0.000 0.420
#> GSM892377 2 0.4459 0.856 0.000 0.780 0.032 0.188
#> GSM892381 2 0.1833 0.892 0.000 0.944 0.032 0.024
#> GSM892383 2 0.1406 0.893 0.000 0.960 0.024 0.016
#> GSM892387 2 0.2797 0.891 0.000 0.900 0.032 0.068
#> GSM892344 3 0.2647 0.972 0.120 0.000 0.880 0.000
#> GSM892347 4 0.7457 0.786 0.276 0.000 0.220 0.504
#> GSM892351 4 0.7478 0.753 0.240 0.000 0.256 0.504
#> GSM892357 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM892359 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM892367 3 0.2647 0.972 0.120 0.000 0.880 0.000
#> GSM892371 3 0.3907 0.943 0.120 0.000 0.836 0.044
#> GSM892375 2 0.4290 0.865 0.000 0.800 0.036 0.164
#> GSM892379 2 0.2699 0.889 0.000 0.904 0.028 0.068
#> GSM892385 2 0.3764 0.872 0.000 0.852 0.076 0.072
#> GSM892389 2 0.2670 0.889 0.000 0.904 0.024 0.072
#> GSM892341 3 0.2647 0.972 0.120 0.000 0.880 0.000
#> GSM892346 4 0.5000 0.386 0.496 0.000 0.000 0.504
#> GSM892350 4 0.7457 0.786 0.276 0.000 0.220 0.504
#> GSM892354 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM892356 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM892362 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM892366 3 0.2647 0.972 0.120 0.000 0.880 0.000
#> GSM892370 3 0.3907 0.943 0.120 0.000 0.836 0.044
#> GSM892374 2 0.4907 0.756 0.000 0.580 0.000 0.420
#> GSM892378 2 0.4459 0.856 0.000 0.780 0.032 0.188
#> GSM892382 2 0.1724 0.892 0.000 0.948 0.032 0.020
#> GSM892384 2 0.1724 0.892 0.000 0.948 0.032 0.020
#> GSM892388 2 0.5358 0.808 0.000 0.700 0.048 0.252
#> GSM892343 3 0.4227 0.921 0.120 0.000 0.820 0.060
#> GSM892348 4 0.6672 0.626 0.408 0.000 0.088 0.504
#> GSM892352 4 0.7026 0.475 0.120 0.000 0.404 0.476
#> GSM892358 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM892360 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM892364 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM892368 3 0.2647 0.972 0.120 0.000 0.880 0.000
#> GSM892372 3 0.2647 0.972 0.120 0.000 0.880 0.000
#> GSM892376 2 0.4197 0.867 0.000 0.808 0.036 0.156
#> GSM892380 2 0.1042 0.894 0.000 0.972 0.008 0.020
#> GSM892386 2 0.1356 0.894 0.000 0.960 0.032 0.008
#> GSM892390 2 0.2521 0.889 0.000 0.912 0.024 0.064
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 3 0.3950 0.838 0.068 0.000 0.796 0.000 0.136
#> GSM892345 4 0.4428 0.856 0.144 0.000 0.096 0.760 0.000
#> GSM892349 4 0.7026 0.610 0.064 0.000 0.212 0.556 0.168
#> GSM892353 1 0.2574 0.919 0.876 0.000 0.000 0.012 0.112
#> GSM892355 1 0.2574 0.919 0.876 0.000 0.000 0.012 0.112
#> GSM892361 1 0.1608 0.938 0.928 0.000 0.000 0.000 0.072
#> GSM892365 3 0.1704 0.886 0.068 0.000 0.928 0.000 0.004
#> GSM892369 3 0.4465 0.852 0.068 0.000 0.800 0.056 0.076
#> GSM892373 5 0.4256 1.000 0.000 0.436 0.000 0.000 0.564
#> GSM892377 2 0.4971 0.397 0.000 0.708 0.000 0.116 0.176
#> GSM892381 2 0.1934 0.663 0.000 0.932 0.008 0.040 0.020
#> GSM892383 2 0.1990 0.664 0.000 0.920 0.008 0.068 0.004
#> GSM892387 2 0.3666 0.580 0.000 0.840 0.020 0.048 0.092
#> GSM892344 3 0.4036 0.836 0.068 0.000 0.788 0.000 0.144
#> GSM892347 4 0.4428 0.856 0.144 0.000 0.096 0.760 0.000
#> GSM892351 4 0.5029 0.842 0.128 0.000 0.112 0.740 0.020
#> GSM892357 1 0.1544 0.940 0.932 0.000 0.000 0.000 0.068
#> GSM892359 1 0.0290 0.950 0.992 0.000 0.000 0.000 0.008
#> GSM892363 1 0.0609 0.951 0.980 0.000 0.000 0.000 0.020
#> GSM892367 3 0.2645 0.883 0.068 0.000 0.888 0.000 0.044
#> GSM892371 3 0.4465 0.852 0.068 0.000 0.800 0.056 0.076
#> GSM892375 2 0.4719 0.345 0.000 0.732 0.012 0.052 0.204
#> GSM892379 2 0.3970 0.614 0.000 0.820 0.016 0.080 0.084
#> GSM892385 2 0.4510 0.581 0.000 0.788 0.032 0.112 0.068
#> GSM892389 2 0.3800 0.621 0.000 0.836 0.028 0.052 0.084
#> GSM892341 3 0.3950 0.838 0.068 0.000 0.796 0.000 0.136
#> GSM892346 4 0.4223 0.739 0.248 0.000 0.000 0.724 0.028
#> GSM892350 4 0.4428 0.856 0.144 0.000 0.096 0.760 0.000
#> GSM892354 1 0.1544 0.940 0.932 0.000 0.000 0.000 0.068
#> GSM892356 1 0.1768 0.940 0.924 0.000 0.000 0.004 0.072
#> GSM892362 1 0.0609 0.948 0.980 0.000 0.000 0.000 0.020
#> GSM892366 3 0.1704 0.886 0.068 0.000 0.928 0.000 0.004
#> GSM892370 3 0.4465 0.852 0.068 0.000 0.800 0.056 0.076
#> GSM892374 5 0.4256 1.000 0.000 0.436 0.000 0.000 0.564
#> GSM892378 2 0.4971 0.397 0.000 0.708 0.000 0.116 0.176
#> GSM892382 2 0.1710 0.664 0.000 0.940 0.004 0.040 0.016
#> GSM892384 2 0.1787 0.662 0.000 0.936 0.004 0.044 0.016
#> GSM892388 2 0.5841 -0.409 0.000 0.560 0.032 0.044 0.364
#> GSM892343 3 0.6278 0.721 0.068 0.000 0.652 0.124 0.156
#> GSM892348 4 0.4285 0.808 0.208 0.000 0.032 0.752 0.008
#> GSM892352 4 0.7095 0.594 0.064 0.000 0.224 0.544 0.168
#> GSM892358 1 0.0671 0.951 0.980 0.000 0.000 0.004 0.016
#> GSM892360 1 0.0290 0.950 0.992 0.000 0.000 0.000 0.008
#> GSM892364 1 0.1410 0.941 0.940 0.000 0.000 0.000 0.060
#> GSM892368 3 0.1704 0.886 0.068 0.000 0.928 0.000 0.004
#> GSM892372 3 0.2491 0.884 0.068 0.000 0.896 0.000 0.036
#> GSM892376 2 0.4574 0.383 0.000 0.748 0.008 0.060 0.184
#> GSM892380 2 0.1597 0.674 0.000 0.940 0.000 0.048 0.012
#> GSM892386 2 0.1843 0.672 0.000 0.932 0.008 0.052 0.008
#> GSM892390 2 0.3656 0.623 0.000 0.844 0.024 0.052 0.080
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 3 0.4002 0.727 0.020 0.000 0.660 0.000 0.000 NA
#> GSM892345 4 0.2647 0.848 0.088 0.000 0.044 0.868 0.000 NA
#> GSM892349 4 0.6375 0.530 0.020 0.000 0.132 0.528 0.028 NA
#> GSM892353 1 0.3885 0.829 0.756 0.000 0.000 0.004 0.048 NA
#> GSM892355 1 0.3791 0.834 0.768 0.000 0.000 0.004 0.048 NA
#> GSM892361 1 0.2390 0.902 0.888 0.000 0.000 0.000 0.056 NA
#> GSM892365 3 0.1408 0.828 0.020 0.000 0.944 0.000 0.000 NA
#> GSM892369 3 0.3921 0.790 0.020 0.000 0.816 0.040 0.092 NA
#> GSM892373 5 0.3464 1.000 0.000 0.312 0.000 0.000 0.688 NA
#> GSM892377 2 0.6405 0.121 0.000 0.504 0.008 0.032 0.296 NA
#> GSM892381 2 0.1053 0.619 0.000 0.964 0.000 0.004 0.012 NA
#> GSM892383 2 0.2923 0.613 0.000 0.856 0.008 0.004 0.024 NA
#> GSM892387 2 0.2854 0.573 0.000 0.872 0.000 0.024 0.068 NA
#> GSM892344 3 0.4064 0.722 0.020 0.000 0.644 0.000 0.000 NA
#> GSM892347 4 0.2647 0.848 0.088 0.000 0.044 0.868 0.000 NA
#> GSM892351 4 0.3818 0.830 0.072 0.000 0.060 0.824 0.028 NA
#> GSM892357 1 0.2390 0.904 0.888 0.000 0.000 0.000 0.056 NA
#> GSM892359 1 0.0603 0.918 0.980 0.000 0.000 0.000 0.016 NA
#> GSM892363 1 0.1168 0.916 0.956 0.000 0.000 0.000 0.028 NA
#> GSM892367 3 0.0951 0.824 0.020 0.000 0.968 0.000 0.004 NA
#> GSM892371 3 0.3921 0.790 0.020 0.000 0.816 0.040 0.092 NA
#> GSM892375 2 0.4256 0.330 0.000 0.728 0.004 0.032 0.220 NA
#> GSM892379 2 0.4680 0.515 0.000 0.684 0.000 0.000 0.132 NA
#> GSM892385 2 0.5609 0.393 0.000 0.600 0.008 0.024 0.088 NA
#> GSM892389 2 0.4733 0.523 0.000 0.688 0.000 0.004 0.120 NA
#> GSM892341 3 0.4002 0.727 0.020 0.000 0.660 0.000 0.000 NA
#> GSM892346 4 0.3476 0.792 0.132 0.000 0.000 0.816 0.024 NA
#> GSM892350 4 0.2647 0.848 0.088 0.000 0.044 0.868 0.000 NA
#> GSM892354 1 0.2451 0.902 0.884 0.000 0.000 0.000 0.056 NA
#> GSM892356 1 0.2201 0.906 0.896 0.000 0.000 0.000 0.028 NA
#> GSM892362 1 0.1074 0.916 0.960 0.000 0.000 0.000 0.028 NA
#> GSM892366 3 0.1408 0.828 0.020 0.000 0.944 0.000 0.000 NA
#> GSM892370 3 0.3921 0.790 0.020 0.000 0.816 0.040 0.092 NA
#> GSM892374 5 0.3464 1.000 0.000 0.312 0.000 0.000 0.688 NA
#> GSM892378 2 0.6405 0.121 0.000 0.504 0.008 0.032 0.296 NA
#> GSM892382 2 0.0692 0.620 0.000 0.976 0.000 0.000 0.004 NA
#> GSM892384 2 0.1074 0.617 0.000 0.960 0.000 0.000 0.012 NA
#> GSM892388 2 0.6845 -0.279 0.000 0.420 0.000 0.068 0.324 NA
#> GSM892343 3 0.5834 0.585 0.020 0.000 0.532 0.132 0.000 NA
#> GSM892348 4 0.2853 0.819 0.124 0.000 0.008 0.852 0.008 NA
#> GSM892352 4 0.6443 0.508 0.020 0.000 0.136 0.512 0.028 NA
#> GSM892358 1 0.0146 0.920 0.996 0.000 0.000 0.000 0.004 NA
#> GSM892360 1 0.0603 0.918 0.980 0.000 0.000 0.000 0.016 NA
#> GSM892364 1 0.2201 0.903 0.900 0.000 0.000 0.000 0.048 NA
#> GSM892368 3 0.1408 0.828 0.020 0.000 0.944 0.000 0.000 NA
#> GSM892372 3 0.0547 0.825 0.020 0.000 0.980 0.000 0.000 NA
#> GSM892376 2 0.4185 0.345 0.000 0.740 0.004 0.028 0.208 NA
#> GSM892380 2 0.2839 0.620 0.000 0.860 0.000 0.004 0.044 NA
#> GSM892386 2 0.1500 0.624 0.000 0.936 0.000 0.000 0.012 NA
#> GSM892390 2 0.4474 0.528 0.000 0.704 0.000 0.000 0.108 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)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> MAD:kmeans 50 1.000 0.934 2.67e-07 1.42e-03 2
#> MAD:kmeans 46 0.905 0.934 3.31e-11 1.38e-04 3
#> MAD:kmeans 47 0.981 0.940 2.58e-16 2.20e-06 4
#> MAD:kmeans 45 0.999 0.723 1.15e-19 2.75e-08 5
#> MAD:kmeans 44 1.000 0.752 5.57e-19 7.88e-08 6
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 31632 rows and 50 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 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 1.000 0.989 0.995 0.4377 0.794 0.612
#> 4 4 1.000 0.975 0.991 0.1020 0.912 0.736
#> 5 5 0.972 0.948 0.964 0.0361 0.958 0.838
#> 6 6 0.972 0.911 0.917 0.0164 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] 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
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.000 1.000 0.000 0 1.000
#> GSM892345 1 0.000 0.985 1.000 0 0.000
#> GSM892349 3 0.000 1.000 0.000 0 1.000
#> GSM892353 1 0.000 0.985 1.000 0 0.000
#> GSM892355 1 0.000 0.985 1.000 0 0.000
#> GSM892361 1 0.000 0.985 1.000 0 0.000
#> GSM892365 3 0.000 1.000 0.000 0 1.000
#> GSM892369 3 0.000 1.000 0.000 0 1.000
#> GSM892373 2 0.000 1.000 0.000 1 0.000
#> GSM892377 2 0.000 1.000 0.000 1 0.000
#> GSM892381 2 0.000 1.000 0.000 1 0.000
#> GSM892383 2 0.000 1.000 0.000 1 0.000
#> GSM892387 2 0.000 1.000 0.000 1 0.000
#> GSM892344 3 0.000 1.000 0.000 0 1.000
#> GSM892347 1 0.000 0.985 1.000 0 0.000
#> GSM892351 1 0.445 0.770 0.808 0 0.192
#> GSM892357 1 0.000 0.985 1.000 0 0.000
#> GSM892359 1 0.000 0.985 1.000 0 0.000
#> GSM892363 1 0.000 0.985 1.000 0 0.000
#> GSM892367 3 0.000 1.000 0.000 0 1.000
#> GSM892371 3 0.000 1.000 0.000 0 1.000
#> GSM892375 2 0.000 1.000 0.000 1 0.000
#> GSM892379 2 0.000 1.000 0.000 1 0.000
#> GSM892385 2 0.000 1.000 0.000 1 0.000
#> GSM892389 2 0.000 1.000 0.000 1 0.000
#> GSM892341 3 0.000 1.000 0.000 0 1.000
#> GSM892346 1 0.000 0.985 1.000 0 0.000
#> GSM892350 1 0.207 0.931 0.940 0 0.060
#> GSM892354 1 0.000 0.985 1.000 0 0.000
#> GSM892356 1 0.000 0.985 1.000 0 0.000
#> GSM892362 1 0.000 0.985 1.000 0 0.000
#> GSM892366 3 0.000 1.000 0.000 0 1.000
#> GSM892370 3 0.000 1.000 0.000 0 1.000
#> GSM892374 2 0.000 1.000 0.000 1 0.000
#> GSM892378 2 0.000 1.000 0.000 1 0.000
#> GSM892382 2 0.000 1.000 0.000 1 0.000
#> GSM892384 2 0.000 1.000 0.000 1 0.000
#> GSM892388 2 0.000 1.000 0.000 1 0.000
#> GSM892343 3 0.000 1.000 0.000 0 1.000
#> GSM892348 1 0.000 0.985 1.000 0 0.000
#> GSM892352 3 0.000 1.000 0.000 0 1.000
#> GSM892358 1 0.000 0.985 1.000 0 0.000
#> GSM892360 1 0.000 0.985 1.000 0 0.000
#> GSM892364 1 0.000 0.985 1.000 0 0.000
#> GSM892368 3 0.000 1.000 0.000 0 1.000
#> GSM892372 3 0.000 1.000 0.000 0 1.000
#> GSM892376 2 0.000 1.000 0.000 1 0.000
#> GSM892380 2 0.000 1.000 0.000 1 0.000
#> GSM892386 2 0.000 1.000 0.000 1 0.000
#> GSM892390 2 0.000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.0000 0.957 0.000 0 1.000 0.000
#> GSM892345 4 0.0000 0.999 0.000 0 0.000 1.000
#> GSM892349 4 0.0000 0.999 0.000 0 0.000 1.000
#> GSM892353 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892355 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892361 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892365 3 0.0000 0.957 0.000 0 1.000 0.000
#> GSM892369 3 0.0188 0.956 0.000 0 0.996 0.004
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892344 3 0.0469 0.949 0.000 0 0.988 0.012
#> GSM892347 4 0.0000 0.999 0.000 0 0.000 1.000
#> GSM892351 4 0.0000 0.999 0.000 0 0.000 1.000
#> GSM892357 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892359 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892363 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892367 3 0.0000 0.957 0.000 0 1.000 0.000
#> GSM892371 3 0.0188 0.956 0.000 0 0.996 0.004
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892341 3 0.0000 0.957 0.000 0 1.000 0.000
#> GSM892346 4 0.0336 0.991 0.008 0 0.000 0.992
#> GSM892350 4 0.0000 0.999 0.000 0 0.000 1.000
#> GSM892354 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892356 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892362 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892366 3 0.0000 0.957 0.000 0 1.000 0.000
#> GSM892370 3 0.0188 0.956 0.000 0 0.996 0.004
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892343 3 0.4941 0.235 0.000 0 0.564 0.436
#> GSM892348 4 0.0000 0.999 0.000 0 0.000 1.000
#> GSM892352 4 0.0000 0.999 0.000 0 0.000 1.000
#> GSM892358 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892360 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892364 1 0.0000 1.000 1.000 0 0.000 0.000
#> GSM892368 3 0.0000 0.957 0.000 0 1.000 0.000
#> GSM892372 3 0.0000 0.957 0.000 0 1.000 0.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 5 0.0609 0.807 0.000 0.000 0.020 0.000 0.980
#> GSM892345 4 0.0162 0.996 0.000 0.000 0.000 0.996 0.004
#> GSM892349 5 0.4201 0.441 0.000 0.000 0.000 0.408 0.592
#> GSM892353 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892355 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892361 1 0.0162 0.997 0.996 0.000 0.000 0.000 0.004
#> GSM892365 3 0.3074 0.896 0.000 0.000 0.804 0.000 0.196
#> GSM892369 3 0.0000 0.879 0.000 0.000 1.000 0.000 0.000
#> GSM892373 2 0.0162 0.998 0.000 0.996 0.000 0.000 0.004
#> GSM892377 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892381 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892383 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892387 2 0.0162 0.998 0.000 0.996 0.000 0.000 0.004
#> GSM892344 5 0.0510 0.808 0.000 0.000 0.016 0.000 0.984
#> GSM892347 4 0.0000 0.996 0.000 0.000 0.000 1.000 0.000
#> GSM892351 4 0.0290 0.994 0.000 0.000 0.000 0.992 0.008
#> GSM892357 1 0.0162 0.997 0.996 0.000 0.000 0.000 0.004
#> GSM892359 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892367 3 0.2230 0.906 0.000 0.000 0.884 0.000 0.116
#> GSM892371 3 0.0000 0.879 0.000 0.000 1.000 0.000 0.000
#> GSM892375 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892379 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892385 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892389 2 0.0162 0.998 0.000 0.996 0.000 0.000 0.004
#> GSM892341 5 0.0609 0.807 0.000 0.000 0.020 0.000 0.980
#> GSM892346 4 0.0162 0.993 0.000 0.000 0.000 0.996 0.004
#> GSM892350 4 0.0162 0.996 0.000 0.000 0.000 0.996 0.004
#> GSM892354 1 0.0162 0.997 0.996 0.000 0.000 0.000 0.004
#> GSM892356 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892362 1 0.0162 0.997 0.996 0.000 0.000 0.000 0.004
#> GSM892366 3 0.3074 0.896 0.000 0.000 0.804 0.000 0.196
#> GSM892370 3 0.0000 0.879 0.000 0.000 1.000 0.000 0.000
#> GSM892374 2 0.0162 0.998 0.000 0.996 0.000 0.000 0.004
#> GSM892378 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892382 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892384 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892388 2 0.0162 0.998 0.000 0.996 0.000 0.000 0.004
#> GSM892343 5 0.3321 0.783 0.000 0.000 0.032 0.136 0.832
#> GSM892348 4 0.0000 0.996 0.000 0.000 0.000 1.000 0.000
#> GSM892352 5 0.3336 0.721 0.000 0.000 0.000 0.228 0.772
#> GSM892358 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892360 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892364 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000
#> GSM892368 3 0.3074 0.896 0.000 0.000 0.804 0.000 0.196
#> GSM892372 3 0.2648 0.906 0.000 0.000 0.848 0.000 0.152
#> GSM892376 2 0.0162 0.998 0.000 0.996 0.000 0.000 0.004
#> GSM892380 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM892386 2 0.0162 0.998 0.000 0.996 0.000 0.000 0.004
#> GSM892390 2 0.0162 0.998 0.000 0.996 0.000 0.000 0.004
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.1349 0.803 0.000 0.000 0.056 0.000 0.940 NA
#> GSM892345 4 0.0891 0.949 0.000 0.000 0.000 0.968 0.008 NA
#> GSM892349 5 0.5847 0.428 0.000 0.000 0.000 0.260 0.488 NA
#> GSM892353 1 0.2118 0.922 0.888 0.000 0.000 0.000 0.008 NA
#> GSM892355 1 0.1644 0.942 0.920 0.000 0.000 0.000 0.004 NA
#> GSM892361 1 0.0547 0.970 0.980 0.000 0.000 0.000 0.000 NA
#> GSM892365 3 0.0405 0.827 0.000 0.000 0.988 0.000 0.008 NA
#> GSM892369 3 0.3789 0.715 0.000 0.000 0.584 0.000 0.000 NA
#> GSM892373 2 0.0458 0.991 0.000 0.984 0.000 0.000 0.000 NA
#> GSM892377 2 0.0363 0.992 0.000 0.988 0.000 0.000 0.000 NA
#> GSM892381 2 0.0260 0.992 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892383 2 0.0363 0.994 0.000 0.988 0.000 0.000 0.000 NA
#> GSM892387 2 0.0146 0.994 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892344 5 0.1196 0.805 0.000 0.000 0.040 0.000 0.952 NA
#> GSM892347 4 0.0363 0.950 0.000 0.000 0.000 0.988 0.000 NA
#> GSM892351 4 0.2494 0.881 0.000 0.000 0.000 0.864 0.016 NA
#> GSM892357 1 0.0547 0.970 0.980 0.000 0.000 0.000 0.000 NA
#> GSM892359 1 0.0713 0.968 0.972 0.000 0.000 0.000 0.000 NA
#> GSM892363 1 0.0790 0.967 0.968 0.000 0.000 0.000 0.000 NA
#> GSM892367 3 0.0790 0.830 0.000 0.000 0.968 0.000 0.000 NA
#> GSM892371 3 0.3765 0.722 0.000 0.000 0.596 0.000 0.000 NA
#> GSM892375 2 0.0458 0.993 0.000 0.984 0.000 0.000 0.000 NA
#> GSM892379 2 0.0146 0.994 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892385 2 0.0146 0.993 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892389 2 0.0146 0.994 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892341 5 0.1204 0.804 0.000 0.000 0.056 0.000 0.944 NA
#> GSM892346 4 0.0713 0.940 0.000 0.000 0.000 0.972 0.000 NA
#> GSM892350 4 0.1285 0.940 0.000 0.000 0.000 0.944 0.004 NA
#> GSM892354 1 0.0458 0.970 0.984 0.000 0.000 0.000 0.000 NA
#> GSM892356 1 0.1007 0.969 0.956 0.000 0.000 0.000 0.000 NA
#> GSM892362 1 0.0547 0.971 0.980 0.000 0.000 0.000 0.000 NA
#> GSM892366 3 0.0405 0.827 0.000 0.000 0.988 0.000 0.008 NA
#> GSM892370 3 0.3774 0.720 0.000 0.000 0.592 0.000 0.000 NA
#> GSM892374 2 0.0458 0.991 0.000 0.984 0.000 0.000 0.000 NA
#> GSM892378 2 0.0363 0.992 0.000 0.988 0.000 0.000 0.000 NA
#> GSM892382 2 0.0260 0.992 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892384 2 0.0146 0.993 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892388 2 0.0146 0.993 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892343 5 0.3208 0.758 0.000 0.000 0.008 0.040 0.832 NA
#> GSM892348 4 0.0632 0.942 0.000 0.000 0.000 0.976 0.000 NA
#> GSM892352 5 0.5105 0.630 0.000 0.000 0.004 0.096 0.600 NA
#> GSM892358 1 0.0260 0.972 0.992 0.000 0.000 0.000 0.000 NA
#> GSM892360 1 0.0632 0.969 0.976 0.000 0.000 0.000 0.000 NA
#> GSM892364 1 0.1141 0.965 0.948 0.000 0.000 0.000 0.000 NA
#> GSM892368 3 0.0260 0.828 0.000 0.000 0.992 0.000 0.008 NA
#> GSM892372 3 0.0547 0.831 0.000 0.000 0.980 0.000 0.000 NA
#> GSM892376 2 0.0458 0.992 0.000 0.984 0.000 0.000 0.000 NA
#> GSM892380 2 0.0146 0.994 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892386 2 0.0146 0.993 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892390 2 0.0146 0.993 0.000 0.996 0.000 0.000 0.000 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> MAD:skmeans 50 1.000 0.934 2.67e-07 1.42e-03 2
#> MAD:skmeans 50 1.000 0.931 1.69e-11 8.93e-05 3
#> MAD:skmeans 49 0.995 0.988 2.28e-17 4.54e-07 4
#> MAD:skmeans 49 0.996 0.982 2.33e-20 7.98e-08 5
#> MAD:skmeans 49 0.996 0.982 2.33e-20 7.98e-08 6
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 31632 rows and 50 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 0.952 0.959 0.981 0.4362 0.794 0.612
#> 4 4 1.000 0.991 0.995 0.1049 0.900 0.704
#> 5 5 1.000 0.966 0.980 0.0372 0.958 0.840
#> 6 6 1.000 0.979 0.991 0.0162 0.988 0.946
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
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.0000 0.989 0.000 0 1.000
#> GSM892345 1 0.3412 0.868 0.876 0 0.124
#> GSM892349 3 0.0000 0.989 0.000 0 1.000
#> GSM892353 1 0.0237 0.948 0.996 0 0.004
#> GSM892355 1 0.0000 0.950 1.000 0 0.000
#> GSM892361 1 0.0000 0.950 1.000 0 0.000
#> GSM892365 3 0.0000 0.989 0.000 0 1.000
#> GSM892369 3 0.0000 0.989 0.000 0 1.000
#> GSM892373 2 0.0000 1.000 0.000 1 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000
#> GSM892344 3 0.0000 0.989 0.000 0 1.000
#> GSM892347 1 0.3412 0.868 0.876 0 0.124
#> GSM892351 1 0.6062 0.431 0.616 0 0.384
#> GSM892357 1 0.0000 0.950 1.000 0 0.000
#> GSM892359 1 0.0000 0.950 1.000 0 0.000
#> GSM892363 1 0.0000 0.950 1.000 0 0.000
#> GSM892367 3 0.0000 0.989 0.000 0 1.000
#> GSM892371 3 0.0000 0.989 0.000 0 1.000
#> GSM892375 2 0.0000 1.000 0.000 1 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000
#> GSM892341 3 0.0000 0.989 0.000 0 1.000
#> GSM892346 1 0.0000 0.950 1.000 0 0.000
#> GSM892350 1 0.3551 0.860 0.868 0 0.132
#> GSM892354 1 0.0000 0.950 1.000 0 0.000
#> GSM892356 1 0.0000 0.950 1.000 0 0.000
#> GSM892362 1 0.0000 0.950 1.000 0 0.000
#> GSM892366 3 0.0000 0.989 0.000 0 1.000
#> GSM892370 3 0.0000 0.989 0.000 0 1.000
#> GSM892374 2 0.0000 1.000 0.000 1 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000
#> GSM892343 3 0.3551 0.833 0.132 0 0.868
#> GSM892348 1 0.2165 0.913 0.936 0 0.064
#> GSM892352 3 0.0000 0.989 0.000 0 1.000
#> GSM892358 1 0.0000 0.950 1.000 0 0.000
#> GSM892360 1 0.0000 0.950 1.000 0 0.000
#> GSM892364 1 0.0000 0.950 1.000 0 0.000
#> GSM892368 3 0.0000 0.989 0.000 0 1.000
#> GSM892372 3 0.0000 0.989 0.000 0 1.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.0000 0.987 0.00 0 1.000 0.000
#> GSM892345 4 0.0000 0.987 0.00 0 0.000 1.000
#> GSM892349 4 0.0000 0.987 0.00 0 0.000 1.000
#> GSM892353 1 0.0000 1.000 1.00 0 0.000 0.000
#> GSM892355 1 0.0000 1.000 1.00 0 0.000 0.000
#> GSM892361 1 0.0000 1.000 1.00 0 0.000 0.000
#> GSM892365 3 0.0000 0.987 0.00 0 1.000 0.000
#> GSM892369 3 0.0000 0.987 0.00 0 1.000 0.000
#> GSM892373 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892344 3 0.2530 0.874 0.00 0 0.888 0.112
#> GSM892347 4 0.0000 0.987 0.00 0 0.000 1.000
#> GSM892351 4 0.0000 0.987 0.00 0 0.000 1.000
#> GSM892357 1 0.0000 1.000 1.00 0 0.000 0.000
#> GSM892359 1 0.0000 1.000 1.00 0 0.000 0.000
#> GSM892363 1 0.0000 1.000 1.00 0 0.000 0.000
#> GSM892367 3 0.0000 0.987 0.00 0 1.000 0.000
#> GSM892371 3 0.0469 0.978 0.00 0 0.988 0.012
#> GSM892375 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892341 3 0.0000 0.987 0.00 0 1.000 0.000
#> GSM892346 4 0.1637 0.935 0.06 0 0.000 0.940
#> GSM892350 4 0.0000 0.987 0.00 0 0.000 1.000
#> GSM892354 1 0.0000 1.000 1.00 0 0.000 0.000
#> GSM892356 1 0.0000 1.000 1.00 0 0.000 0.000
#> GSM892362 1 0.0000 1.000 1.00 0 0.000 0.000
#> GSM892366 3 0.0000 0.987 0.00 0 1.000 0.000
#> GSM892370 3 0.0000 0.987 0.00 0 1.000 0.000
#> GSM892374 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892343 4 0.1302 0.950 0.00 0 0.044 0.956
#> GSM892348 4 0.0000 0.987 0.00 0 0.000 1.000
#> GSM892352 4 0.0000 0.987 0.00 0 0.000 1.000
#> GSM892358 1 0.0000 1.000 1.00 0 0.000 0.000
#> GSM892360 1 0.0000 1.000 1.00 0 0.000 0.000
#> GSM892364 1 0.0000 1.000 1.00 0 0.000 0.000
#> GSM892368 3 0.0000 0.987 0.00 0 1.000 0.000
#> GSM892372 3 0.0000 0.987 0.00 0 1.000 0.000
#> GSM892376 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.00 1 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.00 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 5 0.1608 0.916 0.000 0 0.072 0.000 0.928
#> GSM892345 4 0.0000 0.994 0.000 0 0.000 1.000 0.000
#> GSM892349 5 0.3177 0.785 0.000 0 0.000 0.208 0.792
#> GSM892353 1 0.3636 0.615 0.728 0 0.000 0.000 0.272
#> GSM892355 1 0.0000 0.974 1.000 0 0.000 0.000 0.000
#> GSM892361 1 0.0000 0.974 1.000 0 0.000 0.000 0.000
#> GSM892365 3 0.0162 0.969 0.000 0 0.996 0.000 0.004
#> GSM892369 3 0.1608 0.949 0.000 0 0.928 0.000 0.072
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892344 5 0.1310 0.924 0.000 0 0.024 0.020 0.956
#> GSM892347 4 0.0000 0.994 0.000 0 0.000 1.000 0.000
#> GSM892351 4 0.0000 0.994 0.000 0 0.000 1.000 0.000
#> GSM892357 1 0.0000 0.974 1.000 0 0.000 0.000 0.000
#> GSM892359 1 0.0000 0.974 1.000 0 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.974 1.000 0 0.000 0.000 0.000
#> GSM892367 3 0.0162 0.969 0.000 0 0.996 0.000 0.004
#> GSM892371 3 0.1608 0.949 0.000 0 0.928 0.000 0.072
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892341 5 0.1608 0.916 0.000 0 0.072 0.000 0.928
#> GSM892346 4 0.0609 0.972 0.020 0 0.000 0.980 0.000
#> GSM892350 4 0.0000 0.994 0.000 0 0.000 1.000 0.000
#> GSM892354 1 0.0000 0.974 1.000 0 0.000 0.000 0.000
#> GSM892356 1 0.0000 0.974 1.000 0 0.000 0.000 0.000
#> GSM892362 1 0.0000 0.974 1.000 0 0.000 0.000 0.000
#> GSM892366 3 0.0162 0.969 0.000 0 0.996 0.000 0.004
#> GSM892370 3 0.1608 0.949 0.000 0 0.928 0.000 0.072
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892343 5 0.0510 0.912 0.000 0 0.000 0.016 0.984
#> GSM892348 4 0.0000 0.994 0.000 0 0.000 1.000 0.000
#> GSM892352 5 0.1792 0.905 0.000 0 0.000 0.084 0.916
#> GSM892358 1 0.0000 0.974 1.000 0 0.000 0.000 0.000
#> GSM892360 1 0.0000 0.974 1.000 0 0.000 0.000 0.000
#> GSM892364 1 0.0000 0.974 1.000 0 0.000 0.000 0.000
#> GSM892368 3 0.0162 0.969 0.000 0 0.996 0.000 0.004
#> GSM892372 3 0.0162 0.969 0.000 0 0.996 0.000 0.004
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.0000 0.963 0.000 0 0 0.000 1.000 0
#> GSM892345 4 0.0000 1.000 0.000 0 0 1.000 0.000 0
#> GSM892349 5 0.2340 0.822 0.000 0 0 0.148 0.852 0
#> GSM892353 1 0.3266 0.621 0.728 0 0 0.000 0.272 0
#> GSM892355 1 0.0000 0.973 1.000 0 0 0.000 0.000 0
#> GSM892361 1 0.0000 0.973 1.000 0 0 0.000 0.000 0
#> GSM892365 3 0.0000 1.000 0.000 0 1 0.000 0.000 0
#> GSM892369 6 0.0000 1.000 0.000 0 0 0.000 0.000 1
#> GSM892373 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892377 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892381 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892383 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892387 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892344 5 0.0000 0.963 0.000 0 0 0.000 1.000 0
#> GSM892347 4 0.0000 1.000 0.000 0 0 1.000 0.000 0
#> GSM892351 4 0.0000 1.000 0.000 0 0 1.000 0.000 0
#> GSM892357 1 0.0000 0.973 1.000 0 0 0.000 0.000 0
#> GSM892359 1 0.0000 0.973 1.000 0 0 0.000 0.000 0
#> GSM892363 1 0.0000 0.973 1.000 0 0 0.000 0.000 0
#> GSM892367 3 0.0000 1.000 0.000 0 1 0.000 0.000 0
#> GSM892371 6 0.0000 1.000 0.000 0 0 0.000 0.000 1
#> GSM892375 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892379 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892385 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892389 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892341 5 0.0000 0.963 0.000 0 0 0.000 1.000 0
#> GSM892346 4 0.0000 1.000 0.000 0 0 1.000 0.000 0
#> GSM892350 4 0.0000 1.000 0.000 0 0 1.000 0.000 0
#> GSM892354 1 0.0000 0.973 1.000 0 0 0.000 0.000 0
#> GSM892356 1 0.0000 0.973 1.000 0 0 0.000 0.000 0
#> GSM892362 1 0.0000 0.973 1.000 0 0 0.000 0.000 0
#> GSM892366 3 0.0000 1.000 0.000 0 1 0.000 0.000 0
#> GSM892370 6 0.0000 1.000 0.000 0 0 0.000 0.000 1
#> GSM892374 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892378 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892382 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892384 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892388 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892343 5 0.0000 0.963 0.000 0 0 0.000 1.000 0
#> GSM892348 4 0.0000 1.000 0.000 0 0 1.000 0.000 0
#> GSM892352 5 0.0363 0.957 0.000 0 0 0.012 0.988 0
#> GSM892358 1 0.0000 0.973 1.000 0 0 0.000 0.000 0
#> GSM892360 1 0.0000 0.973 1.000 0 0 0.000 0.000 0
#> GSM892364 1 0.0000 0.973 1.000 0 0 0.000 0.000 0
#> GSM892368 3 0.0000 1.000 0.000 0 1 0.000 0.000 0
#> GSM892372 3 0.0000 1.000 0.000 0 1 0.000 0.000 0
#> GSM892376 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892380 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892386 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
#> GSM892390 2 0.0000 1.000 0.000 1 0 0.000 0.000 0
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> MAD:pam 50 1.000 0.934 2.67e-07 1.42e-03 2
#> MAD:pam 49 0.981 0.952 1.63e-11 6.57e-05 3
#> MAD:pam 50 0.977 0.951 1.45e-16 7.83e-07 4
#> MAD:pam 50 1.000 0.998 3.06e-20 2.01e-07 5
#> MAD:pam 50 0.991 0.984 4.62e-22 7.12e-08 6
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 31632 rows and 50 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 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 1.000 1.000 1.000 0.4158 0.804 0.630
#> 4 4 0.959 0.920 0.966 0.1176 0.922 0.765
#> 5 5 1.000 0.944 0.980 0.0395 0.965 0.864
#> 6 6 0.993 0.984 0.989 0.0272 0.969 0.866
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
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0 1 0 0 1
#> GSM892345 3 0 1 0 0 1
#> GSM892349 3 0 1 0 0 1
#> GSM892353 1 0 1 1 0 0
#> GSM892355 1 0 1 1 0 0
#> GSM892361 1 0 1 1 0 0
#> GSM892365 3 0 1 0 0 1
#> GSM892369 3 0 1 0 0 1
#> GSM892373 2 0 1 0 1 0
#> GSM892377 2 0 1 0 1 0
#> GSM892381 2 0 1 0 1 0
#> GSM892383 2 0 1 0 1 0
#> GSM892387 2 0 1 0 1 0
#> GSM892344 3 0 1 0 0 1
#> GSM892347 3 0 1 0 0 1
#> GSM892351 3 0 1 0 0 1
#> GSM892357 1 0 1 1 0 0
#> GSM892359 1 0 1 1 0 0
#> GSM892363 1 0 1 1 0 0
#> GSM892367 3 0 1 0 0 1
#> GSM892371 3 0 1 0 0 1
#> GSM892375 2 0 1 0 1 0
#> GSM892379 2 0 1 0 1 0
#> GSM892385 2 0 1 0 1 0
#> GSM892389 2 0 1 0 1 0
#> GSM892341 3 0 1 0 0 1
#> GSM892346 3 0 1 0 0 1
#> GSM892350 3 0 1 0 0 1
#> GSM892354 1 0 1 1 0 0
#> GSM892356 1 0 1 1 0 0
#> GSM892362 1 0 1 1 0 0
#> GSM892366 3 0 1 0 0 1
#> GSM892370 3 0 1 0 0 1
#> GSM892374 2 0 1 0 1 0
#> GSM892378 2 0 1 0 1 0
#> GSM892382 2 0 1 0 1 0
#> GSM892384 2 0 1 0 1 0
#> GSM892388 2 0 1 0 1 0
#> GSM892343 3 0 1 0 0 1
#> GSM892348 3 0 1 0 0 1
#> GSM892352 3 0 1 0 0 1
#> GSM892358 1 0 1 1 0 0
#> GSM892360 1 0 1 1 0 0
#> GSM892364 1 0 1 1 0 0
#> GSM892368 3 0 1 0 0 1
#> GSM892372 3 0 1 0 0 1
#> GSM892376 2 0 1 0 1 0
#> GSM892380 2 0 1 0 1 0
#> GSM892386 2 0 1 0 1 0
#> GSM892390 2 0 1 0 1 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.0000 0.873 0 0 1.000 0.000
#> GSM892345 4 0.0000 0.922 0 0 0.000 1.000
#> GSM892349 4 0.2868 0.802 0 0 0.136 0.864
#> GSM892353 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892355 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892361 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892365 3 0.0921 0.865 0 0 0.972 0.028
#> GSM892369 3 0.3837 0.710 0 0 0.776 0.224
#> GSM892373 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892377 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892381 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892383 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892387 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892344 3 0.0000 0.873 0 0 1.000 0.000
#> GSM892347 4 0.0000 0.922 0 0 0.000 1.000
#> GSM892351 4 0.0000 0.922 0 0 0.000 1.000
#> GSM892357 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892359 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892363 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892367 3 0.0469 0.869 0 0 0.988 0.012
#> GSM892371 3 0.4008 0.674 0 0 0.756 0.244
#> GSM892375 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892379 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892385 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892389 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892341 3 0.0000 0.873 0 0 1.000 0.000
#> GSM892346 4 0.0000 0.922 0 0 0.000 1.000
#> GSM892350 4 0.0000 0.922 0 0 0.000 1.000
#> GSM892354 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892356 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892362 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892366 3 0.0188 0.873 0 0 0.996 0.004
#> GSM892370 3 0.4941 0.268 0 0 0.564 0.436
#> GSM892374 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892378 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892382 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892384 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892388 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892343 3 0.4193 0.605 0 0 0.732 0.268
#> GSM892348 4 0.0000 0.922 0 0 0.000 1.000
#> GSM892352 4 0.4564 0.441 0 0 0.328 0.672
#> GSM892358 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892360 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892364 1 0.0000 1.000 1 0 0.000 0.000
#> GSM892368 3 0.0000 0.873 0 0 1.000 0.000
#> GSM892372 3 0.0592 0.870 0 0 0.984 0.016
#> GSM892376 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892380 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892386 2 0.0000 1.000 0 1 0.000 0.000
#> GSM892390 2 0.0000 1.000 0 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 3 0.0000 0.935 0.000 0 1.000 0.000 0.000
#> GSM892345 4 0.0000 0.914 0.000 0 0.000 1.000 0.000
#> GSM892349 4 0.4306 0.029 0.000 0 0.000 0.508 0.492
#> GSM892353 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892355 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892361 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892365 3 0.0000 0.935 0.000 0 1.000 0.000 0.000
#> GSM892369 5 0.0000 0.987 0.000 0 0.000 0.000 1.000
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892344 3 0.4249 0.244 0.000 0 0.568 0.000 0.432
#> GSM892347 4 0.0000 0.914 0.000 0 0.000 1.000 0.000
#> GSM892351 4 0.0000 0.914 0.000 0 0.000 1.000 0.000
#> GSM892357 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892359 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892367 3 0.0162 0.932 0.000 0 0.996 0.004 0.000
#> GSM892371 5 0.0162 0.987 0.000 0 0.000 0.004 0.996
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892341 3 0.0000 0.935 0.000 0 1.000 0.000 0.000
#> GSM892346 4 0.0000 0.914 0.000 0 0.000 1.000 0.000
#> GSM892350 4 0.0000 0.914 0.000 0 0.000 1.000 0.000
#> GSM892354 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892356 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892362 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892366 3 0.0000 0.935 0.000 0 1.000 0.000 0.000
#> GSM892370 5 0.0510 0.980 0.000 0 0.000 0.016 0.984
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892343 5 0.0794 0.971 0.000 0 0.000 0.028 0.972
#> GSM892348 4 0.0000 0.914 0.000 0 0.000 1.000 0.000
#> GSM892352 5 0.0000 0.987 0.000 0 0.000 0.000 1.000
#> GSM892358 1 0.0162 0.996 0.996 0 0.000 0.000 0.004
#> GSM892360 1 0.0000 0.999 1.000 0 0.000 0.000 0.000
#> GSM892364 1 0.0162 0.996 0.996 0 0.000 0.000 0.004
#> GSM892368 3 0.0000 0.935 0.000 0 1.000 0.000 0.000
#> GSM892372 3 0.0162 0.932 0.000 0 0.996 0.004 0.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 3 0.0000 0.983 0.000 0 1.000 0.000 0.000 0.000
#> GSM892345 4 0.0000 0.998 0.000 0 0.000 1.000 0.000 0.000
#> GSM892349 5 0.1082 0.955 0.000 0 0.000 0.040 0.956 0.004
#> GSM892353 6 0.0865 0.929 0.036 0 0.000 0.000 0.000 0.964
#> GSM892355 6 0.1663 0.950 0.088 0 0.000 0.000 0.000 0.912
#> GSM892361 1 0.0000 0.987 1.000 0 0.000 0.000 0.000 0.000
#> GSM892365 3 0.0000 0.983 0.000 0 1.000 0.000 0.000 0.000
#> GSM892369 5 0.0000 0.984 0.000 0 0.000 0.000 1.000 0.000
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892344 3 0.1863 0.878 0.000 0 0.896 0.000 0.104 0.000
#> GSM892347 4 0.0000 0.998 0.000 0 0.000 1.000 0.000 0.000
#> GSM892351 4 0.0000 0.998 0.000 0 0.000 1.000 0.000 0.000
#> GSM892357 1 0.0000 0.987 1.000 0 0.000 0.000 0.000 0.000
#> GSM892359 1 0.0260 0.983 0.992 0 0.000 0.000 0.000 0.008
#> GSM892363 1 0.0000 0.987 1.000 0 0.000 0.000 0.000 0.000
#> GSM892367 3 0.0146 0.980 0.000 0 0.996 0.004 0.000 0.000
#> GSM892371 5 0.0000 0.984 0.000 0 0.000 0.000 1.000 0.000
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892341 3 0.0000 0.983 0.000 0 1.000 0.000 0.000 0.000
#> GSM892346 4 0.0260 0.993 0.000 0 0.000 0.992 0.000 0.008
#> GSM892350 4 0.0000 0.998 0.000 0 0.000 1.000 0.000 0.000
#> GSM892354 1 0.0146 0.985 0.996 0 0.000 0.000 0.000 0.004
#> GSM892356 1 0.0000 0.987 1.000 0 0.000 0.000 0.000 0.000
#> GSM892362 1 0.0000 0.987 1.000 0 0.000 0.000 0.000 0.000
#> GSM892366 3 0.0000 0.983 0.000 0 1.000 0.000 0.000 0.000
#> GSM892370 5 0.0363 0.980 0.000 0 0.000 0.012 0.988 0.000
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892343 5 0.0458 0.978 0.000 0 0.000 0.016 0.984 0.000
#> GSM892348 4 0.0146 0.996 0.000 0 0.000 0.996 0.000 0.004
#> GSM892352 5 0.0000 0.984 0.000 0 0.000 0.000 1.000 0.000
#> GSM892358 6 0.2003 0.935 0.116 0 0.000 0.000 0.000 0.884
#> GSM892360 1 0.0000 0.987 1.000 0 0.000 0.000 0.000 0.000
#> GSM892364 1 0.1663 0.910 0.912 0 0.000 0.000 0.000 0.088
#> GSM892368 3 0.0000 0.983 0.000 0 1.000 0.000 0.000 0.000
#> GSM892372 3 0.0000 0.983 0.000 0 1.000 0.000 0.000 0.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> MAD:mclust 50 1.000 0.934 2.67e-07 1.42e-03 2
#> MAD:mclust 50 1.000 0.931 1.26e-12 1.60e-05 3
#> MAD:mclust 48 0.985 0.946 7.68e-17 1.01e-06 4
#> MAD:mclust 48 0.992 0.975 8.94e-16 1.54e-06 5
#> MAD:mclust 50 0.994 0.989 5.92e-15 1.19e-04 6
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 31632 rows and 50 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 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 0.966 0.972 0.974 0.4151 0.794 0.612
#> 4 4 1.000 0.975 0.981 0.1144 0.912 0.736
#> 5 5 0.960 0.944 0.952 0.0360 0.958 0.838
#> 6 6 0.973 0.934 0.951 0.0107 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] 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
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.1529 0.959 0.040 0.000 0.960
#> GSM892345 1 0.0237 0.985 0.996 0.000 0.004
#> GSM892349 3 0.4555 0.834 0.200 0.000 0.800
#> GSM892353 1 0.0000 0.988 1.000 0.000 0.000
#> GSM892355 1 0.0000 0.988 1.000 0.000 0.000
#> GSM892361 1 0.0000 0.988 1.000 0.000 0.000
#> GSM892365 3 0.1529 0.959 0.040 0.000 0.960
#> GSM892369 3 0.1753 0.959 0.048 0.000 0.952
#> GSM892373 2 0.0000 0.997 0.000 1.000 0.000
#> GSM892377 2 0.0000 0.997 0.000 1.000 0.000
#> GSM892381 2 0.0000 0.997 0.000 1.000 0.000
#> GSM892383 2 0.0000 0.997 0.000 1.000 0.000
#> GSM892387 2 0.0747 0.989 0.000 0.984 0.016
#> GSM892344 3 0.2165 0.951 0.064 0.000 0.936
#> GSM892347 1 0.0592 0.979 0.988 0.000 0.012
#> GSM892351 1 0.3116 0.873 0.892 0.000 0.108
#> GSM892357 1 0.0000 0.988 1.000 0.000 0.000
#> GSM892359 1 0.0000 0.988 1.000 0.000 0.000
#> GSM892363 1 0.0000 0.988 1.000 0.000 0.000
#> GSM892367 3 0.1529 0.959 0.040 0.000 0.960
#> GSM892371 3 0.1753 0.959 0.048 0.000 0.952
#> GSM892375 2 0.0424 0.994 0.000 0.992 0.008
#> GSM892379 2 0.0000 0.997 0.000 1.000 0.000
#> GSM892385 2 0.0424 0.994 0.000 0.992 0.008
#> GSM892389 2 0.0000 0.997 0.000 1.000 0.000
#> GSM892341 3 0.1860 0.958 0.052 0.000 0.948
#> GSM892346 1 0.0000 0.988 1.000 0.000 0.000
#> GSM892350 1 0.2066 0.931 0.940 0.000 0.060
#> GSM892354 1 0.0000 0.988 1.000 0.000 0.000
#> GSM892356 1 0.0000 0.988 1.000 0.000 0.000
#> GSM892362 1 0.0000 0.988 1.000 0.000 0.000
#> GSM892366 3 0.1529 0.959 0.040 0.000 0.960
#> GSM892370 3 0.1643 0.959 0.044 0.000 0.956
#> GSM892374 2 0.0000 0.997 0.000 1.000 0.000
#> GSM892378 2 0.0000 0.997 0.000 1.000 0.000
#> GSM892382 2 0.0000 0.997 0.000 1.000 0.000
#> GSM892384 2 0.0000 0.997 0.000 1.000 0.000
#> GSM892388 2 0.0592 0.992 0.000 0.988 0.012
#> GSM892343 3 0.4291 0.857 0.180 0.000 0.820
#> GSM892348 1 0.0000 0.988 1.000 0.000 0.000
#> GSM892352 3 0.4399 0.849 0.188 0.000 0.812
#> GSM892358 1 0.0000 0.988 1.000 0.000 0.000
#> GSM892360 1 0.0000 0.988 1.000 0.000 0.000
#> GSM892364 1 0.0000 0.988 1.000 0.000 0.000
#> GSM892368 3 0.1529 0.959 0.040 0.000 0.960
#> GSM892372 3 0.1529 0.959 0.040 0.000 0.960
#> GSM892376 2 0.0000 0.997 0.000 1.000 0.000
#> GSM892380 2 0.0747 0.989 0.000 0.984 0.016
#> GSM892386 2 0.0237 0.996 0.000 0.996 0.004
#> GSM892390 2 0.0424 0.994 0.000 0.992 0.008
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.0895 0.956 0.004 0.000 0.976 0.020
#> GSM892345 4 0.1724 0.979 0.020 0.000 0.032 0.948
#> GSM892349 4 0.2125 0.943 0.004 0.000 0.076 0.920
#> GSM892353 1 0.0336 0.990 0.992 0.000 0.000 0.008
#> GSM892355 1 0.0000 0.997 1.000 0.000 0.000 0.000
#> GSM892361 1 0.0336 0.993 0.992 0.000 0.000 0.008
#> GSM892365 3 0.0000 0.962 0.000 0.000 1.000 0.000
#> GSM892369 3 0.0336 0.960 0.000 0.000 0.992 0.008
#> GSM892373 2 0.0188 0.997 0.000 0.996 0.000 0.004
#> GSM892377 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892381 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892383 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892387 2 0.0336 0.994 0.000 0.992 0.000 0.008
#> GSM892344 3 0.1042 0.954 0.008 0.000 0.972 0.020
#> GSM892347 4 0.1724 0.979 0.020 0.000 0.032 0.948
#> GSM892351 4 0.1610 0.978 0.016 0.000 0.032 0.952
#> GSM892357 1 0.0000 0.997 1.000 0.000 0.000 0.000
#> GSM892359 1 0.0000 0.997 1.000 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.997 1.000 0.000 0.000 0.000
#> GSM892367 3 0.0000 0.962 0.000 0.000 1.000 0.000
#> GSM892371 3 0.0469 0.960 0.000 0.000 0.988 0.012
#> GSM892375 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892379 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892385 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892389 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892341 3 0.0895 0.956 0.004 0.000 0.976 0.020
#> GSM892346 4 0.1510 0.965 0.028 0.000 0.016 0.956
#> GSM892350 4 0.1724 0.979 0.020 0.000 0.032 0.948
#> GSM892354 1 0.0188 0.996 0.996 0.000 0.000 0.004
#> GSM892356 1 0.0000 0.997 1.000 0.000 0.000 0.000
#> GSM892362 1 0.0188 0.996 0.996 0.000 0.000 0.004
#> GSM892366 3 0.0000 0.962 0.000 0.000 1.000 0.000
#> GSM892370 3 0.0592 0.957 0.000 0.000 0.984 0.016
#> GSM892374 2 0.0188 0.997 0.000 0.996 0.000 0.004
#> GSM892378 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892382 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892384 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892388 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892343 3 0.4844 0.547 0.012 0.000 0.688 0.300
#> GSM892348 4 0.1624 0.977 0.020 0.000 0.028 0.952
#> GSM892352 4 0.2053 0.947 0.004 0.000 0.072 0.924
#> GSM892358 1 0.0000 0.997 1.000 0.000 0.000 0.000
#> GSM892360 1 0.0188 0.996 0.996 0.000 0.000 0.004
#> GSM892364 1 0.0188 0.996 0.996 0.000 0.000 0.004
#> GSM892368 3 0.0000 0.962 0.000 0.000 1.000 0.000
#> GSM892372 3 0.0000 0.962 0.000 0.000 1.000 0.000
#> GSM892376 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892380 2 0.0336 0.994 0.000 0.992 0.000 0.008
#> GSM892386 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM892390 2 0.0000 0.999 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 5 0.3715 0.747 0.000 0.000 0.260 0.004 0.736
#> GSM892345 4 0.1851 0.910 0.000 0.000 0.000 0.912 0.088
#> GSM892349 5 0.4206 0.616 0.000 0.000 0.016 0.288 0.696
#> GSM892353 1 0.1043 0.963 0.960 0.000 0.000 0.000 0.040
#> GSM892355 1 0.0162 0.993 0.996 0.000 0.000 0.000 0.004
#> GSM892361 1 0.0162 0.993 0.996 0.000 0.000 0.004 0.000
#> GSM892365 3 0.0794 0.962 0.000 0.000 0.972 0.000 0.028
#> GSM892369 3 0.1300 0.948 0.000 0.000 0.956 0.016 0.028
#> GSM892373 2 0.0794 0.984 0.000 0.972 0.000 0.000 0.028
#> GSM892377 2 0.0510 0.990 0.000 0.984 0.000 0.000 0.016
#> GSM892381 2 0.0000 0.994 0.000 1.000 0.000 0.000 0.000
#> GSM892383 2 0.0162 0.994 0.000 0.996 0.000 0.000 0.004
#> GSM892387 2 0.0290 0.992 0.000 0.992 0.000 0.000 0.008
#> GSM892344 5 0.3803 0.808 0.000 0.000 0.140 0.056 0.804
#> GSM892347 4 0.1043 0.919 0.000 0.000 0.000 0.960 0.040
#> GSM892351 4 0.2966 0.803 0.000 0.000 0.000 0.816 0.184
#> GSM892357 1 0.0000 0.995 1.000 0.000 0.000 0.000 0.000
#> GSM892359 1 0.0000 0.995 1.000 0.000 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.995 1.000 0.000 0.000 0.000 0.000
#> GSM892367 3 0.0162 0.966 0.000 0.000 0.996 0.000 0.004
#> GSM892371 3 0.0898 0.958 0.000 0.000 0.972 0.008 0.020
#> GSM892375 2 0.0404 0.991 0.000 0.988 0.000 0.000 0.012
#> GSM892379 2 0.0162 0.994 0.000 0.996 0.000 0.000 0.004
#> GSM892385 2 0.0162 0.994 0.000 0.996 0.000 0.000 0.004
#> GSM892389 2 0.0162 0.994 0.000 0.996 0.000 0.000 0.004
#> GSM892341 5 0.4169 0.782 0.000 0.000 0.240 0.028 0.732
#> GSM892346 4 0.1197 0.866 0.000 0.000 0.000 0.952 0.048
#> GSM892350 4 0.1608 0.917 0.000 0.000 0.000 0.928 0.072
#> GSM892354 1 0.0000 0.995 1.000 0.000 0.000 0.000 0.000
#> GSM892356 1 0.0162 0.994 0.996 0.000 0.000 0.000 0.004
#> GSM892362 1 0.0162 0.994 0.996 0.000 0.000 0.000 0.004
#> GSM892366 3 0.1043 0.954 0.000 0.000 0.960 0.000 0.040
#> GSM892370 3 0.0992 0.956 0.000 0.000 0.968 0.008 0.024
#> GSM892374 2 0.0794 0.984 0.000 0.972 0.000 0.000 0.028
#> GSM892378 2 0.0290 0.992 0.000 0.992 0.000 0.000 0.008
#> GSM892382 2 0.0000 0.994 0.000 1.000 0.000 0.000 0.000
#> GSM892384 2 0.0000 0.994 0.000 1.000 0.000 0.000 0.000
#> GSM892388 2 0.0510 0.989 0.000 0.984 0.000 0.000 0.016
#> GSM892343 5 0.5344 0.784 0.000 0.000 0.168 0.160 0.672
#> GSM892348 4 0.0290 0.908 0.000 0.000 0.000 0.992 0.008
#> GSM892352 5 0.3929 0.714 0.000 0.000 0.028 0.208 0.764
#> GSM892358 1 0.0000 0.995 1.000 0.000 0.000 0.000 0.000
#> GSM892360 1 0.0000 0.995 1.000 0.000 0.000 0.000 0.000
#> GSM892364 1 0.0162 0.994 0.996 0.000 0.000 0.000 0.004
#> GSM892368 3 0.0880 0.960 0.000 0.000 0.968 0.000 0.032
#> GSM892372 3 0.0404 0.966 0.000 0.000 0.988 0.000 0.012
#> GSM892376 2 0.0290 0.993 0.000 0.992 0.000 0.000 0.008
#> GSM892380 2 0.0000 0.994 0.000 1.000 0.000 0.000 0.000
#> GSM892386 2 0.0000 0.994 0.000 1.000 0.000 0.000 0.000
#> GSM892390 2 0.0000 0.994 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.1901 0.788 0.000 0.000 0.076 0.004 0.912 NA
#> GSM892345 4 0.1970 0.904 0.000 0.000 0.000 0.912 0.060 NA
#> GSM892349 5 0.3728 0.568 0.000 0.000 0.000 0.344 0.652 NA
#> GSM892353 1 0.1555 0.933 0.932 0.000 0.004 0.000 0.060 NA
#> GSM892355 1 0.0146 0.991 0.996 0.000 0.000 0.000 0.000 NA
#> GSM892361 1 0.0146 0.991 0.996 0.000 0.000 0.000 0.000 NA
#> GSM892365 3 0.0937 0.970 0.000 0.000 0.960 0.000 0.040 NA
#> GSM892369 3 0.0891 0.960 0.000 0.000 0.968 0.008 0.000 NA
#> GSM892373 2 0.1714 0.940 0.000 0.908 0.000 0.000 0.000 NA
#> GSM892377 2 0.1007 0.971 0.000 0.956 0.000 0.000 0.000 NA
#> GSM892381 2 0.0260 0.980 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892383 2 0.0260 0.979 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892387 2 0.0363 0.979 0.000 0.988 0.000 0.000 0.000 NA
#> GSM892344 5 0.1901 0.807 0.000 0.000 0.028 0.040 0.924 NA
#> GSM892347 4 0.0806 0.906 0.000 0.000 0.000 0.972 0.020 NA
#> GSM892351 4 0.2730 0.785 0.000 0.000 0.000 0.836 0.152 NA
#> GSM892357 1 0.0000 0.993 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892359 1 0.0000 0.993 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892363 1 0.0000 0.993 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892367 3 0.0508 0.973 0.000 0.000 0.984 0.000 0.012 NA
#> GSM892371 3 0.0622 0.966 0.000 0.000 0.980 0.008 0.000 NA
#> GSM892375 2 0.0937 0.973 0.000 0.960 0.000 0.000 0.000 NA
#> GSM892379 2 0.0713 0.976 0.000 0.972 0.000 0.000 0.000 NA
#> GSM892385 2 0.0458 0.979 0.000 0.984 0.000 0.000 0.000 NA
#> GSM892389 2 0.0260 0.980 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892341 5 0.2006 0.801 0.000 0.000 0.080 0.016 0.904 NA
#> GSM892346 4 0.2135 0.830 0.000 0.000 0.000 0.872 0.000 NA
#> GSM892350 4 0.1398 0.904 0.000 0.000 0.000 0.940 0.052 NA
#> GSM892354 1 0.0146 0.991 0.996 0.000 0.000 0.000 0.000 NA
#> GSM892356 1 0.0000 0.993 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892362 1 0.0000 0.993 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892366 3 0.1075 0.964 0.000 0.000 0.952 0.000 0.048 NA
#> GSM892370 3 0.0508 0.968 0.000 0.000 0.984 0.004 0.000 NA
#> GSM892374 2 0.1908 0.934 0.000 0.900 0.000 0.000 0.004 NA
#> GSM892378 2 0.0458 0.979 0.000 0.984 0.000 0.000 0.000 NA
#> GSM892382 2 0.0146 0.980 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892384 2 0.0260 0.980 0.000 0.992 0.000 0.000 0.000 NA
#> GSM892388 2 0.1387 0.955 0.000 0.932 0.000 0.000 0.000 NA
#> GSM892343 5 0.3584 0.796 0.004 0.000 0.060 0.104 0.820 NA
#> GSM892348 4 0.1196 0.896 0.000 0.000 0.000 0.952 0.008 NA
#> GSM892352 5 0.4058 0.618 0.000 0.000 0.004 0.320 0.660 NA
#> GSM892358 1 0.0000 0.993 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892360 1 0.0000 0.993 1.000 0.000 0.000 0.000 0.000 NA
#> GSM892364 1 0.0260 0.988 0.992 0.000 0.000 0.000 0.000 NA
#> GSM892368 3 0.0865 0.972 0.000 0.000 0.964 0.000 0.036 NA
#> GSM892372 3 0.0713 0.973 0.000 0.000 0.972 0.000 0.028 NA
#> GSM892376 2 0.0363 0.979 0.000 0.988 0.000 0.000 0.000 NA
#> GSM892380 2 0.0146 0.979 0.000 0.996 0.000 0.000 0.000 NA
#> GSM892386 2 0.0363 0.979 0.000 0.988 0.000 0.000 0.000 NA
#> GSM892390 2 0.0000 0.980 0.000 1.000 0.000 0.000 0.000 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> MAD:NMF 50 1 0.934 2.67e-07 1.42e-03 2
#> MAD:NMF 50 1 0.931 1.69e-11 8.93e-05 3
#> MAD:NMF 50 1 0.986 6.71e-18 2.02e-07 4
#> MAD:NMF 50 1 0.998 3.06e-20 2.01e-07 5
#> MAD:NMF 50 1 0.998 3.06e-20 2.01e-07 6
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 31632 rows and 50 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 0.846 0.908 0.950 0.3783 0.804 0.630
#> 4 4 0.815 0.874 0.929 0.0799 0.974 0.922
#> 5 5 0.863 0.796 0.866 0.0717 0.922 0.745
#> 6 6 0.918 0.833 0.914 0.0588 0.949 0.780
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.597 0.601 0.364 0 0.636
#> GSM892345 1 0.288 0.886 0.904 0 0.096
#> GSM892349 1 0.304 0.877 0.896 0 0.104
#> GSM892353 1 0.000 0.954 1.000 0 0.000
#> GSM892355 1 0.000 0.954 1.000 0 0.000
#> GSM892361 1 0.000 0.954 1.000 0 0.000
#> GSM892365 3 0.000 0.816 0.000 0 1.000
#> GSM892369 3 0.304 0.822 0.104 0 0.896
#> GSM892373 2 0.000 1.000 0.000 1 0.000
#> GSM892377 2 0.000 1.000 0.000 1 0.000
#> GSM892381 2 0.000 1.000 0.000 1 0.000
#> GSM892383 2 0.000 1.000 0.000 1 0.000
#> GSM892387 2 0.000 1.000 0.000 1 0.000
#> GSM892344 3 0.599 0.596 0.368 0 0.632
#> GSM892347 1 0.196 0.918 0.944 0 0.056
#> GSM892351 1 0.288 0.886 0.904 0 0.096
#> GSM892357 1 0.000 0.954 1.000 0 0.000
#> GSM892359 1 0.000 0.954 1.000 0 0.000
#> GSM892363 1 0.000 0.954 1.000 0 0.000
#> GSM892367 3 0.000 0.816 0.000 0 1.000
#> GSM892371 3 0.304 0.822 0.104 0 0.896
#> GSM892375 2 0.000 1.000 0.000 1 0.000
#> GSM892379 2 0.000 1.000 0.000 1 0.000
#> GSM892385 2 0.000 1.000 0.000 1 0.000
#> GSM892389 2 0.000 1.000 0.000 1 0.000
#> GSM892341 3 0.597 0.601 0.364 0 0.636
#> GSM892346 1 0.000 0.954 1.000 0 0.000
#> GSM892350 1 0.288 0.886 0.904 0 0.096
#> GSM892354 1 0.000 0.954 1.000 0 0.000
#> GSM892356 1 0.000 0.954 1.000 0 0.000
#> GSM892362 1 0.000 0.954 1.000 0 0.000
#> GSM892366 3 0.000 0.816 0.000 0 1.000
#> GSM892370 3 0.304 0.822 0.104 0 0.896
#> GSM892374 2 0.000 1.000 0.000 1 0.000
#> GSM892378 2 0.000 1.000 0.000 1 0.000
#> GSM892382 2 0.000 1.000 0.000 1 0.000
#> GSM892384 2 0.000 1.000 0.000 1 0.000
#> GSM892388 2 0.000 1.000 0.000 1 0.000
#> GSM892343 3 0.599 0.596 0.368 0 0.632
#> GSM892348 1 0.000 0.954 1.000 0 0.000
#> GSM892352 1 0.510 0.627 0.752 0 0.248
#> GSM892358 1 0.000 0.954 1.000 0 0.000
#> GSM892360 1 0.000 0.954 1.000 0 0.000
#> GSM892364 1 0.000 0.954 1.000 0 0.000
#> GSM892368 3 0.000 0.816 0.000 0 1.000
#> GSM892372 3 0.103 0.821 0.024 0 0.976
#> GSM892376 2 0.000 1.000 0.000 1 0.000
#> GSM892380 2 0.000 1.000 0.000 1 0.000
#> GSM892386 2 0.000 1.000 0.000 1 0.000
#> GSM892390 2 0.000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 4 0.289 0.996 0.124 0.000 0.004 0.872
#> GSM892345 1 0.401 0.666 0.756 0.000 0.000 0.244
#> GSM892349 1 0.422 0.625 0.728 0.000 0.000 0.272
#> GSM892353 1 0.000 0.896 1.000 0.000 0.000 0.000
#> GSM892355 1 0.000 0.896 1.000 0.000 0.000 0.000
#> GSM892361 1 0.000 0.896 1.000 0.000 0.000 0.000
#> GSM892365 3 0.000 0.820 0.000 0.000 1.000 0.000
#> GSM892369 3 0.445 0.716 0.000 0.000 0.692 0.308
#> GSM892373 2 0.270 0.896 0.000 0.876 0.000 0.124
#> GSM892377 2 0.000 0.981 0.000 1.000 0.000 0.000
#> GSM892381 2 0.000 0.981 0.000 1.000 0.000 0.000
#> GSM892383 2 0.000 0.981 0.000 1.000 0.000 0.000
#> GSM892387 2 0.000 0.981 0.000 1.000 0.000 0.000
#> GSM892344 4 0.270 0.996 0.124 0.000 0.000 0.876
#> GSM892347 1 0.228 0.823 0.904 0.000 0.000 0.096
#> GSM892351 1 0.416 0.639 0.736 0.000 0.000 0.264
#> GSM892357 1 0.000 0.896 1.000 0.000 0.000 0.000
#> GSM892359 1 0.000 0.896 1.000 0.000 0.000 0.000
#> GSM892363 1 0.000 0.896 1.000 0.000 0.000 0.000
#> GSM892367 3 0.000 0.820 0.000 0.000 1.000 0.000
#> GSM892371 3 0.445 0.716 0.000 0.000 0.692 0.308
#> GSM892375 2 0.000 0.981 0.000 1.000 0.000 0.000
#> GSM892379 2 0.000 0.981 0.000 1.000 0.000 0.000
#> GSM892385 2 0.000 0.981 0.000 1.000 0.000 0.000
#> GSM892389 2 0.000 0.981 0.000 1.000 0.000 0.000
#> GSM892341 4 0.289 0.996 0.124 0.000 0.004 0.872
#> GSM892346 1 0.000 0.896 1.000 0.000 0.000 0.000
#> GSM892350 1 0.416 0.639 0.736 0.000 0.000 0.264
#> GSM892354 1 0.000 0.896 1.000 0.000 0.000 0.000
#> GSM892356 1 0.000 0.896 1.000 0.000 0.000 0.000
#> GSM892362 1 0.000 0.896 1.000 0.000 0.000 0.000
#> GSM892366 3 0.000 0.820 0.000 0.000 1.000 0.000
#> GSM892370 3 0.445 0.716 0.000 0.000 0.692 0.308
#> GSM892374 2 0.270 0.896 0.000 0.876 0.000 0.124
#> GSM892378 2 0.000 0.981 0.000 1.000 0.000 0.000
#> GSM892382 2 0.000 0.981 0.000 1.000 0.000 0.000
#> GSM892384 2 0.000 0.981 0.000 1.000 0.000 0.000
#> GSM892388 2 0.270 0.896 0.000 0.876 0.000 0.124
#> GSM892343 4 0.270 0.996 0.124 0.000 0.000 0.876
#> GSM892348 1 0.000 0.896 1.000 0.000 0.000 0.000
#> GSM892352 1 0.497 0.151 0.548 0.000 0.000 0.452
#> GSM892358 1 0.000 0.896 1.000 0.000 0.000 0.000
#> GSM892360 1 0.000 0.896 1.000 0.000 0.000 0.000
#> GSM892364 1 0.000 0.896 1.000 0.000 0.000 0.000
#> GSM892368 3 0.000 0.820 0.000 0.000 1.000 0.000
#> GSM892372 3 0.327 0.790 0.000 0.000 0.832 0.168
#> GSM892376 2 0.000 0.981 0.000 1.000 0.000 0.000
#> GSM892380 2 0.000 0.981 0.000 1.000 0.000 0.000
#> GSM892386 2 0.000 0.981 0.000 1.000 0.000 0.000
#> GSM892390 2 0.000 0.981 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 5 0.0162 0.996 0.000 0.0 0.004 0.000 0.996
#> GSM892345 4 0.0963 0.610 0.036 0.0 0.000 0.964 0.000
#> GSM892349 4 0.0290 0.628 0.000 0.0 0.000 0.992 0.008
#> GSM892353 1 0.4182 1.000 0.600 0.0 0.000 0.400 0.000
#> GSM892355 1 0.4182 1.000 0.600 0.0 0.000 0.400 0.000
#> GSM892361 1 0.4182 1.000 0.600 0.0 0.000 0.400 0.000
#> GSM892365 3 0.0000 0.826 0.000 0.0 1.000 0.000 0.000
#> GSM892369 3 0.3969 0.730 0.000 0.0 0.692 0.004 0.304
#> GSM892373 2 0.4182 0.581 0.400 0.6 0.000 0.000 0.000
#> GSM892377 2 0.0000 0.934 0.000 1.0 0.000 0.000 0.000
#> GSM892381 2 0.0000 0.934 0.000 1.0 0.000 0.000 0.000
#> GSM892383 2 0.0000 0.934 0.000 1.0 0.000 0.000 0.000
#> GSM892387 2 0.0000 0.934 0.000 1.0 0.000 0.000 0.000
#> GSM892344 5 0.0162 0.996 0.000 0.0 0.000 0.004 0.996
#> GSM892347 4 0.3508 0.207 0.252 0.0 0.000 0.748 0.000
#> GSM892351 4 0.0000 0.630 0.000 0.0 0.000 1.000 0.000
#> GSM892357 1 0.4182 1.000 0.600 0.0 0.000 0.400 0.000
#> GSM892359 1 0.4182 1.000 0.600 0.0 0.000 0.400 0.000
#> GSM892363 1 0.4182 1.000 0.600 0.0 0.000 0.400 0.000
#> GSM892367 3 0.0000 0.826 0.000 0.0 1.000 0.000 0.000
#> GSM892371 3 0.3969 0.730 0.000 0.0 0.692 0.004 0.304
#> GSM892375 2 0.0000 0.934 0.000 1.0 0.000 0.000 0.000
#> GSM892379 2 0.0000 0.934 0.000 1.0 0.000 0.000 0.000
#> GSM892385 2 0.0000 0.934 0.000 1.0 0.000 0.000 0.000
#> GSM892389 2 0.0000 0.934 0.000 1.0 0.000 0.000 0.000
#> GSM892341 5 0.0162 0.996 0.000 0.0 0.004 0.000 0.996
#> GSM892346 4 0.4425 -0.600 0.452 0.0 0.000 0.544 0.004
#> GSM892350 4 0.0000 0.630 0.000 0.0 0.000 1.000 0.000
#> GSM892354 1 0.4182 1.000 0.600 0.0 0.000 0.400 0.000
#> GSM892356 1 0.4182 1.000 0.600 0.0 0.000 0.400 0.000
#> GSM892362 1 0.4182 1.000 0.600 0.0 0.000 0.400 0.000
#> GSM892366 3 0.0000 0.826 0.000 0.0 1.000 0.000 0.000
#> GSM892370 3 0.3969 0.730 0.000 0.0 0.692 0.004 0.304
#> GSM892374 2 0.4182 0.581 0.400 0.6 0.000 0.000 0.000
#> GSM892378 2 0.0000 0.934 0.000 1.0 0.000 0.000 0.000
#> GSM892382 2 0.0000 0.934 0.000 1.0 0.000 0.000 0.000
#> GSM892384 2 0.0000 0.934 0.000 1.0 0.000 0.000 0.000
#> GSM892388 2 0.4182 0.581 0.400 0.6 0.000 0.000 0.000
#> GSM892343 5 0.0162 0.996 0.000 0.0 0.000 0.004 0.996
#> GSM892348 4 0.4425 -0.600 0.452 0.0 0.000 0.544 0.004
#> GSM892352 4 0.3534 0.250 0.000 0.0 0.000 0.744 0.256
#> GSM892358 1 0.4182 1.000 0.600 0.0 0.000 0.400 0.000
#> GSM892360 1 0.4182 1.000 0.600 0.0 0.000 0.400 0.000
#> GSM892364 1 0.4182 1.000 0.600 0.0 0.000 0.400 0.000
#> GSM892368 3 0.0000 0.826 0.000 0.0 1.000 0.000 0.000
#> GSM892372 3 0.2813 0.799 0.000 0.0 0.832 0.000 0.168
#> GSM892376 2 0.0000 0.934 0.000 1.0 0.000 0.000 0.000
#> GSM892380 2 0.0000 0.934 0.000 1.0 0.000 0.000 0.000
#> GSM892386 2 0.0000 0.934 0.000 1.0 0.000 0.000 0.000
#> GSM892390 2 0.0000 0.934 0.000 1.0 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.0405 0.992 0.000 0.000 0.004 0.000 0.988 0.008
#> GSM892345 4 0.1408 0.833 0.020 0.000 0.000 0.944 0.000 0.036
#> GSM892349 4 0.0405 0.851 0.004 0.000 0.000 0.988 0.000 0.008
#> GSM892353 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892355 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892361 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892365 3 0.0000 0.827 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM892369 3 0.3446 0.732 0.000 0.000 0.692 0.000 0.308 0.000
#> GSM892373 6 0.3868 0.256 0.000 0.492 0.000 0.000 0.000 0.508
#> GSM892377 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892344 5 0.0260 0.992 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM892347 4 0.4060 0.590 0.032 0.000 0.000 0.684 0.000 0.284
#> GSM892351 4 0.0146 0.853 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM892357 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892359 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892363 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892367 3 0.0000 0.827 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM892371 3 0.3446 0.732 0.000 0.000 0.692 0.000 0.308 0.000
#> GSM892375 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892341 5 0.0146 0.992 0.000 0.000 0.004 0.000 0.996 0.000
#> GSM892346 6 0.4705 -0.479 0.044 0.000 0.000 0.472 0.000 0.484
#> GSM892350 4 0.0146 0.853 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM892354 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892356 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892362 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892366 3 0.0000 0.827 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM892370 3 0.3446 0.732 0.000 0.000 0.692 0.000 0.308 0.000
#> GSM892374 6 0.3868 0.256 0.000 0.492 0.000 0.000 0.000 0.508
#> GSM892378 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892388 6 0.3868 0.256 0.000 0.492 0.000 0.000 0.000 0.508
#> GSM892343 5 0.0000 0.992 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM892348 6 0.4705 -0.479 0.044 0.000 0.000 0.472 0.000 0.484
#> GSM892352 4 0.3373 0.586 0.000 0.000 0.000 0.744 0.248 0.008
#> GSM892358 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892360 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892364 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892368 3 0.0000 0.827 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM892372 3 0.2527 0.800 0.000 0.000 0.832 0.000 0.168 0.000
#> GSM892376 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> ATC:hclust 50 1.000 0.934 2.67e-07 1.42e-03 2
#> ATC:hclust 50 1.000 0.931 1.26e-12 1.60e-05 3
#> ATC:hclust 49 0.998 0.993 2.28e-17 4.54e-07 4
#> ATC:hclust 46 0.922 0.927 2.35e-20 4.18e-08 5
#> ATC:hclust 45 0.970 1.000 1.15e-19 1.17e-07 6
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 31632 rows and 50 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.4707 0.530 0.530
#> 3 3 0.775 0.952 0.907 0.3034 0.811 0.644
#> 4 4 0.645 0.532 0.805 0.1402 0.984 0.952
#> 5 5 0.764 0.840 0.823 0.0741 0.878 0.633
#> 6 6 0.747 0.771 0.777 0.0570 0.962 0.832
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 2
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.562 0.990 0.308 0.000 0.692
#> GSM892345 1 0.000 0.981 1.000 0.000 0.000
#> GSM892349 1 0.116 0.948 0.972 0.000 0.028
#> GSM892353 1 0.000 0.981 1.000 0.000 0.000
#> GSM892355 1 0.000 0.981 1.000 0.000 0.000
#> GSM892361 1 0.000 0.981 1.000 0.000 0.000
#> GSM892365 3 0.562 0.990 0.308 0.000 0.692
#> GSM892369 3 0.562 0.990 0.308 0.000 0.692
#> GSM892373 2 0.562 0.761 0.000 0.692 0.308
#> GSM892377 2 0.000 0.958 0.000 1.000 0.000
#> GSM892381 2 0.000 0.958 0.000 1.000 0.000
#> GSM892383 2 0.000 0.958 0.000 1.000 0.000
#> GSM892387 2 0.000 0.958 0.000 1.000 0.000
#> GSM892344 3 0.601 0.894 0.372 0.000 0.628
#> GSM892347 1 0.000 0.981 1.000 0.000 0.000
#> GSM892351 1 0.000 0.981 1.000 0.000 0.000
#> GSM892357 1 0.000 0.981 1.000 0.000 0.000
#> GSM892359 1 0.000 0.981 1.000 0.000 0.000
#> GSM892363 1 0.000 0.981 1.000 0.000 0.000
#> GSM892367 3 0.562 0.990 0.308 0.000 0.692
#> GSM892371 3 0.562 0.990 0.308 0.000 0.692
#> GSM892375 2 0.000 0.958 0.000 1.000 0.000
#> GSM892379 2 0.000 0.958 0.000 1.000 0.000
#> GSM892385 2 0.000 0.958 0.000 1.000 0.000
#> GSM892389 2 0.000 0.958 0.000 1.000 0.000
#> GSM892341 3 0.562 0.990 0.308 0.000 0.692
#> GSM892346 1 0.000 0.981 1.000 0.000 0.000
#> GSM892350 1 0.000 0.981 1.000 0.000 0.000
#> GSM892354 1 0.000 0.981 1.000 0.000 0.000
#> GSM892356 1 0.000 0.981 1.000 0.000 0.000
#> GSM892362 1 0.000 0.981 1.000 0.000 0.000
#> GSM892366 3 0.562 0.990 0.308 0.000 0.692
#> GSM892370 3 0.562 0.990 0.308 0.000 0.692
#> GSM892374 2 0.562 0.761 0.000 0.692 0.308
#> GSM892378 2 0.000 0.958 0.000 1.000 0.000
#> GSM892382 2 0.000 0.958 0.000 1.000 0.000
#> GSM892384 2 0.000 0.958 0.000 1.000 0.000
#> GSM892388 2 0.562 0.761 0.000 0.692 0.308
#> GSM892343 1 0.450 0.609 0.804 0.000 0.196
#> GSM892348 1 0.000 0.981 1.000 0.000 0.000
#> GSM892352 1 0.116 0.948 0.972 0.000 0.028
#> GSM892358 1 0.000 0.981 1.000 0.000 0.000
#> GSM892360 1 0.000 0.981 1.000 0.000 0.000
#> GSM892364 1 0.000 0.981 1.000 0.000 0.000
#> GSM892368 3 0.562 0.990 0.308 0.000 0.692
#> GSM892372 3 0.562 0.990 0.308 0.000 0.692
#> GSM892376 2 0.000 0.958 0.000 1.000 0.000
#> GSM892380 2 0.000 0.958 0.000 1.000 0.000
#> GSM892386 2 0.000 0.958 0.000 1.000 0.000
#> GSM892390 2 0.000 0.958 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.5160 0.911 0.136 0.000 0.760 0.104
#> GSM892345 1 0.4916 -0.706 0.576 0.000 0.000 0.424
#> GSM892349 1 0.5168 -0.972 0.504 0.000 0.004 0.492
#> GSM892353 1 0.0592 0.575 0.984 0.000 0.000 0.016
#> GSM892355 1 0.0000 0.596 1.000 0.000 0.000 0.000
#> GSM892361 1 0.0000 0.596 1.000 0.000 0.000 0.000
#> GSM892365 3 0.2868 0.931 0.136 0.000 0.864 0.000
#> GSM892369 3 0.4514 0.930 0.136 0.000 0.800 0.064
#> GSM892373 2 0.5000 0.596 0.000 0.504 0.000 0.496
#> GSM892377 2 0.2408 0.889 0.000 0.896 0.104 0.000
#> GSM892381 2 0.1022 0.899 0.000 0.968 0.032 0.000
#> GSM892383 2 0.0817 0.900 0.000 0.976 0.024 0.000
#> GSM892387 2 0.0921 0.901 0.000 0.972 0.028 0.000
#> GSM892344 3 0.6980 0.636 0.164 0.000 0.572 0.264
#> GSM892347 1 0.4916 -0.706 0.576 0.000 0.000 0.424
#> GSM892351 1 0.4989 -0.886 0.528 0.000 0.000 0.472
#> GSM892357 1 0.0000 0.596 1.000 0.000 0.000 0.000
#> GSM892359 1 0.0000 0.596 1.000 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.596 1.000 0.000 0.000 0.000
#> GSM892367 3 0.2868 0.931 0.136 0.000 0.864 0.000
#> GSM892371 3 0.4514 0.930 0.136 0.000 0.800 0.064
#> GSM892375 2 0.1118 0.898 0.000 0.964 0.036 0.000
#> GSM892379 2 0.2216 0.890 0.000 0.908 0.092 0.000
#> GSM892385 2 0.1302 0.900 0.000 0.956 0.044 0.000
#> GSM892389 2 0.2081 0.892 0.000 0.916 0.084 0.000
#> GSM892341 3 0.5160 0.911 0.136 0.000 0.760 0.104
#> GSM892346 1 0.4877 -0.661 0.592 0.000 0.000 0.408
#> GSM892350 1 0.4916 -0.706 0.576 0.000 0.000 0.424
#> GSM892354 1 0.0000 0.596 1.000 0.000 0.000 0.000
#> GSM892356 1 0.0000 0.596 1.000 0.000 0.000 0.000
#> GSM892362 1 0.0000 0.596 1.000 0.000 0.000 0.000
#> GSM892366 3 0.2868 0.931 0.136 0.000 0.864 0.000
#> GSM892370 3 0.4514 0.930 0.136 0.000 0.800 0.064
#> GSM892374 2 0.5000 0.596 0.000 0.504 0.000 0.496
#> GSM892378 2 0.2345 0.889 0.000 0.900 0.100 0.000
#> GSM892382 2 0.1022 0.899 0.000 0.968 0.032 0.000
#> GSM892384 2 0.0592 0.900 0.000 0.984 0.016 0.000
#> GSM892388 2 0.5000 0.596 0.000 0.504 0.000 0.496
#> GSM892343 1 0.7824 -0.325 0.404 0.000 0.328 0.268
#> GSM892348 1 0.4916 -0.706 0.576 0.000 0.000 0.424
#> GSM892352 4 0.5168 0.000 0.496 0.000 0.004 0.500
#> GSM892358 1 0.0000 0.596 1.000 0.000 0.000 0.000
#> GSM892360 1 0.0000 0.596 1.000 0.000 0.000 0.000
#> GSM892364 1 0.0000 0.596 1.000 0.000 0.000 0.000
#> GSM892368 3 0.2868 0.931 0.136 0.000 0.864 0.000
#> GSM892372 3 0.2868 0.931 0.136 0.000 0.864 0.000
#> GSM892376 2 0.1022 0.899 0.000 0.968 0.032 0.000
#> GSM892380 2 0.1716 0.897 0.000 0.936 0.064 0.000
#> GSM892386 2 0.0707 0.900 0.000 0.980 0.020 0.000
#> GSM892390 2 0.2081 0.892 0.000 0.916 0.084 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 3 0.6353 0.698 0.008 0.000 0.556 0.180 0.256
#> GSM892345 4 0.2179 0.823 0.100 0.000 0.000 0.896 0.004
#> GSM892349 4 0.1082 0.789 0.000 0.000 0.008 0.964 0.028
#> GSM892353 1 0.4763 0.880 0.632 0.000 0.000 0.336 0.032
#> GSM892355 1 0.4475 0.967 0.692 0.000 0.000 0.276 0.032
#> GSM892361 1 0.3814 0.976 0.720 0.000 0.000 0.276 0.004
#> GSM892365 3 0.1928 0.853 0.004 0.000 0.920 0.072 0.004
#> GSM892369 3 0.3900 0.851 0.008 0.000 0.816 0.108 0.068
#> GSM892373 5 0.3913 0.990 0.000 0.324 0.000 0.000 0.676
#> GSM892377 2 0.3993 0.784 0.216 0.756 0.028 0.000 0.000
#> GSM892381 2 0.0912 0.851 0.012 0.972 0.016 0.000 0.000
#> GSM892383 2 0.2580 0.845 0.064 0.892 0.044 0.000 0.000
#> GSM892387 2 0.0451 0.855 0.004 0.988 0.008 0.000 0.000
#> GSM892344 3 0.6952 0.465 0.008 0.000 0.408 0.328 0.256
#> GSM892347 4 0.2179 0.823 0.100 0.000 0.000 0.896 0.004
#> GSM892351 4 0.0992 0.809 0.024 0.000 0.000 0.968 0.008
#> GSM892357 1 0.4229 0.969 0.704 0.000 0.000 0.276 0.020
#> GSM892359 1 0.3661 0.977 0.724 0.000 0.000 0.276 0.000
#> GSM892363 1 0.4138 0.974 0.708 0.000 0.000 0.276 0.016
#> GSM892367 3 0.1608 0.854 0.000 0.000 0.928 0.072 0.000
#> GSM892371 3 0.3900 0.851 0.008 0.000 0.816 0.108 0.068
#> GSM892375 2 0.0693 0.851 0.012 0.980 0.008 0.000 0.000
#> GSM892379 2 0.3395 0.783 0.236 0.764 0.000 0.000 0.000
#> GSM892385 2 0.3003 0.842 0.092 0.864 0.044 0.000 0.000
#> GSM892389 2 0.3282 0.802 0.188 0.804 0.008 0.000 0.000
#> GSM892341 3 0.6353 0.698 0.008 0.000 0.556 0.180 0.256
#> GSM892346 4 0.2389 0.805 0.116 0.000 0.000 0.880 0.004
#> GSM892350 4 0.2020 0.823 0.100 0.000 0.000 0.900 0.000
#> GSM892354 1 0.4229 0.969 0.704 0.000 0.000 0.276 0.020
#> GSM892356 1 0.3661 0.977 0.724 0.000 0.000 0.276 0.000
#> GSM892362 1 0.4138 0.974 0.708 0.000 0.000 0.276 0.016
#> GSM892366 3 0.1928 0.853 0.004 0.000 0.920 0.072 0.004
#> GSM892370 3 0.3900 0.851 0.008 0.000 0.816 0.108 0.068
#> GSM892374 5 0.3913 0.990 0.000 0.324 0.000 0.000 0.676
#> GSM892378 2 0.3424 0.781 0.240 0.760 0.000 0.000 0.000
#> GSM892382 2 0.0912 0.851 0.012 0.972 0.016 0.000 0.000
#> GSM892384 2 0.0290 0.855 0.000 0.992 0.008 0.000 0.000
#> GSM892388 5 0.4812 0.980 0.012 0.324 0.012 0.004 0.648
#> GSM892343 4 0.6808 -0.144 0.008 0.000 0.268 0.468 0.256
#> GSM892348 4 0.2233 0.820 0.104 0.000 0.000 0.892 0.004
#> GSM892352 4 0.1082 0.789 0.000 0.000 0.008 0.964 0.028
#> GSM892358 1 0.3661 0.977 0.724 0.000 0.000 0.276 0.000
#> GSM892360 1 0.3661 0.977 0.724 0.000 0.000 0.276 0.000
#> GSM892364 1 0.4138 0.974 0.708 0.000 0.000 0.276 0.016
#> GSM892368 3 0.1608 0.854 0.000 0.000 0.928 0.072 0.000
#> GSM892372 3 0.2006 0.854 0.000 0.000 0.916 0.072 0.012
#> GSM892376 2 0.0579 0.852 0.008 0.984 0.008 0.000 0.000
#> GSM892380 2 0.3146 0.832 0.128 0.844 0.028 0.000 0.000
#> GSM892386 2 0.0290 0.854 0.000 0.992 0.008 0.000 0.000
#> GSM892390 2 0.3282 0.802 0.188 0.804 0.008 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.5422 0.1256 0.024 0.000 0.316 0.080 0.580 0.000
#> GSM892345 4 0.2597 0.9196 0.176 0.000 0.000 0.824 0.000 0.000
#> GSM892349 4 0.4287 0.8571 0.108 0.000 0.000 0.768 0.028 0.096
#> GSM892353 1 0.3610 0.8378 0.792 0.000 0.000 0.052 0.004 0.152
#> GSM892355 1 0.2340 0.8939 0.852 0.000 0.000 0.000 0.000 0.148
#> GSM892361 1 0.1141 0.9456 0.948 0.000 0.000 0.000 0.000 0.052
#> GSM892365 3 0.1088 0.8936 0.024 0.000 0.960 0.000 0.000 0.016
#> GSM892369 3 0.4416 0.8530 0.024 0.000 0.776 0.016 0.096 0.088
#> GSM892373 5 0.6049 0.0991 0.000 0.332 0.000 0.000 0.404 0.264
#> GSM892377 2 0.1606 0.7628 0.000 0.932 0.004 0.056 0.000 0.008
#> GSM892381 2 0.3850 0.8343 0.000 0.652 0.004 0.004 0.000 0.340
#> GSM892383 2 0.4134 0.8348 0.000 0.708 0.000 0.052 0.000 0.240
#> GSM892387 2 0.4009 0.8379 0.000 0.684 0.000 0.028 0.000 0.288
#> GSM892344 5 0.5858 0.2254 0.028 0.000 0.228 0.164 0.580 0.000
#> GSM892347 4 0.2597 0.9196 0.176 0.000 0.000 0.824 0.000 0.000
#> GSM892351 4 0.3915 0.8865 0.128 0.000 0.000 0.776 0.004 0.092
#> GSM892357 1 0.1387 0.9365 0.932 0.000 0.000 0.000 0.000 0.068
#> GSM892359 1 0.0000 0.9481 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892363 1 0.0937 0.9436 0.960 0.000 0.000 0.000 0.000 0.040
#> GSM892367 3 0.0632 0.8961 0.024 0.000 0.976 0.000 0.000 0.000
#> GSM892371 3 0.4416 0.8530 0.024 0.000 0.776 0.016 0.096 0.088
#> GSM892375 2 0.3758 0.8356 0.000 0.668 0.000 0.008 0.000 0.324
#> GSM892379 2 0.1003 0.7583 0.000 0.964 0.004 0.028 0.000 0.004
#> GSM892385 2 0.3894 0.8328 0.000 0.740 0.004 0.036 0.000 0.220
#> GSM892389 2 0.0984 0.7663 0.000 0.968 0.012 0.012 0.000 0.008
#> GSM892341 5 0.5422 0.1256 0.024 0.000 0.316 0.080 0.580 0.000
#> GSM892346 4 0.2838 0.9112 0.188 0.000 0.000 0.808 0.000 0.004
#> GSM892350 4 0.3695 0.9153 0.176 0.000 0.000 0.776 0.004 0.044
#> GSM892354 1 0.1444 0.9369 0.928 0.000 0.000 0.000 0.000 0.072
#> GSM892356 1 0.0000 0.9481 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892362 1 0.1327 0.9431 0.936 0.000 0.000 0.000 0.000 0.064
#> GSM892366 3 0.1088 0.8936 0.024 0.000 0.960 0.000 0.000 0.016
#> GSM892370 3 0.4416 0.8530 0.024 0.000 0.776 0.016 0.096 0.088
#> GSM892374 5 0.6049 0.0991 0.000 0.332 0.000 0.000 0.404 0.264
#> GSM892378 2 0.0713 0.7602 0.000 0.972 0.000 0.028 0.000 0.000
#> GSM892382 2 0.3850 0.8343 0.000 0.652 0.004 0.004 0.000 0.340
#> GSM892384 2 0.4042 0.8376 0.000 0.664 0.004 0.016 0.000 0.316
#> GSM892388 5 0.6410 0.0961 0.000 0.332 0.004 0.008 0.384 0.272
#> GSM892343 5 0.6283 0.2458 0.088 0.000 0.160 0.172 0.580 0.000
#> GSM892348 4 0.2631 0.9180 0.180 0.000 0.000 0.820 0.000 0.000
#> GSM892352 4 0.4315 0.8527 0.104 0.000 0.000 0.768 0.032 0.096
#> GSM892358 1 0.0547 0.9467 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM892360 1 0.0000 0.9481 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892364 1 0.0937 0.9436 0.960 0.000 0.000 0.000 0.000 0.040
#> GSM892368 3 0.0632 0.8961 0.024 0.000 0.976 0.000 0.000 0.000
#> GSM892372 3 0.2209 0.8896 0.024 0.000 0.900 0.000 0.004 0.072
#> GSM892376 2 0.3784 0.8359 0.000 0.680 0.000 0.012 0.000 0.308
#> GSM892380 2 0.3254 0.8129 0.000 0.820 0.000 0.056 0.000 0.124
#> GSM892386 2 0.3816 0.8373 0.000 0.688 0.000 0.016 0.000 0.296
#> GSM892390 2 0.1078 0.7667 0.000 0.964 0.012 0.016 0.000 0.008
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> ATC:kmeans 50 1.000 0.934 2.67e-07 1.42e-03 2
#> ATC:kmeans 50 0.933 0.869 1.06e-11 4.14e-05 3
#> ATC:kmeans 41 0.967 0.954 7.24e-11 1.02e-04 4
#> ATC:kmeans 48 0.982 0.532 5.15e-16 6.33e-08 5
#> ATC:kmeans 43 0.998 0.998 2.92e-15 1.90e-06 6
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 31632 rows and 50 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 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 1.000 0.984 0.994 0.3946 0.811 0.644
#> 4 4 1.000 0.890 0.956 0.1358 0.882 0.670
#> 5 5 1.000 0.990 0.993 0.0341 0.971 0.888
#> 6 6 0.982 0.930 0.946 0.0143 0.990 0.957
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 2 3 4
There is also optional best \(k\) = 2 3 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.0000 0.968 0.000 0 1.000
#> GSM892345 1 0.0000 0.999 1.000 0 0.000
#> GSM892349 1 0.0000 0.999 1.000 0 0.000
#> GSM892353 1 0.0000 0.999 1.000 0 0.000
#> GSM892355 1 0.0000 0.999 1.000 0 0.000
#> GSM892361 1 0.0000 0.999 1.000 0 0.000
#> GSM892365 3 0.0000 0.968 0.000 0 1.000
#> GSM892369 3 0.0000 0.968 0.000 0 1.000
#> GSM892373 2 0.0000 1.000 0.000 1 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000
#> GSM892344 3 0.5591 0.562 0.304 0 0.696
#> GSM892347 1 0.0000 0.999 1.000 0 0.000
#> GSM892351 1 0.0000 0.999 1.000 0 0.000
#> GSM892357 1 0.0000 0.999 1.000 0 0.000
#> GSM892359 1 0.0000 0.999 1.000 0 0.000
#> GSM892363 1 0.0000 0.999 1.000 0 0.000
#> GSM892367 3 0.0000 0.968 0.000 0 1.000
#> GSM892371 3 0.0000 0.968 0.000 0 1.000
#> GSM892375 2 0.0000 1.000 0.000 1 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000
#> GSM892341 3 0.0000 0.968 0.000 0 1.000
#> GSM892346 1 0.0000 0.999 1.000 0 0.000
#> GSM892350 1 0.0000 0.999 1.000 0 0.000
#> GSM892354 1 0.0000 0.999 1.000 0 0.000
#> GSM892356 1 0.0000 0.999 1.000 0 0.000
#> GSM892362 1 0.0000 0.999 1.000 0 0.000
#> GSM892366 3 0.0000 0.968 0.000 0 1.000
#> GSM892370 3 0.0000 0.968 0.000 0 1.000
#> GSM892374 2 0.0000 1.000 0.000 1 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000
#> GSM892343 1 0.0592 0.987 0.988 0 0.012
#> GSM892348 1 0.0000 0.999 1.000 0 0.000
#> GSM892352 1 0.0000 0.999 1.000 0 0.000
#> GSM892358 1 0.0000 0.999 1.000 0 0.000
#> GSM892360 1 0.0000 0.999 1.000 0 0.000
#> GSM892364 1 0.0000 0.999 1.000 0 0.000
#> GSM892368 3 0.0000 0.968 0.000 0 1.000
#> GSM892372 3 0.0000 0.968 0.000 0 1.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.5000 0.945 0.000 0 0.500 0.500
#> GSM892345 4 0.5925 0.787 0.036 0 0.452 0.512
#> GSM892349 4 0.5268 0.782 0.008 0 0.452 0.540
#> GSM892353 1 0.0817 0.973 0.976 0 0.000 0.024
#> GSM892355 1 0.0000 0.998 1.000 0 0.000 0.000
#> GSM892361 1 0.0000 0.998 1.000 0 0.000 0.000
#> GSM892365 3 0.4967 0.993 0.000 0 0.548 0.452
#> GSM892369 3 0.4967 0.993 0.000 0 0.548 0.452
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892344 4 0.0707 0.140 0.000 0 0.020 0.980
#> GSM892347 4 0.5925 0.787 0.036 0 0.452 0.512
#> GSM892351 4 0.5383 0.783 0.012 0 0.452 0.536
#> GSM892357 1 0.0000 0.998 1.000 0 0.000 0.000
#> GSM892359 1 0.0000 0.998 1.000 0 0.000 0.000
#> GSM892363 1 0.0000 0.998 1.000 0 0.000 0.000
#> GSM892367 3 0.4967 0.993 0.000 0 0.548 0.452
#> GSM892371 3 0.4967 0.993 0.000 0 0.548 0.452
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892341 4 0.5000 -0.956 0.000 0 0.500 0.500
#> GSM892346 4 0.6332 0.774 0.060 0 0.452 0.488
#> GSM892350 4 0.5925 0.787 0.036 0 0.452 0.512
#> GSM892354 1 0.0000 0.998 1.000 0 0.000 0.000
#> GSM892356 1 0.0000 0.998 1.000 0 0.000 0.000
#> GSM892362 1 0.0000 0.998 1.000 0 0.000 0.000
#> GSM892366 3 0.4967 0.993 0.000 0 0.548 0.452
#> GSM892370 3 0.4967 0.993 0.000 0 0.548 0.452
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892343 4 0.0000 0.194 0.000 0 0.000 1.000
#> GSM892348 4 0.6071 0.784 0.044 0 0.452 0.504
#> GSM892352 4 0.4967 0.777 0.000 0 0.452 0.548
#> GSM892358 1 0.0000 0.998 1.000 0 0.000 0.000
#> GSM892360 1 0.0000 0.998 1.000 0 0.000 0.000
#> GSM892364 1 0.0000 0.998 1.000 0 0.000 0.000
#> GSM892368 3 0.4967 0.993 0.000 0 0.548 0.452
#> GSM892372 3 0.4967 0.993 0.000 0 0.548 0.452
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 5 0.0000 1.000 0.000 0 0.000 0.000 1.000
#> GSM892345 4 0.0000 0.994 0.000 0 0.000 1.000 0.000
#> GSM892349 4 0.0404 0.987 0.000 0 0.000 0.988 0.012
#> GSM892353 1 0.0000 1.000 1.000 0 0.000 0.000 0.000
#> GSM892355 1 0.0000 1.000 1.000 0 0.000 0.000 0.000
#> GSM892361 1 0.0000 1.000 1.000 0 0.000 0.000 0.000
#> GSM892365 3 0.0000 0.954 0.000 0 1.000 0.000 0.000
#> GSM892369 3 0.1965 0.931 0.000 0 0.904 0.000 0.096
#> GSM892373 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892344 5 0.0000 1.000 0.000 0 0.000 0.000 1.000
#> GSM892347 4 0.0000 0.994 0.000 0 0.000 1.000 0.000
#> GSM892351 4 0.0000 0.994 0.000 0 0.000 1.000 0.000
#> GSM892357 1 0.0000 1.000 1.000 0 0.000 0.000 0.000
#> GSM892359 1 0.0000 1.000 1.000 0 0.000 0.000 0.000
#> GSM892363 1 0.0000 1.000 1.000 0 0.000 0.000 0.000
#> GSM892367 3 0.0290 0.957 0.000 0 0.992 0.000 0.008
#> GSM892371 3 0.1965 0.931 0.000 0 0.904 0.000 0.096
#> GSM892375 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892341 5 0.0000 1.000 0.000 0 0.000 0.000 1.000
#> GSM892346 4 0.0162 0.991 0.004 0 0.000 0.996 0.000
#> GSM892350 4 0.0000 0.994 0.000 0 0.000 1.000 0.000
#> GSM892354 1 0.0000 1.000 1.000 0 0.000 0.000 0.000
#> GSM892356 1 0.0000 1.000 1.000 0 0.000 0.000 0.000
#> GSM892362 1 0.0000 1.000 1.000 0 0.000 0.000 0.000
#> GSM892366 3 0.0000 0.954 0.000 0 1.000 0.000 0.000
#> GSM892370 3 0.1965 0.931 0.000 0 0.904 0.000 0.096
#> GSM892374 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892343 5 0.0000 1.000 0.000 0 0.000 0.000 1.000
#> GSM892348 4 0.0000 0.994 0.000 0 0.000 1.000 0.000
#> GSM892352 4 0.0794 0.974 0.000 0 0.000 0.972 0.028
#> GSM892358 1 0.0000 1.000 1.000 0 0.000 0.000 0.000
#> GSM892360 1 0.0000 1.000 1.000 0 0.000 0.000 0.000
#> GSM892364 1 0.0000 1.000 1.000 0 0.000 0.000 0.000
#> GSM892368 3 0.0290 0.957 0.000 0 0.992 0.000 0.008
#> GSM892372 3 0.0510 0.957 0.000 0 0.984 0.000 0.016
#> GSM892376 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM892345 4 0.0000 0.933 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM892349 4 0.3068 0.867 0.000 0.000 0.008 0.840 0.032 0.120
#> GSM892353 1 0.0603 0.981 0.980 0.000 0.000 0.000 0.016 0.004
#> GSM892355 1 0.0146 0.996 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM892361 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892365 6 0.2762 0.993 0.000 0.000 0.196 0.000 0.000 0.804
#> GSM892369 3 0.0458 0.685 0.000 0.000 0.984 0.000 0.016 0.000
#> GSM892373 2 0.0146 0.997 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM892377 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892381 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892383 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892387 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892344 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM892347 4 0.0363 0.932 0.000 0.000 0.000 0.988 0.000 0.012
#> GSM892351 4 0.1075 0.925 0.000 0.000 0.000 0.952 0.000 0.048
#> GSM892357 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892359 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892363 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892367 3 0.3684 0.430 0.000 0.000 0.628 0.000 0.000 0.372
#> GSM892371 3 0.0458 0.685 0.000 0.000 0.984 0.000 0.016 0.000
#> GSM892375 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892379 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892385 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892389 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892341 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM892346 4 0.0777 0.928 0.004 0.000 0.000 0.972 0.000 0.024
#> GSM892350 4 0.0547 0.931 0.000 0.000 0.000 0.980 0.000 0.020
#> GSM892354 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892356 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892362 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892366 6 0.2793 0.993 0.000 0.000 0.200 0.000 0.000 0.800
#> GSM892370 3 0.0458 0.685 0.000 0.000 0.984 0.000 0.016 0.000
#> GSM892374 2 0.0146 0.997 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM892378 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892382 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892384 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892388 2 0.0146 0.997 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM892343 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM892348 4 0.0632 0.929 0.000 0.000 0.000 0.976 0.000 0.024
#> GSM892352 4 0.4585 0.770 0.000 0.000 0.016 0.724 0.096 0.164
#> GSM892358 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892360 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM892364 1 0.0146 0.996 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM892368 3 0.3782 0.329 0.000 0.000 0.588 0.000 0.000 0.412
#> GSM892372 3 0.3426 0.560 0.000 0.000 0.720 0.000 0.004 0.276
#> GSM892376 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892380 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892386 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM892390 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> ATC:skmeans 50 1.000 0.934 2.67e-07 1.42e-03 2
#> ATC:skmeans 50 0.933 0.869 1.06e-11 4.14e-05 3
#> ATC:skmeans 47 0.993 0.986 2.58e-16 7.31e-07 4
#> ATC:skmeans 50 1.000 0.998 3.76e-23 2.67e-09 5
#> ATC:skmeans 48 1.000 0.863 1.22e-26 7.95e-11 6
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 31632 rows and 50 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 0.974 0.913 0.968 0.4091 0.811 0.644
#> 4 4 1.000 0.986 0.994 0.1247 0.900 0.714
#> 5 5 0.926 0.880 0.909 0.0446 0.945 0.792
#> 6 6 0.969 0.937 0.968 0.0397 0.971 0.869
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 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
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.000 0.9607 0.000 0 1.000
#> GSM892345 1 0.000 0.9320 1.000 0 0.000
#> GSM892349 1 0.604 0.3948 0.620 0 0.380
#> GSM892353 1 0.000 0.9320 1.000 0 0.000
#> GSM892355 1 0.000 0.9320 1.000 0 0.000
#> GSM892361 1 0.000 0.9320 1.000 0 0.000
#> GSM892365 3 0.000 0.9607 0.000 0 1.000
#> GSM892369 3 0.000 0.9607 0.000 0 1.000
#> GSM892373 2 0.000 1.0000 0.000 1 0.000
#> GSM892377 2 0.000 1.0000 0.000 1 0.000
#> GSM892381 2 0.000 1.0000 0.000 1 0.000
#> GSM892383 2 0.000 1.0000 0.000 1 0.000
#> GSM892387 2 0.000 1.0000 0.000 1 0.000
#> GSM892344 3 0.588 0.3873 0.348 0 0.652
#> GSM892347 1 0.000 0.9320 1.000 0 0.000
#> GSM892351 1 0.000 0.9320 1.000 0 0.000
#> GSM892357 1 0.000 0.9320 1.000 0 0.000
#> GSM892359 1 0.000 0.9320 1.000 0 0.000
#> GSM892363 1 0.000 0.9320 1.000 0 0.000
#> GSM892367 3 0.000 0.9607 0.000 0 1.000
#> GSM892371 3 0.000 0.9607 0.000 0 1.000
#> GSM892375 2 0.000 1.0000 0.000 1 0.000
#> GSM892379 2 0.000 1.0000 0.000 1 0.000
#> GSM892385 2 0.000 1.0000 0.000 1 0.000
#> GSM892389 2 0.000 1.0000 0.000 1 0.000
#> GSM892341 3 0.000 0.9607 0.000 0 1.000
#> GSM892346 1 0.000 0.9320 1.000 0 0.000
#> GSM892350 1 0.000 0.9320 1.000 0 0.000
#> GSM892354 1 0.000 0.9320 1.000 0 0.000
#> GSM892356 1 0.000 0.9320 1.000 0 0.000
#> GSM892362 1 0.000 0.9320 1.000 0 0.000
#> GSM892366 3 0.000 0.9607 0.000 0 1.000
#> GSM892370 3 0.000 0.9607 0.000 0 1.000
#> GSM892374 2 0.000 1.0000 0.000 1 0.000
#> GSM892378 2 0.000 1.0000 0.000 1 0.000
#> GSM892382 2 0.000 1.0000 0.000 1 0.000
#> GSM892384 2 0.000 1.0000 0.000 1 0.000
#> GSM892388 2 0.000 1.0000 0.000 1 0.000
#> GSM892343 1 0.630 0.0864 0.516 0 0.484
#> GSM892348 1 0.000 0.9320 1.000 0 0.000
#> GSM892352 1 0.606 0.3855 0.616 0 0.384
#> GSM892358 1 0.000 0.9320 1.000 0 0.000
#> GSM892360 1 0.000 0.9320 1.000 0 0.000
#> GSM892364 1 0.000 0.9320 1.000 0 0.000
#> GSM892368 3 0.000 0.9607 0.000 0 1.000
#> GSM892372 3 0.000 0.9607 0.000 0 1.000
#> GSM892376 2 0.000 1.0000 0.000 1 0.000
#> GSM892380 2 0.000 1.0000 0.000 1 0.000
#> GSM892386 2 0.000 1.0000 0.000 1 0.000
#> GSM892390 2 0.000 1.0000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.000 1.000 0.000 0 1.000 0.000
#> GSM892345 4 0.000 0.992 0.000 0 0.000 1.000
#> GSM892349 4 0.000 0.992 0.000 0 0.000 1.000
#> GSM892353 1 0.000 0.979 1.000 0 0.000 0.000
#> GSM892355 1 0.000 0.979 1.000 0 0.000 0.000
#> GSM892361 1 0.000 0.979 1.000 0 0.000 0.000
#> GSM892365 3 0.000 1.000 0.000 0 1.000 0.000
#> GSM892369 3 0.000 1.000 0.000 0 1.000 0.000
#> GSM892373 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892377 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892381 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892383 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892387 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892344 4 0.189 0.934 0.008 0 0.056 0.936
#> GSM892347 4 0.000 0.992 0.000 0 0.000 1.000
#> GSM892351 4 0.000 0.992 0.000 0 0.000 1.000
#> GSM892357 1 0.000 0.979 1.000 0 0.000 0.000
#> GSM892359 1 0.000 0.979 1.000 0 0.000 0.000
#> GSM892363 1 0.000 0.979 1.000 0 0.000 0.000
#> GSM892367 3 0.000 1.000 0.000 0 1.000 0.000
#> GSM892371 3 0.000 1.000 0.000 0 1.000 0.000
#> GSM892375 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892379 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892385 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892389 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892341 3 0.000 1.000 0.000 0 1.000 0.000
#> GSM892346 4 0.000 0.992 0.000 0 0.000 1.000
#> GSM892350 4 0.000 0.992 0.000 0 0.000 1.000
#> GSM892354 1 0.000 0.979 1.000 0 0.000 0.000
#> GSM892356 1 0.000 0.979 1.000 0 0.000 0.000
#> GSM892362 1 0.000 0.979 1.000 0 0.000 0.000
#> GSM892366 3 0.000 1.000 0.000 0 1.000 0.000
#> GSM892370 3 0.000 1.000 0.000 0 1.000 0.000
#> GSM892374 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892378 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892382 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892384 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892388 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892343 1 0.511 0.678 0.740 0 0.056 0.204
#> GSM892348 4 0.000 0.992 0.000 0 0.000 1.000
#> GSM892352 4 0.000 0.992 0.000 0 0.000 1.000
#> GSM892358 1 0.000 0.979 1.000 0 0.000 0.000
#> GSM892360 1 0.000 0.979 1.000 0 0.000 0.000
#> GSM892364 1 0.000 0.979 1.000 0 0.000 0.000
#> GSM892368 3 0.000 1.000 0.000 0 1.000 0.000
#> GSM892372 3 0.000 1.000 0.000 0 1.000 0.000
#> GSM892376 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892380 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892386 2 0.000 1.000 0.000 1 0.000 0.000
#> GSM892390 2 0.000 1.000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 3 0.000 0.497 0.000 0.000 1.000 0.000 0.000
#> GSM892345 4 0.000 0.905 0.000 0.000 0.000 1.000 0.000
#> GSM892349 4 0.000 0.905 0.000 0.000 0.000 1.000 0.000
#> GSM892353 1 0.622 0.626 0.520 0.164 0.316 0.000 0.000
#> GSM892355 1 0.430 0.972 0.520 0.480 0.000 0.000 0.000
#> GSM892361 1 0.430 0.972 0.520 0.480 0.000 0.000 0.000
#> GSM892365 3 0.430 0.820 0.000 0.000 0.520 0.000 0.480
#> GSM892369 3 0.430 0.821 0.000 0.000 0.524 0.000 0.476
#> GSM892373 5 0.430 1.000 0.480 0.000 0.000 0.000 0.520
#> GSM892377 2 0.430 1.000 0.480 0.520 0.000 0.000 0.000
#> GSM892381 2 0.430 1.000 0.480 0.520 0.000 0.000 0.000
#> GSM892383 2 0.430 1.000 0.480 0.520 0.000 0.000 0.000
#> GSM892387 2 0.430 1.000 0.480 0.520 0.000 0.000 0.000
#> GSM892344 4 0.456 0.485 0.008 0.000 0.496 0.496 0.000
#> GSM892347 4 0.000 0.905 0.000 0.000 0.000 1.000 0.000
#> GSM892351 4 0.000 0.905 0.000 0.000 0.000 1.000 0.000
#> GSM892357 1 0.430 0.972 0.520 0.480 0.000 0.000 0.000
#> GSM892359 1 0.430 0.972 0.520 0.480 0.000 0.000 0.000
#> GSM892363 1 0.430 0.972 0.520 0.480 0.000 0.000 0.000
#> GSM892367 3 0.430 0.821 0.000 0.000 0.524 0.000 0.476
#> GSM892371 3 0.430 0.821 0.000 0.000 0.524 0.000 0.476
#> GSM892375 2 0.430 1.000 0.480 0.520 0.000 0.000 0.000
#> GSM892379 2 0.430 1.000 0.480 0.520 0.000 0.000 0.000
#> GSM892385 2 0.430 1.000 0.480 0.520 0.000 0.000 0.000
#> GSM892389 2 0.430 1.000 0.480 0.520 0.000 0.000 0.000
#> GSM892341 3 0.000 0.497 0.000 0.000 1.000 0.000 0.000
#> GSM892346 4 0.000 0.905 0.000 0.000 0.000 1.000 0.000
#> GSM892350 4 0.000 0.905 0.000 0.000 0.000 1.000 0.000
#> GSM892354 1 0.430 0.972 0.520 0.480 0.000 0.000 0.000
#> GSM892356 1 0.430 0.972 0.520 0.480 0.000 0.000 0.000
#> GSM892362 1 0.430 0.972 0.520 0.480 0.000 0.000 0.000
#> GSM892366 3 0.430 0.820 0.000 0.000 0.520 0.000 0.480
#> GSM892370 3 0.430 0.821 0.000 0.000 0.524 0.000 0.476
#> GSM892374 5 0.430 1.000 0.480 0.000 0.000 0.000 0.520
#> GSM892378 2 0.430 1.000 0.480 0.520 0.000 0.000 0.000
#> GSM892382 2 0.430 1.000 0.480 0.520 0.000 0.000 0.000
#> GSM892384 2 0.430 1.000 0.480 0.520 0.000 0.000 0.000
#> GSM892388 5 0.430 1.000 0.480 0.000 0.000 0.000 0.520
#> GSM892343 3 0.517 -0.385 0.464 0.000 0.496 0.040 0.000
#> GSM892348 4 0.000 0.905 0.000 0.000 0.000 1.000 0.000
#> GSM892352 4 0.391 0.677 0.000 0.000 0.324 0.676 0.000
#> GSM892358 1 0.430 0.972 0.520 0.480 0.000 0.000 0.000
#> GSM892360 1 0.430 0.972 0.520 0.480 0.000 0.000 0.000
#> GSM892364 1 0.430 0.972 0.520 0.480 0.000 0.000 0.000
#> GSM892368 3 0.430 0.820 0.000 0.000 0.520 0.000 0.480
#> GSM892372 3 0.430 0.821 0.000 0.000 0.524 0.000 0.476
#> GSM892376 2 0.430 1.000 0.480 0.520 0.000 0.000 0.000
#> GSM892380 2 0.430 1.000 0.480 0.520 0.000 0.000 0.000
#> GSM892386 2 0.430 1.000 0.480 0.520 0.000 0.000 0.000
#> GSM892390 2 0.430 1.000 0.480 0.520 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.000 1.000 0.000 0 0.000 0.000 1.000 0
#> GSM892345 4 0.000 0.932 0.000 0 0.000 1.000 0.000 0
#> GSM892349 4 0.000 0.932 0.000 0 0.000 1.000 0.000 0
#> GSM892353 1 0.374 0.355 0.608 0 0.000 0.000 0.392 0
#> GSM892355 1 0.000 0.962 1.000 0 0.000 0.000 0.000 0
#> GSM892361 1 0.000 0.962 1.000 0 0.000 0.000 0.000 0
#> GSM892365 3 0.000 0.880 0.000 0 1.000 0.000 0.000 0
#> GSM892369 3 0.253 0.908 0.000 0 0.832 0.000 0.168 0
#> GSM892373 6 0.000 1.000 0.000 0 0.000 0.000 0.000 1
#> GSM892377 2 0.000 1.000 0.000 1 0.000 0.000 0.000 0
#> GSM892381 2 0.000 1.000 0.000 1 0.000 0.000 0.000 0
#> GSM892383 2 0.000 1.000 0.000 1 0.000 0.000 0.000 0
#> GSM892387 2 0.000 1.000 0.000 1 0.000 0.000 0.000 0
#> GSM892344 5 0.000 1.000 0.000 0 0.000 0.000 1.000 0
#> GSM892347 4 0.000 0.932 0.000 0 0.000 1.000 0.000 0
#> GSM892351 4 0.000 0.932 0.000 0 0.000 1.000 0.000 0
#> GSM892357 1 0.000 0.962 1.000 0 0.000 0.000 0.000 0
#> GSM892359 1 0.000 0.962 1.000 0 0.000 0.000 0.000 0
#> GSM892363 1 0.000 0.962 1.000 0 0.000 0.000 0.000 0
#> GSM892367 3 0.186 0.907 0.000 0 0.896 0.000 0.104 0
#> GSM892371 3 0.253 0.908 0.000 0 0.832 0.000 0.168 0
#> GSM892375 2 0.000 1.000 0.000 1 0.000 0.000 0.000 0
#> GSM892379 2 0.000 1.000 0.000 1 0.000 0.000 0.000 0
#> GSM892385 2 0.000 1.000 0.000 1 0.000 0.000 0.000 0
#> GSM892389 2 0.000 1.000 0.000 1 0.000 0.000 0.000 0
#> GSM892341 5 0.000 1.000 0.000 0 0.000 0.000 1.000 0
#> GSM892346 4 0.000 0.932 0.000 0 0.000 1.000 0.000 0
#> GSM892350 4 0.000 0.932 0.000 0 0.000 1.000 0.000 0
#> GSM892354 1 0.000 0.962 1.000 0 0.000 0.000 0.000 0
#> GSM892356 1 0.000 0.962 1.000 0 0.000 0.000 0.000 0
#> GSM892362 1 0.000 0.962 1.000 0 0.000 0.000 0.000 0
#> GSM892366 3 0.000 0.880 0.000 0 1.000 0.000 0.000 0
#> GSM892370 3 0.253 0.908 0.000 0 0.832 0.000 0.168 0
#> GSM892374 6 0.000 1.000 0.000 0 0.000 0.000 0.000 1
#> GSM892378 2 0.000 1.000 0.000 1 0.000 0.000 0.000 0
#> GSM892382 2 0.000 1.000 0.000 1 0.000 0.000 0.000 0
#> GSM892384 2 0.000 1.000 0.000 1 0.000 0.000 0.000 0
#> GSM892388 6 0.000 1.000 0.000 0 0.000 0.000 0.000 1
#> GSM892343 5 0.000 1.000 0.000 0 0.000 0.000 1.000 0
#> GSM892348 4 0.000 0.932 0.000 0 0.000 1.000 0.000 0
#> GSM892352 4 0.382 0.230 0.000 0 0.000 0.564 0.436 0
#> GSM892358 1 0.000 0.962 1.000 0 0.000 0.000 0.000 0
#> GSM892360 1 0.000 0.962 1.000 0 0.000 0.000 0.000 0
#> GSM892364 1 0.000 0.962 1.000 0 0.000 0.000 0.000 0
#> GSM892368 3 0.000 0.880 0.000 0 1.000 0.000 0.000 0
#> GSM892372 3 0.253 0.908 0.000 0 0.832 0.000 0.168 0
#> GSM892376 2 0.000 1.000 0.000 1 0.000 0.000 0.000 0
#> GSM892380 2 0.000 1.000 0.000 1 0.000 0.000 0.000 0
#> GSM892386 2 0.000 1.000 0.000 1 0.000 0.000 0.000 0
#> GSM892390 2 0.000 1.000 0.000 1 0.000 0.000 0.000 0
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> ATC:pam 50 1.000 0.934 2.67e-07 1.42e-03 2
#> ATC:pam 46 1.000 0.871 3.31e-11 6.62e-05 3
#> ATC:pam 50 0.979 0.866 8.76e-16 7.14e-07 4
#> ATC:pam 46 0.982 0.560 3.62e-16 1.08e-07 5
#> ATC:pam 48 0.986 0.666 6.76e-21 5.72e-09 6
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 31632 rows and 50 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 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 1.000 1.000 1.000 0.4159 0.804 0.630
#> 4 4 1.000 1.000 1.000 0.1174 0.922 0.765
#> 5 5 1.000 0.995 0.995 0.0381 0.971 0.888
#> 6 6 0.989 0.950 0.956 0.0268 0.990 0.957
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 2 3 4
There is also optional best \(k\) = 2 3 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.0000 1.000 0.000 0 1.000
#> GSM892345 3 0.0000 1.000 0.000 0 1.000
#> GSM892349 3 0.0000 1.000 0.000 0 1.000
#> GSM892353 1 0.0000 1.000 1.000 0 0.000
#> GSM892355 1 0.0000 1.000 1.000 0 0.000
#> GSM892361 1 0.0000 1.000 1.000 0 0.000
#> GSM892365 3 0.0000 1.000 0.000 0 1.000
#> GSM892369 3 0.0000 1.000 0.000 0 1.000
#> GSM892373 2 0.0000 1.000 0.000 1 0.000
#> GSM892377 2 0.0000 1.000 0.000 1 0.000
#> GSM892381 2 0.0000 1.000 0.000 1 0.000
#> GSM892383 2 0.0000 1.000 0.000 1 0.000
#> GSM892387 2 0.0000 1.000 0.000 1 0.000
#> GSM892344 3 0.0000 1.000 0.000 0 1.000
#> GSM892347 3 0.0000 1.000 0.000 0 1.000
#> GSM892351 3 0.0000 1.000 0.000 0 1.000
#> GSM892357 1 0.0000 1.000 1.000 0 0.000
#> GSM892359 1 0.0000 1.000 1.000 0 0.000
#> GSM892363 1 0.0000 1.000 1.000 0 0.000
#> GSM892367 3 0.0000 1.000 0.000 0 1.000
#> GSM892371 3 0.0000 1.000 0.000 0 1.000
#> GSM892375 2 0.0000 1.000 0.000 1 0.000
#> GSM892379 2 0.0000 1.000 0.000 1 0.000
#> GSM892385 2 0.0000 1.000 0.000 1 0.000
#> GSM892389 2 0.0000 1.000 0.000 1 0.000
#> GSM892341 3 0.0000 1.000 0.000 0 1.000
#> GSM892346 3 0.0424 0.992 0.008 0 0.992
#> GSM892350 3 0.0000 1.000 0.000 0 1.000
#> GSM892354 1 0.0000 1.000 1.000 0 0.000
#> GSM892356 1 0.0000 1.000 1.000 0 0.000
#> GSM892362 1 0.0000 1.000 1.000 0 0.000
#> GSM892366 3 0.0000 1.000 0.000 0 1.000
#> GSM892370 3 0.0000 1.000 0.000 0 1.000
#> GSM892374 2 0.0000 1.000 0.000 1 0.000
#> GSM892378 2 0.0000 1.000 0.000 1 0.000
#> GSM892382 2 0.0000 1.000 0.000 1 0.000
#> GSM892384 2 0.0000 1.000 0.000 1 0.000
#> GSM892388 2 0.0000 1.000 0.000 1 0.000
#> GSM892343 3 0.0000 1.000 0.000 0 1.000
#> GSM892348 3 0.0000 1.000 0.000 0 1.000
#> GSM892352 3 0.0000 1.000 0.000 0 1.000
#> GSM892358 1 0.0000 1.000 1.000 0 0.000
#> GSM892360 1 0.0000 1.000 1.000 0 0.000
#> GSM892364 1 0.0000 1.000 1.000 0 0.000
#> GSM892368 3 0.0000 1.000 0.000 0 1.000
#> GSM892372 3 0.0000 1.000 0.000 0 1.000
#> GSM892376 2 0.0000 1.000 0.000 1 0.000
#> GSM892380 2 0.0000 1.000 0.000 1 0.000
#> GSM892386 2 0.0000 1.000 0.000 1 0.000
#> GSM892390 2 0.0000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0 1 0 0 1 0
#> GSM892345 4 0 1 0 0 0 1
#> GSM892349 4 0 1 0 0 0 1
#> GSM892353 1 0 1 1 0 0 0
#> GSM892355 1 0 1 1 0 0 0
#> GSM892361 1 0 1 1 0 0 0
#> GSM892365 3 0 1 0 0 1 0
#> GSM892369 3 0 1 0 0 1 0
#> GSM892373 2 0 1 0 1 0 0
#> GSM892377 2 0 1 0 1 0 0
#> GSM892381 2 0 1 0 1 0 0
#> GSM892383 2 0 1 0 1 0 0
#> GSM892387 2 0 1 0 1 0 0
#> GSM892344 3 0 1 0 0 1 0
#> GSM892347 4 0 1 0 0 0 1
#> GSM892351 4 0 1 0 0 0 1
#> GSM892357 1 0 1 1 0 0 0
#> GSM892359 1 0 1 1 0 0 0
#> GSM892363 1 0 1 1 0 0 0
#> GSM892367 3 0 1 0 0 1 0
#> GSM892371 3 0 1 0 0 1 0
#> GSM892375 2 0 1 0 1 0 0
#> GSM892379 2 0 1 0 1 0 0
#> GSM892385 2 0 1 0 1 0 0
#> GSM892389 2 0 1 0 1 0 0
#> GSM892341 3 0 1 0 0 1 0
#> GSM892346 4 0 1 0 0 0 1
#> GSM892350 4 0 1 0 0 0 1
#> GSM892354 1 0 1 1 0 0 0
#> GSM892356 1 0 1 1 0 0 0
#> GSM892362 1 0 1 1 0 0 0
#> GSM892366 3 0 1 0 0 1 0
#> GSM892370 3 0 1 0 0 1 0
#> GSM892374 2 0 1 0 1 0 0
#> GSM892378 2 0 1 0 1 0 0
#> GSM892382 2 0 1 0 1 0 0
#> GSM892384 2 0 1 0 1 0 0
#> GSM892388 2 0 1 0 1 0 0
#> GSM892343 3 0 1 0 0 1 0
#> GSM892348 4 0 1 0 0 0 1
#> GSM892352 4 0 1 0 0 0 1
#> GSM892358 1 0 1 1 0 0 0
#> GSM892360 1 0 1 1 0 0 0
#> GSM892364 1 0 1 1 0 0 0
#> GSM892368 3 0 1 0 0 1 0
#> GSM892372 3 0 1 0 0 1 0
#> GSM892376 2 0 1 0 1 0 0
#> GSM892380 2 0 1 0 1 0 0
#> GSM892386 2 0 1 0 1 0 0
#> GSM892390 2 0 1 0 1 0 0
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 5 0.0290 0.997 0 0.000 0.008 0 0.992
#> GSM892345 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> GSM892349 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> GSM892353 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> GSM892355 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> GSM892361 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> GSM892365 3 0.0609 0.985 0 0.000 0.980 0 0.020
#> GSM892369 5 0.0290 0.997 0 0.000 0.008 0 0.992
#> GSM892373 2 0.0510 0.987 0 0.984 0.016 0 0.000
#> GSM892377 2 0.0000 0.997 0 1.000 0.000 0 0.000
#> GSM892381 2 0.0000 0.997 0 1.000 0.000 0 0.000
#> GSM892383 2 0.0000 0.997 0 1.000 0.000 0 0.000
#> GSM892387 2 0.0000 0.997 0 1.000 0.000 0 0.000
#> GSM892344 5 0.0000 0.993 0 0.000 0.000 0 1.000
#> GSM892347 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> GSM892351 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> GSM892357 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> GSM892359 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> GSM892363 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> GSM892367 3 0.0609 0.985 0 0.000 0.980 0 0.020
#> GSM892371 5 0.0290 0.997 0 0.000 0.008 0 0.992
#> GSM892375 2 0.0000 0.997 0 1.000 0.000 0 0.000
#> GSM892379 2 0.0000 0.997 0 1.000 0.000 0 0.000
#> GSM892385 2 0.0000 0.997 0 1.000 0.000 0 0.000
#> GSM892389 2 0.0000 0.997 0 1.000 0.000 0 0.000
#> GSM892341 5 0.0290 0.997 0 0.000 0.008 0 0.992
#> GSM892346 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> GSM892350 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> GSM892354 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> GSM892356 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> GSM892362 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> GSM892366 3 0.0609 0.985 0 0.000 0.980 0 0.020
#> GSM892370 5 0.0290 0.997 0 0.000 0.008 0 0.992
#> GSM892374 2 0.0510 0.987 0 0.984 0.016 0 0.000
#> GSM892378 2 0.0000 0.997 0 1.000 0.000 0 0.000
#> GSM892382 2 0.0000 0.997 0 1.000 0.000 0 0.000
#> GSM892384 2 0.0000 0.997 0 1.000 0.000 0 0.000
#> GSM892388 2 0.0609 0.984 0 0.980 0.020 0 0.000
#> GSM892343 5 0.0000 0.993 0 0.000 0.000 0 1.000
#> GSM892348 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> GSM892352 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> GSM892358 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> GSM892360 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> GSM892364 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> GSM892368 3 0.0609 0.985 0 0.000 0.980 0 0.020
#> GSM892372 3 0.1671 0.939 0 0.000 0.924 0 0.076
#> GSM892376 2 0.0000 0.997 0 1.000 0.000 0 0.000
#> GSM892380 2 0.0000 0.997 0 1.000 0.000 0 0.000
#> GSM892386 2 0.0000 0.997 0 1.000 0.000 0 0.000
#> GSM892390 2 0.0000 0.997 0 1.000 0.000 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 5 0.385 0.993 0 0.000 0.000 0.000 0.544 0.456
#> GSM892345 4 0.385 1.000 0 0.000 0.000 0.544 0.456 0.000
#> GSM892349 4 0.385 1.000 0 0.000 0.000 0.544 0.456 0.000
#> GSM892353 1 0.000 1.000 1 0.000 0.000 0.000 0.000 0.000
#> GSM892355 1 0.000 1.000 1 0.000 0.000 0.000 0.000 0.000
#> GSM892361 1 0.000 1.000 1 0.000 0.000 0.000 0.000 0.000
#> GSM892365 3 0.000 1.000 0 0.000 1.000 0.000 0.000 0.000
#> GSM892369 5 0.416 0.988 0 0.000 0.012 0.000 0.544 0.444
#> GSM892373 2 0.374 0.567 0 0.608 0.000 0.392 0.000 0.000
#> GSM892377 2 0.000 0.930 0 1.000 0.000 0.000 0.000 0.000
#> GSM892381 2 0.000 0.930 0 1.000 0.000 0.000 0.000 0.000
#> GSM892383 2 0.000 0.930 0 1.000 0.000 0.000 0.000 0.000
#> GSM892387 2 0.000 0.930 0 1.000 0.000 0.000 0.000 0.000
#> GSM892344 5 0.385 0.992 0 0.000 0.000 0.000 0.536 0.464
#> GSM892347 4 0.385 1.000 0 0.000 0.000 0.544 0.456 0.000
#> GSM892351 4 0.385 1.000 0 0.000 0.000 0.544 0.456 0.000
#> GSM892357 1 0.000 1.000 1 0.000 0.000 0.000 0.000 0.000
#> GSM892359 1 0.000 1.000 1 0.000 0.000 0.000 0.000 0.000
#> GSM892363 1 0.000 1.000 1 0.000 0.000 0.000 0.000 0.000
#> GSM892367 3 0.000 1.000 0 0.000 1.000 0.000 0.000 0.000
#> GSM892371 5 0.385 0.993 0 0.000 0.000 0.000 0.544 0.456
#> GSM892375 2 0.000 0.930 0 1.000 0.000 0.000 0.000 0.000
#> GSM892379 2 0.000 0.930 0 1.000 0.000 0.000 0.000 0.000
#> GSM892385 2 0.000 0.930 0 1.000 0.000 0.000 0.000 0.000
#> GSM892389 2 0.000 0.930 0 1.000 0.000 0.000 0.000 0.000
#> GSM892341 5 0.385 0.993 0 0.000 0.000 0.000 0.544 0.456
#> GSM892346 6 0.408 1.000 0 0.000 0.000 0.008 0.456 0.536
#> GSM892350 4 0.385 1.000 0 0.000 0.000 0.544 0.456 0.000
#> GSM892354 1 0.000 1.000 1 0.000 0.000 0.000 0.000 0.000
#> GSM892356 1 0.000 1.000 1 0.000 0.000 0.000 0.000 0.000
#> GSM892362 1 0.000 1.000 1 0.000 0.000 0.000 0.000 0.000
#> GSM892366 3 0.000 1.000 0 0.000 1.000 0.000 0.000 0.000
#> GSM892370 5 0.416 0.988 0 0.000 0.012 0.000 0.544 0.444
#> GSM892374 2 0.374 0.567 0 0.608 0.000 0.392 0.000 0.000
#> GSM892378 2 0.000 0.930 0 1.000 0.000 0.000 0.000 0.000
#> GSM892382 2 0.000 0.930 0 1.000 0.000 0.000 0.000 0.000
#> GSM892384 2 0.000 0.930 0 1.000 0.000 0.000 0.000 0.000
#> GSM892388 2 0.385 0.477 0 0.544 0.000 0.456 0.000 0.000
#> GSM892343 5 0.385 0.992 0 0.000 0.000 0.000 0.536 0.464
#> GSM892348 6 0.408 1.000 0 0.000 0.000 0.008 0.456 0.536
#> GSM892352 4 0.385 1.000 0 0.000 0.000 0.544 0.456 0.000
#> GSM892358 1 0.000 1.000 1 0.000 0.000 0.000 0.000 0.000
#> GSM892360 1 0.000 1.000 1 0.000 0.000 0.000 0.000 0.000
#> GSM892364 1 0.000 1.000 1 0.000 0.000 0.000 0.000 0.000
#> GSM892368 3 0.000 1.000 0 0.000 1.000 0.000 0.000 0.000
#> GSM892372 3 0.000 1.000 0 0.000 1.000 0.000 0.000 0.000
#> GSM892376 2 0.000 0.930 0 1.000 0.000 0.000 0.000 0.000
#> GSM892380 2 0.000 0.930 0 1.000 0.000 0.000 0.000 0.000
#> GSM892386 2 0.000 0.930 0 1.000 0.000 0.000 0.000 0.000
#> GSM892390 2 0.000 0.930 0 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> ATC:mclust 50 1.000 0.934 2.67e-07 1.42e-03 2
#> ATC:mclust 50 1.000 0.931 1.26e-12 1.60e-05 3
#> ATC:mclust 50 1.000 0.986 6.71e-18 2.02e-07 4
#> ATC:mclust 50 0.987 0.975 6.70e-21 2.57e-08 5
#> ATC:mclust 49 0.692 0.996 8.70e-20 2.73e-06 6
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 31632 rows and 50 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4707 0.530 0.530
#> 3 3 0.809 0.964 0.927 0.3206 0.804 0.630
#> 4 4 0.869 0.883 0.867 0.1320 0.919 0.758
#> 5 5 0.846 0.904 0.897 0.0439 0.984 0.941
#> 6 6 0.807 0.860 0.887 0.0263 1.000 1.000
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 2
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM892342 1 0 1 1 0
#> GSM892345 1 0 1 1 0
#> GSM892349 1 0 1 1 0
#> GSM892353 1 0 1 1 0
#> GSM892355 1 0 1 1 0
#> GSM892361 1 0 1 1 0
#> GSM892365 1 0 1 1 0
#> GSM892369 1 0 1 1 0
#> GSM892373 2 0 1 0 1
#> GSM892377 2 0 1 0 1
#> GSM892381 2 0 1 0 1
#> GSM892383 2 0 1 0 1
#> GSM892387 2 0 1 0 1
#> GSM892344 1 0 1 1 0
#> GSM892347 1 0 1 1 0
#> GSM892351 1 0 1 1 0
#> GSM892357 1 0 1 1 0
#> GSM892359 1 0 1 1 0
#> GSM892363 1 0 1 1 0
#> GSM892367 1 0 1 1 0
#> GSM892371 1 0 1 1 0
#> GSM892375 2 0 1 0 1
#> GSM892379 2 0 1 0 1
#> GSM892385 2 0 1 0 1
#> GSM892389 2 0 1 0 1
#> GSM892341 1 0 1 1 0
#> GSM892346 1 0 1 1 0
#> GSM892350 1 0 1 1 0
#> GSM892354 1 0 1 1 0
#> GSM892356 1 0 1 1 0
#> GSM892362 1 0 1 1 0
#> GSM892366 1 0 1 1 0
#> GSM892370 1 0 1 1 0
#> GSM892374 2 0 1 0 1
#> GSM892378 2 0 1 0 1
#> GSM892382 2 0 1 0 1
#> GSM892384 2 0 1 0 1
#> GSM892388 2 0 1 0 1
#> GSM892343 1 0 1 1 0
#> GSM892348 1 0 1 1 0
#> GSM892352 1 0 1 1 0
#> GSM892358 1 0 1 1 0
#> GSM892360 1 0 1 1 0
#> GSM892364 1 0 1 1 0
#> GSM892368 1 0 1 1 0
#> GSM892372 1 0 1 1 0
#> GSM892376 2 0 1 0 1
#> GSM892380 2 0 1 0 1
#> GSM892386 2 0 1 0 1
#> GSM892390 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM892342 3 0.0000 0.964 0.000 0.000 1.000
#> GSM892345 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892349 1 0.5363 0.940 0.724 0.000 0.276
#> GSM892353 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892355 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892361 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892365 3 0.0000 0.964 0.000 0.000 1.000
#> GSM892369 3 0.0000 0.964 0.000 0.000 1.000
#> GSM892373 2 0.0237 0.988 0.004 0.996 0.000
#> GSM892377 2 0.0237 0.988 0.004 0.996 0.000
#> GSM892381 2 0.0000 0.988 0.000 1.000 0.000
#> GSM892383 2 0.1031 0.981 0.024 0.976 0.000
#> GSM892387 2 0.3619 0.901 0.136 0.864 0.000
#> GSM892344 3 0.2448 0.876 0.076 0.000 0.924
#> GSM892347 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892351 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892357 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892359 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892363 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892367 3 0.0000 0.964 0.000 0.000 1.000
#> GSM892371 3 0.0000 0.964 0.000 0.000 1.000
#> GSM892375 2 0.0592 0.985 0.012 0.988 0.000
#> GSM892379 2 0.0237 0.988 0.004 0.996 0.000
#> GSM892385 2 0.0237 0.988 0.004 0.996 0.000
#> GSM892389 2 0.0592 0.986 0.012 0.988 0.000
#> GSM892341 3 0.0000 0.964 0.000 0.000 1.000
#> GSM892346 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892350 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892354 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892356 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892362 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892366 3 0.0000 0.964 0.000 0.000 1.000
#> GSM892370 3 0.0000 0.964 0.000 0.000 1.000
#> GSM892374 2 0.0237 0.988 0.004 0.996 0.000
#> GSM892378 2 0.0424 0.988 0.008 0.992 0.000
#> GSM892382 2 0.0000 0.988 0.000 1.000 0.000
#> GSM892384 2 0.0592 0.986 0.012 0.988 0.000
#> GSM892388 2 0.0237 0.988 0.004 0.996 0.000
#> GSM892343 3 0.4702 0.618 0.212 0.000 0.788
#> GSM892348 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892352 1 0.6140 0.714 0.596 0.000 0.404
#> GSM892358 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892360 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892364 1 0.5016 0.985 0.760 0.000 0.240
#> GSM892368 3 0.0000 0.964 0.000 0.000 1.000
#> GSM892372 3 0.0000 0.964 0.000 0.000 1.000
#> GSM892376 2 0.0000 0.988 0.000 1.000 0.000
#> GSM892380 2 0.1753 0.967 0.048 0.952 0.000
#> GSM892386 2 0.0000 0.988 0.000 1.000 0.000
#> GSM892390 2 0.0424 0.987 0.008 0.992 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM892342 3 0.1489 0.939 0.004 0.000 0.952 0.044
#> GSM892345 4 0.2546 0.761 0.008 0.000 0.092 0.900
#> GSM892349 4 0.3768 0.710 0.008 0.000 0.184 0.808
#> GSM892353 1 0.6235 0.929 0.524 0.000 0.056 0.420
#> GSM892355 1 0.5982 0.962 0.524 0.000 0.040 0.436
#> GSM892361 1 0.5781 0.908 0.492 0.000 0.028 0.480
#> GSM892365 3 0.0188 0.960 0.000 0.000 0.996 0.004
#> GSM892369 3 0.0000 0.960 0.000 0.000 1.000 0.000
#> GSM892373 2 0.1398 0.971 0.040 0.956 0.000 0.004
#> GSM892377 2 0.0188 0.988 0.000 0.996 0.000 0.004
#> GSM892381 2 0.0376 0.987 0.004 0.992 0.000 0.004
#> GSM892383 2 0.0188 0.988 0.000 0.996 0.000 0.004
#> GSM892387 2 0.1256 0.978 0.028 0.964 0.000 0.008
#> GSM892344 3 0.2861 0.876 0.016 0.000 0.888 0.096
#> GSM892347 4 0.2197 0.761 0.004 0.000 0.080 0.916
#> GSM892351 4 0.3217 0.757 0.012 0.000 0.128 0.860
#> GSM892357 1 0.5894 0.964 0.536 0.000 0.036 0.428
#> GSM892359 1 0.5821 0.965 0.536 0.000 0.032 0.432
#> GSM892363 1 0.5838 0.961 0.524 0.000 0.032 0.444
#> GSM892367 3 0.0000 0.960 0.000 0.000 1.000 0.000
#> GSM892371 3 0.0000 0.960 0.000 0.000 1.000 0.000
#> GSM892375 2 0.0376 0.988 0.004 0.992 0.000 0.004
#> GSM892379 2 0.0376 0.987 0.004 0.992 0.000 0.004
#> GSM892385 2 0.0524 0.987 0.008 0.988 0.000 0.004
#> GSM892389 2 0.0376 0.987 0.004 0.992 0.000 0.004
#> GSM892341 3 0.0895 0.953 0.004 0.000 0.976 0.020
#> GSM892346 4 0.3959 0.594 0.092 0.000 0.068 0.840
#> GSM892350 4 0.2197 0.761 0.004 0.000 0.080 0.916
#> GSM892354 1 0.5808 0.959 0.544 0.000 0.032 0.424
#> GSM892356 1 0.5833 0.964 0.528 0.000 0.032 0.440
#> GSM892362 4 0.5862 -0.921 0.484 0.000 0.032 0.484
#> GSM892366 3 0.0000 0.960 0.000 0.000 1.000 0.000
#> GSM892370 3 0.0592 0.956 0.000 0.000 0.984 0.016
#> GSM892374 2 0.2002 0.959 0.044 0.936 0.000 0.020
#> GSM892378 2 0.0524 0.987 0.008 0.988 0.000 0.004
#> GSM892382 2 0.0188 0.988 0.004 0.996 0.000 0.000
#> GSM892384 2 0.0779 0.985 0.016 0.980 0.000 0.004
#> GSM892388 2 0.1297 0.977 0.016 0.964 0.000 0.020
#> GSM892343 3 0.4370 0.733 0.044 0.000 0.800 0.156
#> GSM892348 4 0.3198 0.701 0.040 0.000 0.080 0.880
#> GSM892352 4 0.4163 0.686 0.020 0.000 0.188 0.792
#> GSM892358 1 0.5888 0.961 0.540 0.000 0.036 0.424
#> GSM892360 1 0.5853 0.944 0.508 0.000 0.032 0.460
#> GSM892364 1 0.5982 0.962 0.524 0.000 0.040 0.436
#> GSM892368 3 0.0000 0.960 0.000 0.000 1.000 0.000
#> GSM892372 3 0.0000 0.960 0.000 0.000 1.000 0.000
#> GSM892376 2 0.0524 0.988 0.008 0.988 0.000 0.004
#> GSM892380 2 0.0524 0.987 0.008 0.988 0.000 0.004
#> GSM892386 2 0.0376 0.988 0.004 0.992 0.000 0.004
#> GSM892390 2 0.0657 0.987 0.012 0.984 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM892342 3 0.5560 0.724 0.060 0.000 0.716 0.132 NA
#> GSM892345 4 0.4250 0.887 0.252 0.000 0.028 0.720 NA
#> GSM892349 4 0.5813 0.831 0.200 0.000 0.116 0.660 NA
#> GSM892353 1 0.3863 0.784 0.836 0.000 0.040 0.072 NA
#> GSM892355 1 0.0867 0.953 0.976 0.000 0.008 0.008 NA
#> GSM892361 1 0.1251 0.945 0.956 0.000 0.000 0.036 NA
#> GSM892365 3 0.1041 0.879 0.004 0.000 0.964 0.000 NA
#> GSM892369 3 0.2131 0.859 0.008 0.000 0.920 0.016 NA
#> GSM892373 2 0.1851 0.950 0.000 0.912 0.000 0.000 NA
#> GSM892377 2 0.0963 0.974 0.000 0.964 0.000 0.000 NA
#> GSM892381 2 0.0609 0.976 0.000 0.980 0.000 0.000 NA
#> GSM892383 2 0.1121 0.968 0.000 0.956 0.000 0.000 NA
#> GSM892387 2 0.0880 0.973 0.000 0.968 0.000 0.000 NA
#> GSM892344 3 0.6836 0.510 0.164 0.000 0.596 0.160 NA
#> GSM892347 4 0.4245 0.883 0.236 0.000 0.020 0.736 NA
#> GSM892351 4 0.5228 0.877 0.244 0.000 0.060 0.680 NA
#> GSM892357 1 0.0404 0.960 0.988 0.000 0.000 0.012 NA
#> GSM892359 1 0.1012 0.955 0.968 0.000 0.000 0.020 NA
#> GSM892363 1 0.0451 0.961 0.988 0.000 0.000 0.008 NA
#> GSM892367 3 0.0794 0.873 0.000 0.000 0.972 0.000 NA
#> GSM892371 3 0.1869 0.870 0.012 0.000 0.936 0.016 NA
#> GSM892375 2 0.0794 0.976 0.000 0.972 0.000 0.000 NA
#> GSM892379 2 0.0510 0.975 0.000 0.984 0.000 0.000 NA
#> GSM892385 2 0.1478 0.962 0.000 0.936 0.000 0.000 NA
#> GSM892389 2 0.0609 0.976 0.000 0.980 0.000 0.000 NA
#> GSM892341 3 0.3905 0.820 0.032 0.000 0.832 0.072 NA
#> GSM892346 4 0.5331 0.748 0.344 0.000 0.008 0.600 NA
#> GSM892350 4 0.4181 0.887 0.244 0.000 0.020 0.732 NA
#> GSM892354 1 0.0807 0.958 0.976 0.000 0.000 0.012 NA
#> GSM892356 1 0.0162 0.962 0.996 0.000 0.000 0.004 NA
#> GSM892362 1 0.0703 0.957 0.976 0.000 0.000 0.024 NA
#> GSM892366 3 0.0671 0.880 0.004 0.000 0.980 0.000 NA
#> GSM892370 3 0.1200 0.877 0.016 0.000 0.964 0.012 NA
#> GSM892374 2 0.1732 0.951 0.000 0.920 0.000 0.000 NA
#> GSM892378 2 0.0609 0.977 0.000 0.980 0.000 0.000 NA
#> GSM892382 2 0.0290 0.975 0.000 0.992 0.000 0.000 NA
#> GSM892384 2 0.0671 0.976 0.000 0.980 0.000 0.004 NA
#> GSM892388 2 0.1764 0.957 0.000 0.928 0.000 0.008 NA
#> GSM892343 3 0.5324 0.642 0.204 0.000 0.696 0.080 NA
#> GSM892348 4 0.4564 0.864 0.272 0.000 0.008 0.696 NA
#> GSM892352 4 0.6182 0.766 0.164 0.000 0.152 0.644 NA
#> GSM892358 1 0.0566 0.953 0.984 0.000 0.000 0.012 NA
#> GSM892360 1 0.0798 0.957 0.976 0.000 0.000 0.016 NA
#> GSM892364 1 0.0290 0.961 0.992 0.000 0.000 0.008 NA
#> GSM892368 3 0.0671 0.880 0.004 0.000 0.980 0.000 NA
#> GSM892372 3 0.0324 0.879 0.004 0.000 0.992 0.000 NA
#> GSM892376 2 0.0880 0.974 0.000 0.968 0.000 0.000 NA
#> GSM892380 2 0.0510 0.975 0.000 0.984 0.000 0.000 NA
#> GSM892386 2 0.0880 0.974 0.000 0.968 0.000 0.000 NA
#> GSM892390 2 0.0880 0.974 0.000 0.968 0.000 0.000 NA
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM892342 3 0.6071 0.501 0.040 0.000 0.500 0.112 NA 0.348
#> GSM892345 4 0.3000 0.883 0.124 0.000 0.032 0.840 NA 0.004
#> GSM892349 4 0.5417 0.782 0.112 0.000 0.100 0.684 NA 0.104
#> GSM892353 1 0.3911 0.769 0.796 0.000 0.032 0.036 NA 0.132
#> GSM892355 1 0.0964 0.959 0.968 0.000 0.004 0.016 NA 0.012
#> GSM892361 1 0.0790 0.955 0.968 0.000 0.000 0.032 NA 0.000
#> GSM892365 3 0.1296 0.797 0.000 0.000 0.948 0.004 NA 0.044
#> GSM892369 3 0.3919 0.754 0.012 0.000 0.816 0.080 NA 0.056
#> GSM892373 2 0.2450 0.907 0.000 0.868 0.000 0.000 NA 0.016
#> GSM892377 2 0.1075 0.958 0.000 0.952 0.000 0.000 NA 0.000
#> GSM892381 2 0.0858 0.962 0.000 0.968 0.000 0.000 NA 0.004
#> GSM892383 2 0.1285 0.955 0.000 0.944 0.000 0.000 NA 0.004
#> GSM892387 2 0.0713 0.963 0.000 0.972 0.000 0.000 NA 0.000
#> GSM892344 3 0.7437 0.106 0.128 0.000 0.344 0.248 NA 0.280
#> GSM892347 4 0.2764 0.876 0.100 0.000 0.028 0.864 NA 0.008
#> GSM892351 4 0.3718 0.874 0.124 0.000 0.052 0.804 NA 0.020
#> GSM892357 1 0.0748 0.962 0.976 0.000 0.000 0.016 NA 0.004
#> GSM892359 1 0.0603 0.960 0.980 0.000 0.000 0.000 NA 0.004
#> GSM892363 1 0.0291 0.963 0.992 0.000 0.000 0.000 NA 0.004
#> GSM892367 3 0.1053 0.789 0.000 0.000 0.964 0.004 NA 0.020
#> GSM892371 3 0.2450 0.786 0.008 0.000 0.896 0.068 NA 0.016
#> GSM892375 2 0.1010 0.963 0.000 0.960 0.000 0.000 NA 0.004
#> GSM892379 2 0.0260 0.963 0.000 0.992 0.000 0.000 NA 0.000
#> GSM892385 2 0.1387 0.951 0.000 0.932 0.000 0.000 NA 0.000
#> GSM892389 2 0.0632 0.963 0.000 0.976 0.000 0.000 NA 0.000
#> GSM892341 3 0.5096 0.671 0.028 0.000 0.700 0.096 NA 0.168
#> GSM892346 4 0.4988 0.809 0.180 0.000 0.012 0.712 NA 0.056
#> GSM892350 4 0.2554 0.877 0.092 0.000 0.028 0.876 NA 0.004
#> GSM892354 1 0.0881 0.961 0.972 0.000 0.000 0.008 NA 0.012
#> GSM892356 1 0.0291 0.963 0.992 0.000 0.000 0.004 NA 0.000
#> GSM892362 1 0.0547 0.961 0.980 0.000 0.000 0.020 NA 0.000
#> GSM892366 3 0.1007 0.797 0.000 0.000 0.956 0.000 NA 0.044
#> GSM892370 3 0.2344 0.786 0.008 0.000 0.896 0.068 NA 0.028
#> GSM892374 2 0.2494 0.902 0.000 0.864 0.000 0.000 NA 0.016
#> GSM892378 2 0.0972 0.962 0.000 0.964 0.000 0.000 NA 0.008
#> GSM892382 2 0.0858 0.962 0.000 0.968 0.000 0.000 NA 0.004
#> GSM892384 2 0.0713 0.963 0.000 0.972 0.000 0.000 NA 0.000
#> GSM892388 2 0.2755 0.889 0.000 0.844 0.000 0.004 NA 0.012
#> GSM892343 3 0.7272 0.290 0.164 0.000 0.468 0.264 NA 0.072
#> GSM892348 4 0.3686 0.870 0.152 0.000 0.024 0.800 NA 0.012
#> GSM892352 4 0.6046 0.701 0.088 0.000 0.128 0.624 NA 0.156
#> GSM892358 1 0.0603 0.959 0.980 0.000 0.000 0.004 NA 0.000
#> GSM892360 1 0.0551 0.963 0.984 0.000 0.000 0.004 NA 0.004
#> GSM892364 1 0.1007 0.960 0.968 0.000 0.004 0.016 NA 0.008
#> GSM892368 3 0.0291 0.796 0.000 0.000 0.992 0.004 NA 0.004
#> GSM892372 3 0.0622 0.798 0.000 0.000 0.980 0.012 NA 0.008
#> GSM892376 2 0.0632 0.964 0.000 0.976 0.000 0.000 NA 0.000
#> GSM892380 2 0.0547 0.964 0.000 0.980 0.000 0.000 NA 0.000
#> GSM892386 2 0.1049 0.961 0.000 0.960 0.000 0.000 NA 0.008
#> GSM892390 2 0.0692 0.963 0.000 0.976 0.000 0.000 NA 0.004
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) disease.state(p) other(p) individual(p) k
#> ATC:NMF 50 1.000 0.934 2.67e-07 1.42e-03 2
#> ATC:NMF 50 1.000 0.931 1.26e-12 1.60e-05 3
#> ATC:NMF 49 0.995 0.961 2.28e-17 4.54e-07 4
#> ATC:NMF 50 1.000 0.986 6.71e-18 2.02e-07 5
#> ATC:NMF 48 1.000 0.962 7.68e-17 3.25e-07 6
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