cola Report for GDS3499

Date: 2019-12-25 20:45:33 CET, cola version: 1.3.2

Document is loading...


Summary

All available functions which can be applied to this res_list object:

res_list
#> A 'ConsensusPartitionList' object with 24 methods.
#>   On a matrix with 51941 rows and 62 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] 51941    62

Density distribution

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)

plot of chunk density-heatmap

Suggest the best k

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 2 1.000 0.969 0.987 **
SD:mclust 2 1.000 0.999 0.999 **
MAD:skmeans 2 1.000 0.998 0.999 **
MAD:mclust 2 1.000 0.995 0.996 **
ATC:hclust 2 1.000 1.000 1.000 **
ATC:kmeans 2 1.000 1.000 1.000 **
SD:skmeans 3 0.999 0.966 0.982 ** 2
SD:NMF 3 0.996 0.953 0.965 ** 2
SD:pam 3 0.978 0.936 0.975 **
MAD:NMF 2 0.965 0.929 0.972 **
ATC:skmeans 4 0.964 0.899 0.961 ** 2,3
ATC:pam 6 0.952 0.901 0.948 ** 2,4,5
MAD:pam 3 0.933 0.921 0.966 * 2
ATC:NMF 3 0.918 0.888 0.952 * 2
MAD:kmeans 3 0.890 0.926 0.949
ATC:mclust 2 0.791 0.950 0.973
CV:NMF 2 0.771 0.887 0.954
SD:kmeans 3 0.747 0.920 0.916
CV:mclust 4 0.709 0.806 0.872
MAD:hclust 2 0.704 0.800 0.921
CV:kmeans 2 0.541 0.803 0.899
CV:skmeans 2 0.517 0.810 0.903
CV:pam 2 0.220 0.781 0.856
CV:hclust 4 0.102 0.595 0.731

**: 1-PAC > 0.95, *: 1-PAC > 0.9

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

Consensus heatmaps for all methods. (What is a consensus heatmap?)

collect_plots(res_list, k = 2, fun = consensus_heatmap, mc.cores = 4)

plot of chunk tab-collect-consensus-heatmap-1

collect_plots(res_list, k = 3, fun = consensus_heatmap, mc.cores = 4)

plot of chunk tab-collect-consensus-heatmap-2

collect_plots(res_list, k = 4, fun = consensus_heatmap, mc.cores = 4)

plot of chunk tab-collect-consensus-heatmap-3

collect_plots(res_list, k = 5, fun = consensus_heatmap, mc.cores = 4)

plot of chunk tab-collect-consensus-heatmap-4

collect_plots(res_list, k = 6, fun = consensus_heatmap, mc.cores = 4)

plot of chunk tab-collect-consensus-heatmap-5

Membership heatmap

Membership heatmaps for all methods. (What is a membership heatmap?)

collect_plots(res_list, k = 2, fun = membership_heatmap, mc.cores = 4)

plot of chunk tab-collect-membership-heatmap-1

collect_plots(res_list, k = 3, fun = membership_heatmap, mc.cores = 4)

plot of chunk tab-collect-membership-heatmap-2

collect_plots(res_list, k = 4, fun = membership_heatmap, mc.cores = 4)

plot of chunk tab-collect-membership-heatmap-3

collect_plots(res_list, k = 5, fun = membership_heatmap, mc.cores = 4)

plot of chunk tab-collect-membership-heatmap-4

collect_plots(res_list, k = 6, fun = membership_heatmap, mc.cores = 4)

plot of chunk tab-collect-membership-heatmap-5

Signature heatmap

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)

plot of chunk tab-collect-get-signatures-1

collect_plots(res_list, k = 3, fun = get_signatures, mc.cores = 4)

plot of chunk tab-collect-get-signatures-2

collect_plots(res_list, k = 4, fun = get_signatures, mc.cores = 4)

plot of chunk tab-collect-get-signatures-3

collect_plots(res_list, k = 5, fun = get_signatures, mc.cores = 4)

plot of chunk tab-collect-get-signatures-4

collect_plots(res_list, k = 6, fun = get_signatures, mc.cores = 4)

plot of chunk tab-collect-get-signatures-5

Statistics table

The statistics used for measuring the stability of consensus partitioning. (How are they defined?)

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 1.000           0.967       0.986          0.482 0.518   0.518
#> CV:NMF      2 0.771           0.887       0.954          0.504 0.494   0.494
#> MAD:NMF     2 0.965           0.929       0.972          0.497 0.505   0.505
#> ATC:NMF     2 1.000           0.988       0.994          0.484 0.518   0.518
#> SD:skmeans  2 0.937           0.960       0.981          0.488 0.518   0.518
#> CV:skmeans  2 0.517           0.810       0.903          0.507 0.492   0.492
#> MAD:skmeans 2 1.000           0.998       0.999          0.508 0.492   0.492
#> ATC:skmeans 2 1.000           1.000       1.000          0.483 0.518   0.518
#> SD:mclust   2 1.000           0.999       0.999          0.508 0.492   0.492
#> CV:mclust   2 0.531           0.662       0.871          0.445 0.518   0.518
#> MAD:mclust  2 1.000           0.995       0.996          0.507 0.492   0.492
#> ATC:mclust  2 0.791           0.950       0.973          0.466 0.545   0.545
#> SD:kmeans   2 0.725           0.910       0.952          0.478 0.535   0.535
#> CV:kmeans   2 0.541           0.803       0.899          0.469 0.511   0.511
#> MAD:kmeans  2 0.768           0.827       0.933          0.491 0.518   0.518
#> ATC:kmeans  2 1.000           1.000       1.000          0.466 0.535   0.535
#> SD:pam      2 0.867           0.912       0.962          0.498 0.497   0.497
#> CV:pam      2 0.220           0.781       0.856          0.475 0.497   0.497
#> MAD:pam     2 1.000           0.941       0.977          0.508 0.492   0.492
#> ATC:pam     2 1.000           1.000       1.000          0.466 0.535   0.535
#> SD:hclust   2 1.000           0.969       0.987          0.463 0.545   0.545
#> CV:hclust   2 0.551           0.893       0.922          0.124 0.968   0.968
#> MAD:hclust  2 0.704           0.800       0.921          0.483 0.526   0.526
#> ATC:hclust  2 1.000           1.000       1.000          0.456 0.545   0.545
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.996           0.953       0.965          0.394 0.755   0.549
#> CV:NMF      3 0.514           0.725       0.835          0.278 0.799   0.620
#> MAD:NMF     3 0.744           0.889       0.919          0.338 0.745   0.529
#> ATC:NMF     3 0.918           0.888       0.952          0.373 0.774   0.581
#> SD:skmeans  3 0.999           0.966       0.982          0.379 0.774   0.577
#> CV:skmeans  3 0.246           0.516       0.707          0.316 0.813   0.635
#> MAD:skmeans 3 0.866           0.895       0.949          0.285 0.857   0.712
#> ATC:skmeans 3 1.000           0.979       0.993          0.303 0.841   0.698
#> SD:mclust   3 0.774           0.763       0.883          0.304 0.774   0.570
#> CV:mclust   3 0.523           0.660       0.823          0.433 0.764   0.568
#> MAD:mclust  3 0.730           0.751       0.877          0.285 0.851   0.705
#> ATC:mclust  3 0.860           0.907       0.952          0.415 0.794   0.621
#> SD:kmeans   3 0.747           0.920       0.916          0.357 0.770   0.577
#> CV:kmeans   3 0.563           0.680       0.803          0.327 0.830   0.675
#> MAD:kmeans  3 0.890           0.926       0.949          0.304 0.814   0.651
#> ATC:kmeans  3 0.727           0.867       0.904          0.387 0.777   0.590
#> SD:pam      3 0.978           0.936       0.975          0.334 0.783   0.587
#> CV:pam      3 0.242           0.712       0.797          0.311 0.877   0.756
#> MAD:pam     3 0.933           0.921       0.966          0.304 0.805   0.622
#> ATC:pam     3 0.819           0.873       0.932          0.418 0.789   0.611
#> SD:hclust   3 0.761           0.799       0.908          0.425 0.784   0.604
#> CV:hclust   3 0.233           0.474       0.597          1.898 0.511   0.495
#> MAD:hclust  3 0.707           0.863       0.894          0.287 0.825   0.674
#> ATC:hclust  3 0.863           0.797       0.923          0.401 0.808   0.647
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.886           0.889       0.943         0.1058 0.914   0.744
#> CV:NMF      4 0.693           0.729       0.860         0.1552 0.829   0.565
#> MAD:NMF     4 0.876           0.868       0.931         0.1114 0.914   0.744
#> ATC:NMF     4 0.776           0.737       0.898         0.0632 0.929   0.802
#> SD:skmeans  4 0.721           0.758       0.812         0.0965 0.942   0.826
#> CV:skmeans  4 0.286           0.180       0.509         0.1237 0.810   0.519
#> MAD:skmeans 4 0.678           0.750       0.819         0.1265 0.909   0.750
#> ATC:skmeans 4 0.964           0.899       0.961         0.1013 0.926   0.807
#> SD:mclust   4 0.826           0.891       0.882         0.0872 0.869   0.651
#> CV:mclust   4 0.709           0.806       0.872         0.1548 0.838   0.571
#> MAD:mclust  4 0.779           0.859       0.894         0.0980 0.821   0.571
#> ATC:mclust  4 0.771           0.737       0.849         0.0995 0.928   0.791
#> SD:kmeans   4 0.731           0.803       0.845         0.1196 1.000   1.000
#> CV:kmeans   4 0.621           0.731       0.820         0.1425 0.815   0.543
#> MAD:kmeans  4 0.780           0.736       0.851         0.1196 0.947   0.853
#> ATC:kmeans  4 0.728           0.724       0.777         0.1182 0.880   0.658
#> SD:pam      4 0.852           0.792       0.895         0.1119 0.915   0.750
#> CV:pam      4 0.446           0.583       0.763         0.1615 0.833   0.595
#> MAD:pam     4 0.742           0.786       0.824         0.0992 1.000   1.000
#> ATC:pam     4 0.999           0.944       0.973         0.1353 0.860   0.615
#> SD:hclust   4 0.705           0.607       0.838         0.0850 0.979   0.936
#> CV:hclust   4 0.102           0.595       0.731         0.4356 0.719   0.551
#> MAD:hclust  4 0.755           0.765       0.887         0.0867 0.985   0.959
#> ATC:hclust  4 0.793           0.736       0.861         0.1379 0.873   0.660
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.782           0.780       0.864         0.0481 0.967   0.880
#> CV:NMF      5 0.627           0.665       0.761         0.0641 0.970   0.890
#> MAD:NMF     5 0.748           0.756       0.844         0.0520 0.967   0.880
#> ATC:NMF     5 0.753           0.760       0.879         0.0746 0.895   0.683
#> SD:skmeans  5 0.692           0.577       0.747         0.0583 0.955   0.843
#> CV:skmeans  5 0.361           0.291       0.543         0.0671 0.833   0.476
#> MAD:skmeans 5 0.627           0.594       0.756         0.0582 0.960   0.861
#> ATC:skmeans 5 0.879           0.730       0.868         0.0545 0.995   0.983
#> SD:mclust   5 0.691           0.653       0.793         0.0630 0.955   0.844
#> CV:mclust   5 0.714           0.736       0.836         0.0668 0.921   0.703
#> MAD:mclust  5 0.861           0.914       0.904         0.0727 0.924   0.743
#> ATC:mclust  5 0.703           0.610       0.781         0.0768 0.929   0.753
#> SD:kmeans   5 0.721           0.700       0.708         0.0653 0.912   0.729
#> CV:kmeans   5 0.658           0.670       0.798         0.0631 0.961   0.857
#> MAD:kmeans  5 0.710           0.656       0.796         0.0640 0.937   0.799
#> ATC:kmeans  5 0.748           0.710       0.758         0.0768 0.947   0.808
#> SD:pam      5 0.732           0.642       0.807         0.0618 0.939   0.765
#> CV:pam      5 0.514           0.510       0.740         0.0460 0.938   0.789
#> MAD:pam     5 0.693           0.679       0.812         0.0742 0.858   0.603
#> ATC:pam     5 0.982           0.918       0.961         0.0658 0.952   0.809
#> SD:hclust   5 0.722           0.651       0.786         0.0522 0.936   0.800
#> CV:hclust   5 0.149           0.596       0.709         0.1626 0.912   0.823
#> MAD:hclust  5 0.708           0.721       0.845         0.0764 0.927   0.794
#> ATC:hclust  5 0.838           0.703       0.862         0.0323 0.966   0.876
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.705           0.569       0.773         0.0483 0.943   0.786
#> CV:NMF      6 0.615           0.362       0.667         0.0424 0.948   0.807
#> MAD:NMF     6 0.689           0.612       0.768         0.0443 0.941   0.777
#> ATC:NMF     6 0.665           0.646       0.790         0.0417 0.941   0.773
#> SD:skmeans  6 0.642           0.533       0.700         0.0377 0.932   0.740
#> CV:skmeans  6 0.453           0.297       0.500         0.0417 0.919   0.687
#> MAD:skmeans 6 0.600           0.519       0.698         0.0409 0.963   0.856
#> ATC:skmeans 6 0.838           0.581       0.789         0.0439 0.906   0.703
#> SD:mclust   6 0.787           0.828       0.854         0.0561 0.932   0.727
#> CV:mclust   6 0.687           0.535       0.768         0.0401 0.996   0.979
#> MAD:mclust  6 0.862           0.855       0.888         0.0500 0.966   0.852
#> ATC:mclust  6 0.860           0.817       0.883         0.0560 0.873   0.508
#> SD:kmeans   6 0.714           0.661       0.753         0.0456 0.935   0.735
#> CV:kmeans   6 0.687           0.542       0.745         0.0445 0.961   0.852
#> MAD:kmeans  6 0.716           0.725       0.778         0.0526 0.923   0.714
#> ATC:kmeans  6 0.747           0.612       0.710         0.0404 0.942   0.767
#> SD:pam      6 0.744           0.670       0.792         0.0269 0.940   0.728
#> CV:pam      6 0.549           0.527       0.747         0.0461 0.911   0.681
#> MAD:pam     6 0.714           0.626       0.808         0.0304 0.956   0.812
#> ATC:pam     6 0.952           0.901       0.948         0.0431 0.953   0.777
#> SD:hclust   6 0.731           0.647       0.788         0.0305 0.966   0.874
#> CV:hclust   6 0.403           0.357       0.699         0.1546 0.922   0.816
#> MAD:hclust  6 0.711           0.683       0.788         0.0560 0.957   0.847
#> ATC:hclust  6 0.788           0.667       0.823         0.0279 0.981   0.924

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)

plot of chunk tab-collect-stats-from-consensus-partition-list-1

collect_stats(res_list, k = 3)

plot of chunk tab-collect-stats-from-consensus-partition-list-2

collect_stats(res_list, k = 4)

plot of chunk tab-collect-stats-from-consensus-partition-list-3

collect_stats(res_list, k = 5)

plot of chunk tab-collect-stats-from-consensus-partition-list-4

collect_stats(res_list, k = 6)

plot of chunk tab-collect-stats-from-consensus-partition-list-5

Partition from all methods

Collect partitions from all methods:

collect_classes(res_list, k = 2)

plot of chunk tab-collect-classes-from-consensus-partition-list-1

collect_classes(res_list, k = 3)

plot of chunk tab-collect-classes-from-consensus-partition-list-2

collect_classes(res_list, k = 4)

plot of chunk tab-collect-classes-from-consensus-partition-list-3

collect_classes(res_list, k = 5)

plot of chunk tab-collect-classes-from-consensus-partition-list-4

collect_classes(res_list, k = 6)

plot of chunk tab-collect-classes-from-consensus-partition-list-5

Top rows overlap

Overlap of top rows from different top-row methods:

top_rows_overlap(res_list, top_n = 1000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-1

top_rows_overlap(res_list, top_n = 2000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-2

top_rows_overlap(res_list, top_n = 3000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-3

top_rows_overlap(res_list, top_n = 4000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-4

top_rows_overlap(res_list, top_n = 5000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-5

Also visualize the correspondance of rankings between different top-row methods:

top_rows_overlap(res_list, top_n = 1000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-1

top_rows_overlap(res_list, top_n = 2000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-2

top_rows_overlap(res_list, top_n = 3000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-3

top_rows_overlap(res_list, top_n = 4000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-4

top_rows_overlap(res_list, top_n = 5000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-5

Heatmaps of the top rows:

top_rows_heatmap(res_list, top_n = 1000)

plot of chunk tab-top-rows-heatmap-1

top_rows_heatmap(res_list, top_n = 2000)

plot of chunk tab-top-rows-heatmap-2

top_rows_heatmap(res_list, top_n = 3000)

plot of chunk tab-top-rows-heatmap-3

top_rows_heatmap(res_list, top_n = 4000)

plot of chunk tab-top-rows-heatmap-4

top_rows_heatmap(res_list, top_n = 5000)

plot of chunk tab-top-rows-heatmap-5

Test to known annotations

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 agent(p) individual(p) k
#> SD:NMF      61 1.92e-10         0.988 2
#> CV:NMF      59 3.79e-09         0.899 2
#> MAD:NMF     60 9.25e-10         0.984 2
#> ATC:NMF     62 3.69e-10         0.970 2
#> SD:skmeans  61 4.91e-10         0.973 2
#> CV:skmeans  57 5.06e-11         0.990 2
#> MAD:skmeans 62 4.69e-12         1.000 2
#> ATC:skmeans 62 3.69e-10         0.970 2
#> SD:mclust   62 4.69e-12         1.000 2
#> CV:mclust   46 2.46e-09         0.977 2
#> MAD:mclust  62 4.69e-12         1.000 2
#> ATC:mclust  61 7.55e-12         1.000 2
#> SD:kmeans   62 3.10e-11         0.996 2
#> CV:kmeans   55 1.31e-10         0.997 2
#> MAD:kmeans  53 3.36e-10         0.999 2
#> ATC:kmeans  62 3.10e-11         0.996 2
#> SD:pam      59 9.46e-10         0.996 2
#> CV:pam      57 5.06e-11         0.873 2
#> MAD:pam     60 1.22e-11         1.000 2
#> ATC:pam     62 3.10e-11         0.996 2
#> SD:hclust   61 7.55e-12         1.000 2
#> CV:hclust   61       NA            NA 2
#> MAD:hclust  52 5.39e-10         1.000 2
#> ATC:hclust  62 4.69e-12         1.000 2
test_to_known_factors(res_list, k = 3)
#>              n agent(p) individual(p) k
#> SD:NMF      62 7.33e-20        1.0000 3
#> CV:NMF      56 1.86e-07        0.0141 3
#> MAD:NMF     60 4.01e-19        1.0000 3
#> ATC:NMF     58 2.27e-18        1.0000 3
#> SD:skmeans  62 1.18e-18        0.9998 3
#> CV:skmeans  37 7.45e-12        0.8203 3
#> MAD:skmeans 59 2.27e-19        1.0000 3
#> ATC:skmeans 61 8.57e-20        1.0000 3
#> SD:mclust   55 2.47e-15        0.9454 3
#> CV:mclust   51 3.98e-16        0.9979 3
#> MAD:mclust  50 5.45e-17        1.0000 3
#> ATC:mclust  59 2.52e-19        0.9998 3
#> SD:kmeans   60 4.71e-19        1.0000 3
#> CV:kmeans   46 2.15e-15        0.9992 3
#> MAD:kmeans  62 1.68e-20        1.0000 3
#> ATC:kmeans  57 1.71e-15        0.9052 3
#> SD:pam      60 2.15e-18        1.0000 3
#> CV:pam      56 2.42e-08        0.1067 3
#> MAD:pam     60 6.38e-19        1.0000 3
#> ATC:pam     60 2.86e-17        0.9804 3
#> SD:hclust   54 1.20e-17        1.0000 3
#> CV:hclust   43 1.03e-08        0.7752 3
#> MAD:hclust  61 1.99e-21        1.0000 3
#> ATC:hclust  51 2.17e-17        0.9403 3
test_to_known_factors(res_list, k = 4)
#>              n agent(p) individual(p) k
#> SD:NMF      60 7.79e-15        0.1815 4
#> CV:NMF      52 4.85e-10        0.0368 4
#> MAD:NMF     59 2.01e-14        0.2173 4
#> ATC:NMF     54 1.72e-17        0.9986 4
#> SD:skmeans  57 1.54e-28        1.0000 4
#> CV:skmeans   2       NA            NA 4
#> MAD:skmeans 55 2.46e-27        1.0000 4
#> ATC:skmeans 59 1.22e-16        0.6047 4
#> SD:mclust   62 3.45e-18        0.9723 4
#> CV:mclust   59 1.19e-12        0.2300 4
#> MAD:mclust  61 1.28e-18        0.9794 4
#> ATC:mclust  55 2.41e-15        0.7257 4
#> SD:kmeans   61 1.97e-19        1.0000 4
#> CV:kmeans   51 6.03e-14        0.8547 4
#> MAD:kmeans  56 6.16e-28        1.0000 4
#> ATC:kmeans  51 1.02e-15        0.6871 4
#> SD:pam      56 6.12e-15        0.3402 4
#> CV:pam      46 8.27e-08        0.0221 4
#> MAD:pam     59 1.26e-18        1.0000 4
#> ATC:pam     61 9.07e-18        0.5930 4
#> SD:hclust   49 7.88e-16        0.9994 4
#> CV:hclust   49 1.62e-08        0.8975 4
#> MAD:hclust  53 3.41e-18        0.9998 4
#> ATC:hclust  47 1.71e-13        0.3671 4
test_to_known_factors(res_list, k = 5)
#>              n agent(p) individual(p) k
#> SD:NMF      59 1.08e-13        0.2709 5
#> CV:NMF      49 1.31e-10        0.0471 5
#> MAD:NMF     54 6.11e-14        0.4059 5
#> ATC:NMF     57 1.44e-11        0.0550 5
#> SD:skmeans  48 3.73e-23        0.9997 5
#> CV:skmeans  10       NA            NA 5
#> MAD:skmeans 47 1.46e-22        0.9914 5
#> ATC:skmeans 50 2.37e-15        0.7859 5
#> SD:mclust   48 9.18e-13        0.3439 5
#> CV:mclust   55 7.08e-14        0.2972 5
#> MAD:mclust  61 3.57e-29        0.9992 5
#> ATC:mclust  48 2.79e-11        0.1170 5
#> SD:kmeans   55 9.45e-24        0.9073 5
#> CV:kmeans   50 1.95e-13        0.5615 5
#> MAD:kmeans  54 9.79e-27        1.0000 5
#> ATC:kmeans  55 3.17e-18        0.7260 5
#> SD:pam      49 2.95e-11        0.0710 5
#> CV:pam      43 4.61e-07        0.0202 5
#> MAD:pam     47 9.51e-11        0.2914 5
#> ATC:pam     59 7.90e-16        0.1639 5
#> SD:hclust   48 2.37e-21        1.0000 5
#> CV:hclust   47 3.95e-08        0.9216 5
#> MAD:hclust  56 2.64e-24        1.0000 5
#> ATC:hclust  48 2.80e-12        0.6286 5
test_to_known_factors(res_list, k = 6)
#>              n agent(p) individual(p) k
#> SD:NMF      42 1.41e-07        0.0792 6
#> CV:NMF      24 9.14e-04        0.0811 6
#> MAD:NMF     49 5.83e-12        0.2247 6
#> ATC:NMF     49 4.00e-12        0.1747 6
#> SD:skmeans  39 7.22e-18        0.9948 6
#> CV:skmeans  14 3.01e-01        0.0818 6
#> MAD:skmeans 37 7.82e-13        0.9896 6
#> ATC:skmeans 40 7.02e-16        0.7928 6
#> SD:mclust   60 1.67e-24        0.8737 6
#> CV:mclust   40 3.44e-14        0.9431 6
#> MAD:mclust  60 3.12e-26        0.8679 6
#> ATC:mclust  60 6.03e-21        0.7248 6
#> SD:kmeans   54 9.41e-23        0.4278 6
#> CV:kmeans   39 2.77e-10        0.2120 6
#> MAD:kmeans  55 1.51e-24        0.6533 6
#> ATC:kmeans  52 1.63e-14        0.2066 6
#> SD:pam      53 1.25e-12        0.1240 6
#> CV:pam      39 7.93e-07        0.0617 6
#> MAD:pam     41 3.59e-09        0.1414 6
#> ATC:pam     60 1.14e-15        0.0625 6
#> SD:hclust   50 2.04e-19        0.1109 6
#> CV:hclust   29 8.64e-09        0.7233 6
#> MAD:hclust  51 3.39e-23        0.5806 6
#> ATC:hclust  47 1.63e-12        0.6494 6

Results for each method


SD:hclust**

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 51941 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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:

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)

plot of chunk SD-hclust-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.969       0.987         0.4632 0.545   0.545
#> 3 3 0.761           0.799       0.908         0.4249 0.784   0.604
#> 4 4 0.705           0.607       0.838         0.0850 0.979   0.936
#> 5 5 0.722           0.651       0.786         0.0522 0.936   0.800
#> 6 6 0.731           0.647       0.788         0.0305 0.966   0.874

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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1  0.0000      0.980 1.000 0.000
#> GSM252429     1  0.0000      0.980 1.000 0.000
#> GSM252424     1  0.0000      0.980 1.000 0.000
#> GSM252432     1  0.0000      0.980 1.000 0.000
#> GSM252427     1  0.0000      0.980 1.000 0.000
#> GSM252431     1  0.6247      0.818 0.844 0.156
#> GSM252430     1  0.9944      0.182 0.544 0.456
#> GSM252433     1  0.4022      0.906 0.920 0.080
#> GSM252426     1  0.0000      0.980 1.000 0.000
#> GSM252428     1  0.0376      0.977 0.996 0.004
#> GSM252425     1  0.4161      0.902 0.916 0.084
#> GSM252440     1  0.0000      0.980 1.000 0.000
#> GSM252441     1  0.0000      0.980 1.000 0.000
#> GSM252436     1  0.0000      0.980 1.000 0.000
#> GSM252435     1  0.0000      0.980 1.000 0.000
#> GSM252442     1  0.0000      0.980 1.000 0.000
#> GSM252439     1  0.0000      0.980 1.000 0.000
#> GSM252438     1  0.0000      0.980 1.000 0.000
#> GSM252434     1  0.0000      0.980 1.000 0.000
#> GSM252437     1  0.0000      0.980 1.000 0.000
#> GSM252451     1  0.0000      0.980 1.000 0.000
#> GSM252448     1  0.0000      0.980 1.000 0.000
#> GSM252447     1  0.0000      0.980 1.000 0.000
#> GSM252444     1  0.0000      0.980 1.000 0.000
#> GSM252450     1  0.0000      0.980 1.000 0.000
#> GSM252452     1  0.0000      0.980 1.000 0.000
#> GSM252443     1  0.0000      0.980 1.000 0.000
#> GSM252454     1  0.0000      0.980 1.000 0.000
#> GSM252449     1  0.0000      0.980 1.000 0.000
#> GSM252445     1  0.0000      0.980 1.000 0.000
#> GSM252453     1  0.0000      0.980 1.000 0.000
#> GSM252464     1  0.0000      0.980 1.000 0.000
#> GSM252463     1  0.0000      0.980 1.000 0.000
#> GSM252461     1  0.0000      0.980 1.000 0.000
#> GSM252455     1  0.0000      0.980 1.000 0.000
#> GSM252458     1  0.0000      0.980 1.000 0.000
#> GSM252460     1  0.0000      0.980 1.000 0.000
#> GSM252457     1  0.0000      0.980 1.000 0.000
#> GSM252456     1  0.0000      0.980 1.000 0.000
#> GSM252462     1  0.0000      0.980 1.000 0.000
#> GSM252459     1  0.0000      0.980 1.000 0.000
#> GSM252472     2  0.0000      1.000 0.000 1.000
#> GSM252466     2  0.0000      1.000 0.000 1.000
#> GSM252469     2  0.0000      1.000 0.000 1.000
#> GSM252475     2  0.0000      1.000 0.000 1.000
#> GSM252471     2  0.0000      1.000 0.000 1.000
#> GSM252465     2  0.0000      1.000 0.000 1.000
#> GSM252474     2  0.0000      1.000 0.000 1.000
#> GSM252473     2  0.0000      1.000 0.000 1.000
#> GSM252468     2  0.0000      1.000 0.000 1.000
#> GSM252470     2  0.0376      0.996 0.004 0.996
#> GSM252467     2  0.0000      1.000 0.000 1.000
#> GSM252485     2  0.0000      1.000 0.000 1.000
#> GSM252481     2  0.0000      1.000 0.000 1.000
#> GSM252480     2  0.0000      1.000 0.000 1.000
#> GSM252479     2  0.0000      1.000 0.000 1.000
#> GSM252482     2  0.0000      1.000 0.000 1.000
#> GSM252478     2  0.0000      1.000 0.000 1.000
#> GSM252483     2  0.0000      1.000 0.000 1.000
#> GSM252477     2  0.0000      1.000 0.000 1.000
#> GSM252484     2  0.0000      1.000 0.000 1.000
#> GSM252476     2  0.0000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.0000     0.7864 0.000 0.000 1.000
#> GSM252429     3  0.0000     0.7864 0.000 0.000 1.000
#> GSM252424     3  0.0000     0.7864 0.000 0.000 1.000
#> GSM252432     3  0.0000     0.7864 0.000 0.000 1.000
#> GSM252427     3  0.0892     0.7849 0.020 0.000 0.980
#> GSM252431     3  0.3941     0.7014 0.000 0.156 0.844
#> GSM252430     3  0.6489     0.1593 0.004 0.456 0.540
#> GSM252433     3  0.2955     0.7534 0.008 0.080 0.912
#> GSM252426     3  0.0000     0.7864 0.000 0.000 1.000
#> GSM252428     3  0.1765     0.7785 0.040 0.004 0.956
#> GSM252425     3  0.6063     0.6878 0.132 0.084 0.784
#> GSM252440     1  0.0000     0.8527 1.000 0.000 0.000
#> GSM252441     1  0.0000     0.8527 1.000 0.000 0.000
#> GSM252436     1  0.0000     0.8527 1.000 0.000 0.000
#> GSM252435     1  0.1860     0.8563 0.948 0.000 0.052
#> GSM252442     1  0.3116     0.8286 0.892 0.000 0.108
#> GSM252439     1  0.4654     0.7290 0.792 0.000 0.208
#> GSM252438     1  0.5948     0.5139 0.640 0.000 0.360
#> GSM252434     1  0.1753     0.8575 0.952 0.000 0.048
#> GSM252437     1  0.1753     0.8575 0.952 0.000 0.048
#> GSM252451     1  0.0237     0.8538 0.996 0.000 0.004
#> GSM252448     1  0.0000     0.8527 1.000 0.000 0.000
#> GSM252447     1  0.0000     0.8527 1.000 0.000 0.000
#> GSM252444     1  0.0000     0.8527 1.000 0.000 0.000
#> GSM252450     1  0.1860     0.8563 0.948 0.000 0.052
#> GSM252452     1  0.0592     0.8554 0.988 0.000 0.012
#> GSM252443     1  0.4121     0.7759 0.832 0.000 0.168
#> GSM252454     1  0.3038     0.8363 0.896 0.000 0.104
#> GSM252449     1  0.1753     0.8575 0.952 0.000 0.048
#> GSM252445     1  0.1753     0.8575 0.952 0.000 0.048
#> GSM252453     1  0.3816     0.8047 0.852 0.000 0.148
#> GSM252464     3  0.5859     0.4661 0.344 0.000 0.656
#> GSM252463     3  0.0747     0.7859 0.016 0.000 0.984
#> GSM252461     1  0.6291     0.0589 0.532 0.000 0.468
#> GSM252455     3  0.6192     0.2978 0.420 0.000 0.580
#> GSM252458     3  0.5621     0.5254 0.308 0.000 0.692
#> GSM252460     3  0.5835     0.4716 0.340 0.000 0.660
#> GSM252457     1  0.6215     0.2878 0.572 0.000 0.428
#> GSM252456     3  0.5859     0.4635 0.344 0.000 0.656
#> GSM252462     1  0.6274     0.1422 0.544 0.000 0.456
#> GSM252459     1  0.4121     0.7892 0.832 0.000 0.168
#> GSM252472     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252466     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252469     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252475     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252471     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252465     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252474     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252473     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252468     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252470     2  0.0237     0.9953 0.004 0.996 0.000
#> GSM252467     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252485     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252481     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252480     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252479     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252482     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252478     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252483     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252477     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252484     2  0.0000     0.9998 0.000 1.000 0.000
#> GSM252476     2  0.0000     0.9998 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.0188     0.6446 0.000 0.000 0.996 0.004
#> GSM252429     3  0.2814     0.6218 0.000 0.000 0.868 0.132
#> GSM252424     3  0.0000     0.6443 0.000 0.000 1.000 0.000
#> GSM252432     3  0.0188     0.6446 0.000 0.000 0.996 0.004
#> GSM252427     3  0.2149     0.6236 0.000 0.000 0.912 0.088
#> GSM252431     3  0.3694     0.5645 0.000 0.124 0.844 0.032
#> GSM252430     3  0.7510     0.2462 0.008 0.324 0.508 0.160
#> GSM252433     3  0.4658     0.5515 0.008 0.036 0.788 0.168
#> GSM252426     3  0.0188     0.6446 0.000 0.000 0.996 0.004
#> GSM252428     3  0.3340     0.6104 0.004 0.004 0.848 0.144
#> GSM252425     3  0.6899     0.4042 0.096 0.064 0.680 0.160
#> GSM252440     1  0.1118     0.7044 0.964 0.000 0.000 0.036
#> GSM252441     1  0.1118     0.7044 0.964 0.000 0.000 0.036
#> GSM252436     1  0.1302     0.7041 0.956 0.000 0.000 0.044
#> GSM252435     1  0.3707     0.6425 0.840 0.000 0.028 0.132
#> GSM252442     1  0.4323     0.5898 0.788 0.000 0.028 0.184
#> GSM252439     1  0.5807     0.2495 0.636 0.000 0.052 0.312
#> GSM252438     4  0.6552    -0.2709 0.440 0.000 0.076 0.484
#> GSM252434     1  0.2413     0.6991 0.916 0.000 0.020 0.064
#> GSM252437     1  0.2489     0.6987 0.912 0.000 0.020 0.068
#> GSM252451     1  0.1398     0.7080 0.956 0.000 0.004 0.040
#> GSM252448     1  0.1118     0.7044 0.964 0.000 0.000 0.036
#> GSM252447     1  0.1118     0.7044 0.964 0.000 0.000 0.036
#> GSM252444     1  0.1302     0.7041 0.956 0.000 0.000 0.044
#> GSM252450     1  0.3707     0.6425 0.840 0.000 0.028 0.132
#> GSM252452     1  0.3172     0.6448 0.840 0.000 0.000 0.160
#> GSM252443     1  0.5308     0.3668 0.684 0.000 0.036 0.280
#> GSM252454     1  0.3674     0.6498 0.848 0.000 0.036 0.116
#> GSM252449     1  0.2413     0.6991 0.916 0.000 0.020 0.064
#> GSM252445     1  0.2489     0.6987 0.912 0.000 0.020 0.068
#> GSM252453     1  0.4224     0.5992 0.812 0.000 0.044 0.144
#> GSM252464     3  0.7338    -0.1133 0.156 0.000 0.440 0.404
#> GSM252463     3  0.3583     0.5959 0.004 0.000 0.816 0.180
#> GSM252461     1  0.7905    -0.4657 0.364 0.000 0.332 0.304
#> GSM252455     4  0.7752    -0.2277 0.236 0.000 0.360 0.404
#> GSM252458     3  0.7162    -0.0283 0.136 0.000 0.472 0.392
#> GSM252460     3  0.7281    -0.1109 0.148 0.000 0.440 0.412
#> GSM252457     1  0.7717    -0.2817 0.444 0.000 0.252 0.304
#> GSM252456     3  0.7340    -0.1314 0.156 0.000 0.436 0.408
#> GSM252462     1  0.7732    -0.3976 0.388 0.000 0.228 0.384
#> GSM252459     1  0.4614     0.5772 0.792 0.000 0.064 0.144
#> GSM252472     2  0.0000     0.9757 0.000 1.000 0.000 0.000
#> GSM252466     2  0.0000     0.9757 0.000 1.000 0.000 0.000
#> GSM252469     2  0.0000     0.9757 0.000 1.000 0.000 0.000
#> GSM252475     2  0.0000     0.9757 0.000 1.000 0.000 0.000
#> GSM252471     2  0.0000     0.9757 0.000 1.000 0.000 0.000
#> GSM252465     2  0.0000     0.9757 0.000 1.000 0.000 0.000
#> GSM252474     2  0.2704     0.8990 0.000 0.876 0.000 0.124
#> GSM252473     2  0.0000     0.9757 0.000 1.000 0.000 0.000
#> GSM252468     2  0.0000     0.9757 0.000 1.000 0.000 0.000
#> GSM252470     2  0.0188     0.9726 0.004 0.996 0.000 0.000
#> GSM252467     2  0.0000     0.9757 0.000 1.000 0.000 0.000
#> GSM252485     2  0.0000     0.9757 0.000 1.000 0.000 0.000
#> GSM252481     2  0.0000     0.9757 0.000 1.000 0.000 0.000
#> GSM252480     2  0.0000     0.9757 0.000 1.000 0.000 0.000
#> GSM252479     2  0.0000     0.9757 0.000 1.000 0.000 0.000
#> GSM252482     2  0.2704     0.8990 0.000 0.876 0.000 0.124
#> GSM252478     2  0.1022     0.9553 0.000 0.968 0.000 0.032
#> GSM252483     2  0.2704     0.8990 0.000 0.876 0.000 0.124
#> GSM252477     2  0.2704     0.8990 0.000 0.876 0.000 0.124
#> GSM252484     2  0.0000     0.9757 0.000 1.000 0.000 0.000
#> GSM252476     2  0.0000     0.9757 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.0290     0.6741 0.000 0.000 0.992 0.008 0.000
#> GSM252429     3  0.5283     0.5078 0.000 0.000 0.676 0.188 0.136
#> GSM252424     3  0.0000     0.6723 0.000 0.000 1.000 0.000 0.000
#> GSM252432     3  0.0290     0.6741 0.000 0.000 0.992 0.008 0.000
#> GSM252427     3  0.2439     0.6343 0.000 0.000 0.876 0.120 0.004
#> GSM252431     3  0.3723     0.4708 0.000 0.088 0.840 0.032 0.040
#> GSM252430     5  0.5118     0.0000 0.004 0.020 0.480 0.004 0.492
#> GSM252433     3  0.4519     0.2204 0.000 0.000 0.752 0.100 0.148
#> GSM252426     3  0.0510     0.6755 0.000 0.000 0.984 0.016 0.000
#> GSM252428     3  0.3047     0.6176 0.000 0.004 0.832 0.160 0.004
#> GSM252425     3  0.6628     0.1001 0.080 0.044 0.640 0.200 0.036
#> GSM252440     1  0.0609     0.7728 0.980 0.000 0.000 0.000 0.020
#> GSM252441     1  0.0609     0.7728 0.980 0.000 0.000 0.000 0.020
#> GSM252436     1  0.1216     0.7720 0.960 0.000 0.000 0.020 0.020
#> GSM252435     1  0.3752     0.6892 0.780 0.000 0.016 0.200 0.004
#> GSM252442     1  0.4132     0.6190 0.720 0.000 0.020 0.260 0.000
#> GSM252439     1  0.6611     0.3381 0.512 0.000 0.008 0.216 0.264
#> GSM252438     4  0.6972    -0.1212 0.256 0.000 0.008 0.388 0.348
#> GSM252434     1  0.2771     0.7492 0.860 0.000 0.012 0.128 0.000
#> GSM252437     1  0.2818     0.7480 0.856 0.000 0.012 0.132 0.000
#> GSM252451     1  0.1485     0.7738 0.948 0.000 0.000 0.032 0.020
#> GSM252448     1  0.0609     0.7728 0.980 0.000 0.000 0.000 0.020
#> GSM252447     1  0.0609     0.7728 0.980 0.000 0.000 0.000 0.020
#> GSM252444     1  0.1216     0.7720 0.960 0.000 0.000 0.020 0.020
#> GSM252450     1  0.3752     0.6892 0.780 0.000 0.016 0.200 0.004
#> GSM252452     1  0.3812     0.6779 0.772 0.000 0.000 0.204 0.024
#> GSM252443     1  0.6347     0.4039 0.564 0.000 0.008 0.212 0.216
#> GSM252454     1  0.4523     0.6970 0.768 0.000 0.012 0.148 0.072
#> GSM252449     1  0.2771     0.7492 0.860 0.000 0.012 0.128 0.000
#> GSM252445     1  0.2818     0.7480 0.856 0.000 0.012 0.132 0.000
#> GSM252453     1  0.4010     0.6992 0.784 0.000 0.008 0.176 0.032
#> GSM252464     4  0.5741     0.6144 0.096 0.000 0.360 0.544 0.000
#> GSM252463     3  0.5816     0.3983 0.004 0.000 0.616 0.244 0.136
#> GSM252461     4  0.6670     0.5642 0.308 0.000 0.256 0.436 0.000
#> GSM252455     4  0.6172     0.6363 0.176 0.000 0.280 0.544 0.000
#> GSM252458     4  0.5861     0.5719 0.088 0.000 0.388 0.520 0.004
#> GSM252460     4  0.5641     0.6178 0.088 0.000 0.356 0.556 0.000
#> GSM252457     1  0.8503    -0.0723 0.332 0.000 0.208 0.236 0.224
#> GSM252456     4  0.5719     0.6258 0.096 0.000 0.352 0.552 0.000
#> GSM252462     4  0.6337     0.4916 0.320 0.000 0.180 0.500 0.000
#> GSM252459     1  0.4477     0.6849 0.764 0.000 0.024 0.176 0.036
#> GSM252472     2  0.0000     0.9022 0.000 1.000 0.000 0.000 0.000
#> GSM252466     2  0.0000     0.9022 0.000 1.000 0.000 0.000 0.000
#> GSM252469     2  0.0000     0.9022 0.000 1.000 0.000 0.000 0.000
#> GSM252475     2  0.0000     0.9022 0.000 1.000 0.000 0.000 0.000
#> GSM252471     2  0.0000     0.9022 0.000 1.000 0.000 0.000 0.000
#> GSM252465     2  0.0609     0.8883 0.000 0.980 0.000 0.020 0.000
#> GSM252474     2  0.4249     0.4105 0.000 0.568 0.000 0.000 0.432
#> GSM252473     2  0.0000     0.9022 0.000 1.000 0.000 0.000 0.000
#> GSM252468     2  0.0000     0.9022 0.000 1.000 0.000 0.000 0.000
#> GSM252470     2  0.0162     0.8997 0.000 0.996 0.000 0.000 0.004
#> GSM252467     2  0.0000     0.9022 0.000 1.000 0.000 0.000 0.000
#> GSM252485     2  0.0000     0.9022 0.000 1.000 0.000 0.000 0.000
#> GSM252481     2  0.0000     0.9022 0.000 1.000 0.000 0.000 0.000
#> GSM252480     2  0.0000     0.9022 0.000 1.000 0.000 0.000 0.000
#> GSM252479     2  0.0000     0.9022 0.000 1.000 0.000 0.000 0.000
#> GSM252482     2  0.4249     0.4105 0.000 0.568 0.000 0.000 0.432
#> GSM252478     2  0.1836     0.8482 0.000 0.932 0.000 0.032 0.036
#> GSM252483     2  0.4249     0.4105 0.000 0.568 0.000 0.000 0.432
#> GSM252477     2  0.4249     0.4105 0.000 0.568 0.000 0.000 0.432
#> GSM252484     2  0.0000     0.9022 0.000 1.000 0.000 0.000 0.000
#> GSM252476     2  0.0000     0.9022 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.0717     0.5685 0.000 0.000 0.976 0.016 0.008 0.000
#> GSM252429     3  0.6740     0.1763 0.000 0.000 0.424 0.180 0.336 0.060
#> GSM252424     3  0.0146     0.5625 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM252432     3  0.0603     0.5680 0.000 0.000 0.980 0.016 0.004 0.000
#> GSM252427     3  0.2513     0.5258 0.000 0.000 0.852 0.140 0.008 0.000
#> GSM252431     3  0.3593     0.3801 0.000 0.076 0.836 0.020 0.052 0.016
#> GSM252430     5  0.4593     0.0000 0.000 0.000 0.472 0.000 0.492 0.036
#> GSM252433     3  0.4887    -0.0208 0.000 0.000 0.720 0.044 0.100 0.136
#> GSM252426     3  0.0713     0.5696 0.000 0.000 0.972 0.028 0.000 0.000
#> GSM252428     3  0.2845     0.5000 0.000 0.004 0.820 0.172 0.000 0.004
#> GSM252425     3  0.6582     0.0413 0.040 0.032 0.632 0.104 0.040 0.152
#> GSM252440     1  0.1391     0.7296 0.944 0.000 0.000 0.000 0.040 0.016
#> GSM252441     1  0.1391     0.7296 0.944 0.000 0.000 0.000 0.040 0.016
#> GSM252436     1  0.1787     0.7349 0.932 0.000 0.000 0.020 0.032 0.016
#> GSM252435     1  0.3692     0.6866 0.736 0.000 0.008 0.244 0.000 0.012
#> GSM252442     1  0.3636     0.6064 0.676 0.000 0.004 0.320 0.000 0.000
#> GSM252439     6  0.4870     0.6810 0.372 0.000 0.000 0.004 0.056 0.568
#> GSM252438     6  0.3258     0.5241 0.120 0.000 0.000 0.032 0.016 0.832
#> GSM252434     1  0.2632     0.7472 0.832 0.000 0.004 0.164 0.000 0.000
#> GSM252437     1  0.2668     0.7462 0.828 0.000 0.004 0.168 0.000 0.000
#> GSM252451     1  0.1787     0.7444 0.932 0.000 0.000 0.032 0.020 0.016
#> GSM252448     1  0.1391     0.7296 0.944 0.000 0.000 0.000 0.040 0.016
#> GSM252447     1  0.1391     0.7296 0.944 0.000 0.000 0.000 0.040 0.016
#> GSM252444     1  0.1787     0.7349 0.932 0.000 0.000 0.020 0.032 0.016
#> GSM252450     1  0.3692     0.6866 0.736 0.000 0.008 0.244 0.000 0.012
#> GSM252452     1  0.5813     0.3891 0.544 0.000 0.000 0.332 0.056 0.068
#> GSM252443     6  0.4602     0.5860 0.444 0.000 0.004 0.016 0.008 0.528
#> GSM252454     1  0.4683     0.4888 0.700 0.000 0.004 0.080 0.008 0.208
#> GSM252449     1  0.2632     0.7472 0.832 0.000 0.004 0.164 0.000 0.000
#> GSM252445     1  0.2668     0.7462 0.828 0.000 0.004 0.168 0.000 0.000
#> GSM252453     1  0.4556     0.5503 0.732 0.000 0.004 0.092 0.012 0.160
#> GSM252464     4  0.4399     0.7995 0.056 0.000 0.252 0.688 0.004 0.000
#> GSM252463     3  0.7066     0.0421 0.004 0.000 0.364 0.236 0.336 0.060
#> GSM252461     4  0.5445     0.6810 0.268 0.000 0.168 0.564 0.000 0.000
#> GSM252455     4  0.4716     0.7929 0.136 0.000 0.184 0.680 0.000 0.000
#> GSM252458     4  0.4631     0.7644 0.052 0.000 0.288 0.652 0.008 0.000
#> GSM252460     4  0.4239     0.8075 0.056 0.000 0.248 0.696 0.000 0.000
#> GSM252457     6  0.7089     0.5549 0.256 0.000 0.196 0.044 0.032 0.472
#> GSM252456     4  0.4215     0.8099 0.056 0.000 0.244 0.700 0.000 0.000
#> GSM252462     4  0.5190     0.5738 0.280 0.000 0.128 0.592 0.000 0.000
#> GSM252459     1  0.4980     0.5230 0.712 0.000 0.016 0.096 0.016 0.160
#> GSM252472     2  0.0000     0.8964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252466     2  0.0000     0.8964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252469     2  0.0000     0.8964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252475     2  0.0000     0.8964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252471     2  0.0000     0.8964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252465     2  0.0767     0.8803 0.000 0.976 0.004 0.008 0.012 0.000
#> GSM252474     2  0.3854     0.3559 0.000 0.536 0.000 0.000 0.464 0.000
#> GSM252473     2  0.0000     0.8964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252468     2  0.0000     0.8964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252470     2  0.0146     0.8939 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM252467     2  0.0000     0.8964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252485     2  0.0000     0.8964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252481     2  0.0000     0.8964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252480     2  0.0000     0.8964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252479     2  0.0000     0.8964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252482     2  0.3854     0.3559 0.000 0.536 0.000 0.000 0.464 0.000
#> GSM252478     2  0.2030     0.8350 0.000 0.920 0.004 0.012 0.048 0.016
#> GSM252483     2  0.3854     0.3559 0.000 0.536 0.000 0.000 0.464 0.000
#> GSM252477     2  0.3854     0.3559 0.000 0.536 0.000 0.000 0.464 0.000
#> GSM252484     2  0.0000     0.8964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252476     2  0.0000     0.8964 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)

plot of chunk tab-SD-hclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-SD-hclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-SD-hclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-SD-hclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-SD-hclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-SD-hclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-SD-hclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-SD-hclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-SD-hclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-SD-hclust-membership-heatmap-5

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)

plot of chunk tab-SD-hclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-SD-hclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-SD-hclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-SD-hclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-SD-hclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-SD-hclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-SD-hclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-SD-hclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-SD-hclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-SD-hclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-hclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-SD-hclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-SD-hclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-SD-hclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-SD-hclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-SD-hclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-hclust-collect-classes

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 agent(p) individual(p) k
#> SD:hclust 61 7.55e-12         1.000 2
#> SD:hclust 54 1.20e-17         1.000 3
#> SD:hclust 49 7.88e-16         0.999 4
#> SD:hclust 48 2.37e-21         1.000 5
#> SD:hclust 50 2.04e-19         0.111 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.


SD:kmeans

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 51941 rows and 62 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 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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:

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)

plot of chunk SD-kmeans-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.725           0.910       0.952         0.4777 0.535   0.535
#> 3 3 0.747           0.920       0.916         0.3572 0.770   0.577
#> 4 4 0.731           0.803       0.845         0.1196 1.000   1.000
#> 5 5 0.721           0.700       0.708         0.0653 0.912   0.729
#> 6 6 0.714           0.661       0.753         0.0456 0.935   0.735

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 3

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1  0.8713      0.686 0.708 0.292
#> GSM252429     1  0.8713      0.686 0.708 0.292
#> GSM252424     1  0.8661      0.686 0.712 0.288
#> GSM252432     1  0.8713      0.686 0.708 0.292
#> GSM252427     1  0.8661      0.686 0.712 0.288
#> GSM252431     1  0.8661      0.686 0.712 0.288
#> GSM252430     1  0.8713      0.686 0.708 0.292
#> GSM252433     1  0.8713      0.686 0.708 0.292
#> GSM252426     1  0.8661      0.686 0.712 0.288
#> GSM252428     1  0.8661      0.686 0.712 0.288
#> GSM252425     2  0.0672      0.995 0.008 0.992
#> GSM252440     1  0.0000      0.920 1.000 0.000
#> GSM252441     1  0.0000      0.920 1.000 0.000
#> GSM252436     1  0.0000      0.920 1.000 0.000
#> GSM252435     1  0.0000      0.920 1.000 0.000
#> GSM252442     1  0.0000      0.920 1.000 0.000
#> GSM252439     1  0.0376      0.918 0.996 0.004
#> GSM252438     1  0.0376      0.918 0.996 0.004
#> GSM252434     1  0.0000      0.920 1.000 0.000
#> GSM252437     1  0.0000      0.920 1.000 0.000
#> GSM252451     1  0.0000      0.920 1.000 0.000
#> GSM252448     1  0.0000      0.920 1.000 0.000
#> GSM252447     1  0.0000      0.920 1.000 0.000
#> GSM252444     1  0.0000      0.920 1.000 0.000
#> GSM252450     1  0.0000      0.920 1.000 0.000
#> GSM252452     1  0.0376      0.918 0.996 0.004
#> GSM252443     1  0.0376      0.918 0.996 0.004
#> GSM252454     1  0.0000      0.920 1.000 0.000
#> GSM252449     1  0.0000      0.920 1.000 0.000
#> GSM252445     1  0.0000      0.920 1.000 0.000
#> GSM252453     1  0.0000      0.920 1.000 0.000
#> GSM252464     1  0.0376      0.918 0.996 0.004
#> GSM252463     1  0.0000      0.920 1.000 0.000
#> GSM252461     1  0.0000      0.920 1.000 0.000
#> GSM252455     1  0.0000      0.920 1.000 0.000
#> GSM252458     1  0.0000      0.920 1.000 0.000
#> GSM252460     1  0.0000      0.920 1.000 0.000
#> GSM252457     1  0.0376      0.918 0.996 0.004
#> GSM252456     1  0.0000      0.920 1.000 0.000
#> GSM252462     1  0.0000      0.920 1.000 0.000
#> GSM252459     1  0.0000      0.920 1.000 0.000
#> GSM252472     2  0.0376      0.999 0.004 0.996
#> GSM252466     2  0.0376      0.999 0.004 0.996
#> GSM252469     2  0.0376      0.999 0.004 0.996
#> GSM252475     2  0.0376      0.999 0.004 0.996
#> GSM252471     2  0.0376      0.999 0.004 0.996
#> GSM252465     2  0.0376      0.999 0.004 0.996
#> GSM252474     2  0.0000      0.996 0.000 1.000
#> GSM252473     2  0.0376      0.999 0.004 0.996
#> GSM252468     2  0.0376      0.999 0.004 0.996
#> GSM252470     2  0.0376      0.999 0.004 0.996
#> GSM252467     2  0.0376      0.999 0.004 0.996
#> GSM252485     2  0.0376      0.999 0.004 0.996
#> GSM252481     2  0.0376      0.999 0.004 0.996
#> GSM252480     2  0.0376      0.999 0.004 0.996
#> GSM252479     2  0.0376      0.999 0.004 0.996
#> GSM252482     2  0.0000      0.996 0.000 1.000
#> GSM252478     2  0.0376      0.999 0.004 0.996
#> GSM252483     2  0.0000      0.996 0.000 1.000
#> GSM252477     2  0.0000      0.996 0.000 1.000
#> GSM252484     2  0.0376      0.999 0.004 0.996
#> GSM252476     2  0.0376      0.999 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.5092      0.884 0.176 0.020 0.804
#> GSM252429     3  0.4921      0.879 0.164 0.020 0.816
#> GSM252424     3  0.5092      0.884 0.176 0.020 0.804
#> GSM252432     3  0.5092      0.884 0.176 0.020 0.804
#> GSM252427     3  0.5092      0.884 0.176 0.020 0.804
#> GSM252431     3  0.5092      0.884 0.176 0.020 0.804
#> GSM252430     3  0.1315      0.756 0.008 0.020 0.972
#> GSM252433     3  0.1337      0.760 0.012 0.016 0.972
#> GSM252426     3  0.5092      0.884 0.176 0.020 0.804
#> GSM252428     3  0.5092      0.884 0.176 0.020 0.804
#> GSM252425     3  0.6140      0.315 0.000 0.404 0.596
#> GSM252440     1  0.0592      0.988 0.988 0.000 0.012
#> GSM252441     1  0.0000      0.995 1.000 0.000 0.000
#> GSM252436     1  0.0000      0.995 1.000 0.000 0.000
#> GSM252435     1  0.0000      0.995 1.000 0.000 0.000
#> GSM252442     1  0.0000      0.995 1.000 0.000 0.000
#> GSM252439     1  0.0747      0.984 0.984 0.000 0.016
#> GSM252438     1  0.0747      0.984 0.984 0.000 0.016
#> GSM252434     1  0.0000      0.995 1.000 0.000 0.000
#> GSM252437     1  0.0000      0.995 1.000 0.000 0.000
#> GSM252451     1  0.0000      0.995 1.000 0.000 0.000
#> GSM252448     1  0.0592      0.988 0.988 0.000 0.012
#> GSM252447     1  0.0000      0.995 1.000 0.000 0.000
#> GSM252444     1  0.0000      0.995 1.000 0.000 0.000
#> GSM252450     1  0.0000      0.995 1.000 0.000 0.000
#> GSM252452     1  0.0424      0.991 0.992 0.000 0.008
#> GSM252443     1  0.0592      0.988 0.988 0.000 0.012
#> GSM252454     1  0.0424      0.991 0.992 0.000 0.008
#> GSM252449     1  0.0000      0.995 1.000 0.000 0.000
#> GSM252445     1  0.0000      0.995 1.000 0.000 0.000
#> GSM252453     1  0.0000      0.995 1.000 0.000 0.000
#> GSM252464     3  0.5327      0.847 0.272 0.000 0.728
#> GSM252463     3  0.5327      0.837 0.272 0.000 0.728
#> GSM252461     1  0.0000      0.995 1.000 0.000 0.000
#> GSM252455     3  0.5431      0.835 0.284 0.000 0.716
#> GSM252458     3  0.5327      0.847 0.272 0.000 0.728
#> GSM252460     3  0.5254      0.852 0.264 0.000 0.736
#> GSM252457     3  0.4346      0.878 0.184 0.000 0.816
#> GSM252456     3  0.5327      0.847 0.272 0.000 0.728
#> GSM252462     3  0.6307      0.443 0.488 0.000 0.512
#> GSM252459     1  0.0000      0.995 1.000 0.000 0.000
#> GSM252472     2  0.0000      0.967 0.000 1.000 0.000
#> GSM252466     2  0.1163      0.961 0.000 0.972 0.028
#> GSM252469     2  0.1163      0.961 0.000 0.972 0.028
#> GSM252475     2  0.0000      0.967 0.000 1.000 0.000
#> GSM252471     2  0.0000      0.967 0.000 1.000 0.000
#> GSM252465     2  0.0000      0.967 0.000 1.000 0.000
#> GSM252474     2  0.3941      0.881 0.000 0.844 0.156
#> GSM252473     2  0.0000      0.967 0.000 1.000 0.000
#> GSM252468     2  0.0000      0.967 0.000 1.000 0.000
#> GSM252470     2  0.0000      0.967 0.000 1.000 0.000
#> GSM252467     2  0.0892      0.963 0.000 0.980 0.020
#> GSM252485     2  0.0000      0.967 0.000 1.000 0.000
#> GSM252481     2  0.1163      0.961 0.000 0.972 0.028
#> GSM252480     2  0.1163      0.961 0.000 0.972 0.028
#> GSM252479     2  0.0747      0.964 0.000 0.984 0.016
#> GSM252482     2  0.3941      0.879 0.000 0.844 0.156
#> GSM252478     2  0.0000      0.967 0.000 1.000 0.000
#> GSM252483     2  0.4002      0.878 0.000 0.840 0.160
#> GSM252477     2  0.3941      0.879 0.000 0.844 0.156
#> GSM252484     2  0.0000      0.967 0.000 1.000 0.000
#> GSM252476     2  0.0892      0.963 0.000 0.980 0.020

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3 p4
#> GSM252423     3  0.0817      0.786 0.024 0.000 0.976 NA
#> GSM252429     3  0.1004      0.785 0.024 0.000 0.972 NA
#> GSM252424     3  0.0817      0.786 0.024 0.000 0.976 NA
#> GSM252432     3  0.0817      0.786 0.024 0.000 0.976 NA
#> GSM252427     3  0.1004      0.786 0.024 0.000 0.972 NA
#> GSM252431     3  0.1833      0.781 0.024 0.000 0.944 NA
#> GSM252430     3  0.4948      0.525 0.000 0.000 0.560 NA
#> GSM252433     3  0.4431      0.640 0.000 0.000 0.696 NA
#> GSM252426     3  0.1004      0.786 0.024 0.000 0.972 NA
#> GSM252428     3  0.1151      0.786 0.024 0.000 0.968 NA
#> GSM252425     3  0.6392      0.149 0.000 0.404 0.528 NA
#> GSM252440     1  0.1118      0.888 0.964 0.000 0.000 NA
#> GSM252441     1  0.0707      0.891 0.980 0.000 0.000 NA
#> GSM252436     1  0.0469      0.891 0.988 0.000 0.000 NA
#> GSM252435     1  0.2760      0.868 0.872 0.000 0.000 NA
#> GSM252442     1  0.3764      0.813 0.784 0.000 0.000 NA
#> GSM252439     1  0.3444      0.812 0.816 0.000 0.000 NA
#> GSM252438     1  0.3688      0.798 0.792 0.000 0.000 NA
#> GSM252434     1  0.3764      0.813 0.784 0.000 0.000 NA
#> GSM252437     1  0.2281      0.880 0.904 0.000 0.000 NA
#> GSM252451     1  0.0469      0.892 0.988 0.000 0.000 NA
#> GSM252448     1  0.1118      0.888 0.964 0.000 0.000 NA
#> GSM252447     1  0.0707      0.891 0.980 0.000 0.000 NA
#> GSM252444     1  0.0469      0.891 0.988 0.000 0.000 NA
#> GSM252450     1  0.2281      0.880 0.904 0.000 0.000 NA
#> GSM252452     1  0.3074      0.862 0.848 0.000 0.000 NA
#> GSM252443     1  0.2868      0.847 0.864 0.000 0.000 NA
#> GSM252454     1  0.2973      0.846 0.856 0.000 0.000 NA
#> GSM252449     1  0.3764      0.813 0.784 0.000 0.000 NA
#> GSM252445     1  0.2921      0.863 0.860 0.000 0.000 NA
#> GSM252453     1  0.0592      0.891 0.984 0.000 0.000 NA
#> GSM252464     3  0.6316      0.687 0.080 0.000 0.596 NA
#> GSM252463     3  0.6682      0.671 0.112 0.000 0.576 NA
#> GSM252461     1  0.4406      0.704 0.700 0.000 0.000 NA
#> GSM252455     3  0.6570      0.674 0.100 0.000 0.580 NA
#> GSM252458     3  0.6334      0.687 0.080 0.000 0.592 NA
#> GSM252460     3  0.6334      0.687 0.080 0.000 0.592 NA
#> GSM252457     3  0.4464      0.731 0.024 0.000 0.768 NA
#> GSM252456     3  0.6334      0.687 0.080 0.000 0.592 NA
#> GSM252462     3  0.7282      0.570 0.160 0.000 0.492 NA
#> GSM252459     1  0.2999      0.868 0.864 0.000 0.004 NA
#> GSM252472     2  0.0000      0.906 0.000 1.000 0.000 NA
#> GSM252466     2  0.2813      0.889 0.000 0.896 0.024 NA
#> GSM252469     2  0.2742      0.890 0.000 0.900 0.024 NA
#> GSM252475     2  0.0000      0.906 0.000 1.000 0.000 NA
#> GSM252471     2  0.0188      0.906 0.000 0.996 0.000 NA
#> GSM252465     2  0.1211      0.896 0.000 0.960 0.000 NA
#> GSM252474     2  0.4920      0.688 0.000 0.628 0.004 NA
#> GSM252473     2  0.0188      0.906 0.000 0.996 0.000 NA
#> GSM252468     2  0.0336      0.906 0.000 0.992 0.000 NA
#> GSM252470     2  0.0707      0.905 0.000 0.980 0.000 NA
#> GSM252467     2  0.2670      0.891 0.000 0.904 0.024 NA
#> GSM252485     2  0.0000      0.906 0.000 1.000 0.000 NA
#> GSM252481     2  0.2813      0.889 0.000 0.896 0.024 NA
#> GSM252480     2  0.2742      0.890 0.000 0.900 0.024 NA
#> GSM252479     2  0.0336      0.906 0.000 0.992 0.000 NA
#> GSM252482     2  0.4746      0.683 0.000 0.632 0.000 NA
#> GSM252478     2  0.1211      0.896 0.000 0.960 0.000 NA
#> GSM252483     2  0.4790      0.679 0.000 0.620 0.000 NA
#> GSM252477     2  0.4746      0.683 0.000 0.632 0.000 NA
#> GSM252484     2  0.0336      0.906 0.000 0.992 0.000 NA
#> GSM252476     2  0.2670      0.891 0.000 0.904 0.024 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.4559      0.729 0.000 0.000 0.512 0.480 0.008
#> GSM252429     3  0.4644      0.724 0.000 0.000 0.528 0.460 0.012
#> GSM252424     3  0.4302      0.731 0.000 0.000 0.520 0.480 0.000
#> GSM252432     3  0.4559      0.729 0.000 0.000 0.512 0.480 0.008
#> GSM252427     3  0.4304      0.730 0.000 0.000 0.516 0.484 0.000
#> GSM252431     3  0.4403      0.697 0.000 0.000 0.560 0.436 0.004
#> GSM252430     5  0.5178     -0.250 0.000 0.000 0.476 0.040 0.484
#> GSM252433     3  0.5016      0.408 0.000 0.000 0.704 0.120 0.176
#> GSM252426     3  0.4304      0.730 0.000 0.000 0.516 0.484 0.000
#> GSM252428     3  0.4306      0.725 0.000 0.000 0.508 0.492 0.000
#> GSM252425     3  0.5437      0.208 0.000 0.324 0.608 0.060 0.008
#> GSM252440     1  0.3365      0.731 0.836 0.000 0.044 0.000 0.120
#> GSM252441     1  0.2344      0.746 0.904 0.000 0.032 0.000 0.064
#> GSM252436     1  0.1364      0.751 0.952 0.000 0.012 0.000 0.036
#> GSM252435     1  0.3078      0.725 0.848 0.000 0.004 0.132 0.016
#> GSM252442     1  0.4354      0.637 0.720 0.000 0.008 0.252 0.020
#> GSM252439     1  0.6699      0.488 0.428 0.000 0.268 0.000 0.304
#> GSM252438     1  0.7036      0.477 0.420 0.000 0.284 0.012 0.284
#> GSM252434     1  0.4328      0.641 0.724 0.000 0.008 0.248 0.020
#> GSM252437     1  0.3341      0.725 0.840 0.000 0.008 0.128 0.024
#> GSM252451     1  0.1525      0.751 0.948 0.000 0.012 0.004 0.036
#> GSM252448     1  0.3365      0.731 0.836 0.000 0.044 0.000 0.120
#> GSM252447     1  0.2344      0.746 0.904 0.000 0.032 0.000 0.064
#> GSM252444     1  0.1364      0.751 0.952 0.000 0.012 0.000 0.036
#> GSM252450     1  0.2784      0.735 0.872 0.000 0.004 0.108 0.016
#> GSM252452     1  0.6253      0.633 0.612 0.000 0.156 0.024 0.208
#> GSM252443     1  0.6463      0.546 0.488 0.000 0.212 0.000 0.300
#> GSM252454     1  0.6791      0.557 0.520 0.000 0.212 0.020 0.248
#> GSM252449     1  0.4328      0.641 0.724 0.000 0.008 0.248 0.020
#> GSM252445     1  0.3599      0.708 0.812 0.000 0.008 0.160 0.020
#> GSM252453     1  0.1430      0.754 0.944 0.000 0.004 0.000 0.052
#> GSM252464     4  0.1525      0.929 0.036 0.000 0.012 0.948 0.004
#> GSM252463     4  0.2698      0.893 0.036 0.000 0.036 0.900 0.028
#> GSM252461     1  0.5523      0.311 0.492 0.000 0.012 0.456 0.040
#> GSM252455     4  0.1757      0.926 0.048 0.000 0.012 0.936 0.004
#> GSM252458     4  0.1168      0.928 0.032 0.000 0.008 0.960 0.000
#> GSM252460     4  0.0955      0.925 0.028 0.000 0.000 0.968 0.004
#> GSM252457     3  0.6120      0.320 0.000 0.000 0.564 0.240 0.196
#> GSM252456     4  0.1041      0.928 0.032 0.000 0.000 0.964 0.004
#> GSM252462     4  0.3035      0.772 0.136 0.000 0.008 0.848 0.008
#> GSM252459     1  0.5819      0.678 0.692 0.000 0.064 0.152 0.092
#> GSM252472     2  0.0510      0.839 0.000 0.984 0.016 0.000 0.000
#> GSM252466     2  0.4597      0.731 0.000 0.772 0.092 0.016 0.120
#> GSM252469     2  0.4503      0.741 0.000 0.780 0.092 0.016 0.112
#> GSM252475     2  0.0807      0.837 0.000 0.976 0.012 0.000 0.012
#> GSM252471     2  0.0992      0.834 0.000 0.968 0.024 0.000 0.008
#> GSM252465     2  0.2331      0.777 0.000 0.908 0.068 0.008 0.016
#> GSM252474     5  0.4294      0.659 0.000 0.468 0.000 0.000 0.532
#> GSM252473     2  0.0771      0.835 0.000 0.976 0.020 0.000 0.004
#> GSM252468     2  0.0693      0.837 0.000 0.980 0.008 0.000 0.012
#> GSM252470     2  0.0798      0.839 0.000 0.976 0.008 0.000 0.016
#> GSM252467     2  0.4333      0.755 0.000 0.796 0.080 0.020 0.104
#> GSM252485     2  0.0510      0.839 0.000 0.984 0.016 0.000 0.000
#> GSM252481     2  0.4597      0.731 0.000 0.772 0.092 0.016 0.120
#> GSM252480     2  0.4503      0.741 0.000 0.780 0.092 0.016 0.112
#> GSM252479     2  0.1485      0.831 0.000 0.948 0.020 0.000 0.032
#> GSM252482     5  0.4559      0.657 0.000 0.480 0.008 0.000 0.512
#> GSM252478     2  0.2395      0.773 0.000 0.904 0.072 0.008 0.016
#> GSM252483     5  0.4294      0.659 0.000 0.468 0.000 0.000 0.532
#> GSM252477     5  0.4559      0.657 0.000 0.480 0.008 0.000 0.512
#> GSM252484     2  0.0693      0.837 0.000 0.980 0.008 0.000 0.012
#> GSM252476     2  0.4333      0.755 0.000 0.796 0.080 0.020 0.104

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.0806    0.86044 0.000 0.000 0.972 0.020 0.008 0.000
#> GSM252429     3  0.1367    0.84305 0.000 0.000 0.944 0.012 0.044 0.000
#> GSM252424     3  0.0291    0.86549 0.000 0.000 0.992 0.004 0.004 0.000
#> GSM252432     3  0.0520    0.86432 0.000 0.000 0.984 0.008 0.008 0.000
#> GSM252427     3  0.0547    0.86360 0.000 0.000 0.980 0.020 0.000 0.000
#> GSM252431     3  0.2402    0.82039 0.000 0.000 0.896 0.060 0.032 0.012
#> GSM252430     5  0.5706   -0.16363 0.000 0.000 0.376 0.004 0.476 0.144
#> GSM252433     3  0.5727    0.27610 0.000 0.000 0.536 0.028 0.096 0.340
#> GSM252426     3  0.0547    0.86360 0.000 0.000 0.980 0.020 0.000 0.000
#> GSM252428     3  0.0972    0.85998 0.000 0.000 0.964 0.028 0.008 0.000
#> GSM252425     3  0.5106    0.59296 0.000 0.148 0.720 0.076 0.032 0.024
#> GSM252440     1  0.4211    0.44671 0.776 0.000 0.000 0.044 0.056 0.124
#> GSM252441     1  0.2231    0.56260 0.908 0.000 0.000 0.016 0.028 0.048
#> GSM252436     1  0.0405    0.60707 0.988 0.000 0.000 0.000 0.004 0.008
#> GSM252435     1  0.5547    0.62447 0.652 0.000 0.000 0.188 0.064 0.096
#> GSM252442     1  0.6075    0.57653 0.536 0.000 0.000 0.312 0.068 0.084
#> GSM252439     6  0.3648    0.71007 0.240 0.000 0.000 0.004 0.016 0.740
#> GSM252438     6  0.4329    0.70948 0.232 0.000 0.000 0.016 0.040 0.712
#> GSM252434     1  0.6075    0.57653 0.536 0.000 0.000 0.312 0.068 0.084
#> GSM252437     1  0.5819    0.61559 0.620 0.000 0.000 0.208 0.072 0.100
#> GSM252451     1  0.1088    0.61395 0.960 0.000 0.000 0.016 0.000 0.024
#> GSM252448     1  0.4211    0.44671 0.776 0.000 0.000 0.044 0.056 0.124
#> GSM252447     1  0.2231    0.56260 0.908 0.000 0.000 0.016 0.028 0.048
#> GSM252444     1  0.0603    0.60384 0.980 0.000 0.000 0.000 0.004 0.016
#> GSM252450     1  0.5369    0.62419 0.676 0.000 0.000 0.164 0.064 0.096
#> GSM252452     6  0.5791    0.22843 0.364 0.000 0.000 0.064 0.052 0.520
#> GSM252443     6  0.3136    0.71091 0.228 0.000 0.000 0.004 0.000 0.768
#> GSM252454     6  0.4341    0.64968 0.284 0.000 0.000 0.024 0.016 0.676
#> GSM252449     1  0.6075    0.57653 0.536 0.000 0.000 0.312 0.068 0.084
#> GSM252445     1  0.5831    0.61446 0.608 0.000 0.000 0.232 0.072 0.088
#> GSM252453     1  0.4432    0.51776 0.736 0.000 0.000 0.036 0.044 0.184
#> GSM252464     4  0.4053    0.85588 0.016 0.000 0.288 0.688 0.004 0.004
#> GSM252463     4  0.5063    0.82094 0.016 0.000 0.256 0.664 0.032 0.032
#> GSM252461     4  0.4122    0.38071 0.316 0.000 0.000 0.660 0.004 0.020
#> GSM252455     4  0.4531    0.85415 0.028 0.000 0.280 0.672 0.004 0.016
#> GSM252458     4  0.3915    0.85965 0.016 0.000 0.288 0.692 0.004 0.000
#> GSM252460     4  0.3895    0.85888 0.016 0.000 0.284 0.696 0.004 0.000
#> GSM252457     6  0.5943    0.00155 0.000 0.000 0.368 0.060 0.068 0.504
#> GSM252456     4  0.3758    0.85999 0.016 0.000 0.284 0.700 0.000 0.000
#> GSM252462     4  0.4783    0.75396 0.060 0.000 0.152 0.740 0.024 0.024
#> GSM252459     1  0.6669    0.17193 0.452 0.000 0.000 0.200 0.052 0.296
#> GSM252472     2  0.0862    0.79429 0.000 0.972 0.000 0.016 0.004 0.008
#> GSM252466     2  0.5644    0.61832 0.000 0.656 0.000 0.084 0.152 0.108
#> GSM252469     2  0.5417    0.64870 0.000 0.680 0.000 0.076 0.132 0.112
#> GSM252475     2  0.1275    0.79478 0.000 0.956 0.000 0.016 0.012 0.016
#> GSM252471     2  0.1053    0.79174 0.000 0.964 0.000 0.012 0.004 0.020
#> GSM252465     2  0.2964    0.72556 0.000 0.868 0.000 0.060 0.036 0.036
#> GSM252474     5  0.3578    0.73821 0.000 0.340 0.000 0.000 0.660 0.000
#> GSM252473     2  0.1138    0.79087 0.000 0.960 0.000 0.012 0.004 0.024
#> GSM252468     2  0.0976    0.79433 0.000 0.968 0.000 0.008 0.008 0.016
#> GSM252470     2  0.1275    0.79288 0.000 0.956 0.000 0.012 0.016 0.016
#> GSM252467     2  0.4961    0.68579 0.000 0.724 0.000 0.072 0.104 0.100
#> GSM252485     2  0.0964    0.79434 0.000 0.968 0.000 0.016 0.004 0.012
#> GSM252481     2  0.5644    0.61832 0.000 0.656 0.000 0.084 0.152 0.108
#> GSM252480     2  0.5417    0.64870 0.000 0.680 0.000 0.076 0.132 0.112
#> GSM252479     2  0.1078    0.79369 0.000 0.964 0.000 0.008 0.016 0.012
#> GSM252482     5  0.4058    0.72931 0.000 0.372 0.000 0.004 0.616 0.008
#> GSM252478     2  0.3160    0.71213 0.000 0.856 0.000 0.064 0.036 0.044
#> GSM252483     5  0.3578    0.73821 0.000 0.340 0.000 0.000 0.660 0.000
#> GSM252477     5  0.4058    0.72931 0.000 0.372 0.000 0.004 0.616 0.008
#> GSM252484     2  0.0976    0.79433 0.000 0.968 0.000 0.008 0.008 0.016
#> GSM252476     2  0.4961    0.68579 0.000 0.724 0.000 0.072 0.104 0.100

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-kmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-SD-kmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-SD-kmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-SD-kmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-SD-kmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-SD-kmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-SD-kmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-SD-kmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-SD-kmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-SD-kmeans-membership-heatmap-5

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)

plot of chunk tab-SD-kmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-SD-kmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-SD-kmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-SD-kmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-SD-kmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-SD-kmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-SD-kmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-SD-kmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-SD-kmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-SD-kmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-kmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-SD-kmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-SD-kmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-SD-kmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-SD-kmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-SD-kmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-kmeans-collect-classes

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 agent(p) individual(p) k
#> SD:kmeans 62 3.10e-11         0.996 2
#> SD:kmeans 60 4.71e-19         1.000 3
#> SD:kmeans 61 1.97e-19         1.000 4
#> SD:kmeans 55 9.45e-24         0.907 5
#> SD:kmeans 54 9.41e-23         0.428 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.


SD:skmeans**

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 51941 rows and 62 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 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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:

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)

plot of chunk SD-skmeans-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.937           0.960       0.981         0.4880 0.518   0.518
#> 3 3 0.999           0.966       0.982         0.3786 0.774   0.577
#> 4 4 0.721           0.758       0.812         0.0965 0.942   0.826
#> 5 5 0.692           0.577       0.747         0.0583 0.955   0.843
#> 6 6 0.642           0.533       0.700         0.0377 0.932   0.740

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2

There is also optional best \(k\) = 2 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1   0.443      0.904 0.908 0.092
#> GSM252429     1   0.443      0.904 0.908 0.092
#> GSM252424     1   0.469      0.897 0.900 0.100
#> GSM252432     1   0.443      0.904 0.908 0.092
#> GSM252427     1   0.469      0.897 0.900 0.100
#> GSM252431     1   0.995      0.212 0.540 0.460
#> GSM252430     2   0.000      1.000 0.000 1.000
#> GSM252433     2   0.000      1.000 0.000 1.000
#> GSM252426     1   0.494      0.889 0.892 0.108
#> GSM252428     1   0.584      0.854 0.860 0.140
#> GSM252425     2   0.000      1.000 0.000 1.000
#> GSM252440     1   0.000      0.968 1.000 0.000
#> GSM252441     1   0.000      0.968 1.000 0.000
#> GSM252436     1   0.000      0.968 1.000 0.000
#> GSM252435     1   0.000      0.968 1.000 0.000
#> GSM252442     1   0.000      0.968 1.000 0.000
#> GSM252439     1   0.000      0.968 1.000 0.000
#> GSM252438     1   0.000      0.968 1.000 0.000
#> GSM252434     1   0.000      0.968 1.000 0.000
#> GSM252437     1   0.000      0.968 1.000 0.000
#> GSM252451     1   0.000      0.968 1.000 0.000
#> GSM252448     1   0.000      0.968 1.000 0.000
#> GSM252447     1   0.000      0.968 1.000 0.000
#> GSM252444     1   0.000      0.968 1.000 0.000
#> GSM252450     1   0.000      0.968 1.000 0.000
#> GSM252452     1   0.000      0.968 1.000 0.000
#> GSM252443     1   0.000      0.968 1.000 0.000
#> GSM252454     1   0.000      0.968 1.000 0.000
#> GSM252449     1   0.000      0.968 1.000 0.000
#> GSM252445     1   0.000      0.968 1.000 0.000
#> GSM252453     1   0.000      0.968 1.000 0.000
#> GSM252464     1   0.000      0.968 1.000 0.000
#> GSM252463     1   0.000      0.968 1.000 0.000
#> GSM252461     1   0.000      0.968 1.000 0.000
#> GSM252455     1   0.000      0.968 1.000 0.000
#> GSM252458     1   0.000      0.968 1.000 0.000
#> GSM252460     1   0.000      0.968 1.000 0.000
#> GSM252457     1   0.000      0.968 1.000 0.000
#> GSM252456     1   0.000      0.968 1.000 0.000
#> GSM252462     1   0.000      0.968 1.000 0.000
#> GSM252459     1   0.000      0.968 1.000 0.000
#> GSM252472     2   0.000      1.000 0.000 1.000
#> GSM252466     2   0.000      1.000 0.000 1.000
#> GSM252469     2   0.000      1.000 0.000 1.000
#> GSM252475     2   0.000      1.000 0.000 1.000
#> GSM252471     2   0.000      1.000 0.000 1.000
#> GSM252465     2   0.000      1.000 0.000 1.000
#> GSM252474     2   0.000      1.000 0.000 1.000
#> GSM252473     2   0.000      1.000 0.000 1.000
#> GSM252468     2   0.000      1.000 0.000 1.000
#> GSM252470     2   0.000      1.000 0.000 1.000
#> GSM252467     2   0.000      1.000 0.000 1.000
#> GSM252485     2   0.000      1.000 0.000 1.000
#> GSM252481     2   0.000      1.000 0.000 1.000
#> GSM252480     2   0.000      1.000 0.000 1.000
#> GSM252479     2   0.000      1.000 0.000 1.000
#> GSM252482     2   0.000      1.000 0.000 1.000
#> GSM252478     2   0.000      1.000 0.000 1.000
#> GSM252483     2   0.000      1.000 0.000 1.000
#> GSM252477     2   0.000      1.000 0.000 1.000
#> GSM252484     2   0.000      1.000 0.000 1.000
#> GSM252476     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.0000      0.953 0.000 0.000 1.000
#> GSM252429     3  0.0000      0.953 0.000 0.000 1.000
#> GSM252424     3  0.0000      0.953 0.000 0.000 1.000
#> GSM252432     3  0.0000      0.953 0.000 0.000 1.000
#> GSM252427     3  0.0000      0.953 0.000 0.000 1.000
#> GSM252431     3  0.0000      0.953 0.000 0.000 1.000
#> GSM252430     3  0.0237      0.951 0.000 0.004 0.996
#> GSM252433     3  0.1529      0.927 0.000 0.040 0.960
#> GSM252426     3  0.0000      0.953 0.000 0.000 1.000
#> GSM252428     3  0.0000      0.953 0.000 0.000 1.000
#> GSM252425     2  0.3686      0.842 0.000 0.860 0.140
#> GSM252440     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252441     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252436     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252435     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252442     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252439     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252438     1  0.2066      0.938 0.940 0.000 0.060
#> GSM252434     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252437     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252451     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252448     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252447     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252444     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252450     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252452     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252443     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252454     1  0.1163      0.972 0.972 0.000 0.028
#> GSM252449     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252445     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252453     1  0.0000      0.993 1.000 0.000 0.000
#> GSM252464     3  0.1964      0.931 0.056 0.000 0.944
#> GSM252463     3  0.2625      0.909 0.084 0.000 0.916
#> GSM252461     1  0.0747      0.981 0.984 0.000 0.016
#> GSM252455     3  0.4178      0.816 0.172 0.000 0.828
#> GSM252458     3  0.1529      0.941 0.040 0.000 0.960
#> GSM252460     3  0.1031      0.947 0.024 0.000 0.976
#> GSM252457     3  0.0237      0.952 0.004 0.000 0.996
#> GSM252456     3  0.1643      0.939 0.044 0.000 0.956
#> GSM252462     3  0.5835      0.530 0.340 0.000 0.660
#> GSM252459     1  0.1529      0.961 0.960 0.000 0.040
#> GSM252472     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252466     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252469     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252475     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252471     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252465     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252474     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252473     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252468     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252470     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252467     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252485     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252481     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252480     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252479     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252482     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252478     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252483     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252477     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252484     2  0.0000      0.993 0.000 1.000 0.000
#> GSM252476     2  0.0000      0.993 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.0592      0.722 0.000 0.000 0.984 0.016
#> GSM252429     3  0.1637      0.709 0.000 0.000 0.940 0.060
#> GSM252424     3  0.0592      0.722 0.000 0.000 0.984 0.016
#> GSM252432     3  0.0188      0.722 0.000 0.000 0.996 0.004
#> GSM252427     3  0.0921      0.710 0.000 0.000 0.972 0.028
#> GSM252431     3  0.0921      0.718 0.000 0.000 0.972 0.028
#> GSM252430     3  0.4837      0.516 0.000 0.004 0.648 0.348
#> GSM252433     3  0.4917      0.526 0.000 0.008 0.656 0.336
#> GSM252426     3  0.0592      0.714 0.000 0.000 0.984 0.016
#> GSM252428     3  0.1867      0.662 0.000 0.000 0.928 0.072
#> GSM252425     3  0.6477      0.208 0.000 0.420 0.508 0.072
#> GSM252440     1  0.1389      0.772 0.952 0.000 0.000 0.048
#> GSM252441     1  0.0336      0.776 0.992 0.000 0.000 0.008
#> GSM252436     1  0.2814      0.776 0.868 0.000 0.000 0.132
#> GSM252435     1  0.3942      0.737 0.764 0.000 0.000 0.236
#> GSM252442     1  0.5289      0.622 0.636 0.000 0.020 0.344
#> GSM252439     1  0.4483      0.620 0.712 0.000 0.004 0.284
#> GSM252438     1  0.5837      0.440 0.564 0.000 0.036 0.400
#> GSM252434     1  0.4877      0.655 0.664 0.000 0.008 0.328
#> GSM252437     1  0.3311      0.763 0.828 0.000 0.000 0.172
#> GSM252451     1  0.2345      0.780 0.900 0.000 0.000 0.100
#> GSM252448     1  0.1389      0.774 0.952 0.000 0.000 0.048
#> GSM252447     1  0.0707      0.777 0.980 0.000 0.000 0.020
#> GSM252444     1  0.1302      0.782 0.956 0.000 0.000 0.044
#> GSM252450     1  0.3726      0.753 0.788 0.000 0.000 0.212
#> GSM252452     1  0.4560      0.703 0.700 0.000 0.004 0.296
#> GSM252443     1  0.3157      0.733 0.852 0.000 0.004 0.144
#> GSM252454     1  0.4245      0.696 0.784 0.000 0.020 0.196
#> GSM252449     1  0.4677      0.670 0.680 0.000 0.004 0.316
#> GSM252445     1  0.3873      0.737 0.772 0.000 0.000 0.228
#> GSM252453     1  0.1474      0.782 0.948 0.000 0.000 0.052
#> GSM252464     4  0.6315      0.817 0.060 0.000 0.432 0.508
#> GSM252463     4  0.7053      0.772 0.132 0.000 0.356 0.512
#> GSM252461     1  0.6442      0.198 0.492 0.000 0.068 0.440
#> GSM252455     4  0.7429      0.749 0.192 0.000 0.316 0.492
#> GSM252458     4  0.6125      0.821 0.048 0.000 0.436 0.516
#> GSM252460     4  0.5402      0.771 0.012 0.000 0.472 0.516
#> GSM252457     3  0.6243      0.118 0.060 0.000 0.548 0.392
#> GSM252456     4  0.5503      0.788 0.016 0.000 0.468 0.516
#> GSM252462     4  0.6845      0.767 0.128 0.000 0.308 0.564
#> GSM252459     1  0.6182      0.279 0.520 0.000 0.052 0.428
#> GSM252472     2  0.0336      0.961 0.000 0.992 0.000 0.008
#> GSM252466     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM252469     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM252475     2  0.0336      0.961 0.000 0.992 0.000 0.008
#> GSM252471     2  0.0188      0.961 0.000 0.996 0.000 0.004
#> GSM252465     2  0.0188      0.962 0.000 0.996 0.000 0.004
#> GSM252474     2  0.2814      0.878 0.000 0.868 0.000 0.132
#> GSM252473     2  0.0921      0.953 0.000 0.972 0.000 0.028
#> GSM252468     2  0.0188      0.962 0.000 0.996 0.000 0.004
#> GSM252470     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM252467     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM252485     2  0.0469      0.961 0.000 0.988 0.000 0.012
#> GSM252481     2  0.0188      0.962 0.000 0.996 0.000 0.004
#> GSM252480     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM252479     2  0.0188      0.962 0.000 0.996 0.000 0.004
#> GSM252482     2  0.3649      0.819 0.000 0.796 0.000 0.204
#> GSM252478     2  0.0469      0.960 0.000 0.988 0.000 0.012
#> GSM252483     2  0.3569      0.826 0.000 0.804 0.000 0.196
#> GSM252477     2  0.3837      0.798 0.000 0.776 0.000 0.224
#> GSM252484     2  0.0188      0.962 0.000 0.996 0.000 0.004
#> GSM252476     2  0.0188      0.961 0.000 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.1725     0.7069 0.000 0.000 0.936 0.020 0.044
#> GSM252429     3  0.2946     0.6623 0.000 0.000 0.868 0.044 0.088
#> GSM252424     3  0.1278     0.7132 0.000 0.004 0.960 0.016 0.020
#> GSM252432     3  0.1117     0.7114 0.000 0.000 0.964 0.016 0.020
#> GSM252427     3  0.1670     0.7061 0.000 0.000 0.936 0.052 0.012
#> GSM252431     3  0.1818     0.7008 0.000 0.000 0.932 0.044 0.024
#> GSM252430     5  0.5078    -0.3299 0.000 0.008 0.464 0.020 0.508
#> GSM252433     3  0.5493    -0.1509 0.000 0.004 0.488 0.052 0.456
#> GSM252426     3  0.1670     0.7060 0.000 0.000 0.936 0.052 0.012
#> GSM252428     3  0.3152     0.6449 0.000 0.000 0.840 0.136 0.024
#> GSM252425     3  0.6437     0.1747 0.000 0.308 0.552 0.028 0.112
#> GSM252440     1  0.2569     0.6473 0.892 0.000 0.000 0.040 0.068
#> GSM252441     1  0.1648     0.6700 0.940 0.000 0.000 0.020 0.040
#> GSM252436     1  0.2110     0.6801 0.912 0.000 0.000 0.072 0.016
#> GSM252435     1  0.5156     0.5787 0.668 0.000 0.004 0.256 0.072
#> GSM252442     4  0.6049    -0.4066 0.456 0.000 0.024 0.460 0.060
#> GSM252439     1  0.6444     0.0690 0.476 0.000 0.012 0.128 0.384
#> GSM252438     5  0.6950    -0.1865 0.320 0.000 0.016 0.212 0.452
#> GSM252434     1  0.5461     0.4178 0.528 0.000 0.000 0.408 0.064
#> GSM252437     1  0.4924     0.5879 0.668 0.000 0.000 0.272 0.060
#> GSM252451     1  0.3771     0.6554 0.796 0.000 0.000 0.164 0.040
#> GSM252448     1  0.2588     0.6493 0.892 0.000 0.000 0.048 0.060
#> GSM252447     1  0.1195     0.6674 0.960 0.000 0.000 0.012 0.028
#> GSM252444     1  0.1522     0.6817 0.944 0.000 0.000 0.044 0.012
#> GSM252450     1  0.4459     0.6352 0.744 0.000 0.004 0.200 0.052
#> GSM252452     1  0.6297     0.5109 0.556 0.000 0.004 0.236 0.204
#> GSM252443     1  0.5847     0.4415 0.624 0.000 0.008 0.132 0.236
#> GSM252454     1  0.6681     0.2549 0.512 0.000 0.012 0.208 0.268
#> GSM252449     1  0.5467     0.4181 0.524 0.000 0.000 0.412 0.064
#> GSM252445     1  0.5315     0.5184 0.600 0.000 0.000 0.332 0.068
#> GSM252453     1  0.3970     0.6500 0.800 0.000 0.000 0.096 0.104
#> GSM252464     4  0.6202     0.6258 0.080 0.000 0.272 0.604 0.044
#> GSM252463     4  0.7280     0.5804 0.148 0.000 0.224 0.536 0.092
#> GSM252461     1  0.5945    -0.0942 0.464 0.000 0.024 0.460 0.052
#> GSM252455     4  0.6932     0.6112 0.164 0.000 0.220 0.560 0.056
#> GSM252458     4  0.5741     0.5767 0.044 0.000 0.332 0.592 0.032
#> GSM252460     4  0.4792     0.5812 0.020 0.000 0.312 0.656 0.012
#> GSM252457     3  0.7742    -0.1111 0.060 0.000 0.356 0.344 0.240
#> GSM252456     4  0.5123     0.5915 0.028 0.000 0.308 0.644 0.020
#> GSM252462     4  0.5152     0.6115 0.072 0.000 0.176 0.724 0.028
#> GSM252459     4  0.6953     0.0214 0.360 0.000 0.036 0.464 0.140
#> GSM252472     2  0.1478     0.8895 0.000 0.936 0.000 0.000 0.064
#> GSM252466     2  0.0609     0.8982 0.000 0.980 0.000 0.000 0.020
#> GSM252469     2  0.0162     0.8975 0.000 0.996 0.000 0.000 0.004
#> GSM252475     2  0.1341     0.8897 0.000 0.944 0.000 0.000 0.056
#> GSM252471     2  0.1197     0.8949 0.000 0.952 0.000 0.000 0.048
#> GSM252465     2  0.1121     0.8905 0.000 0.956 0.000 0.000 0.044
#> GSM252474     2  0.3999     0.6371 0.000 0.656 0.000 0.000 0.344
#> GSM252473     2  0.2011     0.8734 0.000 0.908 0.000 0.004 0.088
#> GSM252468     2  0.0609     0.8956 0.000 0.980 0.000 0.000 0.020
#> GSM252470     2  0.0955     0.8929 0.000 0.968 0.000 0.004 0.028
#> GSM252467     2  0.0671     0.8984 0.000 0.980 0.000 0.004 0.016
#> GSM252485     2  0.1197     0.8957 0.000 0.952 0.000 0.000 0.048
#> GSM252481     2  0.0609     0.8982 0.000 0.980 0.000 0.000 0.020
#> GSM252480     2  0.0290     0.8983 0.000 0.992 0.000 0.000 0.008
#> GSM252479     2  0.0510     0.8984 0.000 0.984 0.000 0.000 0.016
#> GSM252482     2  0.4268     0.5075 0.000 0.556 0.000 0.000 0.444
#> GSM252478     2  0.1410     0.8903 0.000 0.940 0.000 0.000 0.060
#> GSM252483     2  0.4219     0.5465 0.000 0.584 0.000 0.000 0.416
#> GSM252477     2  0.4287     0.4797 0.000 0.540 0.000 0.000 0.460
#> GSM252484     2  0.0703     0.8981 0.000 0.976 0.000 0.000 0.024
#> GSM252476     2  0.0609     0.8985 0.000 0.980 0.000 0.000 0.020

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.1036     0.8043 0.000 0.000 0.964 0.024 0.008 0.004
#> GSM252429     3  0.3177     0.7568 0.000 0.000 0.856 0.052 0.052 0.040
#> GSM252424     3  0.1913     0.7973 0.000 0.000 0.924 0.044 0.016 0.016
#> GSM252432     3  0.1173     0.8048 0.000 0.000 0.960 0.016 0.016 0.008
#> GSM252427     3  0.3339     0.7655 0.000 0.000 0.836 0.100 0.040 0.024
#> GSM252431     3  0.4360     0.7399 0.000 0.004 0.780 0.084 0.056 0.076
#> GSM252430     5  0.5566    -0.0118 0.000 0.012 0.312 0.000 0.556 0.120
#> GSM252433     5  0.6302    -0.1208 0.000 0.004 0.332 0.016 0.456 0.192
#> GSM252426     3  0.2252     0.8020 0.000 0.000 0.900 0.072 0.016 0.012
#> GSM252428     3  0.4149     0.7186 0.004 0.000 0.772 0.152 0.048 0.024
#> GSM252425     3  0.7543     0.1790 0.004 0.252 0.452 0.024 0.160 0.108
#> GSM252440     1  0.3753     0.5037 0.788 0.000 0.000 0.040 0.016 0.156
#> GSM252441     1  0.1841     0.5569 0.920 0.000 0.000 0.008 0.008 0.064
#> GSM252436     1  0.2963     0.5868 0.856 0.000 0.000 0.096 0.012 0.036
#> GSM252435     1  0.6248     0.4430 0.548 0.000 0.004 0.248 0.040 0.160
#> GSM252442     4  0.6882    -0.2943 0.364 0.000 0.004 0.416 0.092 0.124
#> GSM252439     6  0.6490     0.2856 0.348 0.000 0.008 0.052 0.116 0.476
#> GSM252438     6  0.6442     0.4224 0.220 0.000 0.016 0.068 0.120 0.576
#> GSM252434     1  0.6901     0.2881 0.428 0.000 0.004 0.348 0.096 0.124
#> GSM252437     1  0.6102     0.5109 0.600 0.000 0.000 0.184 0.084 0.132
#> GSM252451     1  0.4500     0.5668 0.752 0.000 0.000 0.132 0.040 0.076
#> GSM252448     1  0.3496     0.5334 0.820 0.000 0.000 0.036 0.024 0.120
#> GSM252447     1  0.2102     0.5604 0.908 0.000 0.000 0.012 0.012 0.068
#> GSM252444     1  0.2711     0.5906 0.872 0.000 0.000 0.084 0.008 0.036
#> GSM252450     1  0.5950     0.4877 0.596 0.000 0.000 0.220 0.056 0.128
#> GSM252452     1  0.7446     0.2213 0.428 0.000 0.008 0.144 0.188 0.232
#> GSM252443     1  0.5857    -0.0345 0.492 0.000 0.004 0.040 0.068 0.396
#> GSM252454     1  0.6227    -0.0855 0.432 0.000 0.008 0.088 0.044 0.428
#> GSM252449     1  0.6741     0.3291 0.464 0.000 0.004 0.328 0.088 0.116
#> GSM252445     1  0.6755     0.4644 0.524 0.000 0.004 0.224 0.104 0.144
#> GSM252453     1  0.4492     0.5024 0.712 0.000 0.000 0.052 0.020 0.216
#> GSM252464     4  0.4748     0.5473 0.040 0.000 0.208 0.708 0.004 0.040
#> GSM252463     4  0.6885     0.4349 0.108 0.000 0.192 0.552 0.024 0.124
#> GSM252461     4  0.6263     0.2130 0.368 0.000 0.036 0.484 0.012 0.100
#> GSM252455     4  0.6115     0.5273 0.136 0.000 0.192 0.612 0.020 0.040
#> GSM252458     4  0.5325     0.5369 0.032 0.000 0.228 0.664 0.016 0.060
#> GSM252460     4  0.4883     0.5244 0.008 0.000 0.244 0.680 0.036 0.032
#> GSM252457     6  0.7896     0.0856 0.028 0.000 0.240 0.260 0.120 0.352
#> GSM252456     4  0.4428     0.5443 0.020 0.000 0.240 0.708 0.024 0.008
#> GSM252462     4  0.5383     0.4989 0.068 0.000 0.108 0.716 0.028 0.080
#> GSM252459     4  0.7479     0.0280 0.304 0.000 0.032 0.340 0.048 0.276
#> GSM252472     2  0.2367     0.8617 0.000 0.888 0.000 0.008 0.088 0.016
#> GSM252466     2  0.1745     0.8710 0.000 0.924 0.000 0.000 0.056 0.020
#> GSM252469     2  0.0622     0.8782 0.000 0.980 0.000 0.000 0.012 0.008
#> GSM252475     2  0.1584     0.8710 0.000 0.928 0.000 0.008 0.064 0.000
#> GSM252471     2  0.2620     0.8434 0.000 0.868 0.000 0.012 0.108 0.012
#> GSM252465     2  0.2976     0.8256 0.000 0.860 0.000 0.024 0.088 0.028
#> GSM252474     2  0.4025    -0.0566 0.000 0.576 0.000 0.000 0.416 0.008
#> GSM252473     2  0.2949     0.8046 0.000 0.832 0.000 0.000 0.140 0.028
#> GSM252468     2  0.2133     0.8642 0.000 0.912 0.000 0.016 0.052 0.020
#> GSM252470     2  0.2432     0.8519 0.000 0.892 0.000 0.016 0.072 0.020
#> GSM252467     2  0.1053     0.8811 0.000 0.964 0.000 0.004 0.020 0.012
#> GSM252485     2  0.2537     0.8530 0.000 0.880 0.000 0.008 0.088 0.024
#> GSM252481     2  0.1297     0.8778 0.000 0.948 0.000 0.000 0.040 0.012
#> GSM252480     2  0.0632     0.8791 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM252479     2  0.1370     0.8797 0.000 0.948 0.000 0.004 0.036 0.012
#> GSM252482     5  0.3966     0.3265 0.000 0.444 0.000 0.000 0.552 0.004
#> GSM252478     2  0.3792     0.7876 0.000 0.808 0.004 0.024 0.116 0.048
#> GSM252483     5  0.4184     0.2177 0.000 0.488 0.000 0.000 0.500 0.012
#> GSM252477     5  0.4144     0.3650 0.000 0.408 0.000 0.004 0.580 0.008
#> GSM252484     2  0.2114     0.8663 0.000 0.904 0.000 0.008 0.076 0.012
#> GSM252476     2  0.1036     0.8807 0.000 0.964 0.000 0.004 0.024 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)

plot of chunk tab-SD-skmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-SD-skmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-SD-skmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-SD-skmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-SD-skmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-SD-skmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-SD-skmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-SD-skmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-SD-skmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-SD-skmeans-membership-heatmap-5

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)

plot of chunk tab-SD-skmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-SD-skmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-SD-skmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-SD-skmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-SD-skmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-SD-skmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-SD-skmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-SD-skmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-SD-skmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-SD-skmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-skmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-SD-skmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-SD-skmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-SD-skmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-SD-skmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-SD-skmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-skmeans-collect-classes

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 agent(p) individual(p) k
#> SD:skmeans 61 4.91e-10         0.973 2
#> SD:skmeans 62 1.18e-18         1.000 3
#> SD:skmeans 57 1.54e-28         1.000 4
#> SD:skmeans 48 3.73e-23         1.000 5
#> SD:skmeans 39 7.22e-18         0.995 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.


SD:pam**

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 51941 rows and 62 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 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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:

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)

plot of chunk SD-pam-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.867           0.912       0.962         0.4976 0.497   0.497
#> 3 3 0.978           0.936       0.975         0.3345 0.783   0.587
#> 4 4 0.852           0.792       0.895         0.1119 0.915   0.750
#> 5 5 0.732           0.642       0.807         0.0618 0.939   0.765
#> 6 6 0.744           0.670       0.792         0.0269 0.940   0.728

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 3

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1  0.0376      0.972 0.996 0.004
#> GSM252429     1  0.8555      0.589 0.720 0.280
#> GSM252424     2  0.9732      0.382 0.404 0.596
#> GSM252432     1  0.6712      0.773 0.824 0.176
#> GSM252427     2  0.9460      0.481 0.364 0.636
#> GSM252431     2  0.9427      0.487 0.360 0.640
#> GSM252430     2  0.4431      0.867 0.092 0.908
#> GSM252433     2  0.6623      0.788 0.172 0.828
#> GSM252426     1  0.8713      0.566 0.708 0.292
#> GSM252428     2  0.7219      0.757 0.200 0.800
#> GSM252425     2  0.0000      0.939 0.000 1.000
#> GSM252440     1  0.0000      0.975 1.000 0.000
#> GSM252441     1  0.0000      0.975 1.000 0.000
#> GSM252436     1  0.0000      0.975 1.000 0.000
#> GSM252435     1  0.0000      0.975 1.000 0.000
#> GSM252442     1  0.0000      0.975 1.000 0.000
#> GSM252439     1  0.0000      0.975 1.000 0.000
#> GSM252438     1  0.0000      0.975 1.000 0.000
#> GSM252434     1  0.0000      0.975 1.000 0.000
#> GSM252437     1  0.0000      0.975 1.000 0.000
#> GSM252451     1  0.0000      0.975 1.000 0.000
#> GSM252448     1  0.0000      0.975 1.000 0.000
#> GSM252447     1  0.0000      0.975 1.000 0.000
#> GSM252444     1  0.0000      0.975 1.000 0.000
#> GSM252450     1  0.0000      0.975 1.000 0.000
#> GSM252452     1  0.0000      0.975 1.000 0.000
#> GSM252443     1  0.0000      0.975 1.000 0.000
#> GSM252454     1  0.0000      0.975 1.000 0.000
#> GSM252449     1  0.0000      0.975 1.000 0.000
#> GSM252445     1  0.0000      0.975 1.000 0.000
#> GSM252453     1  0.0000      0.975 1.000 0.000
#> GSM252464     1  0.0000      0.975 1.000 0.000
#> GSM252463     1  0.0000      0.975 1.000 0.000
#> GSM252461     1  0.0000      0.975 1.000 0.000
#> GSM252455     1  0.0000      0.975 1.000 0.000
#> GSM252458     1  0.0000      0.975 1.000 0.000
#> GSM252460     1  0.0000      0.975 1.000 0.000
#> GSM252457     1  0.0000      0.975 1.000 0.000
#> GSM252456     1  0.0000      0.975 1.000 0.000
#> GSM252462     1  0.0000      0.975 1.000 0.000
#> GSM252459     1  0.0000      0.975 1.000 0.000
#> GSM252472     2  0.0000      0.939 0.000 1.000
#> GSM252466     2  0.0000      0.939 0.000 1.000
#> GSM252469     2  0.0000      0.939 0.000 1.000
#> GSM252475     2  0.0000      0.939 0.000 1.000
#> GSM252471     2  0.0000      0.939 0.000 1.000
#> GSM252465     2  0.0000      0.939 0.000 1.000
#> GSM252474     2  0.0000      0.939 0.000 1.000
#> GSM252473     2  0.0000      0.939 0.000 1.000
#> GSM252468     2  0.0000      0.939 0.000 1.000
#> GSM252470     2  0.0000      0.939 0.000 1.000
#> GSM252467     2  0.0000      0.939 0.000 1.000
#> GSM252485     2  0.0000      0.939 0.000 1.000
#> GSM252481     2  0.0000      0.939 0.000 1.000
#> GSM252480     2  0.0000      0.939 0.000 1.000
#> GSM252479     2  0.0000      0.939 0.000 1.000
#> GSM252482     2  0.0000      0.939 0.000 1.000
#> GSM252478     2  0.0000      0.939 0.000 1.000
#> GSM252483     2  0.0000      0.939 0.000 1.000
#> GSM252477     2  0.0000      0.939 0.000 1.000
#> GSM252484     2  0.0000      0.939 0.000 1.000
#> GSM252476     2  0.0000      0.939 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.0000      0.964 0.000 0.000 1.000
#> GSM252429     3  0.0000      0.964 0.000 0.000 1.000
#> GSM252424     3  0.0000      0.964 0.000 0.000 1.000
#> GSM252432     3  0.0000      0.964 0.000 0.000 1.000
#> GSM252427     3  0.0000      0.964 0.000 0.000 1.000
#> GSM252431     3  0.0000      0.964 0.000 0.000 1.000
#> GSM252430     3  0.0000      0.964 0.000 0.000 1.000
#> GSM252433     3  0.0000      0.964 0.000 0.000 1.000
#> GSM252426     3  0.0000      0.964 0.000 0.000 1.000
#> GSM252428     3  0.0000      0.964 0.000 0.000 1.000
#> GSM252425     3  0.0424      0.959 0.000 0.008 0.992
#> GSM252440     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252441     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252436     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252435     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252442     1  0.0237      0.951 0.996 0.000 0.004
#> GSM252439     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252438     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252434     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252437     1  0.0424      0.948 0.992 0.000 0.008
#> GSM252451     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252448     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252447     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252444     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252450     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252452     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252443     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252454     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252449     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252445     1  0.0424      0.948 0.992 0.000 0.008
#> GSM252453     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252464     1  0.6192      0.256 0.580 0.000 0.420
#> GSM252463     1  0.4452      0.743 0.808 0.000 0.192
#> GSM252461     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252455     1  0.6267      0.152 0.548 0.000 0.452
#> GSM252458     3  0.3686      0.831 0.140 0.000 0.860
#> GSM252460     3  0.1163      0.947 0.028 0.000 0.972
#> GSM252457     3  0.1163      0.948 0.028 0.000 0.972
#> GSM252456     3  0.5254      0.632 0.264 0.000 0.736
#> GSM252462     1  0.0592      0.945 0.988 0.000 0.012
#> GSM252459     1  0.0000      0.953 1.000 0.000 0.000
#> GSM252472     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252466     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252469     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252475     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252471     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252465     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252474     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252473     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252468     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252470     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252467     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252485     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252481     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252480     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252479     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252482     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252478     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252483     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252477     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252484     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252476     2  0.0000      1.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.0000     0.9496 0.000 0.000 1.000 0.000
#> GSM252429     3  0.0000     0.9496 0.000 0.000 1.000 0.000
#> GSM252424     3  0.0000     0.9496 0.000 0.000 1.000 0.000
#> GSM252432     3  0.0000     0.9496 0.000 0.000 1.000 0.000
#> GSM252427     3  0.0000     0.9496 0.000 0.000 1.000 0.000
#> GSM252431     3  0.0000     0.9496 0.000 0.000 1.000 0.000
#> GSM252430     3  0.0336     0.9464 0.000 0.000 0.992 0.008
#> GSM252433     3  0.0000     0.9496 0.000 0.000 1.000 0.000
#> GSM252426     3  0.0000     0.9496 0.000 0.000 1.000 0.000
#> GSM252428     3  0.0000     0.9496 0.000 0.000 1.000 0.000
#> GSM252425     3  0.0469     0.9414 0.000 0.012 0.988 0.000
#> GSM252440     4  0.4222     0.7385 0.272 0.000 0.000 0.728
#> GSM252441     4  0.4250     0.7366 0.276 0.000 0.000 0.724
#> GSM252436     4  0.3688     0.7047 0.208 0.000 0.000 0.792
#> GSM252435     1  0.1022     0.7389 0.968 0.000 0.000 0.032
#> GSM252442     1  0.0707     0.7415 0.980 0.000 0.000 0.020
#> GSM252439     1  0.2647     0.6672 0.880 0.000 0.000 0.120
#> GSM252438     1  0.4994    -0.3645 0.520 0.000 0.000 0.480
#> GSM252434     1  0.0707     0.7415 0.980 0.000 0.000 0.020
#> GSM252437     1  0.0469     0.7427 0.988 0.000 0.000 0.012
#> GSM252451     4  0.4888     0.6047 0.412 0.000 0.000 0.588
#> GSM252448     4  0.4605     0.6613 0.336 0.000 0.000 0.664
#> GSM252447     4  0.4222     0.7385 0.272 0.000 0.000 0.728
#> GSM252444     4  0.4500     0.7263 0.316 0.000 0.000 0.684
#> GSM252450     1  0.4522     0.3577 0.680 0.000 0.000 0.320
#> GSM252452     1  0.0188     0.7457 0.996 0.000 0.000 0.004
#> GSM252443     1  0.0000     0.7455 1.000 0.000 0.000 0.000
#> GSM252454     1  0.4304     0.3639 0.716 0.000 0.000 0.284
#> GSM252449     1  0.1557     0.7229 0.944 0.000 0.000 0.056
#> GSM252445     1  0.0000     0.7455 1.000 0.000 0.000 0.000
#> GSM252453     1  0.4661     0.2245 0.652 0.000 0.000 0.348
#> GSM252464     1  0.5905     0.1419 0.564 0.000 0.040 0.396
#> GSM252463     4  0.5471     0.5234 0.268 0.000 0.048 0.684
#> GSM252461     4  0.3610     0.6779 0.200 0.000 0.000 0.800
#> GSM252455     4  0.4214     0.6626 0.204 0.000 0.016 0.780
#> GSM252458     3  0.6613     0.5605 0.172 0.000 0.628 0.200
#> GSM252460     3  0.2032     0.9131 0.036 0.000 0.936 0.028
#> GSM252457     3  0.2060     0.9098 0.052 0.000 0.932 0.016
#> GSM252456     3  0.3852     0.7559 0.180 0.000 0.808 0.012
#> GSM252462     1  0.1022     0.7412 0.968 0.000 0.000 0.032
#> GSM252459     1  0.4790     0.0925 0.620 0.000 0.000 0.380
#> GSM252472     2  0.0469     0.9839 0.000 0.988 0.000 0.012
#> GSM252466     2  0.0921     0.9829 0.000 0.972 0.000 0.028
#> GSM252469     2  0.0921     0.9829 0.000 0.972 0.000 0.028
#> GSM252475     2  0.0921     0.9829 0.000 0.972 0.000 0.028
#> GSM252471     2  0.0000     0.9836 0.000 1.000 0.000 0.000
#> GSM252465     2  0.0000     0.9836 0.000 1.000 0.000 0.000
#> GSM252474     2  0.0336     0.9810 0.000 0.992 0.000 0.008
#> GSM252473     2  0.0000     0.9836 0.000 1.000 0.000 0.000
#> GSM252468     2  0.0000     0.9836 0.000 1.000 0.000 0.000
#> GSM252470     2  0.0000     0.9836 0.000 1.000 0.000 0.000
#> GSM252467     2  0.0921     0.9829 0.000 0.972 0.000 0.028
#> GSM252485     2  0.0817     0.9833 0.000 0.976 0.000 0.024
#> GSM252481     2  0.0921     0.9829 0.000 0.972 0.000 0.028
#> GSM252480     2  0.0921     0.9829 0.000 0.972 0.000 0.028
#> GSM252479     2  0.0921     0.9829 0.000 0.972 0.000 0.028
#> GSM252482     2  0.1302     0.9618 0.000 0.956 0.000 0.044
#> GSM252478     2  0.0000     0.9836 0.000 1.000 0.000 0.000
#> GSM252483     2  0.1302     0.9618 0.000 0.956 0.000 0.044
#> GSM252477     2  0.1302     0.9618 0.000 0.956 0.000 0.044
#> GSM252484     2  0.0000     0.9836 0.000 1.000 0.000 0.000
#> GSM252476     2  0.0921     0.9829 0.000 0.972 0.000 0.028

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.0000    0.94060 0.000 0.000 1.000 0.000 0.000
#> GSM252429     3  0.0000    0.94060 0.000 0.000 1.000 0.000 0.000
#> GSM252424     3  0.0000    0.94060 0.000 0.000 1.000 0.000 0.000
#> GSM252432     3  0.0000    0.94060 0.000 0.000 1.000 0.000 0.000
#> GSM252427     3  0.0162    0.93974 0.000 0.000 0.996 0.000 0.004
#> GSM252431     3  0.0000    0.94060 0.000 0.000 1.000 0.000 0.000
#> GSM252430     3  0.0880    0.92781 0.000 0.000 0.968 0.000 0.032
#> GSM252433     3  0.0404    0.93755 0.000 0.000 0.988 0.000 0.012
#> GSM252426     3  0.0000    0.94060 0.000 0.000 1.000 0.000 0.000
#> GSM252428     3  0.0000    0.94060 0.000 0.000 1.000 0.000 0.000
#> GSM252425     3  0.0404    0.93530 0.000 0.012 0.988 0.000 0.000
#> GSM252440     1  0.2886    0.73929 0.844 0.000 0.000 0.148 0.008
#> GSM252441     1  0.2690    0.74065 0.844 0.000 0.000 0.156 0.000
#> GSM252436     1  0.3074    0.71146 0.804 0.000 0.000 0.196 0.000
#> GSM252435     4  0.1809    0.75242 0.012 0.000 0.000 0.928 0.060
#> GSM252442     4  0.0671    0.76046 0.016 0.000 0.000 0.980 0.004
#> GSM252439     4  0.3304    0.65209 0.168 0.000 0.000 0.816 0.016
#> GSM252438     1  0.6247    0.44616 0.484 0.000 0.000 0.364 0.152
#> GSM252434     4  0.0510    0.76112 0.016 0.000 0.000 0.984 0.000
#> GSM252437     4  0.1430    0.75686 0.004 0.000 0.000 0.944 0.052
#> GSM252451     1  0.4150    0.60093 0.612 0.000 0.000 0.388 0.000
#> GSM252448     1  0.3487    0.70402 0.780 0.000 0.000 0.212 0.008
#> GSM252447     1  0.2648    0.74077 0.848 0.000 0.000 0.152 0.000
#> GSM252444     1  0.3424    0.73454 0.760 0.000 0.000 0.240 0.000
#> GSM252450     4  0.4920    0.36283 0.308 0.000 0.000 0.644 0.048
#> GSM252452     4  0.0000    0.76441 0.000 0.000 0.000 1.000 0.000
#> GSM252443     4  0.0404    0.76392 0.000 0.000 0.000 0.988 0.012
#> GSM252454     4  0.5323    0.29656 0.296 0.000 0.000 0.624 0.080
#> GSM252449     4  0.1270    0.74427 0.052 0.000 0.000 0.948 0.000
#> GSM252445     4  0.0000    0.76441 0.000 0.000 0.000 1.000 0.000
#> GSM252453     4  0.5215    0.13229 0.372 0.000 0.000 0.576 0.052
#> GSM252464     4  0.5703    0.28463 0.340 0.000 0.032 0.588 0.040
#> GSM252463     1  0.5442    0.56766 0.676 0.000 0.020 0.228 0.076
#> GSM252461     1  0.4219    0.67693 0.772 0.000 0.000 0.156 0.072
#> GSM252455     1  0.4062    0.67055 0.764 0.000 0.000 0.196 0.040
#> GSM252458     3  0.6867    0.50592 0.140 0.000 0.592 0.184 0.084
#> GSM252460     3  0.2363    0.89217 0.012 0.000 0.912 0.052 0.024
#> GSM252457     3  0.2734    0.87927 0.008 0.000 0.892 0.052 0.048
#> GSM252456     3  0.3160    0.76235 0.004 0.000 0.808 0.188 0.000
#> GSM252462     4  0.2238    0.74690 0.020 0.000 0.004 0.912 0.064
#> GSM252459     4  0.5624   -0.00034 0.388 0.000 0.000 0.532 0.080
#> GSM252472     2  0.2648    0.34204 0.000 0.848 0.000 0.000 0.152
#> GSM252466     5  0.4297    0.96411 0.000 0.472 0.000 0.000 0.528
#> GSM252469     5  0.4304    0.97502 0.000 0.484 0.000 0.000 0.516
#> GSM252475     2  0.4219   -0.76226 0.000 0.584 0.000 0.000 0.416
#> GSM252471     2  0.0290    0.64541 0.000 0.992 0.000 0.000 0.008
#> GSM252465     2  0.0000    0.65119 0.000 1.000 0.000 0.000 0.000
#> GSM252474     2  0.1341    0.62723 0.000 0.944 0.000 0.000 0.056
#> GSM252473     2  0.0162    0.64844 0.000 0.996 0.000 0.000 0.004
#> GSM252468     2  0.0000    0.65119 0.000 1.000 0.000 0.000 0.000
#> GSM252470     2  0.0162    0.65009 0.000 0.996 0.004 0.000 0.000
#> GSM252467     5  0.4307    0.96244 0.000 0.500 0.000 0.000 0.500
#> GSM252485     2  0.4060   -0.57552 0.000 0.640 0.000 0.000 0.360
#> GSM252481     5  0.4300    0.97032 0.000 0.476 0.000 0.000 0.524
#> GSM252480     5  0.4304    0.97502 0.000 0.484 0.000 0.000 0.516
#> GSM252479     2  0.4268   -0.83845 0.000 0.556 0.000 0.000 0.444
#> GSM252482     2  0.4009    0.46988 0.004 0.684 0.000 0.000 0.312
#> GSM252478     2  0.0000    0.65119 0.000 1.000 0.000 0.000 0.000
#> GSM252483     2  0.4009    0.46988 0.004 0.684 0.000 0.000 0.312
#> GSM252477     2  0.4009    0.46988 0.004 0.684 0.000 0.000 0.312
#> GSM252484     2  0.0000    0.65119 0.000 1.000 0.000 0.000 0.000
#> GSM252476     5  0.4307    0.96244 0.000 0.500 0.000 0.000 0.500

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.0000      0.929 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252429     3  0.0146      0.929 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM252424     3  0.0000      0.929 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252432     3  0.0000      0.929 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252427     3  0.0260      0.928 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM252431     3  0.0000      0.929 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252430     3  0.1643      0.891 0.000 0.000 0.924 0.008 0.068 0.000
#> GSM252433     3  0.0508      0.926 0.000 0.000 0.984 0.012 0.004 0.000
#> GSM252426     3  0.0000      0.929 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252428     3  0.0000      0.929 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252425     3  0.0692      0.922 0.000 0.000 0.976 0.020 0.004 0.000
#> GSM252440     1  0.2971      0.726 0.844 0.000 0.000 0.052 0.000 0.104
#> GSM252441     1  0.1957      0.739 0.888 0.000 0.000 0.000 0.000 0.112
#> GSM252436     1  0.3709      0.704 0.756 0.000 0.000 0.040 0.000 0.204
#> GSM252435     6  0.2103      0.756 0.012 0.000 0.000 0.056 0.020 0.912
#> GSM252442     6  0.1092      0.761 0.020 0.000 0.000 0.020 0.000 0.960
#> GSM252439     6  0.3432      0.666 0.148 0.000 0.000 0.052 0.000 0.800
#> GSM252438     4  0.5971     -0.567 0.264 0.000 0.000 0.448 0.000 0.288
#> GSM252434     6  0.0806      0.764 0.020 0.000 0.000 0.008 0.000 0.972
#> GSM252437     6  0.1082      0.766 0.004 0.000 0.000 0.040 0.000 0.956
#> GSM252451     1  0.3975      0.517 0.600 0.000 0.000 0.008 0.000 0.392
#> GSM252448     1  0.3542      0.695 0.788 0.000 0.000 0.052 0.000 0.160
#> GSM252447     1  0.1910      0.739 0.892 0.000 0.000 0.000 0.000 0.108
#> GSM252444     1  0.2697      0.735 0.812 0.000 0.000 0.000 0.000 0.188
#> GSM252450     6  0.4970      0.377 0.300 0.000 0.000 0.060 0.016 0.624
#> GSM252452     6  0.0291      0.768 0.004 0.000 0.000 0.004 0.000 0.992
#> GSM252443     6  0.0790      0.767 0.000 0.000 0.000 0.032 0.000 0.968
#> GSM252454     6  0.4831      0.416 0.268 0.000 0.000 0.096 0.000 0.636
#> GSM252449     6  0.1524      0.747 0.060 0.000 0.000 0.008 0.000 0.932
#> GSM252445     6  0.0000      0.769 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM252453     6  0.4970      0.270 0.336 0.000 0.000 0.084 0.000 0.580
#> GSM252464     6  0.6014      0.284 0.284 0.000 0.032 0.088 0.020 0.576
#> GSM252463     1  0.6175      0.546 0.568 0.000 0.016 0.188 0.020 0.208
#> GSM252461     1  0.4723      0.659 0.704 0.000 0.000 0.108 0.012 0.176
#> GSM252455     1  0.4883      0.660 0.700 0.000 0.004 0.084 0.020 0.192
#> GSM252458     3  0.6631      0.490 0.096 0.000 0.580 0.128 0.020 0.176
#> GSM252460     3  0.2699      0.869 0.008 0.000 0.888 0.036 0.016 0.052
#> GSM252457     3  0.2753      0.863 0.008 0.000 0.872 0.072 0.000 0.048
#> GSM252456     3  0.2915      0.762 0.000 0.000 0.808 0.008 0.000 0.184
#> GSM252462     6  0.2324      0.758 0.016 0.000 0.008 0.048 0.020 0.908
#> GSM252459     6  0.5277      0.150 0.364 0.000 0.000 0.108 0.000 0.528
#> GSM252472     2  0.5724     -0.426 0.000 0.492 0.000 0.324 0.184 0.000
#> GSM252466     2  0.0363      0.815 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM252469     2  0.0000      0.822 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252475     2  0.3394      0.654 0.000 0.804 0.000 0.144 0.052 0.000
#> GSM252471     4  0.6014      0.704 0.000 0.368 0.000 0.392 0.240 0.000
#> GSM252465     4  0.5997      0.738 0.000 0.344 0.000 0.416 0.240 0.000
#> GSM252474     5  0.6082     -0.589 0.000 0.356 0.000 0.272 0.372 0.000
#> GSM252473     4  0.5992      0.728 0.000 0.352 0.000 0.412 0.236 0.000
#> GSM252468     4  0.5997      0.738 0.000 0.344 0.000 0.416 0.240 0.000
#> GSM252470     4  0.6123      0.733 0.000 0.344 0.004 0.412 0.240 0.000
#> GSM252467     2  0.0622      0.823 0.000 0.980 0.000 0.008 0.012 0.000
#> GSM252485     2  0.3940      0.567 0.000 0.764 0.000 0.140 0.096 0.000
#> GSM252481     2  0.0260      0.818 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM252480     2  0.0000      0.822 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252479     2  0.1970      0.780 0.000 0.912 0.000 0.028 0.060 0.000
#> GSM252482     5  0.0547      0.722 0.000 0.020 0.000 0.000 0.980 0.000
#> GSM252478     4  0.5997      0.738 0.000 0.344 0.000 0.416 0.240 0.000
#> GSM252483     5  0.0547      0.722 0.000 0.020 0.000 0.000 0.980 0.000
#> GSM252477     5  0.0547      0.722 0.000 0.020 0.000 0.000 0.980 0.000
#> GSM252484     4  0.5997      0.738 0.000 0.344 0.000 0.416 0.240 0.000
#> GSM252476     2  0.0622      0.823 0.000 0.980 0.000 0.008 0.012 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)

plot of chunk tab-SD-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-SD-pam-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-SD-pam-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-SD-pam-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-SD-pam-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-SD-pam-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-SD-pam-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-SD-pam-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-SD-pam-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-SD-pam-membership-heatmap-5

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)

plot of chunk tab-SD-pam-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-SD-pam-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-SD-pam-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-SD-pam-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-SD-pam-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-SD-pam-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-SD-pam-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-SD-pam-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-SD-pam-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-SD-pam-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-pam-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-SD-pam-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-SD-pam-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-SD-pam-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-SD-pam-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-SD-pam-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-pam-collect-classes

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 agent(p) individual(p) k
#> SD:pam 59 9.46e-10         0.996 2
#> SD:pam 60 2.15e-18         1.000 3
#> SD:pam 56 6.12e-15         0.340 4
#> SD:pam 49 2.95e-11         0.071 5
#> SD:pam 53 1.25e-12         0.124 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.


SD:mclust**

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 51941 rows and 62 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 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)

plot of chunk SD-mclust-collect-plots

The plots are:

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:

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)

plot of chunk SD-mclust-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.999       0.999         0.5080 0.492   0.492
#> 3 3 0.774           0.763       0.883         0.3036 0.774   0.570
#> 4 4 0.826           0.891       0.882         0.0872 0.869   0.651
#> 5 5 0.691           0.653       0.793         0.0630 0.955   0.844
#> 6 6 0.787           0.828       0.854         0.0561 0.932   0.727

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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     2  0.0376      0.997 0.004 0.996
#> GSM252429     2  0.0376      0.997 0.004 0.996
#> GSM252424     2  0.1184      0.986 0.016 0.984
#> GSM252432     2  0.0376      0.997 0.004 0.996
#> GSM252427     2  0.0376      0.997 0.004 0.996
#> GSM252431     2  0.0376      0.997 0.004 0.996
#> GSM252430     2  0.0376      0.997 0.004 0.996
#> GSM252433     2  0.0376      0.997 0.004 0.996
#> GSM252426     2  0.0376      0.997 0.004 0.996
#> GSM252428     2  0.0376      0.997 0.004 0.996
#> GSM252425     2  0.0376      0.997 0.004 0.996
#> GSM252440     1  0.0000      1.000 1.000 0.000
#> GSM252441     1  0.0000      1.000 1.000 0.000
#> GSM252436     1  0.0000      1.000 1.000 0.000
#> GSM252435     1  0.0000      1.000 1.000 0.000
#> GSM252442     1  0.0000      1.000 1.000 0.000
#> GSM252439     1  0.0000      1.000 1.000 0.000
#> GSM252438     1  0.0000      1.000 1.000 0.000
#> GSM252434     1  0.0000      1.000 1.000 0.000
#> GSM252437     1  0.0000      1.000 1.000 0.000
#> GSM252451     1  0.0000      1.000 1.000 0.000
#> GSM252448     1  0.0000      1.000 1.000 0.000
#> GSM252447     1  0.0000      1.000 1.000 0.000
#> GSM252444     1  0.0000      1.000 1.000 0.000
#> GSM252450     1  0.0000      1.000 1.000 0.000
#> GSM252452     1  0.0000      1.000 1.000 0.000
#> GSM252443     1  0.0000      1.000 1.000 0.000
#> GSM252454     1  0.0000      1.000 1.000 0.000
#> GSM252449     1  0.0000      1.000 1.000 0.000
#> GSM252445     1  0.0000      1.000 1.000 0.000
#> GSM252453     1  0.0000      1.000 1.000 0.000
#> GSM252464     1  0.0000      1.000 1.000 0.000
#> GSM252463     1  0.0000      1.000 1.000 0.000
#> GSM252461     1  0.0000      1.000 1.000 0.000
#> GSM252455     1  0.0000      1.000 1.000 0.000
#> GSM252458     1  0.0000      1.000 1.000 0.000
#> GSM252460     1  0.0000      1.000 1.000 0.000
#> GSM252457     1  0.0000      1.000 1.000 0.000
#> GSM252456     1  0.0000      1.000 1.000 0.000
#> GSM252462     1  0.0000      1.000 1.000 0.000
#> GSM252459     1  0.0000      1.000 1.000 0.000
#> GSM252472     2  0.0000      0.998 0.000 1.000
#> GSM252466     2  0.0000      0.998 0.000 1.000
#> GSM252469     2  0.0000      0.998 0.000 1.000
#> GSM252475     2  0.0000      0.998 0.000 1.000
#> GSM252471     2  0.0000      0.998 0.000 1.000
#> GSM252465     2  0.0000      0.998 0.000 1.000
#> GSM252474     2  0.0000      0.998 0.000 1.000
#> GSM252473     2  0.0000      0.998 0.000 1.000
#> GSM252468     2  0.0000      0.998 0.000 1.000
#> GSM252470     2  0.0000      0.998 0.000 1.000
#> GSM252467     2  0.0000      0.998 0.000 1.000
#> GSM252485     2  0.0000      0.998 0.000 1.000
#> GSM252481     2  0.0000      0.998 0.000 1.000
#> GSM252480     2  0.0000      0.998 0.000 1.000
#> GSM252479     2  0.0000      0.998 0.000 1.000
#> GSM252482     2  0.0000      0.998 0.000 1.000
#> GSM252478     2  0.0000      0.998 0.000 1.000
#> GSM252483     2  0.0000      0.998 0.000 1.000
#> GSM252477     2  0.0000      0.998 0.000 1.000
#> GSM252484     2  0.0000      0.998 0.000 1.000
#> GSM252476     2  0.0000      0.998 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.0592      0.630 0.000 0.012 0.988
#> GSM252429     3  0.6008      0.126 0.000 0.372 0.628
#> GSM252424     3  0.3295      0.595 0.008 0.096 0.896
#> GSM252432     3  0.0000      0.629 0.000 0.000 1.000
#> GSM252427     3  0.1031      0.629 0.000 0.024 0.976
#> GSM252431     3  0.2796      0.596 0.000 0.092 0.908
#> GSM252430     2  0.4346      0.785 0.000 0.816 0.184
#> GSM252433     2  0.4346      0.785 0.000 0.816 0.184
#> GSM252426     3  0.0892      0.630 0.000 0.020 0.980
#> GSM252428     2  0.6305      0.234 0.000 0.516 0.484
#> GSM252425     2  0.1860      0.921 0.000 0.948 0.052
#> GSM252440     1  0.0000      0.836 1.000 0.000 0.000
#> GSM252441     1  0.0000      0.836 1.000 0.000 0.000
#> GSM252436     1  0.0000      0.836 1.000 0.000 0.000
#> GSM252435     1  0.0000      0.836 1.000 0.000 0.000
#> GSM252442     1  0.0000      0.836 1.000 0.000 0.000
#> GSM252439     1  0.6180      0.436 0.584 0.000 0.416
#> GSM252438     1  0.6180      0.436 0.584 0.000 0.416
#> GSM252434     1  0.0000      0.836 1.000 0.000 0.000
#> GSM252437     1  0.0000      0.836 1.000 0.000 0.000
#> GSM252451     1  0.0000      0.836 1.000 0.000 0.000
#> GSM252448     1  0.0000      0.836 1.000 0.000 0.000
#> GSM252447     1  0.0000      0.836 1.000 0.000 0.000
#> GSM252444     1  0.0000      0.836 1.000 0.000 0.000
#> GSM252450     1  0.0000      0.836 1.000 0.000 0.000
#> GSM252452     1  0.6026      0.480 0.624 0.000 0.376
#> GSM252443     1  0.6180      0.436 0.584 0.000 0.416
#> GSM252454     1  0.6180      0.436 0.584 0.000 0.416
#> GSM252449     1  0.0000      0.836 1.000 0.000 0.000
#> GSM252445     1  0.0000      0.836 1.000 0.000 0.000
#> GSM252453     1  0.2625      0.778 0.916 0.000 0.084
#> GSM252464     3  0.6225      0.566 0.432 0.000 0.568
#> GSM252463     3  0.6225      0.566 0.432 0.000 0.568
#> GSM252461     3  0.6244      0.552 0.440 0.000 0.560
#> GSM252455     3  0.6225      0.566 0.432 0.000 0.568
#> GSM252458     3  0.6225      0.566 0.432 0.000 0.568
#> GSM252460     3  0.6225      0.566 0.432 0.000 0.568
#> GSM252457     3  0.0747      0.627 0.016 0.000 0.984
#> GSM252456     3  0.6225      0.566 0.432 0.000 0.568
#> GSM252462     3  0.6225      0.566 0.432 0.000 0.568
#> GSM252459     1  0.2959      0.768 0.900 0.000 0.100
#> GSM252472     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252466     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252469     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252475     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252471     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252465     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252474     2  0.0592      0.954 0.000 0.988 0.012
#> GSM252473     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252468     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252470     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252467     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252485     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252481     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252480     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252479     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252482     2  0.0592      0.954 0.000 0.988 0.012
#> GSM252478     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252483     2  0.0592      0.954 0.000 0.988 0.012
#> GSM252477     2  0.0592      0.954 0.000 0.988 0.012
#> GSM252484     2  0.0000      0.959 0.000 1.000 0.000
#> GSM252476     2  0.0000      0.959 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.0000      0.807 0.000 0.000 1.000 0.000
#> GSM252429     3  0.0921      0.802 0.000 0.000 0.972 0.028
#> GSM252424     3  0.0707      0.804 0.000 0.020 0.980 0.000
#> GSM252432     3  0.0000      0.807 0.000 0.000 1.000 0.000
#> GSM252427     3  0.0592      0.805 0.000 0.016 0.984 0.000
#> GSM252431     3  0.0707      0.804 0.000 0.020 0.980 0.000
#> GSM252430     3  0.1488      0.792 0.000 0.012 0.956 0.032
#> GSM252433     3  0.1302      0.795 0.000 0.000 0.956 0.044
#> GSM252426     3  0.0592      0.805 0.000 0.016 0.984 0.000
#> GSM252428     3  0.0804      0.804 0.000 0.012 0.980 0.008
#> GSM252425     3  0.1792      0.774 0.000 0.068 0.932 0.000
#> GSM252440     1  0.2469      0.911 0.892 0.000 0.000 0.108
#> GSM252441     1  0.1867      0.924 0.928 0.000 0.000 0.072
#> GSM252436     1  0.1022      0.929 0.968 0.000 0.000 0.032
#> GSM252435     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM252442     1  0.0895      0.930 0.976 0.000 0.004 0.020
#> GSM252439     1  0.3803      0.882 0.836 0.000 0.032 0.132
#> GSM252438     1  0.5280      0.785 0.752 0.000 0.124 0.124
#> GSM252434     1  0.0707      0.930 0.980 0.000 0.000 0.020
#> GSM252437     1  0.0336      0.931 0.992 0.000 0.000 0.008
#> GSM252451     1  0.1022      0.929 0.968 0.000 0.000 0.032
#> GSM252448     1  0.2469      0.911 0.892 0.000 0.000 0.108
#> GSM252447     1  0.2216      0.918 0.908 0.000 0.000 0.092
#> GSM252444     1  0.1118      0.928 0.964 0.000 0.000 0.036
#> GSM252450     1  0.0469      0.932 0.988 0.000 0.000 0.012
#> GSM252452     1  0.2036      0.917 0.936 0.000 0.032 0.032
#> GSM252443     1  0.3048      0.901 0.876 0.000 0.016 0.108
#> GSM252454     1  0.3525      0.894 0.860 0.000 0.040 0.100
#> GSM252449     1  0.0707      0.930 0.980 0.000 0.000 0.020
#> GSM252445     1  0.0188      0.931 0.996 0.000 0.000 0.004
#> GSM252453     1  0.0707      0.931 0.980 0.000 0.000 0.020
#> GSM252464     3  0.6478      0.725 0.088 0.000 0.576 0.336
#> GSM252463     3  0.6350      0.710 0.072 0.000 0.564 0.364
#> GSM252461     1  0.5546      0.628 0.680 0.000 0.052 0.268
#> GSM252455     3  0.6446      0.726 0.088 0.000 0.584 0.328
#> GSM252458     3  0.6535      0.728 0.100 0.000 0.588 0.312
#> GSM252460     3  0.6535      0.728 0.100 0.000 0.588 0.312
#> GSM252457     3  0.6028      0.717 0.052 0.000 0.584 0.364
#> GSM252456     3  0.6535      0.728 0.100 0.000 0.588 0.312
#> GSM252462     3  0.6729      0.716 0.116 0.000 0.572 0.312
#> GSM252459     1  0.2586      0.904 0.912 0.000 0.040 0.048
#> GSM252472     2  0.0469      0.980 0.000 0.988 0.000 0.012
#> GSM252466     2  0.0336      0.987 0.000 0.992 0.000 0.008
#> GSM252469     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> GSM252475     2  0.0188      0.992 0.000 0.996 0.000 0.004
#> GSM252471     2  0.0188      0.992 0.000 0.996 0.000 0.004
#> GSM252465     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> GSM252474     4  0.4967      1.000 0.000 0.452 0.000 0.548
#> GSM252473     2  0.0469      0.980 0.000 0.988 0.000 0.012
#> GSM252468     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> GSM252470     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> GSM252467     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> GSM252485     2  0.0188      0.992 0.000 0.996 0.000 0.004
#> GSM252481     2  0.0188      0.992 0.000 0.996 0.000 0.004
#> GSM252480     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> GSM252479     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> GSM252482     4  0.4967      1.000 0.000 0.452 0.000 0.548
#> GSM252478     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> GSM252483     4  0.4967      1.000 0.000 0.452 0.000 0.548
#> GSM252477     4  0.4967      1.000 0.000 0.452 0.000 0.548
#> GSM252484     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> GSM252476     2  0.0000      0.994 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.0162      0.647 0.000 0.004 0.996 0.000 0.000
#> GSM252429     3  0.2286      0.600 0.000 0.000 0.888 0.004 0.108
#> GSM252424     3  0.0992      0.644 0.000 0.024 0.968 0.008 0.000
#> GSM252432     3  0.0162      0.647 0.000 0.004 0.996 0.000 0.000
#> GSM252427     3  0.0992      0.644 0.000 0.024 0.968 0.008 0.000
#> GSM252431     3  0.1628      0.628 0.000 0.056 0.936 0.008 0.000
#> GSM252430     3  0.2929      0.564 0.000 0.000 0.840 0.008 0.152
#> GSM252433     3  0.2843      0.568 0.000 0.000 0.848 0.008 0.144
#> GSM252426     3  0.0992      0.645 0.000 0.024 0.968 0.008 0.000
#> GSM252428     3  0.2017      0.614 0.000 0.080 0.912 0.008 0.000
#> GSM252425     3  0.3508      0.458 0.000 0.252 0.748 0.000 0.000
#> GSM252440     4  0.3796      0.916 0.300 0.000 0.000 0.700 0.000
#> GSM252441     4  0.3816      0.917 0.304 0.000 0.000 0.696 0.000
#> GSM252436     1  0.4302     -0.645 0.520 0.000 0.000 0.480 0.000
#> GSM252435     1  0.0510      0.605 0.984 0.000 0.000 0.016 0.000
#> GSM252442     1  0.3003      0.563 0.812 0.000 0.000 0.188 0.000
#> GSM252439     1  0.4067      0.488 0.692 0.000 0.008 0.300 0.000
#> GSM252438     1  0.5493      0.503 0.672 0.000 0.124 0.196 0.008
#> GSM252434     1  0.3480      0.536 0.752 0.000 0.000 0.248 0.000
#> GSM252437     1  0.0794      0.595 0.972 0.000 0.000 0.028 0.000
#> GSM252451     1  0.4304     -0.649 0.516 0.000 0.000 0.484 0.000
#> GSM252448     4  0.3796      0.916 0.300 0.000 0.000 0.700 0.000
#> GSM252447     4  0.3816      0.917 0.304 0.000 0.000 0.696 0.000
#> GSM252444     4  0.4302      0.633 0.480 0.000 0.000 0.520 0.000
#> GSM252450     1  0.1965      0.546 0.904 0.000 0.000 0.096 0.000
#> GSM252452     1  0.2753      0.590 0.856 0.000 0.008 0.136 0.000
#> GSM252443     1  0.3928      0.489 0.700 0.000 0.004 0.296 0.000
#> GSM252454     1  0.4593      0.536 0.736 0.000 0.080 0.184 0.000
#> GSM252449     1  0.3508      0.533 0.748 0.000 0.000 0.252 0.000
#> GSM252445     1  0.2329      0.591 0.876 0.000 0.000 0.124 0.000
#> GSM252453     1  0.1410      0.581 0.940 0.000 0.000 0.060 0.000
#> GSM252464     3  0.7481      0.438 0.280 0.000 0.488 0.132 0.100
#> GSM252463     3  0.7513      0.436 0.280 0.000 0.484 0.136 0.100
#> GSM252461     1  0.6922     -0.011 0.464 0.000 0.212 0.308 0.016
#> GSM252455     3  0.7481      0.438 0.280 0.000 0.488 0.132 0.100
#> GSM252458     3  0.7600      0.423 0.288 0.000 0.468 0.144 0.100
#> GSM252460     3  0.7746      0.399 0.292 0.000 0.444 0.164 0.100
#> GSM252457     3  0.7400      0.343 0.368 0.000 0.432 0.100 0.100
#> GSM252456     3  0.7746      0.399 0.292 0.000 0.444 0.164 0.100
#> GSM252462     3  0.7621      0.378 0.316 0.000 0.440 0.160 0.084
#> GSM252459     1  0.4899      0.511 0.736 0.000 0.180 0.064 0.020
#> GSM252472     2  0.0703      0.960 0.000 0.976 0.000 0.000 0.024
#> GSM252466     2  0.2813      0.813 0.000 0.832 0.000 0.000 0.168
#> GSM252469     2  0.0703      0.956 0.000 0.976 0.000 0.000 0.024
#> GSM252475     2  0.0510      0.963 0.000 0.984 0.000 0.000 0.016
#> GSM252471     2  0.0510      0.962 0.000 0.984 0.000 0.000 0.016
#> GSM252465     2  0.0162      0.963 0.000 0.996 0.000 0.000 0.004
#> GSM252474     5  0.2230      0.966 0.000 0.116 0.000 0.000 0.884
#> GSM252473     2  0.0880      0.955 0.000 0.968 0.000 0.000 0.032
#> GSM252468     2  0.0162      0.963 0.000 0.996 0.000 0.000 0.004
#> GSM252470     2  0.0162      0.963 0.000 0.996 0.000 0.000 0.004
#> GSM252467     2  0.0794      0.957 0.000 0.972 0.000 0.000 0.028
#> GSM252485     2  0.0703      0.960 0.000 0.976 0.000 0.000 0.024
#> GSM252481     2  0.2813      0.813 0.000 0.832 0.000 0.000 0.168
#> GSM252480     2  0.0703      0.956 0.000 0.976 0.000 0.000 0.024
#> GSM252479     2  0.0162      0.963 0.000 0.996 0.000 0.000 0.004
#> GSM252482     5  0.2561      0.960 0.000 0.144 0.000 0.000 0.856
#> GSM252478     2  0.0162      0.963 0.000 0.996 0.000 0.000 0.004
#> GSM252483     5  0.2020      0.964 0.000 0.100 0.000 0.000 0.900
#> GSM252477     5  0.2377      0.970 0.000 0.128 0.000 0.000 0.872
#> GSM252484     2  0.0162      0.963 0.000 0.996 0.000 0.000 0.004
#> GSM252476     2  0.0609      0.957 0.000 0.980 0.000 0.000 0.020

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.0291      0.947 0.000 0.004 0.992 0.004 0.000 0.000
#> GSM252429     3  0.2094      0.905 0.000 0.000 0.900 0.080 0.020 0.000
#> GSM252424     3  0.0146      0.947 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM252432     3  0.0291      0.947 0.000 0.004 0.992 0.004 0.000 0.000
#> GSM252427     3  0.0508      0.947 0.012 0.004 0.984 0.000 0.000 0.000
#> GSM252431     3  0.0508      0.947 0.012 0.004 0.984 0.000 0.000 0.000
#> GSM252430     3  0.3003      0.877 0.016 0.000 0.852 0.104 0.028 0.000
#> GSM252433     3  0.2925      0.880 0.016 0.000 0.856 0.104 0.024 0.000
#> GSM252426     3  0.0508      0.947 0.012 0.004 0.984 0.000 0.000 0.000
#> GSM252428     3  0.0146      0.948 0.000 0.004 0.996 0.000 0.000 0.000
#> GSM252425     3  0.1413      0.922 0.004 0.036 0.948 0.008 0.004 0.000
#> GSM252440     1  0.1141      0.821 0.948 0.000 0.000 0.000 0.000 0.052
#> GSM252441     1  0.1141      0.821 0.948 0.000 0.000 0.000 0.000 0.052
#> GSM252436     1  0.3592      0.667 0.656 0.000 0.000 0.000 0.000 0.344
#> GSM252435     6  0.1387      0.715 0.068 0.000 0.000 0.000 0.000 0.932
#> GSM252442     6  0.0000      0.705 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM252439     6  0.5925      0.532 0.256 0.000 0.000 0.280 0.000 0.464
#> GSM252438     6  0.6375      0.483 0.244 0.000 0.016 0.332 0.000 0.408
#> GSM252434     6  0.0000      0.705 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM252437     6  0.1387      0.715 0.068 0.000 0.000 0.000 0.000 0.932
#> GSM252451     1  0.3634      0.648 0.644 0.000 0.000 0.000 0.000 0.356
#> GSM252448     1  0.1141      0.821 0.948 0.000 0.000 0.000 0.000 0.052
#> GSM252447     1  0.1141      0.821 0.948 0.000 0.000 0.000 0.000 0.052
#> GSM252444     1  0.3351      0.720 0.712 0.000 0.000 0.000 0.000 0.288
#> GSM252450     6  0.1858      0.707 0.092 0.000 0.000 0.004 0.000 0.904
#> GSM252452     6  0.4843      0.653 0.116 0.000 0.000 0.232 0.000 0.652
#> GSM252443     6  0.5888      0.539 0.256 0.000 0.000 0.268 0.000 0.476
#> GSM252454     6  0.5512      0.609 0.232 0.000 0.008 0.168 0.000 0.592
#> GSM252449     6  0.0146      0.704 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM252445     6  0.0713      0.712 0.028 0.000 0.000 0.000 0.000 0.972
#> GSM252453     6  0.1714      0.710 0.092 0.000 0.000 0.000 0.000 0.908
#> GSM252464     4  0.4147      0.979 0.000 0.000 0.224 0.716 0.000 0.060
#> GSM252463     4  0.4590      0.955 0.000 0.000 0.224 0.680 0.000 0.096
#> GSM252461     6  0.6302      0.444 0.116 0.000 0.064 0.304 0.000 0.516
#> GSM252455     4  0.4545      0.959 0.000 0.000 0.224 0.684 0.000 0.092
#> GSM252458     4  0.4393      0.982 0.008 0.000 0.224 0.708 0.000 0.060
#> GSM252460     4  0.4393      0.982 0.008 0.000 0.224 0.708 0.000 0.060
#> GSM252457     4  0.4286      0.979 0.004 0.000 0.224 0.712 0.000 0.060
#> GSM252456     4  0.4393      0.982 0.008 0.000 0.224 0.708 0.000 0.060
#> GSM252462     4  0.4447      0.981 0.008 0.000 0.224 0.704 0.000 0.064
#> GSM252459     6  0.5689      0.535 0.056 0.000 0.084 0.252 0.000 0.608
#> GSM252472     2  0.0790      0.909 0.000 0.968 0.000 0.000 0.032 0.000
#> GSM252466     2  0.3468      0.700 0.000 0.728 0.000 0.008 0.264 0.000
#> GSM252469     2  0.1643      0.892 0.000 0.924 0.000 0.008 0.068 0.000
#> GSM252475     2  0.0603      0.911 0.000 0.980 0.004 0.000 0.016 0.000
#> GSM252471     2  0.0260      0.911 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM252465     2  0.1644      0.894 0.000 0.920 0.000 0.076 0.004 0.000
#> GSM252474     5  0.1556      0.902 0.000 0.080 0.000 0.000 0.920 0.000
#> GSM252473     2  0.1007      0.905 0.000 0.956 0.000 0.000 0.044 0.000
#> GSM252468     2  0.1644      0.894 0.000 0.920 0.000 0.076 0.004 0.000
#> GSM252470     2  0.1845      0.893 0.000 0.916 0.004 0.072 0.008 0.000
#> GSM252467     2  0.1584      0.894 0.000 0.928 0.000 0.008 0.064 0.000
#> GSM252485     2  0.0790      0.909 0.000 0.968 0.000 0.000 0.032 0.000
#> GSM252481     2  0.3468      0.700 0.000 0.728 0.000 0.008 0.264 0.000
#> GSM252480     2  0.1701      0.891 0.000 0.920 0.000 0.008 0.072 0.000
#> GSM252479     2  0.0508      0.911 0.000 0.984 0.004 0.000 0.012 0.000
#> GSM252482     5  0.1910      0.921 0.000 0.108 0.000 0.000 0.892 0.000
#> GSM252478     2  0.1788      0.892 0.000 0.916 0.004 0.076 0.004 0.000
#> GSM252483     5  0.0458      0.895 0.000 0.016 0.000 0.000 0.984 0.000
#> GSM252477     5  0.1814      0.925 0.000 0.100 0.000 0.000 0.900 0.000
#> GSM252484     2  0.1501      0.894 0.000 0.924 0.000 0.076 0.000 0.000
#> GSM252476     2  0.1584      0.894 0.000 0.928 0.000 0.008 0.064 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)

plot of chunk tab-SD-mclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-SD-mclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-SD-mclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-SD-mclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-SD-mclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-SD-mclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-SD-mclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-SD-mclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-SD-mclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-SD-mclust-membership-heatmap-5

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)

plot of chunk tab-SD-mclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-SD-mclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-SD-mclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-SD-mclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-SD-mclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-SD-mclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-SD-mclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-SD-mclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-SD-mclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-SD-mclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-mclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-SD-mclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-SD-mclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-SD-mclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-SD-mclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-SD-mclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-mclust-collect-classes

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 agent(p) individual(p) k
#> SD:mclust 62 4.69e-12         1.000 2
#> SD:mclust 55 2.47e-15         0.945 3
#> SD:mclust 62 3.45e-18         0.972 4
#> SD:mclust 48 9.18e-13         0.344 5
#> SD:mclust 60 1.67e-24         0.874 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.


SD:NMF**

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 51941 rows and 62 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 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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:

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)

plot of chunk SD-NMF-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.967       0.986         0.4817 0.518   0.518
#> 3 3 0.996           0.953       0.965         0.3936 0.755   0.549
#> 4 4 0.886           0.889       0.943         0.1058 0.914   0.744
#> 5 5 0.782           0.780       0.864         0.0481 0.967   0.880
#> 6 6 0.705           0.569       0.773         0.0483 0.943   0.786

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2

There is also optional best \(k\) = 2 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1   0.000      0.989 1.000 0.000
#> GSM252429     1   0.000      0.989 1.000 0.000
#> GSM252424     1   0.000      0.989 1.000 0.000
#> GSM252432     1   0.000      0.989 1.000 0.000
#> GSM252427     1   0.000      0.989 1.000 0.000
#> GSM252431     1   0.861      0.595 0.716 0.284
#> GSM252430     2   0.469      0.878 0.100 0.900
#> GSM252433     2   0.932      0.461 0.348 0.652
#> GSM252426     1   0.000      0.989 1.000 0.000
#> GSM252428     1   0.494      0.872 0.892 0.108
#> GSM252425     2   0.000      0.980 0.000 1.000
#> GSM252440     1   0.000      0.989 1.000 0.000
#> GSM252441     1   0.000      0.989 1.000 0.000
#> GSM252436     1   0.000      0.989 1.000 0.000
#> GSM252435     1   0.000      0.989 1.000 0.000
#> GSM252442     1   0.000      0.989 1.000 0.000
#> GSM252439     1   0.000      0.989 1.000 0.000
#> GSM252438     1   0.000      0.989 1.000 0.000
#> GSM252434     1   0.000      0.989 1.000 0.000
#> GSM252437     1   0.000      0.989 1.000 0.000
#> GSM252451     1   0.000      0.989 1.000 0.000
#> GSM252448     1   0.000      0.989 1.000 0.000
#> GSM252447     1   0.000      0.989 1.000 0.000
#> GSM252444     1   0.000      0.989 1.000 0.000
#> GSM252450     1   0.000      0.989 1.000 0.000
#> GSM252452     1   0.000      0.989 1.000 0.000
#> GSM252443     1   0.000      0.989 1.000 0.000
#> GSM252454     1   0.000      0.989 1.000 0.000
#> GSM252449     1   0.000      0.989 1.000 0.000
#> GSM252445     1   0.000      0.989 1.000 0.000
#> GSM252453     1   0.000      0.989 1.000 0.000
#> GSM252464     1   0.000      0.989 1.000 0.000
#> GSM252463     1   0.000      0.989 1.000 0.000
#> GSM252461     1   0.000      0.989 1.000 0.000
#> GSM252455     1   0.000      0.989 1.000 0.000
#> GSM252458     1   0.000      0.989 1.000 0.000
#> GSM252460     1   0.000      0.989 1.000 0.000
#> GSM252457     1   0.000      0.989 1.000 0.000
#> GSM252456     1   0.000      0.989 1.000 0.000
#> GSM252462     1   0.000      0.989 1.000 0.000
#> GSM252459     1   0.000      0.989 1.000 0.000
#> GSM252472     2   0.000      0.980 0.000 1.000
#> GSM252466     2   0.000      0.980 0.000 1.000
#> GSM252469     2   0.000      0.980 0.000 1.000
#> GSM252475     2   0.000      0.980 0.000 1.000
#> GSM252471     2   0.000      0.980 0.000 1.000
#> GSM252465     2   0.000      0.980 0.000 1.000
#> GSM252474     2   0.000      0.980 0.000 1.000
#> GSM252473     2   0.000      0.980 0.000 1.000
#> GSM252468     2   0.000      0.980 0.000 1.000
#> GSM252470     2   0.000      0.980 0.000 1.000
#> GSM252467     2   0.000      0.980 0.000 1.000
#> GSM252485     2   0.000      0.980 0.000 1.000
#> GSM252481     2   0.000      0.980 0.000 1.000
#> GSM252480     2   0.000      0.980 0.000 1.000
#> GSM252479     2   0.000      0.980 0.000 1.000
#> GSM252482     2   0.000      0.980 0.000 1.000
#> GSM252478     2   0.000      0.980 0.000 1.000
#> GSM252483     2   0.000      0.980 0.000 1.000
#> GSM252477     2   0.000      0.980 0.000 1.000
#> GSM252484     2   0.000      0.980 0.000 1.000
#> GSM252476     2   0.000      0.980 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.1529      0.932 0.040 0.000 0.960
#> GSM252429     3  0.0747      0.924 0.016 0.000 0.984
#> GSM252424     3  0.1860      0.931 0.052 0.000 0.948
#> GSM252432     3  0.1529      0.932 0.040 0.000 0.960
#> GSM252427     3  0.1529      0.932 0.040 0.000 0.960
#> GSM252431     3  0.1774      0.923 0.016 0.024 0.960
#> GSM252430     3  0.0237      0.915 0.000 0.004 0.996
#> GSM252433     3  0.0237      0.915 0.000 0.004 0.996
#> GSM252426     3  0.1765      0.932 0.040 0.004 0.956
#> GSM252428     3  0.1999      0.917 0.012 0.036 0.952
#> GSM252425     3  0.5397      0.617 0.000 0.280 0.720
#> GSM252440     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252441     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252436     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252435     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252442     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252439     1  0.1860      0.949 0.948 0.000 0.052
#> GSM252438     1  0.2261      0.939 0.932 0.000 0.068
#> GSM252434     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252437     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252451     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252448     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252447     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252444     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252450     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252452     1  0.1411      0.963 0.964 0.000 0.036
#> GSM252443     1  0.0592      0.981 0.988 0.000 0.012
#> GSM252454     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252449     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252445     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252453     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252464     3  0.2448      0.925 0.076 0.000 0.924
#> GSM252463     3  0.4887      0.787 0.228 0.000 0.772
#> GSM252461     1  0.0000      0.989 1.000 0.000 0.000
#> GSM252455     3  0.4605      0.816 0.204 0.000 0.796
#> GSM252458     3  0.2537      0.923 0.080 0.000 0.920
#> GSM252460     3  0.2356      0.926 0.072 0.000 0.928
#> GSM252457     3  0.1643      0.932 0.044 0.000 0.956
#> GSM252456     3  0.2448      0.925 0.076 0.000 0.924
#> GSM252462     3  0.5178      0.746 0.256 0.000 0.744
#> GSM252459     1  0.1860      0.937 0.948 0.000 0.052
#> GSM252472     2  0.0592      0.985 0.000 0.988 0.012
#> GSM252466     2  0.0424      0.986 0.000 0.992 0.008
#> GSM252469     2  0.0237      0.988 0.000 0.996 0.004
#> GSM252475     2  0.0424      0.986 0.000 0.992 0.008
#> GSM252471     2  0.0000      0.987 0.000 1.000 0.000
#> GSM252465     2  0.0237      0.988 0.000 0.996 0.004
#> GSM252474     2  0.1529      0.970 0.000 0.960 0.040
#> GSM252473     2  0.0592      0.985 0.000 0.988 0.012
#> GSM252468     2  0.0237      0.988 0.000 0.996 0.004
#> GSM252470     2  0.0237      0.988 0.000 0.996 0.004
#> GSM252467     2  0.0237      0.988 0.000 0.996 0.004
#> GSM252485     2  0.0424      0.986 0.000 0.992 0.008
#> GSM252481     2  0.0237      0.987 0.000 0.996 0.004
#> GSM252480     2  0.0237      0.988 0.000 0.996 0.004
#> GSM252479     2  0.0237      0.988 0.000 0.996 0.004
#> GSM252482     2  0.2066      0.957 0.000 0.940 0.060
#> GSM252478     2  0.0237      0.988 0.000 0.996 0.004
#> GSM252483     2  0.1964      0.960 0.000 0.944 0.056
#> GSM252477     2  0.2066      0.957 0.000 0.940 0.060
#> GSM252484     2  0.0237      0.988 0.000 0.996 0.004
#> GSM252476     2  0.0237      0.988 0.000 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.0469      0.897 0.000 0.000 0.988 0.012
#> GSM252429     3  0.2647      0.818 0.000 0.000 0.880 0.120
#> GSM252424     3  0.0000      0.899 0.000 0.000 1.000 0.000
#> GSM252432     3  0.0188      0.899 0.000 0.000 0.996 0.004
#> GSM252427     3  0.0000      0.899 0.000 0.000 1.000 0.000
#> GSM252431     3  0.0921      0.898 0.000 0.000 0.972 0.028
#> GSM252430     4  0.2345      0.835 0.000 0.000 0.100 0.900
#> GSM252433     4  0.4040      0.658 0.000 0.000 0.248 0.752
#> GSM252426     3  0.1022      0.897 0.000 0.000 0.968 0.032
#> GSM252428     3  0.1890      0.882 0.000 0.008 0.936 0.056
#> GSM252425     3  0.5744      0.183 0.000 0.436 0.536 0.028
#> GSM252440     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM252441     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM252436     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM252435     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM252442     1  0.1929      0.918 0.940 0.000 0.024 0.036
#> GSM252439     4  0.3311      0.782 0.172 0.000 0.000 0.828
#> GSM252438     4  0.2704      0.831 0.124 0.000 0.000 0.876
#> GSM252434     1  0.0817      0.947 0.976 0.000 0.000 0.024
#> GSM252437     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM252451     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM252448     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM252447     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM252444     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM252450     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM252452     1  0.4888      0.247 0.588 0.000 0.000 0.412
#> GSM252443     1  0.1867      0.899 0.928 0.000 0.000 0.072
#> GSM252454     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM252449     1  0.0817      0.947 0.976 0.000 0.000 0.024
#> GSM252445     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM252453     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM252464     3  0.0336      0.898 0.000 0.000 0.992 0.008
#> GSM252463     3  0.2918      0.812 0.116 0.000 0.876 0.008
#> GSM252461     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM252455     3  0.1637      0.870 0.060 0.000 0.940 0.000
#> GSM252458     3  0.0188      0.899 0.000 0.000 0.996 0.004
#> GSM252460     3  0.1118      0.895 0.000 0.000 0.964 0.036
#> GSM252457     3  0.4008      0.652 0.000 0.000 0.756 0.244
#> GSM252456     3  0.0921      0.898 0.000 0.000 0.972 0.028
#> GSM252462     3  0.3479      0.770 0.148 0.000 0.840 0.012
#> GSM252459     1  0.1940      0.887 0.924 0.000 0.076 0.000
#> GSM252472     2  0.1474      0.950 0.000 0.948 0.000 0.052
#> GSM252466     2  0.1302      0.957 0.000 0.956 0.000 0.044
#> GSM252469     2  0.0188      0.968 0.000 0.996 0.000 0.004
#> GSM252475     2  0.1302      0.957 0.000 0.956 0.000 0.044
#> GSM252471     2  0.0188      0.967 0.000 0.996 0.000 0.004
#> GSM252465     2  0.1302      0.950 0.000 0.956 0.000 0.044
#> GSM252474     4  0.2814      0.829 0.000 0.132 0.000 0.868
#> GSM252473     2  0.2469      0.902 0.000 0.892 0.000 0.108
#> GSM252468     2  0.1022      0.958 0.000 0.968 0.000 0.032
#> GSM252470     2  0.0817      0.962 0.000 0.976 0.000 0.024
#> GSM252467     2  0.0188      0.968 0.000 0.996 0.000 0.004
#> GSM252485     2  0.1474      0.952 0.000 0.948 0.000 0.052
#> GSM252481     2  0.1211      0.959 0.000 0.960 0.000 0.040
#> GSM252480     2  0.0469      0.967 0.000 0.988 0.000 0.012
#> GSM252479     2  0.0188      0.967 0.000 0.996 0.000 0.004
#> GSM252482     4  0.1792      0.879 0.000 0.068 0.000 0.932
#> GSM252478     2  0.1302      0.950 0.000 0.956 0.000 0.044
#> GSM252483     4  0.1792      0.878 0.000 0.068 0.000 0.932
#> GSM252477     4  0.1557      0.878 0.000 0.056 0.000 0.944
#> GSM252484     2  0.0817      0.962 0.000 0.976 0.000 0.024
#> GSM252476     2  0.0188      0.968 0.000 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3 p4    p5
#> GSM252423     3  0.0566     0.8155 0.000 0.000 0.984 NA 0.012
#> GSM252429     3  0.3264     0.7402 0.000 0.000 0.820 NA 0.016
#> GSM252424     3  0.0693     0.8145 0.000 0.000 0.980 NA 0.012
#> GSM252432     3  0.0451     0.8172 0.000 0.000 0.988 NA 0.008
#> GSM252427     3  0.0609     0.8173 0.000 0.000 0.980 NA 0.000
#> GSM252431     3  0.3774     0.7124 0.000 0.000 0.704 NA 0.000
#> GSM252430     5  0.2470     0.7896 0.000 0.000 0.104 NA 0.884
#> GSM252433     5  0.4248     0.6485 0.000 0.000 0.240 NA 0.728
#> GSM252426     3  0.2690     0.7768 0.000 0.000 0.844 NA 0.000
#> GSM252428     3  0.4867     0.5698 0.000 0.024 0.544 NA 0.000
#> GSM252425     3  0.5232     0.0305 0.000 0.456 0.500 NA 0.000
#> GSM252440     1  0.2280     0.8156 0.880 0.000 0.000 NA 0.000
#> GSM252441     1  0.0510     0.8728 0.984 0.000 0.000 NA 0.000
#> GSM252436     1  0.0000     0.8741 1.000 0.000 0.000 NA 0.000
#> GSM252435     1  0.0794     0.8711 0.972 0.000 0.000 NA 0.000
#> GSM252442     1  0.4688     0.4751 0.532 0.004 0.008 NA 0.000
#> GSM252439     5  0.4054     0.7089 0.224 0.000 0.000 NA 0.748
#> GSM252438     5  0.6620     0.6904 0.176 0.004 0.036 NA 0.600
#> GSM252434     1  0.4306     0.6351 0.660 0.000 0.012 NA 0.000
#> GSM252437     1  0.1043     0.8680 0.960 0.000 0.000 NA 0.000
#> GSM252451     1  0.0162     0.8740 0.996 0.000 0.000 NA 0.000
#> GSM252448     1  0.1341     0.8581 0.944 0.000 0.000 NA 0.000
#> GSM252447     1  0.0510     0.8727 0.984 0.000 0.000 NA 0.000
#> GSM252444     1  0.0000     0.8741 1.000 0.000 0.000 NA 0.000
#> GSM252450     1  0.0703     0.8733 0.976 0.000 0.000 NA 0.000
#> GSM252452     5  0.5651     0.5894 0.248 0.000 0.000 NA 0.620
#> GSM252443     1  0.2886     0.7626 0.844 0.000 0.000 NA 0.148
#> GSM252454     1  0.1300     0.8632 0.956 0.000 0.000 NA 0.028
#> GSM252449     1  0.3530     0.7567 0.784 0.000 0.012 NA 0.000
#> GSM252445     1  0.2280     0.8287 0.880 0.000 0.000 NA 0.000
#> GSM252453     1  0.0703     0.8738 0.976 0.000 0.000 NA 0.000
#> GSM252464     3  0.0000     0.8174 0.000 0.000 1.000 NA 0.000
#> GSM252463     3  0.3504     0.7424 0.008 0.000 0.816 NA 0.016
#> GSM252461     1  0.0162     0.8738 0.996 0.000 0.000 NA 0.000
#> GSM252455     3  0.1195     0.8089 0.028 0.000 0.960 NA 0.000
#> GSM252458     3  0.0510     0.8176 0.000 0.000 0.984 NA 0.000
#> GSM252460     3  0.4350     0.6086 0.004 0.000 0.588 NA 0.000
#> GSM252457     3  0.2813     0.7730 0.000 0.000 0.876 NA 0.040
#> GSM252456     3  0.3586     0.7208 0.000 0.000 0.736 NA 0.000
#> GSM252462     1  0.6788     0.0632 0.384 0.000 0.296 NA 0.000
#> GSM252459     1  0.1668     0.8577 0.940 0.000 0.032 NA 0.000
#> GSM252472     2  0.1082     0.9059 0.000 0.964 0.000 NA 0.008
#> GSM252466     2  0.3906     0.7055 0.000 0.704 0.000 NA 0.004
#> GSM252469     2  0.0609     0.9027 0.000 0.980 0.000 NA 0.000
#> GSM252475     2  0.0671     0.9043 0.000 0.980 0.000 NA 0.016
#> GSM252471     2  0.1626     0.8999 0.000 0.940 0.000 NA 0.016
#> GSM252465     2  0.3210     0.8171 0.000 0.788 0.000 NA 0.000
#> GSM252474     5  0.1195     0.8287 0.000 0.028 0.000 NA 0.960
#> GSM252473     2  0.2519     0.8580 0.000 0.884 0.000 NA 0.100
#> GSM252468     2  0.2424     0.8680 0.000 0.868 0.000 NA 0.000
#> GSM252470     2  0.1792     0.8919 0.000 0.916 0.000 NA 0.000
#> GSM252467     2  0.0671     0.9044 0.000 0.980 0.000 NA 0.004
#> GSM252485     2  0.0865     0.9044 0.000 0.972 0.000 NA 0.004
#> GSM252481     2  0.3928     0.7016 0.000 0.700 0.000 NA 0.004
#> GSM252480     2  0.0880     0.9000 0.000 0.968 0.000 NA 0.000
#> GSM252479     2  0.0404     0.9050 0.000 0.988 0.000 NA 0.000
#> GSM252482     5  0.1018     0.8308 0.000 0.016 0.000 NA 0.968
#> GSM252478     2  0.4047     0.7096 0.000 0.676 0.000 NA 0.004
#> GSM252483     5  0.0771     0.8310 0.000 0.020 0.000 NA 0.976
#> GSM252477     5  0.1012     0.8313 0.000 0.020 0.000 NA 0.968
#> GSM252484     2  0.1965     0.8878 0.000 0.904 0.000 NA 0.000
#> GSM252476     2  0.0771     0.9048 0.000 0.976 0.000 NA 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.0291     0.7395 0.000 0.000 0.992 0.004 0.000 0.004
#> GSM252429     3  0.3921     0.5401 0.000 0.000 0.676 0.012 0.004 0.308
#> GSM252424     3  0.0000     0.7391 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252432     3  0.0260     0.7388 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM252427     3  0.1564     0.7262 0.000 0.000 0.936 0.040 0.000 0.024
#> GSM252431     3  0.5343     0.2289 0.000 0.012 0.572 0.324 0.000 0.092
#> GSM252430     5  0.1599     0.7887 0.000 0.000 0.028 0.008 0.940 0.024
#> GSM252433     5  0.6425     0.5460 0.000 0.000 0.196 0.116 0.564 0.124
#> GSM252426     3  0.3198     0.3998 0.000 0.000 0.740 0.260 0.000 0.000
#> GSM252428     4  0.4267     0.3774 0.000 0.008 0.420 0.564 0.000 0.008
#> GSM252425     2  0.6924     0.1318 0.000 0.492 0.212 0.168 0.000 0.128
#> GSM252440     1  0.2730     0.7037 0.808 0.000 0.000 0.000 0.000 0.192
#> GSM252441     1  0.0891     0.7788 0.968 0.000 0.000 0.024 0.000 0.008
#> GSM252436     1  0.0692     0.7788 0.976 0.000 0.000 0.020 0.000 0.004
#> GSM252435     1  0.1575     0.7740 0.936 0.000 0.000 0.032 0.000 0.032
#> GSM252442     4  0.3923     0.0138 0.372 0.000 0.008 0.620 0.000 0.000
#> GSM252439     5  0.3740     0.7395 0.100 0.000 0.000 0.020 0.808 0.072
#> GSM252438     5  0.8400     0.3724 0.188 0.016 0.036 0.164 0.360 0.236
#> GSM252434     1  0.3998     0.0585 0.504 0.000 0.004 0.492 0.000 0.000
#> GSM252437     1  0.1908     0.7466 0.900 0.000 0.000 0.096 0.000 0.004
#> GSM252451     1  0.0603     0.7776 0.980 0.000 0.000 0.016 0.000 0.004
#> GSM252448     1  0.2178     0.7441 0.868 0.000 0.000 0.000 0.000 0.132
#> GSM252447     1  0.0725     0.7792 0.976 0.000 0.000 0.012 0.000 0.012
#> GSM252444     1  0.0692     0.7788 0.976 0.000 0.000 0.020 0.000 0.004
#> GSM252450     1  0.1864     0.7747 0.924 0.004 0.000 0.032 0.000 0.040
#> GSM252452     5  0.5194     0.6129 0.192 0.000 0.000 0.068 0.680 0.060
#> GSM252443     1  0.3621     0.6583 0.772 0.000 0.000 0.004 0.192 0.032
#> GSM252454     1  0.4136     0.6846 0.772 0.004 0.000 0.112 0.008 0.104
#> GSM252449     1  0.3765     0.3262 0.596 0.000 0.000 0.404 0.000 0.000
#> GSM252445     1  0.3601     0.5094 0.684 0.000 0.000 0.312 0.000 0.004
#> GSM252453     1  0.4763     0.6479 0.736 0.060 0.000 0.128 0.000 0.076
#> GSM252464     3  0.1320     0.7336 0.000 0.000 0.948 0.036 0.000 0.016
#> GSM252463     3  0.4157     0.4875 0.004 0.000 0.624 0.008 0.004 0.360
#> GSM252461     1  0.0405     0.7779 0.988 0.000 0.004 0.000 0.000 0.008
#> GSM252455     3  0.1616     0.7320 0.012 0.000 0.940 0.028 0.000 0.020
#> GSM252458     3  0.1564     0.7258 0.000 0.000 0.936 0.040 0.000 0.024
#> GSM252460     4  0.3961     0.3549 0.004 0.000 0.440 0.556 0.000 0.000
#> GSM252457     3  0.4168     0.6045 0.000 0.000 0.764 0.096 0.012 0.128
#> GSM252456     3  0.3975    -0.1021 0.000 0.000 0.600 0.392 0.000 0.008
#> GSM252462     1  0.6319    -0.1559 0.412 0.000 0.168 0.392 0.000 0.028
#> GSM252459     1  0.6548     0.4762 0.580 0.068 0.024 0.200 0.000 0.128
#> GSM252472     2  0.2318     0.5914 0.000 0.892 0.000 0.064 0.000 0.044
#> GSM252466     6  0.4446     0.9376 0.000 0.424 0.000 0.016 0.008 0.552
#> GSM252469     2  0.2740     0.5212 0.000 0.864 0.000 0.060 0.000 0.076
#> GSM252475     2  0.1908     0.5770 0.000 0.916 0.000 0.056 0.000 0.028
#> GSM252471     2  0.2452     0.5887 0.000 0.892 0.000 0.056 0.008 0.044
#> GSM252465     2  0.5042     0.3737 0.000 0.592 0.000 0.308 0.000 0.100
#> GSM252474     5  0.1148     0.7869 0.000 0.004 0.000 0.016 0.960 0.020
#> GSM252473     2  0.4335     0.5226 0.000 0.776 0.000 0.076 0.064 0.084
#> GSM252468     2  0.3835     0.4151 0.000 0.684 0.000 0.300 0.000 0.016
#> GSM252470     2  0.4002     0.4037 0.000 0.704 0.000 0.260 0.000 0.036
#> GSM252467     2  0.1575     0.5988 0.000 0.936 0.000 0.032 0.000 0.032
#> GSM252485     2  0.3118     0.5695 0.000 0.836 0.000 0.092 0.000 0.072
#> GSM252481     6  0.4274     0.9367 0.000 0.432 0.000 0.012 0.004 0.552
#> GSM252480     2  0.2937     0.4959 0.000 0.848 0.000 0.056 0.000 0.096
#> GSM252479     2  0.3225     0.4949 0.000 0.828 0.000 0.092 0.000 0.080
#> GSM252482     5  0.0777     0.7944 0.000 0.000 0.000 0.004 0.972 0.024
#> GSM252478     2  0.5428     0.2585 0.000 0.484 0.000 0.396 0.000 0.120
#> GSM252483     5  0.0291     0.7931 0.000 0.000 0.000 0.004 0.992 0.004
#> GSM252477     5  0.0777     0.7943 0.000 0.000 0.000 0.004 0.972 0.024
#> GSM252484     2  0.4204     0.3868 0.000 0.696 0.000 0.260 0.004 0.040
#> GSM252476     2  0.2442     0.5909 0.000 0.884 0.000 0.048 0.000 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)

plot of chunk tab-SD-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-SD-NMF-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-SD-NMF-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-SD-NMF-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-SD-NMF-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-SD-NMF-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-SD-NMF-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-SD-NMF-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-SD-NMF-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-SD-NMF-membership-heatmap-5

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)

plot of chunk tab-SD-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-SD-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-SD-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-SD-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-SD-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-SD-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-SD-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-SD-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-SD-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-SD-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-NMF-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-SD-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-SD-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-SD-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-SD-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-SD-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-NMF-collect-classes

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 agent(p) individual(p) k
#> SD:NMF 61 1.92e-10        0.9881 2
#> SD:NMF 62 7.33e-20        1.0000 3
#> SD:NMF 60 7.79e-15        0.1815 4
#> SD:NMF 59 1.08e-13        0.2709 5
#> SD:NMF 42 1.41e-07        0.0792 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.


CV:hclust

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 51941 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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:

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)

plot of chunk CV-hclust-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.551           0.893       0.922          0.124 0.968   0.968
#> 3 3 0.233           0.474       0.597          1.898 0.511   0.495
#> 4 4 0.102           0.595       0.731          0.436 0.719   0.551
#> 5 5 0.149           0.596       0.709          0.163 0.912   0.823
#> 6 6 0.403           0.357       0.699          0.155 0.922   0.816

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 4

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1   0.204      0.924 0.968 0.032
#> GSM252429     1   0.260      0.924 0.956 0.044
#> GSM252424     1   0.327      0.919 0.940 0.060
#> GSM252432     1   0.224      0.923 0.964 0.036
#> GSM252427     1   0.260      0.926 0.956 0.044
#> GSM252431     1   0.552      0.896 0.872 0.128
#> GSM252430     1   0.416      0.916 0.916 0.084
#> GSM252433     1   0.605      0.860 0.852 0.148
#> GSM252426     1   0.242      0.924 0.960 0.040
#> GSM252428     1   0.224      0.925 0.964 0.036
#> GSM252425     1   0.327      0.920 0.940 0.060
#> GSM252440     1   0.278      0.914 0.952 0.048
#> GSM252441     1   0.242      0.917 0.960 0.040
#> GSM252436     1   0.260      0.916 0.956 0.044
#> GSM252435     1   0.184      0.921 0.972 0.028
#> GSM252442     1   0.242      0.920 0.960 0.040
#> GSM252439     1   0.388      0.908 0.924 0.076
#> GSM252438     2   0.738      0.000 0.208 0.792
#> GSM252434     1   0.242      0.920 0.960 0.040
#> GSM252437     1   0.260      0.916 0.956 0.044
#> GSM252451     1   0.260      0.918 0.956 0.044
#> GSM252448     1   0.242      0.919 0.960 0.040
#> GSM252447     1   0.278      0.914 0.952 0.048
#> GSM252444     1   0.260      0.916 0.956 0.044
#> GSM252450     1   0.260      0.916 0.956 0.044
#> GSM252452     1   0.443      0.901 0.908 0.092
#> GSM252443     1   0.278      0.920 0.952 0.048
#> GSM252454     1   0.402      0.924 0.920 0.080
#> GSM252449     1   0.242      0.920 0.960 0.040
#> GSM252445     1   0.260      0.921 0.956 0.044
#> GSM252453     1   0.242      0.919 0.960 0.040
#> GSM252464     1   0.260      0.920 0.956 0.044
#> GSM252463     1   0.242      0.921 0.960 0.040
#> GSM252461     1   0.224      0.920 0.964 0.036
#> GSM252455     1   0.224      0.922 0.964 0.036
#> GSM252458     1   0.204      0.924 0.968 0.032
#> GSM252460     1   0.260      0.920 0.956 0.044
#> GSM252457     1   0.260      0.922 0.956 0.044
#> GSM252456     1   0.204      0.924 0.968 0.032
#> GSM252462     1   0.204      0.925 0.968 0.032
#> GSM252459     1   0.184      0.923 0.972 0.028
#> GSM252472     1   0.518      0.899 0.884 0.116
#> GSM252466     1   0.563      0.888 0.868 0.132
#> GSM252469     1   0.552      0.891 0.872 0.128
#> GSM252475     1   0.574      0.884 0.864 0.136
#> GSM252471     1   0.529      0.893 0.880 0.120
#> GSM252465     1   0.671      0.859 0.824 0.176
#> GSM252474     1   0.552      0.894 0.872 0.128
#> GSM252473     1   0.574      0.887 0.864 0.136
#> GSM252468     1   0.456      0.905 0.904 0.096
#> GSM252470     1   0.224      0.925 0.964 0.036
#> GSM252467     1   0.595      0.878 0.856 0.144
#> GSM252485     1   0.529      0.897 0.880 0.120
#> GSM252481     1   0.552      0.889 0.872 0.128
#> GSM252480     1   0.563      0.888 0.868 0.132
#> GSM252479     1   0.529      0.896 0.880 0.120
#> GSM252482     1   0.506      0.903 0.888 0.112
#> GSM252478     1   0.760      0.812 0.780 0.220
#> GSM252483     1   0.506      0.902 0.888 0.112
#> GSM252477     1   0.506      0.903 0.888 0.112
#> GSM252484     1   0.482      0.901 0.896 0.104
#> GSM252476     1   0.574      0.884 0.864 0.136

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     2  0.6286    -0.5933 0.464 0.536 0.000
#> GSM252429     2  0.6442    -0.5328 0.432 0.564 0.004
#> GSM252424     2  0.5988    -0.2322 0.368 0.632 0.000
#> GSM252432     2  0.6280    -0.5813 0.460 0.540 0.000
#> GSM252427     2  0.6274    -0.6051 0.456 0.544 0.000
#> GSM252431     2  0.6082     0.4383 0.296 0.692 0.012
#> GSM252430     2  0.6675     0.2605 0.404 0.584 0.012
#> GSM252433     2  0.8951     0.0654 0.396 0.476 0.128
#> GSM252426     2  0.6168    -0.4904 0.412 0.588 0.000
#> GSM252428     2  0.6647    -0.6207 0.452 0.540 0.008
#> GSM252425     2  0.5650    -0.0344 0.312 0.688 0.000
#> GSM252440     1  0.6735     0.8788 0.564 0.424 0.012
#> GSM252441     1  0.6460     0.8819 0.556 0.440 0.004
#> GSM252436     1  0.6432     0.8823 0.568 0.428 0.004
#> GSM252435     1  0.6468     0.8822 0.552 0.444 0.004
#> GSM252442     1  0.6215     0.8739 0.572 0.428 0.000
#> GSM252439     1  0.7379     0.6402 0.584 0.376 0.040
#> GSM252438     3  0.2187     0.0000 0.028 0.024 0.948
#> GSM252434     1  0.6244     0.8795 0.560 0.440 0.000
#> GSM252437     1  0.6745     0.8844 0.560 0.428 0.012
#> GSM252451     1  0.6244     0.8829 0.560 0.440 0.000
#> GSM252448     1  0.6641     0.8722 0.544 0.448 0.008
#> GSM252447     1  0.6763     0.8807 0.552 0.436 0.012
#> GSM252444     1  0.6442     0.8810 0.564 0.432 0.004
#> GSM252450     1  0.6225     0.8799 0.568 0.432 0.000
#> GSM252452     1  0.7013     0.5445 0.640 0.324 0.036
#> GSM252443     1  0.6924     0.7321 0.580 0.400 0.020
#> GSM252454     2  0.6793    -0.6118 0.452 0.536 0.012
#> GSM252449     1  0.6244     0.8795 0.560 0.440 0.000
#> GSM252445     1  0.6633     0.8836 0.548 0.444 0.008
#> GSM252453     1  0.6307     0.8256 0.512 0.488 0.000
#> GSM252464     1  0.6345     0.8343 0.596 0.400 0.004
#> GSM252463     1  0.7029     0.8553 0.540 0.440 0.020
#> GSM252461     1  0.6617     0.8847 0.556 0.436 0.008
#> GSM252455     1  0.6468     0.8758 0.552 0.444 0.004
#> GSM252458     1  0.6274     0.8515 0.544 0.456 0.000
#> GSM252460     1  0.6126     0.8628 0.600 0.400 0.000
#> GSM252457     1  0.6919     0.7978 0.536 0.448 0.016
#> GSM252456     1  0.6280     0.8540 0.540 0.460 0.000
#> GSM252462     1  0.6664     0.8528 0.528 0.464 0.008
#> GSM252459     1  0.6309     0.8000 0.500 0.500 0.000
#> GSM252472     2  0.3573     0.5547 0.120 0.876 0.004
#> GSM252466     2  0.1170     0.5832 0.016 0.976 0.008
#> GSM252469     2  0.1015     0.5825 0.012 0.980 0.008
#> GSM252475     2  0.1878     0.5809 0.044 0.952 0.004
#> GSM252471     2  0.1525     0.5844 0.032 0.964 0.004
#> GSM252465     2  0.3995     0.5184 0.116 0.868 0.016
#> GSM252474     2  0.6388     0.4599 0.284 0.692 0.024
#> GSM252473     2  0.1950     0.5839 0.040 0.952 0.008
#> GSM252468     2  0.2537     0.5506 0.080 0.920 0.000
#> GSM252470     2  0.6598    -0.5674 0.428 0.564 0.008
#> GSM252467     2  0.1315     0.5747 0.020 0.972 0.008
#> GSM252485     2  0.3500     0.5547 0.116 0.880 0.004
#> GSM252481     2  0.0983     0.5826 0.016 0.980 0.004
#> GSM252480     2  0.1170     0.5832 0.016 0.976 0.008
#> GSM252479     2  0.1711     0.5800 0.032 0.960 0.008
#> GSM252482     2  0.6773     0.3994 0.340 0.636 0.024
#> GSM252478     2  0.7770    -0.2251 0.384 0.560 0.056
#> GSM252483     2  0.6934     0.3846 0.348 0.624 0.028
#> GSM252477     2  0.6773     0.3994 0.340 0.636 0.024
#> GSM252484     2  0.1964     0.5687 0.056 0.944 0.000
#> GSM252476     2  0.1267     0.5813 0.024 0.972 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     1   0.630     0.5816 0.632 0.268 0.100 0.000
#> GSM252429     1   0.600     0.6203 0.676 0.240 0.080 0.004
#> GSM252424     1   0.623     0.4115 0.584 0.348 0.068 0.000
#> GSM252432     1   0.640     0.5679 0.624 0.268 0.108 0.000
#> GSM252427     1   0.553     0.6562 0.708 0.220 0.072 0.000
#> GSM252431     2   0.721     0.0563 0.168 0.560 0.268 0.004
#> GSM252430     2   0.692     0.1776 0.140 0.592 0.264 0.004
#> GSM252433     2   0.729    -0.1176 0.048 0.508 0.392 0.052
#> GSM252426     1   0.597     0.5612 0.648 0.280 0.072 0.000
#> GSM252428     1   0.529     0.6919 0.736 0.204 0.056 0.004
#> GSM252425     1   0.595     0.2611 0.572 0.384 0.044 0.000
#> GSM252440     1   0.259     0.7875 0.920 0.028 0.040 0.012
#> GSM252441     1   0.259     0.7886 0.912 0.044 0.044 0.000
#> GSM252436     1   0.152     0.7889 0.956 0.024 0.020 0.000
#> GSM252435     1   0.221     0.7956 0.932 0.040 0.024 0.004
#> GSM252442     1   0.283     0.7907 0.900 0.040 0.060 0.000
#> GSM252439     1   0.837     0.2974 0.496 0.268 0.188 0.048
#> GSM252438     4   0.000     0.0000 0.000 0.000 0.000 1.000
#> GSM252434     1   0.284     0.7919 0.900 0.052 0.048 0.000
#> GSM252437     1   0.274     0.7956 0.912 0.044 0.036 0.008
#> GSM252451     1   0.136     0.7883 0.960 0.032 0.008 0.000
#> GSM252448     1   0.324     0.7860 0.880 0.052 0.068 0.000
#> GSM252447     1   0.274     0.7867 0.912 0.036 0.044 0.008
#> GSM252444     1   0.191     0.7905 0.944 0.032 0.020 0.004
#> GSM252450     1   0.115     0.7888 0.968 0.024 0.008 0.000
#> GSM252452     1   0.815     0.3291 0.532 0.248 0.172 0.048
#> GSM252443     1   0.689     0.5303 0.624 0.228 0.136 0.012
#> GSM252454     1   0.438     0.6981 0.788 0.180 0.032 0.000
#> GSM252449     1   0.284     0.7907 0.900 0.048 0.052 0.000
#> GSM252445     1   0.263     0.7966 0.916 0.048 0.028 0.008
#> GSM252453     1   0.318     0.7682 0.880 0.084 0.036 0.000
#> GSM252464     1   0.560     0.7140 0.744 0.132 0.116 0.008
#> GSM252463     1   0.424     0.7878 0.840 0.056 0.088 0.016
#> GSM252461     1   0.232     0.7974 0.928 0.036 0.032 0.004
#> GSM252455     1   0.267     0.7932 0.912 0.052 0.032 0.004
#> GSM252458     1   0.377     0.7858 0.852 0.104 0.040 0.004
#> GSM252460     1   0.395     0.7667 0.840 0.064 0.096 0.000
#> GSM252457     1   0.589     0.7016 0.724 0.156 0.108 0.012
#> GSM252456     1   0.368     0.7830 0.856 0.084 0.060 0.000
#> GSM252462     1   0.373     0.7954 0.860 0.076 0.060 0.004
#> GSM252459     1   0.365     0.7616 0.852 0.108 0.040 0.000
#> GSM252472     2   0.597     0.6391 0.296 0.644 0.056 0.004
#> GSM252466     2   0.483     0.6662 0.264 0.716 0.020 0.000
#> GSM252469     2   0.451     0.6666 0.268 0.724 0.008 0.000
#> GSM252475     2   0.514     0.6593 0.256 0.708 0.036 0.000
#> GSM252471     2   0.485     0.6690 0.268 0.712 0.020 0.000
#> GSM252465     2   0.653     0.5240 0.244 0.624 0.132 0.000
#> GSM252474     2   0.582     0.2573 0.088 0.704 0.204 0.004
#> GSM252473     2   0.514     0.6619 0.256 0.712 0.028 0.004
#> GSM252468     2   0.480     0.6215 0.340 0.656 0.004 0.000
#> GSM252470     1   0.500     0.6770 0.744 0.216 0.036 0.004
#> GSM252467     2   0.493     0.6495 0.264 0.712 0.024 0.000
#> GSM252485     2   0.587     0.6382 0.292 0.652 0.052 0.004
#> GSM252481     2   0.472     0.6656 0.264 0.720 0.016 0.000
#> GSM252480     2   0.472     0.6671 0.264 0.720 0.016 0.000
#> GSM252479     2   0.482     0.6562 0.296 0.692 0.012 0.000
#> GSM252482     2   0.543     0.1448 0.040 0.696 0.260 0.004
#> GSM252478     3   0.493     0.0000 0.000 0.432 0.568 0.000
#> GSM252483     2   0.576     0.1273 0.048 0.680 0.264 0.008
#> GSM252477     2   0.543     0.1448 0.040 0.696 0.260 0.004
#> GSM252484     2   0.468     0.6423 0.316 0.680 0.004 0.000
#> GSM252476     2   0.478     0.6595 0.272 0.712 0.016 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     1  0.7443     0.5089 0.508 0.228 0.180 0.000 0.084
#> GSM252429     1  0.6782     0.6034 0.588 0.204 0.144 0.000 0.064
#> GSM252424     1  0.7185     0.3876 0.476 0.340 0.108 0.000 0.076
#> GSM252432     1  0.7510     0.4996 0.504 0.224 0.180 0.000 0.092
#> GSM252427     1  0.6646     0.6152 0.604 0.200 0.132 0.000 0.064
#> GSM252431     2  0.7290    -0.1332 0.088 0.476 0.108 0.000 0.328
#> GSM252430     3  0.5890     0.4408 0.088 0.352 0.552 0.000 0.008
#> GSM252433     3  0.7192    -0.0365 0.012 0.304 0.488 0.024 0.172
#> GSM252426     1  0.6639     0.5354 0.564 0.280 0.104 0.000 0.052
#> GSM252428     1  0.5690     0.6793 0.684 0.188 0.100 0.004 0.024
#> GSM252425     1  0.6777     0.0561 0.440 0.404 0.128 0.000 0.028
#> GSM252440     1  0.3602     0.7382 0.848 0.032 0.096 0.008 0.016
#> GSM252441     1  0.3352     0.7350 0.852 0.036 0.100 0.000 0.012
#> GSM252436     1  0.2299     0.7510 0.912 0.032 0.052 0.000 0.004
#> GSM252435     1  0.2950     0.7562 0.888 0.028 0.060 0.004 0.020
#> GSM252442     1  0.4238     0.7490 0.816 0.040 0.092 0.004 0.048
#> GSM252439     3  0.7119     0.0564 0.396 0.088 0.456 0.040 0.020
#> GSM252438     4  0.0162     0.0000 0.000 0.000 0.004 0.996 0.000
#> GSM252434     1  0.3955     0.7524 0.832 0.044 0.088 0.004 0.032
#> GSM252437     1  0.2930     0.7522 0.884 0.024 0.076 0.008 0.008
#> GSM252451     1  0.2673     0.7488 0.900 0.036 0.044 0.000 0.020
#> GSM252448     1  0.3653     0.7288 0.828 0.036 0.124 0.000 0.012
#> GSM252447     1  0.3580     0.7325 0.848 0.036 0.096 0.008 0.012
#> GSM252444     1  0.2959     0.7525 0.888 0.040 0.052 0.004 0.016
#> GSM252450     1  0.2333     0.7537 0.916 0.028 0.040 0.000 0.016
#> GSM252452     3  0.6353     0.0134 0.428 0.032 0.484 0.036 0.020
#> GSM252443     1  0.6294     0.3025 0.536 0.068 0.364 0.008 0.024
#> GSM252454     1  0.5198     0.6484 0.708 0.208 0.048 0.000 0.036
#> GSM252449     1  0.3955     0.7513 0.832 0.044 0.088 0.004 0.032
#> GSM252445     1  0.3196     0.7581 0.868 0.040 0.080 0.008 0.004
#> GSM252453     1  0.5175     0.6722 0.744 0.112 0.100 0.000 0.044
#> GSM252464     1  0.6400     0.6020 0.620 0.060 0.236 0.004 0.080
#> GSM252463     1  0.4714     0.7340 0.764 0.028 0.168 0.012 0.028
#> GSM252461     1  0.3511     0.7549 0.848 0.024 0.104 0.004 0.020
#> GSM252455     1  0.4097     0.7567 0.824 0.052 0.088 0.004 0.032
#> GSM252458     1  0.5081     0.7416 0.752 0.084 0.128 0.004 0.032
#> GSM252460     1  0.5631     0.6826 0.708 0.052 0.164 0.004 0.072
#> GSM252457     1  0.5999     0.6280 0.644 0.104 0.224 0.004 0.024
#> GSM252456     1  0.5088     0.7264 0.740 0.060 0.156 0.000 0.044
#> GSM252462     1  0.4725     0.7470 0.772 0.036 0.148 0.008 0.036
#> GSM252459     1  0.4915     0.6973 0.756 0.120 0.096 0.000 0.028
#> GSM252472     2  0.5365     0.7419 0.172 0.704 0.104 0.000 0.020
#> GSM252466     2  0.3489     0.8224 0.148 0.824 0.016 0.000 0.012
#> GSM252469     2  0.3362     0.8228 0.156 0.824 0.012 0.000 0.008
#> GSM252475     2  0.4437     0.8104 0.148 0.780 0.044 0.000 0.028
#> GSM252471     2  0.3844     0.8126 0.144 0.808 0.040 0.000 0.008
#> GSM252465     2  0.5770     0.6817 0.140 0.688 0.040 0.000 0.132
#> GSM252474     2  0.5276    -0.2884 0.048 0.516 0.436 0.000 0.000
#> GSM252473     2  0.3911     0.8005 0.144 0.796 0.060 0.000 0.000
#> GSM252468     2  0.3974     0.7293 0.228 0.752 0.016 0.000 0.004
#> GSM252470     1  0.5251     0.6751 0.704 0.212 0.060 0.004 0.020
#> GSM252467     2  0.3853     0.8151 0.152 0.804 0.008 0.000 0.036
#> GSM252485     2  0.5458     0.7369 0.172 0.696 0.112 0.000 0.020
#> GSM252481     2  0.3489     0.8224 0.148 0.824 0.012 0.000 0.016
#> GSM252480     2  0.3379     0.8222 0.148 0.828 0.016 0.000 0.008
#> GSM252479     2  0.3734     0.8058 0.184 0.792 0.016 0.000 0.008
#> GSM252482     3  0.4865     0.4403 0.016 0.444 0.536 0.000 0.004
#> GSM252478     5  0.4243     0.0000 0.000 0.264 0.024 0.000 0.712
#> GSM252483     3  0.4843     0.4547 0.016 0.428 0.552 0.000 0.004
#> GSM252477     3  0.4865     0.4403 0.016 0.444 0.536 0.000 0.004
#> GSM252484     2  0.3630     0.7769 0.204 0.780 0.016 0.000 0.000
#> GSM252476     2  0.3903     0.8181 0.160 0.800 0.020 0.000 0.020

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.6830     0.7137 0.328 0.184 0.428 0.004 0.056 0.000
#> GSM252429     1  0.6675    -0.4577 0.448 0.172 0.328 0.004 0.048 0.000
#> GSM252424     1  0.7138    -0.5511 0.336 0.284 0.316 0.004 0.060 0.000
#> GSM252432     3  0.6949     0.7162 0.324 0.172 0.432 0.008 0.064 0.000
#> GSM252427     1  0.6669    -0.4744 0.432 0.164 0.344 0.000 0.060 0.000
#> GSM252431     2  0.6848    -0.2742 0.020 0.404 0.152 0.384 0.040 0.000
#> GSM252430     5  0.5931     0.4634 0.032 0.284 0.116 0.004 0.564 0.000
#> GSM252433     5  0.7305    -0.1696 0.004 0.128 0.320 0.100 0.432 0.016
#> GSM252426     1  0.6607    -0.4474 0.448 0.232 0.280 0.000 0.040 0.000
#> GSM252428     1  0.6270     0.0714 0.596 0.152 0.188 0.008 0.052 0.004
#> GSM252425     2  0.6862    -0.1710 0.296 0.444 0.204 0.008 0.048 0.000
#> GSM252440     1  0.3805     0.5201 0.812 0.012 0.052 0.008 0.112 0.004
#> GSM252441     1  0.2995     0.5331 0.864 0.012 0.048 0.004 0.072 0.000
#> GSM252436     1  0.2854     0.5427 0.872 0.020 0.080 0.004 0.024 0.000
#> GSM252435     1  0.2911     0.5375 0.856 0.008 0.100 0.000 0.036 0.000
#> GSM252442     1  0.4156     0.4008 0.728 0.028 0.224 0.000 0.020 0.000
#> GSM252439     5  0.6959     0.1403 0.292 0.052 0.092 0.012 0.516 0.036
#> GSM252438     6  0.0000     0.0000 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM252434     1  0.3658     0.4347 0.772 0.028 0.192 0.000 0.008 0.000
#> GSM252437     1  0.3227     0.5367 0.860 0.016 0.048 0.008 0.064 0.004
#> GSM252451     1  0.2976     0.5374 0.860 0.024 0.088 0.000 0.028 0.000
#> GSM252448     1  0.3354     0.5207 0.836 0.012 0.048 0.004 0.100 0.000
#> GSM252447     1  0.3478     0.5253 0.832 0.012 0.044 0.004 0.104 0.004
#> GSM252444     1  0.3410     0.5245 0.824 0.028 0.128 0.000 0.016 0.004
#> GSM252450     1  0.2395     0.5415 0.892 0.012 0.076 0.000 0.020 0.000
#> GSM252452     5  0.6817     0.1207 0.232 0.004 0.224 0.016 0.492 0.032
#> GSM252443     1  0.6713     0.0506 0.440 0.032 0.140 0.016 0.368 0.004
#> GSM252454     1  0.5574     0.3447 0.668 0.192 0.032 0.028 0.080 0.000
#> GSM252449     1  0.3724     0.4378 0.772 0.028 0.188 0.000 0.012 0.000
#> GSM252445     1  0.3268     0.5375 0.852 0.028 0.072 0.000 0.044 0.004
#> GSM252453     1  0.6083     0.3559 0.636 0.136 0.140 0.016 0.072 0.000
#> GSM252464     3  0.6081     0.3955 0.404 0.016 0.448 0.008 0.124 0.000
#> GSM252463     1  0.5110     0.3999 0.696 0.012 0.152 0.008 0.128 0.004
#> GSM252461     1  0.3292     0.5355 0.840 0.004 0.088 0.008 0.060 0.000
#> GSM252455     1  0.4543     0.4595 0.720 0.040 0.208 0.000 0.028 0.004
#> GSM252458     1  0.5496     0.1987 0.624 0.052 0.252 0.000 0.072 0.000
#> GSM252460     1  0.5665    -0.3358 0.504 0.036 0.400 0.004 0.056 0.000
#> GSM252457     1  0.6622     0.1787 0.572 0.076 0.144 0.012 0.192 0.004
#> GSM252456     1  0.5405     0.0791 0.564 0.048 0.352 0.004 0.032 0.000
#> GSM252462     1  0.5095     0.2574 0.616 0.040 0.312 0.000 0.028 0.004
#> GSM252459     1  0.6117     0.3316 0.616 0.156 0.160 0.012 0.056 0.000
#> GSM252472     2  0.4238     0.6689 0.036 0.788 0.052 0.012 0.112 0.000
#> GSM252466     2  0.0862     0.7592 0.008 0.972 0.000 0.004 0.016 0.000
#> GSM252469     2  0.1053     0.7604 0.020 0.964 0.004 0.000 0.012 0.000
#> GSM252475     2  0.2257     0.7457 0.008 0.912 0.016 0.020 0.044 0.000
#> GSM252471     2  0.2039     0.7377 0.016 0.908 0.004 0.000 0.072 0.000
#> GSM252465     2  0.4116     0.6210 0.008 0.776 0.020 0.152 0.044 0.000
#> GSM252474     2  0.4315    -0.2817 0.012 0.492 0.004 0.000 0.492 0.000
#> GSM252473     2  0.2019     0.7264 0.012 0.900 0.000 0.000 0.088 0.000
#> GSM252468     2  0.3482     0.6453 0.108 0.824 0.048 0.000 0.020 0.000
#> GSM252470     1  0.5896     0.1860 0.636 0.196 0.112 0.012 0.040 0.004
#> GSM252467     2  0.1498     0.7559 0.012 0.948 0.004 0.024 0.012 0.000
#> GSM252485     2  0.4497     0.6517 0.048 0.768 0.060 0.008 0.116 0.000
#> GSM252481     2  0.0881     0.7595 0.008 0.972 0.000 0.008 0.012 0.000
#> GSM252480     2  0.0806     0.7592 0.008 0.972 0.000 0.000 0.020 0.000
#> GSM252479     2  0.1952     0.7410 0.052 0.920 0.016 0.000 0.012 0.000
#> GSM252482     5  0.4203     0.4423 0.008 0.388 0.008 0.000 0.596 0.000
#> GSM252478     4  0.2651     0.0000 0.000 0.112 0.000 0.860 0.028 0.000
#> GSM252483     5  0.4138     0.4654 0.008 0.364 0.008 0.000 0.620 0.000
#> GSM252477     5  0.4193     0.4466 0.008 0.384 0.008 0.000 0.600 0.000
#> GSM252484     2  0.2642     0.7189 0.064 0.884 0.032 0.000 0.020 0.000
#> GSM252476     2  0.2156     0.7557 0.028 0.920 0.020 0.020 0.012 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)

plot of chunk tab-CV-hclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-CV-hclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-CV-hclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-CV-hclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-CV-hclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-CV-hclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-CV-hclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-CV-hclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-CV-hclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-CV-hclust-membership-heatmap-5

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)

plot of chunk tab-CV-hclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-CV-hclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-CV-hclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-CV-hclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-CV-hclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-CV-hclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-CV-hclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-CV-hclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-CV-hclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-CV-hclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-hclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-CV-hclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-CV-hclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-CV-hclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-CV-hclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-CV-hclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-hclust-collect-classes

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 agent(p) individual(p) k
#> CV:hclust 61       NA            NA 2
#> CV:hclust 43 1.03e-08         0.775 3
#> CV:hclust 49 1.62e-08         0.898 4
#> CV:hclust 47 3.95e-08         0.922 5
#> CV:hclust 29 8.64e-09         0.723 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.


CV:kmeans

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 51941 rows and 62 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)

plot of chunk CV-kmeans-collect-plots

The plots are:

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:

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)

plot of chunk CV-kmeans-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.541           0.803       0.899         0.4694 0.511   0.511
#> 3 3 0.563           0.680       0.803         0.3274 0.830   0.675
#> 4 4 0.621           0.731       0.820         0.1425 0.815   0.543
#> 5 5 0.658           0.670       0.798         0.0631 0.961   0.857
#> 6 6 0.687           0.542       0.745         0.0445 0.961   0.852

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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1  0.9922    0.12901 0.552 0.448
#> GSM252429     1  0.9977    0.07243 0.528 0.472
#> GSM252424     1  0.9993    0.00493 0.516 0.484
#> GSM252432     1  0.9933    0.11572 0.548 0.452
#> GSM252427     1  0.9954    0.10210 0.540 0.460
#> GSM252431     2  0.8955    0.62946 0.312 0.688
#> GSM252430     2  0.1843    0.89480 0.028 0.972
#> GSM252433     2  0.3879    0.86342 0.076 0.924
#> GSM252426     1  0.9954    0.08726 0.540 0.460
#> GSM252428     1  0.9933    0.12911 0.548 0.452
#> GSM252425     2  0.5408    0.94454 0.124 0.876
#> GSM252440     1  0.0672    0.87668 0.992 0.008
#> GSM252441     1  0.0376    0.87760 0.996 0.004
#> GSM252436     1  0.0000    0.87778 1.000 0.000
#> GSM252435     1  0.0376    0.87760 0.996 0.004
#> GSM252442     1  0.0000    0.87778 1.000 0.000
#> GSM252439     1  0.4562    0.80511 0.904 0.096
#> GSM252438     1  0.6247    0.77544 0.844 0.156
#> GSM252434     1  0.0000    0.87778 1.000 0.000
#> GSM252437     1  0.0376    0.87760 0.996 0.004
#> GSM252451     1  0.0000    0.87778 1.000 0.000
#> GSM252448     1  0.0672    0.87668 0.992 0.008
#> GSM252447     1  0.0376    0.87760 0.996 0.004
#> GSM252444     1  0.0000    0.87778 1.000 0.000
#> GSM252450     1  0.0000    0.87778 1.000 0.000
#> GSM252452     1  0.4431    0.80576 0.908 0.092
#> GSM252443     1  0.1843    0.86335 0.972 0.028
#> GSM252454     1  0.1843    0.86257 0.972 0.028
#> GSM252449     1  0.0000    0.87778 1.000 0.000
#> GSM252445     1  0.0376    0.87760 0.996 0.004
#> GSM252453     1  0.0000    0.87778 1.000 0.000
#> GSM252464     1  0.0376    0.87702 0.996 0.004
#> GSM252463     1  0.0672    0.87668 0.992 0.008
#> GSM252461     1  0.0672    0.87668 0.992 0.008
#> GSM252455     1  0.0000    0.87778 1.000 0.000
#> GSM252458     1  0.0938    0.87414 0.988 0.012
#> GSM252460     1  0.0376    0.87607 0.996 0.004
#> GSM252457     1  0.0938    0.87466 0.988 0.012
#> GSM252456     1  0.0000    0.87778 1.000 0.000
#> GSM252462     1  0.0376    0.87760 0.996 0.004
#> GSM252459     1  0.0000    0.87778 1.000 0.000
#> GSM252472     2  0.5059    0.95454 0.112 0.888
#> GSM252466     2  0.4939    0.95442 0.108 0.892
#> GSM252469     2  0.4939    0.95442 0.108 0.892
#> GSM252475     2  0.5059    0.95454 0.112 0.888
#> GSM252471     2  0.4939    0.95442 0.108 0.892
#> GSM252465     2  0.4939    0.95296 0.108 0.892
#> GSM252474     2  0.1184    0.89482 0.016 0.984
#> GSM252473     2  0.4939    0.95442 0.108 0.892
#> GSM252468     2  0.5059    0.95454 0.112 0.888
#> GSM252470     2  0.4939    0.95442 0.108 0.892
#> GSM252467     2  0.5059    0.95454 0.112 0.888
#> GSM252485     2  0.5059    0.95454 0.112 0.888
#> GSM252481     2  0.4939    0.95442 0.108 0.892
#> GSM252480     2  0.4939    0.95442 0.108 0.892
#> GSM252479     2  0.5059    0.95454 0.112 0.888
#> GSM252482     2  0.1184    0.89482 0.016 0.984
#> GSM252478     2  0.4562    0.94787 0.096 0.904
#> GSM252483     2  0.1184    0.89482 0.016 0.984
#> GSM252477     2  0.1184    0.89482 0.016 0.984
#> GSM252484     2  0.5059    0.95454 0.112 0.888
#> GSM252476     2  0.5059    0.95454 0.112 0.888

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.9787      0.643 0.320 0.252 0.428
#> GSM252429     3  0.9858      0.630 0.328 0.264 0.408
#> GSM252424     3  0.9924      0.660 0.288 0.320 0.392
#> GSM252432     3  0.9813      0.667 0.304 0.268 0.428
#> GSM252427     3  0.9808      0.664 0.308 0.264 0.428
#> GSM252431     3  0.8401      0.381 0.084 0.444 0.472
#> GSM252430     3  0.5621      0.149 0.000 0.308 0.692
#> GSM252433     3  0.4784      0.272 0.004 0.200 0.796
#> GSM252426     3  0.9817      0.669 0.300 0.272 0.428
#> GSM252428     3  0.9808      0.664 0.308 0.264 0.428
#> GSM252425     2  0.5992      0.402 0.016 0.716 0.268
#> GSM252440     1  0.1878      0.798 0.952 0.004 0.044
#> GSM252441     1  0.1525      0.802 0.964 0.004 0.032
#> GSM252436     1  0.0829      0.804 0.984 0.004 0.012
#> GSM252435     1  0.1267      0.803 0.972 0.004 0.024
#> GSM252442     1  0.3112      0.769 0.900 0.004 0.096
#> GSM252439     1  0.6513      0.191 0.520 0.004 0.476
#> GSM252438     3  0.4409      0.286 0.172 0.004 0.824
#> GSM252434     1  0.2496      0.785 0.928 0.004 0.068
#> GSM252437     1  0.1399      0.803 0.968 0.004 0.028
#> GSM252451     1  0.0829      0.804 0.984 0.004 0.012
#> GSM252448     1  0.1989      0.798 0.948 0.004 0.048
#> GSM252447     1  0.1525      0.802 0.964 0.004 0.032
#> GSM252444     1  0.0475      0.805 0.992 0.004 0.004
#> GSM252450     1  0.0475      0.805 0.992 0.004 0.004
#> GSM252452     1  0.6451      0.258 0.560 0.004 0.436
#> GSM252443     1  0.3272      0.770 0.892 0.004 0.104
#> GSM252454     1  0.2793      0.789 0.928 0.028 0.044
#> GSM252449     1  0.2400      0.786 0.932 0.004 0.064
#> GSM252445     1  0.0661      0.806 0.988 0.004 0.008
#> GSM252453     1  0.1399      0.805 0.968 0.004 0.028
#> GSM252464     1  0.6140      0.304 0.596 0.000 0.404
#> GSM252463     1  0.5327      0.606 0.728 0.000 0.272
#> GSM252461     1  0.2261      0.797 0.932 0.000 0.068
#> GSM252455     1  0.3879      0.720 0.848 0.000 0.152
#> GSM252458     1  0.6057      0.438 0.656 0.004 0.340
#> GSM252460     1  0.6282      0.346 0.612 0.004 0.384
#> GSM252457     1  0.6008      0.423 0.628 0.000 0.372
#> GSM252456     1  0.5835      0.447 0.660 0.000 0.340
#> GSM252462     1  0.4504      0.679 0.804 0.000 0.196
#> GSM252459     1  0.2165      0.797 0.936 0.000 0.064
#> GSM252472     2  0.1015      0.866 0.012 0.980 0.008
#> GSM252466     2  0.0829      0.869 0.012 0.984 0.004
#> GSM252469     2  0.0592      0.869 0.012 0.988 0.000
#> GSM252475     2  0.0829      0.869 0.012 0.984 0.004
#> GSM252471     2  0.0829      0.869 0.012 0.984 0.004
#> GSM252465     2  0.1170      0.863 0.008 0.976 0.016
#> GSM252474     2  0.6079      0.474 0.000 0.612 0.388
#> GSM252473     2  0.1015      0.868 0.012 0.980 0.008
#> GSM252468     2  0.0592      0.869 0.012 0.988 0.000
#> GSM252470     2  0.1182      0.864 0.012 0.976 0.012
#> GSM252467     2  0.1015      0.867 0.012 0.980 0.008
#> GSM252485     2  0.1182      0.866 0.012 0.976 0.012
#> GSM252481     2  0.0829      0.869 0.012 0.984 0.004
#> GSM252480     2  0.1482      0.862 0.012 0.968 0.020
#> GSM252479     2  0.0592      0.869 0.012 0.988 0.000
#> GSM252482     2  0.6154      0.450 0.000 0.592 0.408
#> GSM252478     2  0.1878      0.844 0.004 0.952 0.044
#> GSM252483     2  0.6168      0.446 0.000 0.588 0.412
#> GSM252477     2  0.6168      0.446 0.000 0.588 0.412
#> GSM252484     2  0.0592      0.869 0.012 0.988 0.000
#> GSM252476     2  0.1015      0.867 0.012 0.980 0.008

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.4537     0.8007 0.088 0.072 0.824 0.016
#> GSM252429     3  0.5690     0.7803 0.100 0.080 0.768 0.052
#> GSM252424     3  0.5555     0.7706 0.096 0.116 0.764 0.024
#> GSM252432     3  0.4292     0.8030 0.088 0.072 0.832 0.008
#> GSM252427     3  0.4990     0.8082 0.100 0.064 0.804 0.032
#> GSM252431     3  0.5878     0.5416 0.012 0.176 0.720 0.092
#> GSM252430     4  0.7018     0.5234 0.004 0.168 0.236 0.592
#> GSM252433     4  0.5585     0.5150 0.000 0.084 0.204 0.712
#> GSM252426     3  0.4676     0.8044 0.100 0.076 0.812 0.012
#> GSM252428     3  0.4409     0.8082 0.100 0.068 0.824 0.008
#> GSM252425     2  0.5203     0.3912 0.000 0.636 0.348 0.016
#> GSM252440     1  0.3280     0.8096 0.860 0.000 0.016 0.124
#> GSM252441     1  0.2125     0.8376 0.920 0.000 0.004 0.076
#> GSM252436     1  0.0927     0.8382 0.976 0.000 0.016 0.008
#> GSM252435     1  0.1970     0.8424 0.932 0.000 0.008 0.060
#> GSM252442     1  0.4319     0.6103 0.760 0.000 0.228 0.012
#> GSM252439     4  0.5344     0.2903 0.300 0.000 0.032 0.668
#> GSM252438     4  0.4590     0.4426 0.060 0.000 0.148 0.792
#> GSM252434     1  0.3324     0.7488 0.852 0.000 0.136 0.012
#> GSM252437     1  0.2198     0.8399 0.920 0.000 0.008 0.072
#> GSM252451     1  0.1297     0.8373 0.964 0.000 0.016 0.020
#> GSM252448     1  0.3108     0.8163 0.872 0.000 0.016 0.112
#> GSM252447     1  0.2125     0.8376 0.920 0.000 0.004 0.076
#> GSM252444     1  0.0804     0.8392 0.980 0.000 0.012 0.008
#> GSM252450     1  0.0804     0.8433 0.980 0.000 0.012 0.008
#> GSM252452     4  0.5657     0.2914 0.312 0.000 0.044 0.644
#> GSM252443     1  0.4281     0.7642 0.792 0.000 0.028 0.180
#> GSM252454     1  0.3200     0.8318 0.880 0.012 0.012 0.096
#> GSM252449     1  0.2859     0.7733 0.880 0.000 0.112 0.008
#> GSM252445     1  0.1256     0.8448 0.964 0.000 0.008 0.028
#> GSM252453     1  0.1151     0.8432 0.968 0.000 0.008 0.024
#> GSM252464     3  0.4994     0.7582 0.208 0.000 0.744 0.048
#> GSM252463     3  0.7453     0.3793 0.324 0.000 0.484 0.192
#> GSM252461     1  0.4849     0.7701 0.772 0.000 0.064 0.164
#> GSM252455     1  0.6094    -0.1073 0.536 0.000 0.416 0.048
#> GSM252458     3  0.4900     0.7461 0.236 0.000 0.732 0.032
#> GSM252460     3  0.5143     0.7276 0.256 0.000 0.708 0.036
#> GSM252457     3  0.6654     0.5709 0.296 0.000 0.588 0.116
#> GSM252456     3  0.5466     0.6803 0.292 0.000 0.668 0.040
#> GSM252462     1  0.6024    -0.0312 0.540 0.000 0.416 0.044
#> GSM252459     1  0.2739     0.8220 0.904 0.000 0.036 0.060
#> GSM252472     2  0.1452     0.9265 0.000 0.956 0.036 0.008
#> GSM252466     2  0.0469     0.9343 0.000 0.988 0.000 0.012
#> GSM252469     2  0.0524     0.9374 0.000 0.988 0.004 0.008
#> GSM252475     2  0.0000     0.9377 0.000 1.000 0.000 0.000
#> GSM252471     2  0.0592     0.9323 0.000 0.984 0.000 0.016
#> GSM252465     2  0.1820     0.9144 0.000 0.944 0.036 0.020
#> GSM252474     4  0.4996     0.4031 0.000 0.484 0.000 0.516
#> GSM252473     2  0.0592     0.9323 0.000 0.984 0.000 0.016
#> GSM252468     2  0.0707     0.9388 0.000 0.980 0.020 0.000
#> GSM252470     2  0.1109     0.9326 0.000 0.968 0.028 0.004
#> GSM252467     2  0.0804     0.9382 0.000 0.980 0.012 0.008
#> GSM252485     2  0.1256     0.9328 0.000 0.964 0.028 0.008
#> GSM252481     2  0.0336     0.9351 0.000 0.992 0.000 0.008
#> GSM252480     2  0.0779     0.9345 0.000 0.980 0.004 0.016
#> GSM252479     2  0.0817     0.9379 0.000 0.976 0.024 0.000
#> GSM252482     4  0.5746     0.4860 0.004 0.444 0.020 0.532
#> GSM252478     2  0.3239     0.8499 0.000 0.880 0.068 0.052
#> GSM252483     4  0.5746     0.4860 0.004 0.444 0.020 0.532
#> GSM252477     4  0.5746     0.4860 0.004 0.444 0.020 0.532
#> GSM252484     2  0.0707     0.9388 0.000 0.980 0.020 0.000
#> GSM252476     2  0.1042     0.9369 0.000 0.972 0.020 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.2682    0.70268 0.028 0.040 0.904 0.024 0.004
#> GSM252429     3  0.4222    0.67925 0.044 0.060 0.832 0.032 0.032
#> GSM252424     3  0.3868    0.67031 0.028 0.092 0.840 0.020 0.020
#> GSM252432     3  0.2353    0.70437 0.028 0.044 0.916 0.008 0.004
#> GSM252427     3  0.3064    0.71257 0.032 0.032 0.888 0.040 0.008
#> GSM252431     3  0.6102    0.31646 0.000 0.076 0.632 0.240 0.052
#> GSM252430     5  0.4950    0.40585 0.004 0.120 0.152 0.000 0.724
#> GSM252433     5  0.4841    0.18749 0.000 0.044 0.132 0.060 0.764
#> GSM252426     3  0.2856    0.70493 0.032 0.044 0.892 0.032 0.000
#> GSM252428     3  0.3247    0.70942 0.032 0.028 0.868 0.072 0.000
#> GSM252425     2  0.5529    0.23709 0.000 0.512 0.420 0.068 0.000
#> GSM252440     1  0.2751    0.78570 0.888 0.000 0.004 0.056 0.052
#> GSM252441     1  0.0671    0.82683 0.980 0.000 0.000 0.016 0.004
#> GSM252436     1  0.2305    0.82964 0.896 0.000 0.012 0.092 0.000
#> GSM252435     1  0.1569    0.83226 0.948 0.000 0.012 0.032 0.008
#> GSM252442     1  0.6275    0.43161 0.556 0.000 0.252 0.188 0.004
#> GSM252439     5  0.6295   -0.16720 0.308 0.000 0.008 0.144 0.540
#> GSM252438     4  0.4874    0.00000 0.008 0.000 0.016 0.588 0.388
#> GSM252434     1  0.5410    0.67325 0.676 0.000 0.140 0.180 0.004
#> GSM252437     1  0.1364    0.83411 0.952 0.000 0.012 0.036 0.000
#> GSM252451     1  0.3155    0.82002 0.852 0.000 0.020 0.120 0.008
#> GSM252448     1  0.2536    0.79556 0.900 0.000 0.004 0.044 0.052
#> GSM252447     1  0.0865    0.82462 0.972 0.000 0.000 0.024 0.004
#> GSM252444     1  0.3204    0.82878 0.860 0.000 0.016 0.100 0.024
#> GSM252450     1  0.2228    0.83434 0.908 0.000 0.012 0.076 0.004
#> GSM252452     5  0.6093   -0.00324 0.176 0.000 0.040 0.132 0.652
#> GSM252443     1  0.4691    0.68189 0.760 0.000 0.012 0.100 0.128
#> GSM252454     1  0.2590    0.82186 0.908 0.008 0.012 0.044 0.028
#> GSM252449     1  0.5289    0.68938 0.688 0.000 0.128 0.180 0.004
#> GSM252445     1  0.2270    0.83320 0.904 0.000 0.020 0.076 0.000
#> GSM252453     1  0.3809    0.78930 0.804 0.000 0.016 0.160 0.020
#> GSM252464     3  0.4330    0.69566 0.052 0.000 0.776 0.160 0.012
#> GSM252463     3  0.7945    0.31769 0.280 0.000 0.424 0.180 0.116
#> GSM252461     1  0.5579    0.67420 0.708 0.000 0.048 0.148 0.096
#> GSM252455     3  0.7198    0.20099 0.380 0.000 0.400 0.188 0.032
#> GSM252458     3  0.4054    0.69706 0.072 0.000 0.788 0.140 0.000
#> GSM252460     3  0.4608    0.68172 0.060 0.000 0.744 0.188 0.008
#> GSM252457     3  0.7119    0.46179 0.212 0.000 0.560 0.132 0.096
#> GSM252456     3  0.5459    0.63389 0.096 0.000 0.660 0.236 0.008
#> GSM252462     3  0.7156    0.30771 0.312 0.000 0.420 0.248 0.020
#> GSM252459     1  0.5249    0.73617 0.712 0.000 0.064 0.192 0.032
#> GSM252472     2  0.2086    0.87262 0.000 0.924 0.048 0.020 0.008
#> GSM252466     2  0.0703    0.89570 0.000 0.976 0.000 0.000 0.024
#> GSM252469     2  0.0671    0.89908 0.000 0.980 0.004 0.000 0.016
#> GSM252475     2  0.0290    0.89989 0.000 0.992 0.000 0.000 0.008
#> GSM252471     2  0.0703    0.89570 0.000 0.976 0.000 0.000 0.024
#> GSM252465     2  0.3361    0.81211 0.000 0.856 0.032 0.092 0.020
#> GSM252474     5  0.4101    0.56175 0.000 0.372 0.000 0.000 0.628
#> GSM252473     2  0.0703    0.89570 0.000 0.976 0.000 0.000 0.024
#> GSM252468     2  0.0404    0.90068 0.000 0.988 0.012 0.000 0.000
#> GSM252470     2  0.1372    0.89686 0.004 0.956 0.024 0.000 0.016
#> GSM252467     2  0.1205    0.88768 0.000 0.956 0.004 0.040 0.000
#> GSM252485     2  0.1525    0.88787 0.000 0.948 0.036 0.012 0.004
#> GSM252481     2  0.0703    0.89570 0.000 0.976 0.000 0.000 0.024
#> GSM252480     2  0.0703    0.89570 0.000 0.976 0.000 0.000 0.024
#> GSM252479     2  0.0404    0.90068 0.000 0.988 0.012 0.000 0.000
#> GSM252482     5  0.4387    0.59745 0.004 0.336 0.008 0.000 0.652
#> GSM252478     2  0.5920    0.56407 0.000 0.656 0.072 0.220 0.052
#> GSM252483     5  0.4387    0.59745 0.004 0.336 0.008 0.000 0.652
#> GSM252477     5  0.4387    0.59745 0.004 0.336 0.008 0.000 0.652
#> GSM252484     2  0.0404    0.90068 0.000 0.988 0.012 0.000 0.000
#> GSM252476     2  0.1808    0.88148 0.000 0.936 0.020 0.040 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.2055    0.66403 0.016 0.020 0.928 0.016 0.004 0.016
#> GSM252429     3  0.3316    0.64568 0.016 0.028 0.868 0.032 0.040 0.016
#> GSM252424     3  0.2855    0.64687 0.016 0.072 0.880 0.008 0.008 0.016
#> GSM252432     3  0.1943    0.66909 0.016 0.016 0.932 0.024 0.004 0.008
#> GSM252427     3  0.3400    0.66322 0.016 0.016 0.852 0.084 0.016 0.016
#> GSM252431     3  0.6935    0.14809 0.000 0.028 0.484 0.312 0.088 0.088
#> GSM252430     5  0.4173    0.53645 0.004 0.064 0.168 0.000 0.756 0.008
#> GSM252433     5  0.4871    0.38523 0.000 0.012 0.140 0.004 0.704 0.140
#> GSM252426     3  0.3152    0.65689 0.016 0.028 0.860 0.084 0.004 0.008
#> GSM252428     3  0.3636    0.63861 0.016 0.012 0.808 0.148 0.008 0.008
#> GSM252425     2  0.6415    0.10723 0.000 0.444 0.408 0.088 0.036 0.024
#> GSM252440     1  0.3165    0.55627 0.864 0.000 0.008 0.052 0.036 0.040
#> GSM252441     1  0.0291    0.60629 0.992 0.000 0.000 0.004 0.004 0.000
#> GSM252436     1  0.4004    0.43205 0.684 0.000 0.004 0.296 0.004 0.012
#> GSM252435     1  0.1554    0.60578 0.940 0.000 0.004 0.044 0.004 0.008
#> GSM252442     4  0.6290    0.36141 0.356 0.000 0.164 0.456 0.016 0.008
#> GSM252439     1  0.7285   -0.15425 0.416 0.000 0.016 0.084 0.312 0.172
#> GSM252438     6  0.1901    0.00000 0.012 0.000 0.004 0.008 0.052 0.924
#> GSM252434     1  0.5546   -0.18034 0.476 0.000 0.072 0.432 0.016 0.004
#> GSM252437     1  0.2113    0.59513 0.896 0.000 0.000 0.092 0.008 0.004
#> GSM252451     1  0.4320    0.39161 0.640 0.000 0.004 0.332 0.004 0.020
#> GSM252448     1  0.3082    0.55754 0.864 0.000 0.008 0.072 0.036 0.020
#> GSM252447     1  0.0551    0.60413 0.984 0.000 0.004 0.004 0.008 0.000
#> GSM252444     1  0.4250    0.42915 0.664 0.000 0.004 0.308 0.008 0.016
#> GSM252450     1  0.3608    0.53787 0.776 0.000 0.008 0.196 0.008 0.012
#> GSM252452     5  0.6542    0.08170 0.152 0.000 0.024 0.120 0.600 0.104
#> GSM252443     1  0.4668    0.49162 0.760 0.000 0.008 0.088 0.056 0.088
#> GSM252454     1  0.2415    0.60368 0.908 0.008 0.004 0.040 0.024 0.016
#> GSM252449     1  0.5365   -0.11523 0.492 0.000 0.056 0.432 0.016 0.004
#> GSM252445     1  0.3897    0.41961 0.684 0.000 0.008 0.300 0.000 0.008
#> GSM252453     1  0.5516    0.38998 0.600 0.000 0.004 0.296 0.052 0.048
#> GSM252464     3  0.4268    0.57708 0.020 0.000 0.756 0.180 0.016 0.028
#> GSM252463     3  0.8136   -0.00919 0.272 0.000 0.376 0.168 0.076 0.108
#> GSM252461     1  0.5718    0.43834 0.688 0.000 0.040 0.128 0.056 0.088
#> GSM252455     4  0.7001    0.48554 0.220 0.000 0.332 0.396 0.020 0.032
#> GSM252458     3  0.4756    0.56505 0.052 0.000 0.724 0.184 0.028 0.012
#> GSM252460     3  0.4871    0.47557 0.024 0.000 0.648 0.292 0.024 0.012
#> GSM252457     3  0.6894    0.30042 0.152 0.000 0.576 0.140 0.052 0.080
#> GSM252456     3  0.5299    0.01070 0.040 0.000 0.500 0.432 0.024 0.004
#> GSM252462     4  0.6234    0.56714 0.176 0.000 0.256 0.536 0.024 0.008
#> GSM252459     1  0.6096    0.31730 0.540 0.000 0.020 0.332 0.052 0.056
#> GSM252472     2  0.2558    0.83929 0.000 0.896 0.052 0.012 0.028 0.012
#> GSM252466     2  0.0777    0.87668 0.000 0.972 0.004 0.000 0.024 0.000
#> GSM252469     2  0.1116    0.87692 0.000 0.960 0.008 0.000 0.028 0.004
#> GSM252475     2  0.0458    0.87864 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM252471     2  0.0935    0.87462 0.000 0.964 0.004 0.000 0.032 0.000
#> GSM252465     2  0.4486    0.71698 0.000 0.772 0.020 0.108 0.076 0.024
#> GSM252474     5  0.3330    0.69770 0.000 0.284 0.000 0.000 0.716 0.000
#> GSM252473     2  0.0790    0.87320 0.000 0.968 0.000 0.000 0.032 0.000
#> GSM252468     2  0.0551    0.87902 0.000 0.984 0.004 0.000 0.008 0.004
#> GSM252470     2  0.1377    0.87204 0.004 0.952 0.024 0.004 0.016 0.000
#> GSM252467     2  0.1518    0.86181 0.000 0.944 0.000 0.024 0.024 0.008
#> GSM252485     2  0.2358    0.84441 0.000 0.908 0.044 0.016 0.020 0.012
#> GSM252481     2  0.0777    0.87764 0.000 0.972 0.004 0.000 0.024 0.000
#> GSM252480     2  0.0937    0.86998 0.000 0.960 0.000 0.000 0.040 0.000
#> GSM252479     2  0.0551    0.87902 0.000 0.984 0.004 0.000 0.008 0.004
#> GSM252482     5  0.3337    0.72337 0.004 0.260 0.000 0.000 0.736 0.000
#> GSM252478     2  0.7039    0.26719 0.000 0.492 0.020 0.268 0.132 0.088
#> GSM252483     5  0.3337    0.72337 0.004 0.260 0.000 0.000 0.736 0.000
#> GSM252477     5  0.3337    0.72337 0.004 0.260 0.000 0.000 0.736 0.000
#> GSM252484     2  0.0551    0.87902 0.000 0.984 0.004 0.000 0.008 0.004
#> GSM252476     2  0.2037    0.85560 0.000 0.924 0.008 0.028 0.028 0.012

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-kmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-CV-kmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-CV-kmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-CV-kmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-CV-kmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-CV-kmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-CV-kmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-CV-kmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-CV-kmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-CV-kmeans-membership-heatmap-5

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)

plot of chunk tab-CV-kmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-CV-kmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-CV-kmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-CV-kmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-CV-kmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-CV-kmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-CV-kmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-CV-kmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-CV-kmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-CV-kmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-kmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-CV-kmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-CV-kmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-CV-kmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-CV-kmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-CV-kmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-kmeans-collect-classes

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 agent(p) individual(p) k
#> CV:kmeans 55 1.31e-10         0.997 2
#> CV:kmeans 46 2.15e-15         0.999 3
#> CV:kmeans 51 6.03e-14         0.855 4
#> CV:kmeans 50 1.95e-13         0.562 5
#> CV:kmeans 39 2.77e-10         0.212 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.


CV:skmeans

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 51941 rows and 62 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 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)

plot of chunk CV-skmeans-collect-plots

The plots are:

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:

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)

plot of chunk CV-skmeans-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.517           0.810       0.903         0.5070 0.492   0.492
#> 3 3 0.246           0.516       0.707         0.3163 0.813   0.635
#> 4 4 0.286           0.180       0.509         0.1237 0.810   0.519
#> 5 5 0.361           0.291       0.543         0.0671 0.833   0.476
#> 6 6 0.453           0.297       0.500         0.0417 0.919   0.687

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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1  0.9996    -0.0778 0.512 0.488
#> GSM252429     2  0.8909     0.6266 0.308 0.692
#> GSM252424     2  0.8267     0.6885 0.260 0.740
#> GSM252432     2  0.9460     0.5056 0.364 0.636
#> GSM252427     2  0.9460     0.4912 0.364 0.636
#> GSM252431     2  0.7299     0.7646 0.204 0.796
#> GSM252430     2  0.6531     0.8031 0.168 0.832
#> GSM252433     2  0.6247     0.8183 0.156 0.844
#> GSM252426     2  0.9522     0.4882 0.372 0.628
#> GSM252428     2  0.9983     0.1545 0.476 0.524
#> GSM252425     2  0.5178     0.8381 0.116 0.884
#> GSM252440     1  0.2603     0.9016 0.956 0.044
#> GSM252441     1  0.1184     0.9007 0.984 0.016
#> GSM252436     1  0.0672     0.8985 0.992 0.008
#> GSM252435     1  0.2778     0.9020 0.952 0.048
#> GSM252442     1  0.2236     0.9026 0.964 0.036
#> GSM252439     1  0.8499     0.6629 0.724 0.276
#> GSM252438     1  0.9635     0.3819 0.612 0.388
#> GSM252434     1  0.0672     0.8988 0.992 0.008
#> GSM252437     1  0.2778     0.9020 0.952 0.048
#> GSM252451     1  0.0000     0.8956 1.000 0.000
#> GSM252448     1  0.2043     0.9021 0.968 0.032
#> GSM252447     1  0.2423     0.9027 0.960 0.040
#> GSM252444     1  0.0672     0.8984 0.992 0.008
#> GSM252450     1  0.1414     0.9018 0.980 0.020
#> GSM252452     1  0.5946     0.8370 0.856 0.144
#> GSM252443     1  0.6343     0.8207 0.840 0.160
#> GSM252454     1  0.9044     0.5570 0.680 0.320
#> GSM252449     1  0.0938     0.8999 0.988 0.012
#> GSM252445     1  0.3431     0.8985 0.936 0.064
#> GSM252453     1  0.7139     0.7755 0.804 0.196
#> GSM252464     1  0.3114     0.8972 0.944 0.056
#> GSM252463     1  0.0672     0.8989 0.992 0.008
#> GSM252461     1  0.0376     0.8963 0.996 0.004
#> GSM252455     1  0.0000     0.8956 1.000 0.000
#> GSM252458     1  0.3584     0.8913 0.932 0.068
#> GSM252460     1  0.2778     0.9025 0.952 0.048
#> GSM252457     1  0.5737     0.8398 0.864 0.136
#> GSM252456     1  0.2778     0.9003 0.952 0.048
#> GSM252462     1  0.3879     0.8896 0.924 0.076
#> GSM252459     1  0.4298     0.8808 0.912 0.088
#> GSM252472     2  0.1184     0.8890 0.016 0.984
#> GSM252466     2  0.0000     0.8885 0.000 1.000
#> GSM252469     2  0.0376     0.8886 0.004 0.996
#> GSM252475     2  0.0376     0.8890 0.004 0.996
#> GSM252471     2  0.0376     0.8888 0.004 0.996
#> GSM252465     2  0.1414     0.8881 0.020 0.980
#> GSM252474     2  0.0376     0.8882 0.004 0.996
#> GSM252473     2  0.2948     0.8777 0.052 0.948
#> GSM252468     2  0.0000     0.8885 0.000 1.000
#> GSM252470     2  0.5294     0.8384 0.120 0.880
#> GSM252467     2  0.0000     0.8885 0.000 1.000
#> GSM252485     2  0.3274     0.8755 0.060 0.940
#> GSM252481     2  0.0000     0.8885 0.000 1.000
#> GSM252480     2  0.0000     0.8885 0.000 1.000
#> GSM252479     2  0.0672     0.8887 0.008 0.992
#> GSM252482     2  0.1414     0.8881 0.020 0.980
#> GSM252478     2  0.1414     0.8886 0.020 0.980
#> GSM252483     2  0.1633     0.8872 0.024 0.976
#> GSM252477     2  0.0672     0.8887 0.008 0.992
#> GSM252484     2  0.0000     0.8885 0.000 1.000
#> GSM252476     2  0.0376     0.8886 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3   0.859     0.4450 0.216 0.180 0.604
#> GSM252429     3   0.930     0.4386 0.184 0.316 0.500
#> GSM252424     2   0.964    -0.3301 0.208 0.420 0.372
#> GSM252432     3   0.721     0.5076 0.100 0.192 0.708
#> GSM252427     3   0.879     0.4883 0.192 0.224 0.584
#> GSM252431     3   0.874     0.4479 0.124 0.340 0.536
#> GSM252430     3   0.791    -0.0736 0.056 0.448 0.496
#> GSM252433     3   0.855     0.2781 0.108 0.348 0.544
#> GSM252426     3   0.892     0.4981 0.172 0.268 0.560
#> GSM252428     3   0.916     0.4617 0.196 0.268 0.536
#> GSM252425     2   0.866     0.0896 0.116 0.536 0.348
#> GSM252440     1   0.455     0.6480 0.840 0.020 0.140
#> GSM252441     1   0.368     0.6567 0.892 0.028 0.080
#> GSM252436     1   0.335     0.6511 0.888 0.004 0.108
#> GSM252435     1   0.535     0.6533 0.804 0.036 0.160
#> GSM252442     1   0.687     0.5569 0.672 0.040 0.288
#> GSM252439     1   0.906     0.1840 0.520 0.156 0.324
#> GSM252438     3   0.971     0.1547 0.352 0.224 0.424
#> GSM252434     1   0.700     0.5647 0.672 0.048 0.280
#> GSM252437     1   0.615     0.6309 0.772 0.068 0.160
#> GSM252451     1   0.411     0.6585 0.844 0.004 0.152
#> GSM252448     1   0.555     0.6270 0.768 0.020 0.212
#> GSM252447     1   0.432     0.6528 0.860 0.028 0.112
#> GSM252444     1   0.423     0.6620 0.836 0.004 0.160
#> GSM252450     1   0.541     0.6572 0.804 0.040 0.156
#> GSM252452     1   0.821     0.2974 0.472 0.072 0.456
#> GSM252443     1   0.839     0.3665 0.560 0.100 0.340
#> GSM252454     1   0.905     0.2035 0.556 0.212 0.232
#> GSM252449     1   0.580     0.6271 0.760 0.028 0.212
#> GSM252445     1   0.486     0.6566 0.840 0.044 0.116
#> GSM252453     1   0.820     0.4906 0.624 0.124 0.252
#> GSM252464     3   0.728    -0.1343 0.404 0.032 0.564
#> GSM252463     1   0.619     0.4915 0.580 0.000 0.420
#> GSM252461     1   0.576     0.6159 0.716 0.008 0.276
#> GSM252455     1   0.579     0.5677 0.668 0.000 0.332
#> GSM252458     3   0.763    -0.1596 0.432 0.044 0.524
#> GSM252460     3   0.714    -0.0829 0.396 0.028 0.576
#> GSM252457     1   0.821     0.3030 0.476 0.072 0.452
#> GSM252456     1   0.758     0.2709 0.496 0.040 0.464
#> GSM252462     1   0.733     0.3921 0.544 0.032 0.424
#> GSM252459     1   0.835     0.4415 0.568 0.100 0.332
#> GSM252472     2   0.434     0.7766 0.024 0.856 0.120
#> GSM252466     2   0.210     0.7914 0.004 0.944 0.052
#> GSM252469     2   0.199     0.7912 0.004 0.948 0.048
#> GSM252475     2   0.447     0.7771 0.028 0.852 0.120
#> GSM252471     2   0.468     0.7724 0.020 0.832 0.148
#> GSM252465     2   0.499     0.7360 0.024 0.816 0.160
#> GSM252474     2   0.392     0.7671 0.004 0.856 0.140
#> GSM252473     2   0.464     0.7735 0.036 0.848 0.116
#> GSM252468     2   0.329     0.7858 0.008 0.896 0.096
#> GSM252470     2   0.833     0.3824 0.164 0.628 0.208
#> GSM252467     2   0.223     0.7902 0.012 0.944 0.044
#> GSM252485     2   0.599     0.6968 0.056 0.776 0.168
#> GSM252481     2   0.258     0.7912 0.008 0.928 0.064
#> GSM252480     2   0.290     0.7928 0.016 0.920 0.064
#> GSM252479     2   0.305     0.7888 0.020 0.916 0.064
#> GSM252482     2   0.570     0.6658 0.012 0.736 0.252
#> GSM252478     2   0.615     0.6730 0.044 0.752 0.204
#> GSM252483     2   0.618     0.6502 0.024 0.716 0.260
#> GSM252477     2   0.598     0.6686 0.020 0.728 0.252
#> GSM252484     2   0.238     0.7916 0.008 0.936 0.056
#> GSM252476     2   0.245     0.7891 0.000 0.924 0.076

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3   0.783   0.387003 0.080 0.088 0.572 0.260
#> GSM252429     3   0.983   0.262671 0.176 0.236 0.328 0.260
#> GSM252424     4   0.946  -0.238023 0.160 0.152 0.312 0.376
#> GSM252432     3   0.780   0.414290 0.048 0.136 0.572 0.244
#> GSM252427     3   0.892   0.368827 0.104 0.140 0.440 0.316
#> GSM252431     4   0.921  -0.250503 0.096 0.192 0.348 0.364
#> GSM252430     2   0.789   0.148026 0.080 0.600 0.144 0.176
#> GSM252433     2   0.855   0.033822 0.080 0.520 0.184 0.216
#> GSM252426     3   0.801   0.352459 0.064 0.100 0.520 0.316
#> GSM252428     3   0.834   0.312951 0.076 0.112 0.488 0.324
#> GSM252425     4   0.888   0.139555 0.096 0.176 0.252 0.476
#> GSM252440     1   0.716   0.429536 0.660 0.068 0.168 0.104
#> GSM252441     1   0.425   0.512156 0.844 0.028 0.084 0.044
#> GSM252436     1   0.490   0.498859 0.760 0.004 0.196 0.040
#> GSM252435     1   0.642   0.457582 0.688 0.028 0.196 0.088
#> GSM252442     1   0.787   0.205581 0.444 0.032 0.404 0.120
#> GSM252439     1   0.944   0.069974 0.384 0.304 0.156 0.156
#> GSM252438     3   0.991   0.136564 0.196 0.288 0.288 0.228
#> GSM252434     1   0.830   0.216210 0.436 0.052 0.380 0.132
#> GSM252437     1   0.746   0.426468 0.624 0.056 0.196 0.124
#> GSM252451     1   0.573   0.475943 0.708 0.012 0.224 0.056
#> GSM252448     1   0.633   0.456042 0.720 0.068 0.148 0.064
#> GSM252447     1   0.558   0.506030 0.776 0.056 0.092 0.076
#> GSM252444     1   0.597   0.483017 0.696 0.012 0.220 0.072
#> GSM252450     1   0.644   0.462526 0.664 0.024 0.240 0.072
#> GSM252452     2   0.933  -0.382925 0.304 0.360 0.244 0.092
#> GSM252443     1   0.921   0.191298 0.460 0.208 0.188 0.144
#> GSM252454     1   0.910   0.200060 0.480 0.196 0.156 0.168
#> GSM252449     1   0.713   0.361948 0.568 0.020 0.316 0.096
#> GSM252445     1   0.653   0.448865 0.664 0.012 0.200 0.124
#> GSM252453     1   0.851   0.232755 0.496 0.056 0.224 0.224
#> GSM252464     3   0.804   0.220394 0.228 0.084 0.572 0.116
#> GSM252463     3   0.766  -0.153915 0.428 0.044 0.448 0.080
#> GSM252461     1   0.720   0.392357 0.576 0.024 0.300 0.100
#> GSM252455     1   0.743   0.198161 0.464 0.024 0.420 0.092
#> GSM252458     3   0.790   0.030969 0.328 0.044 0.512 0.116
#> GSM252460     3   0.698   0.254850 0.200 0.032 0.648 0.120
#> GSM252457     3   0.945   0.000401 0.336 0.124 0.348 0.192
#> GSM252456     3   0.666   0.083134 0.296 0.016 0.612 0.076
#> GSM252462     3   0.796  -0.062873 0.376 0.048 0.472 0.104
#> GSM252459     1   0.804   0.208081 0.448 0.020 0.352 0.180
#> GSM252472     2   0.730  -0.019173 0.028 0.484 0.076 0.412
#> GSM252466     2   0.580  -0.052129 0.008 0.516 0.016 0.460
#> GSM252469     2   0.599  -0.084954 0.008 0.500 0.024 0.468
#> GSM252475     2   0.628   0.065246 0.012 0.588 0.044 0.356
#> GSM252471     2   0.622   0.140131 0.020 0.640 0.044 0.296
#> GSM252465     4   0.686   0.130595 0.016 0.380 0.068 0.536
#> GSM252474     2   0.433   0.253757 0.004 0.808 0.036 0.152
#> GSM252473     2   0.727   0.064752 0.060 0.556 0.048 0.336
#> GSM252468     4   0.630   0.031523 0.008 0.464 0.040 0.488
#> GSM252470     4   0.859   0.161717 0.104 0.324 0.104 0.468
#> GSM252467     4   0.560   0.015533 0.000 0.464 0.020 0.516
#> GSM252485     4   0.788   0.041343 0.032 0.416 0.120 0.432
#> GSM252481     2   0.655   0.026704 0.020 0.560 0.044 0.376
#> GSM252480     2   0.582   0.064067 0.008 0.592 0.024 0.376
#> GSM252479     4   0.689   0.092989 0.016 0.436 0.064 0.484
#> GSM252482     2   0.465   0.267999 0.028 0.816 0.040 0.116
#> GSM252478     2   0.805  -0.054108 0.036 0.420 0.132 0.412
#> GSM252483     2   0.357   0.282641 0.028 0.864 0.008 0.100
#> GSM252477     2   0.370   0.283129 0.028 0.872 0.032 0.068
#> GSM252484     2   0.633  -0.103550 0.012 0.508 0.036 0.444
#> GSM252476     4   0.609   0.069851 0.012 0.452 0.024 0.512

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3   0.762    0.28360 0.044 0.084 0.576 0.164 0.132
#> GSM252429     3   0.943    0.20020 0.140 0.108 0.356 0.160 0.236
#> GSM252424     3   0.889    0.25800 0.060 0.228 0.416 0.176 0.120
#> GSM252432     3   0.759    0.30527 0.048 0.060 0.556 0.112 0.224
#> GSM252427     3   0.877    0.18097 0.072 0.100 0.408 0.288 0.132
#> GSM252431     3   0.896    0.30491 0.044 0.172 0.392 0.168 0.224
#> GSM252430     5   0.653    0.42171 0.036 0.108 0.128 0.056 0.672
#> GSM252433     5   0.723    0.36763 0.040 0.116 0.144 0.084 0.616
#> GSM252426     3   0.768    0.31035 0.060 0.108 0.584 0.148 0.100
#> GSM252428     3   0.797    0.26541 0.040 0.124 0.536 0.184 0.116
#> GSM252425     2   0.850   -0.01372 0.032 0.360 0.356 0.128 0.124
#> GSM252440     1   0.573    0.31729 0.696 0.028 0.040 0.200 0.036
#> GSM252441     1   0.364    0.40088 0.852 0.012 0.032 0.084 0.020
#> GSM252436     1   0.470    0.34594 0.708 0.000 0.040 0.244 0.008
#> GSM252435     1   0.692    0.26182 0.596 0.028 0.080 0.240 0.056
#> GSM252442     1   0.810   -0.06924 0.360 0.040 0.288 0.288 0.024
#> GSM252439     5   0.817    0.06474 0.324 0.032 0.060 0.176 0.408
#> GSM252438     5   0.937   -0.00155 0.172 0.096 0.140 0.228 0.364
#> GSM252434     1   0.799    0.03110 0.388 0.020 0.196 0.344 0.052
#> GSM252437     1   0.720    0.26265 0.596 0.072 0.056 0.216 0.060
#> GSM252451     1   0.546    0.28983 0.624 0.000 0.060 0.304 0.012
#> GSM252448     1   0.634    0.29933 0.656 0.008 0.052 0.164 0.120
#> GSM252447     1   0.366    0.40175 0.852 0.016 0.024 0.084 0.024
#> GSM252444     1   0.619    0.28275 0.588 0.004 0.048 0.308 0.052
#> GSM252450     1   0.678    0.30976 0.608 0.020 0.068 0.232 0.072
#> GSM252452     5   0.829    0.10453 0.196 0.028 0.124 0.172 0.480
#> GSM252443     1   0.848    0.03001 0.416 0.036 0.080 0.212 0.256
#> GSM252454     1   0.929    0.02387 0.348 0.096 0.104 0.256 0.196
#> GSM252449     1   0.710    0.14215 0.472 0.008 0.148 0.344 0.028
#> GSM252445     1   0.655    0.32475 0.632 0.028 0.080 0.220 0.040
#> GSM252453     1   0.858    0.05781 0.412 0.108 0.144 0.292 0.044
#> GSM252464     4   0.781    0.12901 0.136 0.004 0.352 0.408 0.100
#> GSM252463     4   0.818    0.15278 0.324 0.004 0.216 0.356 0.100
#> GSM252461     1   0.723    0.05035 0.484 0.008 0.136 0.328 0.044
#> GSM252455     4   0.723    0.02642 0.384 0.008 0.132 0.436 0.040
#> GSM252458     4   0.843    0.21121 0.248 0.028 0.272 0.380 0.072
#> GSM252460     3   0.746   -0.05260 0.128 0.008 0.480 0.316 0.068
#> GSM252457     3   0.931   -0.02845 0.224 0.040 0.252 0.240 0.244
#> GSM252456     4   0.789    0.18381 0.152 0.040 0.300 0.464 0.044
#> GSM252462     4   0.783    0.12890 0.280 0.012 0.160 0.468 0.080
#> GSM252459     4   0.871    0.09387 0.272 0.068 0.200 0.396 0.064
#> GSM252472     2   0.772    0.40976 0.016 0.492 0.172 0.064 0.256
#> GSM252466     2   0.367    0.62608 0.008 0.848 0.064 0.012 0.068
#> GSM252469     2   0.400    0.63717 0.004 0.824 0.064 0.016 0.092
#> GSM252475     2   0.680    0.49916 0.020 0.596 0.128 0.032 0.224
#> GSM252471     2   0.686    0.44151 0.012 0.588 0.096 0.060 0.244
#> GSM252465     2   0.680    0.51688 0.020 0.612 0.164 0.036 0.168
#> GSM252474     5   0.555    0.15445 0.008 0.416 0.016 0.024 0.536
#> GSM252473     2   0.741    0.45257 0.028 0.564 0.128 0.064 0.216
#> GSM252468     2   0.497    0.62416 0.008 0.760 0.120 0.020 0.092
#> GSM252470     2   0.844    0.37181 0.088 0.508 0.144 0.096 0.164
#> GSM252467     2   0.418    0.63051 0.000 0.812 0.060 0.032 0.096
#> GSM252485     2   0.785    0.42323 0.024 0.520 0.180 0.084 0.192
#> GSM252481     2   0.506    0.60775 0.020 0.764 0.052 0.032 0.132
#> GSM252480     2   0.462    0.58748 0.012 0.764 0.028 0.020 0.176
#> GSM252479     2   0.550    0.61713 0.008 0.732 0.112 0.044 0.104
#> GSM252482     5   0.519    0.44461 0.004 0.228 0.024 0.044 0.700
#> GSM252478     2   0.791    0.31149 0.020 0.460 0.164 0.068 0.288
#> GSM252483     5   0.499    0.39209 0.012 0.304 0.024 0.004 0.656
#> GSM252477     5   0.545    0.40425 0.008 0.272 0.028 0.032 0.660
#> GSM252484     2   0.476    0.62091 0.020 0.792 0.092 0.028 0.068
#> GSM252476     2   0.450    0.62815 0.004 0.804 0.072 0.052 0.068

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3   0.784     0.2846 0.056 0.044 0.496 0.140 0.052 0.212
#> GSM252429     3   0.936     0.0296 0.084 0.096 0.304 0.252 0.136 0.128
#> GSM252424     3   0.947     0.1615 0.084 0.156 0.292 0.148 0.092 0.228
#> GSM252432     3   0.664     0.3449 0.008 0.032 0.612 0.084 0.116 0.148
#> GSM252427     3   0.821     0.2864 0.056 0.052 0.488 0.136 0.112 0.156
#> GSM252431     3   0.865     0.2393 0.020 0.116 0.352 0.092 0.144 0.276
#> GSM252430     5   0.619     0.4656 0.036 0.044 0.092 0.092 0.684 0.052
#> GSM252433     5   0.698     0.4211 0.028 0.028 0.104 0.128 0.600 0.112
#> GSM252426     3   0.782     0.3447 0.052 0.076 0.516 0.088 0.060 0.208
#> GSM252428     3   0.788     0.3468 0.080 0.092 0.520 0.068 0.052 0.188
#> GSM252425     2   0.823     0.2335 0.052 0.384 0.164 0.064 0.036 0.300
#> GSM252440     1   0.630     0.0383 0.512 0.012 0.036 0.364 0.048 0.028
#> GSM252441     1   0.501     0.2801 0.720 0.004 0.016 0.152 0.016 0.092
#> GSM252436     1   0.500     0.3222 0.744 0.000 0.092 0.088 0.024 0.052
#> GSM252435     1   0.794     0.1397 0.464 0.028 0.096 0.252 0.052 0.108
#> GSM252442     3   0.816     0.0108 0.288 0.020 0.376 0.132 0.028 0.156
#> GSM252439     5   0.792    -0.0912 0.200 0.016 0.044 0.324 0.360 0.056
#> GSM252438     5   0.821     0.0636 0.076 0.052 0.076 0.360 0.364 0.072
#> GSM252434     1   0.771     0.1283 0.396 0.008 0.316 0.152 0.024 0.104
#> GSM252437     1   0.726     0.2341 0.568 0.060 0.084 0.184 0.024 0.080
#> GSM252451     1   0.630     0.2889 0.632 0.008 0.148 0.132 0.024 0.056
#> GSM252448     1   0.661     0.0749 0.564 0.008 0.040 0.264 0.072 0.052
#> GSM252447     1   0.573     0.2375 0.688 0.024 0.032 0.172 0.044 0.040
#> GSM252444     1   0.689     0.2122 0.588 0.008 0.112 0.172 0.052 0.068
#> GSM252450     1   0.636     0.2876 0.632 0.012 0.120 0.160 0.036 0.040
#> GSM252452     5   0.809     0.1032 0.144 0.004 0.132 0.196 0.444 0.080
#> GSM252443     4   0.843     0.2195 0.272 0.016 0.084 0.352 0.204 0.072
#> GSM252454     1   0.904     0.0466 0.360 0.064 0.064 0.188 0.140 0.184
#> GSM252449     1   0.758     0.2652 0.500 0.028 0.212 0.144 0.020 0.096
#> GSM252445     1   0.770     0.2471 0.524 0.040 0.148 0.156 0.032 0.100
#> GSM252453     1   0.852     0.1205 0.372 0.096 0.060 0.196 0.028 0.248
#> GSM252464     3   0.767     0.1935 0.136 0.012 0.508 0.184 0.052 0.108
#> GSM252463     4   0.749     0.3066 0.188 0.008 0.244 0.464 0.060 0.036
#> GSM252461     4   0.739     0.0616 0.368 0.012 0.108 0.412 0.040 0.060
#> GSM252455     1   0.766    -0.0421 0.340 0.008 0.284 0.288 0.024 0.056
#> GSM252458     3   0.787     0.0970 0.184 0.024 0.436 0.252 0.032 0.072
#> GSM252460     3   0.658     0.3138 0.112 0.020 0.632 0.104 0.024 0.108
#> GSM252457     4   0.826     0.2276 0.132 0.020 0.168 0.464 0.124 0.092
#> GSM252456     3   0.675     0.2637 0.160 0.008 0.588 0.152 0.032 0.060
#> GSM252462     3   0.800    -0.0516 0.320 0.012 0.348 0.208 0.048 0.064
#> GSM252459     1   0.902    -0.0344 0.292 0.048 0.164 0.244 0.048 0.204
#> GSM252472     2   0.731     0.4776 0.008 0.504 0.056 0.048 0.140 0.244
#> GSM252466     2   0.527     0.5900 0.004 0.728 0.028 0.044 0.108 0.088
#> GSM252469     2   0.408     0.6228 0.004 0.808 0.020 0.020 0.056 0.092
#> GSM252475     2   0.654     0.5311 0.008 0.576 0.032 0.024 0.160 0.200
#> GSM252471     2   0.691     0.4334 0.028 0.536 0.028 0.020 0.240 0.148
#> GSM252465     2   0.648     0.5463 0.012 0.564 0.056 0.012 0.092 0.264
#> GSM252474     5   0.604     0.1018 0.008 0.364 0.024 0.036 0.528 0.040
#> GSM252473     2   0.765     0.4166 0.024 0.480 0.032 0.064 0.204 0.196
#> GSM252468     2   0.577     0.5992 0.004 0.656 0.040 0.024 0.076 0.200
#> GSM252470     2   0.814     0.4301 0.088 0.504 0.100 0.052 0.092 0.164
#> GSM252467     2   0.504     0.6150 0.004 0.692 0.004 0.024 0.072 0.204
#> GSM252485     2   0.731     0.4957 0.020 0.516 0.040 0.060 0.112 0.252
#> GSM252481     2   0.547     0.5943 0.024 0.720 0.012 0.048 0.104 0.092
#> GSM252480     2   0.494     0.5914 0.016 0.752 0.024 0.040 0.132 0.036
#> GSM252479     2   0.537     0.6121 0.012 0.708 0.020 0.032 0.068 0.160
#> GSM252482     5   0.450     0.5005 0.004 0.164 0.020 0.020 0.756 0.036
#> GSM252478     2   0.794     0.3254 0.012 0.384 0.072 0.044 0.188 0.300
#> GSM252483     5   0.480     0.5030 0.004 0.152 0.016 0.044 0.744 0.040
#> GSM252477     5   0.432     0.5045 0.008 0.124 0.020 0.028 0.788 0.032
#> GSM252484     2   0.542     0.6100 0.008 0.708 0.028 0.032 0.076 0.148
#> GSM252476     2   0.523     0.6072 0.008 0.692 0.040 0.032 0.020 0.208

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-skmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-CV-skmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-CV-skmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-CV-skmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-CV-skmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-CV-skmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-CV-skmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-CV-skmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-CV-skmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-CV-skmeans-membership-heatmap-5

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)

plot of chunk tab-CV-skmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-CV-skmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-CV-skmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-CV-skmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-CV-skmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-CV-skmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-CV-skmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-CV-skmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-CV-skmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-CV-skmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-skmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-CV-skmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-CV-skmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-CV-skmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-CV-skmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-CV-skmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-skmeans-collect-classes

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 agent(p) individual(p) k
#> CV:skmeans 57 5.06e-11        0.9896 2
#> CV:skmeans 37 7.45e-12        0.8203 3
#> CV:skmeans  2       NA            NA 4
#> CV:skmeans 10       NA            NA 5
#> CV:skmeans 14 3.01e-01        0.0818 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.


CV:pam

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 51941 rows and 62 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 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)

plot of chunk CV-pam-collect-plots

The plots are:

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:

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)

plot of chunk CV-pam-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.220           0.781       0.856         0.4753 0.497   0.497
#> 3 3 0.242           0.712       0.797         0.3111 0.877   0.756
#> 4 4 0.446           0.583       0.763         0.1615 0.833   0.595
#> 5 5 0.514           0.510       0.740         0.0460 0.938   0.789
#> 6 6 0.549           0.527       0.747         0.0461 0.911   0.681

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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     2  0.8081      0.621 0.248 0.752
#> GSM252429     2  0.3114      0.862 0.056 0.944
#> GSM252424     2  0.2603      0.874 0.044 0.956
#> GSM252432     2  0.5519      0.807 0.128 0.872
#> GSM252427     2  0.6048      0.784 0.148 0.852
#> GSM252431     2  0.4431      0.843 0.092 0.908
#> GSM252430     2  0.4562      0.846 0.096 0.904
#> GSM252433     2  0.8207      0.682 0.256 0.744
#> GSM252426     2  0.9580      0.227 0.380 0.620
#> GSM252428     2  0.8813      0.496 0.300 0.700
#> GSM252425     2  0.6438      0.740 0.164 0.836
#> GSM252440     1  0.8443      0.754 0.728 0.272
#> GSM252441     1  0.6148      0.829 0.848 0.152
#> GSM252436     1  0.4298      0.815 0.912 0.088
#> GSM252435     1  0.5737      0.829 0.864 0.136
#> GSM252442     1  0.7950      0.794 0.760 0.240
#> GSM252439     1  0.9170      0.593 0.668 0.332
#> GSM252438     2  0.9044      0.481 0.320 0.680
#> GSM252434     1  0.6438      0.826 0.836 0.164
#> GSM252437     1  0.7376      0.821 0.792 0.208
#> GSM252451     1  0.3114      0.801 0.944 0.056
#> GSM252448     1  0.8443      0.746 0.728 0.272
#> GSM252447     1  0.5519      0.827 0.872 0.128
#> GSM252444     1  0.6247      0.830 0.844 0.156
#> GSM252450     1  0.8016      0.802 0.756 0.244
#> GSM252452     1  0.8144      0.720 0.748 0.252
#> GSM252443     1  0.9460      0.630 0.636 0.364
#> GSM252454     2  0.9522      0.315 0.372 0.628
#> GSM252449     1  0.6887      0.822 0.816 0.184
#> GSM252445     1  0.4562      0.818 0.904 0.096
#> GSM252453     1  0.6973      0.823 0.812 0.188
#> GSM252464     1  0.9087      0.717 0.676 0.324
#> GSM252463     1  0.9209      0.667 0.664 0.336
#> GSM252461     1  0.3584      0.809 0.932 0.068
#> GSM252455     1  0.8081      0.793 0.752 0.248
#> GSM252458     1  0.8207      0.791 0.744 0.256
#> GSM252460     1  0.8144      0.787 0.748 0.252
#> GSM252457     1  0.5178      0.828 0.884 0.116
#> GSM252456     1  0.8267      0.770 0.740 0.260
#> GSM252462     1  0.4431      0.818 0.908 0.092
#> GSM252459     1  0.9850      0.476 0.572 0.428
#> GSM252472     2  0.1414      0.879 0.020 0.980
#> GSM252466     2  0.0376      0.882 0.004 0.996
#> GSM252469     2  0.0376      0.882 0.004 0.996
#> GSM252475     2  0.0938      0.882 0.012 0.988
#> GSM252471     2  0.2603      0.869 0.044 0.956
#> GSM252465     2  0.0672      0.882 0.008 0.992
#> GSM252474     2  0.2948      0.850 0.052 0.948
#> GSM252473     2  0.0376      0.882 0.004 0.996
#> GSM252468     2  0.0672      0.882 0.008 0.992
#> GSM252470     2  0.5059      0.816 0.112 0.888
#> GSM252467     2  0.0000      0.881 0.000 1.000
#> GSM252485     2  0.0672      0.882 0.008 0.992
#> GSM252481     2  0.0376      0.882 0.004 0.996
#> GSM252480     2  0.0376      0.882 0.004 0.996
#> GSM252479     2  0.0376      0.882 0.004 0.996
#> GSM252482     2  0.3114      0.851 0.056 0.944
#> GSM252478     2  0.2043      0.876 0.032 0.968
#> GSM252483     2  0.2948      0.850 0.052 0.948
#> GSM252477     2  0.3274      0.850 0.060 0.940
#> GSM252484     2  0.0376      0.882 0.004 0.996
#> GSM252476     2  0.0376      0.882 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     2  0.6990     0.6711 0.164 0.728 0.108
#> GSM252429     2  0.4453     0.8146 0.012 0.836 0.152
#> GSM252424     2  0.3678     0.8128 0.028 0.892 0.080
#> GSM252432     2  0.5047     0.7793 0.036 0.824 0.140
#> GSM252427     2  0.6880     0.7178 0.108 0.736 0.156
#> GSM252431     2  0.4914     0.7900 0.068 0.844 0.088
#> GSM252430     3  0.2878     0.8485 0.000 0.096 0.904
#> GSM252433     3  0.3551     0.8152 0.000 0.132 0.868
#> GSM252426     2  0.8091     0.2118 0.348 0.572 0.080
#> GSM252428     2  0.8153     0.4972 0.240 0.632 0.128
#> GSM252425     2  0.4891     0.7746 0.124 0.836 0.040
#> GSM252440     1  0.7724     0.6394 0.680 0.156 0.164
#> GSM252441     1  0.5020     0.7501 0.836 0.108 0.056
#> GSM252436     1  0.2903     0.7445 0.924 0.048 0.028
#> GSM252435     1  0.6250     0.7051 0.776 0.104 0.120
#> GSM252442     1  0.6526     0.6514 0.704 0.260 0.036
#> GSM252439     3  0.8113     0.3324 0.312 0.092 0.596
#> GSM252438     2  0.9224     0.0489 0.152 0.440 0.408
#> GSM252434     1  0.5974     0.7448 0.784 0.148 0.068
#> GSM252437     1  0.5435     0.7626 0.808 0.144 0.048
#> GSM252451     1  0.1337     0.7318 0.972 0.012 0.016
#> GSM252448     1  0.8246     0.5591 0.632 0.148 0.220
#> GSM252447     1  0.3589     0.7459 0.900 0.052 0.048
#> GSM252444     1  0.4059     0.7659 0.860 0.128 0.012
#> GSM252450     1  0.5435     0.7505 0.784 0.192 0.024
#> GSM252452     3  0.4821     0.7464 0.120 0.040 0.840
#> GSM252443     1  0.9100     0.5069 0.548 0.248 0.204
#> GSM252454     2  0.8126     0.2089 0.356 0.564 0.080
#> GSM252449     1  0.5346     0.7518 0.808 0.152 0.040
#> GSM252445     1  0.3009     0.7413 0.920 0.028 0.052
#> GSM252453     1  0.5384     0.7388 0.788 0.188 0.024
#> GSM252464     1  0.6688     0.6155 0.664 0.308 0.028
#> GSM252463     1  0.8125     0.6725 0.648 0.180 0.172
#> GSM252461     1  0.2772     0.7326 0.916 0.004 0.080
#> GSM252455     1  0.6968     0.7258 0.716 0.204 0.080
#> GSM252458     1  0.7963     0.6760 0.660 0.188 0.152
#> GSM252460     1  0.6758     0.7121 0.728 0.200 0.072
#> GSM252457     1  0.5863     0.7463 0.796 0.084 0.120
#> GSM252456     1  0.7489     0.6228 0.664 0.256 0.080
#> GSM252462     1  0.3028     0.7406 0.920 0.032 0.048
#> GSM252459     1  0.8268     0.2171 0.484 0.440 0.076
#> GSM252472     2  0.1315     0.8311 0.008 0.972 0.020
#> GSM252466     2  0.3116     0.8134 0.000 0.892 0.108
#> GSM252469     2  0.2356     0.8225 0.000 0.928 0.072
#> GSM252475     2  0.2261     0.8235 0.000 0.932 0.068
#> GSM252471     2  0.4475     0.7952 0.016 0.840 0.144
#> GSM252465     2  0.1411     0.8320 0.000 0.964 0.036
#> GSM252474     3  0.3816     0.8576 0.000 0.148 0.852
#> GSM252473     2  0.1289     0.8296 0.000 0.968 0.032
#> GSM252468     2  0.1289     0.8288 0.000 0.968 0.032
#> GSM252470     2  0.6091     0.7557 0.124 0.784 0.092
#> GSM252467     2  0.0892     0.8295 0.000 0.980 0.020
#> GSM252485     2  0.1860     0.8349 0.000 0.948 0.052
#> GSM252481     2  0.3267     0.8154 0.000 0.884 0.116
#> GSM252480     2  0.3116     0.8119 0.000 0.892 0.108
#> GSM252479     2  0.0747     0.8301 0.000 0.984 0.016
#> GSM252482     3  0.3879     0.8601 0.000 0.152 0.848
#> GSM252478     2  0.4968     0.7491 0.012 0.800 0.188
#> GSM252483     3  0.4235     0.8554 0.000 0.176 0.824
#> GSM252477     3  0.3918     0.8629 0.004 0.140 0.856
#> GSM252484     2  0.1129     0.8327 0.004 0.976 0.020
#> GSM252476     2  0.1529     0.8280 0.000 0.960 0.040

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     2  0.6166   0.471701 0.012 0.584 0.368 0.036
#> GSM252429     2  0.6384   0.716156 0.024 0.700 0.148 0.128
#> GSM252424     2  0.6015   0.584725 0.028 0.668 0.272 0.032
#> GSM252432     2  0.6222   0.368806 0.000 0.532 0.412 0.056
#> GSM252427     2  0.6897   0.385141 0.012 0.520 0.392 0.076
#> GSM252431     2  0.5941   0.461250 0.004 0.584 0.376 0.036
#> GSM252430     4  0.0657   0.797474 0.000 0.012 0.004 0.984
#> GSM252433     4  0.3107   0.750953 0.000 0.080 0.036 0.884
#> GSM252426     3  0.5343   0.367534 0.000 0.316 0.656 0.028
#> GSM252428     3  0.7257  -0.001114 0.032 0.372 0.524 0.072
#> GSM252425     2  0.5349   0.692082 0.032 0.744 0.200 0.024
#> GSM252440     1  0.3902   0.676926 0.860 0.036 0.080 0.024
#> GSM252441     1  0.1892   0.681691 0.944 0.016 0.036 0.004
#> GSM252436     1  0.4284   0.604370 0.764 0.012 0.224 0.000
#> GSM252435     1  0.4254   0.678876 0.840 0.024 0.096 0.040
#> GSM252442     3  0.5021   0.578690 0.100 0.116 0.780 0.004
#> GSM252439     4  0.7752  -0.004630 0.432 0.072 0.056 0.440
#> GSM252438     4  0.8778   0.087685 0.056 0.344 0.200 0.400
#> GSM252434     3  0.5246   0.582965 0.148 0.088 0.760 0.004
#> GSM252437     1  0.7089   0.038161 0.460 0.096 0.436 0.008
#> GSM252451     3  0.4941   0.000642 0.436 0.000 0.564 0.000
#> GSM252448     1  0.2634   0.678442 0.920 0.020 0.032 0.028
#> GSM252447     1  0.1970   0.679082 0.932 0.008 0.060 0.000
#> GSM252444     1  0.5228   0.551018 0.696 0.036 0.268 0.000
#> GSM252450     1  0.5257   0.631174 0.752 0.104 0.144 0.000
#> GSM252452     4  0.3726   0.722877 0.040 0.008 0.092 0.860
#> GSM252443     1  0.8956   0.278917 0.488 0.144 0.228 0.140
#> GSM252454     1  0.6670   0.394421 0.608 0.288 0.096 0.008
#> GSM252449     3  0.5647   0.548452 0.164 0.116 0.720 0.000
#> GSM252445     1  0.5531   0.190401 0.548 0.004 0.436 0.012
#> GSM252453     1  0.4679   0.646854 0.772 0.044 0.184 0.000
#> GSM252464     3  0.5585   0.552250 0.084 0.204 0.712 0.000
#> GSM252463     3  0.7761   0.258985 0.352 0.068 0.512 0.068
#> GSM252461     1  0.3856   0.670038 0.832 0.000 0.136 0.032
#> GSM252455     3  0.6179   0.585959 0.148 0.128 0.708 0.016
#> GSM252458     3  0.6052   0.597063 0.100 0.080 0.748 0.072
#> GSM252460     3  0.2392   0.620240 0.036 0.024 0.928 0.012
#> GSM252457     3  0.6580   0.090917 0.424 0.020 0.516 0.040
#> GSM252456     3  0.2422   0.620330 0.028 0.028 0.928 0.016
#> GSM252462     3  0.3495   0.574609 0.140 0.016 0.844 0.000
#> GSM252459     1  0.7107   0.296036 0.528 0.344 0.124 0.004
#> GSM252472     2  0.1284   0.802241 0.000 0.964 0.012 0.024
#> GSM252466     2  0.3171   0.791971 0.016 0.876 0.004 0.104
#> GSM252469     2  0.2311   0.800634 0.004 0.916 0.004 0.076
#> GSM252475     2  0.2089   0.800108 0.000 0.932 0.020 0.048
#> GSM252471     2  0.4074   0.749680 0.008 0.792 0.004 0.196
#> GSM252465     2  0.2954   0.795144 0.008 0.900 0.064 0.028
#> GSM252474     4  0.1389   0.795115 0.000 0.048 0.000 0.952
#> GSM252473     2  0.1211   0.808186 0.000 0.960 0.000 0.040
#> GSM252468     2  0.1629   0.800933 0.000 0.952 0.024 0.024
#> GSM252470     2  0.7162   0.613731 0.088 0.648 0.200 0.064
#> GSM252467     2  0.0707   0.807058 0.000 0.980 0.000 0.020
#> GSM252485     2  0.2660   0.807997 0.012 0.916 0.024 0.048
#> GSM252481     2  0.3684   0.784949 0.020 0.844 0.004 0.132
#> GSM252480     2  0.3340   0.778386 0.004 0.848 0.004 0.144
#> GSM252479     2  0.1004   0.806041 0.000 0.972 0.004 0.024
#> GSM252482     4  0.1211   0.801338 0.000 0.040 0.000 0.960
#> GSM252478     2  0.5205   0.698539 0.020 0.740 0.024 0.216
#> GSM252483     4  0.1867   0.794097 0.000 0.072 0.000 0.928
#> GSM252477     4  0.1118   0.800533 0.000 0.036 0.000 0.964
#> GSM252484     2  0.1004   0.806493 0.000 0.972 0.004 0.024
#> GSM252476     2  0.1732   0.808383 0.008 0.948 0.004 0.040

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     2  0.6741    0.17187 0.004 0.488 0.220 0.284 0.004
#> GSM252429     2  0.5944    0.59879 0.000 0.660 0.080 0.208 0.052
#> GSM252424     2  0.6179    0.31378 0.016 0.584 0.124 0.276 0.000
#> GSM252432     2  0.7170   -0.12261 0.000 0.412 0.248 0.320 0.020
#> GSM252427     2  0.6949    0.00917 0.000 0.440 0.204 0.340 0.016
#> GSM252431     2  0.6909    0.04154 0.000 0.472 0.216 0.296 0.016
#> GSM252430     5  0.0290    0.92358 0.000 0.000 0.000 0.008 0.992
#> GSM252433     5  0.3216    0.81034 0.000 0.044 0.004 0.096 0.856
#> GSM252426     3  0.6598   -0.04837 0.000 0.232 0.452 0.316 0.000
#> GSM252428     4  0.7622   -0.23274 0.016 0.324 0.308 0.336 0.016
#> GSM252425     2  0.5308    0.58081 0.012 0.704 0.148 0.136 0.000
#> GSM252440     1  0.2095    0.65419 0.920 0.012 0.060 0.008 0.000
#> GSM252441     1  0.0833    0.65328 0.976 0.004 0.016 0.004 0.000
#> GSM252436     1  0.3835    0.52427 0.732 0.008 0.260 0.000 0.000
#> GSM252435     1  0.3328    0.63975 0.844 0.004 0.124 0.004 0.024
#> GSM252442     3  0.2369    0.59897 0.032 0.056 0.908 0.004 0.000
#> GSM252439     1  0.7224    0.07092 0.452 0.068 0.064 0.020 0.396
#> GSM252438     4  0.6053   -0.27518 0.000 0.064 0.052 0.624 0.260
#> GSM252434     3  0.4073    0.60430 0.088 0.060 0.820 0.032 0.000
#> GSM252437     3  0.6333    0.15729 0.392 0.096 0.492 0.020 0.000
#> GSM252451     3  0.3837    0.32897 0.308 0.000 0.692 0.000 0.000
#> GSM252448     1  0.0740    0.65166 0.980 0.004 0.008 0.000 0.008
#> GSM252447     1  0.0771    0.65318 0.976 0.004 0.020 0.000 0.000
#> GSM252444     1  0.4640    0.36164 0.584 0.016 0.400 0.000 0.000
#> GSM252450     1  0.4967    0.56402 0.704 0.104 0.192 0.000 0.000
#> GSM252452     5  0.3367    0.81926 0.032 0.004 0.088 0.016 0.860
#> GSM252443     1  0.8193    0.25160 0.476 0.144 0.248 0.032 0.100
#> GSM252454     1  0.5873    0.40569 0.632 0.272 0.060 0.032 0.004
#> GSM252449     3  0.3640    0.59432 0.084 0.072 0.836 0.008 0.000
#> GSM252445     3  0.5315    0.08685 0.456 0.004 0.500 0.040 0.000
#> GSM252453     1  0.4196    0.60296 0.768 0.024 0.192 0.016 0.000
#> GSM252464     3  0.4971    0.50225 0.040 0.172 0.740 0.048 0.000
#> GSM252463     3  0.8070    0.27682 0.300 0.036 0.336 0.304 0.024
#> GSM252461     1  0.2835    0.64095 0.868 0.000 0.112 0.004 0.016
#> GSM252455     3  0.6891    0.50180 0.120 0.108 0.596 0.176 0.000
#> GSM252458     3  0.7103    0.50515 0.080 0.064 0.636 0.140 0.080
#> GSM252460     3  0.3559    0.54690 0.008 0.012 0.804 0.176 0.000
#> GSM252457     1  0.6828   -0.07561 0.420 0.000 0.324 0.252 0.004
#> GSM252456     3  0.3551    0.52179 0.008 0.000 0.772 0.220 0.000
#> GSM252462     3  0.2513    0.60202 0.048 0.008 0.904 0.040 0.000
#> GSM252459     1  0.7006    0.26895 0.492 0.332 0.124 0.052 0.000
#> GSM252472     2  0.0771    0.72049 0.000 0.976 0.000 0.020 0.004
#> GSM252466     2  0.3634    0.70132 0.004 0.832 0.000 0.088 0.076
#> GSM252469     2  0.2726    0.71397 0.000 0.884 0.000 0.064 0.052
#> GSM252475     2  0.1728    0.71278 0.000 0.940 0.004 0.020 0.036
#> GSM252471     2  0.4550    0.64910 0.000 0.744 0.004 0.064 0.188
#> GSM252465     2  0.3317    0.70871 0.000 0.848 0.032 0.112 0.008
#> GSM252474     5  0.0854    0.91299 0.000 0.012 0.004 0.008 0.976
#> GSM252473     2  0.1300    0.72685 0.000 0.956 0.000 0.028 0.016
#> GSM252468     2  0.1662    0.71732 0.000 0.936 0.004 0.056 0.004
#> GSM252470     2  0.7154    0.41820 0.064 0.596 0.208 0.100 0.032
#> GSM252467     2  0.0486    0.72302 0.000 0.988 0.004 0.004 0.004
#> GSM252485     2  0.3122    0.71848 0.004 0.852 0.000 0.120 0.024
#> GSM252481     2  0.4248    0.69463 0.004 0.800 0.008 0.096 0.092
#> GSM252480     2  0.4078    0.68516 0.000 0.796 0.004 0.072 0.128
#> GSM252479     2  0.0771    0.72165 0.000 0.976 0.000 0.020 0.004
#> GSM252482     5  0.0162    0.92168 0.000 0.004 0.000 0.000 0.996
#> GSM252478     2  0.5114    0.59245 0.004 0.728 0.024 0.060 0.184
#> GSM252483     5  0.0963    0.90765 0.000 0.036 0.000 0.000 0.964
#> GSM252477     5  0.0162    0.92395 0.000 0.004 0.000 0.000 0.996
#> GSM252484     2  0.0727    0.72102 0.000 0.980 0.004 0.012 0.004
#> GSM252476     2  0.2054    0.72399 0.000 0.920 0.000 0.052 0.028

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.5388    0.12129 0.000 0.452 0.468 0.064 0.004 0.012
#> GSM252429     2  0.6059    0.49901 0.004 0.552 0.312 0.008 0.036 0.088
#> GSM252424     2  0.4523   -0.15765 0.016 0.496 0.480 0.004 0.000 0.004
#> GSM252432     3  0.3780    0.57104 0.000 0.204 0.760 0.016 0.020 0.000
#> GSM252427     3  0.4880    0.37806 0.000 0.352 0.596 0.032 0.016 0.004
#> GSM252431     3  0.4056    0.54858 0.000 0.276 0.696 0.016 0.012 0.000
#> GSM252430     5  0.0146    0.91479 0.000 0.000 0.004 0.000 0.996 0.000
#> GSM252433     5  0.2940    0.77379 0.000 0.036 0.112 0.004 0.848 0.000
#> GSM252426     3  0.4125    0.50732 0.000 0.128 0.748 0.124 0.000 0.000
#> GSM252428     3  0.3791    0.55466 0.000 0.148 0.796 0.032 0.008 0.016
#> GSM252425     2  0.5306    0.44396 0.008 0.616 0.292 0.064 0.000 0.020
#> GSM252440     1  0.1867    0.65920 0.916 0.000 0.000 0.064 0.000 0.020
#> GSM252441     1  0.0653    0.66303 0.980 0.000 0.004 0.012 0.000 0.004
#> GSM252436     1  0.3774    0.45135 0.664 0.008 0.000 0.328 0.000 0.000
#> GSM252435     1  0.3017    0.64348 0.840 0.004 0.000 0.132 0.016 0.008
#> GSM252442     4  0.1413    0.63820 0.004 0.008 0.036 0.948 0.000 0.004
#> GSM252439     1  0.6997    0.08641 0.440 0.068 0.016 0.064 0.384 0.028
#> GSM252438     6  0.2964    0.00000 0.000 0.032 0.004 0.004 0.108 0.852
#> GSM252434     4  0.1477    0.63412 0.008 0.004 0.048 0.940 0.000 0.000
#> GSM252437     4  0.7122    0.21464 0.324 0.080 0.116 0.452 0.000 0.028
#> GSM252451     4  0.2632    0.56336 0.164 0.000 0.004 0.832 0.000 0.000
#> GSM252448     1  0.0653    0.66172 0.980 0.000 0.000 0.004 0.004 0.012
#> GSM252447     1  0.0436    0.66190 0.988 0.004 0.000 0.004 0.000 0.004
#> GSM252444     1  0.3998    0.18501 0.504 0.004 0.000 0.492 0.000 0.000
#> GSM252450     1  0.4652    0.56238 0.704 0.088 0.012 0.196 0.000 0.000
#> GSM252452     5  0.3286    0.78311 0.032 0.004 0.012 0.088 0.852 0.012
#> GSM252443     1  0.8664    0.16889 0.408 0.124 0.112 0.228 0.084 0.044
#> GSM252454     1  0.5408    0.44059 0.632 0.256 0.080 0.024 0.000 0.008
#> GSM252449     4  0.1294    0.63737 0.008 0.008 0.024 0.956 0.000 0.004
#> GSM252445     4  0.5053    0.31792 0.356 0.000 0.052 0.576 0.000 0.016
#> GSM252453     1  0.4176    0.59739 0.756 0.016 0.020 0.188 0.000 0.020
#> GSM252464     4  0.5038    0.49061 0.020 0.132 0.148 0.696 0.000 0.004
#> GSM252463     3  0.6934    0.14171 0.228 0.020 0.480 0.240 0.016 0.016
#> GSM252461     1  0.3034    0.64484 0.852 0.000 0.008 0.108 0.008 0.024
#> GSM252455     4  0.6240   -0.00239 0.068 0.056 0.388 0.476 0.000 0.012
#> GSM252458     4  0.6678    0.15826 0.040 0.044 0.356 0.484 0.072 0.004
#> GSM252460     3  0.3950    0.03243 0.000 0.004 0.564 0.432 0.000 0.000
#> GSM252457     3  0.5986    0.12775 0.316 0.000 0.488 0.188 0.004 0.004
#> GSM252456     3  0.3862   -0.01821 0.000 0.000 0.524 0.476 0.000 0.000
#> GSM252462     4  0.3771    0.52061 0.012 0.004 0.252 0.728 0.000 0.004
#> GSM252459     1  0.6987    0.25705 0.448 0.344 0.044 0.124 0.000 0.040
#> GSM252472     2  0.0891    0.76199 0.000 0.968 0.024 0.000 0.000 0.008
#> GSM252466     2  0.4536    0.74390 0.000 0.764 0.076 0.004 0.052 0.104
#> GSM252469     2  0.3578    0.76266 0.000 0.832 0.052 0.004 0.032 0.080
#> GSM252475     2  0.1478    0.75731 0.000 0.944 0.032 0.000 0.020 0.004
#> GSM252471     2  0.4834    0.71288 0.000 0.720 0.040 0.004 0.172 0.064
#> GSM252465     2  0.3406    0.73292 0.000 0.816 0.136 0.004 0.004 0.040
#> GSM252474     5  0.1007    0.89547 0.000 0.004 0.008 0.004 0.968 0.016
#> GSM252473     2  0.1843    0.77576 0.000 0.932 0.016 0.004 0.016 0.032
#> GSM252468     2  0.1493    0.75959 0.000 0.936 0.056 0.004 0.000 0.004
#> GSM252470     2  0.7490    0.17203 0.036 0.432 0.344 0.096 0.020 0.072
#> GSM252467     2  0.1390    0.77271 0.000 0.948 0.032 0.004 0.000 0.016
#> GSM252485     2  0.3481    0.75061 0.000 0.820 0.120 0.004 0.008 0.048
#> GSM252481     2  0.5107    0.73271 0.000 0.724 0.092 0.008 0.068 0.108
#> GSM252480     2  0.4974    0.73240 0.000 0.736 0.068 0.008 0.100 0.088
#> GSM252479     2  0.0993    0.76511 0.000 0.964 0.024 0.000 0.000 0.012
#> GSM252482     5  0.0000    0.91380 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM252478     2  0.6235    0.47857 0.000 0.588 0.180 0.012 0.176 0.044
#> GSM252483     5  0.0547    0.90627 0.000 0.020 0.000 0.000 0.980 0.000
#> GSM252477     5  0.0146    0.91482 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM252484     2  0.1080    0.76413 0.000 0.960 0.032 0.004 0.000 0.004
#> GSM252476     2  0.3212    0.77032 0.000 0.852 0.056 0.004 0.016 0.072

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-CV-pam-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-CV-pam-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-CV-pam-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-CV-pam-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-CV-pam-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-CV-pam-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-CV-pam-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-CV-pam-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-CV-pam-membership-heatmap-5

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)

plot of chunk tab-CV-pam-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-CV-pam-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-CV-pam-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-CV-pam-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-CV-pam-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-CV-pam-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-CV-pam-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-CV-pam-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-CV-pam-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-CV-pam-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-pam-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-CV-pam-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-CV-pam-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-CV-pam-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-CV-pam-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-CV-pam-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-pam-collect-classes

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 agent(p) individual(p) k
#> CV:pam 57 5.06e-11        0.8734 2
#> CV:pam 56 2.42e-08        0.1067 3
#> CV:pam 46 8.27e-08        0.0221 4
#> CV:pam 43 4.61e-07        0.0202 5
#> CV:pam 39 7.93e-07        0.0617 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.


CV:mclust

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 51941 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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:

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)

plot of chunk CV-mclust-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.531           0.662       0.871         0.4455 0.518   0.518
#> 3 3 0.523           0.660       0.823         0.4328 0.764   0.568
#> 4 4 0.709           0.806       0.872         0.1548 0.838   0.571
#> 5 5 0.714           0.736       0.836         0.0668 0.921   0.703
#> 6 6 0.687           0.535       0.768         0.0401 0.996   0.979

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 4

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1  0.9732     0.1612 0.596 0.404
#> GSM252429     1  0.9866     0.0779 0.568 0.432
#> GSM252424     1  0.9866     0.0630 0.568 0.432
#> GSM252432     1  0.9795     0.1226 0.584 0.416
#> GSM252427     1  0.9833     0.0950 0.576 0.424
#> GSM252431     1  0.9850     0.0795 0.572 0.428
#> GSM252430     2  0.9954     0.2907 0.460 0.540
#> GSM252433     2  0.9963     0.2775 0.464 0.536
#> GSM252426     1  0.9833     0.0950 0.576 0.424
#> GSM252428     1  0.9754     0.1487 0.592 0.408
#> GSM252425     2  0.9909     0.3406 0.444 0.556
#> GSM252440     1  0.0376     0.8556 0.996 0.004
#> GSM252441     1  0.0376     0.8556 0.996 0.004
#> GSM252436     1  0.0000     0.8564 1.000 0.000
#> GSM252435     1  0.0376     0.8556 0.996 0.004
#> GSM252442     1  0.0000     0.8564 1.000 0.000
#> GSM252439     1  0.4298     0.7750 0.912 0.088
#> GSM252438     1  0.7815     0.5924 0.768 0.232
#> GSM252434     1  0.0000     0.8564 1.000 0.000
#> GSM252437     1  0.0376     0.8556 0.996 0.004
#> GSM252451     1  0.0000     0.8564 1.000 0.000
#> GSM252448     1  0.0376     0.8556 0.996 0.004
#> GSM252447     1  0.0376     0.8556 0.996 0.004
#> GSM252444     1  0.0000     0.8564 1.000 0.000
#> GSM252450     1  0.0000     0.8564 1.000 0.000
#> GSM252452     1  0.4298     0.7750 0.912 0.088
#> GSM252443     1  0.0376     0.8556 0.996 0.004
#> GSM252454     1  0.0938     0.8514 0.988 0.012
#> GSM252449     1  0.0000     0.8564 1.000 0.000
#> GSM252445     1  0.0376     0.8556 0.996 0.004
#> GSM252453     1  0.0000     0.8564 1.000 0.000
#> GSM252464     1  0.0000     0.8564 1.000 0.000
#> GSM252463     1  0.0376     0.8556 0.996 0.004
#> GSM252461     1  0.0376     0.8556 0.996 0.004
#> GSM252455     1  0.0000     0.8564 1.000 0.000
#> GSM252458     1  0.0000     0.8564 1.000 0.000
#> GSM252460     1  0.0000     0.8564 1.000 0.000
#> GSM252457     1  0.0000     0.8564 1.000 0.000
#> GSM252456     1  0.0000     0.8564 1.000 0.000
#> GSM252462     1  0.0000     0.8564 1.000 0.000
#> GSM252459     1  0.0000     0.8564 1.000 0.000
#> GSM252472     2  0.4690     0.7528 0.100 0.900
#> GSM252466     2  0.0000     0.7738 0.000 1.000
#> GSM252469     2  0.0000     0.7738 0.000 1.000
#> GSM252475     2  0.0376     0.7741 0.004 0.996
#> GSM252471     2  0.0000     0.7738 0.000 1.000
#> GSM252465     2  0.3431     0.7644 0.064 0.936
#> GSM252474     2  0.9909     0.3356 0.444 0.556
#> GSM252473     2  0.7219     0.6774 0.200 0.800
#> GSM252468     2  0.0672     0.7745 0.008 0.992
#> GSM252470     2  0.5294     0.7397 0.120 0.880
#> GSM252467     2  0.0376     0.7741 0.004 0.996
#> GSM252485     2  0.4298     0.7578 0.088 0.912
#> GSM252481     2  0.0000     0.7738 0.000 1.000
#> GSM252480     2  0.0376     0.7743 0.004 0.996
#> GSM252479     2  0.0376     0.7741 0.004 0.996
#> GSM252482     2  0.9909     0.3356 0.444 0.556
#> GSM252478     2  0.9460     0.4844 0.364 0.636
#> GSM252483     2  0.9909     0.3356 0.444 0.556
#> GSM252477     2  0.9909     0.3356 0.444 0.556
#> GSM252484     2  0.0376     0.7741 0.004 0.996
#> GSM252476     2  0.0376     0.7741 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.6646    0.64774 0.048 0.240 0.712
#> GSM252429     3  0.6986    0.64084 0.056 0.256 0.688
#> GSM252424     3  0.7157    0.62041 0.056 0.276 0.668
#> GSM252432     3  0.6646    0.64774 0.048 0.240 0.712
#> GSM252427     3  0.6685    0.64599 0.048 0.244 0.708
#> GSM252431     3  0.6685    0.64599 0.048 0.244 0.708
#> GSM252430     3  0.5443    0.48325 0.004 0.260 0.736
#> GSM252433     3  0.4575    0.54639 0.004 0.184 0.812
#> GSM252426     3  0.6723    0.64380 0.048 0.248 0.704
#> GSM252428     3  0.6685    0.64599 0.048 0.244 0.708
#> GSM252425     2  0.6476   -0.03569 0.004 0.548 0.448
#> GSM252440     1  0.0000    0.80608 1.000 0.000 0.000
#> GSM252441     1  0.0000    0.80608 1.000 0.000 0.000
#> GSM252436     1  0.0237    0.80721 0.996 0.000 0.004
#> GSM252435     1  0.0000    0.80608 1.000 0.000 0.000
#> GSM252442     1  0.4555    0.74493 0.800 0.000 0.200
#> GSM252439     3  0.5882    0.07948 0.348 0.000 0.652
#> GSM252438     3  0.2486    0.56601 0.060 0.008 0.932
#> GSM252434     1  0.2796    0.79760 0.908 0.000 0.092
#> GSM252437     1  0.0000    0.80608 1.000 0.000 0.000
#> GSM252451     1  0.1411    0.80697 0.964 0.000 0.036
#> GSM252448     1  0.0592    0.80872 0.988 0.000 0.012
#> GSM252447     1  0.0000    0.80608 1.000 0.000 0.000
#> GSM252444     1  0.0592    0.80870 0.988 0.000 0.012
#> GSM252450     1  0.0000    0.80608 1.000 0.000 0.000
#> GSM252452     3  0.5397    0.21156 0.280 0.000 0.720
#> GSM252443     1  0.6225    0.46067 0.568 0.000 0.432
#> GSM252454     1  0.5502    0.63467 0.744 0.008 0.248
#> GSM252449     1  0.1411    0.80789 0.964 0.000 0.036
#> GSM252445     1  0.0000    0.80608 1.000 0.000 0.000
#> GSM252453     1  0.0237    0.80721 0.996 0.000 0.004
#> GSM252464     1  0.7276    0.49438 0.564 0.032 0.404
#> GSM252463     1  0.5733    0.66496 0.676 0.000 0.324
#> GSM252461     1  0.5098    0.72467 0.752 0.000 0.248
#> GSM252455     1  0.5497    0.68790 0.708 0.000 0.292
#> GSM252458     1  0.5926    0.62757 0.644 0.000 0.356
#> GSM252460     1  0.6045    0.58972 0.620 0.000 0.380
#> GSM252457     1  0.6994    0.47103 0.556 0.020 0.424
#> GSM252456     1  0.5968    0.61596 0.636 0.000 0.364
#> GSM252462     1  0.5431    0.69854 0.716 0.000 0.284
#> GSM252459     1  0.3482    0.78874 0.872 0.000 0.128
#> GSM252472     2  0.2878    0.80252 0.000 0.904 0.096
#> GSM252466     2  0.0000    0.86335 0.000 1.000 0.000
#> GSM252469     2  0.0000    0.86335 0.000 1.000 0.000
#> GSM252475     2  0.0237    0.86451 0.000 0.996 0.004
#> GSM252471     2  0.0000    0.86335 0.000 1.000 0.000
#> GSM252465     2  0.2066    0.83652 0.000 0.940 0.060
#> GSM252474     2  0.6468   -0.00212 0.004 0.552 0.444
#> GSM252473     2  0.2066    0.82330 0.000 0.940 0.060
#> GSM252468     2  0.0237    0.86451 0.000 0.996 0.004
#> GSM252470     2  0.4978    0.64361 0.004 0.780 0.216
#> GSM252467     2  0.0237    0.86451 0.000 0.996 0.004
#> GSM252485     2  0.4002    0.73749 0.000 0.840 0.160
#> GSM252481     2  0.0000    0.86335 0.000 1.000 0.000
#> GSM252480     2  0.1031    0.85486 0.000 0.976 0.024
#> GSM252479     2  0.0237    0.86451 0.000 0.996 0.004
#> GSM252482     3  0.6483    0.16990 0.004 0.452 0.544
#> GSM252478     2  0.4654    0.59120 0.000 0.792 0.208
#> GSM252483     3  0.6483    0.16990 0.004 0.452 0.544
#> GSM252477     3  0.6483    0.16990 0.004 0.452 0.544
#> GSM252484     2  0.0237    0.86451 0.000 0.996 0.004
#> GSM252476     2  0.0237    0.86451 0.000 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.0592      0.780 0.000 0.016 0.984 0.000
#> GSM252429     3  0.2170      0.776 0.028 0.028 0.936 0.008
#> GSM252424     3  0.2928      0.736 0.024 0.076 0.896 0.004
#> GSM252432     3  0.0592      0.780 0.000 0.016 0.984 0.000
#> GSM252427     3  0.0592      0.780 0.000 0.016 0.984 0.000
#> GSM252431     3  0.0592      0.780 0.000 0.016 0.984 0.000
#> GSM252430     4  0.4605      0.806 0.000 0.072 0.132 0.796
#> GSM252433     4  0.4614      0.797 0.000 0.064 0.144 0.792
#> GSM252426     3  0.0592      0.780 0.000 0.016 0.984 0.000
#> GSM252428     3  0.0779      0.780 0.000 0.016 0.980 0.004
#> GSM252425     2  0.4456      0.655 0.004 0.716 0.280 0.000
#> GSM252440     1  0.1557      0.898 0.944 0.000 0.000 0.056
#> GSM252441     1  0.1557      0.898 0.944 0.000 0.000 0.056
#> GSM252436     1  0.0779      0.897 0.980 0.000 0.016 0.004
#> GSM252435     1  0.1474      0.899 0.948 0.000 0.000 0.052
#> GSM252442     1  0.5150      0.187 0.596 0.000 0.396 0.008
#> GSM252439     4  0.4499      0.689 0.160 0.000 0.048 0.792
#> GSM252438     4  0.3048      0.755 0.016 0.000 0.108 0.876
#> GSM252434     1  0.3243      0.831 0.876 0.000 0.088 0.036
#> GSM252437     1  0.1557      0.898 0.944 0.000 0.000 0.056
#> GSM252451     1  0.1042      0.895 0.972 0.000 0.020 0.008
#> GSM252448     1  0.1661      0.898 0.944 0.000 0.004 0.052
#> GSM252447     1  0.1557      0.898 0.944 0.000 0.000 0.056
#> GSM252444     1  0.0779      0.897 0.980 0.000 0.016 0.004
#> GSM252450     1  0.0779      0.897 0.980 0.000 0.016 0.004
#> GSM252452     4  0.5330      0.603 0.132 0.000 0.120 0.748
#> GSM252443     1  0.3991      0.820 0.808 0.000 0.020 0.172
#> GSM252454     1  0.3970      0.844 0.840 0.000 0.084 0.076
#> GSM252449     1  0.1004      0.895 0.972 0.000 0.024 0.004
#> GSM252445     1  0.1474      0.899 0.948 0.000 0.000 0.052
#> GSM252453     1  0.0779      0.897 0.980 0.000 0.016 0.004
#> GSM252464     3  0.4488      0.762 0.096 0.000 0.808 0.096
#> GSM252463     3  0.7083      0.209 0.432 0.000 0.444 0.124
#> GSM252461     1  0.3996      0.808 0.836 0.000 0.104 0.060
#> GSM252455     3  0.5898      0.549 0.348 0.000 0.604 0.048
#> GSM252458     3  0.5437      0.739 0.144 0.004 0.748 0.104
#> GSM252460     3  0.4483      0.762 0.104 0.000 0.808 0.088
#> GSM252457     3  0.6422      0.643 0.248 0.000 0.632 0.120
#> GSM252456     3  0.4549      0.761 0.100 0.000 0.804 0.096
#> GSM252462     3  0.6617      0.439 0.380 0.000 0.532 0.088
#> GSM252459     1  0.4791      0.725 0.784 0.000 0.136 0.080
#> GSM252472     2  0.1474      0.917 0.000 0.948 0.052 0.000
#> GSM252466     2  0.0707      0.936 0.000 0.980 0.000 0.020
#> GSM252469     2  0.0707      0.936 0.000 0.980 0.000 0.020
#> GSM252475     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> GSM252471     2  0.0707      0.936 0.000 0.980 0.000 0.020
#> GSM252465     2  0.1022      0.928 0.000 0.968 0.032 0.000
#> GSM252474     4  0.4857      0.620 0.000 0.324 0.008 0.668
#> GSM252473     2  0.0188      0.940 0.000 0.996 0.000 0.004
#> GSM252468     2  0.0188      0.940 0.000 0.996 0.004 0.000
#> GSM252470     2  0.3160      0.850 0.008 0.868 0.120 0.004
#> GSM252467     2  0.0188      0.941 0.000 0.996 0.000 0.004
#> GSM252485     2  0.3257      0.825 0.004 0.844 0.152 0.000
#> GSM252481     2  0.0707      0.936 0.000 0.980 0.000 0.020
#> GSM252480     2  0.0895      0.933 0.000 0.976 0.004 0.020
#> GSM252479     2  0.0188      0.941 0.000 0.996 0.000 0.004
#> GSM252482     4  0.3545      0.819 0.000 0.164 0.008 0.828
#> GSM252478     2  0.2408      0.871 0.000 0.896 0.104 0.000
#> GSM252483     4  0.3545      0.819 0.000 0.164 0.008 0.828
#> GSM252477     4  0.3545      0.819 0.000 0.164 0.008 0.828
#> GSM252484     2  0.0188      0.941 0.000 0.996 0.000 0.004
#> GSM252476     2  0.0000      0.941 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.0693      0.825 0.000 0.012 0.980 0.008 0.000
#> GSM252429     3  0.4770      0.664 0.000 0.032 0.736 0.200 0.032
#> GSM252424     3  0.5484      0.591 0.004 0.124 0.688 0.176 0.008
#> GSM252432     3  0.0510      0.825 0.000 0.016 0.984 0.000 0.000
#> GSM252427     3  0.0566      0.825 0.000 0.012 0.984 0.004 0.000
#> GSM252431     3  0.0609      0.824 0.000 0.020 0.980 0.000 0.000
#> GSM252430     5  0.2304      0.824 0.000 0.020 0.068 0.004 0.908
#> GSM252433     5  0.2228      0.812 0.000 0.004 0.092 0.004 0.900
#> GSM252426     3  0.0510      0.825 0.000 0.016 0.984 0.000 0.000
#> GSM252428     3  0.0404      0.825 0.000 0.012 0.988 0.000 0.000
#> GSM252425     2  0.3783      0.726 0.000 0.740 0.252 0.008 0.000
#> GSM252440     1  0.1116      0.775 0.964 0.000 0.004 0.028 0.004
#> GSM252441     1  0.0609      0.789 0.980 0.000 0.000 0.020 0.000
#> GSM252436     1  0.3885      0.696 0.724 0.000 0.000 0.268 0.008
#> GSM252435     1  0.1792      0.793 0.916 0.000 0.000 0.084 0.000
#> GSM252442     4  0.4424      0.529 0.212 0.000 0.032 0.744 0.012
#> GSM252439     5  0.5783      0.662 0.196 0.000 0.024 0.116 0.664
#> GSM252438     5  0.3907      0.777 0.032 0.000 0.068 0.068 0.832
#> GSM252434     4  0.4405      0.470 0.260 0.000 0.020 0.712 0.008
#> GSM252437     1  0.1478      0.795 0.936 0.000 0.000 0.064 0.000
#> GSM252451     1  0.4457      0.556 0.620 0.000 0.000 0.368 0.012
#> GSM252448     1  0.1455      0.770 0.952 0.000 0.008 0.032 0.008
#> GSM252447     1  0.0404      0.780 0.988 0.000 0.000 0.012 0.000
#> GSM252444     1  0.4618      0.572 0.636 0.000 0.004 0.344 0.016
#> GSM252450     1  0.4146      0.689 0.716 0.000 0.004 0.268 0.012
#> GSM252452     5  0.6156      0.622 0.072 0.000 0.076 0.204 0.648
#> GSM252443     1  0.4662      0.598 0.768 0.000 0.020 0.132 0.080
#> GSM252454     1  0.3894      0.726 0.828 0.000 0.092 0.056 0.024
#> GSM252449     4  0.4745     -0.029 0.424 0.000 0.004 0.560 0.012
#> GSM252445     1  0.2074      0.791 0.896 0.000 0.000 0.104 0.000
#> GSM252453     1  0.3783      0.708 0.740 0.000 0.000 0.252 0.008
#> GSM252464     3  0.3944      0.608 0.004 0.000 0.720 0.272 0.004
#> GSM252463     4  0.5421      0.555 0.076 0.000 0.152 0.720 0.052
#> GSM252461     4  0.6160      0.427 0.308 0.000 0.060 0.584 0.048
#> GSM252455     4  0.4668      0.570 0.048 0.000 0.220 0.724 0.008
#> GSM252458     4  0.4924      0.421 0.020 0.000 0.320 0.644 0.016
#> GSM252460     3  0.3365      0.688 0.008 0.000 0.808 0.180 0.004
#> GSM252457     4  0.5468      0.473 0.048 0.000 0.236 0.676 0.040
#> GSM252456     3  0.4564      0.367 0.008 0.000 0.600 0.388 0.004
#> GSM252462     4  0.4704      0.598 0.064 0.000 0.192 0.736 0.008
#> GSM252459     4  0.5171      0.481 0.276 0.000 0.076 0.648 0.000
#> GSM252472     2  0.2077      0.906 0.000 0.908 0.084 0.008 0.000
#> GSM252466     2  0.1357      0.925 0.000 0.948 0.000 0.004 0.048
#> GSM252469     2  0.1430      0.923 0.000 0.944 0.000 0.004 0.052
#> GSM252475     2  0.0613      0.932 0.000 0.984 0.004 0.004 0.008
#> GSM252471     2  0.1357      0.925 0.000 0.948 0.000 0.004 0.048
#> GSM252465     2  0.1591      0.924 0.000 0.940 0.052 0.004 0.004
#> GSM252474     5  0.3975      0.691 0.000 0.240 0.008 0.008 0.744
#> GSM252473     2  0.1282      0.927 0.000 0.952 0.000 0.004 0.044
#> GSM252468     2  0.0960      0.931 0.000 0.972 0.016 0.008 0.004
#> GSM252470     2  0.3052      0.876 0.008 0.856 0.124 0.004 0.008
#> GSM252467     2  0.0613      0.932 0.000 0.984 0.004 0.004 0.008
#> GSM252485     2  0.2660      0.877 0.000 0.864 0.128 0.008 0.000
#> GSM252481     2  0.1357      0.925 0.000 0.948 0.000 0.004 0.048
#> GSM252480     2  0.1928      0.910 0.000 0.920 0.004 0.004 0.072
#> GSM252479     2  0.0613      0.932 0.000 0.984 0.004 0.004 0.008
#> GSM252482     5  0.2237      0.829 0.000 0.084 0.008 0.004 0.904
#> GSM252478     2  0.2522      0.892 0.000 0.880 0.108 0.012 0.000
#> GSM252483     5  0.2177      0.829 0.000 0.080 0.008 0.004 0.908
#> GSM252477     5  0.2237      0.829 0.000 0.084 0.008 0.004 0.904
#> GSM252484     2  0.0486      0.932 0.000 0.988 0.004 0.004 0.004
#> GSM252476     2  0.0613      0.932 0.000 0.984 0.004 0.004 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.0665     0.7964 0.000 0.004 0.980 0.008 0.008 0.000
#> GSM252429     3  0.5141     0.6567 0.000 0.028 0.728 0.132 0.060 0.052
#> GSM252424     3  0.5504     0.5746 0.000 0.152 0.676 0.100 0.068 0.004
#> GSM252432     3  0.0665     0.7970 0.000 0.008 0.980 0.004 0.008 0.000
#> GSM252427     3  0.0405     0.7974 0.000 0.004 0.988 0.008 0.000 0.000
#> GSM252431     3  0.0405     0.7967 0.000 0.008 0.988 0.000 0.004 0.000
#> GSM252430     6  0.4385    -0.1384 0.000 0.000 0.032 0.004 0.328 0.636
#> GSM252433     6  0.4598    -0.0437 0.000 0.000 0.060 0.004 0.280 0.656
#> GSM252426     3  0.0405     0.7965 0.000 0.008 0.988 0.000 0.004 0.000
#> GSM252428     3  0.0912     0.7940 0.000 0.004 0.972 0.012 0.008 0.004
#> GSM252425     2  0.5255     0.5895 0.000 0.600 0.272 0.004 0.124 0.000
#> GSM252440     1  0.2809     0.6587 0.848 0.000 0.000 0.004 0.128 0.020
#> GSM252441     1  0.1333     0.7003 0.944 0.000 0.000 0.008 0.048 0.000
#> GSM252436     1  0.4268     0.5729 0.684 0.000 0.000 0.272 0.040 0.004
#> GSM252435     1  0.1320     0.7095 0.948 0.000 0.000 0.036 0.016 0.000
#> GSM252442     4  0.4389     0.4303 0.208 0.000 0.004 0.712 0.076 0.000
#> GSM252439     6  0.3755     0.2043 0.172 0.000 0.000 0.016 0.032 0.780
#> GSM252438     6  0.2570     0.2414 0.008 0.000 0.008 0.016 0.084 0.884
#> GSM252434     4  0.4747     0.3002 0.288 0.000 0.000 0.632 0.080 0.000
#> GSM252437     1  0.2177     0.7055 0.908 0.000 0.000 0.052 0.032 0.008
#> GSM252451     1  0.4619     0.3816 0.564 0.000 0.000 0.392 0.044 0.000
#> GSM252448     1  0.3000     0.6548 0.840 0.000 0.000 0.004 0.124 0.032
#> GSM252447     1  0.2146     0.6732 0.880 0.000 0.000 0.004 0.116 0.000
#> GSM252444     1  0.4582     0.4613 0.604 0.000 0.000 0.356 0.032 0.008
#> GSM252450     1  0.4182     0.5943 0.700 0.000 0.000 0.256 0.040 0.004
#> GSM252452     6  0.2993     0.2290 0.016 0.000 0.004 0.080 0.036 0.864
#> GSM252443     1  0.5562     0.3435 0.520 0.000 0.000 0.004 0.132 0.344
#> GSM252454     1  0.4717     0.6606 0.776 0.004 0.032 0.068 0.044 0.076
#> GSM252449     4  0.5052     0.0233 0.388 0.000 0.000 0.532 0.080 0.000
#> GSM252445     1  0.2595     0.6957 0.872 0.000 0.000 0.084 0.044 0.000
#> GSM252453     1  0.4559     0.5691 0.664 0.000 0.000 0.272 0.060 0.004
#> GSM252464     3  0.4602     0.4361 0.004 0.000 0.580 0.388 0.016 0.012
#> GSM252463     4  0.5074     0.4809 0.036 0.000 0.004 0.644 0.040 0.276
#> GSM252461     4  0.6614     0.3762 0.236 0.000 0.000 0.472 0.048 0.244
#> GSM252455     4  0.2477     0.5518 0.008 0.000 0.084 0.888 0.012 0.008
#> GSM252458     4  0.4173     0.2948 0.008 0.000 0.272 0.692 0.000 0.028
#> GSM252460     3  0.4119     0.5723 0.004 0.000 0.692 0.280 0.016 0.008
#> GSM252457     4  0.5714     0.4836 0.024 0.000 0.088 0.652 0.036 0.200
#> GSM252456     3  0.4634     0.2753 0.008 0.000 0.512 0.460 0.012 0.008
#> GSM252462     4  0.3658     0.5549 0.020 0.000 0.088 0.832 0.028 0.032
#> GSM252459     4  0.5886     0.2576 0.332 0.000 0.052 0.552 0.052 0.012
#> GSM252472     2  0.3118     0.8412 0.000 0.836 0.072 0.000 0.092 0.000
#> GSM252466     2  0.2527     0.8384 0.000 0.832 0.000 0.000 0.168 0.000
#> GSM252469     2  0.2491     0.8403 0.000 0.836 0.000 0.000 0.164 0.000
#> GSM252475     2  0.0713     0.8690 0.000 0.972 0.000 0.000 0.028 0.000
#> GSM252471     2  0.2048     0.8597 0.000 0.880 0.000 0.000 0.120 0.000
#> GSM252465     2  0.3078     0.8477 0.000 0.836 0.056 0.000 0.108 0.000
#> GSM252474     5  0.4992     0.0000 0.000 0.068 0.000 0.000 0.472 0.460
#> GSM252473     2  0.2491     0.8577 0.000 0.836 0.000 0.000 0.164 0.000
#> GSM252468     2  0.1858     0.8575 0.000 0.904 0.004 0.000 0.092 0.000
#> GSM252470     2  0.3220     0.8417 0.000 0.832 0.108 0.000 0.056 0.004
#> GSM252467     2  0.1387     0.8586 0.000 0.932 0.000 0.000 0.068 0.000
#> GSM252485     2  0.3727     0.8109 0.000 0.784 0.128 0.000 0.088 0.000
#> GSM252481     2  0.2527     0.8384 0.000 0.832 0.000 0.000 0.168 0.000
#> GSM252480     2  0.2743     0.8335 0.000 0.828 0.000 0.000 0.164 0.008
#> GSM252479     2  0.0458     0.8689 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM252482     6  0.3996    -0.5643 0.000 0.004 0.000 0.000 0.484 0.512
#> GSM252478     2  0.4120     0.7876 0.000 0.744 0.096 0.000 0.160 0.000
#> GSM252483     6  0.3996    -0.5643 0.000 0.004 0.000 0.000 0.484 0.512
#> GSM252477     6  0.3996    -0.5643 0.000 0.004 0.000 0.000 0.484 0.512
#> GSM252484     2  0.0458     0.8689 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM252476     2  0.1267     0.8605 0.000 0.940 0.000 0.000 0.060 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)

plot of chunk tab-CV-mclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-CV-mclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-CV-mclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-CV-mclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-CV-mclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-CV-mclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-CV-mclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-CV-mclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-CV-mclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-CV-mclust-membership-heatmap-5

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)

plot of chunk tab-CV-mclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-CV-mclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-CV-mclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-CV-mclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-CV-mclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-CV-mclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-CV-mclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-CV-mclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-CV-mclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-CV-mclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-mclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-CV-mclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-CV-mclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-CV-mclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-CV-mclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-CV-mclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-mclust-collect-classes

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 agent(p) individual(p) k
#> CV:mclust 46 2.46e-09         0.977 2
#> CV:mclust 51 3.98e-16         0.998 3
#> CV:mclust 59 1.19e-12         0.230 4
#> CV:mclust 55 7.08e-14         0.297 5
#> CV:mclust 40 3.44e-14         0.943 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.


CV:NMF

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 51941 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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:

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)

plot of chunk CV-NMF-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.771           0.887       0.954         0.5042 0.494   0.494
#> 3 3 0.514           0.725       0.835         0.2775 0.799   0.620
#> 4 4 0.693           0.729       0.860         0.1552 0.829   0.565
#> 5 5 0.627           0.665       0.761         0.0641 0.970   0.890
#> 6 6 0.615           0.362       0.667         0.0424 0.948   0.807

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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1  0.5059     0.8576 0.888 0.112
#> GSM252429     2  0.9795     0.2574 0.416 0.584
#> GSM252424     2  0.8267     0.6262 0.260 0.740
#> GSM252432     1  0.8813     0.5933 0.700 0.300
#> GSM252427     2  0.9996    -0.0106 0.488 0.512
#> GSM252431     2  0.1184     0.9369 0.016 0.984
#> GSM252430     2  0.0000     0.9491 0.000 1.000
#> GSM252433     2  0.0000     0.9491 0.000 1.000
#> GSM252426     1  0.9460     0.4450 0.636 0.364
#> GSM252428     1  0.6623     0.7966 0.828 0.172
#> GSM252425     2  0.4939     0.8452 0.108 0.892
#> GSM252440     1  0.0000     0.9484 1.000 0.000
#> GSM252441     1  0.0000     0.9484 1.000 0.000
#> GSM252436     1  0.0000     0.9484 1.000 0.000
#> GSM252435     1  0.0000     0.9484 1.000 0.000
#> GSM252442     1  0.0000     0.9484 1.000 0.000
#> GSM252439     1  0.7883     0.7023 0.764 0.236
#> GSM252438     2  0.2043     0.9241 0.032 0.968
#> GSM252434     1  0.0000     0.9484 1.000 0.000
#> GSM252437     1  0.0000     0.9484 1.000 0.000
#> GSM252451     1  0.0000     0.9484 1.000 0.000
#> GSM252448     1  0.0000     0.9484 1.000 0.000
#> GSM252447     1  0.0000     0.9484 1.000 0.000
#> GSM252444     1  0.0000     0.9484 1.000 0.000
#> GSM252450     1  0.0000     0.9484 1.000 0.000
#> GSM252452     1  0.5737     0.8328 0.864 0.136
#> GSM252443     1  0.0938     0.9408 0.988 0.012
#> GSM252454     1  0.7602     0.7293 0.780 0.220
#> GSM252449     1  0.0000     0.9484 1.000 0.000
#> GSM252445     1  0.0000     0.9484 1.000 0.000
#> GSM252453     1  0.0000     0.9484 1.000 0.000
#> GSM252464     1  0.0000     0.9484 1.000 0.000
#> GSM252463     1  0.0000     0.9484 1.000 0.000
#> GSM252461     1  0.0000     0.9484 1.000 0.000
#> GSM252455     1  0.0000     0.9484 1.000 0.000
#> GSM252458     1  0.0000     0.9484 1.000 0.000
#> GSM252460     1  0.0000     0.9484 1.000 0.000
#> GSM252457     1  0.0000     0.9484 1.000 0.000
#> GSM252456     1  0.0000     0.9484 1.000 0.000
#> GSM252462     1  0.0000     0.9484 1.000 0.000
#> GSM252459     1  0.0000     0.9484 1.000 0.000
#> GSM252472     2  0.0000     0.9491 0.000 1.000
#> GSM252466     2  0.0000     0.9491 0.000 1.000
#> GSM252469     2  0.0000     0.9491 0.000 1.000
#> GSM252475     2  0.0000     0.9491 0.000 1.000
#> GSM252471     2  0.0000     0.9491 0.000 1.000
#> GSM252465     2  0.0000     0.9491 0.000 1.000
#> GSM252474     2  0.0000     0.9491 0.000 1.000
#> GSM252473     2  0.0000     0.9491 0.000 1.000
#> GSM252468     2  0.0000     0.9491 0.000 1.000
#> GSM252470     2  0.0000     0.9491 0.000 1.000
#> GSM252467     2  0.0000     0.9491 0.000 1.000
#> GSM252485     2  0.0000     0.9491 0.000 1.000
#> GSM252481     2  0.0000     0.9491 0.000 1.000
#> GSM252480     2  0.0000     0.9491 0.000 1.000
#> GSM252479     2  0.0000     0.9491 0.000 1.000
#> GSM252482     2  0.0000     0.9491 0.000 1.000
#> GSM252478     2  0.0000     0.9491 0.000 1.000
#> GSM252483     2  0.0000     0.9491 0.000 1.000
#> GSM252477     2  0.0000     0.9491 0.000 1.000
#> GSM252484     2  0.0000     0.9491 0.000 1.000
#> GSM252476     2  0.0000     0.9491 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     1  0.8825     0.5215 0.560 0.288 0.152
#> GSM252429     3  0.8890     0.3618 0.328 0.140 0.532
#> GSM252424     2  0.6500     0.6449 0.140 0.760 0.100
#> GSM252432     1  0.8886     0.5634 0.572 0.240 0.188
#> GSM252427     2  0.9319     0.0182 0.368 0.464 0.168
#> GSM252431     2  0.4164     0.6960 0.008 0.848 0.144
#> GSM252430     3  0.3918     0.7681 0.004 0.140 0.856
#> GSM252433     3  0.4178     0.7563 0.000 0.172 0.828
#> GSM252426     2  0.8016     0.4865 0.188 0.656 0.156
#> GSM252428     2  0.9311     0.0931 0.364 0.468 0.168
#> GSM252425     2  0.4277     0.6996 0.016 0.852 0.132
#> GSM252440     1  0.2878     0.8179 0.904 0.000 0.096
#> GSM252441     1  0.1643     0.8463 0.956 0.000 0.044
#> GSM252436     1  0.0592     0.8546 0.988 0.000 0.012
#> GSM252435     1  0.1964     0.8468 0.944 0.000 0.056
#> GSM252442     1  0.5334     0.8105 0.820 0.060 0.120
#> GSM252439     3  0.4931     0.6808 0.212 0.004 0.784
#> GSM252438     3  0.4485     0.7678 0.020 0.136 0.844
#> GSM252434     1  0.4859     0.8210 0.840 0.044 0.116
#> GSM252437     1  0.1031     0.8522 0.976 0.000 0.024
#> GSM252451     1  0.1015     0.8583 0.980 0.008 0.012
#> GSM252448     1  0.3482     0.7830 0.872 0.000 0.128
#> GSM252447     1  0.2878     0.8200 0.904 0.000 0.096
#> GSM252444     1  0.0592     0.8543 0.988 0.000 0.012
#> GSM252450     1  0.0592     0.8543 0.988 0.000 0.012
#> GSM252452     3  0.6154     0.3647 0.408 0.000 0.592
#> GSM252443     3  0.6079     0.4263 0.388 0.000 0.612
#> GSM252454     1  0.5356     0.6978 0.784 0.020 0.196
#> GSM252449     1  0.2096     0.8568 0.944 0.004 0.052
#> GSM252445     1  0.0592     0.8564 0.988 0.000 0.012
#> GSM252453     1  0.4209     0.7895 0.856 0.128 0.016
#> GSM252464     1  0.7044     0.7487 0.724 0.108 0.168
#> GSM252463     1  0.2878     0.8306 0.904 0.000 0.096
#> GSM252461     1  0.1529     0.8477 0.960 0.000 0.040
#> GSM252455     1  0.3678     0.8503 0.892 0.028 0.080
#> GSM252458     1  0.3695     0.8443 0.880 0.012 0.108
#> GSM252460     1  0.7155     0.7347 0.720 0.128 0.152
#> GSM252457     1  0.2945     0.8556 0.908 0.004 0.088
#> GSM252456     1  0.7223     0.7284 0.716 0.144 0.140
#> GSM252462     1  0.3610     0.8446 0.888 0.016 0.096
#> GSM252459     1  0.3370     0.8515 0.904 0.024 0.072
#> GSM252472     2  0.2448     0.7824 0.000 0.924 0.076
#> GSM252466     2  0.4654     0.7003 0.000 0.792 0.208
#> GSM252469     2  0.4504     0.7072 0.000 0.804 0.196
#> GSM252475     2  0.2165     0.7862 0.000 0.936 0.064
#> GSM252471     2  0.5178     0.6474 0.000 0.744 0.256
#> GSM252465     2  0.2537     0.7800 0.000 0.920 0.080
#> GSM252474     3  0.4605     0.7104 0.000 0.204 0.796
#> GSM252473     2  0.4702     0.6991 0.000 0.788 0.212
#> GSM252468     2  0.0747     0.7829 0.000 0.984 0.016
#> GSM252470     2  0.3412     0.7634 0.000 0.876 0.124
#> GSM252467     2  0.0892     0.7896 0.000 0.980 0.020
#> GSM252485     2  0.2537     0.7783 0.000 0.920 0.080
#> GSM252481     2  0.4750     0.6926 0.000 0.784 0.216
#> GSM252480     2  0.4555     0.7061 0.000 0.800 0.200
#> GSM252479     2  0.0747     0.7894 0.000 0.984 0.016
#> GSM252482     3  0.3941     0.7650 0.000 0.156 0.844
#> GSM252478     2  0.1964     0.7875 0.000 0.944 0.056
#> GSM252483     3  0.4002     0.7623 0.000 0.160 0.840
#> GSM252477     3  0.4002     0.7631 0.000 0.160 0.840
#> GSM252484     2  0.1031     0.7905 0.000 0.976 0.024
#> GSM252476     2  0.0592     0.7887 0.000 0.988 0.012

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.1843     0.7449 0.028 0.008 0.948 0.016
#> GSM252429     4  0.6197     0.1309 0.052 0.000 0.440 0.508
#> GSM252424     2  0.5342     0.6847 0.024 0.732 0.220 0.024
#> GSM252432     3  0.1786     0.7328 0.008 0.008 0.948 0.036
#> GSM252427     3  0.1811     0.7343 0.004 0.028 0.948 0.020
#> GSM252431     3  0.4889     0.2821 0.000 0.360 0.636 0.004
#> GSM252430     4  0.0779     0.8678 0.000 0.004 0.016 0.980
#> GSM252433     4  0.2266     0.8437 0.000 0.004 0.084 0.912
#> GSM252426     3  0.1474     0.7259 0.000 0.052 0.948 0.000
#> GSM252428     3  0.1545     0.7311 0.000 0.040 0.952 0.008
#> GSM252425     2  0.4605     0.5760 0.000 0.664 0.336 0.000
#> GSM252440     1  0.0937     0.8389 0.976 0.000 0.012 0.012
#> GSM252441     1  0.0524     0.8420 0.988 0.000 0.008 0.004
#> GSM252436     1  0.0817     0.8425 0.976 0.000 0.024 0.000
#> GSM252435     1  0.0524     0.8429 0.988 0.000 0.008 0.004
#> GSM252442     3  0.6214     0.0773 0.472 0.052 0.476 0.000
#> GSM252439     4  0.3973     0.7113 0.200 0.004 0.004 0.792
#> GSM252438     4  0.2408     0.8563 0.016 0.004 0.060 0.920
#> GSM252434     1  0.5244     0.1113 0.556 0.008 0.436 0.000
#> GSM252437     1  0.0657     0.8438 0.984 0.000 0.012 0.004
#> GSM252451     1  0.1389     0.8378 0.952 0.000 0.048 0.000
#> GSM252448     1  0.1798     0.8303 0.944 0.000 0.016 0.040
#> GSM252447     1  0.0859     0.8381 0.980 0.004 0.008 0.008
#> GSM252444     1  0.1743     0.8320 0.940 0.000 0.056 0.004
#> GSM252450     1  0.1211     0.8400 0.960 0.000 0.040 0.000
#> GSM252452     4  0.4224     0.7586 0.044 0.000 0.144 0.812
#> GSM252443     1  0.5024     0.4119 0.632 0.000 0.008 0.360
#> GSM252454     1  0.4011     0.7568 0.844 0.020 0.024 0.112
#> GSM252449     1  0.3311     0.7208 0.828 0.000 0.172 0.000
#> GSM252445     1  0.1191     0.8440 0.968 0.004 0.024 0.004
#> GSM252453     1  0.3171     0.7591 0.876 0.104 0.016 0.004
#> GSM252464     3  0.2300     0.7411 0.048 0.000 0.924 0.028
#> GSM252463     1  0.6961     0.1148 0.496 0.000 0.388 0.116
#> GSM252461     1  0.1576     0.8373 0.948 0.000 0.048 0.004
#> GSM252455     3  0.4991     0.4036 0.388 0.004 0.608 0.000
#> GSM252458     3  0.4483     0.5904 0.284 0.000 0.712 0.004
#> GSM252460     3  0.1305     0.7483 0.036 0.004 0.960 0.000
#> GSM252457     3  0.6197     0.4670 0.324 0.000 0.604 0.072
#> GSM252456     3  0.3801     0.7376 0.076 0.064 0.856 0.004
#> GSM252462     3  0.4992     0.1441 0.476 0.000 0.524 0.000
#> GSM252459     1  0.5012     0.4631 0.668 0.004 0.320 0.008
#> GSM252472     2  0.4030     0.8570 0.000 0.836 0.092 0.072
#> GSM252466     2  0.3479     0.8615 0.000 0.840 0.012 0.148
#> GSM252469     2  0.2888     0.8776 0.004 0.872 0.000 0.124
#> GSM252475     2  0.0895     0.9021 0.000 0.976 0.004 0.020
#> GSM252471     2  0.3498     0.8544 0.000 0.832 0.008 0.160
#> GSM252465     2  0.2214     0.9028 0.000 0.928 0.028 0.044
#> GSM252474     4  0.1661     0.8480 0.004 0.052 0.000 0.944
#> GSM252473     2  0.2271     0.8947 0.000 0.916 0.008 0.076
#> GSM252468     2  0.1305     0.8978 0.000 0.960 0.036 0.004
#> GSM252470     2  0.2010     0.9029 0.008 0.940 0.012 0.040
#> GSM252467     2  0.0336     0.8990 0.000 0.992 0.008 0.000
#> GSM252485     2  0.3323     0.8745 0.000 0.876 0.060 0.064
#> GSM252481     2  0.2466     0.8882 0.000 0.900 0.004 0.096
#> GSM252480     2  0.3300     0.8630 0.000 0.848 0.008 0.144
#> GSM252479     2  0.0657     0.9007 0.000 0.984 0.012 0.004
#> GSM252482     4  0.0657     0.8689 0.000 0.012 0.004 0.984
#> GSM252478     2  0.2742     0.8856 0.000 0.900 0.076 0.024
#> GSM252483     4  0.0469     0.8685 0.000 0.012 0.000 0.988
#> GSM252477     4  0.0592     0.8681 0.000 0.016 0.000 0.984
#> GSM252484     2  0.0657     0.9008 0.000 0.984 0.012 0.004
#> GSM252476     2  0.0657     0.9003 0.000 0.984 0.012 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3 p4    p5
#> GSM252423     3  0.2929      0.671 0.012 0.000 0.856 NA 0.004
#> GSM252429     3  0.7747      0.247 0.024 0.024 0.404 NA 0.228
#> GSM252424     2  0.6976      0.408 0.012 0.516 0.244 NA 0.012
#> GSM252432     3  0.2802      0.680 0.008 0.008 0.888 NA 0.016
#> GSM252427     3  0.2972      0.677 0.000 0.004 0.864 NA 0.024
#> GSM252431     3  0.6495      0.287 0.000 0.216 0.480 NA 0.000
#> GSM252430     5  0.1877      0.862 0.000 0.000 0.012 NA 0.924
#> GSM252433     5  0.4522      0.798 0.000 0.016 0.068 NA 0.772
#> GSM252426     3  0.2629      0.682 0.004 0.012 0.880 NA 0.000
#> GSM252428     3  0.3844      0.655 0.000 0.040 0.808 NA 0.008
#> GSM252425     2  0.6550      0.480 0.000 0.436 0.172 NA 0.004
#> GSM252440     1  0.3023      0.770 0.868 0.012 0.004 NA 0.012
#> GSM252441     1  0.1121      0.790 0.956 0.000 0.000 NA 0.000
#> GSM252436     1  0.1251      0.788 0.956 0.000 0.008 NA 0.000
#> GSM252435     1  0.2061      0.790 0.924 0.004 0.004 NA 0.012
#> GSM252442     3  0.6764      0.191 0.388 0.016 0.436 NA 0.000
#> GSM252439     5  0.4693      0.736 0.148 0.000 0.008 NA 0.752
#> GSM252438     5  0.5297      0.749 0.008 0.012 0.072 NA 0.704
#> GSM252434     1  0.5981      0.183 0.540 0.004 0.348 NA 0.000
#> GSM252437     1  0.1430      0.792 0.944 0.000 0.004 NA 0.000
#> GSM252451     1  0.2585      0.768 0.896 0.004 0.036 NA 0.000
#> GSM252448     1  0.3187      0.759 0.860 0.000 0.008 NA 0.036
#> GSM252447     1  0.2026      0.787 0.924 0.008 0.000 NA 0.012
#> GSM252444     1  0.2729      0.776 0.884 0.000 0.028 NA 0.004
#> GSM252450     1  0.1408      0.791 0.948 0.000 0.008 NA 0.000
#> GSM252452     5  0.5065      0.725 0.032 0.000 0.152 NA 0.740
#> GSM252443     1  0.6110      0.308 0.540 0.000 0.008 NA 0.340
#> GSM252454     1  0.5285      0.702 0.744 0.040 0.008 NA 0.076
#> GSM252449     1  0.4738      0.628 0.744 0.004 0.140 NA 0.000
#> GSM252445     1  0.1670      0.789 0.936 0.000 0.012 NA 0.000
#> GSM252453     1  0.5875      0.487 0.592 0.152 0.000 NA 0.000
#> GSM252464     3  0.2238      0.690 0.020 0.000 0.912 NA 0.004
#> GSM252463     3  0.7786      0.205 0.344 0.000 0.396 NA 0.092
#> GSM252461     1  0.4228      0.720 0.788 0.000 0.100 NA 0.004
#> GSM252455     3  0.6139      0.478 0.288 0.004 0.560 NA 0.000
#> GSM252458     3  0.5018      0.635 0.164 0.000 0.716 NA 0.004
#> GSM252460     3  0.2727      0.681 0.016 0.000 0.868 NA 0.000
#> GSM252457     3  0.7636      0.461 0.188 0.000 0.432 NA 0.072
#> GSM252456     3  0.5012      0.677 0.084 0.032 0.748 NA 0.000
#> GSM252462     3  0.6209      0.133 0.424 0.000 0.452 NA 0.004
#> GSM252459     1  0.7201      0.163 0.432 0.032 0.196 NA 0.000
#> GSM252472     2  0.6005      0.696 0.000 0.604 0.068 NA 0.036
#> GSM252466     2  0.3912      0.797 0.000 0.804 0.000 NA 0.088
#> GSM252469     2  0.4123      0.794 0.000 0.796 0.004 NA 0.092
#> GSM252475     2  0.3146      0.801 0.000 0.844 0.000 NA 0.028
#> GSM252471     2  0.4158      0.780 0.000 0.784 0.000 NA 0.124
#> GSM252465     2  0.5716      0.707 0.000 0.624 0.044 NA 0.040
#> GSM252474     5  0.1626      0.856 0.000 0.044 0.000 NA 0.940
#> GSM252473     2  0.3517      0.803 0.000 0.832 0.000 NA 0.068
#> GSM252468     2  0.3717      0.799 0.000 0.816 0.028 NA 0.012
#> GSM252470     2  0.3409      0.803 0.008 0.824 0.004 NA 0.008
#> GSM252467     2  0.2179      0.809 0.000 0.888 0.000 NA 0.000
#> GSM252485     2  0.5181      0.737 0.000 0.668 0.032 NA 0.028
#> GSM252481     2  0.3141      0.805 0.000 0.852 0.000 NA 0.040
#> GSM252480     2  0.4038      0.784 0.000 0.792 0.000 NA 0.128
#> GSM252479     2  0.2517      0.806 0.000 0.884 0.008 NA 0.004
#> GSM252482     5  0.0798      0.870 0.000 0.008 0.000 NA 0.976
#> GSM252478     2  0.5893      0.664 0.000 0.576 0.052 NA 0.032
#> GSM252483     5  0.0671      0.868 0.000 0.004 0.000 NA 0.980
#> GSM252477     5  0.0693      0.868 0.000 0.008 0.000 NA 0.980
#> GSM252484     2  0.2589      0.809 0.000 0.888 0.012 NA 0.008
#> GSM252476     2  0.3461      0.783 0.000 0.772 0.000 NA 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3   0.345    0.52933 0.000 0.004 0.804 0.044 0.000 0.148
#> GSM252429     3   0.772    0.22240 0.020 0.028 0.384 0.068 0.152 0.348
#> GSM252424     3   0.811   -0.01843 0.032 0.292 0.320 0.124 0.004 0.228
#> GSM252432     3   0.291    0.55922 0.000 0.008 0.864 0.016 0.016 0.096
#> GSM252427     3   0.462    0.54575 0.000 0.012 0.756 0.072 0.032 0.128
#> GSM252431     3   0.760    0.00269 0.000 0.156 0.360 0.320 0.012 0.152
#> GSM252430     5   0.213    0.78695 0.000 0.000 0.004 0.020 0.904 0.072
#> GSM252433     5   0.514    0.70162 0.000 0.008 0.064 0.108 0.720 0.100
#> GSM252426     3   0.334    0.55659 0.000 0.016 0.836 0.060 0.000 0.088
#> GSM252428     3   0.484    0.52304 0.000 0.008 0.716 0.160 0.016 0.100
#> GSM252425     2   0.770   -0.18461 0.000 0.344 0.184 0.240 0.004 0.228
#> GSM252440     1   0.378    0.49368 0.800 0.012 0.000 0.028 0.016 0.144
#> GSM252441     1   0.178    0.55185 0.920 0.000 0.000 0.016 0.000 0.064
#> GSM252436     1   0.170    0.56427 0.920 0.000 0.008 0.000 0.000 0.072
#> GSM252435     1   0.382    0.51974 0.812 0.024 0.016 0.020 0.004 0.124
#> GSM252442     3   0.772    0.02891 0.264 0.008 0.348 0.156 0.000 0.224
#> GSM252439     5   0.551    0.58059 0.140 0.000 0.000 0.048 0.656 0.156
#> GSM252438     5   0.761    0.35799 0.012 0.036 0.052 0.184 0.420 0.296
#> GSM252434     1   0.668    0.08483 0.448 0.008 0.276 0.028 0.000 0.240
#> GSM252437     1   0.237    0.56776 0.888 0.008 0.004 0.008 0.000 0.092
#> GSM252451     1   0.355    0.52432 0.808 0.000 0.032 0.020 0.000 0.140
#> GSM252448     1   0.380    0.48105 0.800 0.000 0.004 0.036 0.024 0.136
#> GSM252447     1   0.250    0.54599 0.880 0.000 0.000 0.028 0.004 0.088
#> GSM252444     1   0.378    0.49803 0.772 0.000 0.028 0.016 0.000 0.184
#> GSM252450     1   0.245    0.56965 0.888 0.000 0.016 0.016 0.000 0.080
#> GSM252452     5   0.498    0.68908 0.020 0.000 0.092 0.056 0.744 0.088
#> GSM252443     1   0.649    0.00987 0.500 0.000 0.004 0.048 0.292 0.156
#> GSM252454     1   0.713    0.12373 0.568 0.068 0.008 0.180 0.076 0.100
#> GSM252449     1   0.566    0.32745 0.612 0.000 0.120 0.036 0.000 0.232
#> GSM252445     1   0.373    0.53549 0.780 0.016 0.004 0.012 0.004 0.184
#> GSM252453     1   0.721   -0.52816 0.468 0.160 0.004 0.164 0.000 0.204
#> GSM252464     3   0.306    0.56019 0.008 0.000 0.848 0.016 0.012 0.116
#> GSM252463     3   0.766    0.02941 0.252 0.004 0.392 0.020 0.088 0.244
#> GSM252461     1   0.490    0.40589 0.720 0.008 0.076 0.032 0.000 0.164
#> GSM252455     3   0.665    0.16601 0.236 0.004 0.460 0.036 0.000 0.264
#> GSM252458     3   0.505    0.51520 0.064 0.012 0.728 0.036 0.008 0.152
#> GSM252460     3   0.387    0.52558 0.000 0.000 0.780 0.088 0.004 0.128
#> GSM252457     3   0.747    0.17866 0.120 0.004 0.412 0.064 0.052 0.348
#> GSM252456     3   0.608    0.43735 0.048 0.028 0.600 0.072 0.000 0.252
#> GSM252462     1   0.672   -0.10388 0.348 0.004 0.332 0.024 0.000 0.292
#> GSM252459     6   0.803    0.00000 0.348 0.060 0.096 0.136 0.008 0.352
#> GSM252472     2   0.661    0.19392 0.000 0.536 0.040 0.228 0.020 0.176
#> GSM252466     2   0.432    0.43189 0.000 0.776 0.000 0.092 0.060 0.072
#> GSM252469     2   0.371    0.38945 0.000 0.800 0.000 0.140 0.032 0.028
#> GSM252475     2   0.492    0.38059 0.000 0.684 0.000 0.220 0.036 0.060
#> GSM252471     2   0.554    0.31495 0.000 0.664 0.004 0.176 0.096 0.060
#> GSM252465     2   0.549   -0.46538 0.000 0.484 0.020 0.436 0.052 0.008
#> GSM252474     5   0.297    0.76636 0.000 0.044 0.000 0.056 0.868 0.032
#> GSM252473     2   0.483    0.40432 0.000 0.716 0.000 0.172 0.056 0.056
#> GSM252468     2   0.461    0.36720 0.000 0.712 0.008 0.204 0.008 0.068
#> GSM252470     2   0.509    0.29566 0.016 0.684 0.008 0.220 0.008 0.064
#> GSM252467     2   0.353    0.40492 0.000 0.796 0.000 0.140 0.000 0.064
#> GSM252485     2   0.679    0.24438 0.000 0.532 0.032 0.196 0.040 0.200
#> GSM252481     2   0.464    0.38244 0.004 0.728 0.000 0.176 0.024 0.068
#> GSM252480     2   0.493    0.36607 0.004 0.720 0.000 0.140 0.100 0.036
#> GSM252479     2   0.398    0.44845 0.000 0.784 0.012 0.136 0.004 0.064
#> GSM252482     5   0.196    0.78823 0.000 0.020 0.000 0.032 0.924 0.024
#> GSM252478     4   0.601    0.00000 0.000 0.376 0.028 0.512 0.048 0.036
#> GSM252483     5   0.191    0.78936 0.000 0.016 0.000 0.044 0.924 0.016
#> GSM252477     5   0.208    0.78597 0.000 0.016 0.000 0.044 0.916 0.024
#> GSM252484     2   0.404    0.41197 0.000 0.772 0.008 0.160 0.008 0.052
#> GSM252476     2   0.474    0.30704 0.000 0.680 0.004 0.212 0.000 0.104

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-CV-NMF-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-CV-NMF-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-CV-NMF-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-CV-NMF-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-CV-NMF-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-CV-NMF-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-CV-NMF-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-CV-NMF-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-CV-NMF-membership-heatmap-5

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)

plot of chunk tab-CV-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-CV-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-CV-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-CV-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-CV-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-CV-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-CV-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-CV-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-CV-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-CV-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-NMF-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-CV-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-CV-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-CV-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-CV-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-CV-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-NMF-collect-classes

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 agent(p) individual(p) k
#> CV:NMF 59 3.79e-09        0.8992 2
#> CV:NMF 56 1.86e-07        0.0141 3
#> CV:NMF 52 4.85e-10        0.0368 4
#> CV:NMF 49 1.31e-10        0.0471 5
#> CV:NMF 24 9.14e-04        0.0811 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.


MAD:hclust

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 51941 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk MAD-hclust-collect-plots

The plots are:

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:

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)

plot of chunk MAD-hclust-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.704           0.800       0.921         0.4827 0.526   0.526
#> 3 3 0.707           0.863       0.894         0.2874 0.825   0.674
#> 4 4 0.755           0.765       0.887         0.0867 0.985   0.959
#> 5 5 0.708           0.721       0.845         0.0764 0.927   0.794
#> 6 6 0.711           0.683       0.788         0.0560 0.957   0.847

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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1  0.9954      0.275 0.540 0.460
#> GSM252429     1  0.9954      0.275 0.540 0.460
#> GSM252424     1  0.9944      0.286 0.544 0.456
#> GSM252432     1  0.9954      0.275 0.540 0.460
#> GSM252427     1  0.9686      0.418 0.604 0.396
#> GSM252431     2  0.9977     -0.106 0.472 0.528
#> GSM252430     2  0.9129      0.398 0.328 0.672
#> GSM252433     1  0.9732      0.402 0.596 0.404
#> GSM252426     1  0.9933      0.296 0.548 0.452
#> GSM252428     1  0.9988      0.213 0.520 0.480
#> GSM252425     1  0.9087      0.547 0.676 0.324
#> GSM252440     1  0.0000      0.881 1.000 0.000
#> GSM252441     1  0.0000      0.881 1.000 0.000
#> GSM252436     1  0.0000      0.881 1.000 0.000
#> GSM252435     1  0.0000      0.881 1.000 0.000
#> GSM252442     1  0.0000      0.881 1.000 0.000
#> GSM252439     1  0.0000      0.881 1.000 0.000
#> GSM252438     1  0.0938      0.875 0.988 0.012
#> GSM252434     1  0.0000      0.881 1.000 0.000
#> GSM252437     1  0.0000      0.881 1.000 0.000
#> GSM252451     1  0.0000      0.881 1.000 0.000
#> GSM252448     1  0.0000      0.881 1.000 0.000
#> GSM252447     1  0.0000      0.881 1.000 0.000
#> GSM252444     1  0.0000      0.881 1.000 0.000
#> GSM252450     1  0.0000      0.881 1.000 0.000
#> GSM252452     1  0.1184      0.872 0.984 0.016
#> GSM252443     1  0.0000      0.881 1.000 0.000
#> GSM252454     1  0.0000      0.881 1.000 0.000
#> GSM252449     1  0.0000      0.881 1.000 0.000
#> GSM252445     1  0.0000      0.881 1.000 0.000
#> GSM252453     1  0.0000      0.881 1.000 0.000
#> GSM252464     1  0.0000      0.881 1.000 0.000
#> GSM252463     1  0.0000      0.881 1.000 0.000
#> GSM252461     1  0.0000      0.881 1.000 0.000
#> GSM252455     1  0.0000      0.881 1.000 0.000
#> GSM252458     1  0.0376      0.879 0.996 0.004
#> GSM252460     1  0.0000      0.881 1.000 0.000
#> GSM252457     1  0.4815      0.804 0.896 0.104
#> GSM252456     1  0.0000      0.881 1.000 0.000
#> GSM252462     1  0.0000      0.881 1.000 0.000
#> GSM252459     1  0.1184      0.872 0.984 0.016
#> GSM252472     2  0.0000      0.953 0.000 1.000
#> GSM252466     2  0.0000      0.953 0.000 1.000
#> GSM252469     2  0.0000      0.953 0.000 1.000
#> GSM252475     2  0.0000      0.953 0.000 1.000
#> GSM252471     2  0.0000      0.953 0.000 1.000
#> GSM252465     2  0.0000      0.953 0.000 1.000
#> GSM252474     2  0.0672      0.948 0.008 0.992
#> GSM252473     2  0.0000      0.953 0.000 1.000
#> GSM252468     2  0.0000      0.953 0.000 1.000
#> GSM252470     2  0.1633      0.933 0.024 0.976
#> GSM252467     2  0.0000      0.953 0.000 1.000
#> GSM252485     2  0.0000      0.953 0.000 1.000
#> GSM252481     2  0.0000      0.953 0.000 1.000
#> GSM252480     2  0.0000      0.953 0.000 1.000
#> GSM252479     2  0.0000      0.953 0.000 1.000
#> GSM252482     2  0.0672      0.948 0.008 0.992
#> GSM252478     2  0.0000      0.953 0.000 1.000
#> GSM252483     2  0.0672      0.948 0.008 0.992
#> GSM252477     2  0.0672      0.948 0.008 0.992
#> GSM252484     2  0.0000      0.953 0.000 1.000
#> GSM252476     2  0.0000      0.953 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.6151      0.884 0.056 0.180 0.764
#> GSM252429     3  0.6151      0.884 0.056 0.180 0.764
#> GSM252424     3  0.6098      0.883 0.056 0.176 0.768
#> GSM252432     3  0.6151      0.884 0.056 0.180 0.764
#> GSM252427     3  0.7091      0.843 0.124 0.152 0.724
#> GSM252431     3  0.6420      0.793 0.024 0.288 0.688
#> GSM252430     3  0.6410      0.504 0.004 0.420 0.576
#> GSM252433     3  0.8241      0.742 0.204 0.160 0.636
#> GSM252426     3  0.6192      0.883 0.060 0.176 0.764
#> GSM252428     3  0.6541      0.867 0.056 0.212 0.732
#> GSM252425     3  0.8203      0.609 0.268 0.116 0.616
#> GSM252440     1  0.0237      0.889 0.996 0.000 0.004
#> GSM252441     1  0.0237      0.889 0.996 0.000 0.004
#> GSM252436     1  0.0424      0.890 0.992 0.000 0.008
#> GSM252435     1  0.0892      0.890 0.980 0.000 0.020
#> GSM252442     1  0.2066      0.879 0.940 0.000 0.060
#> GSM252439     1  0.0747      0.885 0.984 0.000 0.016
#> GSM252438     1  0.5621      0.625 0.692 0.000 0.308
#> GSM252434     1  0.1163      0.888 0.972 0.000 0.028
#> GSM252437     1  0.1163      0.888 0.972 0.000 0.028
#> GSM252451     1  0.0237      0.889 0.996 0.000 0.004
#> GSM252448     1  0.0237      0.889 0.996 0.000 0.004
#> GSM252447     1  0.0237      0.889 0.996 0.000 0.004
#> GSM252444     1  0.0424      0.890 0.992 0.000 0.008
#> GSM252450     1  0.0424      0.890 0.992 0.000 0.008
#> GSM252452     1  0.1753      0.876 0.952 0.000 0.048
#> GSM252443     1  0.0747      0.885 0.984 0.000 0.016
#> GSM252454     1  0.0237      0.890 0.996 0.000 0.004
#> GSM252449     1  0.1163      0.888 0.972 0.000 0.028
#> GSM252445     1  0.1163      0.888 0.972 0.000 0.028
#> GSM252453     1  0.0592      0.888 0.988 0.000 0.012
#> GSM252464     1  0.5397      0.681 0.720 0.000 0.280
#> GSM252463     1  0.5016      0.724 0.760 0.000 0.240
#> GSM252461     1  0.1964      0.879 0.944 0.000 0.056
#> GSM252455     1  0.4931      0.731 0.768 0.000 0.232
#> GSM252458     1  0.6247      0.504 0.620 0.004 0.376
#> GSM252460     1  0.5706      0.635 0.680 0.000 0.320
#> GSM252457     1  0.6950      0.309 0.572 0.020 0.408
#> GSM252456     1  0.5431      0.678 0.716 0.000 0.284
#> GSM252462     1  0.1753      0.883 0.952 0.000 0.048
#> GSM252459     1  0.3752      0.798 0.856 0.000 0.144
#> GSM252472     2  0.0000      0.983 0.000 1.000 0.000
#> GSM252466     2  0.0000      0.983 0.000 1.000 0.000
#> GSM252469     2  0.0000      0.983 0.000 1.000 0.000
#> GSM252475     2  0.0000      0.983 0.000 1.000 0.000
#> GSM252471     2  0.0000      0.983 0.000 1.000 0.000
#> GSM252465     2  0.0424      0.977 0.000 0.992 0.008
#> GSM252474     2  0.2165      0.937 0.000 0.936 0.064
#> GSM252473     2  0.0000      0.983 0.000 1.000 0.000
#> GSM252468     2  0.0000      0.983 0.000 1.000 0.000
#> GSM252470     2  0.1182      0.959 0.012 0.976 0.012
#> GSM252467     2  0.0000      0.983 0.000 1.000 0.000
#> GSM252485     2  0.0000      0.983 0.000 1.000 0.000
#> GSM252481     2  0.0000      0.983 0.000 1.000 0.000
#> GSM252480     2  0.0000      0.983 0.000 1.000 0.000
#> GSM252479     2  0.0000      0.983 0.000 1.000 0.000
#> GSM252482     2  0.2165      0.937 0.000 0.936 0.064
#> GSM252478     2  0.0424      0.977 0.000 0.992 0.008
#> GSM252483     2  0.2165      0.937 0.000 0.936 0.064
#> GSM252477     2  0.2165      0.937 0.000 0.936 0.064
#> GSM252484     2  0.0000      0.983 0.000 1.000 0.000
#> GSM252476     2  0.0000      0.983 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.1733     0.8125 0.028 0.024 0.948 0.000
#> GSM252429     3  0.1733     0.8125 0.028 0.024 0.948 0.000
#> GSM252424     3  0.1920     0.8118 0.028 0.024 0.944 0.004
#> GSM252432     3  0.1733     0.8125 0.028 0.024 0.948 0.000
#> GSM252427     3  0.4094     0.7493 0.076 0.024 0.852 0.048
#> GSM252431     3  0.4579     0.6477 0.000 0.200 0.768 0.032
#> GSM252430     3  0.5254     0.4466 0.000 0.300 0.672 0.028
#> GSM252433     3  0.5645     0.4847 0.012 0.020 0.640 0.328
#> GSM252426     3  0.2197     0.8103 0.028 0.024 0.936 0.012
#> GSM252428     3  0.3527     0.7808 0.024 0.088 0.872 0.016
#> GSM252425     3  0.6277     0.4596 0.232 0.060 0.680 0.028
#> GSM252440     1  0.0188     0.8053 0.996 0.000 0.000 0.004
#> GSM252441     1  0.0188     0.8053 0.996 0.000 0.000 0.004
#> GSM252436     1  0.0524     0.8078 0.988 0.000 0.004 0.008
#> GSM252435     1  0.1854     0.7982 0.940 0.000 0.012 0.048
#> GSM252442     1  0.3612     0.7573 0.856 0.000 0.044 0.100
#> GSM252439     1  0.1637     0.7692 0.940 0.000 0.000 0.060
#> GSM252438     4  0.4164     0.0000 0.264 0.000 0.000 0.736
#> GSM252434     1  0.1520     0.8060 0.956 0.000 0.024 0.020
#> GSM252437     1  0.1733     0.8046 0.948 0.000 0.024 0.028
#> GSM252451     1  0.0188     0.8053 0.996 0.000 0.000 0.004
#> GSM252448     1  0.0188     0.8053 0.996 0.000 0.000 0.004
#> GSM252447     1  0.0188     0.8053 0.996 0.000 0.000 0.004
#> GSM252444     1  0.0524     0.8078 0.988 0.000 0.004 0.008
#> GSM252450     1  0.0657     0.8065 0.984 0.000 0.004 0.012
#> GSM252452     1  0.1820     0.7838 0.944 0.000 0.036 0.020
#> GSM252443     1  0.1637     0.7734 0.940 0.000 0.000 0.060
#> GSM252454     1  0.0817     0.8064 0.976 0.000 0.000 0.024
#> GSM252449     1  0.1520     0.8060 0.956 0.000 0.024 0.020
#> GSM252445     1  0.1733     0.8046 0.948 0.000 0.024 0.028
#> GSM252453     1  0.1151     0.8003 0.968 0.000 0.008 0.024
#> GSM252464     1  0.7082     0.4478 0.564 0.000 0.184 0.252
#> GSM252463     1  0.6690     0.5077 0.608 0.000 0.144 0.248
#> GSM252461     1  0.3505     0.7569 0.864 0.000 0.048 0.088
#> GSM252455     1  0.6542     0.5197 0.620 0.000 0.128 0.252
#> GSM252458     1  0.7520     0.3047 0.492 0.000 0.280 0.228
#> GSM252460     1  0.7407     0.3752 0.516 0.000 0.224 0.260
#> GSM252457     1  0.7152     0.0765 0.512 0.004 0.360 0.124
#> GSM252456     1  0.7059     0.4577 0.568 0.000 0.184 0.248
#> GSM252462     1  0.2313     0.7977 0.924 0.000 0.044 0.032
#> GSM252459     1  0.3711     0.6673 0.836 0.000 0.140 0.024
#> GSM252472     2  0.0000     0.9631 0.000 1.000 0.000 0.000
#> GSM252466     2  0.0000     0.9631 0.000 1.000 0.000 0.000
#> GSM252469     2  0.0000     0.9631 0.000 1.000 0.000 0.000
#> GSM252475     2  0.0000     0.9631 0.000 1.000 0.000 0.000
#> GSM252471     2  0.0000     0.9631 0.000 1.000 0.000 0.000
#> GSM252465     2  0.0376     0.9586 0.000 0.992 0.004 0.004
#> GSM252474     2  0.3479     0.8431 0.000 0.840 0.148 0.012
#> GSM252473     2  0.0000     0.9631 0.000 1.000 0.000 0.000
#> GSM252468     2  0.0000     0.9631 0.000 1.000 0.000 0.000
#> GSM252470     2  0.1007     0.9453 0.008 0.976 0.008 0.008
#> GSM252467     2  0.0000     0.9631 0.000 1.000 0.000 0.000
#> GSM252485     2  0.0000     0.9631 0.000 1.000 0.000 0.000
#> GSM252481     2  0.0000     0.9631 0.000 1.000 0.000 0.000
#> GSM252480     2  0.0000     0.9631 0.000 1.000 0.000 0.000
#> GSM252479     2  0.0000     0.9631 0.000 1.000 0.000 0.000
#> GSM252482     2  0.3479     0.8431 0.000 0.840 0.148 0.012
#> GSM252478     2  0.0937     0.9482 0.000 0.976 0.012 0.012
#> GSM252483     2  0.3479     0.8431 0.000 0.840 0.148 0.012
#> GSM252477     2  0.3479     0.8431 0.000 0.840 0.148 0.012
#> GSM252484     2  0.0000     0.9631 0.000 1.000 0.000 0.000
#> GSM252476     2  0.0000     0.9631 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.0324      0.801 0.004 0.000 0.992 0.000 0.004
#> GSM252429     3  0.0324      0.801 0.004 0.000 0.992 0.000 0.004
#> GSM252424     3  0.0162      0.800 0.004 0.000 0.996 0.000 0.000
#> GSM252432     3  0.0324      0.801 0.004 0.000 0.992 0.000 0.004
#> GSM252427     3  0.3080      0.711 0.020 0.000 0.852 0.004 0.124
#> GSM252431     3  0.4863      0.595 0.000 0.176 0.740 0.020 0.064
#> GSM252430     3  0.6211      0.360 0.000 0.128 0.564 0.012 0.296
#> GSM252433     3  0.4418      0.456 0.000 0.000 0.652 0.332 0.016
#> GSM252426     3  0.0451      0.799 0.004 0.000 0.988 0.000 0.008
#> GSM252428     3  0.2457      0.766 0.008 0.060 0.908 0.004 0.020
#> GSM252425     3  0.6176      0.504 0.172 0.044 0.680 0.024 0.080
#> GSM252440     1  0.0404      0.756 0.988 0.000 0.000 0.000 0.012
#> GSM252441     1  0.0290      0.755 0.992 0.000 0.000 0.000 0.008
#> GSM252436     1  0.1965      0.736 0.904 0.000 0.000 0.000 0.096
#> GSM252435     1  0.2722      0.700 0.868 0.000 0.004 0.008 0.120
#> GSM252442     1  0.4240      0.412 0.700 0.000 0.012 0.004 0.284
#> GSM252439     1  0.4269      0.525 0.756 0.000 0.000 0.188 0.056
#> GSM252438     4  0.0880      0.000 0.032 0.000 0.000 0.968 0.000
#> GSM252434     1  0.2763      0.701 0.848 0.000 0.004 0.000 0.148
#> GSM252437     1  0.2833      0.706 0.852 0.000 0.004 0.004 0.140
#> GSM252451     1  0.0404      0.756 0.988 0.000 0.000 0.000 0.012
#> GSM252448     1  0.0404      0.756 0.988 0.000 0.000 0.000 0.012
#> GSM252447     1  0.0290      0.755 0.992 0.000 0.000 0.000 0.008
#> GSM252444     1  0.1965      0.736 0.904 0.000 0.000 0.000 0.096
#> GSM252450     1  0.1809      0.750 0.928 0.000 0.000 0.012 0.060
#> GSM252452     1  0.2536      0.681 0.868 0.000 0.004 0.000 0.128
#> GSM252443     1  0.4465      0.500 0.736 0.000 0.000 0.204 0.060
#> GSM252454     1  0.1741      0.754 0.936 0.000 0.000 0.024 0.040
#> GSM252449     1  0.2763      0.701 0.848 0.000 0.004 0.000 0.148
#> GSM252445     1  0.2833      0.706 0.852 0.000 0.004 0.004 0.140
#> GSM252453     1  0.2208      0.726 0.908 0.000 0.000 0.020 0.072
#> GSM252464     5  0.5858      0.854 0.308 0.000 0.124 0.000 0.568
#> GSM252463     5  0.5611      0.809 0.380 0.000 0.060 0.008 0.552
#> GSM252461     1  0.4573      0.314 0.688 0.000 0.028 0.004 0.280
#> GSM252455     5  0.5188      0.755 0.416 0.000 0.044 0.000 0.540
#> GSM252458     5  0.6674      0.749 0.336 0.000 0.208 0.004 0.452
#> GSM252460     5  0.6301      0.816 0.276 0.000 0.148 0.012 0.564
#> GSM252457     1  0.8251     -0.295 0.336 0.000 0.328 0.192 0.144
#> GSM252456     5  0.5785      0.859 0.320 0.000 0.112 0.000 0.568
#> GSM252462     1  0.3752      0.610 0.780 0.000 0.016 0.004 0.200
#> GSM252459     1  0.4524      0.561 0.776 0.000 0.128 0.016 0.080
#> GSM252472     2  0.0162      0.923 0.000 0.996 0.000 0.004 0.000
#> GSM252466     2  0.0000      0.924 0.000 1.000 0.000 0.000 0.000
#> GSM252469     2  0.0000      0.924 0.000 1.000 0.000 0.000 0.000
#> GSM252475     2  0.0000      0.924 0.000 1.000 0.000 0.000 0.000
#> GSM252471     2  0.0162      0.923 0.000 0.996 0.000 0.004 0.000
#> GSM252465     2  0.0693      0.915 0.000 0.980 0.000 0.012 0.008
#> GSM252474     2  0.4914      0.636 0.000 0.672 0.040 0.008 0.280
#> GSM252473     2  0.0290      0.922 0.000 0.992 0.000 0.008 0.000
#> GSM252468     2  0.0000      0.924 0.000 1.000 0.000 0.000 0.000
#> GSM252470     2  0.1143      0.905 0.008 0.968 0.004 0.008 0.012
#> GSM252467     2  0.0000      0.924 0.000 1.000 0.000 0.000 0.000
#> GSM252485     2  0.0290      0.922 0.000 0.992 0.000 0.008 0.000
#> GSM252481     2  0.0000      0.924 0.000 1.000 0.000 0.000 0.000
#> GSM252480     2  0.0000      0.924 0.000 1.000 0.000 0.000 0.000
#> GSM252479     2  0.0000      0.924 0.000 1.000 0.000 0.000 0.000
#> GSM252482     2  0.4914      0.636 0.000 0.672 0.040 0.008 0.280
#> GSM252478     2  0.1485      0.892 0.000 0.948 0.000 0.020 0.032
#> GSM252483     2  0.4914      0.636 0.000 0.672 0.040 0.008 0.280
#> GSM252477     2  0.4914      0.636 0.000 0.672 0.040 0.008 0.280
#> GSM252484     2  0.0000      0.924 0.000 1.000 0.000 0.000 0.000
#> GSM252476     2  0.0000      0.924 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.0260     0.8267 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM252429     3  0.0993     0.8198 0.000 0.000 0.964 0.012 0.024 0.000
#> GSM252424     3  0.0291     0.8262 0.000 0.000 0.992 0.004 0.004 0.000
#> GSM252432     3  0.0260     0.8267 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM252427     3  0.3123     0.7198 0.000 0.000 0.824 0.136 0.040 0.000
#> GSM252431     3  0.4865     0.5945 0.000 0.176 0.716 0.040 0.064 0.004
#> GSM252430     5  0.4331    -0.3440 0.000 0.020 0.464 0.000 0.516 0.000
#> GSM252433     3  0.4855     0.3898 0.000 0.000 0.596 0.000 0.076 0.328
#> GSM252426     3  0.0508     0.8251 0.000 0.000 0.984 0.012 0.004 0.000
#> GSM252428     3  0.2401     0.7886 0.004 0.060 0.900 0.020 0.016 0.000
#> GSM252425     3  0.6109     0.5472 0.096 0.032 0.660 0.132 0.076 0.004
#> GSM252440     1  0.1649     0.6519 0.932 0.000 0.000 0.036 0.032 0.000
#> GSM252441     1  0.1575     0.6512 0.936 0.000 0.000 0.032 0.032 0.000
#> GSM252436     1  0.2553     0.6188 0.848 0.000 0.000 0.144 0.008 0.000
#> GSM252435     1  0.3017     0.6039 0.816 0.000 0.000 0.164 0.020 0.000
#> GSM252442     1  0.4423     0.2447 0.608 0.000 0.004 0.360 0.028 0.000
#> GSM252439     1  0.6117     0.4017 0.596 0.000 0.000 0.136 0.080 0.188
#> GSM252438     6  0.0146     0.0000 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM252434     1  0.3374     0.5539 0.772 0.000 0.000 0.208 0.020 0.000
#> GSM252437     1  0.4459     0.5293 0.700 0.000 0.000 0.204 0.096 0.000
#> GSM252451     1  0.1151     0.6569 0.956 0.000 0.000 0.032 0.012 0.000
#> GSM252448     1  0.1649     0.6519 0.932 0.000 0.000 0.036 0.032 0.000
#> GSM252447     1  0.1575     0.6512 0.936 0.000 0.000 0.032 0.032 0.000
#> GSM252444     1  0.2553     0.6188 0.848 0.000 0.000 0.144 0.008 0.000
#> GSM252450     1  0.2505     0.6478 0.880 0.000 0.000 0.092 0.020 0.008
#> GSM252452     1  0.5469     0.4049 0.568 0.000 0.000 0.284 0.144 0.004
#> GSM252443     1  0.5977     0.4138 0.600 0.000 0.000 0.136 0.060 0.204
#> GSM252454     1  0.3099     0.6425 0.848 0.000 0.000 0.084 0.060 0.008
#> GSM252449     1  0.3374     0.5539 0.772 0.000 0.000 0.208 0.020 0.000
#> GSM252445     1  0.4431     0.5277 0.704 0.000 0.000 0.200 0.096 0.000
#> GSM252453     1  0.3766     0.5941 0.784 0.000 0.000 0.144 0.068 0.004
#> GSM252464     4  0.4324     0.8522 0.192 0.000 0.080 0.724 0.004 0.000
#> GSM252463     4  0.4057     0.8169 0.268 0.000 0.016 0.704 0.008 0.004
#> GSM252461     1  0.4489     0.0668 0.568 0.000 0.008 0.404 0.020 0.000
#> GSM252455     4  0.3933     0.7649 0.308 0.000 0.008 0.676 0.008 0.000
#> GSM252458     4  0.6068     0.7445 0.232 0.000 0.164 0.564 0.040 0.000
#> GSM252460     4  0.5046     0.8178 0.172 0.000 0.092 0.700 0.032 0.004
#> GSM252457     1  0.8733    -0.2283 0.260 0.000 0.248 0.204 0.100 0.188
#> GSM252456     4  0.4178     0.8582 0.208 0.000 0.060 0.728 0.004 0.000
#> GSM252462     1  0.5004     0.3932 0.624 0.000 0.004 0.276 0.096 0.000
#> GSM252459     1  0.5778     0.4801 0.656 0.000 0.108 0.136 0.096 0.004
#> GSM252472     2  0.0458     0.9695 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM252466     2  0.0000     0.9755 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252469     2  0.0000     0.9755 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252475     2  0.0260     0.9685 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM252471     2  0.0363     0.9711 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM252465     2  0.1075     0.9365 0.000 0.952 0.000 0.000 0.048 0.000
#> GSM252474     5  0.3979     0.7483 0.000 0.456 0.004 0.000 0.540 0.000
#> GSM252473     2  0.0458     0.9693 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM252468     2  0.0000     0.9755 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252470     2  0.1218     0.9411 0.004 0.956 0.000 0.012 0.028 0.000
#> GSM252467     2  0.0000     0.9755 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252485     2  0.0547     0.9665 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM252481     2  0.0000     0.9755 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252480     2  0.0000     0.9755 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252479     2  0.0146     0.9743 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM252482     5  0.3979     0.7483 0.000 0.456 0.004 0.000 0.540 0.000
#> GSM252478     2  0.1863     0.8517 0.000 0.896 0.000 0.000 0.104 0.000
#> GSM252483     5  0.3979     0.7483 0.000 0.456 0.004 0.000 0.540 0.000
#> GSM252477     5  0.3979     0.7483 0.000 0.456 0.004 0.000 0.540 0.000
#> GSM252484     2  0.0000     0.9755 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252476     2  0.0000     0.9755 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)

plot of chunk tab-MAD-hclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-hclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-hclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-hclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-hclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-hclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-hclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-hclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-hclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-hclust-membership-heatmap-5

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)

plot of chunk tab-MAD-hclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-hclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-hclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-hclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-hclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-hclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-hclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-hclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-hclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-hclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-hclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-MAD-hclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-hclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-hclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-hclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-hclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-hclust-collect-classes

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 agent(p) individual(p) k
#> MAD:hclust 52 5.39e-10         1.000 2
#> MAD:hclust 61 1.99e-21         1.000 3
#> MAD:hclust 53 3.41e-18         1.000 4
#> MAD:hclust 56 2.64e-24         1.000 5
#> MAD:hclust 51 3.39e-23         0.581 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.


MAD:kmeans

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 51941 rows and 62 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 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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:

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)

plot of chunk MAD-kmeans-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.768           0.827       0.933         0.4906 0.518   0.518
#> 3 3 0.890           0.926       0.949         0.3044 0.814   0.651
#> 4 4 0.780           0.736       0.851         0.1196 0.947   0.853
#> 5 5 0.710           0.656       0.796         0.0640 0.937   0.799
#> 6 6 0.716           0.725       0.778         0.0526 0.923   0.714

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 3

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1   0.995      0.279 0.540 0.460
#> GSM252429     1   0.995      0.279 0.540 0.460
#> GSM252424     1   0.995      0.279 0.540 0.460
#> GSM252432     1   0.995      0.279 0.540 0.460
#> GSM252427     1   0.995      0.279 0.540 0.460
#> GSM252431     1   0.995      0.279 0.540 0.460
#> GSM252430     2   0.163      0.949 0.024 0.976
#> GSM252433     2   0.994     -0.048 0.456 0.544
#> GSM252426     1   0.995      0.279 0.540 0.460
#> GSM252428     1   0.995      0.279 0.540 0.460
#> GSM252425     2   0.000      0.975 0.000 1.000
#> GSM252440     1   0.000      0.890 1.000 0.000
#> GSM252441     1   0.000      0.890 1.000 0.000
#> GSM252436     1   0.000      0.890 1.000 0.000
#> GSM252435     1   0.000      0.890 1.000 0.000
#> GSM252442     1   0.000      0.890 1.000 0.000
#> GSM252439     1   0.000      0.890 1.000 0.000
#> GSM252438     1   0.000      0.890 1.000 0.000
#> GSM252434     1   0.000      0.890 1.000 0.000
#> GSM252437     1   0.000      0.890 1.000 0.000
#> GSM252451     1   0.000      0.890 1.000 0.000
#> GSM252448     1   0.000      0.890 1.000 0.000
#> GSM252447     1   0.000      0.890 1.000 0.000
#> GSM252444     1   0.000      0.890 1.000 0.000
#> GSM252450     1   0.000      0.890 1.000 0.000
#> GSM252452     1   0.000      0.890 1.000 0.000
#> GSM252443     1   0.000      0.890 1.000 0.000
#> GSM252454     1   0.000      0.890 1.000 0.000
#> GSM252449     1   0.000      0.890 1.000 0.000
#> GSM252445     1   0.000      0.890 1.000 0.000
#> GSM252453     1   0.000      0.890 1.000 0.000
#> GSM252464     1   0.000      0.890 1.000 0.000
#> GSM252463     1   0.000      0.890 1.000 0.000
#> GSM252461     1   0.000      0.890 1.000 0.000
#> GSM252455     1   0.000      0.890 1.000 0.000
#> GSM252458     1   0.000      0.890 1.000 0.000
#> GSM252460     1   0.000      0.890 1.000 0.000
#> GSM252457     1   0.000      0.890 1.000 0.000
#> GSM252456     1   0.000      0.890 1.000 0.000
#> GSM252462     1   0.000      0.890 1.000 0.000
#> GSM252459     1   0.000      0.890 1.000 0.000
#> GSM252472     2   0.000      0.975 0.000 1.000
#> GSM252466     2   0.000      0.975 0.000 1.000
#> GSM252469     2   0.000      0.975 0.000 1.000
#> GSM252475     2   0.000      0.975 0.000 1.000
#> GSM252471     2   0.000      0.975 0.000 1.000
#> GSM252465     2   0.000      0.975 0.000 1.000
#> GSM252474     2   0.000      0.975 0.000 1.000
#> GSM252473     2   0.000      0.975 0.000 1.000
#> GSM252468     2   0.000      0.975 0.000 1.000
#> GSM252470     2   0.000      0.975 0.000 1.000
#> GSM252467     2   0.000      0.975 0.000 1.000
#> GSM252485     2   0.000      0.975 0.000 1.000
#> GSM252481     2   0.000      0.975 0.000 1.000
#> GSM252480     2   0.000      0.975 0.000 1.000
#> GSM252479     2   0.000      0.975 0.000 1.000
#> GSM252482     2   0.000      0.975 0.000 1.000
#> GSM252478     2   0.000      0.975 0.000 1.000
#> GSM252483     2   0.000      0.975 0.000 1.000
#> GSM252477     2   0.000      0.975 0.000 1.000
#> GSM252484     2   0.000      0.975 0.000 1.000
#> GSM252476     2   0.000      0.975 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.3998      0.965 0.056 0.060 0.884
#> GSM252429     3  0.3998      0.965 0.056 0.060 0.884
#> GSM252424     3  0.3998      0.965 0.056 0.060 0.884
#> GSM252432     3  0.3998      0.965 0.056 0.060 0.884
#> GSM252427     3  0.3998      0.965 0.056 0.060 0.884
#> GSM252431     3  0.3998      0.965 0.056 0.060 0.884
#> GSM252430     3  0.0592      0.903 0.000 0.012 0.988
#> GSM252433     3  0.0592      0.903 0.000 0.012 0.988
#> GSM252426     3  0.3998      0.965 0.056 0.060 0.884
#> GSM252428     3  0.3998      0.965 0.056 0.060 0.884
#> GSM252425     3  0.3340      0.902 0.000 0.120 0.880
#> GSM252440     1  0.0000      0.941 1.000 0.000 0.000
#> GSM252441     1  0.0000      0.941 1.000 0.000 0.000
#> GSM252436     1  0.0000      0.941 1.000 0.000 0.000
#> GSM252435     1  0.0000      0.941 1.000 0.000 0.000
#> GSM252442     1  0.0237      0.940 0.996 0.000 0.004
#> GSM252439     1  0.0424      0.938 0.992 0.000 0.008
#> GSM252438     1  0.0592      0.937 0.988 0.000 0.012
#> GSM252434     1  0.0237      0.940 0.996 0.000 0.004
#> GSM252437     1  0.0000      0.941 1.000 0.000 0.000
#> GSM252451     1  0.0000      0.941 1.000 0.000 0.000
#> GSM252448     1  0.0000      0.941 1.000 0.000 0.000
#> GSM252447     1  0.0000      0.941 1.000 0.000 0.000
#> GSM252444     1  0.0000      0.941 1.000 0.000 0.000
#> GSM252450     1  0.0000      0.941 1.000 0.000 0.000
#> GSM252452     1  0.0000      0.941 1.000 0.000 0.000
#> GSM252443     1  0.0424      0.938 0.992 0.000 0.008
#> GSM252454     1  0.0424      0.938 0.992 0.000 0.008
#> GSM252449     1  0.0237      0.940 0.996 0.000 0.004
#> GSM252445     1  0.0000      0.941 1.000 0.000 0.000
#> GSM252453     1  0.0237      0.940 0.996 0.000 0.004
#> GSM252464     1  0.5397      0.647 0.720 0.000 0.280
#> GSM252463     1  0.4931      0.716 0.768 0.000 0.232
#> GSM252461     1  0.0237      0.940 0.996 0.000 0.004
#> GSM252455     1  0.1964      0.903 0.944 0.000 0.056
#> GSM252458     1  0.5465      0.634 0.712 0.000 0.288
#> GSM252460     1  0.5465      0.634 0.712 0.000 0.288
#> GSM252457     3  0.3482      0.875 0.128 0.000 0.872
#> GSM252456     1  0.5465      0.634 0.712 0.000 0.288
#> GSM252462     1  0.0892      0.931 0.980 0.000 0.020
#> GSM252459     1  0.0424      0.939 0.992 0.000 0.008
#> GSM252472     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252466     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252469     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252475     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252471     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252465     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252474     2  0.3038      0.913 0.000 0.896 0.104
#> GSM252473     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252468     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252470     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252467     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252485     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252481     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252480     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252479     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252482     2  0.3038      0.913 0.000 0.896 0.104
#> GSM252478     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252483     2  0.3038      0.913 0.000 0.896 0.104
#> GSM252477     2  0.3038      0.913 0.000 0.896 0.104
#> GSM252484     2  0.0000      0.980 0.000 1.000 0.000
#> GSM252476     2  0.0000      0.980 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.0376     0.8936 0.004 0.000 0.992 0.004
#> GSM252429     3  0.0524     0.8926 0.004 0.000 0.988 0.008
#> GSM252424     3  0.0188     0.8936 0.004 0.000 0.996 0.000
#> GSM252432     3  0.0376     0.8936 0.004 0.000 0.992 0.004
#> GSM252427     3  0.0188     0.8936 0.004 0.000 0.996 0.000
#> GSM252431     3  0.0592     0.8885 0.000 0.000 0.984 0.016
#> GSM252430     3  0.4746     0.6102 0.000 0.000 0.632 0.368
#> GSM252433     3  0.3444     0.7818 0.000 0.000 0.816 0.184
#> GSM252426     3  0.0188     0.8936 0.004 0.000 0.996 0.000
#> GSM252428     3  0.0657     0.8903 0.004 0.000 0.984 0.012
#> GSM252425     3  0.2450     0.8252 0.000 0.072 0.912 0.016
#> GSM252440     1  0.0336     0.7750 0.992 0.000 0.000 0.008
#> GSM252441     1  0.0336     0.7750 0.992 0.000 0.000 0.008
#> GSM252436     1  0.0336     0.7754 0.992 0.000 0.000 0.008
#> GSM252435     1  0.0817     0.7733 0.976 0.000 0.000 0.024
#> GSM252442     1  0.2973     0.6927 0.856 0.000 0.000 0.144
#> GSM252439     1  0.3751     0.6300 0.800 0.000 0.004 0.196
#> GSM252438     1  0.4155     0.5848 0.756 0.000 0.004 0.240
#> GSM252434     1  0.2921     0.6973 0.860 0.000 0.000 0.140
#> GSM252437     1  0.1557     0.7653 0.944 0.000 0.000 0.056
#> GSM252451     1  0.0336     0.7754 0.992 0.000 0.000 0.008
#> GSM252448     1  0.0336     0.7750 0.992 0.000 0.000 0.008
#> GSM252447     1  0.0336     0.7750 0.992 0.000 0.000 0.008
#> GSM252444     1  0.0336     0.7754 0.992 0.000 0.000 0.008
#> GSM252450     1  0.0817     0.7733 0.976 0.000 0.000 0.024
#> GSM252452     1  0.2944     0.7439 0.868 0.000 0.004 0.128
#> GSM252443     1  0.3157     0.6823 0.852 0.000 0.004 0.144
#> GSM252454     1  0.2593     0.7238 0.892 0.000 0.004 0.104
#> GSM252449     1  0.2921     0.6973 0.860 0.000 0.000 0.140
#> GSM252445     1  0.1557     0.7631 0.944 0.000 0.000 0.056
#> GSM252453     1  0.1824     0.7643 0.936 0.000 0.004 0.060
#> GSM252464     4  0.7839     0.9488 0.352 0.000 0.264 0.384
#> GSM252463     1  0.7774    -0.9003 0.388 0.000 0.240 0.372
#> GSM252461     1  0.4730     0.0934 0.636 0.000 0.000 0.364
#> GSM252455     1  0.6532    -0.3582 0.548 0.000 0.084 0.368
#> GSM252458     4  0.7863     0.9602 0.344 0.000 0.276 0.380
#> GSM252460     4  0.7877     0.9185 0.304 0.000 0.308 0.388
#> GSM252457     3  0.5538     0.4828 0.036 0.000 0.644 0.320
#> GSM252456     4  0.7856     0.9592 0.336 0.000 0.276 0.388
#> GSM252462     1  0.6376    -0.3053 0.536 0.000 0.068 0.396
#> GSM252459     1  0.4655     0.3977 0.684 0.000 0.004 0.312
#> GSM252472     2  0.1118     0.9169 0.000 0.964 0.000 0.036
#> GSM252466     2  0.0817     0.9185 0.000 0.976 0.000 0.024
#> GSM252469     2  0.0707     0.9187 0.000 0.980 0.000 0.020
#> GSM252475     2  0.0000     0.9195 0.000 1.000 0.000 0.000
#> GSM252471     2  0.1022     0.9177 0.000 0.968 0.000 0.032
#> GSM252465     2  0.1474     0.9095 0.000 0.948 0.000 0.052
#> GSM252474     2  0.4679     0.6862 0.000 0.648 0.000 0.352
#> GSM252473     2  0.0817     0.9187 0.000 0.976 0.000 0.024
#> GSM252468     2  0.0817     0.9187 0.000 0.976 0.000 0.024
#> GSM252470     2  0.1474     0.9148 0.000 0.948 0.000 0.052
#> GSM252467     2  0.0817     0.9185 0.000 0.976 0.000 0.024
#> GSM252485     2  0.1118     0.9169 0.000 0.964 0.000 0.036
#> GSM252481     2  0.0817     0.9185 0.000 0.976 0.000 0.024
#> GSM252480     2  0.0817     0.9185 0.000 0.976 0.000 0.024
#> GSM252479     2  0.0592     0.9191 0.000 0.984 0.000 0.016
#> GSM252482     2  0.4679     0.6857 0.000 0.648 0.000 0.352
#> GSM252478     2  0.1716     0.9063 0.000 0.936 0.000 0.064
#> GSM252483     2  0.4679     0.6857 0.000 0.648 0.000 0.352
#> GSM252477     2  0.4679     0.6857 0.000 0.648 0.000 0.352
#> GSM252484     2  0.0817     0.9196 0.000 0.976 0.000 0.024
#> GSM252476     2  0.0817     0.9185 0.000 0.976 0.000 0.024

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.0451    0.85797 0.000 0.000 0.988 0.004 0.008
#> GSM252429     3  0.0290    0.85818 0.000 0.000 0.992 0.000 0.008
#> GSM252424     3  0.0000    0.85834 0.000 0.000 1.000 0.000 0.000
#> GSM252432     3  0.0451    0.85797 0.000 0.000 0.988 0.004 0.008
#> GSM252427     3  0.0000    0.85834 0.000 0.000 1.000 0.000 0.000
#> GSM252431     3  0.1701    0.84191 0.000 0.000 0.936 0.048 0.016
#> GSM252430     3  0.4497    0.51876 0.000 0.000 0.568 0.008 0.424
#> GSM252433     3  0.5083    0.65728 0.000 0.000 0.696 0.120 0.184
#> GSM252426     3  0.0162    0.85798 0.000 0.000 0.996 0.000 0.004
#> GSM252428     3  0.0912    0.85243 0.000 0.000 0.972 0.012 0.016
#> GSM252425     3  0.3287    0.78091 0.000 0.068 0.864 0.052 0.016
#> GSM252440     1  0.1914    0.67861 0.924 0.000 0.000 0.016 0.060
#> GSM252441     1  0.1740    0.68431 0.932 0.000 0.000 0.012 0.056
#> GSM252436     1  0.1012    0.69934 0.968 0.000 0.000 0.012 0.020
#> GSM252435     1  0.2074    0.70280 0.920 0.000 0.000 0.044 0.036
#> GSM252442     1  0.3596    0.62483 0.784 0.000 0.000 0.200 0.016
#> GSM252439     1  0.6582   -0.87853 0.416 0.000 0.000 0.208 0.376
#> GSM252438     5  0.6655    0.00000 0.368 0.000 0.000 0.228 0.404
#> GSM252434     1  0.3527    0.63181 0.792 0.000 0.000 0.192 0.016
#> GSM252437     1  0.3192    0.67937 0.848 0.000 0.000 0.112 0.040
#> GSM252451     1  0.1018    0.70144 0.968 0.000 0.000 0.016 0.016
#> GSM252448     1  0.1914    0.67861 0.924 0.000 0.000 0.016 0.060
#> GSM252447     1  0.1740    0.68431 0.932 0.000 0.000 0.012 0.056
#> GSM252444     1  0.1012    0.69934 0.968 0.000 0.000 0.012 0.020
#> GSM252450     1  0.1408    0.70443 0.948 0.000 0.000 0.044 0.008
#> GSM252452     1  0.5567    0.31067 0.644 0.000 0.000 0.196 0.160
#> GSM252443     1  0.6101   -0.54016 0.528 0.000 0.000 0.144 0.328
#> GSM252454     1  0.5140    0.09042 0.664 0.000 0.000 0.084 0.252
#> GSM252449     1  0.3527    0.63181 0.792 0.000 0.000 0.192 0.016
#> GSM252445     1  0.2873    0.67731 0.860 0.000 0.000 0.120 0.020
#> GSM252453     1  0.2928    0.67461 0.872 0.000 0.000 0.064 0.064
#> GSM252464     4  0.5958    0.82358 0.208 0.000 0.200 0.592 0.000
#> GSM252463     4  0.6191    0.79740 0.264 0.000 0.168 0.564 0.004
#> GSM252461     4  0.4656    0.49011 0.480 0.000 0.000 0.508 0.012
#> GSM252455     4  0.5501    0.72418 0.360 0.000 0.064 0.572 0.004
#> GSM252458     4  0.6107    0.82134 0.204 0.000 0.204 0.588 0.004
#> GSM252460     4  0.5867    0.79971 0.180 0.000 0.216 0.604 0.000
#> GSM252457     3  0.7325    0.00927 0.024 0.000 0.372 0.324 0.280
#> GSM252456     4  0.5904    0.81895 0.196 0.000 0.204 0.600 0.000
#> GSM252462     4  0.5330    0.65583 0.352 0.000 0.040 0.596 0.012
#> GSM252459     1  0.5834    0.02776 0.548 0.000 0.004 0.356 0.092
#> GSM252472     2  0.2325    0.85321 0.000 0.904 0.000 0.068 0.028
#> GSM252466     2  0.1830    0.86467 0.000 0.932 0.000 0.040 0.028
#> GSM252469     2  0.1579    0.86587 0.000 0.944 0.000 0.032 0.024
#> GSM252475     2  0.1211    0.86796 0.000 0.960 0.000 0.024 0.016
#> GSM252471     2  0.1485    0.86267 0.000 0.948 0.000 0.032 0.020
#> GSM252465     2  0.2694    0.84028 0.000 0.884 0.000 0.076 0.040
#> GSM252474     2  0.4307    0.53565 0.000 0.500 0.000 0.000 0.500
#> GSM252473     2  0.1740    0.85928 0.000 0.932 0.000 0.056 0.012
#> GSM252468     2  0.1012    0.86513 0.000 0.968 0.000 0.020 0.012
#> GSM252470     2  0.1300    0.86224 0.000 0.956 0.000 0.016 0.028
#> GSM252467     2  0.1907    0.86566 0.000 0.928 0.000 0.044 0.028
#> GSM252485     2  0.2171    0.85442 0.000 0.912 0.000 0.064 0.024
#> GSM252481     2  0.1830    0.86467 0.000 0.932 0.000 0.040 0.028
#> GSM252480     2  0.1830    0.86415 0.000 0.932 0.000 0.040 0.028
#> GSM252479     2  0.1485    0.86730 0.000 0.948 0.000 0.032 0.020
#> GSM252482     2  0.4307    0.53693 0.000 0.504 0.000 0.000 0.496
#> GSM252478     2  0.3269    0.82554 0.000 0.848 0.000 0.096 0.056
#> GSM252483     2  0.4307    0.53565 0.000 0.500 0.000 0.000 0.500
#> GSM252477     2  0.4307    0.53693 0.000 0.504 0.000 0.000 0.496
#> GSM252484     2  0.0579    0.86675 0.000 0.984 0.000 0.008 0.008
#> GSM252476     2  0.1981    0.86569 0.000 0.924 0.000 0.048 0.028

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.1262      0.874 0.000 0.000 0.956 0.008 0.020 0.016
#> GSM252429     3  0.1448      0.872 0.000 0.000 0.948 0.012 0.024 0.016
#> GSM252424     3  0.0520      0.876 0.000 0.000 0.984 0.008 0.000 0.008
#> GSM252432     3  0.1065      0.874 0.000 0.000 0.964 0.008 0.020 0.008
#> GSM252427     3  0.0622      0.876 0.000 0.000 0.980 0.012 0.000 0.008
#> GSM252431     3  0.1528      0.860 0.000 0.000 0.944 0.016 0.028 0.012
#> GSM252430     3  0.5163      0.277 0.000 0.000 0.464 0.004 0.460 0.072
#> GSM252433     3  0.5117      0.466 0.000 0.000 0.604 0.016 0.068 0.312
#> GSM252426     3  0.0458      0.875 0.000 0.000 0.984 0.016 0.000 0.000
#> GSM252428     3  0.0984      0.871 0.000 0.000 0.968 0.012 0.012 0.008
#> GSM252425     3  0.2583      0.820 0.000 0.024 0.900 0.028 0.028 0.020
#> GSM252440     1  0.1390      0.714 0.948 0.000 0.000 0.004 0.016 0.032
#> GSM252441     1  0.1074      0.718 0.960 0.000 0.000 0.000 0.012 0.028
#> GSM252436     1  0.0622      0.732 0.980 0.000 0.000 0.012 0.008 0.000
#> GSM252435     1  0.3229      0.731 0.852 0.000 0.000 0.064 0.040 0.044
#> GSM252442     1  0.5919      0.611 0.604 0.000 0.000 0.224 0.096 0.076
#> GSM252439     6  0.3721      0.661 0.252 0.000 0.000 0.016 0.004 0.728
#> GSM252438     6  0.4465      0.684 0.172 0.000 0.000 0.048 0.040 0.740
#> GSM252434     1  0.5745      0.624 0.620 0.000 0.000 0.224 0.080 0.076
#> GSM252437     1  0.5157      0.683 0.700 0.000 0.000 0.148 0.080 0.072
#> GSM252451     1  0.0725      0.734 0.976 0.000 0.000 0.012 0.012 0.000
#> GSM252448     1  0.1390      0.714 0.948 0.000 0.000 0.004 0.016 0.032
#> GSM252447     1  0.1074      0.718 0.960 0.000 0.000 0.000 0.012 0.028
#> GSM252444     1  0.0622      0.732 0.980 0.000 0.000 0.012 0.008 0.000
#> GSM252450     1  0.3080      0.733 0.860 0.000 0.000 0.068 0.036 0.036
#> GSM252452     1  0.6801      0.198 0.428 0.000 0.000 0.128 0.096 0.348
#> GSM252443     6  0.4548      0.449 0.360 0.000 0.000 0.024 0.012 0.604
#> GSM252454     1  0.5928     -0.189 0.452 0.000 0.000 0.080 0.044 0.424
#> GSM252449     1  0.5722      0.628 0.624 0.000 0.000 0.220 0.080 0.076
#> GSM252445     1  0.5124      0.682 0.700 0.000 0.000 0.156 0.076 0.068
#> GSM252453     1  0.4686      0.679 0.748 0.000 0.000 0.084 0.072 0.096
#> GSM252464     4  0.3907      0.814 0.088 0.000 0.104 0.792 0.000 0.016
#> GSM252463     4  0.4446      0.808 0.128 0.000 0.084 0.760 0.008 0.020
#> GSM252461     4  0.4000      0.639 0.324 0.000 0.000 0.660 0.008 0.008
#> GSM252455     4  0.4154      0.799 0.148 0.000 0.056 0.772 0.004 0.020
#> GSM252458     4  0.4040      0.810 0.084 0.000 0.116 0.784 0.004 0.012
#> GSM252460     4  0.4127      0.800 0.072 0.000 0.120 0.784 0.016 0.008
#> GSM252457     6  0.5924      0.356 0.004 0.000 0.204 0.184 0.024 0.584
#> GSM252456     4  0.3642      0.811 0.080 0.000 0.116 0.800 0.000 0.004
#> GSM252462     4  0.5134      0.689 0.116 0.000 0.028 0.732 0.076 0.048
#> GSM252459     4  0.6575      0.189 0.316 0.000 0.000 0.476 0.072 0.136
#> GSM252472     2  0.4484      0.764 0.000 0.768 0.004 0.052 0.104 0.072
#> GSM252466     2  0.2122      0.806 0.000 0.916 0.000 0.032 0.028 0.024
#> GSM252469     2  0.1546      0.817 0.000 0.944 0.000 0.016 0.020 0.020
#> GSM252475     2  0.1296      0.828 0.000 0.952 0.000 0.012 0.032 0.004
#> GSM252471     2  0.3648      0.795 0.000 0.820 0.000 0.028 0.084 0.068
#> GSM252465     2  0.4825      0.730 0.000 0.736 0.004 0.052 0.132 0.076
#> GSM252474     5  0.3499      0.987 0.000 0.320 0.000 0.000 0.680 0.000
#> GSM252473     2  0.3845      0.791 0.000 0.816 0.004 0.040 0.068 0.072
#> GSM252468     2  0.2638      0.821 0.000 0.884 0.000 0.016 0.060 0.040
#> GSM252470     2  0.2315      0.827 0.000 0.908 0.004 0.016 0.040 0.032
#> GSM252467     2  0.2116      0.810 0.000 0.916 0.000 0.024 0.024 0.036
#> GSM252485     2  0.4339      0.770 0.000 0.780 0.004 0.052 0.096 0.068
#> GSM252481     2  0.2122      0.806 0.000 0.916 0.000 0.032 0.028 0.024
#> GSM252480     2  0.1802      0.810 0.000 0.932 0.000 0.020 0.024 0.024
#> GSM252479     2  0.0748      0.828 0.000 0.976 0.000 0.016 0.004 0.004
#> GSM252482     5  0.3499      0.996 0.000 0.320 0.000 0.000 0.680 0.000
#> GSM252478     2  0.5822      0.624 0.000 0.652 0.008 0.072 0.152 0.116
#> GSM252483     5  0.3499      0.996 0.000 0.320 0.000 0.000 0.680 0.000
#> GSM252477     5  0.3499      0.996 0.000 0.320 0.000 0.000 0.680 0.000
#> GSM252484     2  0.2240      0.825 0.000 0.908 0.000 0.016 0.044 0.032
#> GSM252476     2  0.2116      0.810 0.000 0.916 0.000 0.024 0.024 0.036

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-kmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-kmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-kmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-kmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-kmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-kmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-kmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-kmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-kmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-kmeans-membership-heatmap-5

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)

plot of chunk tab-MAD-kmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-kmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-kmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-kmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-kmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-kmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-kmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-kmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-kmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-kmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-kmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-MAD-kmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-kmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-kmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-kmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-kmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-kmeans-collect-classes

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 agent(p) individual(p) k
#> MAD:kmeans 53 3.36e-10         0.999 2
#> MAD:kmeans 62 1.68e-20         1.000 3
#> MAD:kmeans 56 6.16e-28         1.000 4
#> MAD:kmeans 54 9.79e-27         1.000 5
#> MAD:kmeans 55 1.51e-24         0.653 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.


MAD:skmeans**

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 51941 rows and 62 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 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)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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:

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)

plot of chunk MAD-skmeans-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.998       0.999         0.5082 0.492   0.492
#> 3 3 0.866           0.895       0.949         0.2848 0.857   0.712
#> 4 4 0.678           0.750       0.819         0.1265 0.909   0.750
#> 5 5 0.627           0.594       0.756         0.0582 0.960   0.861
#> 6 6 0.600           0.519       0.698         0.0409 0.963   0.856

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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     2  0.1843      0.973 0.028 0.972
#> GSM252429     2  0.0000      0.998 0.000 1.000
#> GSM252424     2  0.0672      0.992 0.008 0.992
#> GSM252432     2  0.0376      0.995 0.004 0.996
#> GSM252427     2  0.0938      0.988 0.012 0.988
#> GSM252431     2  0.0000      0.998 0.000 1.000
#> GSM252430     2  0.0000      0.998 0.000 1.000
#> GSM252433     2  0.0000      0.998 0.000 1.000
#> GSM252426     2  0.0376      0.995 0.004 0.996
#> GSM252428     2  0.1184      0.985 0.016 0.984
#> GSM252425     2  0.0000      0.998 0.000 1.000
#> GSM252440     1  0.0000      1.000 1.000 0.000
#> GSM252441     1  0.0000      1.000 1.000 0.000
#> GSM252436     1  0.0000      1.000 1.000 0.000
#> GSM252435     1  0.0000      1.000 1.000 0.000
#> GSM252442     1  0.0000      1.000 1.000 0.000
#> GSM252439     1  0.0000      1.000 1.000 0.000
#> GSM252438     1  0.0000      1.000 1.000 0.000
#> GSM252434     1  0.0000      1.000 1.000 0.000
#> GSM252437     1  0.0000      1.000 1.000 0.000
#> GSM252451     1  0.0000      1.000 1.000 0.000
#> GSM252448     1  0.0000      1.000 1.000 0.000
#> GSM252447     1  0.0000      1.000 1.000 0.000
#> GSM252444     1  0.0000      1.000 1.000 0.000
#> GSM252450     1  0.0000      1.000 1.000 0.000
#> GSM252452     1  0.0000      1.000 1.000 0.000
#> GSM252443     1  0.0000      1.000 1.000 0.000
#> GSM252454     1  0.0000      1.000 1.000 0.000
#> GSM252449     1  0.0000      1.000 1.000 0.000
#> GSM252445     1  0.0000      1.000 1.000 0.000
#> GSM252453     1  0.0000      1.000 1.000 0.000
#> GSM252464     1  0.0000      1.000 1.000 0.000
#> GSM252463     1  0.0000      1.000 1.000 0.000
#> GSM252461     1  0.0000      1.000 1.000 0.000
#> GSM252455     1  0.0000      1.000 1.000 0.000
#> GSM252458     1  0.0000      1.000 1.000 0.000
#> GSM252460     1  0.0000      1.000 1.000 0.000
#> GSM252457     1  0.0000      1.000 1.000 0.000
#> GSM252456     1  0.0000      1.000 1.000 0.000
#> GSM252462     1  0.0000      1.000 1.000 0.000
#> GSM252459     1  0.0000      1.000 1.000 0.000
#> GSM252472     2  0.0000      0.998 0.000 1.000
#> GSM252466     2  0.0000      0.998 0.000 1.000
#> GSM252469     2  0.0000      0.998 0.000 1.000
#> GSM252475     2  0.0000      0.998 0.000 1.000
#> GSM252471     2  0.0000      0.998 0.000 1.000
#> GSM252465     2  0.0000      0.998 0.000 1.000
#> GSM252474     2  0.0000      0.998 0.000 1.000
#> GSM252473     2  0.0000      0.998 0.000 1.000
#> GSM252468     2  0.0000      0.998 0.000 1.000
#> GSM252470     2  0.0000      0.998 0.000 1.000
#> GSM252467     2  0.0000      0.998 0.000 1.000
#> GSM252485     2  0.0000      0.998 0.000 1.000
#> GSM252481     2  0.0000      0.998 0.000 1.000
#> GSM252480     2  0.0000      0.998 0.000 1.000
#> GSM252479     2  0.0000      0.998 0.000 1.000
#> GSM252482     2  0.0000      0.998 0.000 1.000
#> GSM252478     2  0.0000      0.998 0.000 1.000
#> GSM252483     2  0.0000      0.998 0.000 1.000
#> GSM252477     2  0.0000      0.998 0.000 1.000
#> GSM252484     2  0.0000      0.998 0.000 1.000
#> GSM252476     2  0.0000      0.998 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.0000      0.937 0.000 0.000 1.000
#> GSM252429     3  0.0000      0.937 0.000 0.000 1.000
#> GSM252424     3  0.0000      0.937 0.000 0.000 1.000
#> GSM252432     3  0.0000      0.937 0.000 0.000 1.000
#> GSM252427     3  0.0000      0.937 0.000 0.000 1.000
#> GSM252431     3  0.0237      0.936 0.000 0.004 0.996
#> GSM252430     3  0.2959      0.875 0.000 0.100 0.900
#> GSM252433     3  0.2356      0.900 0.000 0.072 0.928
#> GSM252426     3  0.0000      0.937 0.000 0.000 1.000
#> GSM252428     3  0.0661      0.934 0.004 0.008 0.988
#> GSM252425     3  0.5431      0.608 0.000 0.284 0.716
#> GSM252440     1  0.0000      0.909 1.000 0.000 0.000
#> GSM252441     1  0.0000      0.909 1.000 0.000 0.000
#> GSM252436     1  0.0000      0.909 1.000 0.000 0.000
#> GSM252435     1  0.0000      0.909 1.000 0.000 0.000
#> GSM252442     1  0.0237      0.908 0.996 0.000 0.004
#> GSM252439     1  0.0892      0.903 0.980 0.000 0.020
#> GSM252438     1  0.3193      0.850 0.896 0.004 0.100
#> GSM252434     1  0.0000      0.909 1.000 0.000 0.000
#> GSM252437     1  0.0000      0.909 1.000 0.000 0.000
#> GSM252451     1  0.0000      0.909 1.000 0.000 0.000
#> GSM252448     1  0.0000      0.909 1.000 0.000 0.000
#> GSM252447     1  0.0000      0.909 1.000 0.000 0.000
#> GSM252444     1  0.0000      0.909 1.000 0.000 0.000
#> GSM252450     1  0.0000      0.909 1.000 0.000 0.000
#> GSM252452     1  0.0592      0.906 0.988 0.000 0.012
#> GSM252443     1  0.0237      0.908 0.996 0.000 0.004
#> GSM252454     1  0.0592      0.906 0.988 0.000 0.012
#> GSM252449     1  0.0000      0.909 1.000 0.000 0.000
#> GSM252445     1  0.0000      0.909 1.000 0.000 0.000
#> GSM252453     1  0.0237      0.908 0.996 0.000 0.004
#> GSM252464     1  0.5835      0.579 0.660 0.000 0.340
#> GSM252463     1  0.5560      0.641 0.700 0.000 0.300
#> GSM252461     1  0.1031      0.901 0.976 0.000 0.024
#> GSM252455     1  0.3816      0.817 0.852 0.000 0.148
#> GSM252458     1  0.6168      0.433 0.588 0.000 0.412
#> GSM252460     1  0.6302      0.262 0.520 0.000 0.480
#> GSM252457     3  0.3879      0.779 0.152 0.000 0.848
#> GSM252456     1  0.6154      0.446 0.592 0.000 0.408
#> GSM252462     1  0.4002      0.808 0.840 0.000 0.160
#> GSM252459     1  0.2537      0.871 0.920 0.000 0.080
#> GSM252472     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252466     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252469     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252475     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252471     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252465     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252474     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252473     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252468     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252470     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252467     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252485     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252481     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252480     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252479     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252482     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252478     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252483     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252477     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252484     2  0.0000      1.000 0.000 1.000 0.000
#> GSM252476     2  0.0000      1.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.1118     0.8335 0.000 0.000 0.964 0.036
#> GSM252429     3  0.1557     0.8277 0.000 0.000 0.944 0.056
#> GSM252424     3  0.1398     0.8330 0.004 0.000 0.956 0.040
#> GSM252432     3  0.0469     0.8345 0.000 0.000 0.988 0.012
#> GSM252427     3  0.1211     0.8323 0.000 0.000 0.960 0.040
#> GSM252431     3  0.2246     0.8265 0.004 0.016 0.928 0.052
#> GSM252430     3  0.6040     0.6256 0.004 0.072 0.660 0.264
#> GSM252433     3  0.6554     0.5846 0.008 0.096 0.628 0.268
#> GSM252426     3  0.0921     0.8292 0.000 0.000 0.972 0.028
#> GSM252428     3  0.3375     0.7881 0.016 0.016 0.876 0.092
#> GSM252425     3  0.5496     0.5825 0.000 0.232 0.704 0.064
#> GSM252440     1  0.1637     0.7499 0.940 0.000 0.000 0.060
#> GSM252441     1  0.0921     0.7457 0.972 0.000 0.000 0.028
#> GSM252436     1  0.2589     0.7518 0.884 0.000 0.000 0.116
#> GSM252435     1  0.3351     0.7381 0.844 0.000 0.008 0.148
#> GSM252442     1  0.5508     0.3953 0.572 0.000 0.020 0.408
#> GSM252439     1  0.4769     0.5427 0.684 0.000 0.008 0.308
#> GSM252438     1  0.6213     0.2013 0.484 0.000 0.052 0.464
#> GSM252434     1  0.4980     0.6077 0.680 0.000 0.016 0.304
#> GSM252437     1  0.2868     0.7472 0.864 0.000 0.000 0.136
#> GSM252451     1  0.2647     0.7527 0.880 0.000 0.000 0.120
#> GSM252448     1  0.2281     0.7492 0.904 0.000 0.000 0.096
#> GSM252447     1  0.1118     0.7478 0.964 0.000 0.000 0.036
#> GSM252444     1  0.2760     0.7436 0.872 0.000 0.000 0.128
#> GSM252450     1  0.2773     0.7529 0.880 0.000 0.004 0.116
#> GSM252452     1  0.5620     0.4228 0.560 0.000 0.024 0.416
#> GSM252443     1  0.4364     0.6618 0.764 0.000 0.016 0.220
#> GSM252454     1  0.4364     0.6809 0.764 0.000 0.016 0.220
#> GSM252449     1  0.4511     0.6361 0.724 0.000 0.008 0.268
#> GSM252445     1  0.3172     0.7353 0.840 0.000 0.000 0.160
#> GSM252453     1  0.2921     0.7479 0.860 0.000 0.000 0.140
#> GSM252464     4  0.7371     0.7049 0.244 0.000 0.232 0.524
#> GSM252463     4  0.7138     0.6535 0.268 0.000 0.180 0.552
#> GSM252461     1  0.5523     0.3365 0.596 0.000 0.024 0.380
#> GSM252455     4  0.6907     0.5303 0.348 0.000 0.120 0.532
#> GSM252458     4  0.7103     0.7098 0.160 0.000 0.296 0.544
#> GSM252460     4  0.6682     0.6927 0.112 0.000 0.312 0.576
#> GSM252457     4  0.7081     0.3017 0.124 0.000 0.424 0.452
#> GSM252456     4  0.6895     0.7260 0.148 0.000 0.276 0.576
#> GSM252462     4  0.6716     0.4898 0.320 0.000 0.112 0.568
#> GSM252459     1  0.6694     0.0167 0.516 0.000 0.092 0.392
#> GSM252472     2  0.0592     0.9614 0.000 0.984 0.000 0.016
#> GSM252466     2  0.0000     0.9634 0.000 1.000 0.000 0.000
#> GSM252469     2  0.0188     0.9630 0.000 0.996 0.000 0.004
#> GSM252475     2  0.0817     0.9586 0.000 0.976 0.000 0.024
#> GSM252471     2  0.0817     0.9606 0.000 0.976 0.000 0.024
#> GSM252465     2  0.0469     0.9626 0.000 0.988 0.000 0.012
#> GSM252474     2  0.2760     0.8929 0.000 0.872 0.000 0.128
#> GSM252473     2  0.1452     0.9520 0.000 0.956 0.008 0.036
#> GSM252468     2  0.0188     0.9630 0.000 0.996 0.000 0.004
#> GSM252470     2  0.0336     0.9634 0.000 0.992 0.000 0.008
#> GSM252467     2  0.0188     0.9632 0.000 0.996 0.000 0.004
#> GSM252485     2  0.0817     0.9592 0.000 0.976 0.000 0.024
#> GSM252481     2  0.0000     0.9634 0.000 1.000 0.000 0.000
#> GSM252480     2  0.0000     0.9634 0.000 1.000 0.000 0.000
#> GSM252479     2  0.0188     0.9631 0.000 0.996 0.000 0.004
#> GSM252482     2  0.3494     0.8536 0.000 0.824 0.004 0.172
#> GSM252478     2  0.1042     0.9578 0.000 0.972 0.008 0.020
#> GSM252483     2  0.3024     0.8799 0.000 0.852 0.000 0.148
#> GSM252477     2  0.3725     0.8431 0.000 0.812 0.008 0.180
#> GSM252484     2  0.0188     0.9630 0.000 0.996 0.000 0.004
#> GSM252476     2  0.0000     0.9634 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.2291     0.7782 0.000 0.000 0.908 0.036 0.056
#> GSM252429     3  0.2325     0.7746 0.000 0.000 0.904 0.028 0.068
#> GSM252424     3  0.2353     0.7798 0.000 0.004 0.908 0.060 0.028
#> GSM252432     3  0.1914     0.7835 0.000 0.004 0.932 0.032 0.032
#> GSM252427     3  0.2569     0.7637 0.000 0.000 0.892 0.068 0.040
#> GSM252431     3  0.4241     0.7570 0.000 0.028 0.808 0.084 0.080
#> GSM252430     3  0.6017     0.4957 0.004 0.048 0.540 0.028 0.380
#> GSM252433     3  0.5831     0.5011 0.000 0.020 0.544 0.056 0.380
#> GSM252426     3  0.2929     0.7727 0.000 0.008 0.880 0.068 0.044
#> GSM252428     3  0.4919     0.6963 0.004 0.024 0.752 0.156 0.064
#> GSM252425     3  0.6394     0.5057 0.000 0.240 0.608 0.052 0.100
#> GSM252440     1  0.3620     0.5849 0.824 0.000 0.000 0.108 0.068
#> GSM252441     1  0.1579     0.5886 0.944 0.000 0.000 0.024 0.032
#> GSM252436     1  0.3321     0.6024 0.832 0.000 0.000 0.136 0.032
#> GSM252435     1  0.5134     0.5247 0.688 0.000 0.004 0.220 0.088
#> GSM252442     4  0.5609    -0.1945 0.452 0.000 0.016 0.492 0.040
#> GSM252439     1  0.6362    -0.1130 0.560 0.000 0.012 0.160 0.268
#> GSM252438     5  0.7831     0.0000 0.328 0.008 0.048 0.240 0.376
#> GSM252434     1  0.5145     0.4476 0.612 0.000 0.000 0.332 0.056
#> GSM252437     1  0.4822     0.5462 0.704 0.000 0.000 0.220 0.076
#> GSM252451     1  0.4045     0.6054 0.796 0.000 0.004 0.136 0.064
#> GSM252448     1  0.3164     0.5737 0.852 0.000 0.000 0.104 0.044
#> GSM252447     1  0.1836     0.5863 0.932 0.000 0.000 0.036 0.032
#> GSM252444     1  0.3551     0.6059 0.820 0.000 0.000 0.136 0.044
#> GSM252450     1  0.3840     0.5971 0.808 0.000 0.000 0.116 0.076
#> GSM252452     1  0.6711     0.2085 0.500 0.000 0.012 0.288 0.200
#> GSM252443     1  0.5769     0.2133 0.644 0.000 0.012 0.124 0.220
#> GSM252454     1  0.6558    -0.1201 0.540 0.000 0.012 0.212 0.236
#> GSM252449     1  0.4920     0.5048 0.644 0.000 0.000 0.308 0.048
#> GSM252445     1  0.4599     0.5424 0.688 0.000 0.000 0.272 0.040
#> GSM252453     1  0.4487     0.5399 0.756 0.000 0.000 0.140 0.104
#> GSM252464     4  0.6621     0.5061 0.152 0.000 0.172 0.612 0.064
#> GSM252463     4  0.6605     0.4649 0.184 0.000 0.160 0.604 0.052
#> GSM252461     1  0.6145    -0.0557 0.484 0.000 0.040 0.428 0.048
#> GSM252455     4  0.6367     0.4442 0.268 0.000 0.080 0.596 0.056
#> GSM252458     4  0.6383     0.4982 0.132 0.000 0.180 0.632 0.056
#> GSM252460     4  0.5557     0.5066 0.068 0.000 0.196 0.692 0.044
#> GSM252457     4  0.8031    -0.0941 0.092 0.000 0.256 0.372 0.280
#> GSM252456     4  0.5412     0.5244 0.080 0.000 0.216 0.684 0.020
#> GSM252462     4  0.5873     0.4275 0.196 0.000 0.068 0.672 0.064
#> GSM252459     4  0.7323     0.0707 0.344 0.000 0.052 0.440 0.164
#> GSM252472     2  0.2612     0.8851 0.000 0.868 0.008 0.000 0.124
#> GSM252466     2  0.1282     0.9033 0.000 0.952 0.000 0.004 0.044
#> GSM252469     2  0.0955     0.8984 0.000 0.968 0.000 0.004 0.028
#> GSM252475     2  0.2248     0.8933 0.000 0.900 0.000 0.012 0.088
#> GSM252471     2  0.2124     0.8956 0.000 0.900 0.000 0.004 0.096
#> GSM252465     2  0.2666     0.8812 0.000 0.892 0.020 0.012 0.076
#> GSM252474     2  0.4064     0.7763 0.000 0.716 0.008 0.004 0.272
#> GSM252473     2  0.2783     0.8873 0.000 0.868 0.004 0.012 0.116
#> GSM252468     2  0.1569     0.9029 0.000 0.944 0.004 0.008 0.044
#> GSM252470     2  0.1644     0.8954 0.000 0.940 0.004 0.008 0.048
#> GSM252467     2  0.1082     0.8989 0.000 0.964 0.000 0.008 0.028
#> GSM252485     2  0.2286     0.8938 0.000 0.888 0.000 0.004 0.108
#> GSM252481     2  0.1116     0.9016 0.000 0.964 0.004 0.004 0.028
#> GSM252480     2  0.0880     0.9019 0.000 0.968 0.000 0.000 0.032
#> GSM252479     2  0.1478     0.9027 0.000 0.936 0.000 0.000 0.064
#> GSM252482     2  0.4430     0.6934 0.000 0.628 0.012 0.000 0.360
#> GSM252478     2  0.3019     0.8725 0.000 0.864 0.016 0.012 0.108
#> GSM252483     2  0.4183     0.7250 0.000 0.668 0.008 0.000 0.324
#> GSM252477     2  0.4517     0.6738 0.000 0.616 0.008 0.004 0.372
#> GSM252484     2  0.1774     0.9021 0.000 0.932 0.000 0.016 0.052
#> GSM252476     2  0.0955     0.9028 0.000 0.968 0.004 0.000 0.028

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3   0.334     0.7336 0.000 0.000 0.844 0.044 0.072 0.040
#> GSM252429     3   0.456     0.6818 0.004 0.000 0.756 0.044 0.128 0.068
#> GSM252424     3   0.318     0.7395 0.000 0.000 0.856 0.040 0.048 0.056
#> GSM252432     3   0.302     0.7435 0.000 0.000 0.860 0.060 0.064 0.016
#> GSM252427     3   0.355     0.7242 0.000 0.000 0.832 0.064 0.060 0.044
#> GSM252431     3   0.530     0.6870 0.004 0.024 0.728 0.060 0.096 0.088
#> GSM252430     5   0.523    -0.1510 0.000 0.008 0.360 0.000 0.552 0.080
#> GSM252433     5   0.653    -0.1853 0.000 0.032 0.376 0.028 0.460 0.104
#> GSM252426     3   0.342     0.7286 0.000 0.004 0.836 0.096 0.044 0.020
#> GSM252428     3   0.579     0.5900 0.008 0.012 0.672 0.144 0.112 0.052
#> GSM252425     3   0.701     0.3715 0.004 0.220 0.536 0.024 0.128 0.088
#> GSM252440     1   0.393     0.6130 0.796 0.000 0.004 0.072 0.016 0.112
#> GSM252441     1   0.186     0.6291 0.920 0.000 0.000 0.016 0.004 0.060
#> GSM252436     1   0.400     0.6110 0.780 0.000 0.000 0.096 0.012 0.112
#> GSM252435     1   0.614     0.5176 0.632 0.000 0.028 0.172 0.056 0.112
#> GSM252442     4   0.690    -0.0628 0.324 0.000 0.012 0.440 0.052 0.172
#> GSM252439     1   0.661    -0.0125 0.428 0.000 0.020 0.048 0.100 0.404
#> GSM252438     6   0.712     0.3170 0.176 0.000 0.028 0.080 0.204 0.512
#> GSM252434     1   0.628     0.3449 0.500 0.000 0.008 0.340 0.040 0.112
#> GSM252437     1   0.599     0.5158 0.608 0.000 0.012 0.208 0.036 0.136
#> GSM252451     1   0.412     0.6244 0.792 0.000 0.004 0.084 0.032 0.088
#> GSM252448     1   0.428     0.6095 0.768 0.000 0.004 0.100 0.016 0.112
#> GSM252447     1   0.256     0.6302 0.888 0.000 0.004 0.032 0.008 0.068
#> GSM252444     1   0.385     0.6136 0.792 0.000 0.004 0.104 0.004 0.096
#> GSM252450     1   0.507     0.5927 0.696 0.000 0.000 0.100 0.040 0.164
#> GSM252452     1   0.773     0.1292 0.308 0.000 0.004 0.252 0.168 0.268
#> GSM252443     1   0.597     0.3575 0.580 0.000 0.016 0.064 0.052 0.288
#> GSM252454     1   0.713     0.2844 0.480 0.004 0.036 0.144 0.048 0.288
#> GSM252449     1   0.581     0.4553 0.572 0.000 0.000 0.280 0.036 0.112
#> GSM252445     1   0.570     0.5230 0.620 0.000 0.008 0.236 0.032 0.104
#> GSM252453     1   0.555     0.5376 0.624 0.000 0.000 0.120 0.032 0.224
#> GSM252464     4   0.652     0.4464 0.084 0.000 0.164 0.612 0.044 0.096
#> GSM252463     4   0.685     0.3716 0.176 0.000 0.108 0.560 0.024 0.132
#> GSM252461     1   0.652     0.1766 0.504 0.000 0.044 0.316 0.016 0.120
#> GSM252455     4   0.607     0.4428 0.168 0.000 0.064 0.636 0.020 0.112
#> GSM252458     4   0.695     0.4016 0.076 0.000 0.192 0.564 0.060 0.108
#> GSM252460     4   0.533     0.4597 0.036 0.000 0.152 0.708 0.040 0.064
#> GSM252457     6   0.829     0.1523 0.056 0.000 0.200 0.260 0.152 0.332
#> GSM252456     4   0.511     0.4951 0.060 0.000 0.148 0.724 0.032 0.036
#> GSM252462     4   0.520     0.4376 0.116 0.000 0.036 0.720 0.024 0.104
#> GSM252459     4   0.786     0.1151 0.232 0.000 0.072 0.352 0.052 0.292
#> GSM252472     2   0.354     0.7961 0.000 0.808 0.004 0.004 0.136 0.048
#> GSM252466     2   0.178     0.8379 0.000 0.920 0.000 0.000 0.064 0.016
#> GSM252469     2   0.100     0.8397 0.000 0.964 0.000 0.004 0.028 0.004
#> GSM252475     2   0.323     0.7734 0.000 0.820 0.004 0.004 0.148 0.024
#> GSM252471     2   0.286     0.8144 0.000 0.844 0.000 0.000 0.124 0.032
#> GSM252465     2   0.300     0.8165 0.000 0.856 0.008 0.000 0.064 0.072
#> GSM252474     2   0.418     0.3338 0.000 0.608 0.000 0.000 0.372 0.020
#> GSM252473     2   0.355     0.7883 0.000 0.804 0.004 0.004 0.144 0.044
#> GSM252468     2   0.220     0.8355 0.000 0.900 0.000 0.000 0.048 0.052
#> GSM252470     2   0.269     0.8157 0.000 0.880 0.004 0.008 0.072 0.036
#> GSM252467     2   0.170     0.8411 0.000 0.928 0.000 0.000 0.048 0.024
#> GSM252485     2   0.274     0.8178 0.000 0.872 0.004 0.004 0.084 0.036
#> GSM252481     2   0.181     0.8434 0.000 0.920 0.000 0.000 0.060 0.020
#> GSM252480     2   0.130     0.8424 0.000 0.948 0.000 0.000 0.040 0.012
#> GSM252479     2   0.156     0.8399 0.000 0.932 0.000 0.000 0.056 0.012
#> GSM252482     5   0.386    -0.0719 0.000 0.476 0.000 0.000 0.524 0.000
#> GSM252478     2   0.381     0.7777 0.000 0.808 0.028 0.000 0.088 0.076
#> GSM252483     2   0.418    -0.0518 0.000 0.520 0.000 0.000 0.468 0.012
#> GSM252477     5   0.427     0.0274 0.000 0.432 0.012 0.004 0.552 0.000
#> GSM252484     2   0.229     0.8385 0.000 0.904 0.004 0.004 0.044 0.044
#> GSM252476     2   0.163     0.8440 0.000 0.932 0.000 0.000 0.044 0.024

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-skmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-skmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-skmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-skmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-skmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-skmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-skmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-skmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-skmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-skmeans-membership-heatmap-5

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)

plot of chunk tab-MAD-skmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-skmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-skmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-skmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-skmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-skmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-skmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-skmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-skmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-skmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-skmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-MAD-skmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-skmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-skmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-skmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-skmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-skmeans-collect-classes

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 agent(p) individual(p) k
#> MAD:skmeans 62 4.69e-12         1.000 2
#> MAD:skmeans 59 2.27e-19         1.000 3
#> MAD:skmeans 55 2.46e-27         1.000 4
#> MAD:skmeans 47 1.46e-22         0.991 5
#> MAD:skmeans 37 7.82e-13         0.990 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.


MAD:pam*

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 51941 rows and 62 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 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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:

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)

plot of chunk MAD-pam-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.941       0.977         0.5076 0.492   0.492
#> 3 3 0.933           0.921       0.966         0.3036 0.805   0.622
#> 4 4 0.742           0.786       0.824         0.0992 1.000   1.000
#> 5 5 0.693           0.679       0.812         0.0742 0.858   0.603
#> 6 6 0.714           0.626       0.808         0.0304 0.956   0.812

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2

There is also optional best \(k\) = 2 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1  0.9580      0.382 0.620 0.380
#> GSM252429     2  0.1414      0.967 0.020 0.980
#> GSM252424     2  0.7602      0.719 0.220 0.780
#> GSM252432     2  0.6801      0.781 0.180 0.820
#> GSM252427     2  0.3114      0.933 0.056 0.944
#> GSM252431     2  0.2043      0.957 0.032 0.968
#> GSM252430     2  0.0000      0.981 0.000 1.000
#> GSM252433     2  0.0000      0.981 0.000 1.000
#> GSM252426     1  0.9998      0.022 0.508 0.492
#> GSM252428     2  0.1633      0.963 0.024 0.976
#> GSM252425     2  0.0000      0.981 0.000 1.000
#> GSM252440     1  0.0000      0.970 1.000 0.000
#> GSM252441     1  0.0000      0.970 1.000 0.000
#> GSM252436     1  0.0000      0.970 1.000 0.000
#> GSM252435     1  0.0000      0.970 1.000 0.000
#> GSM252442     1  0.0000      0.970 1.000 0.000
#> GSM252439     1  0.0000      0.970 1.000 0.000
#> GSM252438     1  0.1843      0.944 0.972 0.028
#> GSM252434     1  0.0000      0.970 1.000 0.000
#> GSM252437     1  0.0000      0.970 1.000 0.000
#> GSM252451     1  0.0000      0.970 1.000 0.000
#> GSM252448     1  0.0000      0.970 1.000 0.000
#> GSM252447     1  0.0000      0.970 1.000 0.000
#> GSM252444     1  0.0000      0.970 1.000 0.000
#> GSM252450     1  0.0000      0.970 1.000 0.000
#> GSM252452     1  0.0000      0.970 1.000 0.000
#> GSM252443     1  0.0000      0.970 1.000 0.000
#> GSM252454     1  0.0376      0.967 0.996 0.004
#> GSM252449     1  0.0000      0.970 1.000 0.000
#> GSM252445     1  0.0000      0.970 1.000 0.000
#> GSM252453     1  0.0000      0.970 1.000 0.000
#> GSM252464     1  0.0000      0.970 1.000 0.000
#> GSM252463     1  0.0000      0.970 1.000 0.000
#> GSM252461     1  0.0000      0.970 1.000 0.000
#> GSM252455     1  0.0000      0.970 1.000 0.000
#> GSM252458     1  0.0000      0.970 1.000 0.000
#> GSM252460     1  0.0000      0.970 1.000 0.000
#> GSM252457     1  0.0000      0.970 1.000 0.000
#> GSM252456     1  0.0000      0.970 1.000 0.000
#> GSM252462     1  0.0000      0.970 1.000 0.000
#> GSM252459     1  0.0000      0.970 1.000 0.000
#> GSM252472     2  0.0000      0.981 0.000 1.000
#> GSM252466     2  0.0000      0.981 0.000 1.000
#> GSM252469     2  0.0000      0.981 0.000 1.000
#> GSM252475     2  0.0000      0.981 0.000 1.000
#> GSM252471     2  0.0000      0.981 0.000 1.000
#> GSM252465     2  0.0000      0.981 0.000 1.000
#> GSM252474     2  0.0000      0.981 0.000 1.000
#> GSM252473     2  0.0000      0.981 0.000 1.000
#> GSM252468     2  0.0000      0.981 0.000 1.000
#> GSM252470     2  0.0000      0.981 0.000 1.000
#> GSM252467     2  0.0000      0.981 0.000 1.000
#> GSM252485     2  0.0000      0.981 0.000 1.000
#> GSM252481     2  0.0000      0.981 0.000 1.000
#> GSM252480     2  0.0000      0.981 0.000 1.000
#> GSM252479     2  0.0000      0.981 0.000 1.000
#> GSM252482     2  0.0000      0.981 0.000 1.000
#> GSM252478     2  0.0000      0.981 0.000 1.000
#> GSM252483     2  0.0000      0.981 0.000 1.000
#> GSM252477     2  0.0000      0.981 0.000 1.000
#> GSM252484     2  0.0000      0.981 0.000 1.000
#> GSM252476     2  0.0000      0.981 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.0000    0.95875 0.000 0.000 1.000
#> GSM252429     3  0.0000    0.95875 0.000 0.000 1.000
#> GSM252424     3  0.0000    0.95875 0.000 0.000 1.000
#> GSM252432     3  0.0000    0.95875 0.000 0.000 1.000
#> GSM252427     3  0.0000    0.95875 0.000 0.000 1.000
#> GSM252431     3  0.0000    0.95875 0.000 0.000 1.000
#> GSM252430     3  0.1289    0.93444 0.000 0.032 0.968
#> GSM252433     3  0.0000    0.95875 0.000 0.000 1.000
#> GSM252426     3  0.0000    0.95875 0.000 0.000 1.000
#> GSM252428     3  0.0000    0.95875 0.000 0.000 1.000
#> GSM252425     3  0.0000    0.95875 0.000 0.000 1.000
#> GSM252440     1  0.0000    0.93423 1.000 0.000 0.000
#> GSM252441     1  0.0000    0.93423 1.000 0.000 0.000
#> GSM252436     1  0.0000    0.93423 1.000 0.000 0.000
#> GSM252435     1  0.0892    0.92827 0.980 0.000 0.020
#> GSM252442     1  0.0592    0.93152 0.988 0.000 0.012
#> GSM252439     1  0.0424    0.93084 0.992 0.008 0.000
#> GSM252438     1  0.1860    0.90805 0.948 0.000 0.052
#> GSM252434     1  0.0000    0.93423 1.000 0.000 0.000
#> GSM252437     1  0.1411    0.92018 0.964 0.000 0.036
#> GSM252451     1  0.0000    0.93423 1.000 0.000 0.000
#> GSM252448     1  0.0000    0.93423 1.000 0.000 0.000
#> GSM252447     1  0.0000    0.93423 1.000 0.000 0.000
#> GSM252444     1  0.0000    0.93423 1.000 0.000 0.000
#> GSM252450     1  0.0000    0.93423 1.000 0.000 0.000
#> GSM252452     1  0.0237    0.93339 0.996 0.000 0.004
#> GSM252443     1  0.1031    0.92619 0.976 0.000 0.024
#> GSM252454     1  0.0000    0.93423 1.000 0.000 0.000
#> GSM252449     1  0.0000    0.93423 1.000 0.000 0.000
#> GSM252445     1  0.3192    0.85834 0.888 0.000 0.112
#> GSM252453     1  0.0000    0.93423 1.000 0.000 0.000
#> GSM252464     1  0.5291    0.66451 0.732 0.000 0.268
#> GSM252463     1  0.4235    0.78864 0.824 0.000 0.176
#> GSM252461     1  0.0000    0.93423 1.000 0.000 0.000
#> GSM252455     1  0.1529    0.91660 0.960 0.000 0.040
#> GSM252458     3  0.2625    0.88389 0.084 0.000 0.916
#> GSM252460     3  0.1289    0.93640 0.032 0.000 0.968
#> GSM252457     3  0.5882    0.43948 0.348 0.000 0.652
#> GSM252456     1  0.6308    0.00672 0.508 0.000 0.492
#> GSM252462     1  0.5327    0.65011 0.728 0.000 0.272
#> GSM252459     1  0.2959    0.86907 0.900 0.000 0.100
#> GSM252472     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252466     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252469     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252475     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252471     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252465     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252474     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252473     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252468     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252470     2  0.0747    0.98352 0.000 0.984 0.016
#> GSM252467     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252485     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252481     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252480     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252479     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252482     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252478     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252483     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252477     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252484     2  0.0000    0.99919 0.000 1.000 0.000
#> GSM252476     2  0.0000    0.99919 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3 p4
#> GSM252423     3  0.0000     0.8964 0.000 0.000 1.000 NA
#> GSM252429     3  0.0000     0.8964 0.000 0.000 1.000 NA
#> GSM252424     3  0.0000     0.8964 0.000 0.000 1.000 NA
#> GSM252432     3  0.0000     0.8964 0.000 0.000 1.000 NA
#> GSM252427     3  0.0469     0.8914 0.000 0.000 0.988 NA
#> GSM252431     3  0.0000     0.8964 0.000 0.000 1.000 NA
#> GSM252430     3  0.5155     0.5236 0.000 0.004 0.528 NA
#> GSM252433     3  0.2011     0.8552 0.000 0.000 0.920 NA
#> GSM252426     3  0.0000     0.8964 0.000 0.000 1.000 NA
#> GSM252428     3  0.0000     0.8964 0.000 0.000 1.000 NA
#> GSM252425     3  0.0000     0.8964 0.000 0.000 1.000 NA
#> GSM252440     1  0.4877     0.7747 0.592 0.000 0.000 NA
#> GSM252441     1  0.4790     0.7773 0.620 0.000 0.000 NA
#> GSM252436     1  0.4072     0.7990 0.748 0.000 0.000 NA
#> GSM252435     1  0.5452     0.7938 0.616 0.000 0.024 NA
#> GSM252442     1  0.1807     0.7760 0.940 0.000 0.008 NA
#> GSM252439     1  0.4776     0.7910 0.624 0.000 0.000 NA
#> GSM252438     1  0.5313     0.7945 0.608 0.000 0.016 NA
#> GSM252434     1  0.0469     0.7771 0.988 0.000 0.000 NA
#> GSM252437     1  0.5249     0.7979 0.708 0.000 0.044 NA
#> GSM252451     1  0.1474     0.7917 0.948 0.000 0.000 NA
#> GSM252448     1  0.4941     0.7728 0.564 0.000 0.000 NA
#> GSM252447     1  0.4843     0.7744 0.604 0.000 0.000 NA
#> GSM252444     1  0.4382     0.7886 0.704 0.000 0.000 NA
#> GSM252450     1  0.4277     0.8134 0.720 0.000 0.000 NA
#> GSM252452     1  0.2647     0.7399 0.880 0.000 0.000 NA
#> GSM252443     1  0.5105     0.8116 0.696 0.000 0.028 NA
#> GSM252454     1  0.4830     0.7964 0.608 0.000 0.000 NA
#> GSM252449     1  0.0336     0.7775 0.992 0.000 0.000 NA
#> GSM252445     1  0.4856     0.6936 0.780 0.000 0.136 NA
#> GSM252453     1  0.3400     0.8138 0.820 0.000 0.000 NA
#> GSM252464     1  0.5025     0.5325 0.716 0.000 0.252 NA
#> GSM252463     1  0.6162     0.6885 0.676 0.000 0.156 NA
#> GSM252461     1  0.4543     0.8064 0.676 0.000 0.000 NA
#> GSM252455     1  0.2635     0.7948 0.904 0.000 0.020 NA
#> GSM252458     3  0.4307     0.7438 0.048 0.000 0.808 NA
#> GSM252460     3  0.2918     0.8170 0.116 0.000 0.876 NA
#> GSM252457     3  0.5850     0.0406 0.456 0.000 0.512 NA
#> GSM252456     1  0.5364     0.3197 0.592 0.000 0.392 NA
#> GSM252462     1  0.6808     0.3791 0.560 0.000 0.320 NA
#> GSM252459     1  0.4565     0.7857 0.796 0.000 0.064 NA
#> GSM252472     2  0.0000     0.9110 0.000 1.000 0.000 NA
#> GSM252466     2  0.0707     0.9101 0.000 0.980 0.000 NA
#> GSM252469     2  0.0707     0.9101 0.000 0.980 0.000 NA
#> GSM252475     2  0.0188     0.9112 0.000 0.996 0.000 NA
#> GSM252471     2  0.0000     0.9110 0.000 1.000 0.000 NA
#> GSM252465     2  0.0000     0.9110 0.000 1.000 0.000 NA
#> GSM252474     2  0.4972     0.5929 0.000 0.544 0.000 NA
#> GSM252473     2  0.0469     0.9110 0.000 0.988 0.000 NA
#> GSM252468     2  0.0000     0.9110 0.000 1.000 0.000 NA
#> GSM252470     2  0.1042     0.8999 0.000 0.972 0.020 NA
#> GSM252467     2  0.0707     0.9101 0.000 0.980 0.000 NA
#> GSM252485     2  0.0336     0.9112 0.000 0.992 0.000 NA
#> GSM252481     2  0.0707     0.9101 0.000 0.980 0.000 NA
#> GSM252480     2  0.0707     0.9101 0.000 0.980 0.000 NA
#> GSM252479     2  0.0000     0.9110 0.000 1.000 0.000 NA
#> GSM252482     2  0.4994     0.5543 0.000 0.520 0.000 NA
#> GSM252478     2  0.0188     0.9099 0.000 0.996 0.004 NA
#> GSM252483     2  0.4999     0.5526 0.000 0.508 0.000 NA
#> GSM252477     2  0.4996     0.5542 0.000 0.516 0.000 NA
#> GSM252484     2  0.0000     0.9110 0.000 1.000 0.000 NA
#> GSM252476     2  0.0707     0.9101 0.000 0.980 0.000 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.0000     0.9435 0.000 0.000 1.000 0.000 0.000
#> GSM252429     3  0.0000     0.9435 0.000 0.000 1.000 0.000 0.000
#> GSM252424     3  0.0000     0.9435 0.000 0.000 1.000 0.000 0.000
#> GSM252432     3  0.0000     0.9435 0.000 0.000 1.000 0.000 0.000
#> GSM252427     3  0.1364     0.9149 0.036 0.000 0.952 0.000 0.012
#> GSM252431     3  0.0000     0.9435 0.000 0.000 1.000 0.000 0.000
#> GSM252430     5  0.3730     0.5138 0.000 0.000 0.288 0.000 0.712
#> GSM252433     3  0.2020     0.8536 0.000 0.000 0.900 0.000 0.100
#> GSM252426     3  0.0000     0.9435 0.000 0.000 1.000 0.000 0.000
#> GSM252428     3  0.0000     0.9435 0.000 0.000 1.000 0.000 0.000
#> GSM252425     3  0.0451     0.9363 0.000 0.008 0.988 0.000 0.004
#> GSM252440     4  0.3053     0.7135 0.164 0.000 0.000 0.828 0.008
#> GSM252441     4  0.2561     0.7308 0.144 0.000 0.000 0.856 0.000
#> GSM252436     4  0.4415     0.2273 0.444 0.000 0.000 0.552 0.004
#> GSM252435     1  0.6315    -0.1262 0.476 0.000 0.020 0.412 0.092
#> GSM252442     1  0.1410     0.5507 0.940 0.000 0.000 0.060 0.000
#> GSM252439     4  0.3700     0.6570 0.240 0.000 0.000 0.752 0.008
#> GSM252438     1  0.5762     0.2481 0.532 0.000 0.004 0.384 0.080
#> GSM252434     1  0.1671     0.5445 0.924 0.000 0.000 0.076 0.000
#> GSM252437     1  0.5500     0.4246 0.668 0.000 0.032 0.244 0.056
#> GSM252451     1  0.3305     0.4810 0.776 0.000 0.000 0.224 0.000
#> GSM252448     4  0.3115     0.7070 0.112 0.000 0.000 0.852 0.036
#> GSM252447     4  0.2179     0.7253 0.100 0.000 0.000 0.896 0.004
#> GSM252444     4  0.3300     0.6770 0.204 0.000 0.000 0.792 0.004
#> GSM252450     1  0.5555    -0.0771 0.480 0.000 0.000 0.452 0.068
#> GSM252452     1  0.3741     0.5168 0.816 0.000 0.000 0.076 0.108
#> GSM252443     1  0.5536     0.2649 0.584 0.000 0.024 0.356 0.036
#> GSM252454     4  0.5599     0.0737 0.444 0.000 0.000 0.484 0.072
#> GSM252449     1  0.1671     0.5445 0.924 0.000 0.000 0.076 0.000
#> GSM252445     1  0.4910     0.5155 0.748 0.000 0.140 0.092 0.020
#> GSM252453     1  0.4315     0.4406 0.700 0.000 0.000 0.276 0.024
#> GSM252464     1  0.5700     0.4277 0.648 0.000 0.244 0.088 0.020
#> GSM252463     1  0.5479     0.5063 0.728 0.000 0.092 0.104 0.076
#> GSM252461     1  0.5689    -0.1517 0.480 0.000 0.000 0.440 0.080
#> GSM252455     1  0.4554     0.4833 0.736 0.000 0.016 0.216 0.032
#> GSM252458     3  0.5086     0.6936 0.100 0.000 0.756 0.060 0.084
#> GSM252460     3  0.2753     0.8217 0.136 0.000 0.856 0.000 0.008
#> GSM252457     1  0.4807     0.2001 0.532 0.000 0.448 0.020 0.000
#> GSM252456     1  0.4607     0.3649 0.616 0.000 0.368 0.004 0.012
#> GSM252462     1  0.6526     0.3376 0.524 0.000 0.344 0.096 0.036
#> GSM252459     1  0.4900     0.5243 0.740 0.000 0.044 0.180 0.036
#> GSM252472     2  0.0404     0.9425 0.000 0.988 0.000 0.000 0.012
#> GSM252466     2  0.2127     0.9216 0.000 0.892 0.000 0.000 0.108
#> GSM252469     2  0.2074     0.9231 0.000 0.896 0.000 0.000 0.104
#> GSM252475     2  0.0880     0.9445 0.000 0.968 0.000 0.000 0.032
#> GSM252471     2  0.0290     0.9449 0.000 0.992 0.000 0.000 0.008
#> GSM252465     2  0.0609     0.9410 0.000 0.980 0.000 0.000 0.020
#> GSM252474     5  0.3274     0.7587 0.000 0.220 0.000 0.000 0.780
#> GSM252473     2  0.1608     0.9410 0.000 0.928 0.000 0.000 0.072
#> GSM252468     2  0.0510     0.9409 0.000 0.984 0.000 0.000 0.016
#> GSM252470     2  0.1216     0.9364 0.000 0.960 0.020 0.000 0.020
#> GSM252467     2  0.2127     0.9216 0.000 0.892 0.000 0.000 0.108
#> GSM252485     2  0.1043     0.9449 0.000 0.960 0.000 0.000 0.040
#> GSM252481     2  0.2179     0.9202 0.000 0.888 0.000 0.000 0.112
#> GSM252480     2  0.2127     0.9216 0.000 0.892 0.000 0.000 0.108
#> GSM252479     2  0.0510     0.9447 0.000 0.984 0.000 0.000 0.016
#> GSM252482     5  0.3210     0.8416 0.000 0.212 0.000 0.000 0.788
#> GSM252478     2  0.0798     0.9377 0.000 0.976 0.008 0.000 0.016
#> GSM252483     5  0.2813     0.8454 0.000 0.168 0.000 0.000 0.832
#> GSM252477     5  0.3003     0.8492 0.000 0.188 0.000 0.000 0.812
#> GSM252484     2  0.0510     0.9409 0.000 0.984 0.000 0.000 0.016
#> GSM252476     2  0.1608     0.9364 0.000 0.928 0.000 0.000 0.072

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.0000     0.9088 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252429     3  0.0000     0.9088 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252424     3  0.0000     0.9088 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252432     3  0.0000     0.9088 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252427     3  0.3003     0.7514 0.000 0.000 0.812 0.016 0.000 0.172
#> GSM252431     3  0.0000     0.9088 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252430     5  0.3151     0.5780 0.000 0.000 0.252 0.000 0.748 0.000
#> GSM252433     3  0.1765     0.8265 0.000 0.000 0.904 0.000 0.096 0.000
#> GSM252426     3  0.0000     0.9088 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252428     3  0.0000     0.9088 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252425     3  0.0520     0.8997 0.000 0.008 0.984 0.000 0.008 0.000
#> GSM252440     1  0.1858     0.5063 0.904 0.000 0.000 0.092 0.000 0.004
#> GSM252441     1  0.1686     0.5247 0.924 0.000 0.000 0.064 0.000 0.012
#> GSM252436     1  0.3795     0.3240 0.632 0.000 0.000 0.364 0.000 0.004
#> GSM252435     6  0.6654    -0.1505 0.288 0.000 0.020 0.328 0.004 0.360
#> GSM252442     4  0.1049     0.5638 0.032 0.000 0.000 0.960 0.000 0.008
#> GSM252439     1  0.4225     0.4370 0.736 0.000 0.000 0.192 0.008 0.064
#> GSM252438     6  0.3725     0.1439 0.140 0.000 0.000 0.060 0.008 0.792
#> GSM252434     4  0.1007     0.5649 0.044 0.000 0.000 0.956 0.000 0.000
#> GSM252437     4  0.5564     0.3966 0.192 0.000 0.032 0.656 0.012 0.108
#> GSM252451     4  0.2969     0.4978 0.224 0.000 0.000 0.776 0.000 0.000
#> GSM252448     1  0.2364     0.4822 0.892 0.000 0.000 0.032 0.004 0.072
#> GSM252447     1  0.0725     0.5173 0.976 0.000 0.000 0.012 0.000 0.012
#> GSM252444     1  0.1765     0.5230 0.904 0.000 0.000 0.096 0.000 0.000
#> GSM252450     1  0.5659     0.0830 0.428 0.000 0.000 0.420 0.000 0.152
#> GSM252452     4  0.2605     0.5151 0.028 0.000 0.000 0.864 0.108 0.000
#> GSM252443     4  0.5916     0.2264 0.316 0.000 0.024 0.556 0.016 0.088
#> GSM252454     1  0.6021    -0.0423 0.396 0.000 0.000 0.360 0.000 0.244
#> GSM252449     4  0.1007     0.5649 0.044 0.000 0.000 0.956 0.000 0.000
#> GSM252445     4  0.4512     0.4848 0.056 0.000 0.140 0.760 0.012 0.032
#> GSM252453     4  0.3979     0.4499 0.256 0.000 0.000 0.708 0.000 0.036
#> GSM252464     4  0.6935     0.2462 0.092 0.000 0.240 0.464 0.000 0.204
#> GSM252463     4  0.5625     0.2331 0.032 0.000 0.076 0.536 0.000 0.356
#> GSM252461     1  0.6130    -0.1656 0.344 0.000 0.000 0.332 0.000 0.324
#> GSM252455     4  0.5855     0.3228 0.248 0.000 0.008 0.532 0.000 0.212
#> GSM252458     3  0.4773     0.3557 0.004 0.000 0.572 0.048 0.000 0.376
#> GSM252460     3  0.2981     0.7585 0.000 0.000 0.820 0.160 0.000 0.020
#> GSM252457     4  0.5451     0.2727 0.008 0.000 0.356 0.548 0.008 0.080
#> GSM252456     4  0.5050     0.3627 0.004 0.000 0.260 0.628 0.000 0.108
#> GSM252462     4  0.6164     0.2283 0.056 0.000 0.344 0.520 0.012 0.068
#> GSM252459     4  0.5448     0.4329 0.156 0.000 0.028 0.644 0.000 0.172
#> GSM252472     2  0.0632     0.9246 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM252466     2  0.2613     0.8898 0.000 0.848 0.000 0.000 0.140 0.012
#> GSM252469     2  0.2257     0.9040 0.000 0.876 0.000 0.000 0.116 0.008
#> GSM252475     2  0.1124     0.9253 0.000 0.956 0.000 0.000 0.036 0.008
#> GSM252471     2  0.0260     0.9284 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM252465     2  0.1010     0.9211 0.000 0.960 0.000 0.000 0.036 0.004
#> GSM252474     5  0.2768     0.7162 0.000 0.156 0.000 0.000 0.832 0.012
#> GSM252473     2  0.2266     0.9174 0.000 0.880 0.000 0.000 0.108 0.012
#> GSM252468     2  0.0935     0.9208 0.000 0.964 0.000 0.000 0.032 0.004
#> GSM252470     2  0.1334     0.9220 0.000 0.948 0.020 0.000 0.032 0.000
#> GSM252467     2  0.2446     0.8992 0.000 0.864 0.000 0.000 0.124 0.012
#> GSM252485     2  0.1524     0.9233 0.000 0.932 0.000 0.000 0.060 0.008
#> GSM252481     2  0.2653     0.8880 0.000 0.844 0.000 0.000 0.144 0.012
#> GSM252480     2  0.2357     0.9027 0.000 0.872 0.000 0.000 0.116 0.012
#> GSM252479     2  0.0713     0.9274 0.000 0.972 0.000 0.000 0.028 0.000
#> GSM252482     5  0.2416     0.8139 0.000 0.156 0.000 0.000 0.844 0.000
#> GSM252478     2  0.1116     0.9200 0.000 0.960 0.008 0.000 0.028 0.004
#> GSM252483     5  0.2048     0.8260 0.000 0.120 0.000 0.000 0.880 0.000
#> GSM252477     5  0.2092     0.8256 0.000 0.124 0.000 0.000 0.876 0.000
#> GSM252484     2  0.0935     0.9208 0.000 0.964 0.000 0.000 0.032 0.004
#> GSM252476     2  0.1700     0.9196 0.000 0.916 0.000 0.000 0.080 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)

plot of chunk tab-MAD-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-pam-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-pam-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-pam-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-pam-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-pam-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-pam-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-pam-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-pam-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-pam-membership-heatmap-5

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)

plot of chunk tab-MAD-pam-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-pam-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-pam-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-pam-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-pam-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-pam-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-pam-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-pam-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-pam-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-pam-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-pam-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-MAD-pam-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-pam-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-pam-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-pam-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-pam-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-pam-collect-classes

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 agent(p) individual(p) k
#> MAD:pam 60 1.22e-11         1.000 2
#> MAD:pam 60 6.38e-19         1.000 3
#> MAD:pam 59 1.26e-18         1.000 4
#> MAD:pam 47 9.51e-11         0.291 5
#> MAD:pam 41 3.59e-09         0.141 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.


MAD:mclust**

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 51941 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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:

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)

plot of chunk MAD-mclust-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.995       0.996         0.5072 0.492   0.492
#> 3 3 0.730           0.751       0.877         0.2845 0.851   0.705
#> 4 4 0.779           0.859       0.894         0.0980 0.821   0.571
#> 5 5 0.861           0.914       0.904         0.0727 0.924   0.743
#> 6 6 0.862           0.855       0.888         0.0500 0.966   0.852

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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette   p1   p2
#> GSM252423     2   0.141      0.986 0.02 0.98
#> GSM252429     2   0.141      0.986 0.02 0.98
#> GSM252424     2   0.141      0.986 0.02 0.98
#> GSM252432     2   0.141      0.986 0.02 0.98
#> GSM252427     2   0.141      0.986 0.02 0.98
#> GSM252431     2   0.141      0.986 0.02 0.98
#> GSM252430     2   0.141      0.986 0.02 0.98
#> GSM252433     2   0.141      0.986 0.02 0.98
#> GSM252426     2   0.141      0.986 0.02 0.98
#> GSM252428     2   0.141      0.986 0.02 0.98
#> GSM252425     2   0.141      0.986 0.02 0.98
#> GSM252440     1   0.000      1.000 1.00 0.00
#> GSM252441     1   0.000      1.000 1.00 0.00
#> GSM252436     1   0.000      1.000 1.00 0.00
#> GSM252435     1   0.000      1.000 1.00 0.00
#> GSM252442     1   0.000      1.000 1.00 0.00
#> GSM252439     1   0.000      1.000 1.00 0.00
#> GSM252438     1   0.000      1.000 1.00 0.00
#> GSM252434     1   0.000      1.000 1.00 0.00
#> GSM252437     1   0.000      1.000 1.00 0.00
#> GSM252451     1   0.000      1.000 1.00 0.00
#> GSM252448     1   0.000      1.000 1.00 0.00
#> GSM252447     1   0.000      1.000 1.00 0.00
#> GSM252444     1   0.000      1.000 1.00 0.00
#> GSM252450     1   0.000      1.000 1.00 0.00
#> GSM252452     1   0.000      1.000 1.00 0.00
#> GSM252443     1   0.000      1.000 1.00 0.00
#> GSM252454     1   0.000      1.000 1.00 0.00
#> GSM252449     1   0.000      1.000 1.00 0.00
#> GSM252445     1   0.000      1.000 1.00 0.00
#> GSM252453     1   0.000      1.000 1.00 0.00
#> GSM252464     1   0.000      1.000 1.00 0.00
#> GSM252463     1   0.000      1.000 1.00 0.00
#> GSM252461     1   0.000      1.000 1.00 0.00
#> GSM252455     1   0.000      1.000 1.00 0.00
#> GSM252458     1   0.000      1.000 1.00 0.00
#> GSM252460     1   0.000      1.000 1.00 0.00
#> GSM252457     1   0.000      1.000 1.00 0.00
#> GSM252456     1   0.000      1.000 1.00 0.00
#> GSM252462     1   0.000      1.000 1.00 0.00
#> GSM252459     1   0.000      1.000 1.00 0.00
#> GSM252472     2   0.000      0.993 0.00 1.00
#> GSM252466     2   0.000      0.993 0.00 1.00
#> GSM252469     2   0.000      0.993 0.00 1.00
#> GSM252475     2   0.000      0.993 0.00 1.00
#> GSM252471     2   0.000      0.993 0.00 1.00
#> GSM252465     2   0.000      0.993 0.00 1.00
#> GSM252474     2   0.000      0.993 0.00 1.00
#> GSM252473     2   0.000      0.993 0.00 1.00
#> GSM252468     2   0.000      0.993 0.00 1.00
#> GSM252470     2   0.000      0.993 0.00 1.00
#> GSM252467     2   0.000      0.993 0.00 1.00
#> GSM252485     2   0.000      0.993 0.00 1.00
#> GSM252481     2   0.000      0.993 0.00 1.00
#> GSM252480     2   0.000      0.993 0.00 1.00
#> GSM252479     2   0.000      0.993 0.00 1.00
#> GSM252482     2   0.000      0.993 0.00 1.00
#> GSM252478     2   0.000      0.993 0.00 1.00
#> GSM252483     2   0.000      0.993 0.00 1.00
#> GSM252477     2   0.000      0.993 0.00 1.00
#> GSM252484     2   0.000      0.993 0.00 1.00
#> GSM252476     2   0.000      0.993 0.00 1.00

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.6308      0.722 0.000 0.492 0.508
#> GSM252429     3  0.6291      0.744 0.000 0.468 0.532
#> GSM252424     3  0.6062      0.787 0.000 0.384 0.616
#> GSM252432     3  0.6308      0.722 0.000 0.492 0.508
#> GSM252427     3  0.6154      0.784 0.000 0.408 0.592
#> GSM252431     3  0.6079      0.787 0.000 0.388 0.612
#> GSM252430     3  0.0000      0.326 0.000 0.000 1.000
#> GSM252433     3  0.0424      0.345 0.000 0.008 0.992
#> GSM252426     3  0.6168      0.782 0.000 0.412 0.588
#> GSM252428     3  0.5706      0.739 0.000 0.320 0.680
#> GSM252425     3  0.1031      0.255 0.000 0.024 0.976
#> GSM252440     1  0.0000      0.815 1.000 0.000 0.000
#> GSM252441     1  0.0000      0.815 1.000 0.000 0.000
#> GSM252436     1  0.0000      0.815 1.000 0.000 0.000
#> GSM252435     1  0.0000      0.815 1.000 0.000 0.000
#> GSM252442     1  0.0000      0.815 1.000 0.000 0.000
#> GSM252439     1  0.4504      0.689 0.804 0.196 0.000
#> GSM252438     1  0.4504      0.689 0.804 0.196 0.000
#> GSM252434     1  0.0000      0.815 1.000 0.000 0.000
#> GSM252437     1  0.0000      0.815 1.000 0.000 0.000
#> GSM252451     1  0.0000      0.815 1.000 0.000 0.000
#> GSM252448     1  0.0000      0.815 1.000 0.000 0.000
#> GSM252447     1  0.0000      0.815 1.000 0.000 0.000
#> GSM252444     1  0.0000      0.815 1.000 0.000 0.000
#> GSM252450     1  0.0000      0.815 1.000 0.000 0.000
#> GSM252452     1  0.4504      0.689 0.804 0.196 0.000
#> GSM252443     1  0.4504      0.689 0.804 0.196 0.000
#> GSM252454     1  0.4504      0.689 0.804 0.196 0.000
#> GSM252449     1  0.0000      0.815 1.000 0.000 0.000
#> GSM252445     1  0.0000      0.815 1.000 0.000 0.000
#> GSM252453     1  0.0000      0.815 1.000 0.000 0.000
#> GSM252464     1  0.8674      0.498 0.568 0.296 0.136
#> GSM252463     1  0.8674      0.498 0.568 0.296 0.136
#> GSM252461     1  0.8674      0.498 0.568 0.296 0.136
#> GSM252455     1  0.8674      0.498 0.568 0.296 0.136
#> GSM252458     1  0.8674      0.498 0.568 0.296 0.136
#> GSM252460     1  0.8674      0.498 0.568 0.296 0.136
#> GSM252457     2  0.9004     -0.574 0.376 0.488 0.136
#> GSM252456     1  0.8674      0.498 0.568 0.296 0.136
#> GSM252462     1  0.8674      0.498 0.568 0.296 0.136
#> GSM252459     1  0.2959      0.771 0.900 0.100 0.000
#> GSM252472     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252466     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252469     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252475     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252471     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252465     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252474     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252473     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252468     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252470     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252467     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252485     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252481     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252480     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252479     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252482     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252478     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252483     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252477     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252484     2  0.6308      0.938 0.000 0.508 0.492
#> GSM252476     2  0.6308      0.938 0.000 0.508 0.492

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.1209      0.785 0.000 0.032 0.964 0.004
#> GSM252429     3  0.1211      0.785 0.000 0.040 0.960 0.000
#> GSM252424     3  0.1557      0.782 0.000 0.056 0.944 0.000
#> GSM252432     3  0.1209      0.785 0.000 0.032 0.964 0.004
#> GSM252427     3  0.1557      0.782 0.000 0.056 0.944 0.000
#> GSM252431     3  0.1743      0.781 0.000 0.056 0.940 0.004
#> GSM252430     3  0.3400      0.697 0.000 0.000 0.820 0.180
#> GSM252433     3  0.3356      0.699 0.000 0.000 0.824 0.176
#> GSM252426     3  0.1743      0.781 0.000 0.056 0.940 0.004
#> GSM252428     3  0.2197      0.764 0.000 0.080 0.916 0.004
#> GSM252425     3  0.3157      0.701 0.000 0.144 0.852 0.004
#> GSM252440     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM252441     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM252436     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM252435     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM252442     1  0.0188      0.908 0.996 0.000 0.004 0.000
#> GSM252439     1  0.5339      0.741 0.744 0.000 0.100 0.156
#> GSM252438     1  0.6709      0.572 0.616 0.000 0.212 0.172
#> GSM252434     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM252437     1  0.0336      0.907 0.992 0.000 0.000 0.008
#> GSM252451     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM252448     1  0.0188      0.909 0.996 0.000 0.000 0.004
#> GSM252447     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM252444     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM252450     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM252452     1  0.4662      0.785 0.796 0.000 0.092 0.112
#> GSM252443     1  0.3080      0.848 0.880 0.000 0.024 0.096
#> GSM252454     1  0.2053      0.870 0.924 0.000 0.004 0.072
#> GSM252449     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM252445     1  0.0188      0.909 0.996 0.000 0.000 0.004
#> GSM252453     1  0.0817      0.899 0.976 0.000 0.000 0.024
#> GSM252464     3  0.6149      0.738 0.144 0.000 0.676 0.180
#> GSM252463     3  0.6149      0.738 0.144 0.000 0.676 0.180
#> GSM252461     1  0.7290      0.105 0.504 0.000 0.328 0.168
#> GSM252455     3  0.6236      0.733 0.152 0.000 0.668 0.180
#> GSM252458     3  0.6149      0.738 0.144 0.000 0.676 0.180
#> GSM252460     3  0.6236      0.734 0.152 0.000 0.668 0.180
#> GSM252457     3  0.5910      0.730 0.088 0.000 0.676 0.236
#> GSM252456     3  0.6193      0.737 0.148 0.000 0.672 0.180
#> GSM252462     3  0.6360      0.723 0.164 0.000 0.656 0.180
#> GSM252459     1  0.5705      0.608 0.704 0.000 0.204 0.092
#> GSM252472     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252466     2  0.0188      0.995 0.000 0.996 0.000 0.004
#> GSM252469     2  0.0188      0.995 0.000 0.996 0.000 0.004
#> GSM252475     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252471     2  0.0188      0.995 0.000 0.996 0.000 0.004
#> GSM252465     2  0.0188      0.994 0.000 0.996 0.000 0.004
#> GSM252474     4  0.4277      0.970 0.000 0.280 0.000 0.720
#> GSM252473     2  0.0188      0.995 0.000 0.996 0.000 0.004
#> GSM252468     2  0.0188      0.994 0.000 0.996 0.000 0.004
#> GSM252470     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252467     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252485     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252481     2  0.0188      0.995 0.000 0.996 0.000 0.004
#> GSM252480     2  0.0188      0.995 0.000 0.996 0.000 0.004
#> GSM252479     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252482     4  0.4134      0.990 0.000 0.260 0.000 0.740
#> GSM252478     2  0.0188      0.994 0.000 0.996 0.000 0.004
#> GSM252483     4  0.4134      0.990 0.000 0.260 0.000 0.740
#> GSM252477     4  0.4134      0.990 0.000 0.260 0.000 0.740
#> GSM252484     2  0.0188      0.994 0.000 0.996 0.000 0.004
#> GSM252476     2  0.0000      0.997 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.2813     0.9786 0.000 0.000 0.832 0.168 0.000
#> GSM252429     3  0.3093     0.9772 0.000 0.000 0.824 0.168 0.008
#> GSM252424     3  0.3053     0.9807 0.000 0.008 0.828 0.164 0.000
#> GSM252432     3  0.2813     0.9786 0.000 0.000 0.832 0.168 0.000
#> GSM252427     3  0.2970     0.9802 0.000 0.004 0.828 0.168 0.000
#> GSM252431     3  0.3163     0.9803 0.000 0.012 0.824 0.164 0.000
#> GSM252430     3  0.4219     0.9392 0.000 0.000 0.772 0.156 0.072
#> GSM252433     3  0.3875     0.9592 0.000 0.000 0.792 0.160 0.048
#> GSM252426     3  0.3163     0.9803 0.000 0.012 0.824 0.164 0.000
#> GSM252428     3  0.3163     0.9803 0.000 0.012 0.824 0.164 0.000
#> GSM252425     3  0.3708     0.9693 0.000 0.020 0.808 0.160 0.012
#> GSM252440     1  0.2390     0.9156 0.912 0.000 0.044 0.012 0.032
#> GSM252441     1  0.2575     0.9138 0.904 0.000 0.044 0.016 0.036
#> GSM252436     1  0.1267     0.9204 0.960 0.000 0.012 0.004 0.024
#> GSM252435     1  0.1314     0.9232 0.960 0.000 0.012 0.012 0.016
#> GSM252442     1  0.1623     0.9197 0.948 0.000 0.020 0.016 0.016
#> GSM252439     1  0.5017     0.8106 0.748 0.000 0.148 0.052 0.052
#> GSM252438     1  0.5585     0.7830 0.712 0.000 0.144 0.080 0.064
#> GSM252434     1  0.1413     0.9205 0.956 0.000 0.020 0.012 0.012
#> GSM252437     1  0.1799     0.9205 0.940 0.000 0.012 0.028 0.020
#> GSM252451     1  0.1267     0.9204 0.960 0.000 0.012 0.004 0.024
#> GSM252448     1  0.2352     0.9160 0.912 0.000 0.048 0.008 0.032
#> GSM252447     1  0.2575     0.9138 0.904 0.000 0.044 0.016 0.036
#> GSM252444     1  0.1153     0.9222 0.964 0.000 0.008 0.004 0.024
#> GSM252450     1  0.1299     0.9236 0.960 0.000 0.008 0.012 0.020
#> GSM252452     1  0.4041     0.8586 0.804 0.000 0.140 0.032 0.024
#> GSM252443     1  0.4740     0.8230 0.764 0.000 0.148 0.048 0.040
#> GSM252454     1  0.3471     0.8871 0.860 0.000 0.044 0.048 0.048
#> GSM252449     1  0.1393     0.9212 0.956 0.000 0.024 0.012 0.008
#> GSM252445     1  0.1518     0.9196 0.952 0.000 0.016 0.020 0.012
#> GSM252453     1  0.1869     0.9192 0.936 0.000 0.016 0.036 0.012
#> GSM252464     4  0.1282     0.8972 0.044 0.000 0.004 0.952 0.000
#> GSM252463     4  0.1408     0.8962 0.044 0.000 0.008 0.948 0.000
#> GSM252461     4  0.2865     0.8156 0.132 0.000 0.004 0.856 0.008
#> GSM252455     4  0.1282     0.8972 0.044 0.000 0.004 0.952 0.000
#> GSM252458     4  0.1408     0.8962 0.044 0.000 0.008 0.948 0.000
#> GSM252460     4  0.1043     0.8962 0.040 0.000 0.000 0.960 0.000
#> GSM252457     4  0.1618     0.8311 0.008 0.000 0.040 0.944 0.008
#> GSM252456     4  0.1043     0.8962 0.040 0.000 0.000 0.960 0.000
#> GSM252462     4  0.1282     0.8961 0.044 0.000 0.000 0.952 0.004
#> GSM252459     4  0.5382    -0.0487 0.476 0.000 0.004 0.476 0.044
#> GSM252472     2  0.0290     0.9669 0.000 0.992 0.000 0.000 0.008
#> GSM252466     2  0.1341     0.9540 0.000 0.944 0.000 0.000 0.056
#> GSM252469     2  0.1341     0.9540 0.000 0.944 0.000 0.000 0.056
#> GSM252475     2  0.0162     0.9682 0.000 0.996 0.000 0.000 0.004
#> GSM252471     2  0.0510     0.9647 0.000 0.984 0.000 0.000 0.016
#> GSM252465     2  0.0404     0.9664 0.000 0.988 0.000 0.000 0.012
#> GSM252474     5  0.3039     0.9279 0.000 0.192 0.000 0.000 0.808
#> GSM252473     2  0.0510     0.9647 0.000 0.984 0.000 0.000 0.016
#> GSM252468     2  0.0510     0.9645 0.000 0.984 0.000 0.000 0.016
#> GSM252470     2  0.0703     0.9651 0.000 0.976 0.000 0.000 0.024
#> GSM252467     2  0.1270     0.9545 0.000 0.948 0.000 0.000 0.052
#> GSM252485     2  0.0290     0.9669 0.000 0.992 0.000 0.000 0.008
#> GSM252481     2  0.1341     0.9540 0.000 0.944 0.000 0.000 0.056
#> GSM252480     2  0.1341     0.9540 0.000 0.944 0.000 0.000 0.056
#> GSM252479     2  0.0162     0.9680 0.000 0.996 0.000 0.000 0.004
#> GSM252482     5  0.2773     0.9627 0.000 0.164 0.000 0.000 0.836
#> GSM252478     2  0.0609     0.9641 0.000 0.980 0.000 0.000 0.020
#> GSM252483     5  0.2605     0.9571 0.000 0.148 0.000 0.000 0.852
#> GSM252477     5  0.2813     0.9608 0.000 0.168 0.000 0.000 0.832
#> GSM252484     2  0.0703     0.9646 0.000 0.976 0.000 0.000 0.024
#> GSM252476     2  0.1270     0.9545 0.000 0.948 0.000 0.000 0.052

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.0000      0.830 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252429     3  0.0405      0.826 0.000 0.000 0.988 0.000 0.008 0.004
#> GSM252424     3  0.3136      0.867 0.000 0.000 0.768 0.000 0.004 0.228
#> GSM252432     3  0.0000      0.830 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252427     3  0.2996      0.867 0.000 0.000 0.772 0.000 0.000 0.228
#> GSM252431     3  0.2996      0.867 0.000 0.000 0.772 0.000 0.000 0.228
#> GSM252430     3  0.3426      0.699 0.000 0.000 0.808 0.000 0.124 0.068
#> GSM252433     3  0.3206      0.720 0.000 0.000 0.828 0.000 0.104 0.068
#> GSM252426     3  0.2996      0.867 0.000 0.000 0.772 0.000 0.000 0.228
#> GSM252428     3  0.2996      0.867 0.000 0.000 0.772 0.000 0.000 0.228
#> GSM252425     3  0.3217      0.866 0.000 0.000 0.768 0.000 0.008 0.224
#> GSM252440     1  0.1556      0.847 0.920 0.000 0.000 0.000 0.000 0.080
#> GSM252441     1  0.1663      0.843 0.912 0.000 0.000 0.000 0.000 0.088
#> GSM252436     1  0.1007      0.849 0.956 0.000 0.000 0.000 0.000 0.044
#> GSM252435     1  0.1267      0.859 0.940 0.000 0.000 0.000 0.000 0.060
#> GSM252442     1  0.1349      0.856 0.940 0.000 0.000 0.004 0.000 0.056
#> GSM252439     6  0.4285      0.940 0.320 0.000 0.000 0.036 0.000 0.644
#> GSM252438     6  0.4498      0.923 0.300 0.000 0.000 0.056 0.000 0.644
#> GSM252434     1  0.1204      0.858 0.944 0.000 0.000 0.000 0.000 0.056
#> GSM252437     1  0.1765      0.844 0.904 0.000 0.000 0.000 0.000 0.096
#> GSM252451     1  0.0937      0.851 0.960 0.000 0.000 0.000 0.000 0.040
#> GSM252448     1  0.1663      0.841 0.912 0.000 0.000 0.000 0.000 0.088
#> GSM252447     1  0.1663      0.843 0.912 0.000 0.000 0.000 0.000 0.088
#> GSM252444     1  0.1007      0.849 0.956 0.000 0.000 0.000 0.000 0.044
#> GSM252450     1  0.1075      0.861 0.952 0.000 0.000 0.000 0.000 0.048
#> GSM252452     1  0.4594     -0.715 0.488 0.000 0.000 0.036 0.000 0.476
#> GSM252443     6  0.4300      0.940 0.324 0.000 0.000 0.036 0.000 0.640
#> GSM252454     6  0.4508      0.842 0.396 0.000 0.000 0.036 0.000 0.568
#> GSM252449     1  0.1204      0.858 0.944 0.000 0.000 0.000 0.000 0.056
#> GSM252445     1  0.1075      0.863 0.952 0.000 0.000 0.000 0.000 0.048
#> GSM252453     1  0.1610      0.852 0.916 0.000 0.000 0.000 0.000 0.084
#> GSM252464     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM252463     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM252461     4  0.2030      0.861 0.064 0.000 0.000 0.908 0.000 0.028
#> GSM252455     4  0.0146      0.934 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM252458     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM252460     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM252457     4  0.0865      0.914 0.000 0.000 0.000 0.964 0.000 0.036
#> GSM252456     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM252462     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM252459     4  0.4963      0.390 0.240 0.000 0.000 0.636 0.000 0.124
#> GSM252472     2  0.0458      0.937 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM252466     2  0.2191      0.910 0.000 0.876 0.000 0.000 0.120 0.004
#> GSM252469     2  0.2146      0.912 0.000 0.880 0.000 0.000 0.116 0.004
#> GSM252475     2  0.0146      0.942 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM252471     2  0.1075      0.934 0.000 0.952 0.000 0.000 0.048 0.000
#> GSM252465     2  0.0547      0.936 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM252474     5  0.1663      0.908 0.000 0.088 0.000 0.000 0.912 0.000
#> GSM252473     2  0.1007      0.935 0.000 0.956 0.000 0.000 0.044 0.000
#> GSM252468     2  0.0458      0.938 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM252470     2  0.0632      0.938 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM252467     2  0.2100      0.913 0.000 0.884 0.000 0.000 0.112 0.004
#> GSM252485     2  0.0632      0.939 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM252481     2  0.2191      0.910 0.000 0.876 0.000 0.000 0.120 0.004
#> GSM252480     2  0.2100      0.913 0.000 0.884 0.000 0.000 0.112 0.004
#> GSM252479     2  0.0000      0.941 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252482     5  0.2092      0.936 0.000 0.124 0.000 0.000 0.876 0.000
#> GSM252478     2  0.0547      0.936 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM252483     5  0.1765      0.934 0.000 0.096 0.000 0.000 0.904 0.000
#> GSM252477     5  0.2135      0.933 0.000 0.128 0.000 0.000 0.872 0.000
#> GSM252484     2  0.0713      0.938 0.000 0.972 0.000 0.000 0.028 0.000
#> GSM252476     2  0.2100      0.913 0.000 0.884 0.000 0.000 0.112 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)

plot of chunk tab-MAD-mclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-mclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-mclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-mclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-mclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-mclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-mclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-mclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-mclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-mclust-membership-heatmap-5

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)

plot of chunk tab-MAD-mclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-mclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-mclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-mclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-mclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-mclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-MAD-mclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-mclust-collect-classes

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 agent(p) individual(p) k
#> MAD:mclust 62 4.69e-12         1.000 2
#> MAD:mclust 50 5.45e-17         1.000 3
#> MAD:mclust 61 1.28e-18         0.979 4
#> MAD:mclust 61 3.57e-29         0.999 5
#> MAD:mclust 60 3.12e-26         0.868 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.


MAD:NMF**

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 51941 rows and 62 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 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)

plot of chunk MAD-NMF-collect-plots

The plots are:

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:

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)

plot of chunk MAD-NMF-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.965           0.929       0.972         0.4966 0.505   0.505
#> 3 3 0.744           0.889       0.919         0.3376 0.745   0.529
#> 4 4 0.876           0.868       0.931         0.1114 0.914   0.744
#> 5 5 0.748           0.756       0.844         0.0520 0.967   0.880
#> 6 6 0.689           0.612       0.768         0.0443 0.941   0.777

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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1   0.242     0.9343 0.960 0.040
#> GSM252429     2   0.998     0.0171 0.476 0.524
#> GSM252424     1   0.456     0.8832 0.904 0.096
#> GSM252432     1   0.891     0.5711 0.692 0.308
#> GSM252427     1   0.541     0.8535 0.876 0.124
#> GSM252431     2   0.443     0.8783 0.092 0.908
#> GSM252430     2   0.000     0.9759 0.000 1.000
#> GSM252433     2   0.000     0.9759 0.000 1.000
#> GSM252426     1   0.680     0.7840 0.820 0.180
#> GSM252428     1   0.981     0.2954 0.580 0.420
#> GSM252425     2   0.000     0.9759 0.000 1.000
#> GSM252440     1   0.000     0.9657 1.000 0.000
#> GSM252441     1   0.000     0.9657 1.000 0.000
#> GSM252436     1   0.000     0.9657 1.000 0.000
#> GSM252435     1   0.000     0.9657 1.000 0.000
#> GSM252442     1   0.000     0.9657 1.000 0.000
#> GSM252439     1   0.000     0.9657 1.000 0.000
#> GSM252438     1   0.000     0.9657 1.000 0.000
#> GSM252434     1   0.000     0.9657 1.000 0.000
#> GSM252437     1   0.000     0.9657 1.000 0.000
#> GSM252451     1   0.000     0.9657 1.000 0.000
#> GSM252448     1   0.000     0.9657 1.000 0.000
#> GSM252447     1   0.000     0.9657 1.000 0.000
#> GSM252444     1   0.000     0.9657 1.000 0.000
#> GSM252450     1   0.000     0.9657 1.000 0.000
#> GSM252452     1   0.000     0.9657 1.000 0.000
#> GSM252443     1   0.000     0.9657 1.000 0.000
#> GSM252454     1   0.000     0.9657 1.000 0.000
#> GSM252449     1   0.000     0.9657 1.000 0.000
#> GSM252445     1   0.000     0.9657 1.000 0.000
#> GSM252453     1   0.000     0.9657 1.000 0.000
#> GSM252464     1   0.000     0.9657 1.000 0.000
#> GSM252463     1   0.000     0.9657 1.000 0.000
#> GSM252461     1   0.000     0.9657 1.000 0.000
#> GSM252455     1   0.000     0.9657 1.000 0.000
#> GSM252458     1   0.000     0.9657 1.000 0.000
#> GSM252460     1   0.000     0.9657 1.000 0.000
#> GSM252457     1   0.000     0.9657 1.000 0.000
#> GSM252456     1   0.000     0.9657 1.000 0.000
#> GSM252462     1   0.000     0.9657 1.000 0.000
#> GSM252459     1   0.000     0.9657 1.000 0.000
#> GSM252472     2   0.000     0.9759 0.000 1.000
#> GSM252466     2   0.000     0.9759 0.000 1.000
#> GSM252469     2   0.000     0.9759 0.000 1.000
#> GSM252475     2   0.000     0.9759 0.000 1.000
#> GSM252471     2   0.000     0.9759 0.000 1.000
#> GSM252465     2   0.000     0.9759 0.000 1.000
#> GSM252474     2   0.000     0.9759 0.000 1.000
#> GSM252473     2   0.000     0.9759 0.000 1.000
#> GSM252468     2   0.000     0.9759 0.000 1.000
#> GSM252470     2   0.000     0.9759 0.000 1.000
#> GSM252467     2   0.000     0.9759 0.000 1.000
#> GSM252485     2   0.000     0.9759 0.000 1.000
#> GSM252481     2   0.000     0.9759 0.000 1.000
#> GSM252480     2   0.000     0.9759 0.000 1.000
#> GSM252479     2   0.000     0.9759 0.000 1.000
#> GSM252482     2   0.000     0.9759 0.000 1.000
#> GSM252478     2   0.000     0.9759 0.000 1.000
#> GSM252483     2   0.000     0.9759 0.000 1.000
#> GSM252477     2   0.000     0.9759 0.000 1.000
#> GSM252484     2   0.000     0.9759 0.000 1.000
#> GSM252476     2   0.000     0.9759 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.3038      0.848 0.104 0.000 0.896
#> GSM252429     3  0.0983      0.807 0.016 0.004 0.980
#> GSM252424     3  0.4473      0.858 0.164 0.008 0.828
#> GSM252432     3  0.3038      0.848 0.104 0.000 0.896
#> GSM252427     3  0.3941      0.857 0.156 0.000 0.844
#> GSM252431     3  0.4465      0.758 0.004 0.176 0.820
#> GSM252430     3  0.1289      0.785 0.000 0.032 0.968
#> GSM252433     3  0.1643      0.778 0.000 0.044 0.956
#> GSM252426     3  0.4575      0.858 0.160 0.012 0.828
#> GSM252428     3  0.4782      0.772 0.016 0.164 0.820
#> GSM252425     3  0.5529      0.608 0.000 0.296 0.704
#> GSM252440     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252441     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252436     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252435     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252442     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252439     1  0.4733      0.767 0.800 0.004 0.196
#> GSM252438     1  0.4291      0.801 0.820 0.000 0.180
#> GSM252434     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252437     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252451     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252448     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252447     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252444     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252450     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252452     1  0.2711      0.897 0.912 0.000 0.088
#> GSM252443     1  0.1289      0.945 0.968 0.000 0.032
#> GSM252454     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252449     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252445     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252453     1  0.0000      0.970 1.000 0.000 0.000
#> GSM252464     3  0.4452      0.850 0.192 0.000 0.808
#> GSM252463     3  0.4974      0.814 0.236 0.000 0.764
#> GSM252461     1  0.0237      0.966 0.996 0.000 0.004
#> GSM252455     3  0.6274      0.446 0.456 0.000 0.544
#> GSM252458     3  0.4504      0.847 0.196 0.000 0.804
#> GSM252460     3  0.4399      0.851 0.188 0.000 0.812
#> GSM252457     3  0.4235      0.855 0.176 0.000 0.824
#> GSM252456     3  0.4399      0.851 0.188 0.000 0.812
#> GSM252462     3  0.6307      0.355 0.488 0.000 0.512
#> GSM252459     1  0.1964      0.912 0.944 0.000 0.056
#> GSM252472     2  0.0424      0.959 0.000 0.992 0.008
#> GSM252466     2  0.0592      0.957 0.000 0.988 0.012
#> GSM252469     2  0.0237      0.960 0.000 0.996 0.004
#> GSM252475     2  0.1643      0.943 0.000 0.956 0.044
#> GSM252471     2  0.0237      0.959 0.000 0.996 0.004
#> GSM252465     2  0.0237      0.960 0.000 0.996 0.004
#> GSM252474     2  0.4062      0.863 0.000 0.836 0.164
#> GSM252473     2  0.1529      0.945 0.000 0.960 0.040
#> GSM252468     2  0.0237      0.960 0.000 0.996 0.004
#> GSM252470     2  0.0237      0.960 0.000 0.996 0.004
#> GSM252467     2  0.0237      0.960 0.000 0.996 0.004
#> GSM252485     2  0.0424      0.959 0.000 0.992 0.008
#> GSM252481     2  0.0000      0.960 0.000 1.000 0.000
#> GSM252480     2  0.0000      0.960 0.000 1.000 0.000
#> GSM252479     2  0.0237      0.960 0.000 0.996 0.004
#> GSM252482     2  0.4346      0.847 0.000 0.816 0.184
#> GSM252478     2  0.0237      0.960 0.000 0.996 0.004
#> GSM252483     2  0.4346      0.847 0.000 0.816 0.184
#> GSM252477     2  0.4399      0.844 0.000 0.812 0.188
#> GSM252484     2  0.0237      0.960 0.000 0.996 0.004
#> GSM252476     2  0.0237      0.960 0.000 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.0469      0.872 0.000 0.000 0.988 0.012
#> GSM252429     3  0.1302      0.859 0.000 0.000 0.956 0.044
#> GSM252424     3  0.0188      0.874 0.000 0.000 0.996 0.004
#> GSM252432     3  0.0188      0.874 0.000 0.000 0.996 0.004
#> GSM252427     3  0.0000      0.874 0.000 0.000 1.000 0.000
#> GSM252431     3  0.0895      0.872 0.000 0.004 0.976 0.020
#> GSM252430     4  0.3545      0.756 0.000 0.008 0.164 0.828
#> GSM252433     4  0.4262      0.673 0.000 0.008 0.236 0.756
#> GSM252426     3  0.0592      0.873 0.000 0.000 0.984 0.016
#> GSM252428     3  0.2546      0.840 0.000 0.028 0.912 0.060
#> GSM252425     3  0.5099      0.363 0.000 0.380 0.612 0.008
#> GSM252440     1  0.0000      0.965 1.000 0.000 0.000 0.000
#> GSM252441     1  0.0000      0.965 1.000 0.000 0.000 0.000
#> GSM252436     1  0.0188      0.964 0.996 0.000 0.000 0.004
#> GSM252435     1  0.0000      0.965 1.000 0.000 0.000 0.000
#> GSM252442     1  0.1706      0.928 0.948 0.000 0.016 0.036
#> GSM252439     4  0.4356      0.591 0.292 0.000 0.000 0.708
#> GSM252438     4  0.3356      0.754 0.176 0.000 0.000 0.824
#> GSM252434     1  0.0921      0.948 0.972 0.000 0.000 0.028
#> GSM252437     1  0.0000      0.965 1.000 0.000 0.000 0.000
#> GSM252451     1  0.0000      0.965 1.000 0.000 0.000 0.000
#> GSM252448     1  0.0000      0.965 1.000 0.000 0.000 0.000
#> GSM252447     1  0.0000      0.965 1.000 0.000 0.000 0.000
#> GSM252444     1  0.0000      0.965 1.000 0.000 0.000 0.000
#> GSM252450     1  0.0000      0.965 1.000 0.000 0.000 0.000
#> GSM252452     1  0.4406      0.544 0.700 0.000 0.000 0.300
#> GSM252443     1  0.1716      0.916 0.936 0.000 0.000 0.064
#> GSM252454     1  0.0188      0.964 0.996 0.000 0.000 0.004
#> GSM252449     1  0.0188      0.964 0.996 0.000 0.000 0.004
#> GSM252445     1  0.0000      0.965 1.000 0.000 0.000 0.000
#> GSM252453     1  0.0188      0.964 0.996 0.000 0.000 0.004
#> GSM252464     3  0.0817      0.871 0.000 0.000 0.976 0.024
#> GSM252463     3  0.1978      0.832 0.068 0.000 0.928 0.004
#> GSM252461     1  0.0469      0.958 0.988 0.000 0.012 0.000
#> GSM252455     3  0.4800      0.482 0.340 0.000 0.656 0.004
#> GSM252458     3  0.0000      0.874 0.000 0.000 1.000 0.000
#> GSM252460     3  0.1474      0.861 0.000 0.000 0.948 0.052
#> GSM252457     3  0.2149      0.826 0.000 0.000 0.912 0.088
#> GSM252456     3  0.1022      0.869 0.000 0.000 0.968 0.032
#> GSM252462     3  0.5112      0.249 0.436 0.000 0.560 0.004
#> GSM252459     1  0.2773      0.839 0.880 0.000 0.116 0.004
#> GSM252472     2  0.1022      0.952 0.000 0.968 0.000 0.032
#> GSM252466     2  0.2149      0.916 0.000 0.912 0.000 0.088
#> GSM252469     2  0.0188      0.955 0.000 0.996 0.000 0.004
#> GSM252475     2  0.3400      0.810 0.000 0.820 0.000 0.180
#> GSM252471     2  0.1022      0.952 0.000 0.968 0.000 0.032
#> GSM252465     2  0.1302      0.938 0.000 0.956 0.000 0.044
#> GSM252474     4  0.2868      0.798 0.000 0.136 0.000 0.864
#> GSM252473     2  0.2530      0.893 0.000 0.888 0.000 0.112
#> GSM252468     2  0.1302      0.938 0.000 0.956 0.000 0.044
#> GSM252470     2  0.0817      0.948 0.000 0.976 0.000 0.024
#> GSM252467     2  0.0188      0.955 0.000 0.996 0.000 0.004
#> GSM252485     2  0.0817      0.955 0.000 0.976 0.000 0.024
#> GSM252481     2  0.0921      0.954 0.000 0.972 0.000 0.028
#> GSM252480     2  0.0707      0.955 0.000 0.980 0.000 0.020
#> GSM252479     2  0.0592      0.956 0.000 0.984 0.000 0.016
#> GSM252482     4  0.2011      0.840 0.000 0.080 0.000 0.920
#> GSM252478     2  0.1557      0.929 0.000 0.944 0.000 0.056
#> GSM252483     4  0.2149      0.837 0.000 0.088 0.000 0.912
#> GSM252477     4  0.2011      0.840 0.000 0.080 0.000 0.920
#> GSM252484     2  0.1211      0.944 0.000 0.960 0.000 0.040
#> GSM252476     2  0.0592      0.956 0.000 0.984 0.000 0.016

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3 p4    p5
#> GSM252423     3  0.0510      0.804 0.000 0.000 0.984 NA 0.000
#> GSM252429     3  0.1671      0.785 0.000 0.000 0.924 NA 0.000
#> GSM252424     3  0.0771      0.803 0.000 0.004 0.976 NA 0.000
#> GSM252432     3  0.0510      0.808 0.000 0.000 0.984 NA 0.000
#> GSM252427     3  0.1197      0.808 0.000 0.000 0.952 NA 0.000
#> GSM252431     3  0.3957      0.709 0.000 0.008 0.712 NA 0.000
#> GSM252430     5  0.3197      0.657 0.000 0.000 0.140 NA 0.836
#> GSM252433     5  0.6302      0.156 0.004 0.000 0.420 NA 0.444
#> GSM252426     3  0.2648      0.778 0.000 0.000 0.848 NA 0.000
#> GSM252428     3  0.5238      0.481 0.000 0.044 0.484 NA 0.000
#> GSM252425     3  0.4540      0.492 0.000 0.320 0.656 NA 0.000
#> GSM252440     1  0.0510      0.867 0.984 0.000 0.000 NA 0.000
#> GSM252441     1  0.0794      0.865 0.972 0.000 0.000 NA 0.000
#> GSM252436     1  0.0404      0.869 0.988 0.000 0.000 NA 0.000
#> GSM252435     1  0.0609      0.869 0.980 0.000 0.000 NA 0.000
#> GSM252442     1  0.4451      0.416 0.504 0.000 0.004 NA 0.000
#> GSM252439     5  0.5142      0.456 0.348 0.000 0.000 NA 0.600
#> GSM252438     5  0.8393      0.376 0.308 0.036 0.048 NA 0.324
#> GSM252434     1  0.3857      0.661 0.688 0.000 0.000 NA 0.000
#> GSM252437     1  0.1851      0.844 0.912 0.000 0.000 NA 0.000
#> GSM252451     1  0.0404      0.870 0.988 0.000 0.000 NA 0.000
#> GSM252448     1  0.0404      0.868 0.988 0.000 0.000 NA 0.000
#> GSM252447     1  0.0963      0.863 0.964 0.000 0.000 NA 0.000
#> GSM252444     1  0.0609      0.870 0.980 0.000 0.000 NA 0.000
#> GSM252450     1  0.0703      0.868 0.976 0.000 0.000 NA 0.000
#> GSM252452     5  0.6597      0.395 0.244 0.000 0.000 NA 0.460
#> GSM252443     1  0.1579      0.851 0.944 0.000 0.000 NA 0.032
#> GSM252454     1  0.1041      0.864 0.964 0.004 0.000 NA 0.000
#> GSM252449     1  0.3636      0.704 0.728 0.000 0.000 NA 0.000
#> GSM252445     1  0.2929      0.787 0.820 0.000 0.000 NA 0.000
#> GSM252453     1  0.1082      0.868 0.964 0.008 0.000 NA 0.000
#> GSM252464     3  0.0794      0.809 0.000 0.000 0.972 NA 0.000
#> GSM252463     3  0.1661      0.793 0.036 0.000 0.940 NA 0.000
#> GSM252461     1  0.1331      0.857 0.952 0.000 0.040 NA 0.000
#> GSM252455     3  0.3845      0.625 0.208 0.000 0.768 NA 0.000
#> GSM252458     3  0.1043      0.809 0.000 0.000 0.960 NA 0.000
#> GSM252460     3  0.4256      0.571 0.000 0.000 0.564 NA 0.000
#> GSM252457     3  0.3396      0.730 0.008 0.000 0.844 NA 0.036
#> GSM252456     3  0.3966      0.662 0.000 0.000 0.664 NA 0.000
#> GSM252462     1  0.6439      0.309 0.460 0.000 0.184 NA 0.000
#> GSM252459     1  0.3106      0.778 0.856 0.008 0.116 NA 0.000
#> GSM252472     2  0.2561      0.886 0.000 0.884 0.000 NA 0.020
#> GSM252466     2  0.3692      0.851 0.000 0.812 0.000 NA 0.052
#> GSM252469     2  0.0880      0.896 0.000 0.968 0.000 NA 0.000
#> GSM252475     2  0.3759      0.833 0.000 0.808 0.000 NA 0.136
#> GSM252471     2  0.2370      0.891 0.000 0.904 0.000 NA 0.056
#> GSM252465     2  0.2732      0.858 0.000 0.840 0.000 NA 0.000
#> GSM252474     5  0.0451      0.729 0.000 0.008 0.000 NA 0.988
#> GSM252473     2  0.2504      0.886 0.000 0.896 0.000 NA 0.040
#> GSM252468     2  0.3530      0.824 0.000 0.784 0.000 NA 0.012
#> GSM252470     2  0.2338      0.876 0.000 0.884 0.000 NA 0.004
#> GSM252467     2  0.0703      0.897 0.000 0.976 0.000 NA 0.000
#> GSM252485     2  0.2006      0.895 0.000 0.916 0.000 NA 0.012
#> GSM252481     2  0.2921      0.870 0.000 0.856 0.000 NA 0.020
#> GSM252480     2  0.1648      0.897 0.000 0.940 0.000 NA 0.020
#> GSM252479     2  0.1626      0.899 0.000 0.940 0.000 NA 0.016
#> GSM252482     5  0.0510      0.729 0.000 0.000 0.000 NA 0.984
#> GSM252478     2  0.3969      0.735 0.000 0.692 0.000 NA 0.004
#> GSM252483     5  0.0324      0.730 0.000 0.004 0.000 NA 0.992
#> GSM252477     5  0.0609      0.729 0.000 0.000 0.000 NA 0.980
#> GSM252484     2  0.3694      0.840 0.000 0.796 0.000 NA 0.032
#> GSM252476     2  0.1410      0.893 0.000 0.940 0.000 NA 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.1152     0.7565 0.000 0.000 0.952 0.004 0.000 0.044
#> GSM252429     3  0.3098     0.7015 0.000 0.000 0.844 0.064 0.004 0.088
#> GSM252424     3  0.0748     0.7580 0.000 0.004 0.976 0.004 0.000 0.016
#> GSM252432     3  0.0820     0.7593 0.000 0.000 0.972 0.012 0.000 0.016
#> GSM252427     3  0.1391     0.7537 0.000 0.000 0.944 0.040 0.000 0.016
#> GSM252431     3  0.6390     0.0453 0.000 0.052 0.464 0.352 0.000 0.132
#> GSM252430     5  0.3178     0.5868 0.000 0.000 0.056 0.016 0.848 0.080
#> GSM252433     6  0.6295     0.4254 0.000 0.004 0.200 0.012 0.356 0.428
#> GSM252426     3  0.2743     0.6626 0.000 0.000 0.828 0.164 0.000 0.008
#> GSM252428     4  0.5626    -0.0516 0.000 0.048 0.428 0.476 0.000 0.048
#> GSM252425     2  0.6017     0.1566 0.000 0.464 0.388 0.028 0.000 0.120
#> GSM252440     1  0.1572     0.8313 0.936 0.000 0.000 0.028 0.000 0.036
#> GSM252441     1  0.1408     0.8288 0.944 0.000 0.000 0.036 0.000 0.020
#> GSM252436     1  0.1563     0.8295 0.932 0.000 0.000 0.056 0.000 0.012
#> GSM252435     1  0.1708     0.8303 0.932 0.000 0.004 0.040 0.000 0.024
#> GSM252442     4  0.4246     0.0798 0.408 0.000 0.008 0.576 0.000 0.008
#> GSM252439     5  0.6083     0.1502 0.268 0.000 0.004 0.044 0.564 0.120
#> GSM252438     6  0.6518     0.4693 0.144 0.004 0.028 0.032 0.224 0.568
#> GSM252434     1  0.3905     0.4297 0.636 0.000 0.004 0.356 0.000 0.004
#> GSM252437     1  0.2431     0.7801 0.860 0.000 0.000 0.132 0.000 0.008
#> GSM252451     1  0.1265     0.8284 0.948 0.000 0.000 0.044 0.000 0.008
#> GSM252448     1  0.0820     0.8293 0.972 0.000 0.000 0.016 0.000 0.012
#> GSM252447     1  0.1480     0.8294 0.940 0.000 0.000 0.040 0.000 0.020
#> GSM252444     1  0.1930     0.8271 0.916 0.000 0.000 0.048 0.000 0.036
#> GSM252450     1  0.1245     0.8309 0.952 0.000 0.000 0.032 0.000 0.016
#> GSM252452     5  0.5878     0.2455 0.164 0.000 0.000 0.208 0.592 0.036
#> GSM252443     1  0.3732     0.7290 0.808 0.000 0.000 0.020 0.104 0.068
#> GSM252454     1  0.3637     0.7267 0.788 0.008 0.000 0.040 0.000 0.164
#> GSM252449     1  0.3668     0.5136 0.668 0.000 0.000 0.328 0.000 0.004
#> GSM252445     1  0.3695     0.6519 0.732 0.000 0.000 0.244 0.000 0.024
#> GSM252453     1  0.4232     0.7363 0.784 0.072 0.000 0.064 0.000 0.080
#> GSM252464     3  0.1672     0.7532 0.004 0.000 0.932 0.048 0.000 0.016
#> GSM252463     3  0.3205     0.7223 0.040 0.000 0.852 0.036 0.000 0.072
#> GSM252461     1  0.1701     0.8018 0.920 0.000 0.072 0.000 0.000 0.008
#> GSM252455     3  0.4276     0.5392 0.160 0.000 0.756 0.056 0.000 0.028
#> GSM252458     3  0.2002     0.7406 0.004 0.000 0.908 0.076 0.000 0.012
#> GSM252460     4  0.4538    -0.0117 0.008 0.000 0.436 0.536 0.000 0.020
#> GSM252457     3  0.5339     0.2103 0.024 0.000 0.564 0.016 0.032 0.364
#> GSM252456     3  0.3756     0.3384 0.000 0.000 0.644 0.352 0.000 0.004
#> GSM252462     4  0.6238     0.2238 0.372 0.000 0.092 0.472 0.000 0.064
#> GSM252459     1  0.6193     0.5275 0.652 0.052 0.088 0.076 0.000 0.132
#> GSM252472     2  0.3825     0.7126 0.000 0.768 0.000 0.072 0.000 0.160
#> GSM252466     2  0.5374     0.6253 0.000 0.632 0.000 0.100 0.028 0.240
#> GSM252469     2  0.2425     0.7529 0.000 0.884 0.000 0.024 0.004 0.088
#> GSM252475     2  0.4543     0.7167 0.000 0.752 0.000 0.052 0.068 0.128
#> GSM252471     2  0.3878     0.7496 0.000 0.792 0.000 0.032 0.040 0.136
#> GSM252465     2  0.4847     0.6493 0.000 0.656 0.000 0.220 0.000 0.124
#> GSM252474     5  0.2063     0.6631 0.000 0.020 0.000 0.008 0.912 0.060
#> GSM252473     2  0.3381     0.7399 0.000 0.808 0.000 0.040 0.004 0.148
#> GSM252468     2  0.5560     0.6526 0.000 0.616 0.000 0.240 0.032 0.112
#> GSM252470     2  0.4727     0.7080 0.000 0.708 0.000 0.152 0.012 0.128
#> GSM252467     2  0.1983     0.7507 0.000 0.908 0.000 0.020 0.000 0.072
#> GSM252485     2  0.3923     0.7045 0.000 0.748 0.000 0.060 0.000 0.192
#> GSM252481     2  0.4478     0.6728 0.000 0.688 0.000 0.084 0.000 0.228
#> GSM252480     2  0.3663     0.7401 0.000 0.792 0.000 0.040 0.012 0.156
#> GSM252479     2  0.4020     0.7390 0.000 0.764 0.000 0.068 0.008 0.160
#> GSM252482     5  0.0291     0.6966 0.000 0.004 0.000 0.000 0.992 0.004
#> GSM252478     2  0.5606     0.5248 0.000 0.512 0.000 0.324 0.000 0.164
#> GSM252483     5  0.0603     0.6944 0.000 0.004 0.000 0.000 0.980 0.016
#> GSM252477     5  0.0692     0.6904 0.000 0.000 0.000 0.004 0.976 0.020
#> GSM252484     2  0.5725     0.6551 0.000 0.612 0.000 0.208 0.036 0.144
#> GSM252476     2  0.1895     0.7502 0.000 0.912 0.000 0.016 0.000 0.072

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-NMF-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-NMF-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-NMF-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-NMF-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-NMF-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-NMF-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-NMF-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-NMF-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-NMF-membership-heatmap-5

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)

plot of chunk tab-MAD-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-NMF-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-MAD-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-NMF-collect-classes

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 agent(p) individual(p) k
#> MAD:NMF 60 9.25e-10         0.984 2
#> MAD:NMF 60 4.01e-19         1.000 3
#> MAD:NMF 59 2.01e-14         0.217 4
#> MAD:NMF 54 6.11e-14         0.406 5
#> MAD:NMF 49 5.83e-12         0.225 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.


ATC:hclust**

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 51941 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

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:

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)

plot of chunk ATC-hclust-select-partition-number

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.4559 0.545   0.545
#> 3 3 0.863           0.797       0.923         0.4010 0.808   0.647
#> 4 4 0.793           0.736       0.861         0.1379 0.873   0.660
#> 5 5 0.838           0.703       0.862         0.0323 0.966   0.876
#> 6 6 0.788           0.667       0.823         0.0279 0.981   0.924

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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1  0.0000      1.000 1.000 0.000
#> GSM252429     1  0.0000      1.000 1.000 0.000
#> GSM252424     1  0.0000      1.000 1.000 0.000
#> GSM252432     1  0.0000      1.000 1.000 0.000
#> GSM252427     1  0.0000      1.000 1.000 0.000
#> GSM252431     1  0.0000      1.000 1.000 0.000
#> GSM252430     1  0.0376      0.996 0.996 0.004
#> GSM252433     1  0.0376      0.996 0.996 0.004
#> GSM252426     1  0.0000      1.000 1.000 0.000
#> GSM252428     1  0.0000      1.000 1.000 0.000
#> GSM252425     1  0.0376      0.996 0.996 0.004
#> GSM252440     1  0.0000      1.000 1.000 0.000
#> GSM252441     1  0.0000      1.000 1.000 0.000
#> GSM252436     1  0.0000      1.000 1.000 0.000
#> GSM252435     1  0.0000      1.000 1.000 0.000
#> GSM252442     1  0.0000      1.000 1.000 0.000
#> GSM252439     1  0.0000      1.000 1.000 0.000
#> GSM252438     1  0.0000      1.000 1.000 0.000
#> GSM252434     1  0.0000      1.000 1.000 0.000
#> GSM252437     1  0.0000      1.000 1.000 0.000
#> GSM252451     1  0.0000      1.000 1.000 0.000
#> GSM252448     1  0.0000      1.000 1.000 0.000
#> GSM252447     1  0.0000      1.000 1.000 0.000
#> GSM252444     1  0.0000      1.000 1.000 0.000
#> GSM252450     1  0.0000      1.000 1.000 0.000
#> GSM252452     1  0.0000      1.000 1.000 0.000
#> GSM252443     1  0.0000      1.000 1.000 0.000
#> GSM252454     1  0.0000      1.000 1.000 0.000
#> GSM252449     1  0.0000      1.000 1.000 0.000
#> GSM252445     1  0.0000      1.000 1.000 0.000
#> GSM252453     1  0.0000      1.000 1.000 0.000
#> GSM252464     1  0.0000      1.000 1.000 0.000
#> GSM252463     1  0.0000      1.000 1.000 0.000
#> GSM252461     1  0.0000      1.000 1.000 0.000
#> GSM252455     1  0.0000      1.000 1.000 0.000
#> GSM252458     1  0.0000      1.000 1.000 0.000
#> GSM252460     1  0.0000      1.000 1.000 0.000
#> GSM252457     1  0.0000      1.000 1.000 0.000
#> GSM252456     1  0.0000      1.000 1.000 0.000
#> GSM252462     1  0.0000      1.000 1.000 0.000
#> GSM252459     1  0.0000      1.000 1.000 0.000
#> GSM252472     2  0.0000      1.000 0.000 1.000
#> GSM252466     2  0.0000      1.000 0.000 1.000
#> GSM252469     2  0.0000      1.000 0.000 1.000
#> GSM252475     2  0.0000      1.000 0.000 1.000
#> GSM252471     2  0.0000      1.000 0.000 1.000
#> GSM252465     2  0.0000      1.000 0.000 1.000
#> GSM252474     2  0.0000      1.000 0.000 1.000
#> GSM252473     2  0.0000      1.000 0.000 1.000
#> GSM252468     2  0.0000      1.000 0.000 1.000
#> GSM252470     2  0.0000      1.000 0.000 1.000
#> GSM252467     2  0.0000      1.000 0.000 1.000
#> GSM252485     2  0.0000      1.000 0.000 1.000
#> GSM252481     2  0.0000      1.000 0.000 1.000
#> GSM252480     2  0.0000      1.000 0.000 1.000
#> GSM252479     2  0.0000      1.000 0.000 1.000
#> GSM252482     2  0.0000      1.000 0.000 1.000
#> GSM252478     2  0.0000      1.000 0.000 1.000
#> GSM252483     2  0.0000      1.000 0.000 1.000
#> GSM252477     2  0.0000      1.000 0.000 1.000
#> GSM252484     2  0.0000      1.000 0.000 1.000
#> GSM252476     2  0.0000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM252423     3  0.6192      0.356 0.420  0 0.580
#> GSM252429     3  0.6192      0.356 0.420  0 0.580
#> GSM252424     3  0.1753      0.759 0.048  0 0.952
#> GSM252432     3  0.6192      0.356 0.420  0 0.580
#> GSM252427     3  0.0237      0.773 0.004  0 0.996
#> GSM252431     3  0.0237      0.773 0.004  0 0.996
#> GSM252430     3  0.0000      0.771 0.000  0 1.000
#> GSM252433     3  0.0000      0.771 0.000  0 1.000
#> GSM252426     3  0.0592      0.773 0.012  0 0.988
#> GSM252428     3  0.0592      0.773 0.012  0 0.988
#> GSM252425     3  0.0000      0.771 0.000  0 1.000
#> GSM252440     1  0.0000      0.881 1.000  0 0.000
#> GSM252441     1  0.0000      0.881 1.000  0 0.000
#> GSM252436     1  0.0000      0.881 1.000  0 0.000
#> GSM252435     1  0.0237      0.880 0.996  0 0.004
#> GSM252442     1  0.0237      0.880 0.996  0 0.004
#> GSM252439     1  0.5678      0.449 0.684  0 0.316
#> GSM252438     3  0.6299      0.149 0.476  0 0.524
#> GSM252434     1  0.0237      0.880 0.996  0 0.004
#> GSM252437     1  0.1964      0.843 0.944  0 0.056
#> GSM252451     1  0.0000      0.881 1.000  0 0.000
#> GSM252448     1  0.0000      0.881 1.000  0 0.000
#> GSM252447     1  0.0000      0.881 1.000  0 0.000
#> GSM252444     1  0.0000      0.881 1.000  0 0.000
#> GSM252450     1  0.0237      0.880 0.996  0 0.004
#> GSM252452     1  0.1964      0.843 0.944  0 0.056
#> GSM252443     1  0.5678      0.449 0.684  0 0.316
#> GSM252454     3  0.6299      0.149 0.476  0 0.524
#> GSM252449     1  0.0237      0.880 0.996  0 0.004
#> GSM252445     1  0.1964      0.843 0.944  0 0.056
#> GSM252453     1  0.6235      0.107 0.564  0 0.436
#> GSM252464     1  0.0000      0.881 1.000  0 0.000
#> GSM252463     1  0.0000      0.881 1.000  0 0.000
#> GSM252461     1  0.0000      0.881 1.000  0 0.000
#> GSM252455     1  0.0000      0.881 1.000  0 0.000
#> GSM252458     1  0.0000      0.881 1.000  0 0.000
#> GSM252460     1  0.0000      0.881 1.000  0 0.000
#> GSM252457     1  0.6154      0.194 0.592  0 0.408
#> GSM252456     1  0.0000      0.881 1.000  0 0.000
#> GSM252462     1  0.6026      0.294 0.624  0 0.376
#> GSM252459     1  0.6235      0.107 0.564  0 0.436
#> GSM252472     2  0.0000      1.000 0.000  1 0.000
#> GSM252466     2  0.0000      1.000 0.000  1 0.000
#> GSM252469     2  0.0000      1.000 0.000  1 0.000
#> GSM252475     2  0.0000      1.000 0.000  1 0.000
#> GSM252471     2  0.0000      1.000 0.000  1 0.000
#> GSM252465     2  0.0000      1.000 0.000  1 0.000
#> GSM252474     2  0.0000      1.000 0.000  1 0.000
#> GSM252473     2  0.0000      1.000 0.000  1 0.000
#> GSM252468     2  0.0000      1.000 0.000  1 0.000
#> GSM252470     2  0.0000      1.000 0.000  1 0.000
#> GSM252467     2  0.0000      1.000 0.000  1 0.000
#> GSM252485     2  0.0000      1.000 0.000  1 0.000
#> GSM252481     2  0.0000      1.000 0.000  1 0.000
#> GSM252480     2  0.0000      1.000 0.000  1 0.000
#> GSM252479     2  0.0000      1.000 0.000  1 0.000
#> GSM252482     2  0.0000      1.000 0.000  1 0.000
#> GSM252478     2  0.0000      1.000 0.000  1 0.000
#> GSM252483     2  0.0000      1.000 0.000  1 0.000
#> GSM252477     2  0.0000      1.000 0.000  1 0.000
#> GSM252484     2  0.0000      1.000 0.000  1 0.000
#> GSM252476     2  0.0000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM252423     4  0.5576      0.375 0.020  0 0.444 0.536
#> GSM252429     4  0.5576      0.375 0.020  0 0.444 0.536
#> GSM252424     3  0.2675      0.732 0.008  0 0.892 0.100
#> GSM252432     4  0.5576      0.375 0.020  0 0.444 0.536
#> GSM252427     3  0.3726      0.823 0.000  0 0.788 0.212
#> GSM252431     3  0.3726      0.823 0.000  0 0.788 0.212
#> GSM252430     3  0.0592      0.810 0.000  0 0.984 0.016
#> GSM252433     3  0.3356      0.813 0.000  0 0.824 0.176
#> GSM252426     3  0.1576      0.801 0.004  0 0.948 0.048
#> GSM252428     3  0.1576      0.801 0.004  0 0.948 0.048
#> GSM252425     3  0.3356      0.813 0.000  0 0.824 0.176
#> GSM252440     1  0.0188      0.795 0.996  0 0.000 0.004
#> GSM252441     1  0.0188      0.795 0.996  0 0.000 0.004
#> GSM252436     1  0.0188      0.795 0.996  0 0.000 0.004
#> GSM252435     1  0.4843      0.475 0.604  0 0.000 0.396
#> GSM252442     1  0.4888      0.446 0.588  0 0.000 0.412
#> GSM252439     4  0.4538      0.562 0.024  0 0.216 0.760
#> GSM252438     4  0.4343      0.294 0.004  0 0.264 0.732
#> GSM252434     1  0.4843      0.475 0.604  0 0.000 0.396
#> GSM252437     1  0.5000      0.204 0.500  0 0.000 0.500
#> GSM252451     1  0.0188      0.795 0.996  0 0.000 0.004
#> GSM252448     1  0.0188      0.795 0.996  0 0.000 0.004
#> GSM252447     1  0.0188      0.795 0.996  0 0.000 0.004
#> GSM252444     1  0.0188      0.795 0.996  0 0.000 0.004
#> GSM252450     1  0.4843      0.475 0.604  0 0.000 0.396
#> GSM252452     4  0.4277      0.325 0.280  0 0.000 0.720
#> GSM252443     4  0.4538      0.562 0.024  0 0.216 0.760
#> GSM252454     4  0.4343      0.294 0.004  0 0.264 0.732
#> GSM252449     1  0.4843      0.475 0.604  0 0.000 0.396
#> GSM252445     4  0.5000     -0.302 0.500  0 0.000 0.500
#> GSM252453     4  0.3539      0.433 0.004  0 0.176 0.820
#> GSM252464     1  0.0592      0.788 0.984  0 0.000 0.016
#> GSM252463     1  0.0592      0.788 0.984  0 0.000 0.016
#> GSM252461     1  0.0592      0.788 0.984  0 0.000 0.016
#> GSM252455     1  0.0592      0.788 0.984  0 0.000 0.016
#> GSM252458     1  0.2647      0.753 0.880  0 0.000 0.120
#> GSM252460     1  0.3801      0.682 0.780  0 0.000 0.220
#> GSM252457     4  0.7225      0.511 0.160  0 0.328 0.512
#> GSM252456     1  0.2647      0.753 0.880  0 0.000 0.120
#> GSM252462     4  0.7429      0.502 0.192  0 0.316 0.492
#> GSM252459     4  0.3539      0.433 0.004  0 0.176 0.820
#> GSM252472     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252466     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252469     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252475     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252471     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252465     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252474     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252473     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252468     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252470     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252467     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252485     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252481     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252480     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252479     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252482     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252478     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252483     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252477     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252484     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM252476     2  0.0000      1.000 0.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     5  0.0000      0.696 0.000 0.000 0.000 0.000 1.000
#> GSM252429     5  0.0000      0.696 0.000 0.000 0.000 0.000 1.000
#> GSM252424     3  0.4948      0.546 0.000 0.000 0.536 0.028 0.436
#> GSM252432     5  0.0000      0.696 0.000 0.000 0.000 0.000 1.000
#> GSM252427     3  0.1981      0.742 0.000 0.000 0.924 0.028 0.048
#> GSM252431     3  0.1981      0.742 0.000 0.000 0.924 0.028 0.048
#> GSM252430     3  0.4040      0.681 0.000 0.000 0.724 0.016 0.260
#> GSM252433     3  0.0000      0.721 0.000 0.000 1.000 0.000 0.000
#> GSM252426     3  0.4824      0.626 0.000 0.000 0.596 0.028 0.376
#> GSM252428     3  0.4824      0.626 0.000 0.000 0.596 0.028 0.376
#> GSM252425     3  0.0162      0.719 0.000 0.000 0.996 0.004 0.000
#> GSM252440     1  0.0510      0.810 0.984 0.000 0.000 0.016 0.000
#> GSM252441     1  0.0510      0.810 0.984 0.000 0.000 0.016 0.000
#> GSM252436     1  0.0510      0.810 0.984 0.000 0.000 0.016 0.000
#> GSM252435     1  0.4201      0.376 0.592 0.000 0.000 0.408 0.000
#> GSM252442     1  0.4235      0.339 0.576 0.000 0.000 0.424 0.000
#> GSM252439     4  0.2753      0.456 0.008 0.000 0.000 0.856 0.136
#> GSM252438     4  0.4060      0.397 0.000 0.000 0.360 0.640 0.000
#> GSM252434     1  0.4201      0.376 0.592 0.000 0.000 0.408 0.000
#> GSM252437     4  0.4305     -0.170 0.488 0.000 0.000 0.512 0.000
#> GSM252451     1  0.0510      0.810 0.984 0.000 0.000 0.016 0.000
#> GSM252448     1  0.0510      0.810 0.984 0.000 0.000 0.016 0.000
#> GSM252447     1  0.0510      0.810 0.984 0.000 0.000 0.016 0.000
#> GSM252444     1  0.0510      0.810 0.984 0.000 0.000 0.016 0.000
#> GSM252450     1  0.4201      0.376 0.592 0.000 0.000 0.408 0.000
#> GSM252452     4  0.3612      0.409 0.268 0.000 0.000 0.732 0.000
#> GSM252443     4  0.2753      0.456 0.008 0.000 0.000 0.856 0.136
#> GSM252454     4  0.4060      0.397 0.000 0.000 0.360 0.640 0.000
#> GSM252449     1  0.4201      0.376 0.592 0.000 0.000 0.408 0.000
#> GSM252445     4  0.4305     -0.170 0.488 0.000 0.000 0.512 0.000
#> GSM252453     4  0.3586      0.505 0.000 0.000 0.264 0.736 0.000
#> GSM252464     1  0.0671      0.799 0.980 0.000 0.000 0.004 0.016
#> GSM252463     1  0.0671      0.799 0.980 0.000 0.000 0.004 0.016
#> GSM252461     1  0.0671      0.799 0.980 0.000 0.000 0.004 0.016
#> GSM252455     1  0.0671      0.799 0.980 0.000 0.000 0.004 0.016
#> GSM252458     1  0.2793      0.756 0.876 0.000 0.000 0.036 0.088
#> GSM252460     1  0.4238      0.681 0.776 0.000 0.000 0.136 0.088
#> GSM252457     4  0.6325     -0.147 0.156 0.000 0.000 0.428 0.416
#> GSM252456     1  0.2793      0.756 0.876 0.000 0.000 0.036 0.088
#> GSM252462     5  0.6499     -0.188 0.188 0.000 0.000 0.396 0.416
#> GSM252459     4  0.3586      0.505 0.000 0.000 0.264 0.736 0.000
#> GSM252472     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252466     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252469     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252475     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252471     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252465     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252474     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252473     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252468     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252470     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252467     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252485     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252481     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252480     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252479     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252482     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252478     2  0.2377      0.871 0.000 0.872 0.000 0.128 0.000
#> GSM252483     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252477     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252484     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM252476     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4 p5    p6
#> GSM252423     4  0.4692      0.673 0.000 0.000 0.000 0.512 NA 0.044
#> GSM252429     4  0.4692      0.673 0.000 0.000 0.000 0.512 NA 0.044
#> GSM252424     3  0.5590      0.541 0.000 0.000 0.536 0.032 NA 0.072
#> GSM252432     4  0.4692      0.673 0.000 0.000 0.000 0.512 NA 0.044
#> GSM252427     3  0.1901      0.741 0.000 0.000 0.924 0.008 NA 0.028
#> GSM252431     3  0.1901      0.741 0.000 0.000 0.924 0.008 NA 0.028
#> GSM252430     3  0.4427      0.670 0.000 0.000 0.716 0.000 NA 0.148
#> GSM252433     3  0.0260      0.718 0.000 0.000 0.992 0.000 NA 0.000
#> GSM252426     3  0.5032      0.618 0.000 0.000 0.596 0.008 NA 0.072
#> GSM252428     3  0.5032      0.618 0.000 0.000 0.596 0.008 NA 0.072
#> GSM252425     3  0.0405      0.716 0.000 0.000 0.988 0.000 NA 0.004
#> GSM252440     1  0.0260      0.785 0.992 0.000 0.000 0.000 NA 0.008
#> GSM252441     1  0.0260      0.785 0.992 0.000 0.000 0.000 NA 0.008
#> GSM252436     1  0.0260      0.785 0.992 0.000 0.000 0.000 NA 0.008
#> GSM252435     1  0.3756      0.345 0.600 0.000 0.000 0.000 NA 0.400
#> GSM252442     1  0.3789      0.308 0.584 0.000 0.000 0.000 NA 0.416
#> GSM252439     6  0.0603      0.529 0.016 0.000 0.000 0.000 NA 0.980
#> GSM252438     6  0.3861      0.372 0.000 0.000 0.352 0.000 NA 0.640
#> GSM252434     1  0.3756      0.345 0.600 0.000 0.000 0.000 NA 0.400
#> GSM252437     6  0.3868     -0.131 0.496 0.000 0.000 0.000 NA 0.504
#> GSM252451     1  0.0260      0.785 0.992 0.000 0.000 0.000 NA 0.008
#> GSM252448     1  0.0260      0.785 0.992 0.000 0.000 0.000 NA 0.008
#> GSM252447     1  0.0260      0.785 0.992 0.000 0.000 0.000 NA 0.008
#> GSM252444     1  0.0260      0.785 0.992 0.000 0.000 0.000 NA 0.008
#> GSM252450     1  0.3756      0.345 0.600 0.000 0.000 0.000 NA 0.400
#> GSM252452     6  0.3288      0.423 0.276 0.000 0.000 0.000 NA 0.724
#> GSM252443     6  0.0603      0.529 0.016 0.000 0.000 0.000 NA 0.980
#> GSM252454     6  0.3861      0.372 0.000 0.000 0.352 0.000 NA 0.640
#> GSM252449     1  0.3756      0.345 0.600 0.000 0.000 0.000 NA 0.400
#> GSM252445     6  0.3868     -0.131 0.496 0.000 0.000 0.000 NA 0.504
#> GSM252453     6  0.3421      0.482 0.000 0.000 0.256 0.000 NA 0.736
#> GSM252464     1  0.1779      0.760 0.920 0.000 0.000 0.016 NA 0.000
#> GSM252463     1  0.1779      0.760 0.920 0.000 0.000 0.016 NA 0.000
#> GSM252461     1  0.1779      0.760 0.920 0.000 0.000 0.016 NA 0.000
#> GSM252455     1  0.1779      0.760 0.920 0.000 0.000 0.016 NA 0.000
#> GSM252458     1  0.3424      0.724 0.816 0.000 0.000 0.016 NA 0.032
#> GSM252460     1  0.4710      0.651 0.716 0.000 0.000 0.016 NA 0.132
#> GSM252457     6  0.5648      0.220 0.156 0.000 0.000 0.000 NA 0.472
#> GSM252456     1  0.3424      0.724 0.816 0.000 0.000 0.016 NA 0.032
#> GSM252462     6  0.5823      0.225 0.188 0.000 0.000 0.000 NA 0.440
#> GSM252459     6  0.3421      0.482 0.000 0.000 0.256 0.000 NA 0.736
#> GSM252472     2  0.0000      0.931 0.000 1.000 0.000 0.000 NA 0.000
#> GSM252466     2  0.2730      0.858 0.000 0.808 0.000 0.000 NA 0.000
#> GSM252469     2  0.2730      0.858 0.000 0.808 0.000 0.000 NA 0.000
#> GSM252475     2  0.0000      0.931 0.000 1.000 0.000 0.000 NA 0.000
#> GSM252471     2  0.0000      0.931 0.000 1.000 0.000 0.000 NA 0.000
#> GSM252465     2  0.0000      0.931 0.000 1.000 0.000 0.000 NA 0.000
#> GSM252474     2  0.1444      0.911 0.000 0.928 0.000 0.000 NA 0.000
#> GSM252473     2  0.0000      0.931 0.000 1.000 0.000 0.000 NA 0.000
#> GSM252468     2  0.0000      0.931 0.000 1.000 0.000 0.000 NA 0.000
#> GSM252470     2  0.0000      0.931 0.000 1.000 0.000 0.000 NA 0.000
#> GSM252467     2  0.2730      0.858 0.000 0.808 0.000 0.000 NA 0.000
#> GSM252485     2  0.0000      0.931 0.000 1.000 0.000 0.000 NA 0.000
#> GSM252481     2  0.2730      0.858 0.000 0.808 0.000 0.000 NA 0.000
#> GSM252480     2  0.2730      0.858 0.000 0.808 0.000 0.000 NA 0.000
#> GSM252479     2  0.0000      0.931 0.000 1.000 0.000 0.000 NA 0.000
#> GSM252482     2  0.0000      0.931 0.000 1.000 0.000 0.000 NA 0.000
#> GSM252478     4  0.5875      0.126 0.000 0.228 0.000 0.472 NA 0.000
#> GSM252483     2  0.1444      0.911 0.000 0.928 0.000 0.000 NA 0.000
#> GSM252477     2  0.0000      0.931 0.000 1.000 0.000 0.000 NA 0.000
#> GSM252484     2  0.0000      0.931 0.000 1.000 0.000 0.000 NA 0.000
#> GSM252476     2  0.2730      0.858 0.000 0.808 0.000 0.000 NA 0.000

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-hclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-hclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-hclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-hclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-hclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-hclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-hclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-hclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-hclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-hclust-membership-heatmap-5

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)

plot of chunk tab-ATC-hclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-hclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-hclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-hclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-hclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-ATC-hclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

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 agent(p) individual(p) k
#> ATC:hclust 62 4.69e-12         1.000 2
#> ATC:hclust 51 2.17e-17         0.940 3
#> ATC:hclust 47 1.71e-13         0.367 4
#> ATC:hclust 48 2.80e-12         0.629 5
#> ATC:hclust 47 1.63e-12         0.649 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.


ATC:kmeans**

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 51941 rows and 62 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)

plot of chunk ATC-kmeans-collect-plots

The plots are:

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:

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)

plot of chunk ATC-kmeans-select-partition-number

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.4659 0.535   0.535
#> 3 3 0.727           0.867       0.904         0.3866 0.777   0.590
#> 4 4 0.728           0.724       0.777         0.1182 0.880   0.658
#> 5 5 0.748           0.710       0.758         0.0768 0.947   0.808
#> 6 6 0.747           0.612       0.710         0.0404 0.942   0.767

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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM252423     1       0          1  1  0
#> GSM252429     1       0          1  1  0
#> GSM252424     1       0          1  1  0
#> GSM252432     1       0          1  1  0
#> GSM252427     1       0          1  1  0
#> GSM252431     1       0          1  1  0
#> GSM252430     1       0          1  1  0
#> GSM252433     1       0          1  1  0
#> GSM252426     1       0          1  1  0
#> GSM252428     1       0          1  1  0
#> GSM252425     2       0          1  0  1
#> GSM252440     1       0          1  1  0
#> GSM252441     1       0          1  1  0
#> GSM252436     1       0          1  1  0
#> GSM252435     1       0          1  1  0
#> GSM252442     1       0          1  1  0
#> GSM252439     1       0          1  1  0
#> GSM252438     1       0          1  1  0
#> GSM252434     1       0          1  1  0
#> GSM252437     1       0          1  1  0
#> GSM252451     1       0          1  1  0
#> GSM252448     1       0          1  1  0
#> GSM252447     1       0          1  1  0
#> GSM252444     1       0          1  1  0
#> GSM252450     1       0          1  1  0
#> GSM252452     1       0          1  1  0
#> GSM252443     1       0          1  1  0
#> GSM252454     1       0          1  1  0
#> GSM252449     1       0          1  1  0
#> GSM252445     1       0          1  1  0
#> GSM252453     1       0          1  1  0
#> GSM252464     1       0          1  1  0
#> GSM252463     1       0          1  1  0
#> GSM252461     1       0          1  1  0
#> GSM252455     1       0          1  1  0
#> GSM252458     1       0          1  1  0
#> GSM252460     1       0          1  1  0
#> GSM252457     1       0          1  1  0
#> GSM252456     1       0          1  1  0
#> GSM252462     1       0          1  1  0
#> GSM252459     1       0          1  1  0
#> GSM252472     2       0          1  0  1
#> GSM252466     2       0          1  0  1
#> GSM252469     2       0          1  0  1
#> GSM252475     2       0          1  0  1
#> GSM252471     2       0          1  0  1
#> GSM252465     2       0          1  0  1
#> GSM252474     2       0          1  0  1
#> GSM252473     2       0          1  0  1
#> GSM252468     2       0          1  0  1
#> GSM252470     2       0          1  0  1
#> GSM252467     2       0          1  0  1
#> GSM252485     2       0          1  0  1
#> GSM252481     2       0          1  0  1
#> GSM252480     2       0          1  0  1
#> GSM252479     2       0          1  0  1
#> GSM252482     2       0          1  0  1
#> GSM252478     2       0          1  0  1
#> GSM252483     2       0          1  0  1
#> GSM252477     2       0          1  0  1
#> GSM252484     2       0          1  0  1
#> GSM252476     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.4178      0.935 0.172 0.000 0.828
#> GSM252429     3  0.4178      0.935 0.172 0.000 0.828
#> GSM252424     3  0.4178      0.935 0.172 0.000 0.828
#> GSM252432     3  0.4178      0.935 0.172 0.000 0.828
#> GSM252427     3  0.4178      0.935 0.172 0.000 0.828
#> GSM252431     3  0.4178      0.935 0.172 0.000 0.828
#> GSM252430     3  0.4178      0.935 0.172 0.000 0.828
#> GSM252433     3  0.4002      0.922 0.160 0.000 0.840
#> GSM252426     3  0.4178      0.935 0.172 0.000 0.828
#> GSM252428     3  0.4178      0.935 0.172 0.000 0.828
#> GSM252425     3  0.4002      0.723 0.000 0.160 0.840
#> GSM252440     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252441     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252436     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252435     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252442     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252439     3  0.6252      0.466 0.444 0.000 0.556
#> GSM252438     3  0.4178      0.935 0.172 0.000 0.828
#> GSM252434     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252437     1  0.6308     -0.327 0.508 0.000 0.492
#> GSM252451     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252448     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252447     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252444     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252450     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252452     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252443     1  0.6309     -0.340 0.504 0.000 0.496
#> GSM252454     3  0.4178      0.935 0.172 0.000 0.828
#> GSM252449     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252445     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252453     3  0.6274      0.432 0.456 0.000 0.544
#> GSM252464     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252463     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252461     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252455     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252458     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252460     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252457     3  0.4178      0.935 0.172 0.000 0.828
#> GSM252456     1  0.0000      0.928 1.000 0.000 0.000
#> GSM252462     1  0.5397      0.447 0.720 0.000 0.280
#> GSM252459     3  0.4178      0.935 0.172 0.000 0.828
#> GSM252472     2  0.0592      0.955 0.000 0.988 0.012
#> GSM252466     2  0.3816      0.917 0.000 0.852 0.148
#> GSM252469     2  0.3816      0.917 0.000 0.852 0.148
#> GSM252475     2  0.0592      0.955 0.000 0.988 0.012
#> GSM252471     2  0.0592      0.955 0.000 0.988 0.012
#> GSM252465     2  0.0592      0.955 0.000 0.988 0.012
#> GSM252474     2  0.2796      0.937 0.000 0.908 0.092
#> GSM252473     2  0.0592      0.955 0.000 0.988 0.012
#> GSM252468     2  0.0237      0.954 0.000 0.996 0.004
#> GSM252470     2  0.0747      0.954 0.000 0.984 0.016
#> GSM252467     2  0.3816      0.917 0.000 0.852 0.148
#> GSM252485     2  0.0592      0.955 0.000 0.988 0.012
#> GSM252481     2  0.3816      0.917 0.000 0.852 0.148
#> GSM252480     2  0.3816      0.917 0.000 0.852 0.148
#> GSM252479     2  0.0000      0.954 0.000 1.000 0.000
#> GSM252482     2  0.1031      0.952 0.000 0.976 0.024
#> GSM252478     2  0.0592      0.955 0.000 0.988 0.012
#> GSM252483     2  0.2796      0.937 0.000 0.908 0.092
#> GSM252477     2  0.1031      0.952 0.000 0.976 0.024
#> GSM252484     2  0.0237      0.954 0.000 0.996 0.004
#> GSM252476     2  0.3816      0.917 0.000 0.852 0.148

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.4985     0.9830 0.000 0.000 0.532 0.468
#> GSM252429     3  0.4985     0.9830 0.000 0.000 0.532 0.468
#> GSM252424     3  0.4985     0.9830 0.000 0.000 0.532 0.468
#> GSM252432     3  0.4985     0.9830 0.000 0.000 0.532 0.468
#> GSM252427     3  0.4985     0.9830 0.000 0.000 0.532 0.468
#> GSM252431     3  0.4981     0.9821 0.000 0.000 0.536 0.464
#> GSM252430     3  0.4981     0.9821 0.000 0.000 0.536 0.464
#> GSM252433     3  0.4981     0.9821 0.000 0.000 0.536 0.464
#> GSM252426     3  0.4985     0.9830 0.000 0.000 0.532 0.468
#> GSM252428     3  0.4981     0.9821 0.000 0.000 0.536 0.464
#> GSM252425     3  0.6315     0.8584 0.000 0.064 0.540 0.396
#> GSM252440     1  0.3545     0.8464 0.828 0.000 0.008 0.164
#> GSM252441     1  0.3636     0.8414 0.820 0.000 0.008 0.172
#> GSM252436     1  0.3545     0.8464 0.828 0.000 0.008 0.164
#> GSM252435     4  0.4866     0.2432 0.404 0.000 0.000 0.596
#> GSM252442     1  0.4843     0.4598 0.604 0.000 0.000 0.396
#> GSM252439     4  0.3074     0.6125 0.152 0.000 0.000 0.848
#> GSM252438     4  0.3266    -0.0864 0.000 0.000 0.168 0.832
#> GSM252434     1  0.4843     0.4598 0.604 0.000 0.000 0.396
#> GSM252437     4  0.3569     0.5994 0.196 0.000 0.000 0.804
#> GSM252451     1  0.3545     0.8464 0.828 0.000 0.008 0.164
#> GSM252448     1  0.3545     0.8464 0.828 0.000 0.008 0.164
#> GSM252447     1  0.3636     0.8414 0.820 0.000 0.008 0.172
#> GSM252444     1  0.3545     0.8464 0.828 0.000 0.008 0.164
#> GSM252450     4  0.4925     0.1601 0.428 0.000 0.000 0.572
#> GSM252452     4  0.4866     0.2432 0.404 0.000 0.000 0.596
#> GSM252443     4  0.3528     0.6023 0.192 0.000 0.000 0.808
#> GSM252454     4  0.2469     0.1193 0.000 0.000 0.108 0.892
#> GSM252449     1  0.4843     0.4598 0.604 0.000 0.000 0.396
#> GSM252445     4  0.4866     0.2432 0.404 0.000 0.000 0.596
#> GSM252453     4  0.3266     0.6116 0.168 0.000 0.000 0.832
#> GSM252464     1  0.2179     0.8354 0.924 0.000 0.012 0.064
#> GSM252463     1  0.2179     0.8354 0.924 0.000 0.012 0.064
#> GSM252461     1  0.2179     0.8354 0.924 0.000 0.012 0.064
#> GSM252455     1  0.2179     0.8354 0.924 0.000 0.012 0.064
#> GSM252458     1  0.2179     0.8354 0.924 0.000 0.012 0.064
#> GSM252460     1  0.2179     0.8354 0.924 0.000 0.012 0.064
#> GSM252457     4  0.4164    -0.4220 0.000 0.000 0.264 0.736
#> GSM252456     1  0.2179     0.8354 0.924 0.000 0.012 0.064
#> GSM252462     4  0.5764     0.5092 0.304 0.000 0.052 0.644
#> GSM252459     4  0.2469     0.1193 0.000 0.000 0.108 0.892
#> GSM252472     2  0.0707     0.8739 0.000 0.980 0.020 0.000
#> GSM252466     2  0.4855     0.7626 0.000 0.600 0.400 0.000
#> GSM252469     2  0.4855     0.7626 0.000 0.600 0.400 0.000
#> GSM252475     2  0.0707     0.8739 0.000 0.980 0.020 0.000
#> GSM252471     2  0.0000     0.8730 0.000 1.000 0.000 0.000
#> GSM252465     2  0.0188     0.8725 0.000 0.996 0.004 0.000
#> GSM252474     2  0.5218     0.8180 0.064 0.736 0.200 0.000
#> GSM252473     2  0.0000     0.8730 0.000 1.000 0.000 0.000
#> GSM252468     2  0.0336     0.8733 0.008 0.992 0.000 0.000
#> GSM252470     2  0.0336     0.8733 0.008 0.992 0.000 0.000
#> GSM252467     2  0.4855     0.7626 0.000 0.600 0.400 0.000
#> GSM252485     2  0.0707     0.8739 0.000 0.980 0.020 0.000
#> GSM252481     2  0.4855     0.7626 0.000 0.600 0.400 0.000
#> GSM252480     2  0.4855     0.7626 0.000 0.600 0.400 0.000
#> GSM252479     2  0.0707     0.8739 0.000 0.980 0.020 0.000
#> GSM252482     2  0.2623     0.8544 0.064 0.908 0.028 0.000
#> GSM252478     2  0.0592     0.8695 0.000 0.984 0.016 0.000
#> GSM252483     2  0.5218     0.8180 0.064 0.736 0.200 0.000
#> GSM252477     2  0.2623     0.8544 0.064 0.908 0.028 0.000
#> GSM252484     2  0.0336     0.8733 0.008 0.992 0.000 0.000
#> GSM252476     2  0.4855     0.7626 0.000 0.600 0.400 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4 p5
#> GSM252423     3  0.0451     0.9279 0.000 0.000 0.988 0.004 NA
#> GSM252429     3  0.0451     0.9279 0.000 0.000 0.988 0.004 NA
#> GSM252424     3  0.0451     0.9279 0.000 0.000 0.988 0.004 NA
#> GSM252432     3  0.0451     0.9279 0.000 0.000 0.988 0.004 NA
#> GSM252427     3  0.0162     0.9284 0.000 0.000 0.996 0.004 NA
#> GSM252431     3  0.1205     0.9237 0.000 0.000 0.956 0.004 NA
#> GSM252430     3  0.1124     0.9249 0.000 0.000 0.960 0.004 NA
#> GSM252433     3  0.1357     0.9204 0.000 0.000 0.948 0.004 NA
#> GSM252426     3  0.0162     0.9284 0.000 0.000 0.996 0.004 NA
#> GSM252428     3  0.1124     0.9249 0.000 0.000 0.960 0.004 NA
#> GSM252425     3  0.1990     0.9033 0.008 0.004 0.920 0.000 NA
#> GSM252440     1  0.3684     0.7527 0.720 0.000 0.000 0.280 NA
#> GSM252441     1  0.3816     0.7331 0.696 0.000 0.000 0.304 NA
#> GSM252436     1  0.3661     0.7539 0.724 0.000 0.000 0.276 NA
#> GSM252435     4  0.1732     0.5494 0.080 0.000 0.000 0.920 NA
#> GSM252442     4  0.4352     0.1645 0.244 0.000 0.000 0.720 NA
#> GSM252439     4  0.4783     0.6649 0.000 0.000 0.100 0.724 NA
#> GSM252438     4  0.6533     0.3337 0.000 0.000 0.304 0.472 NA
#> GSM252434     4  0.4352     0.1645 0.244 0.000 0.000 0.720 NA
#> GSM252437     4  0.4647     0.6658 0.000 0.000 0.092 0.736 NA
#> GSM252451     1  0.3684     0.7527 0.720 0.000 0.000 0.280 NA
#> GSM252448     1  0.3684     0.7527 0.720 0.000 0.000 0.280 NA
#> GSM252447     1  0.3816     0.7331 0.696 0.000 0.000 0.304 NA
#> GSM252444     1  0.3661     0.7539 0.724 0.000 0.000 0.276 NA
#> GSM252450     4  0.2020     0.5235 0.100 0.000 0.000 0.900 NA
#> GSM252452     4  0.0162     0.6010 0.000 0.000 0.000 0.996 NA
#> GSM252443     4  0.4683     0.6657 0.000 0.000 0.092 0.732 NA
#> GSM252454     4  0.6349     0.4175 0.000 0.000 0.268 0.520 NA
#> GSM252449     4  0.4352     0.1645 0.244 0.000 0.000 0.720 NA
#> GSM252445     4  0.1331     0.5840 0.040 0.000 0.000 0.952 NA
#> GSM252453     4  0.4803     0.6625 0.000 0.000 0.096 0.720 NA
#> GSM252464     1  0.5892     0.7420 0.600 0.000 0.000 0.180 NA
#> GSM252463     1  0.5892     0.7420 0.600 0.000 0.000 0.180 NA
#> GSM252461     1  0.5892     0.7420 0.600 0.000 0.000 0.180 NA
#> GSM252455     1  0.5892     0.7420 0.600 0.000 0.000 0.180 NA
#> GSM252458     1  0.6545     0.6608 0.464 0.000 0.000 0.316 NA
#> GSM252460     1  0.6579     0.6455 0.448 0.000 0.000 0.332 NA
#> GSM252457     3  0.6164    -0.0131 0.000 0.000 0.492 0.368 NA
#> GSM252456     1  0.6563     0.6530 0.456 0.000 0.000 0.324 NA
#> GSM252462     4  0.2905     0.6444 0.000 0.000 0.096 0.868 NA
#> GSM252459     4  0.6176     0.4470 0.000 0.000 0.268 0.548 NA
#> GSM252472     2  0.0510     0.8313 0.000 0.984 0.000 0.000 NA
#> GSM252466     2  0.6114     0.7063 0.152 0.536 0.000 0.000 NA
#> GSM252469     2  0.6229     0.7064 0.148 0.536 0.004 0.000 NA
#> GSM252475     2  0.0510     0.8313 0.000 0.984 0.000 0.000 NA
#> GSM252471     2  0.0000     0.8297 0.000 1.000 0.000 0.000 NA
#> GSM252465     2  0.0671     0.8262 0.004 0.980 0.000 0.000 NA
#> GSM252474     2  0.4126     0.7461 0.000 0.620 0.000 0.000 NA
#> GSM252473     2  0.0162     0.8301 0.000 0.996 0.000 0.000 NA
#> GSM252468     2  0.1197     0.8294 0.000 0.952 0.000 0.000 NA
#> GSM252470     2  0.1270     0.8286 0.000 0.948 0.000 0.000 NA
#> GSM252467     2  0.6096     0.7064 0.148 0.536 0.000 0.000 NA
#> GSM252485     2  0.0510     0.8313 0.000 0.984 0.000 0.000 NA
#> GSM252481     2  0.6114     0.7063 0.152 0.536 0.000 0.000 NA
#> GSM252480     2  0.6229     0.7064 0.148 0.536 0.004 0.000 NA
#> GSM252479     2  0.0671     0.8315 0.004 0.980 0.000 0.000 NA
#> GSM252482     2  0.3266     0.7865 0.004 0.796 0.000 0.000 NA
#> GSM252478     2  0.1211     0.8223 0.016 0.960 0.000 0.000 NA
#> GSM252483     2  0.4126     0.7461 0.000 0.620 0.000 0.000 NA
#> GSM252477     2  0.3266     0.7865 0.004 0.796 0.000 0.000 NA
#> GSM252484     2  0.1197     0.8294 0.000 0.952 0.000 0.000 NA
#> GSM252476     2  0.6096     0.7064 0.148 0.536 0.000 0.000 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3 p4    p5    p6
#> GSM252423     3  0.2789     0.8356 0.000 0.044 0.864 NA 0.000 0.004
#> GSM252429     3  0.2789     0.8356 0.000 0.044 0.864 NA 0.000 0.004
#> GSM252424     3  0.2789     0.8356 0.000 0.044 0.864 NA 0.000 0.004
#> GSM252432     3  0.2789     0.8356 0.000 0.044 0.864 NA 0.000 0.004
#> GSM252427     3  0.0000     0.8549 0.000 0.000 1.000 NA 0.000 0.000
#> GSM252431     3  0.2122     0.8424 0.000 0.024 0.900 NA 0.000 0.000
#> GSM252430     3  0.1867     0.8470 0.000 0.020 0.916 NA 0.000 0.000
#> GSM252433     3  0.2831     0.8167 0.000 0.024 0.840 NA 0.000 0.000
#> GSM252426     3  0.0000     0.8549 0.000 0.000 1.000 NA 0.000 0.000
#> GSM252428     3  0.1461     0.8509 0.000 0.016 0.940 NA 0.000 0.000
#> GSM252425     3  0.3911     0.7652 0.000 0.056 0.760 NA 0.000 0.004
#> GSM252440     1  0.1408     0.7050 0.944 0.000 0.000 NA 0.000 0.036
#> GSM252441     1  0.1285     0.6956 0.944 0.000 0.000 NA 0.000 0.052
#> GSM252436     1  0.0865     0.7056 0.964 0.000 0.000 NA 0.000 0.036
#> GSM252435     6  0.3109     0.5763 0.224 0.004 0.000 NA 0.000 0.772
#> GSM252442     6  0.4709     0.0918 0.448 0.024 0.000 NA 0.000 0.516
#> GSM252439     6  0.4974     0.6668 0.036 0.012 0.044 NA 0.000 0.696
#> GSM252438     6  0.5742     0.4190 0.000 0.000 0.176 NA 0.000 0.468
#> GSM252434     6  0.4709     0.0918 0.448 0.024 0.000 NA 0.000 0.516
#> GSM252437     6  0.4711     0.6712 0.040 0.008 0.040 NA 0.000 0.724
#> GSM252451     1  0.1152     0.7019 0.952 0.000 0.000 NA 0.000 0.044
#> GSM252448     1  0.1408     0.7050 0.944 0.000 0.000 NA 0.000 0.036
#> GSM252447     1  0.1285     0.6956 0.944 0.000 0.000 NA 0.000 0.052
#> GSM252444     1  0.0865     0.7056 0.964 0.000 0.000 NA 0.000 0.036
#> GSM252450     6  0.3136     0.5719 0.228 0.004 0.000 NA 0.000 0.768
#> GSM252452     6  0.2620     0.6416 0.108 0.012 0.000 NA 0.000 0.868
#> GSM252443     6  0.4976     0.6692 0.040 0.012 0.040 NA 0.000 0.696
#> GSM252454     6  0.5400     0.5083 0.000 0.000 0.132 NA 0.000 0.536
#> GSM252449     6  0.4709     0.0918 0.448 0.024 0.000 NA 0.000 0.516
#> GSM252445     6  0.3004     0.6293 0.144 0.012 0.000 NA 0.000 0.832
#> GSM252453     6  0.5221     0.6392 0.036 0.008 0.044 NA 0.000 0.640
#> GSM252464     1  0.5074     0.6967 0.596 0.296 0.000 NA 0.000 0.000
#> GSM252463     1  0.5074     0.6967 0.596 0.296 0.000 NA 0.000 0.000
#> GSM252461     1  0.5058     0.6972 0.600 0.292 0.000 NA 0.000 0.000
#> GSM252455     1  0.5058     0.6972 0.600 0.292 0.000 NA 0.000 0.000
#> GSM252458     1  0.6681     0.6302 0.484 0.296 0.000 NA 0.000 0.108
#> GSM252460     1  0.6865     0.6055 0.460 0.296 0.000 NA 0.000 0.132
#> GSM252457     3  0.5819    -0.1439 0.000 0.000 0.420 NA 0.000 0.396
#> GSM252456     1  0.6714     0.6265 0.480 0.296 0.000 NA 0.000 0.112
#> GSM252462     6  0.2456     0.6656 0.048 0.000 0.052 NA 0.000 0.892
#> GSM252459     6  0.5172     0.5515 0.000 0.000 0.124 NA 0.000 0.592
#> GSM252472     2  0.3915     0.9356 0.000 0.584 0.000 NA 0.412 0.000
#> GSM252466     5  0.4812     0.6041 0.000 0.048 0.000 NA 0.592 0.008
#> GSM252469     5  0.4812     0.6041 0.000 0.048 0.000 NA 0.592 0.008
#> GSM252475     2  0.4151     0.9348 0.000 0.576 0.000 NA 0.412 0.008
#> GSM252471     2  0.3915     0.9360 0.000 0.584 0.000 NA 0.412 0.004
#> GSM252465     2  0.4024     0.9289 0.000 0.592 0.000 NA 0.400 0.004
#> GSM252474     5  0.1082     0.3372 0.000 0.040 0.000 NA 0.956 0.000
#> GSM252473     2  0.3789     0.9360 0.000 0.584 0.000 NA 0.416 0.000
#> GSM252468     2  0.4338     0.8442 0.000 0.496 0.000 NA 0.484 0.020
#> GSM252470     5  0.4338    -0.8591 0.000 0.488 0.000 NA 0.492 0.020
#> GSM252467     5  0.4776     0.6032 0.000 0.048 0.000 NA 0.604 0.008
#> GSM252485     2  0.3915     0.9356 0.000 0.584 0.000 NA 0.412 0.000
#> GSM252481     5  0.4812     0.6041 0.000 0.048 0.000 NA 0.592 0.008
#> GSM252480     5  0.4812     0.6041 0.000 0.048 0.000 NA 0.592 0.008
#> GSM252479     2  0.4408     0.9270 0.000 0.560 0.000 NA 0.416 0.020
#> GSM252482     5  0.3876    -0.3243 0.000 0.276 0.000 NA 0.700 0.024
#> GSM252478     2  0.4693     0.8742 0.000 0.576 0.000 NA 0.384 0.016
#> GSM252483     5  0.1082     0.3372 0.000 0.040 0.000 NA 0.956 0.000
#> GSM252477     5  0.3799    -0.3232 0.000 0.276 0.000 NA 0.704 0.020
#> GSM252484     2  0.4338     0.8442 0.000 0.496 0.000 NA 0.484 0.020
#> GSM252476     5  0.4776     0.6032 0.000 0.048 0.000 NA 0.604 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)

plot of chunk tab-ATC-kmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-kmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-kmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-kmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-kmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-kmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-kmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-kmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-kmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-kmeans-membership-heatmap-5

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)

plot of chunk tab-ATC-kmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-kmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-kmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-kmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-kmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-kmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-ATC-kmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-kmeans-collect-classes

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 agent(p) individual(p) k
#> ATC:kmeans 62 3.10e-11         0.996 2
#> ATC:kmeans 57 1.71e-15         0.905 3
#> ATC:kmeans 51 1.02e-15         0.687 4
#> ATC:kmeans 55 3.17e-18         0.726 5
#> ATC:kmeans 52 1.63e-14         0.207 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.


ATC:skmeans**

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 51941 rows and 62 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 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

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:

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)

plot of chunk ATC-skmeans-select-partition-number

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.4828 0.518   0.518
#> 3 3 1.000           0.979       0.993         0.3027 0.841   0.698
#> 4 4 0.964           0.899       0.961         0.1013 0.926   0.807
#> 5 5 0.879           0.730       0.868         0.0545 0.995   0.983
#> 6 6 0.838           0.581       0.789         0.0439 0.906   0.703

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3

There is also optional best \(k\) = 2 3 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1  0.0000      1.000 1.000 0.000
#> GSM252429     1  0.0000      1.000 1.000 0.000
#> GSM252424     1  0.0000      1.000 1.000 0.000
#> GSM252432     1  0.0000      1.000 1.000 0.000
#> GSM252427     1  0.0000      1.000 1.000 0.000
#> GSM252431     1  0.0000      1.000 1.000 0.000
#> GSM252430     2  0.0376      0.996 0.004 0.996
#> GSM252433     2  0.0000      1.000 0.000 1.000
#> GSM252426     1  0.0000      1.000 1.000 0.000
#> GSM252428     1  0.0000      1.000 1.000 0.000
#> GSM252425     2  0.0000      1.000 0.000 1.000
#> GSM252440     1  0.0000      1.000 1.000 0.000
#> GSM252441     1  0.0000      1.000 1.000 0.000
#> GSM252436     1  0.0000      1.000 1.000 0.000
#> GSM252435     1  0.0000      1.000 1.000 0.000
#> GSM252442     1  0.0000      1.000 1.000 0.000
#> GSM252439     1  0.0000      1.000 1.000 0.000
#> GSM252438     1  0.0000      1.000 1.000 0.000
#> GSM252434     1  0.0000      1.000 1.000 0.000
#> GSM252437     1  0.0000      1.000 1.000 0.000
#> GSM252451     1  0.0000      1.000 1.000 0.000
#> GSM252448     1  0.0000      1.000 1.000 0.000
#> GSM252447     1  0.0000      1.000 1.000 0.000
#> GSM252444     1  0.0000      1.000 1.000 0.000
#> GSM252450     1  0.0000      1.000 1.000 0.000
#> GSM252452     1  0.0000      1.000 1.000 0.000
#> GSM252443     1  0.0000      1.000 1.000 0.000
#> GSM252454     1  0.0000      1.000 1.000 0.000
#> GSM252449     1  0.0000      1.000 1.000 0.000
#> GSM252445     1  0.0000      1.000 1.000 0.000
#> GSM252453     1  0.0000      1.000 1.000 0.000
#> GSM252464     1  0.0000      1.000 1.000 0.000
#> GSM252463     1  0.0000      1.000 1.000 0.000
#> GSM252461     1  0.0000      1.000 1.000 0.000
#> GSM252455     1  0.0000      1.000 1.000 0.000
#> GSM252458     1  0.0000      1.000 1.000 0.000
#> GSM252460     1  0.0000      1.000 1.000 0.000
#> GSM252457     1  0.0000      1.000 1.000 0.000
#> GSM252456     1  0.0000      1.000 1.000 0.000
#> GSM252462     1  0.0000      1.000 1.000 0.000
#> GSM252459     1  0.0000      1.000 1.000 0.000
#> GSM252472     2  0.0000      1.000 0.000 1.000
#> GSM252466     2  0.0000      1.000 0.000 1.000
#> GSM252469     2  0.0000      1.000 0.000 1.000
#> GSM252475     2  0.0000      1.000 0.000 1.000
#> GSM252471     2  0.0000      1.000 0.000 1.000
#> GSM252465     2  0.0000      1.000 0.000 1.000
#> GSM252474     2  0.0000      1.000 0.000 1.000
#> GSM252473     2  0.0000      1.000 0.000 1.000
#> GSM252468     2  0.0000      1.000 0.000 1.000
#> GSM252470     2  0.0000      1.000 0.000 1.000
#> GSM252467     2  0.0000      1.000 0.000 1.000
#> GSM252485     2  0.0000      1.000 0.000 1.000
#> GSM252481     2  0.0000      1.000 0.000 1.000
#> GSM252480     2  0.0000      1.000 0.000 1.000
#> GSM252479     2  0.0000      1.000 0.000 1.000
#> GSM252482     2  0.0000      1.000 0.000 1.000
#> GSM252478     2  0.0000      1.000 0.000 1.000
#> GSM252483     2  0.0000      1.000 0.000 1.000
#> GSM252477     2  0.0000      1.000 0.000 1.000
#> GSM252484     2  0.0000      1.000 0.000 1.000
#> GSM252476     2  0.0000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM252423     3   0.000      1.000 0.000  0 1.000
#> GSM252429     3   0.000      1.000 0.000  0 1.000
#> GSM252424     3   0.000      1.000 0.000  0 1.000
#> GSM252432     3   0.000      1.000 0.000  0 1.000
#> GSM252427     3   0.000      1.000 0.000  0 1.000
#> GSM252431     3   0.000      1.000 0.000  0 1.000
#> GSM252430     3   0.000      1.000 0.000  0 1.000
#> GSM252433     3   0.000      1.000 0.000  0 1.000
#> GSM252426     3   0.000      1.000 0.000  0 1.000
#> GSM252428     3   0.000      1.000 0.000  0 1.000
#> GSM252425     2   0.000      1.000 0.000  1 0.000
#> GSM252440     1   0.000      0.984 1.000  0 0.000
#> GSM252441     1   0.000      0.984 1.000  0 0.000
#> GSM252436     1   0.000      0.984 1.000  0 0.000
#> GSM252435     1   0.000      0.984 1.000  0 0.000
#> GSM252442     1   0.000      0.984 1.000  0 0.000
#> GSM252439     1   0.000      0.984 1.000  0 0.000
#> GSM252438     1   0.000      0.984 1.000  0 0.000
#> GSM252434     1   0.000      0.984 1.000  0 0.000
#> GSM252437     1   0.000      0.984 1.000  0 0.000
#> GSM252451     1   0.000      0.984 1.000  0 0.000
#> GSM252448     1   0.000      0.984 1.000  0 0.000
#> GSM252447     1   0.000      0.984 1.000  0 0.000
#> GSM252444     1   0.000      0.984 1.000  0 0.000
#> GSM252450     1   0.000      0.984 1.000  0 0.000
#> GSM252452     1   0.000      0.984 1.000  0 0.000
#> GSM252443     1   0.000      0.984 1.000  0 0.000
#> GSM252454     1   0.000      0.984 1.000  0 0.000
#> GSM252449     1   0.000      0.984 1.000  0 0.000
#> GSM252445     1   0.000      0.984 1.000  0 0.000
#> GSM252453     1   0.000      0.984 1.000  0 0.000
#> GSM252464     1   0.000      0.984 1.000  0 0.000
#> GSM252463     1   0.000      0.984 1.000  0 0.000
#> GSM252461     1   0.000      0.984 1.000  0 0.000
#> GSM252455     1   0.000      0.984 1.000  0 0.000
#> GSM252458     1   0.000      0.984 1.000  0 0.000
#> GSM252460     1   0.000      0.984 1.000  0 0.000
#> GSM252457     1   0.627      0.175 0.548  0 0.452
#> GSM252456     1   0.000      0.984 1.000  0 0.000
#> GSM252462     1   0.000      0.984 1.000  0 0.000
#> GSM252459     1   0.000      0.984 1.000  0 0.000
#> GSM252472     2   0.000      1.000 0.000  1 0.000
#> GSM252466     2   0.000      1.000 0.000  1 0.000
#> GSM252469     2   0.000      1.000 0.000  1 0.000
#> GSM252475     2   0.000      1.000 0.000  1 0.000
#> GSM252471     2   0.000      1.000 0.000  1 0.000
#> GSM252465     2   0.000      1.000 0.000  1 0.000
#> GSM252474     2   0.000      1.000 0.000  1 0.000
#> GSM252473     2   0.000      1.000 0.000  1 0.000
#> GSM252468     2   0.000      1.000 0.000  1 0.000
#> GSM252470     2   0.000      1.000 0.000  1 0.000
#> GSM252467     2   0.000      1.000 0.000  1 0.000
#> GSM252485     2   0.000      1.000 0.000  1 0.000
#> GSM252481     2   0.000      1.000 0.000  1 0.000
#> GSM252480     2   0.000      1.000 0.000  1 0.000
#> GSM252479     2   0.000      1.000 0.000  1 0.000
#> GSM252482     2   0.000      1.000 0.000  1 0.000
#> GSM252478     2   0.000      1.000 0.000  1 0.000
#> GSM252483     2   0.000      1.000 0.000  1 0.000
#> GSM252477     2   0.000      1.000 0.000  1 0.000
#> GSM252484     2   0.000      1.000 0.000  1 0.000
#> GSM252476     2   0.000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM252423     3  0.0000     0.9109 0.000  0 1.000 0.000
#> GSM252429     3  0.0000     0.9109 0.000  0 1.000 0.000
#> GSM252424     3  0.0000     0.9109 0.000  0 1.000 0.000
#> GSM252432     3  0.0000     0.9109 0.000  0 1.000 0.000
#> GSM252427     3  0.0000     0.9109 0.000  0 1.000 0.000
#> GSM252431     3  0.0000     0.9109 0.000  0 1.000 0.000
#> GSM252430     3  0.0000     0.9109 0.000  0 1.000 0.000
#> GSM252433     3  0.3219     0.7689 0.000  0 0.836 0.164
#> GSM252426     3  0.0000     0.9109 0.000  0 1.000 0.000
#> GSM252428     3  0.0000     0.9109 0.000  0 1.000 0.000
#> GSM252425     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252440     1  0.0336     0.9338 0.992  0 0.000 0.008
#> GSM252441     1  0.0336     0.9338 0.992  0 0.000 0.008
#> GSM252436     1  0.0336     0.9338 0.992  0 0.000 0.008
#> GSM252435     1  0.0336     0.9338 0.992  0 0.000 0.008
#> GSM252442     1  0.0000     0.9327 1.000  0 0.000 0.000
#> GSM252439     1  0.4996    -0.0529 0.516  0 0.000 0.484
#> GSM252438     4  0.0188     0.8294 0.004  0 0.000 0.996
#> GSM252434     1  0.0188     0.9335 0.996  0 0.000 0.004
#> GSM252437     1  0.4585     0.4578 0.668  0 0.000 0.332
#> GSM252451     1  0.0336     0.9338 0.992  0 0.000 0.008
#> GSM252448     1  0.0336     0.9338 0.992  0 0.000 0.008
#> GSM252447     1  0.0336     0.9338 0.992  0 0.000 0.008
#> GSM252444     1  0.0336     0.9338 0.992  0 0.000 0.008
#> GSM252450     1  0.0336     0.9338 0.992  0 0.000 0.008
#> GSM252452     1  0.0000     0.9327 1.000  0 0.000 0.000
#> GSM252443     1  0.4454     0.5110 0.692  0 0.000 0.308
#> GSM252454     4  0.0336     0.8306 0.008  0 0.000 0.992
#> GSM252449     1  0.0188     0.9335 0.996  0 0.000 0.004
#> GSM252445     1  0.0336     0.9338 0.992  0 0.000 0.008
#> GSM252453     4  0.3444     0.8219 0.184  0 0.000 0.816
#> GSM252464     1  0.0817     0.9266 0.976  0 0.000 0.024
#> GSM252463     1  0.0817     0.9266 0.976  0 0.000 0.024
#> GSM252461     1  0.0817     0.9266 0.976  0 0.000 0.024
#> GSM252455     1  0.0817     0.9266 0.976  0 0.000 0.024
#> GSM252458     1  0.0817     0.9266 0.976  0 0.000 0.024
#> GSM252460     1  0.0817     0.9266 0.976  0 0.000 0.024
#> GSM252457     3  0.5925     0.0568 0.452  0 0.512 0.036
#> GSM252456     1  0.0817     0.9266 0.976  0 0.000 0.024
#> GSM252462     1  0.0921     0.9244 0.972  0 0.000 0.028
#> GSM252459     4  0.3172     0.8290 0.160  0 0.000 0.840
#> GSM252472     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252466     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252469     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252475     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252471     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252465     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252474     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252473     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252468     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252470     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252467     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252485     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252481     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252480     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252479     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252482     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252478     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252483     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252477     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252484     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM252476     2  0.0000     1.0000 0.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.0703     0.8832 0.000 0.000 0.976 0.000 0.024
#> GSM252429     3  0.0703     0.8832 0.000 0.000 0.976 0.000 0.024
#> GSM252424     3  0.0794     0.8816 0.000 0.000 0.972 0.000 0.028
#> GSM252432     3  0.0794     0.8816 0.000 0.000 0.972 0.000 0.028
#> GSM252427     3  0.0404     0.8836 0.000 0.000 0.988 0.000 0.012
#> GSM252431     3  0.2329     0.8492 0.000 0.000 0.876 0.000 0.124
#> GSM252430     3  0.3857     0.7227 0.000 0.000 0.688 0.000 0.312
#> GSM252433     3  0.5901     0.5014 0.000 0.000 0.496 0.104 0.400
#> GSM252426     3  0.0703     0.8822 0.000 0.000 0.976 0.000 0.024
#> GSM252428     3  0.1908     0.8646 0.000 0.000 0.908 0.000 0.092
#> GSM252425     2  0.3446     0.8293 0.000 0.840 0.008 0.036 0.116
#> GSM252440     1  0.0290     0.6661 0.992 0.000 0.000 0.000 0.008
#> GSM252441     1  0.0794     0.6561 0.972 0.000 0.000 0.000 0.028
#> GSM252436     1  0.0290     0.6686 0.992 0.000 0.000 0.000 0.008
#> GSM252435     1  0.1544     0.6530 0.932 0.000 0.000 0.000 0.068
#> GSM252442     1  0.1792     0.6489 0.916 0.000 0.000 0.000 0.084
#> GSM252439     1  0.6009     0.0352 0.580 0.000 0.000 0.180 0.240
#> GSM252438     4  0.1410     0.9020 0.000 0.000 0.000 0.940 0.060
#> GSM252434     1  0.1124     0.6656 0.960 0.000 0.000 0.004 0.036
#> GSM252437     1  0.4752     0.3229 0.724 0.000 0.000 0.184 0.092
#> GSM252451     1  0.0290     0.6686 0.992 0.000 0.000 0.000 0.008
#> GSM252448     1  0.0290     0.6661 0.992 0.000 0.000 0.000 0.008
#> GSM252447     1  0.0794     0.6561 0.972 0.000 0.000 0.000 0.028
#> GSM252444     1  0.0404     0.6670 0.988 0.000 0.000 0.000 0.012
#> GSM252450     1  0.1544     0.6530 0.932 0.000 0.000 0.000 0.068
#> GSM252452     1  0.2074     0.6485 0.896 0.000 0.000 0.000 0.104
#> GSM252443     1  0.5354     0.1683 0.652 0.000 0.000 0.108 0.240
#> GSM252454     4  0.1270     0.9024 0.000 0.000 0.000 0.948 0.052
#> GSM252449     1  0.1124     0.6656 0.960 0.000 0.000 0.004 0.036
#> GSM252445     1  0.2570     0.5766 0.888 0.000 0.000 0.028 0.084
#> GSM252453     4  0.2473     0.8483 0.072 0.000 0.000 0.896 0.032
#> GSM252464     1  0.4030     0.2782 0.648 0.000 0.000 0.000 0.352
#> GSM252463     1  0.4030     0.2782 0.648 0.000 0.000 0.000 0.352
#> GSM252461     1  0.3999     0.2949 0.656 0.000 0.000 0.000 0.344
#> GSM252455     1  0.4030     0.2782 0.648 0.000 0.000 0.000 0.352
#> GSM252458     1  0.4030     0.2782 0.648 0.000 0.000 0.000 0.352
#> GSM252460     1  0.4060     0.2733 0.640 0.000 0.000 0.000 0.360
#> GSM252457     5  0.6800     0.0000 0.336 0.000 0.212 0.008 0.444
#> GSM252456     1  0.4060     0.2733 0.640 0.000 0.000 0.000 0.360
#> GSM252462     1  0.4225     0.2594 0.632 0.000 0.000 0.004 0.364
#> GSM252459     4  0.2193     0.8658 0.028 0.000 0.000 0.912 0.060
#> GSM252472     2  0.0290     0.9884 0.000 0.992 0.000 0.000 0.008
#> GSM252466     2  0.0000     0.9905 0.000 1.000 0.000 0.000 0.000
#> GSM252469     2  0.0000     0.9905 0.000 1.000 0.000 0.000 0.000
#> GSM252475     2  0.0162     0.9899 0.000 0.996 0.000 0.000 0.004
#> GSM252471     2  0.0290     0.9884 0.000 0.992 0.000 0.000 0.008
#> GSM252465     2  0.0290     0.9884 0.000 0.992 0.000 0.000 0.008
#> GSM252474     2  0.0000     0.9905 0.000 1.000 0.000 0.000 0.000
#> GSM252473     2  0.0162     0.9899 0.000 0.996 0.000 0.000 0.004
#> GSM252468     2  0.0000     0.9905 0.000 1.000 0.000 0.000 0.000
#> GSM252470     2  0.0000     0.9905 0.000 1.000 0.000 0.000 0.000
#> GSM252467     2  0.0000     0.9905 0.000 1.000 0.000 0.000 0.000
#> GSM252485     2  0.0290     0.9884 0.000 0.992 0.000 0.000 0.008
#> GSM252481     2  0.0000     0.9905 0.000 1.000 0.000 0.000 0.000
#> GSM252480     2  0.0000     0.9905 0.000 1.000 0.000 0.000 0.000
#> GSM252479     2  0.0000     0.9905 0.000 1.000 0.000 0.000 0.000
#> GSM252482     2  0.0162     0.9899 0.000 0.996 0.000 0.000 0.004
#> GSM252478     2  0.0290     0.9884 0.000 0.992 0.000 0.000 0.008
#> GSM252483     2  0.0000     0.9905 0.000 1.000 0.000 0.000 0.000
#> GSM252477     2  0.0162     0.9899 0.000 0.996 0.000 0.000 0.004
#> GSM252484     2  0.0000     0.9905 0.000 1.000 0.000 0.000 0.000
#> GSM252476     2  0.0000     0.9905 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.0260     0.8052 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM252429     3  0.0405     0.8045 0.000 0.000 0.988 0.008 0.004 0.000
#> GSM252424     3  0.0260     0.8052 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM252432     3  0.0260     0.8052 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM252427     3  0.0937     0.7881 0.000 0.000 0.960 0.000 0.040 0.000
#> GSM252431     3  0.3615     0.3286 0.008 0.000 0.700 0.000 0.292 0.000
#> GSM252430     3  0.4517    -0.3242 0.032 0.000 0.524 0.000 0.444 0.000
#> GSM252433     5  0.4332     0.0000 0.000 0.000 0.288 0.000 0.664 0.048
#> GSM252426     3  0.1500     0.7766 0.012 0.000 0.936 0.000 0.052 0.000
#> GSM252428     3  0.2949     0.6668 0.028 0.000 0.832 0.000 0.140 0.000
#> GSM252425     2  0.4344     0.4986 0.000 0.628 0.000 0.000 0.336 0.036
#> GSM252440     1  0.3866     0.3658 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM252441     1  0.3843     0.4159 0.548 0.000 0.000 0.452 0.000 0.000
#> GSM252436     4  0.3868    -0.3993 0.492 0.000 0.000 0.508 0.000 0.000
#> GSM252435     4  0.4274    -0.2377 0.424 0.000 0.000 0.560 0.008 0.008
#> GSM252442     4  0.4246    -0.1594 0.400 0.000 0.000 0.580 0.020 0.000
#> GSM252439     1  0.4857     0.0246 0.684 0.000 0.000 0.036 0.228 0.052
#> GSM252438     6  0.1866     0.7681 0.008 0.000 0.000 0.000 0.084 0.908
#> GSM252434     1  0.4594     0.3357 0.488 0.000 0.000 0.476 0.036 0.000
#> GSM252437     1  0.4689     0.3830 0.736 0.000 0.000 0.120 0.036 0.108
#> GSM252451     4  0.3999    -0.4142 0.496 0.000 0.000 0.500 0.004 0.000
#> GSM252448     1  0.3862     0.3816 0.524 0.000 0.000 0.476 0.000 0.000
#> GSM252447     1  0.3843     0.4159 0.548 0.000 0.000 0.452 0.000 0.000
#> GSM252444     1  0.3868     0.3446 0.508 0.000 0.000 0.492 0.000 0.000
#> GSM252450     4  0.4280    -0.2491 0.428 0.000 0.000 0.556 0.008 0.008
#> GSM252452     4  0.4806    -0.1504 0.380 0.000 0.000 0.560 0.060 0.000
#> GSM252443     1  0.4676     0.0620 0.696 0.000 0.000 0.040 0.228 0.036
#> GSM252454     6  0.1367     0.7808 0.012 0.000 0.000 0.000 0.044 0.944
#> GSM252449     1  0.4594     0.3357 0.488 0.000 0.000 0.476 0.036 0.000
#> GSM252445     1  0.4000     0.4189 0.724 0.000 0.000 0.228 0.048 0.000
#> GSM252453     6  0.3273     0.7239 0.212 0.000 0.000 0.004 0.008 0.776
#> GSM252464     4  0.0000     0.6069 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM252463     4  0.0260     0.6054 0.008 0.000 0.000 0.992 0.000 0.000
#> GSM252461     4  0.0363     0.6043 0.012 0.000 0.000 0.988 0.000 0.000
#> GSM252455     4  0.0260     0.6054 0.008 0.000 0.000 0.992 0.000 0.000
#> GSM252458     4  0.0146     0.6065 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM252460     4  0.0603     0.6017 0.016 0.000 0.000 0.980 0.004 0.000
#> GSM252457     4  0.4907     0.3087 0.140 0.000 0.132 0.704 0.024 0.000
#> GSM252456     4  0.0458     0.6030 0.016 0.000 0.000 0.984 0.000 0.000
#> GSM252462     4  0.0922     0.5937 0.024 0.000 0.000 0.968 0.004 0.004
#> GSM252459     6  0.3633     0.7103 0.064 0.000 0.000 0.136 0.004 0.796
#> GSM252472     2  0.1349     0.9519 0.004 0.940 0.000 0.000 0.056 0.000
#> GSM252466     2  0.0547     0.9593 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM252469     2  0.0547     0.9593 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM252475     2  0.1152     0.9554 0.004 0.952 0.000 0.000 0.044 0.000
#> GSM252471     2  0.1010     0.9540 0.004 0.960 0.000 0.000 0.036 0.000
#> GSM252465     2  0.1010     0.9540 0.004 0.960 0.000 0.000 0.036 0.000
#> GSM252474     2  0.0632     0.9545 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM252473     2  0.0935     0.9555 0.004 0.964 0.000 0.000 0.032 0.000
#> GSM252468     2  0.0260     0.9596 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM252470     2  0.0458     0.9592 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM252467     2  0.0260     0.9610 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM252485     2  0.1349     0.9519 0.004 0.940 0.000 0.000 0.056 0.000
#> GSM252481     2  0.0547     0.9593 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM252480     2  0.0547     0.9593 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM252479     2  0.0547     0.9593 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM252482     2  0.0865     0.9553 0.000 0.964 0.000 0.000 0.036 0.000
#> GSM252478     2  0.1010     0.9540 0.004 0.960 0.000 0.000 0.036 0.000
#> GSM252483     2  0.0632     0.9545 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM252477     2  0.0937     0.9549 0.000 0.960 0.000 0.000 0.040 0.000
#> GSM252484     2  0.0363     0.9586 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM252476     2  0.0260     0.9610 0.000 0.992 0.000 0.000 0.008 0.000

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-skmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-skmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-skmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-skmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-skmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-skmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-skmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-skmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-skmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-skmeans-membership-heatmap-5

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)

plot of chunk tab-ATC-skmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-skmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-skmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-skmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-skmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-skmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-ATC-skmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-skmeans-collect-classes

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 agent(p) individual(p) k
#> ATC:skmeans 62 3.69e-10         0.970 2
#> ATC:skmeans 61 8.57e-20         1.000 3
#> ATC:skmeans 59 1.22e-16         0.605 4
#> ATC:skmeans 50 2.37e-15         0.786 5
#> ATC:skmeans 40 7.02e-16         0.793 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.


ATC:pam**

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 51941 rows and 62 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)

plot of chunk ATC-pam-collect-plots

The plots are:

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:

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)

plot of chunk ATC-pam-select-partition-number

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.4659 0.535   0.535
#> 3 3 0.819           0.873       0.932         0.4175 0.789   0.611
#> 4 4 0.999           0.944       0.973         0.1353 0.860   0.615
#> 5 5 0.982           0.918       0.961         0.0658 0.952   0.809
#> 6 6 0.952           0.901       0.948         0.0431 0.953   0.777

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 4 5

There is also optional best \(k\) = 2 4 5 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM252423     1       0          1  1  0
#> GSM252429     1       0          1  1  0
#> GSM252424     1       0          1  1  0
#> GSM252432     1       0          1  1  0
#> GSM252427     1       0          1  1  0
#> GSM252431     1       0          1  1  0
#> GSM252430     1       0          1  1  0
#> GSM252433     1       0          1  1  0
#> GSM252426     1       0          1  1  0
#> GSM252428     1       0          1  1  0
#> GSM252425     2       0          1  0  1
#> GSM252440     1       0          1  1  0
#> GSM252441     1       0          1  1  0
#> GSM252436     1       0          1  1  0
#> GSM252435     1       0          1  1  0
#> GSM252442     1       0          1  1  0
#> GSM252439     1       0          1  1  0
#> GSM252438     1       0          1  1  0
#> GSM252434     1       0          1  1  0
#> GSM252437     1       0          1  1  0
#> GSM252451     1       0          1  1  0
#> GSM252448     1       0          1  1  0
#> GSM252447     1       0          1  1  0
#> GSM252444     1       0          1  1  0
#> GSM252450     1       0          1  1  0
#> GSM252452     1       0          1  1  0
#> GSM252443     1       0          1  1  0
#> GSM252454     1       0          1  1  0
#> GSM252449     1       0          1  1  0
#> GSM252445     1       0          1  1  0
#> GSM252453     1       0          1  1  0
#> GSM252464     1       0          1  1  0
#> GSM252463     1       0          1  1  0
#> GSM252461     1       0          1  1  0
#> GSM252455     1       0          1  1  0
#> GSM252458     1       0          1  1  0
#> GSM252460     1       0          1  1  0
#> GSM252457     1       0          1  1  0
#> GSM252456     1       0          1  1  0
#> GSM252462     1       0          1  1  0
#> GSM252459     1       0          1  1  0
#> GSM252472     2       0          1  0  1
#> GSM252466     2       0          1  0  1
#> GSM252469     2       0          1  0  1
#> GSM252475     2       0          1  0  1
#> GSM252471     2       0          1  0  1
#> GSM252465     2       0          1  0  1
#> GSM252474     2       0          1  0  1
#> GSM252473     2       0          1  0  1
#> GSM252468     2       0          1  0  1
#> GSM252470     2       0          1  0  1
#> GSM252467     2       0          1  0  1
#> GSM252485     2       0          1  0  1
#> GSM252481     2       0          1  0  1
#> GSM252480     2       0          1  0  1
#> GSM252479     2       0          1  0  1
#> GSM252482     2       0          1  0  1
#> GSM252478     2       0          1  0  1
#> GSM252483     2       0          1  0  1
#> GSM252477     2       0          1  0  1
#> GSM252484     2       0          1  0  1
#> GSM252476     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1  p2    p3
#> GSM252423     3   0.000      0.909 0.000 0.0 1.000
#> GSM252429     3   0.000      0.909 0.000 0.0 1.000
#> GSM252424     3   0.000      0.909 0.000 0.0 1.000
#> GSM252432     3   0.000      0.909 0.000 0.0 1.000
#> GSM252427     3   0.000      0.909 0.000 0.0 1.000
#> GSM252431     3   0.000      0.909 0.000 0.0 1.000
#> GSM252430     3   0.000      0.909 0.000 0.0 1.000
#> GSM252433     3   0.000      0.909 0.000 0.0 1.000
#> GSM252426     3   0.000      0.909 0.000 0.0 1.000
#> GSM252428     3   0.000      0.909 0.000 0.0 1.000
#> GSM252425     3   0.556      0.492 0.000 0.3 0.700
#> GSM252440     1   0.000      0.858 1.000 0.0 0.000
#> GSM252441     1   0.000      0.858 1.000 0.0 0.000
#> GSM252436     1   0.000      0.858 1.000 0.0 0.000
#> GSM252435     1   0.445      0.802 0.808 0.0 0.192
#> GSM252442     1   0.216      0.859 0.936 0.0 0.064
#> GSM252439     1   0.556      0.711 0.700 0.0 0.300
#> GSM252438     3   0.412      0.732 0.168 0.0 0.832
#> GSM252434     1   0.216      0.859 0.936 0.0 0.064
#> GSM252437     1   0.522      0.753 0.740 0.0 0.260
#> GSM252451     1   0.000      0.858 1.000 0.0 0.000
#> GSM252448     1   0.000      0.858 1.000 0.0 0.000
#> GSM252447     1   0.000      0.858 1.000 0.0 0.000
#> GSM252444     1   0.000      0.858 1.000 0.0 0.000
#> GSM252450     1   0.245      0.857 0.924 0.0 0.076
#> GSM252452     1   0.518      0.757 0.744 0.0 0.256
#> GSM252443     1   0.556      0.711 0.700 0.0 0.300
#> GSM252454     3   0.418      0.727 0.172 0.0 0.828
#> GSM252449     1   0.216      0.859 0.936 0.0 0.064
#> GSM252445     1   0.518      0.757 0.744 0.0 0.256
#> GSM252453     1   0.533      0.742 0.728 0.0 0.272
#> GSM252464     1   0.000      0.858 1.000 0.0 0.000
#> GSM252463     1   0.153      0.848 0.960 0.0 0.040
#> GSM252461     1   0.000      0.858 1.000 0.0 0.000
#> GSM252455     1   0.000      0.858 1.000 0.0 0.000
#> GSM252458     1   0.245      0.857 0.924 0.0 0.076
#> GSM252460     1   0.611      0.559 0.604 0.0 0.396
#> GSM252457     3   0.000      0.909 0.000 0.0 1.000
#> GSM252456     1   0.533      0.693 0.728 0.0 0.272
#> GSM252462     1   0.581      0.656 0.664 0.0 0.336
#> GSM252459     3   0.593      0.295 0.356 0.0 0.644
#> GSM252472     2   0.000      1.000 0.000 1.0 0.000
#> GSM252466     2   0.000      1.000 0.000 1.0 0.000
#> GSM252469     2   0.000      1.000 0.000 1.0 0.000
#> GSM252475     2   0.000      1.000 0.000 1.0 0.000
#> GSM252471     2   0.000      1.000 0.000 1.0 0.000
#> GSM252465     2   0.000      1.000 0.000 1.0 0.000
#> GSM252474     2   0.000      1.000 0.000 1.0 0.000
#> GSM252473     2   0.000      1.000 0.000 1.0 0.000
#> GSM252468     2   0.000      1.000 0.000 1.0 0.000
#> GSM252470     2   0.000      1.000 0.000 1.0 0.000
#> GSM252467     2   0.000      1.000 0.000 1.0 0.000
#> GSM252485     2   0.000      1.000 0.000 1.0 0.000
#> GSM252481     2   0.000      1.000 0.000 1.0 0.000
#> GSM252480     2   0.000      1.000 0.000 1.0 0.000
#> GSM252479     2   0.000      1.000 0.000 1.0 0.000
#> GSM252482     2   0.000      1.000 0.000 1.0 0.000
#> GSM252478     2   0.000      1.000 0.000 1.0 0.000
#> GSM252483     2   0.000      1.000 0.000 1.0 0.000
#> GSM252477     2   0.000      1.000 0.000 1.0 0.000
#> GSM252484     2   0.000      1.000 0.000 1.0 0.000
#> GSM252476     2   0.000      1.000 0.000 1.0 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM252429     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM252424     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM252432     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM252427     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM252431     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM252430     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM252433     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM252426     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM252428     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM252425     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM252440     4  0.0336      0.947 0.008 0.000 0.000 0.992
#> GSM252441     4  0.0707      0.943 0.020 0.000 0.000 0.980
#> GSM252436     4  0.0336      0.947 0.008 0.000 0.000 0.992
#> GSM252435     1  0.0188      0.970 0.996 0.000 0.000 0.004
#> GSM252442     1  0.3610      0.741 0.800 0.000 0.000 0.200
#> GSM252439     1  0.0188      0.970 0.996 0.000 0.000 0.004
#> GSM252438     1  0.2704      0.855 0.876 0.000 0.124 0.000
#> GSM252434     1  0.0592      0.964 0.984 0.000 0.000 0.016
#> GSM252437     1  0.0188      0.970 0.996 0.000 0.000 0.004
#> GSM252451     4  0.1022      0.935 0.032 0.000 0.000 0.968
#> GSM252448     4  0.0336      0.947 0.008 0.000 0.000 0.992
#> GSM252447     4  0.1637      0.914 0.060 0.000 0.000 0.940
#> GSM252444     4  0.0336      0.947 0.008 0.000 0.000 0.992
#> GSM252450     1  0.0336      0.969 0.992 0.000 0.000 0.008
#> GSM252452     1  0.0188      0.970 0.996 0.000 0.000 0.004
#> GSM252443     1  0.0188      0.970 0.996 0.000 0.000 0.004
#> GSM252454     1  0.1118      0.944 0.964 0.000 0.036 0.000
#> GSM252449     1  0.0592      0.964 0.984 0.000 0.000 0.016
#> GSM252445     1  0.0188      0.970 0.996 0.000 0.000 0.004
#> GSM252453     1  0.0188      0.970 0.996 0.000 0.000 0.004
#> GSM252464     4  0.0336      0.947 0.008 0.000 0.000 0.992
#> GSM252463     4  0.0336      0.947 0.008 0.000 0.000 0.992
#> GSM252461     4  0.0336      0.947 0.008 0.000 0.000 0.992
#> GSM252455     4  0.0336      0.947 0.008 0.000 0.000 0.992
#> GSM252458     4  0.1792      0.904 0.068 0.000 0.000 0.932
#> GSM252460     3  0.6300      0.505 0.108 0.000 0.640 0.252
#> GSM252457     3  0.1940      0.895 0.076 0.000 0.924 0.000
#> GSM252456     4  0.6546      0.184 0.080 0.000 0.396 0.524
#> GSM252462     1  0.0188      0.970 0.996 0.000 0.000 0.004
#> GSM252459     1  0.0188      0.968 0.996 0.000 0.004 0.000
#> GSM252472     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252466     2  0.0524      0.993 0.004 0.988 0.000 0.008
#> GSM252469     2  0.0524      0.993 0.004 0.988 0.000 0.008
#> GSM252475     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252471     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252465     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252474     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252473     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252468     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252470     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252467     2  0.0524      0.993 0.004 0.988 0.000 0.008
#> GSM252485     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252481     2  0.0524      0.993 0.004 0.988 0.000 0.008
#> GSM252480     2  0.0524      0.993 0.004 0.988 0.000 0.008
#> GSM252479     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252482     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252478     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252483     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252477     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252484     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM252476     2  0.0524      0.993 0.004 0.988 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000
#> GSM252429     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000
#> GSM252424     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000
#> GSM252432     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000
#> GSM252427     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000
#> GSM252431     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000
#> GSM252430     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000
#> GSM252433     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000
#> GSM252426     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000
#> GSM252428     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000
#> GSM252425     3  0.0162      0.956 0.000 0.000 0.996 0.000 0.004
#> GSM252440     1  0.0000      0.932 1.000 0.000 0.000 0.000 0.000
#> GSM252441     1  0.0404      0.929 0.988 0.000 0.000 0.012 0.000
#> GSM252436     1  0.0000      0.932 1.000 0.000 0.000 0.000 0.000
#> GSM252435     4  0.0290      0.962 0.000 0.000 0.000 0.992 0.008
#> GSM252442     4  0.3438      0.772 0.172 0.000 0.000 0.808 0.020
#> GSM252439     4  0.0162      0.963 0.000 0.000 0.000 0.996 0.004
#> GSM252438     4  0.2389      0.855 0.000 0.000 0.116 0.880 0.004
#> GSM252434     4  0.1549      0.937 0.016 0.000 0.000 0.944 0.040
#> GSM252437     4  0.0162      0.963 0.000 0.000 0.000 0.996 0.004
#> GSM252451     1  0.0794      0.920 0.972 0.000 0.000 0.028 0.000
#> GSM252448     1  0.0000      0.932 1.000 0.000 0.000 0.000 0.000
#> GSM252447     1  0.1341      0.896 0.944 0.000 0.000 0.056 0.000
#> GSM252444     1  0.0000      0.932 1.000 0.000 0.000 0.000 0.000
#> GSM252450     4  0.0579      0.959 0.008 0.000 0.000 0.984 0.008
#> GSM252452     4  0.0290      0.962 0.000 0.000 0.000 0.992 0.008
#> GSM252443     4  0.0000      0.963 0.000 0.000 0.000 1.000 0.000
#> GSM252454     4  0.0865      0.948 0.000 0.000 0.024 0.972 0.004
#> GSM252449     4  0.1444      0.940 0.012 0.000 0.000 0.948 0.040
#> GSM252445     4  0.0000      0.963 0.000 0.000 0.000 1.000 0.000
#> GSM252453     4  0.0162      0.963 0.000 0.000 0.000 0.996 0.004
#> GSM252464     1  0.0880      0.925 0.968 0.000 0.000 0.000 0.032
#> GSM252463     1  0.0880      0.925 0.968 0.000 0.000 0.000 0.032
#> GSM252461     1  0.0290      0.932 0.992 0.000 0.000 0.000 0.008
#> GSM252455     1  0.0404      0.931 0.988 0.000 0.000 0.000 0.012
#> GSM252458     1  0.2228      0.884 0.912 0.000 0.000 0.048 0.040
#> GSM252460     3  0.6176      0.470 0.252 0.000 0.616 0.092 0.040
#> GSM252457     3  0.1671      0.884 0.000 0.000 0.924 0.076 0.000
#> GSM252456     1  0.6326      0.152 0.500 0.000 0.396 0.064 0.040
#> GSM252462     4  0.0000      0.963 0.000 0.000 0.000 1.000 0.000
#> GSM252459     4  0.0162      0.963 0.000 0.000 0.000 0.996 0.004
#> GSM252472     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000
#> GSM252466     5  0.1121      1.000 0.000 0.044 0.000 0.000 0.956
#> GSM252469     5  0.1121      1.000 0.000 0.044 0.000 0.000 0.956
#> GSM252475     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000
#> GSM252471     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000
#> GSM252465     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000
#> GSM252474     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000
#> GSM252473     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000
#> GSM252468     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000
#> GSM252470     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000
#> GSM252467     5  0.1121      1.000 0.000 0.044 0.000 0.000 0.956
#> GSM252485     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000
#> GSM252481     5  0.1121      1.000 0.000 0.044 0.000 0.000 0.956
#> GSM252480     5  0.1121      1.000 0.000 0.044 0.000 0.000 0.956
#> GSM252479     2  0.4249      0.176 0.000 0.568 0.000 0.000 0.432
#> GSM252482     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000
#> GSM252478     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000
#> GSM252483     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000
#> GSM252477     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000
#> GSM252484     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000
#> GSM252476     5  0.1121      1.000 0.000 0.044 0.000 0.000 0.956

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252429     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252424     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252432     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252427     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252431     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252430     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252433     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252426     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252428     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252425     3  0.0146      0.994 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM252440     1  0.0146      0.932 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM252441     1  0.1327      0.918 0.936 0.000 0.000 0.064 0.000 0.000
#> GSM252436     1  0.0000      0.931 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM252435     6  0.3390      0.706 0.000 0.000 0.000 0.296 0.000 0.704
#> GSM252442     6  0.5144      0.464 0.092 0.000 0.000 0.372 0.000 0.536
#> GSM252439     6  0.0000      0.886 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM252438     6  0.0000      0.886 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM252434     4  0.0790      0.808 0.000 0.000 0.000 0.968 0.000 0.032
#> GSM252437     6  0.0000      0.886 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM252451     1  0.1327      0.918 0.936 0.000 0.000 0.064 0.000 0.000
#> GSM252448     1  0.0547      0.932 0.980 0.000 0.000 0.020 0.000 0.000
#> GSM252447     1  0.1327      0.918 0.936 0.000 0.000 0.064 0.000 0.000
#> GSM252444     1  0.0000      0.931 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM252450     6  0.3464      0.692 0.000 0.000 0.000 0.312 0.000 0.688
#> GSM252452     6  0.3330      0.713 0.000 0.000 0.000 0.284 0.000 0.716
#> GSM252443     6  0.0146      0.886 0.000 0.000 0.000 0.004 0.000 0.996
#> GSM252454     6  0.0000      0.886 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM252449     4  0.0790      0.808 0.000 0.000 0.000 0.968 0.000 0.032
#> GSM252445     6  0.0458      0.882 0.000 0.000 0.000 0.016 0.000 0.984
#> GSM252453     6  0.0000      0.886 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM252464     4  0.3330      0.704 0.284 0.000 0.000 0.716 0.000 0.000
#> GSM252463     4  0.3330      0.704 0.284 0.000 0.000 0.716 0.000 0.000
#> GSM252461     1  0.1610      0.876 0.916 0.000 0.000 0.084 0.000 0.000
#> GSM252455     1  0.2260      0.807 0.860 0.000 0.000 0.140 0.000 0.000
#> GSM252458     4  0.2969      0.763 0.224 0.000 0.000 0.776 0.000 0.000
#> GSM252460     4  0.1204      0.822 0.056 0.000 0.000 0.944 0.000 0.000
#> GSM252457     3  0.0713      0.969 0.000 0.000 0.972 0.000 0.000 0.028
#> GSM252456     4  0.0458      0.821 0.016 0.000 0.000 0.984 0.000 0.000
#> GSM252462     6  0.0146      0.886 0.000 0.000 0.000 0.004 0.000 0.996
#> GSM252459     6  0.0000      0.886 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM252472     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252466     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM252469     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM252475     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252471     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252465     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252474     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252473     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252468     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252470     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252467     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM252485     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252481     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM252480     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM252479     2  0.3823      0.227 0.000 0.564 0.000 0.000 0.436 0.000
#> GSM252482     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252478     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252483     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252477     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252484     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM252476     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.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)

plot of chunk tab-ATC-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-pam-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-pam-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-pam-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-pam-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-pam-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-pam-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-pam-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-pam-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-pam-membership-heatmap-5

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)

plot of chunk tab-ATC-pam-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-pam-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-pam-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-pam-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-pam-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-pam-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-ATC-pam-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-pam-collect-classes

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 agent(p) individual(p) k
#> ATC:pam 62 3.10e-11        0.9963 2
#> ATC:pam 60 2.86e-17        0.9804 3
#> ATC:pam 61 9.07e-18        0.5930 4
#> ATC:pam 59 7.90e-16        0.1639 5
#> ATC:pam 60 1.14e-15        0.0625 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.


ATC:mclust

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 51941 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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:

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)

plot of chunk ATC-mclust-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.791           0.950       0.973         0.4657 0.545   0.545
#> 3 3 0.860           0.907       0.952         0.4153 0.794   0.621
#> 4 4 0.771           0.737       0.849         0.0995 0.928   0.791
#> 5 5 0.703           0.610       0.781         0.0768 0.929   0.753
#> 6 6 0.860           0.817       0.883         0.0560 0.873   0.508

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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1   0.541      0.883 0.876 0.124
#> GSM252429     1   0.541      0.883 0.876 0.124
#> GSM252424     1   0.430      0.907 0.912 0.088
#> GSM252432     1   0.541      0.883 0.876 0.124
#> GSM252427     1   0.541      0.883 0.876 0.124
#> GSM252431     1   0.541      0.883 0.876 0.124
#> GSM252430     1   0.644      0.841 0.836 0.164
#> GSM252433     1   0.563      0.875 0.868 0.132
#> GSM252426     1   0.541      0.883 0.876 0.124
#> GSM252428     1   0.541      0.883 0.876 0.124
#> GSM252425     1   0.981      0.368 0.580 0.420
#> GSM252440     1   0.000      0.957 1.000 0.000
#> GSM252441     1   0.000      0.957 1.000 0.000
#> GSM252436     1   0.000      0.957 1.000 0.000
#> GSM252435     1   0.000      0.957 1.000 0.000
#> GSM252442     1   0.000      0.957 1.000 0.000
#> GSM252439     1   0.000      0.957 1.000 0.000
#> GSM252438     1   0.000      0.957 1.000 0.000
#> GSM252434     1   0.000      0.957 1.000 0.000
#> GSM252437     1   0.000      0.957 1.000 0.000
#> GSM252451     1   0.000      0.957 1.000 0.000
#> GSM252448     1   0.000      0.957 1.000 0.000
#> GSM252447     1   0.000      0.957 1.000 0.000
#> GSM252444     1   0.000      0.957 1.000 0.000
#> GSM252450     1   0.000      0.957 1.000 0.000
#> GSM252452     1   0.000      0.957 1.000 0.000
#> GSM252443     1   0.000      0.957 1.000 0.000
#> GSM252454     1   0.000      0.957 1.000 0.000
#> GSM252449     1   0.000      0.957 1.000 0.000
#> GSM252445     1   0.000      0.957 1.000 0.000
#> GSM252453     1   0.000      0.957 1.000 0.000
#> GSM252464     1   0.000      0.957 1.000 0.000
#> GSM252463     1   0.000      0.957 1.000 0.000
#> GSM252461     1   0.000      0.957 1.000 0.000
#> GSM252455     1   0.000      0.957 1.000 0.000
#> GSM252458     1   0.000      0.957 1.000 0.000
#> GSM252460     1   0.000      0.957 1.000 0.000
#> GSM252457     1   0.000      0.957 1.000 0.000
#> GSM252456     1   0.000      0.957 1.000 0.000
#> GSM252462     1   0.000      0.957 1.000 0.000
#> GSM252459     1   0.000      0.957 1.000 0.000
#> GSM252472     2   0.000      1.000 0.000 1.000
#> GSM252466     2   0.000      1.000 0.000 1.000
#> GSM252469     2   0.000      1.000 0.000 1.000
#> GSM252475     2   0.000      1.000 0.000 1.000
#> GSM252471     2   0.000      1.000 0.000 1.000
#> GSM252465     2   0.000      1.000 0.000 1.000
#> GSM252474     2   0.000      1.000 0.000 1.000
#> GSM252473     2   0.000      1.000 0.000 1.000
#> GSM252468     2   0.000      1.000 0.000 1.000
#> GSM252470     2   0.000      1.000 0.000 1.000
#> GSM252467     2   0.000      1.000 0.000 1.000
#> GSM252485     2   0.000      1.000 0.000 1.000
#> GSM252481     2   0.000      1.000 0.000 1.000
#> GSM252480     2   0.000      1.000 0.000 1.000
#> GSM252479     2   0.000      1.000 0.000 1.000
#> GSM252482     2   0.000      1.000 0.000 1.000
#> GSM252478     2   0.000      1.000 0.000 1.000
#> GSM252483     2   0.000      1.000 0.000 1.000
#> GSM252477     2   0.000      1.000 0.000 1.000
#> GSM252484     2   0.000      1.000 0.000 1.000
#> GSM252476     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1   p2    p3
#> GSM252423     3  0.0000      0.891 0.000 0.00 1.000
#> GSM252429     3  0.0000      0.891 0.000 0.00 1.000
#> GSM252424     3  0.0000      0.891 0.000 0.00 1.000
#> GSM252432     3  0.0000      0.891 0.000 0.00 1.000
#> GSM252427     3  0.0237      0.892 0.004 0.00 0.996
#> GSM252431     3  0.0237      0.892 0.004 0.00 0.996
#> GSM252430     3  0.0237      0.892 0.004 0.00 0.996
#> GSM252433     3  0.0237      0.892 0.004 0.00 0.996
#> GSM252426     3  0.0237      0.892 0.004 0.00 0.996
#> GSM252428     3  0.0237      0.892 0.004 0.00 0.996
#> GSM252425     3  0.4291      0.709 0.000 0.18 0.820
#> GSM252440     1  0.0237      0.930 0.996 0.00 0.004
#> GSM252441     1  0.0237      0.930 0.996 0.00 0.004
#> GSM252436     1  0.0237      0.930 0.996 0.00 0.004
#> GSM252435     1  0.0000      0.931 1.000 0.00 0.000
#> GSM252442     1  0.0000      0.931 1.000 0.00 0.000
#> GSM252439     1  0.0237      0.930 0.996 0.00 0.004
#> GSM252438     3  0.6154      0.460 0.408 0.00 0.592
#> GSM252434     1  0.0000      0.931 1.000 0.00 0.000
#> GSM252437     1  0.0237      0.930 0.996 0.00 0.004
#> GSM252451     1  0.0000      0.931 1.000 0.00 0.000
#> GSM252448     1  0.0237      0.930 0.996 0.00 0.004
#> GSM252447     1  0.0237      0.930 0.996 0.00 0.004
#> GSM252444     1  0.0237      0.930 0.996 0.00 0.004
#> GSM252450     1  0.0000      0.931 1.000 0.00 0.000
#> GSM252452     1  0.0000      0.931 1.000 0.00 0.000
#> GSM252443     1  0.0237      0.930 0.996 0.00 0.004
#> GSM252454     3  0.6180      0.443 0.416 0.00 0.584
#> GSM252449     1  0.0000      0.931 1.000 0.00 0.000
#> GSM252445     1  0.0000      0.931 1.000 0.00 0.000
#> GSM252453     1  0.0237      0.930 0.996 0.00 0.004
#> GSM252464     1  0.4346      0.827 0.816 0.00 0.184
#> GSM252463     1  0.4346      0.827 0.816 0.00 0.184
#> GSM252461     1  0.4346      0.827 0.816 0.00 0.184
#> GSM252455     1  0.4346      0.827 0.816 0.00 0.184
#> GSM252458     1  0.4291      0.828 0.820 0.00 0.180
#> GSM252460     1  0.4291      0.828 0.820 0.00 0.180
#> GSM252457     3  0.0747      0.885 0.016 0.00 0.984
#> GSM252456     1  0.4291      0.828 0.820 0.00 0.180
#> GSM252462     1  0.4121      0.837 0.832 0.00 0.168
#> GSM252459     3  0.6192      0.434 0.420 0.00 0.580
#> GSM252472     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252466     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252469     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252475     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252471     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252465     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252474     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252473     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252468     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252470     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252467     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252485     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252481     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252480     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252479     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252482     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252478     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252483     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252477     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252484     2  0.0000      1.000 0.000 1.00 0.000
#> GSM252476     2  0.0000      1.000 0.000 1.00 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> GSM252429     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> GSM252424     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> GSM252432     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> GSM252427     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> GSM252431     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> GSM252430     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> GSM252433     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> GSM252426     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> GSM252428     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> GSM252425     3  0.0817      0.950 0.000 0.000 0.976 0.024
#> GSM252440     1  0.3444      0.703 0.816 0.000 0.000 0.184
#> GSM252441     1  0.3444      0.703 0.816 0.000 0.000 0.184
#> GSM252436     1  0.3356      0.705 0.824 0.000 0.000 0.176
#> GSM252435     4  0.5483      0.447 0.448 0.000 0.016 0.536
#> GSM252442     1  0.3494      0.688 0.824 0.000 0.004 0.172
#> GSM252439     4  0.5713      0.499 0.360 0.000 0.036 0.604
#> GSM252438     4  0.6436      0.577 0.100 0.000 0.292 0.608
#> GSM252434     1  0.3801      0.686 0.780 0.000 0.000 0.220
#> GSM252437     4  0.5512      0.447 0.488 0.000 0.016 0.496
#> GSM252451     1  0.3356      0.694 0.824 0.000 0.000 0.176
#> GSM252448     1  0.3444      0.703 0.816 0.000 0.000 0.184
#> GSM252447     1  0.3444      0.703 0.816 0.000 0.000 0.184
#> GSM252444     1  0.3444      0.703 0.816 0.000 0.000 0.184
#> GSM252450     1  0.4594      0.517 0.712 0.000 0.008 0.280
#> GSM252452     1  0.4516      0.479 0.736 0.000 0.012 0.252
#> GSM252443     4  0.5408      0.382 0.408 0.000 0.016 0.576
#> GSM252454     4  0.6466      0.584 0.104 0.000 0.288 0.608
#> GSM252449     1  0.3569      0.692 0.804 0.000 0.000 0.196
#> GSM252445     1  0.4356      0.586 0.708 0.000 0.000 0.292
#> GSM252453     1  0.5937     -0.543 0.492 0.000 0.036 0.472
#> GSM252464     1  0.2376      0.643 0.916 0.000 0.016 0.068
#> GSM252463     1  0.2300      0.643 0.920 0.000 0.016 0.064
#> GSM252461     1  0.1284      0.660 0.964 0.000 0.012 0.024
#> GSM252455     1  0.2101      0.648 0.928 0.000 0.012 0.060
#> GSM252458     1  0.2376      0.643 0.916 0.000 0.016 0.068
#> GSM252460     1  0.2742      0.634 0.900 0.000 0.024 0.076
#> GSM252457     3  0.5811      0.564 0.180 0.000 0.704 0.116
#> GSM252456     1  0.2376      0.643 0.916 0.000 0.016 0.068
#> GSM252462     1  0.5992     -0.420 0.516 0.000 0.040 0.444
#> GSM252459     4  0.6745      0.609 0.176 0.000 0.212 0.612
#> GSM252472     2  0.4008      0.830 0.000 0.756 0.000 0.244
#> GSM252466     2  0.0188      0.927 0.000 0.996 0.000 0.004
#> GSM252469     2  0.0188      0.927 0.000 0.996 0.000 0.004
#> GSM252475     2  0.0707      0.923 0.000 0.980 0.000 0.020
#> GSM252471     2  0.4008      0.830 0.000 0.756 0.000 0.244
#> GSM252465     2  0.4008      0.830 0.000 0.756 0.000 0.244
#> GSM252474     2  0.1637      0.906 0.000 0.940 0.000 0.060
#> GSM252473     2  0.4008      0.830 0.000 0.756 0.000 0.244
#> GSM252468     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM252470     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM252467     2  0.0188      0.927 0.000 0.996 0.000 0.004
#> GSM252485     2  0.4008      0.830 0.000 0.756 0.000 0.244
#> GSM252481     2  0.0188      0.927 0.000 0.996 0.000 0.004
#> GSM252480     2  0.0188      0.927 0.000 0.996 0.000 0.004
#> GSM252479     2  0.0188      0.927 0.000 0.996 0.000 0.004
#> GSM252482     2  0.0921      0.919 0.000 0.972 0.000 0.028
#> GSM252478     2  0.4008      0.830 0.000 0.756 0.000 0.244
#> GSM252483     2  0.1637      0.906 0.000 0.940 0.000 0.060
#> GSM252477     2  0.1118      0.916 0.000 0.964 0.000 0.036
#> GSM252484     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM252476     2  0.0188      0.927 0.000 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.0000     0.9280 0.000 0.000 1.000 0.000 0.000
#> GSM252429     3  0.0000     0.9280 0.000 0.000 1.000 0.000 0.000
#> GSM252424     3  0.0000     0.9280 0.000 0.000 1.000 0.000 0.000
#> GSM252432     3  0.0000     0.9280 0.000 0.000 1.000 0.000 0.000
#> GSM252427     3  0.0000     0.9280 0.000 0.000 1.000 0.000 0.000
#> GSM252431     3  0.0162     0.9262 0.000 0.000 0.996 0.000 0.004
#> GSM252430     3  0.0000     0.9280 0.000 0.000 1.000 0.000 0.000
#> GSM252433     3  0.0162     0.9262 0.000 0.000 0.996 0.000 0.004
#> GSM252426     3  0.0000     0.9280 0.000 0.000 1.000 0.000 0.000
#> GSM252428     3  0.0000     0.9280 0.000 0.000 1.000 0.000 0.000
#> GSM252425     3  0.6011     0.2333 0.000 0.344 0.528 0.000 0.128
#> GSM252440     1  0.0963     0.7768 0.964 0.000 0.000 0.036 0.000
#> GSM252441     1  0.0963     0.7768 0.964 0.000 0.000 0.036 0.000
#> GSM252436     1  0.0000     0.7834 1.000 0.000 0.000 0.000 0.000
#> GSM252435     4  0.5068     0.6204 0.388 0.000 0.040 0.572 0.000
#> GSM252442     1  0.1544     0.7775 0.932 0.000 0.000 0.068 0.000
#> GSM252439     4  0.5260     0.7264 0.332 0.000 0.064 0.604 0.000
#> GSM252438     4  0.4482     0.7682 0.088 0.000 0.160 0.752 0.000
#> GSM252434     1  0.0794     0.7841 0.972 0.000 0.000 0.028 0.000
#> GSM252437     4  0.4010     0.7936 0.160 0.000 0.056 0.784 0.000
#> GSM252451     1  0.1197     0.7828 0.952 0.000 0.000 0.048 0.000
#> GSM252448     1  0.0963     0.7768 0.964 0.000 0.000 0.036 0.000
#> GSM252447     1  0.0963     0.7768 0.964 0.000 0.000 0.036 0.000
#> GSM252444     1  0.0963     0.7768 0.964 0.000 0.000 0.036 0.000
#> GSM252450     1  0.4074     0.1675 0.636 0.000 0.000 0.364 0.000
#> GSM252452     1  0.5083     0.0278 0.532 0.000 0.036 0.432 0.000
#> GSM252443     4  0.5364     0.6847 0.364 0.000 0.064 0.572 0.000
#> GSM252454     4  0.4478     0.7882 0.100 0.000 0.144 0.756 0.000
#> GSM252449     1  0.1043     0.7841 0.960 0.000 0.000 0.040 0.000
#> GSM252445     1  0.3707     0.3283 0.716 0.000 0.000 0.284 0.000
#> GSM252453     4  0.3846     0.7906 0.144 0.000 0.056 0.800 0.000
#> GSM252464     1  0.4313     0.7289 0.732 0.000 0.040 0.228 0.000
#> GSM252463     1  0.4313     0.7289 0.732 0.000 0.040 0.228 0.000
#> GSM252461     1  0.3462     0.7524 0.792 0.000 0.012 0.196 0.000
#> GSM252455     1  0.4096     0.7409 0.760 0.000 0.040 0.200 0.000
#> GSM252458     1  0.4313     0.7289 0.732 0.000 0.040 0.228 0.000
#> GSM252460     1  0.4683     0.7037 0.732 0.000 0.092 0.176 0.000
#> GSM252457     3  0.3266     0.6847 0.004 0.000 0.796 0.200 0.000
#> GSM252456     1  0.4313     0.7289 0.732 0.000 0.040 0.228 0.000
#> GSM252462     4  0.5580     0.6707 0.236 0.000 0.132 0.632 0.000
#> GSM252459     4  0.4406     0.7980 0.108 0.000 0.128 0.764 0.000
#> GSM252472     2  0.4331     0.5370 0.000 0.596 0.000 0.004 0.400
#> GSM252466     5  0.4305     0.9084 0.000 0.488 0.000 0.000 0.512
#> GSM252469     5  0.4302     0.9120 0.000 0.480 0.000 0.000 0.520
#> GSM252475     2  0.0865     0.4375 0.000 0.972 0.000 0.004 0.024
#> GSM252471     2  0.4321     0.5375 0.000 0.600 0.000 0.004 0.396
#> GSM252465     2  0.4331     0.5370 0.000 0.596 0.000 0.004 0.400
#> GSM252474     5  0.4283     0.8645 0.000 0.456 0.000 0.000 0.544
#> GSM252473     2  0.4276     0.5370 0.000 0.616 0.000 0.004 0.380
#> GSM252468     2  0.0609     0.3993 0.000 0.980 0.000 0.000 0.020
#> GSM252470     2  0.0963     0.4272 0.000 0.964 0.000 0.000 0.036
#> GSM252467     2  0.4256    -0.7856 0.000 0.564 0.000 0.000 0.436
#> GSM252485     2  0.4331     0.5370 0.000 0.596 0.000 0.004 0.400
#> GSM252481     2  0.4273    -0.8132 0.000 0.552 0.000 0.000 0.448
#> GSM252480     5  0.4302     0.9120 0.000 0.480 0.000 0.000 0.520
#> GSM252479     2  0.2561     0.1875 0.000 0.856 0.000 0.000 0.144
#> GSM252482     2  0.1544     0.3858 0.000 0.932 0.000 0.000 0.068
#> GSM252478     2  0.4331     0.5370 0.000 0.596 0.000 0.004 0.400
#> GSM252483     5  0.4262     0.8707 0.000 0.440 0.000 0.000 0.560
#> GSM252477     2  0.1671     0.4050 0.000 0.924 0.000 0.000 0.076
#> GSM252484     2  0.3039    -0.0747 0.000 0.808 0.000 0.000 0.192
#> GSM252476     2  0.4192    -0.7220 0.000 0.596 0.000 0.000 0.404

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM252423     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252429     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252424     3  0.0146      0.964 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM252432     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM252427     3  0.0146      0.965 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM252431     3  0.0865      0.956 0.000 0.000 0.964 0.036 0.000 0.000
#> GSM252430     3  0.0458      0.963 0.000 0.000 0.984 0.016 0.000 0.000
#> GSM252433     3  0.1007      0.954 0.000 0.000 0.956 0.044 0.000 0.000
#> GSM252426     3  0.0146      0.965 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM252428     3  0.0508      0.964 0.004 0.000 0.984 0.012 0.000 0.000
#> GSM252425     3  0.2905      0.870 0.000 0.000 0.856 0.048 0.092 0.004
#> GSM252440     1  0.0000      0.843 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM252441     1  0.0146      0.842 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM252436     1  0.0547      0.839 0.980 0.000 0.000 0.020 0.000 0.000
#> GSM252435     6  0.3616      0.715 0.232 0.000 0.008 0.012 0.000 0.748
#> GSM252442     1  0.4338     -0.322 0.492 0.000 0.000 0.020 0.000 0.488
#> GSM252439     6  0.3470      0.698 0.176 0.000 0.012 0.020 0.000 0.792
#> GSM252438     6  0.1913      0.745 0.000 0.000 0.080 0.012 0.000 0.908
#> GSM252434     1  0.1334      0.830 0.948 0.000 0.000 0.020 0.000 0.032
#> GSM252437     6  0.3230      0.730 0.212 0.000 0.012 0.000 0.000 0.776
#> GSM252451     1  0.1418      0.827 0.944 0.000 0.000 0.024 0.000 0.032
#> GSM252448     1  0.0146      0.842 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM252447     1  0.0146      0.842 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM252444     1  0.0000      0.843 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM252450     6  0.4328      0.570 0.352 0.000 0.004 0.024 0.000 0.620
#> GSM252452     6  0.4654      0.543 0.368 0.000 0.016 0.024 0.000 0.592
#> GSM252443     6  0.3536      0.691 0.184 0.000 0.012 0.020 0.000 0.784
#> GSM252454     6  0.1701      0.747 0.000 0.000 0.072 0.008 0.000 0.920
#> GSM252449     1  0.1176      0.834 0.956 0.000 0.000 0.020 0.000 0.024
#> GSM252445     1  0.4333     -0.251 0.512 0.000 0.000 0.020 0.000 0.468
#> GSM252453     6  0.3430      0.733 0.208 0.000 0.016 0.004 0.000 0.772
#> GSM252464     4  0.1745      0.987 0.056 0.000 0.020 0.924 0.000 0.000
#> GSM252463     4  0.1745      0.987 0.056 0.000 0.020 0.924 0.000 0.000
#> GSM252461     4  0.2070      0.943 0.100 0.000 0.008 0.892 0.000 0.000
#> GSM252455     4  0.1745      0.987 0.056 0.000 0.020 0.924 0.000 0.000
#> GSM252458     4  0.1682      0.986 0.052 0.000 0.020 0.928 0.000 0.000
#> GSM252460     4  0.1989      0.978 0.052 0.000 0.028 0.916 0.000 0.004
#> GSM252457     3  0.3018      0.802 0.004 0.000 0.816 0.012 0.000 0.168
#> GSM252456     4  0.1682      0.986 0.052 0.000 0.020 0.928 0.000 0.000
#> GSM252462     6  0.3626      0.734 0.012 0.000 0.092 0.084 0.000 0.812
#> GSM252459     6  0.1951      0.748 0.000 0.000 0.076 0.016 0.000 0.908
#> GSM252472     5  0.0000      0.998 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM252466     2  0.2309      0.825 0.000 0.888 0.000 0.028 0.084 0.000
#> GSM252469     2  0.2255      0.825 0.000 0.892 0.000 0.028 0.080 0.000
#> GSM252475     2  0.3659      0.719 0.000 0.636 0.000 0.000 0.364 0.000
#> GSM252471     5  0.0146      0.996 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM252465     5  0.0000      0.998 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM252474     2  0.0547      0.801 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM252473     5  0.0146      0.996 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM252468     2  0.3499      0.763 0.000 0.680 0.000 0.000 0.320 0.000
#> GSM252470     2  0.3309      0.770 0.000 0.720 0.000 0.000 0.280 0.000
#> GSM252467     2  0.2309      0.826 0.000 0.888 0.000 0.028 0.084 0.000
#> GSM252485     5  0.0000      0.998 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM252481     2  0.2361      0.826 0.000 0.884 0.000 0.028 0.088 0.000
#> GSM252480     2  0.2255      0.825 0.000 0.892 0.000 0.028 0.080 0.000
#> GSM252479     2  0.3371      0.781 0.000 0.708 0.000 0.000 0.292 0.000
#> GSM252482     2  0.3101      0.762 0.000 0.756 0.000 0.000 0.244 0.000
#> GSM252478     5  0.0000      0.998 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM252483     2  0.0363      0.798 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM252477     2  0.3101      0.762 0.000 0.756 0.000 0.000 0.244 0.000
#> GSM252484     2  0.3351      0.778 0.000 0.712 0.000 0.000 0.288 0.000
#> GSM252476     2  0.2462      0.827 0.000 0.876 0.000 0.028 0.096 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)

plot of chunk tab-ATC-mclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-mclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-mclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-mclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-mclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-mclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-mclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-mclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-mclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-mclust-membership-heatmap-5

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)

plot of chunk tab-ATC-mclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-mclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-mclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-mclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-mclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-mclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-ATC-mclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-mclust-collect-classes

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 agent(p) individual(p) k
#> ATC:mclust 61 7.55e-12         1.000 2
#> ATC:mclust 59 2.52e-19         1.000 3
#> ATC:mclust 55 2.41e-15         0.726 4
#> ATC:mclust 48 2.79e-11         0.117 5
#> ATC:mclust 60 6.03e-21         0.725 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.


ATC:NMF*

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 51941 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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:

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)

plot of chunk ATC-NMF-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.988       0.994         0.4843 0.518   0.518
#> 3 3 0.918           0.888       0.952         0.3732 0.774   0.581
#> 4 4 0.776           0.737       0.898         0.0632 0.929   0.802
#> 5 5 0.753           0.760       0.879         0.0746 0.895   0.683
#> 6 6 0.665           0.646       0.790         0.0417 0.941   0.773

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2

There is also optional best \(k\) = 2 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM252423     1  0.0000      0.992 1.000 0.000
#> GSM252429     1  0.0000      0.992 1.000 0.000
#> GSM252424     1  0.0000      0.992 1.000 0.000
#> GSM252432     1  0.0000      0.992 1.000 0.000
#> GSM252427     1  0.0000      0.992 1.000 0.000
#> GSM252431     1  0.7299      0.747 0.796 0.204
#> GSM252430     2  0.2603      0.954 0.044 0.956
#> GSM252433     2  0.0938      0.987 0.012 0.988
#> GSM252426     1  0.0000      0.992 1.000 0.000
#> GSM252428     1  0.4161      0.907 0.916 0.084
#> GSM252425     2  0.0000      0.998 0.000 1.000
#> GSM252440     1  0.0000      0.992 1.000 0.000
#> GSM252441     1  0.0000      0.992 1.000 0.000
#> GSM252436     1  0.0000      0.992 1.000 0.000
#> GSM252435     1  0.0000      0.992 1.000 0.000
#> GSM252442     1  0.0000      0.992 1.000 0.000
#> GSM252439     1  0.0000      0.992 1.000 0.000
#> GSM252438     1  0.0376      0.989 0.996 0.004
#> GSM252434     1  0.0000      0.992 1.000 0.000
#> GSM252437     1  0.0000      0.992 1.000 0.000
#> GSM252451     1  0.0000      0.992 1.000 0.000
#> GSM252448     1  0.0000      0.992 1.000 0.000
#> GSM252447     1  0.0000      0.992 1.000 0.000
#> GSM252444     1  0.0000      0.992 1.000 0.000
#> GSM252450     1  0.0000      0.992 1.000 0.000
#> GSM252452     1  0.0000      0.992 1.000 0.000
#> GSM252443     1  0.0000      0.992 1.000 0.000
#> GSM252454     1  0.0000      0.992 1.000 0.000
#> GSM252449     1  0.0000      0.992 1.000 0.000
#> GSM252445     1  0.0000      0.992 1.000 0.000
#> GSM252453     1  0.0000      0.992 1.000 0.000
#> GSM252464     1  0.0000      0.992 1.000 0.000
#> GSM252463     1  0.0000      0.992 1.000 0.000
#> GSM252461     1  0.0000      0.992 1.000 0.000
#> GSM252455     1  0.0000      0.992 1.000 0.000
#> GSM252458     1  0.0000      0.992 1.000 0.000
#> GSM252460     1  0.0000      0.992 1.000 0.000
#> GSM252457     1  0.0000      0.992 1.000 0.000
#> GSM252456     1  0.0000      0.992 1.000 0.000
#> GSM252462     1  0.0000      0.992 1.000 0.000
#> GSM252459     1  0.0000      0.992 1.000 0.000
#> GSM252472     2  0.0000      0.998 0.000 1.000
#> GSM252466     2  0.0000      0.998 0.000 1.000
#> GSM252469     2  0.0000      0.998 0.000 1.000
#> GSM252475     2  0.0000      0.998 0.000 1.000
#> GSM252471     2  0.0000      0.998 0.000 1.000
#> GSM252465     2  0.0000      0.998 0.000 1.000
#> GSM252474     2  0.0000      0.998 0.000 1.000
#> GSM252473     2  0.0000      0.998 0.000 1.000
#> GSM252468     2  0.0000      0.998 0.000 1.000
#> GSM252470     2  0.0000      0.998 0.000 1.000
#> GSM252467     2  0.0000      0.998 0.000 1.000
#> GSM252485     2  0.0000      0.998 0.000 1.000
#> GSM252481     2  0.0000      0.998 0.000 1.000
#> GSM252480     2  0.0000      0.998 0.000 1.000
#> GSM252479     2  0.0000      0.998 0.000 1.000
#> GSM252482     2  0.0000      0.998 0.000 1.000
#> GSM252478     2  0.0000      0.998 0.000 1.000
#> GSM252483     2  0.0000      0.998 0.000 1.000
#> GSM252477     2  0.0000      0.998 0.000 1.000
#> GSM252484     2  0.0000      0.998 0.000 1.000
#> GSM252476     2  0.0000      0.998 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM252423     3  0.0237     0.9179 0.004 0.000 0.996
#> GSM252429     3  0.0237     0.9179 0.004 0.000 0.996
#> GSM252424     3  0.0592     0.9166 0.012 0.000 0.988
#> GSM252432     3  0.0592     0.9166 0.012 0.000 0.988
#> GSM252427     3  0.0237     0.9179 0.004 0.000 0.996
#> GSM252431     3  0.0237     0.9179 0.004 0.000 0.996
#> GSM252430     3  0.0424     0.9127 0.000 0.008 0.992
#> GSM252433     3  0.0592     0.9106 0.000 0.012 0.988
#> GSM252426     3  0.0237     0.9179 0.004 0.000 0.996
#> GSM252428     3  0.0237     0.9179 0.004 0.000 0.996
#> GSM252425     3  0.5327     0.5987 0.000 0.272 0.728
#> GSM252440     1  0.0000     0.9184 1.000 0.000 0.000
#> GSM252441     1  0.0000     0.9184 1.000 0.000 0.000
#> GSM252436     1  0.0237     0.9196 0.996 0.000 0.004
#> GSM252435     1  0.0237     0.9196 0.996 0.000 0.004
#> GSM252442     1  0.0424     0.9180 0.992 0.000 0.008
#> GSM252439     1  0.0237     0.9196 0.996 0.000 0.004
#> GSM252438     1  0.8380     0.4653 0.600 0.276 0.124
#> GSM252434     1  0.0237     0.9196 0.996 0.000 0.004
#> GSM252437     1  0.0237     0.9196 0.996 0.000 0.004
#> GSM252451     1  0.0237     0.9196 0.996 0.000 0.004
#> GSM252448     1  0.0000     0.9184 1.000 0.000 0.000
#> GSM252447     1  0.0000     0.9184 1.000 0.000 0.000
#> GSM252444     1  0.0237     0.9196 0.996 0.000 0.004
#> GSM252450     1  0.0237     0.9196 0.996 0.000 0.004
#> GSM252452     1  0.0424     0.9180 0.992 0.000 0.008
#> GSM252443     1  0.0237     0.9196 0.996 0.000 0.004
#> GSM252454     1  0.1774     0.8975 0.960 0.024 0.016
#> GSM252449     1  0.0237     0.9196 0.996 0.000 0.004
#> GSM252445     1  0.0000     0.9184 1.000 0.000 0.000
#> GSM252453     1  0.0000     0.9184 1.000 0.000 0.000
#> GSM252464     1  0.5905     0.4464 0.648 0.000 0.352
#> GSM252463     1  0.6302     0.0685 0.520 0.000 0.480
#> GSM252461     1  0.0892     0.9106 0.980 0.000 0.020
#> GSM252455     1  0.1529     0.8953 0.960 0.000 0.040
#> GSM252458     3  0.4555     0.7362 0.200 0.000 0.800
#> GSM252460     3  0.1163     0.9083 0.028 0.000 0.972
#> GSM252457     3  0.0892     0.9131 0.020 0.000 0.980
#> GSM252456     3  0.5058     0.6721 0.244 0.000 0.756
#> GSM252462     3  0.5529     0.5750 0.296 0.000 0.704
#> GSM252459     1  0.6215     0.2444 0.572 0.000 0.428
#> GSM252472     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252466     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252469     2  0.0237     0.9968 0.000 0.996 0.004
#> GSM252475     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252471     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252465     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252474     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252473     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252468     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252470     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252467     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252485     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252481     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252480     2  0.0237     0.9968 0.000 0.996 0.004
#> GSM252479     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252482     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252478     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252483     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252477     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252484     2  0.0000     0.9997 0.000 1.000 0.000
#> GSM252476     2  0.0000     0.9997 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM252423     3  0.0592     0.8294 0.000 0.000 0.984 0.016
#> GSM252429     3  0.0188     0.8311 0.000 0.000 0.996 0.004
#> GSM252424     3  0.0804     0.8293 0.008 0.000 0.980 0.012
#> GSM252432     3  0.0376     0.8316 0.004 0.000 0.992 0.004
#> GSM252427     3  0.0921     0.8282 0.000 0.000 0.972 0.028
#> GSM252431     3  0.3649     0.7148 0.000 0.000 0.796 0.204
#> GSM252430     3  0.4040     0.6789 0.000 0.000 0.752 0.248
#> GSM252433     3  0.3726     0.7100 0.000 0.000 0.788 0.212
#> GSM252426     3  0.1118     0.8257 0.000 0.000 0.964 0.036
#> GSM252428     3  0.1637     0.8215 0.000 0.000 0.940 0.060
#> GSM252425     3  0.7591     0.1473 0.000 0.352 0.444 0.204
#> GSM252440     1  0.1059     0.8118 0.972 0.000 0.016 0.012
#> GSM252441     1  0.0000     0.8161 1.000 0.000 0.000 0.000
#> GSM252436     1  0.1174     0.8090 0.968 0.000 0.020 0.012
#> GSM252435     1  0.0592     0.8089 0.984 0.000 0.000 0.016
#> GSM252442     1  0.0000     0.8161 1.000 0.000 0.000 0.000
#> GSM252439     1  0.2814     0.6694 0.868 0.000 0.000 0.132
#> GSM252438     4  0.5920     0.0000 0.368 0.016 0.020 0.596
#> GSM252434     1  0.0469     0.8160 0.988 0.000 0.000 0.012
#> GSM252437     1  0.0592     0.8089 0.984 0.000 0.000 0.016
#> GSM252451     1  0.0804     0.8146 0.980 0.000 0.012 0.008
#> GSM252448     1  0.1059     0.8118 0.972 0.000 0.016 0.012
#> GSM252447     1  0.0336     0.8138 0.992 0.000 0.000 0.008
#> GSM252444     1  0.1059     0.8118 0.972 0.000 0.016 0.012
#> GSM252450     1  0.0524     0.8158 0.988 0.000 0.004 0.008
#> GSM252452     1  0.4907    -0.3214 0.580 0.000 0.000 0.420
#> GSM252443     1  0.2654     0.7133 0.888 0.000 0.004 0.108
#> GSM252454     1  0.4560     0.1754 0.700 0.000 0.004 0.296
#> GSM252449     1  0.0000     0.8161 1.000 0.000 0.000 0.000
#> GSM252445     1  0.0336     0.8138 0.992 0.000 0.000 0.008
#> GSM252453     1  0.1557     0.7729 0.944 0.000 0.000 0.056
#> GSM252464     3  0.3978     0.6419 0.192 0.000 0.796 0.012
#> GSM252463     3  0.3047     0.7524 0.116 0.000 0.872 0.012
#> GSM252461     1  0.1767     0.7859 0.944 0.000 0.044 0.012
#> GSM252455     1  0.4485     0.3688 0.740 0.000 0.248 0.012
#> GSM252458     3  0.2741     0.7768 0.096 0.000 0.892 0.012
#> GSM252460     3  0.1388     0.8222 0.028 0.000 0.960 0.012
#> GSM252457     3  0.0804     0.8326 0.008 0.000 0.980 0.012
#> GSM252456     3  0.5075     0.2633 0.344 0.000 0.644 0.012
#> GSM252462     1  0.6855    -0.1178 0.580 0.000 0.276 0.144
#> GSM252459     1  0.6788    -0.0719 0.624 0.008 0.132 0.236
#> GSM252472     2  0.0921     0.9360 0.000 0.972 0.000 0.028
#> GSM252466     2  0.0707     0.9401 0.000 0.980 0.000 0.020
#> GSM252469     2  0.0469     0.9405 0.000 0.988 0.000 0.012
#> GSM252475     2  0.0592     0.9393 0.000 0.984 0.000 0.016
#> GSM252471     2  0.0707     0.9376 0.000 0.980 0.000 0.020
#> GSM252465     2  0.3074     0.8345 0.000 0.848 0.000 0.152
#> GSM252474     2  0.2760     0.8933 0.000 0.872 0.000 0.128
#> GSM252473     2  0.0469     0.9406 0.000 0.988 0.000 0.012
#> GSM252468     2  0.1637     0.9292 0.000 0.940 0.000 0.060
#> GSM252470     2  0.2011     0.9216 0.000 0.920 0.000 0.080
#> GSM252467     2  0.0000     0.9408 0.000 1.000 0.000 0.000
#> GSM252485     2  0.1022     0.9342 0.000 0.968 0.000 0.032
#> GSM252481     2  0.0336     0.9412 0.000 0.992 0.000 0.008
#> GSM252480     2  0.0469     0.9411 0.000 0.988 0.000 0.012
#> GSM252479     2  0.0469     0.9398 0.000 0.988 0.000 0.012
#> GSM252482     2  0.2647     0.8991 0.000 0.880 0.000 0.120
#> GSM252478     2  0.3486     0.7936 0.000 0.812 0.000 0.188
#> GSM252483     2  0.2760     0.8933 0.000 0.872 0.000 0.128
#> GSM252477     2  0.3688     0.8249 0.000 0.792 0.000 0.208
#> GSM252484     2  0.1940     0.9233 0.000 0.924 0.000 0.076
#> GSM252476     2  0.0336     0.9406 0.000 0.992 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM252423     3  0.0609    0.87635 0.000 0.000 0.980 0.020 0.000
#> GSM252429     3  0.0579    0.87896 0.000 0.000 0.984 0.008 0.008
#> GSM252424     3  0.0566    0.88246 0.012 0.000 0.984 0.004 0.000
#> GSM252432     3  0.0324    0.88061 0.000 0.000 0.992 0.004 0.004
#> GSM252427     3  0.1341    0.85948 0.000 0.000 0.944 0.056 0.000
#> GSM252431     4  0.3398    0.59904 0.000 0.000 0.216 0.780 0.004
#> GSM252430     5  0.4047    0.23592 0.000 0.000 0.320 0.004 0.676
#> GSM252433     4  0.4416    0.47160 0.000 0.000 0.356 0.632 0.012
#> GSM252426     3  0.1018    0.87478 0.000 0.000 0.968 0.016 0.016
#> GSM252428     3  0.3550    0.64042 0.000 0.000 0.760 0.004 0.236
#> GSM252425     4  0.3479    0.67044 0.000 0.056 0.064 0.856 0.024
#> GSM252440     1  0.0162    0.88860 0.996 0.000 0.004 0.000 0.000
#> GSM252441     1  0.0290    0.88632 0.992 0.000 0.000 0.008 0.000
#> GSM252436     1  0.0404    0.88571 0.988 0.000 0.012 0.000 0.000
#> GSM252435     1  0.0609    0.88270 0.980 0.000 0.000 0.020 0.000
#> GSM252442     1  0.0162    0.88766 0.996 0.000 0.000 0.004 0.000
#> GSM252439     5  0.4150    0.54012 0.388 0.000 0.000 0.000 0.612
#> GSM252438     4  0.3647    0.63358 0.132 0.000 0.000 0.816 0.052
#> GSM252434     1  0.0693    0.88400 0.980 0.000 0.008 0.000 0.012
#> GSM252437     1  0.0671    0.87985 0.980 0.000 0.000 0.016 0.004
#> GSM252451     1  0.0162    0.88860 0.996 0.000 0.004 0.000 0.000
#> GSM252448     1  0.0162    0.88860 0.996 0.000 0.004 0.000 0.000
#> GSM252447     1  0.0404    0.88561 0.988 0.000 0.000 0.012 0.000
#> GSM252444     1  0.0290    0.88769 0.992 0.000 0.008 0.000 0.000
#> GSM252450     1  0.0162    0.88863 0.996 0.000 0.000 0.004 0.000
#> GSM252452     1  0.2966    0.75125 0.848 0.000 0.000 0.016 0.136
#> GSM252443     5  0.3837    0.62443 0.308 0.000 0.000 0.000 0.692
#> GSM252454     4  0.4206    0.45128 0.288 0.000 0.000 0.696 0.016
#> GSM252449     1  0.0290    0.88748 0.992 0.000 0.008 0.000 0.000
#> GSM252445     1  0.0912    0.87557 0.972 0.000 0.000 0.012 0.016
#> GSM252453     1  0.4451    0.36837 0.644 0.000 0.000 0.340 0.016
#> GSM252464     3  0.2179    0.82381 0.112 0.000 0.888 0.000 0.000
#> GSM252463     3  0.1608    0.86453 0.072 0.000 0.928 0.000 0.000
#> GSM252461     1  0.1043    0.86257 0.960 0.000 0.040 0.000 0.000
#> GSM252455     1  0.4305   -0.00961 0.512 0.000 0.488 0.000 0.000
#> GSM252458     3  0.2020    0.84022 0.100 0.000 0.900 0.000 0.000
#> GSM252460     3  0.1544    0.86750 0.068 0.000 0.932 0.000 0.000
#> GSM252457     3  0.1471    0.88148 0.024 0.000 0.952 0.004 0.020
#> GSM252456     3  0.3612    0.54158 0.268 0.000 0.732 0.000 0.000
#> GSM252462     1  0.4407    0.61347 0.760 0.000 0.064 0.172 0.004
#> GSM252459     4  0.2957    0.65315 0.120 0.000 0.008 0.860 0.012
#> GSM252472     2  0.3146    0.80837 0.000 0.844 0.000 0.128 0.028
#> GSM252466     2  0.0290    0.87949 0.000 0.992 0.000 0.000 0.008
#> GSM252469     2  0.0693    0.87885 0.000 0.980 0.000 0.008 0.012
#> GSM252475     2  0.1364    0.87127 0.000 0.952 0.000 0.036 0.012
#> GSM252471     2  0.3163    0.78663 0.000 0.824 0.000 0.164 0.012
#> GSM252465     4  0.3790    0.55714 0.000 0.272 0.000 0.724 0.004
#> GSM252474     2  0.3837    0.63838 0.000 0.692 0.000 0.000 0.308
#> GSM252473     2  0.2536    0.82456 0.000 0.868 0.000 0.128 0.004
#> GSM252468     2  0.0404    0.87885 0.000 0.988 0.000 0.000 0.012
#> GSM252470     2  0.1121    0.87048 0.000 0.956 0.000 0.000 0.044
#> GSM252467     2  0.0992    0.87754 0.000 0.968 0.000 0.024 0.008
#> GSM252485     2  0.3521    0.78792 0.000 0.820 0.000 0.140 0.040
#> GSM252481     2  0.0162    0.87965 0.000 0.996 0.000 0.000 0.004
#> GSM252480     2  0.0162    0.87965 0.000 0.996 0.000 0.000 0.004
#> GSM252479     2  0.0324    0.87978 0.000 0.992 0.000 0.004 0.004
#> GSM252482     2  0.3455    0.75334 0.000 0.784 0.000 0.008 0.208
#> GSM252478     4  0.3487    0.60843 0.000 0.212 0.000 0.780 0.008
#> GSM252483     2  0.3837    0.64025 0.000 0.692 0.000 0.000 0.308
#> GSM252477     2  0.4599    0.50828 0.000 0.600 0.000 0.016 0.384
#> GSM252484     2  0.0703    0.87729 0.000 0.976 0.000 0.000 0.024
#> GSM252476     2  0.1357    0.86960 0.000 0.948 0.000 0.048 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3 p4    p5    p6
#> GSM252423     3  0.0632     0.7057 0.000 0.000 0.976 NA 0.000 0.024
#> GSM252429     3  0.0717     0.7073 0.000 0.000 0.976 NA 0.008 0.016
#> GSM252424     3  0.0146     0.7150 0.000 0.000 0.996 NA 0.000 0.000
#> GSM252432     3  0.0146     0.7145 0.000 0.000 0.996 NA 0.000 0.004
#> GSM252427     3  0.1531     0.6954 0.000 0.000 0.928 NA 0.000 0.068
#> GSM252431     6  0.4371     0.6558 0.000 0.000 0.104 NA 0.000 0.716
#> GSM252430     5  0.3693     0.2462 0.000 0.000 0.280 NA 0.708 0.004
#> GSM252433     6  0.5783     0.5926 0.000 0.000 0.220 NA 0.128 0.608
#> GSM252426     3  0.3342     0.6340 0.000 0.000 0.760 NA 0.012 0.000
#> GSM252428     3  0.5357     0.4837 0.000 0.000 0.536 NA 0.124 0.000
#> GSM252425     6  0.3229     0.6965 0.000 0.012 0.124 NA 0.008 0.836
#> GSM252440     1  0.1138     0.7863 0.960 0.000 0.000 NA 0.004 0.024
#> GSM252441     1  0.2164     0.7633 0.912 0.000 0.000 NA 0.016 0.044
#> GSM252436     1  0.1528     0.7962 0.936 0.000 0.016 NA 0.000 0.000
#> GSM252435     1  0.1616     0.7981 0.932 0.000 0.000 NA 0.000 0.020
#> GSM252442     1  0.3923     0.6383 0.620 0.000 0.008 NA 0.000 0.000
#> GSM252439     5  0.4443     0.2796 0.328 0.000 0.000 NA 0.636 0.024
#> GSM252438     6  0.5775     0.6567 0.120 0.000 0.020 NA 0.104 0.676
#> GSM252434     1  0.4312     0.6054 0.584 0.000 0.008 NA 0.012 0.000
#> GSM252437     1  0.2307     0.7604 0.904 0.000 0.000 NA 0.016 0.048
#> GSM252451     1  0.0405     0.7964 0.988 0.000 0.000 NA 0.000 0.004
#> GSM252448     1  0.0951     0.7891 0.968 0.000 0.000 NA 0.008 0.020
#> GSM252447     1  0.2231     0.7621 0.908 0.000 0.000 NA 0.016 0.048
#> GSM252444     1  0.0622     0.7984 0.980 0.000 0.008 NA 0.000 0.000
#> GSM252450     1  0.1444     0.7939 0.928 0.000 0.000 NA 0.000 0.000
#> GSM252452     1  0.4478     0.6903 0.660 0.000 0.000 NA 0.020 0.024
#> GSM252443     5  0.4393     0.3339 0.232 0.000 0.000 NA 0.708 0.016
#> GSM252454     6  0.5235     0.5743 0.232 0.000 0.000 NA 0.060 0.656
#> GSM252449     1  0.3684     0.6730 0.664 0.000 0.004 NA 0.000 0.000
#> GSM252445     1  0.4550     0.7018 0.716 0.000 0.000 NA 0.064 0.020
#> GSM252453     1  0.4913     0.3331 0.600 0.000 0.000 NA 0.020 0.340
#> GSM252464     3  0.4403     0.6736 0.196 0.000 0.708 NA 0.000 0.000
#> GSM252463     3  0.3732     0.7016 0.144 0.000 0.780 NA 0.000 0.000
#> GSM252461     1  0.2537     0.7725 0.872 0.000 0.032 NA 0.000 0.000
#> GSM252455     3  0.5182     0.3639 0.372 0.000 0.532 NA 0.000 0.000
#> GSM252458     3  0.4461     0.6743 0.192 0.000 0.704 NA 0.000 0.000
#> GSM252460     3  0.5471     0.5940 0.140 0.000 0.524 NA 0.000 0.000
#> GSM252457     3  0.2525     0.6679 0.012 0.000 0.876 NA 0.100 0.012
#> GSM252456     3  0.5783     0.5263 0.220 0.000 0.500 NA 0.000 0.000
#> GSM252462     1  0.6484     0.2860 0.444 0.000 0.164 NA 0.000 0.044
#> GSM252459     6  0.2991     0.7014 0.096 0.000 0.024 NA 0.012 0.860
#> GSM252472     2  0.2614     0.8119 0.000 0.884 0.000 NA 0.060 0.044
#> GSM252466     2  0.0603     0.8532 0.000 0.980 0.000 NA 0.016 0.000
#> GSM252469     2  0.0622     0.8562 0.000 0.980 0.000 NA 0.012 0.000
#> GSM252475     2  0.0964     0.8552 0.000 0.968 0.000 NA 0.016 0.004
#> GSM252471     2  0.2538     0.7847 0.000 0.860 0.000 NA 0.000 0.124
#> GSM252465     2  0.5822     0.0932 0.000 0.480 0.000 NA 0.020 0.388
#> GSM252474     5  0.4096     0.2802 0.000 0.484 0.000 NA 0.508 0.000
#> GSM252473     2  0.3352     0.7100 0.000 0.800 0.000 NA 0.012 0.172
#> GSM252468     2  0.0909     0.8526 0.000 0.968 0.000 NA 0.012 0.000
#> GSM252470     2  0.2794     0.7846 0.000 0.860 0.000 NA 0.060 0.000
#> GSM252467     2  0.0653     0.8552 0.000 0.980 0.000 NA 0.012 0.004
#> GSM252485     2  0.3057     0.7949 0.000 0.860 0.000 NA 0.068 0.048
#> GSM252481     2  0.0405     0.8555 0.000 0.988 0.000 NA 0.008 0.000
#> GSM252480     2  0.0520     0.8560 0.000 0.984 0.000 NA 0.008 0.000
#> GSM252479     2  0.0820     0.8560 0.000 0.972 0.000 NA 0.016 0.000
#> GSM252482     2  0.4176    -0.0560 0.000 0.580 0.000 NA 0.404 0.000
#> GSM252478     6  0.4892     0.4228 0.000 0.268 0.000 NA 0.012 0.648
#> GSM252483     5  0.3993     0.3020 0.000 0.476 0.000 NA 0.520 0.000
#> GSM252477     5  0.4702     0.4185 0.000 0.388 0.000 NA 0.572 0.024
#> GSM252484     2  0.1088     0.8494 0.000 0.960 0.000 NA 0.016 0.000
#> GSM252476     2  0.0984     0.8544 0.000 0.968 0.000 NA 0.012 0.012

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-NMF-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-NMF-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-NMF-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-NMF-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-NMF-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-NMF-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-NMF-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-NMF-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-NMF-membership-heatmap-5

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)

plot of chunk tab-ATC-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-NMF-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. 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")

plot of chunk tab-ATC-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-NMF-collect-classes

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 agent(p) individual(p) k
#> ATC:NMF 62 3.69e-10         0.970 2
#> ATC:NMF 58 2.27e-18         1.000 3
#> ATC:NMF 54 1.72e-17         0.999 4
#> ATC:NMF 57 1.44e-11         0.055 5
#> ATC:NMF 49 4.00e-12         0.175 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.

Session info

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