cola Report for GDS4167

Date: 2019-12-25 21:12:22 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 21167 rows and 52 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] 21167    52

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:kmeans 3 1.000 0.981 0.986 **
SD:skmeans 3 1.000 0.982 0.993 **
SD:pam 3 1.000 0.958 0.985 ** 2
SD:mclust 2 1.000 0.981 0.987 **
CV:kmeans 3 1.000 0.975 0.981 **
CV:skmeans 3 1.000 0.969 0.989 **
CV:mclust 2 1.000 0.976 0.986 **
CV:NMF 3 1.000 0.973 0.988 **
MAD:kmeans 3 1.000 0.969 0.978 **
MAD:skmeans 3 1.000 0.960 0.985 **
ATC:kmeans 3 1.000 0.998 0.995 **
ATC:skmeans 3 1.000 0.993 0.996 ** 2
CV:pam 3 0.999 0.962 0.985 ** 2
SD:NMF 3 0.998 0.948 0.978 **
MAD:mclust 3 0.979 0.962 0.977 ** 2
MAD:NMF 3 0.969 0.917 0.968 **
MAD:pam 3 0.967 0.927 0.973 **
ATC:NMF 3 0.922 0.925 0.968 * 2
ATC:pam 3 0.772 0.924 0.967
ATC:mclust 4 0.765 0.789 0.900
ATC:hclust 3 0.684 0.818 0.904
CV:hclust 3 0.662 0.830 0.897
MAD:hclust 3 0.385 0.617 0.801
SD:hclust 2 0.381 0.750 0.848

**: 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 0.422           0.782       0.858          0.452 0.527   0.527
#> CV:NMF      2 0.418           0.820       0.861          0.450 0.527   0.527
#> MAD:NMF     2 0.880           0.944       0.973          0.479 0.527   0.527
#> ATC:NMF     2 1.000           0.958       0.982          0.405 0.599   0.599
#> SD:skmeans  2 0.571           0.918       0.933          0.481 0.517   0.517
#> CV:skmeans  2 0.524           0.899       0.912          0.476 0.517   0.517
#> MAD:skmeans 2 0.847           0.945       0.976          0.486 0.517   0.517
#> ATC:skmeans 2 1.000           0.969       0.987          0.500 0.497   0.497
#> SD:mclust   2 1.000           0.981       0.987          0.328 0.683   0.683
#> CV:mclust   2 1.000           0.976       0.986          0.331 0.683   0.683
#> MAD:mclust  2 1.000           0.978       0.974          0.324 0.683   0.683
#> ATC:mclust  2 0.451           0.781       0.770          0.369 0.517   0.517
#> SD:kmeans   2 0.482           0.606       0.774          0.375 0.502   0.502
#> CV:kmeans   2 0.497           0.756       0.795          0.376 0.581   0.581
#> MAD:kmeans  2 0.491           0.786       0.850          0.414 0.538   0.538
#> ATC:kmeans  2 0.479           0.832       0.843          0.419 0.566   0.566
#> SD:pam      2 1.000           0.966       0.973          0.327 0.683   0.683
#> CV:pam      2 1.000           0.975       0.974          0.320 0.683   0.683
#> MAD:pam     2 0.473           0.747       0.840          0.372 0.599   0.599
#> ATC:pam     2 0.501           0.769       0.861          0.329 0.735   0.735
#> SD:hclust   2 0.381           0.750       0.848          0.397 0.527   0.527
#> CV:hclust   2 0.409           0.807       0.871          0.375 0.618   0.618
#> MAD:hclust  2 0.685           0.833       0.931          0.364 0.638   0.638
#> ATC:hclust  2 0.788           0.961       0.973          0.417 0.566   0.566
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.998           0.948       0.978          0.376 0.687   0.490
#> CV:NMF      3 1.000           0.973       0.988          0.367 0.702   0.509
#> MAD:NMF     3 0.969           0.917       0.968          0.342 0.775   0.593
#> ATC:NMF     3 0.922           0.925       0.968          0.658 0.660   0.463
#> SD:skmeans  3 1.000           0.982       0.993          0.344 0.773   0.586
#> CV:skmeans  3 1.000           0.969       0.989          0.355 0.773   0.586
#> MAD:skmeans 3 1.000           0.960       0.985          0.339 0.773   0.586
#> ATC:skmeans 3 1.000           0.993       0.996          0.357 0.738   0.515
#> SD:mclust   3 0.687           0.819       0.911          0.896 0.704   0.567
#> CV:mclust   3 0.628           0.842       0.908          0.855 0.716   0.584
#> MAD:mclust  3 0.979           0.962       0.977          0.903 0.704   0.567
#> ATC:mclust  3 0.509           0.822       0.850          0.704 0.756   0.556
#> SD:kmeans   3 1.000           0.981       0.986          0.620 0.849   0.710
#> CV:kmeans   3 1.000           0.975       0.981          0.618 0.793   0.647
#> MAD:kmeans  3 1.000           0.969       0.978          0.472 0.740   0.563
#> ATC:kmeans  3 1.000           0.998       0.995          0.569 0.775   0.601
#> SD:pam      3 1.000           0.958       0.985          0.786 0.729   0.603
#> CV:pam      3 0.999           0.962       0.985          0.783 0.743   0.624
#> MAD:pam     3 0.967           0.927       0.973          0.630 0.633   0.463
#> ATC:pam     3 0.772           0.924       0.967          0.756 0.667   0.551
#> SD:hclust   3 0.642           0.695       0.855          0.392 0.621   0.431
#> CV:hclust   3 0.662           0.830       0.897          0.448 0.781   0.646
#> MAD:hclust  3 0.385           0.617       0.801          0.530 0.743   0.603
#> ATC:hclust  3 0.684           0.818       0.904          0.572 0.759   0.573
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.730           0.769       0.885         0.1802 0.855   0.638
#> CV:NMF      4 0.707           0.703       0.854         0.1689 0.867   0.665
#> MAD:NMF     4 0.680           0.625       0.834         0.1157 0.825   0.570
#> ATC:NMF     4 0.619           0.606       0.789         0.0956 0.900   0.715
#> SD:skmeans  4 0.866           0.932       0.954         0.1661 0.851   0.600
#> CV:skmeans  4 0.847           0.907       0.931         0.1694 0.851   0.600
#> MAD:skmeans 4 0.844           0.852       0.908         0.1514 0.851   0.600
#> ATC:skmeans 4 0.898           0.901       0.926         0.0867 0.926   0.776
#> SD:mclust   4 0.703           0.562       0.820         0.1283 0.873   0.695
#> CV:mclust   4 0.699           0.548       0.805         0.1460 0.925   0.811
#> MAD:mclust  4 0.770           0.819       0.871         0.1028 0.988   0.969
#> ATC:mclust  4 0.765           0.789       0.900         0.1436 0.888   0.682
#> SD:kmeans   4 0.704           0.629       0.814         0.1622 0.931   0.824
#> CV:kmeans   4 0.677           0.706       0.824         0.1463 0.931   0.825
#> MAD:kmeans  4 0.681           0.616       0.814         0.1623 0.876   0.696
#> ATC:kmeans  4 0.694           0.741       0.776         0.1151 0.889   0.680
#> SD:pam      4 0.855           0.932       0.947         0.2300 0.853   0.652
#> CV:pam      4 0.832           0.895       0.944         0.2335 0.860   0.677
#> MAD:pam     4 0.816           0.878       0.934         0.2014 0.843   0.625
#> ATC:pam     4 0.734           0.855       0.928         0.2663 0.791   0.524
#> SD:hclust   4 0.514           0.586       0.773         0.1931 0.848   0.668
#> CV:hclust   4 0.530           0.787       0.828         0.1909 0.957   0.895
#> MAD:hclust  4 0.408           0.609       0.741         0.1979 0.928   0.830
#> ATC:hclust  4 0.713           0.682       0.827         0.0640 0.989   0.965
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.700           0.638       0.793         0.0693 0.922   0.729
#> CV:NMF      5 0.702           0.637       0.817         0.0822 0.845   0.524
#> MAD:NMF     5 0.654           0.671       0.795         0.0905 0.839   0.516
#> ATC:NMF     5 0.672           0.699       0.828         0.0743 0.881   0.595
#> SD:skmeans  5 0.804           0.698       0.839         0.0574 0.907   0.658
#> CV:skmeans  5 0.771           0.690       0.843         0.0574 0.913   0.674
#> MAD:skmeans 5 0.801           0.688       0.830         0.0582 0.857   0.526
#> ATC:skmeans 5 0.857           0.894       0.909         0.0712 0.942   0.781
#> SD:mclust   5 0.707           0.772       0.808         0.0624 0.910   0.715
#> CV:mclust   5 0.683           0.670       0.801         0.0472 0.851   0.607
#> MAD:mclust  5 0.736           0.771       0.802         0.0905 0.834   0.572
#> ATC:mclust  5 0.697           0.788       0.856         0.0478 0.920   0.709
#> SD:kmeans   5 0.657           0.589       0.722         0.0834 0.923   0.776
#> CV:kmeans   5 0.659           0.592       0.743         0.0882 0.923   0.777
#> MAD:kmeans  5 0.665           0.640       0.770         0.0882 0.910   0.720
#> ATC:kmeans  5 0.770           0.675       0.784         0.0658 0.804   0.413
#> SD:pam      5 0.823           0.902       0.929         0.0234 0.988   0.958
#> CV:pam      5 0.825           0.886       0.934         0.0233 0.988   0.959
#> MAD:pam     5 0.829           0.881       0.931         0.0240 0.986   0.948
#> ATC:pam     5 0.725           0.614       0.794         0.0791 0.864   0.551
#> SD:hclust   5 0.645           0.677       0.800         0.0745 0.950   0.868
#> CV:hclust   5 0.658           0.654       0.807         0.1100 0.969   0.918
#> MAD:hclust  5 0.577           0.615       0.756         0.1158 0.836   0.597
#> ATC:hclust  5 0.736           0.660       0.781         0.0917 0.891   0.671
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.716           0.631       0.786         0.0509 0.847   0.451
#> CV:NMF      6 0.740           0.657       0.799         0.0565 0.870   0.514
#> MAD:NMF     6 0.671           0.633       0.771         0.0556 0.916   0.654
#> ATC:NMF     6 0.629           0.511       0.711         0.0380 0.956   0.801
#> SD:skmeans  6 0.781           0.547       0.789         0.0331 0.965   0.844
#> CV:skmeans  6 0.759           0.539       0.765         0.0349 0.956   0.797
#> MAD:skmeans 6 0.772           0.549       0.783         0.0341 0.990   0.955
#> ATC:skmeans 6 0.846           0.798       0.853         0.0391 0.973   0.869
#> SD:mclust   6 0.715           0.707       0.818         0.0400 0.955   0.820
#> CV:mclust   6 0.730           0.633       0.787         0.0484 0.948   0.830
#> MAD:mclust  6 0.858           0.864       0.921         0.0715 0.952   0.800
#> ATC:mclust  6 0.749           0.710       0.813         0.0653 0.925   0.685
#> SD:kmeans   6 0.669           0.577       0.705         0.0493 0.848   0.513
#> CV:kmeans   6 0.674           0.544       0.702         0.0667 0.836   0.485
#> MAD:kmeans  6 0.694           0.578       0.737         0.0555 0.851   0.504
#> ATC:kmeans  6 0.764           0.789       0.839         0.0379 0.941   0.751
#> SD:pam      6 0.758           0.794       0.871         0.0325 0.981   0.932
#> CV:pam      6 0.850           0.830       0.917         0.0230 0.993   0.976
#> MAD:pam     6 0.719           0.629       0.830         0.0523 0.946   0.803
#> ATC:pam     6 0.782           0.781       0.888         0.0447 0.834   0.396
#> SD:hclust   6 0.651           0.642       0.749         0.0507 0.905   0.744
#> CV:hclust   6 0.643           0.445       0.776         0.0479 0.947   0.852
#> MAD:hclust  6 0.642           0.567       0.755         0.0481 0.876   0.564
#> ATC:hclust  6 0.773           0.710       0.855         0.0338 0.958   0.826

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 disease.state(p) k
#> SD:NMF      49         1.10e-01 2
#> CV:NMF      50         1.22e-01 2
#> MAD:NMF     52         2.84e-01 2
#> ATC:NMF     52         7.24e-01 2
#> SD:skmeans  52         6.10e-01 2
#> CV:skmeans  52         6.10e-01 2
#> MAD:skmeans 52         6.10e-01 2
#> ATC:skmeans 51         3.92e-01 2
#> SD:mclust   52         1.99e-10 2
#> CV:mclust   52         1.99e-10 2
#> MAD:mclust  52         1.99e-10 2
#> ATC:mclust  45         1.00e+00 2
#> SD:kmeans   28               NA 2
#> CV:kmeans   42         7.20e-01 2
#> MAD:kmeans  49         5.19e-01 2
#> ATC:kmeans  52         5.15e-01 2
#> SD:pam      52         1.99e-10 2
#> CV:pam      52         1.99e-10 2
#> MAD:pam     48         1.09e-09 2
#> ATC:pam     50         1.00e+00 2
#> SD:hclust   47         1.81e-01 2
#> CV:hclust   50         2.90e-01 2
#> MAD:hclust  48         5.03e-01 2
#> ATC:hclust  52         5.15e-01 2
test_to_known_factors(res_list, k = 3)
#>              n disease.state(p) k
#> SD:NMF      51         1.31e-10 3
#> CV:NMF      52         8.27e-11 3
#> MAD:NMF     49         4.55e-09 3
#> ATC:NMF     51         3.28e-02 3
#> SD:skmeans  52         1.31e-09 3
#> CV:skmeans  51         1.98e-09 3
#> MAD:skmeans 51         2.00e-09 3
#> ATC:skmeans 52         4.76e-02 3
#> SD:mclust   49         3.24e-10 3
#> CV:mclust   49         3.24e-10 3
#> MAD:mclust  52         8.27e-11 3
#> ATC:mclust  51         2.34e-02 3
#> SD:kmeans   52         8.27e-11 3
#> CV:kmeans   52         8.27e-11 3
#> MAD:kmeans  52         9.23e-10 3
#> ATC:kmeans  52         3.39e-01 3
#> SD:pam      51         1.24e-10 3
#> CV:pam      52         7.80e-11 3
#> MAD:pam     50         2.49e-10 3
#> ATC:pam     51         8.17e-01 3
#> SD:hclust   41         2.26e-08 3
#> CV:hclust   50         2.05e-10 3
#> MAD:hclust  38         8.40e-08 3
#> ATC:hclust  50         1.16e-02 3
test_to_known_factors(res_list, k = 4)
#>              n disease.state(p) k
#> SD:NMF      44         3.12e-08 4
#> CV:NMF      45         1.58e-08 4
#> MAD:NMF     36         7.39e-07 4
#> ATC:NMF     41         8.42e-04 4
#> SD:skmeans  52         6.69e-09 4
#> CV:skmeans  51         1.01e-08 4
#> MAD:skmeans 50         2.17e-08 4
#> ATC:skmeans 52         3.19e-02 4
#> SD:mclust   27         9.27e-06 4
#> CV:mclust   38         5.20e-08 4
#> MAD:mclust  50         1.37e-09 4
#> ATC:mclust  47         7.96e-05 4
#> SD:kmeans   36         1.30e-07 4
#> CV:kmeans   45         1.93e-09 4
#> MAD:kmeans  39         3.60e-08 4
#> ATC:kmeans  49         2.18e-02 4
#> SD:pam      51         6.63e-10 4
#> CV:pam      51         6.63e-10 4
#> MAD:pam     50         1.26e-09 4
#> ATC:pam     51         1.49e-02 4
#> SD:hclust   46         6.53e-09 4
#> CV:hclust   50         1.11e-09 4
#> MAD:hclust  40         9.62e-08 4
#> ATC:hclust  49         1.36e-02 4
test_to_known_factors(res_list, k = 5)
#>              n disease.state(p) k
#> SD:NMF      44         7.87e-08 5
#> CV:NMF      41         1.10e-07 5
#> MAD:NMF     46         2.74e-07 5
#> ATC:NMF     47         5.90e-05 5
#> SD:skmeans  40         3.95e-07 5
#> CV:skmeans  42         1.66e-07 5
#> MAD:skmeans 38         2.79e-06 5
#> ATC:skmeans 52         4.66e-02 5
#> SD:mclust   50         4.77e-09 5
#> CV:mclust   45         1.55e-08 5
#> MAD:mclust  48         1.40e-08 5
#> ATC:mclust  48         2.46e-05 5
#> SD:kmeans   34         3.24e-07 5
#> CV:kmeans   40         1.97e-08 5
#> MAD:kmeans  39         5.73e-07 5
#> ATC:kmeans  39         3.49e-03 5
#> SD:pam      51         2.87e-09 5
#> CV:pam      51         2.87e-09 5
#> MAD:pam     51         2.87e-09 5
#> ATC:pam     34         9.04e-04 5
#> SD:hclust   43         2.96e-08 5
#> CV:hclust   38         8.67e-07 5
#> MAD:hclust  35         3.15e-06 5
#> ATC:hclust  48         1.63e-02 5
test_to_known_factors(res_list, k = 6)
#>              n disease.state(p) k
#> SD:NMF      41         9.38e-08 6
#> CV:NMF      42         5.89e-08 6
#> MAD:NMF     38         9.49e-07 6
#> ATC:NMF     32         1.64e-04 6
#> SD:skmeans  32         3.80e-06 6
#> CV:skmeans  33         8.40e-06 6
#> MAD:skmeans 31         1.82e-04 6
#> ATC:skmeans 49         6.23e-02 6
#> SD:mclust   45         1.75e-07 6
#> CV:mclust   38         3.39e-07 6
#> MAD:mclust  51         1.14e-08 6
#> ATC:mclust  45         2.69e-07 6
#> SD:kmeans   36         6.48e-06 6
#> CV:kmeans   34         1.26e-05 6
#> MAD:kmeans  29         4.63e-05 6
#> ATC:kmeans  49         1.47e-02 6
#> SD:pam      46         2.54e-08 6
#> CV:pam      49         6.75e-09 6
#> MAD:pam     38         8.67e-07 6
#> ATC:pam     49         4.81e-04 6
#> SD:hclust   44         2.32e-08 6
#> CV:hclust   25         8.49e-05 6
#> MAD:hclust  32         3.76e-05 6
#> ATC:hclust  47         4.08e-02 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 21167 rows and 52 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 0.381           0.750       0.848         0.3974 0.527   0.527
#> 3 3 0.642           0.695       0.855         0.3922 0.621   0.431
#> 4 4 0.514           0.586       0.773         0.1931 0.848   0.668
#> 5 5 0.645           0.677       0.800         0.0745 0.950   0.868
#> 6 6 0.651           0.642       0.749         0.0507 0.905   0.744

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
#> GSM559383     1   0.000     0.7741 1.000 0.000
#> GSM559387     1   0.000     0.7741 1.000 0.000
#> GSM559391     1   0.000     0.7741 1.000 0.000
#> GSM559395     1   0.000     0.7741 1.000 0.000
#> GSM559397     1   0.000     0.7741 1.000 0.000
#> GSM559401     1   0.000     0.7741 1.000 0.000
#> GSM559414     1   0.000     0.7741 1.000 0.000
#> GSM559422     1   0.118     0.7646 0.984 0.016
#> GSM559424     1   0.000     0.7741 1.000 0.000
#> GSM559431     2   0.000     0.7794 0.000 1.000
#> GSM559432     1   0.118     0.7646 0.984 0.016
#> GSM559381     1   0.850     0.7711 0.724 0.276
#> GSM559382     2   0.891     0.5178 0.308 0.692
#> GSM559384     1   0.714     0.8893 0.804 0.196
#> GSM559385     1   0.714     0.8893 0.804 0.196
#> GSM559386     2   0.932     0.4443 0.348 0.652
#> GSM559388     2   0.861     0.5551 0.284 0.716
#> GSM559389     1   0.788     0.8385 0.764 0.236
#> GSM559390     1   0.767     0.8569 0.776 0.224
#> GSM559392     2   0.000     0.7794 0.000 1.000
#> GSM559393     1   0.714     0.8893 0.804 0.196
#> GSM559394     1   0.714     0.8893 0.804 0.196
#> GSM559396     1   0.714     0.8893 0.804 0.196
#> GSM559398     2   0.000     0.7794 0.000 1.000
#> GSM559399     1   0.714     0.8893 0.804 0.196
#> GSM559400     2   0.662     0.6778 0.172 0.828
#> GSM559402     1   0.714     0.8893 0.804 0.196
#> GSM559403     1   0.714     0.8893 0.804 0.196
#> GSM559404     1   0.714     0.8893 0.804 0.196
#> GSM559405     1   0.730     0.8806 0.796 0.204
#> GSM559406     1   0.714     0.8893 0.804 0.196
#> GSM559407     1   0.714     0.8893 0.804 0.196
#> GSM559408     1   0.714     0.8893 0.804 0.196
#> GSM559409     1   0.714     0.8893 0.804 0.196
#> GSM559410     1   0.714     0.8893 0.804 0.196
#> GSM559411     1   0.714     0.8893 0.804 0.196
#> GSM559412     1   0.714     0.8893 0.804 0.196
#> GSM559413     1   0.714     0.8893 0.804 0.196
#> GSM559415     2   1.000    -0.0703 0.500 0.500
#> GSM559416     2   0.988     0.2114 0.436 0.564
#> GSM559417     2   0.988     0.2114 0.436 0.564
#> GSM559418     2   1.000    -0.0703 0.500 0.500
#> GSM559419     1   0.714     0.8893 0.804 0.196
#> GSM559420     1   0.714     0.8893 0.804 0.196
#> GSM559421     2   0.000     0.7794 0.000 1.000
#> GSM559423     2   0.000     0.7794 0.000 1.000
#> GSM559425     2   0.000     0.7794 0.000 1.000
#> GSM559426     2   0.118     0.7775 0.016 0.984
#> GSM559427     2   0.000     0.7794 0.000 1.000
#> GSM559428     2   0.118     0.7775 0.016 0.984
#> GSM559429     2   0.118     0.7775 0.016 0.984
#> GSM559430     2   0.000     0.7794 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
#> GSM559383     3   0.000     0.7043 0.000 0.000 1.000
#> GSM559387     3   0.000     0.7043 0.000 0.000 1.000
#> GSM559391     3   0.000     0.7043 0.000 0.000 1.000
#> GSM559395     3   0.000     0.7043 0.000 0.000 1.000
#> GSM559397     3   0.000     0.7043 0.000 0.000 1.000
#> GSM559401     3   0.650     0.4915 0.004 0.460 0.536
#> GSM559414     3   0.000     0.7043 0.000 0.000 1.000
#> GSM559422     3   0.652     0.4736 0.004 0.480 0.516
#> GSM559424     3   0.000     0.7043 0.000 0.000 1.000
#> GSM559431     2   0.630     0.9917 0.480 0.520 0.000
#> GSM559432     3   0.652     0.4736 0.004 0.480 0.516
#> GSM559381     1   0.740     0.6944 0.552 0.036 0.412
#> GSM559382     1   0.968    -0.0715 0.448 0.320 0.232
#> GSM559384     1   0.630     0.7744 0.516 0.000 0.484
#> GSM559385     1   0.630     0.7749 0.520 0.000 0.480
#> GSM559386     1   0.978     0.1042 0.436 0.304 0.260
#> GSM559388     1   0.950    -0.1486 0.476 0.316 0.208
#> GSM559389     1   0.748     0.7296 0.512 0.036 0.452
#> GSM559390     1   0.628     0.7541 0.540 0.000 0.460
#> GSM559392     2   0.630     0.9917 0.480 0.520 0.000
#> GSM559393     1   0.652     0.7736 0.516 0.004 0.480
#> GSM559394     1   0.630     0.7749 0.520 0.000 0.480
#> GSM559396     1   0.630     0.7744 0.516 0.000 0.484
#> GSM559398     2   0.630     0.9917 0.480 0.520 0.000
#> GSM559399     1   0.630     0.7749 0.520 0.000 0.480
#> GSM559400     1   0.618    -0.4865 0.732 0.236 0.032
#> GSM559402     1   0.630     0.7744 0.516 0.000 0.484
#> GSM559403     1   0.630     0.7749 0.520 0.000 0.480
#> GSM559404     1   0.630     0.7744 0.516 0.000 0.484
#> GSM559405     1   0.630     0.7716 0.528 0.000 0.472
#> GSM559406     1   0.631     0.7679 0.508 0.000 0.492
#> GSM559407     1   0.630     0.7744 0.516 0.000 0.484
#> GSM559408     1   0.630     0.7744 0.516 0.000 0.484
#> GSM559409     1   0.630     0.7744 0.516 0.000 0.484
#> GSM559410     1   0.630     0.7749 0.520 0.000 0.480
#> GSM559411     1   0.630     0.7744 0.516 0.000 0.484
#> GSM559412     1   0.630     0.7744 0.516 0.000 0.484
#> GSM559413     1   0.630     0.7744 0.516 0.000 0.484
#> GSM559415     1   0.781     0.4986 0.640 0.092 0.268
#> GSM559416     1   0.872     0.4239 0.576 0.152 0.272
#> GSM559417     1   0.872     0.4239 0.576 0.152 0.272
#> GSM559418     1   0.781     0.4986 0.640 0.092 0.268
#> GSM559419     1   0.630     0.7749 0.520 0.000 0.480
#> GSM559420     1   0.630     0.7749 0.520 0.000 0.480
#> GSM559421     2   0.630     0.9917 0.480 0.520 0.000
#> GSM559423     2   0.630     0.9917 0.480 0.520 0.000
#> GSM559425     2   0.630     0.9917 0.480 0.520 0.000
#> GSM559426     2   0.682     0.9798 0.472 0.516 0.012
#> GSM559427     2   0.630     0.9917 0.480 0.520 0.000
#> GSM559428     2   0.682     0.9668 0.484 0.504 0.012
#> GSM559429     2   0.682     0.9798 0.472 0.516 0.012
#> GSM559430     2   0.630     0.9917 0.480 0.520 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM559383     3  0.4164      0.809 0.264 0.000 0.736 0.000
#> GSM559387     3  0.4164      0.809 0.264 0.000 0.736 0.000
#> GSM559391     3  0.4164      0.809 0.264 0.000 0.736 0.000
#> GSM559395     3  0.4164      0.809 0.264 0.000 0.736 0.000
#> GSM559397     3  0.4164      0.809 0.264 0.000 0.736 0.000
#> GSM559401     3  0.4086      0.563 0.008 0.000 0.776 0.216
#> GSM559414     3  0.4164      0.809 0.264 0.000 0.736 0.000
#> GSM559422     3  0.3975      0.546 0.000 0.000 0.760 0.240
#> GSM559424     3  0.4164      0.809 0.264 0.000 0.736 0.000
#> GSM559431     2  0.3311      0.620 0.000 0.828 0.000 0.172
#> GSM559432     3  0.3975      0.546 0.000 0.000 0.760 0.240
#> GSM559381     1  0.4361      0.548 0.772 0.020 0.000 0.208
#> GSM559382     2  0.7863     -0.482 0.276 0.380 0.000 0.344
#> GSM559384     1  0.1297      0.768 0.964 0.000 0.016 0.020
#> GSM559385     1  0.3166      0.743 0.868 0.000 0.016 0.116
#> GSM559386     2  0.7924     -0.591 0.328 0.340 0.000 0.332
#> GSM559388     2  0.7812     -0.421 0.264 0.408 0.000 0.328
#> GSM559389     1  0.3900      0.647 0.816 0.020 0.000 0.164
#> GSM559390     1  0.3726      0.572 0.788 0.000 0.000 0.212
#> GSM559392     2  0.2408      0.689 0.000 0.896 0.000 0.104
#> GSM559393     1  0.3408      0.738 0.860 0.004 0.016 0.120
#> GSM559394     1  0.3166      0.743 0.868 0.000 0.016 0.116
#> GSM559396     1  0.1297      0.768 0.964 0.000 0.016 0.020
#> GSM559398     2  0.2408      0.689 0.000 0.896 0.000 0.104
#> GSM559399     1  0.2216      0.754 0.908 0.000 0.000 0.092
#> GSM559400     2  0.6200      0.173 0.052 0.504 0.000 0.444
#> GSM559402     1  0.0657      0.770 0.984 0.000 0.012 0.004
#> GSM559403     1  0.2281      0.753 0.904 0.000 0.000 0.096
#> GSM559404     1  0.5179      0.514 0.728 0.000 0.220 0.052
#> GSM559405     1  0.2281      0.751 0.904 0.000 0.000 0.096
#> GSM559406     1  0.4163      0.619 0.792 0.000 0.020 0.188
#> GSM559407     1  0.0657      0.770 0.984 0.000 0.012 0.004
#> GSM559408     1  0.1042      0.767 0.972 0.000 0.020 0.008
#> GSM559409     1  0.1042      0.767 0.972 0.000 0.020 0.008
#> GSM559410     1  0.2546      0.757 0.900 0.000 0.008 0.092
#> GSM559411     1  0.1059      0.767 0.972 0.000 0.012 0.016
#> GSM559412     1  0.4562      0.545 0.764 0.000 0.208 0.028
#> GSM559413     1  0.4562      0.545 0.764 0.000 0.208 0.028
#> GSM559415     1  0.6987     -0.447 0.568 0.160 0.000 0.272
#> GSM559416     4  0.7344      0.958 0.380 0.160 0.000 0.460
#> GSM559417     4  0.7301      0.959 0.356 0.160 0.000 0.484
#> GSM559418     1  0.6987     -0.447 0.568 0.160 0.000 0.272
#> GSM559419     1  0.0469      0.771 0.988 0.000 0.000 0.012
#> GSM559420     1  0.0469      0.771 0.988 0.000 0.000 0.012
#> GSM559421     2  0.2216      0.691 0.000 0.908 0.000 0.092
#> GSM559423     2  0.2281      0.691 0.000 0.904 0.000 0.096
#> GSM559425     2  0.3311      0.620 0.000 0.828 0.000 0.172
#> GSM559426     2  0.2473      0.670 0.012 0.908 0.000 0.080
#> GSM559427     2  0.3311      0.620 0.000 0.828 0.000 0.172
#> GSM559428     2  0.2796      0.663 0.016 0.892 0.000 0.092
#> GSM559429     2  0.2542      0.669 0.012 0.904 0.000 0.084
#> GSM559430     2  0.2149      0.692 0.000 0.912 0.000 0.088

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4 p5
#> GSM559383     3  0.0000     0.9174 0.000 0.000 1.000 0.000 NA
#> GSM559387     3  0.0000     0.9174 0.000 0.000 1.000 0.000 NA
#> GSM559391     3  0.0000     0.9174 0.000 0.000 1.000 0.000 NA
#> GSM559395     3  0.0000     0.9174 0.000 0.000 1.000 0.000 NA
#> GSM559397     3  0.0000     0.9174 0.000 0.000 1.000 0.000 NA
#> GSM559401     3  0.4307    -0.1779 0.000 0.000 0.500 0.500 NA
#> GSM559414     3  0.0000     0.9174 0.000 0.000 1.000 0.000 NA
#> GSM559422     4  0.1851     1.0000 0.000 0.000 0.088 0.912 NA
#> GSM559424     3  0.0000     0.9174 0.000 0.000 1.000 0.000 NA
#> GSM559431     2  0.3942     0.5637 0.000 0.728 0.000 0.012 NA
#> GSM559432     4  0.1851     1.0000 0.000 0.000 0.088 0.912 NA
#> GSM559381     1  0.3085     0.7344 0.852 0.032 0.000 0.000 NA
#> GSM559382     2  0.6613     0.2946 0.352 0.468 0.000 0.008 NA
#> GSM559384     1  0.3194     0.7958 0.832 0.000 0.020 0.000 NA
#> GSM559385     1  0.1502     0.7966 0.940 0.000 0.000 0.004 NA
#> GSM559386     2  0.6594     0.1771 0.404 0.428 0.000 0.008 NA
#> GSM559388     2  0.6481     0.3382 0.340 0.496 0.000 0.008 NA
#> GSM559389     1  0.2473     0.7645 0.896 0.032 0.000 0.000 NA
#> GSM559390     1  0.3805     0.7498 0.784 0.000 0.000 0.032 NA
#> GSM559392     2  0.0404     0.6979 0.000 0.988 0.000 0.000 NA
#> GSM559393     1  0.1731     0.7949 0.932 0.004 0.000 0.004 NA
#> GSM559394     1  0.1502     0.7966 0.940 0.000 0.000 0.004 NA
#> GSM559396     1  0.3351     0.7948 0.828 0.000 0.020 0.004 NA
#> GSM559398     2  0.0404     0.6979 0.000 0.988 0.000 0.000 NA
#> GSM559399     1  0.0451     0.8015 0.988 0.000 0.000 0.004 NA
#> GSM559400     2  0.6420     0.4171 0.100 0.596 0.000 0.048 NA
#> GSM559402     1  0.2471     0.7980 0.864 0.000 0.000 0.000 NA
#> GSM559403     1  0.0727     0.8016 0.980 0.000 0.004 0.004 NA
#> GSM559404     1  0.5755     0.5550 0.604 0.000 0.060 0.024 NA
#> GSM559405     1  0.0566     0.8014 0.984 0.000 0.000 0.004 NA
#> GSM559406     1  0.3925     0.7557 0.784 0.000 0.004 0.032 NA
#> GSM559407     1  0.2471     0.7980 0.864 0.000 0.000 0.000 NA
#> GSM559408     1  0.2763     0.7949 0.848 0.000 0.004 0.000 NA
#> GSM559409     1  0.2763     0.7949 0.848 0.000 0.004 0.000 NA
#> GSM559410     1  0.0671     0.8028 0.980 0.000 0.000 0.004 NA
#> GSM559411     1  0.2719     0.7966 0.852 0.000 0.004 0.000 NA
#> GSM559412     1  0.5049     0.6225 0.644 0.000 0.060 0.000 NA
#> GSM559413     1  0.5049     0.6225 0.644 0.000 0.060 0.000 NA
#> GSM559415     1  0.5691     0.4065 0.632 0.236 0.000 0.004 NA
#> GSM559416     1  0.7343     0.1016 0.408 0.236 0.000 0.032 NA
#> GSM559417     1  0.7362     0.0554 0.392 0.236 0.000 0.032 NA
#> GSM559418     1  0.5691     0.4065 0.632 0.236 0.000 0.004 NA
#> GSM559419     1  0.2329     0.8020 0.876 0.000 0.000 0.000 NA
#> GSM559420     1  0.2329     0.8020 0.876 0.000 0.000 0.000 NA
#> GSM559421     2  0.0000     0.6991 0.000 1.000 0.000 0.000 NA
#> GSM559423     2  0.0162     0.6995 0.000 0.996 0.000 0.000 NA
#> GSM559425     2  0.3942     0.5637 0.000 0.728 0.000 0.012 NA
#> GSM559426     2  0.3783     0.6641 0.012 0.768 0.000 0.004 NA
#> GSM559427     2  0.3942     0.5637 0.000 0.728 0.000 0.012 NA
#> GSM559428     2  0.4054     0.6565 0.012 0.744 0.000 0.008 NA
#> GSM559429     2  0.3875     0.6596 0.012 0.756 0.000 0.004 NA
#> GSM559430     2  0.0404     0.6986 0.000 0.988 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
#> GSM559383     3  0.0000    0.92470 0.000 0.000 1.00 0.000 0.0 0.000
#> GSM559387     3  0.0000    0.92470 0.000 0.000 1.00 0.000 0.0 0.000
#> GSM559391     3  0.0000    0.92470 0.000 0.000 1.00 0.000 0.0 0.000
#> GSM559395     3  0.0000    0.92470 0.000 0.000 1.00 0.000 0.0 0.000
#> GSM559397     3  0.0000    0.92470 0.000 0.000 1.00 0.000 0.0 0.000
#> GSM559401     3  0.3869   -0.00016 0.000 0.000 0.50 0.000 0.5 0.000
#> GSM559414     3  0.0000    0.92470 0.000 0.000 1.00 0.000 0.0 0.000
#> GSM559422     5  0.0000    1.00000 0.000 0.000 0.00 0.000 1.0 0.000
#> GSM559424     3  0.0000    0.92470 0.000 0.000 1.00 0.000 0.0 0.000
#> GSM559431     2  0.0790    0.49872 0.000 0.968 0.00 0.000 0.0 0.032
#> GSM559432     5  0.0000    1.00000 0.000 0.000 0.00 0.000 1.0 0.000
#> GSM559381     1  0.4580    0.57283 0.708 0.004 0.00 0.120 0.0 0.168
#> GSM559382     4  0.7415    0.59937 0.204 0.208 0.00 0.404 0.0 0.184
#> GSM559384     1  0.2332    0.70666 0.904 0.000 0.02 0.036 0.0 0.040
#> GSM559385     1  0.3834    0.64219 0.708 0.000 0.00 0.024 0.0 0.268
#> GSM559386     4  0.7414    0.60832 0.252 0.168 0.00 0.392 0.0 0.188
#> GSM559388     4  0.7443    0.56865 0.188 0.236 0.00 0.392 0.0 0.184
#> GSM559389     1  0.4102    0.62655 0.752 0.004 0.00 0.080 0.0 0.164
#> GSM559390     1  0.3404    0.58588 0.760 0.000 0.00 0.224 0.0 0.016
#> GSM559392     2  0.3288    0.73816 0.000 0.724 0.00 0.276 0.0 0.000
#> GSM559393     1  0.4045    0.63614 0.700 0.004 0.00 0.028 0.0 0.268
#> GSM559394     1  0.3834    0.64219 0.708 0.000 0.00 0.024 0.0 0.268
#> GSM559396     1  0.2401    0.70535 0.900 0.000 0.02 0.036 0.0 0.044
#> GSM559398     2  0.3288    0.73816 0.000 0.724 0.00 0.276 0.0 0.000
#> GSM559399     1  0.3240    0.66202 0.752 0.000 0.00 0.004 0.0 0.244
#> GSM559400     4  0.4289   -0.17813 0.020 0.332 0.00 0.640 0.0 0.008
#> GSM559402     1  0.0508    0.71641 0.984 0.000 0.00 0.012 0.0 0.004
#> GSM559403     1  0.3373    0.66112 0.744 0.000 0.00 0.008 0.0 0.248
#> GSM559404     1  0.5208    0.39745 0.604 0.000 0.00 0.248 0.0 0.148
#> GSM559405     1  0.2968    0.68499 0.816 0.000 0.00 0.016 0.0 0.168
#> GSM559406     1  0.3431    0.60388 0.756 0.000 0.00 0.228 0.0 0.016
#> GSM559407     1  0.0508    0.71641 0.984 0.000 0.00 0.012 0.0 0.004
#> GSM559408     1  0.0935    0.71279 0.964 0.000 0.00 0.032 0.0 0.004
#> GSM559409     1  0.0935    0.71279 0.964 0.000 0.00 0.032 0.0 0.004
#> GSM559410     1  0.3445    0.66410 0.744 0.000 0.00 0.012 0.0 0.244
#> GSM559411     1  0.1713    0.70035 0.928 0.000 0.00 0.028 0.0 0.044
#> GSM559412     1  0.4025    0.52077 0.720 0.000 0.00 0.232 0.0 0.048
#> GSM559413     1  0.4025    0.52077 0.720 0.000 0.00 0.232 0.0 0.048
#> GSM559415     1  0.6051   -0.27548 0.396 0.000 0.00 0.344 0.0 0.260
#> GSM559416     4  0.3578    0.51342 0.340 0.000 0.00 0.660 0.0 0.000
#> GSM559417     4  0.3482    0.53826 0.316 0.000 0.00 0.684 0.0 0.000
#> GSM559418     1  0.6051   -0.27548 0.396 0.000 0.00 0.344 0.0 0.260
#> GSM559419     1  0.0260    0.71888 0.992 0.000 0.00 0.000 0.0 0.008
#> GSM559420     1  0.0260    0.71888 0.992 0.000 0.00 0.000 0.0 0.008
#> GSM559421     2  0.3221    0.74239 0.000 0.736 0.00 0.264 0.0 0.000
#> GSM559423     2  0.3360    0.74015 0.000 0.732 0.00 0.264 0.0 0.004
#> GSM559425     2  0.0790    0.49872 0.000 0.968 0.00 0.000 0.0 0.032
#> GSM559426     6  0.4238    0.90251 0.000 0.444 0.00 0.016 0.0 0.540
#> GSM559427     2  0.0790    0.49872 0.000 0.968 0.00 0.000 0.0 0.032
#> GSM559428     6  0.4228    0.94043 0.000 0.392 0.00 0.020 0.0 0.588
#> GSM559429     6  0.4168    0.94678 0.000 0.400 0.00 0.016 0.0 0.584
#> GSM559430     2  0.3151    0.73925 0.000 0.748 0.00 0.252 0.0 0.000

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

consensus_heatmap(res, k = 2)

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 disease.state(p) k
#> SD:hclust 47         1.81e-01 2
#> SD:hclust 41         2.26e-08 3
#> SD:hclust 46         6.53e-09 4
#> SD:hclust 43         2.96e-08 5
#> SD:hclust 44         2.32e-08 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 21167 rows and 52 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.482           0.606       0.774         0.3753 0.502   0.502
#> 3 3 1.000           0.981       0.986         0.6200 0.849   0.710
#> 4 4 0.704           0.629       0.814         0.1622 0.931   0.824
#> 5 5 0.657           0.589       0.722         0.0834 0.923   0.776
#> 6 6 0.669           0.577       0.705         0.0493 0.848   0.513

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
#> GSM559383     2  0.9983      0.242 0.476 0.524
#> GSM559387     2  0.9983      0.242 0.476 0.524
#> GSM559391     2  0.9983      0.242 0.476 0.524
#> GSM559395     2  0.9983      0.242 0.476 0.524
#> GSM559397     2  0.9983      0.242 0.476 0.524
#> GSM559401     2  0.9983      0.242 0.476 0.524
#> GSM559414     2  0.9983      0.242 0.476 0.524
#> GSM559422     2  0.9983      0.242 0.476 0.524
#> GSM559424     2  0.9983      0.242 0.476 0.524
#> GSM559431     2  0.9996      0.347 0.488 0.512
#> GSM559432     2  0.0000      0.331 0.000 1.000
#> GSM559381     1  0.0000      0.923 1.000 0.000
#> GSM559382     2  0.9996      0.347 0.488 0.512
#> GSM559384     1  0.0000      0.923 1.000 0.000
#> GSM559385     1  0.0000      0.923 1.000 0.000
#> GSM559386     1  0.4939      0.731 0.892 0.108
#> GSM559388     1  0.9996     -0.349 0.512 0.488
#> GSM559389     1  0.0000      0.923 1.000 0.000
#> GSM559390     1  0.0000      0.923 1.000 0.000
#> GSM559392     2  0.9998      0.339 0.492 0.508
#> GSM559393     1  0.1633      0.889 0.976 0.024
#> GSM559394     1  0.0000      0.923 1.000 0.000
#> GSM559396     1  0.0000      0.923 1.000 0.000
#> GSM559398     2  0.9996      0.347 0.488 0.512
#> GSM559399     1  0.0000      0.923 1.000 0.000
#> GSM559400     1  0.9970     -0.312 0.532 0.468
#> GSM559402     1  0.0000      0.923 1.000 0.000
#> GSM559403     1  0.0000      0.923 1.000 0.000
#> GSM559404     1  0.0672      0.914 0.992 0.008
#> GSM559405     1  0.0000      0.923 1.000 0.000
#> GSM559406     1  0.0672      0.914 0.992 0.008
#> GSM559407     1  0.0000      0.923 1.000 0.000
#> GSM559408     1  0.0000      0.923 1.000 0.000
#> GSM559409     1  0.0000      0.923 1.000 0.000
#> GSM559410     1  0.0000      0.923 1.000 0.000
#> GSM559411     1  0.0672      0.914 0.992 0.008
#> GSM559412     1  0.0672      0.914 0.992 0.008
#> GSM559413     1  0.0672      0.914 0.992 0.008
#> GSM559415     1  0.0000      0.923 1.000 0.000
#> GSM559416     1  0.0000      0.923 1.000 0.000
#> GSM559417     1  0.0000      0.923 1.000 0.000
#> GSM559418     1  0.2603      0.856 0.956 0.044
#> GSM559419     1  0.0000      0.923 1.000 0.000
#> GSM559420     1  0.0000      0.923 1.000 0.000
#> GSM559421     2  0.9996      0.347 0.488 0.512
#> GSM559423     2  0.9996      0.347 0.488 0.512
#> GSM559425     2  0.9996      0.347 0.488 0.512
#> GSM559426     2  0.9996      0.347 0.488 0.512
#> GSM559427     2  0.9996      0.347 0.488 0.512
#> GSM559428     2  0.9996      0.347 0.488 0.512
#> GSM559429     2  0.9996      0.347 0.488 0.512
#> GSM559430     2  0.9996      0.347 0.488 0.512

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM559383     3  0.1163      0.992 0.028 0.000 0.972
#> GSM559387     3  0.1163      0.992 0.028 0.000 0.972
#> GSM559391     3  0.1163      0.992 0.028 0.000 0.972
#> GSM559395     3  0.1163      0.992 0.028 0.000 0.972
#> GSM559397     3  0.1163      0.992 0.028 0.000 0.972
#> GSM559401     3  0.1399      0.991 0.028 0.004 0.968
#> GSM559414     3  0.1163      0.992 0.028 0.000 0.972
#> GSM559422     3  0.0661      0.974 0.008 0.004 0.988
#> GSM559424     3  0.1163      0.992 0.028 0.000 0.972
#> GSM559431     2  0.0661      0.971 0.004 0.988 0.008
#> GSM559432     3  0.0237      0.966 0.000 0.004 0.996
#> GSM559381     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559382     2  0.1129      0.968 0.004 0.976 0.020
#> GSM559384     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559385     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559386     1  0.1315      0.973 0.972 0.008 0.020
#> GSM559388     2  0.1129      0.968 0.004 0.976 0.020
#> GSM559389     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559390     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559392     2  0.0237      0.972 0.004 0.996 0.000
#> GSM559393     1  0.1315      0.973 0.972 0.008 0.020
#> GSM559394     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559396     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559398     2  0.0661      0.971 0.004 0.988 0.008
#> GSM559399     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559400     2  0.5200      0.734 0.184 0.796 0.020
#> GSM559402     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559403     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559404     1  0.0237      0.992 0.996 0.000 0.004
#> GSM559405     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559406     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559407     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559408     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559409     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559410     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559411     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559412     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559413     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559415     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559416     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559417     1  0.0983      0.980 0.980 0.004 0.016
#> GSM559418     1  0.1170      0.976 0.976 0.008 0.016
#> GSM559419     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559420     1  0.0000      0.996 1.000 0.000 0.000
#> GSM559421     2  0.0237      0.972 0.004 0.996 0.000
#> GSM559423     2  0.0983      0.969 0.004 0.980 0.016
#> GSM559425     2  0.0661      0.971 0.004 0.988 0.008
#> GSM559426     2  0.0237      0.972 0.004 0.996 0.000
#> GSM559427     2  0.0661      0.971 0.004 0.988 0.008
#> GSM559428     2  0.1129      0.968 0.004 0.976 0.020
#> GSM559429     2  0.0983      0.969 0.004 0.980 0.016
#> GSM559430     2  0.0661      0.971 0.004 0.988 0.008

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM559383     3  0.0188     0.9647 0.000 0.000 0.996 0.004
#> GSM559387     3  0.0000     0.9654 0.000 0.000 1.000 0.000
#> GSM559391     3  0.0188     0.9647 0.000 0.000 0.996 0.004
#> GSM559395     3  0.0000     0.9654 0.000 0.000 1.000 0.000
#> GSM559397     3  0.0000     0.9654 0.000 0.000 1.000 0.000
#> GSM559401     3  0.0000     0.9654 0.000 0.000 1.000 0.000
#> GSM559414     3  0.0000     0.9654 0.000 0.000 1.000 0.000
#> GSM559422     3  0.3649     0.8581 0.000 0.000 0.796 0.204
#> GSM559424     3  0.0188     0.9647 0.000 0.000 0.996 0.004
#> GSM559431     2  0.0336     0.8567 0.000 0.992 0.000 0.008
#> GSM559432     3  0.3726     0.8528 0.000 0.000 0.788 0.212
#> GSM559381     1  0.1792     0.6394 0.932 0.000 0.000 0.068
#> GSM559382     2  0.5771     0.4645 0.028 0.512 0.000 0.460
#> GSM559384     1  0.2216     0.6468 0.908 0.000 0.000 0.092
#> GSM559385     1  0.1792     0.6321 0.932 0.000 0.000 0.068
#> GSM559386     1  0.4907    -0.0738 0.580 0.000 0.000 0.420
#> GSM559388     2  0.4907     0.5400 0.000 0.580 0.000 0.420
#> GSM559389     1  0.2081     0.6182 0.916 0.000 0.000 0.084
#> GSM559390     4  0.4843     0.4317 0.396 0.000 0.000 0.604
#> GSM559392     2  0.1867     0.8612 0.000 0.928 0.000 0.072
#> GSM559393     1  0.4948    -0.0473 0.560 0.000 0.000 0.440
#> GSM559394     1  0.1792     0.6321 0.932 0.000 0.000 0.068
#> GSM559396     1  0.4222     0.5020 0.728 0.000 0.000 0.272
#> GSM559398     2  0.0336     0.8589 0.000 0.992 0.000 0.008
#> GSM559399     1  0.2408     0.5873 0.896 0.000 0.000 0.104
#> GSM559400     4  0.5947    -0.3058 0.044 0.384 0.000 0.572
#> GSM559402     1  0.2868     0.6303 0.864 0.000 0.000 0.136
#> GSM559403     1  0.1792     0.6321 0.932 0.000 0.000 0.068
#> GSM559404     1  0.2081     0.6371 0.916 0.000 0.000 0.084
#> GSM559405     1  0.0000     0.6533 1.000 0.000 0.000 0.000
#> GSM559406     1  0.4356     0.4772 0.708 0.000 0.000 0.292
#> GSM559407     1  0.2921     0.6288 0.860 0.000 0.000 0.140
#> GSM559408     1  0.4277     0.4927 0.720 0.000 0.000 0.280
#> GSM559409     1  0.4277     0.4927 0.720 0.000 0.000 0.280
#> GSM559410     1  0.0336     0.6537 0.992 0.000 0.000 0.008
#> GSM559411     1  0.4356     0.4871 0.708 0.000 0.000 0.292
#> GSM559412     1  0.4356     0.4871 0.708 0.000 0.000 0.292
#> GSM559413     1  0.4356     0.4871 0.708 0.000 0.000 0.292
#> GSM559415     1  0.2345     0.5923 0.900 0.000 0.000 0.100
#> GSM559416     4  0.4961     0.4070 0.448 0.000 0.000 0.552
#> GSM559417     4  0.4961     0.4070 0.448 0.000 0.000 0.552
#> GSM559418     1  0.4477     0.1311 0.688 0.000 0.000 0.312
#> GSM559419     1  0.4888     0.0463 0.588 0.000 0.000 0.412
#> GSM559420     1  0.2868     0.6303 0.864 0.000 0.000 0.136
#> GSM559421     2  0.1792     0.8616 0.000 0.932 0.000 0.068
#> GSM559423     2  0.2011     0.8592 0.000 0.920 0.000 0.080
#> GSM559425     2  0.0000     0.8582 0.000 1.000 0.000 0.000
#> GSM559426     2  0.2011     0.8598 0.000 0.920 0.000 0.080
#> GSM559427     2  0.0000     0.8582 0.000 1.000 0.000 0.000
#> GSM559428     2  0.5774     0.4681 0.028 0.508 0.000 0.464
#> GSM559429     2  0.2345     0.8551 0.000 0.900 0.000 0.100
#> GSM559430     2  0.0000     0.8582 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
#> GSM559383     3  0.0898     0.9102 0.000 0.000 0.972 0.020 NA
#> GSM559387     3  0.0000     0.9145 0.000 0.000 1.000 0.000 NA
#> GSM559391     3  0.0898     0.9102 0.000 0.000 0.972 0.020 NA
#> GSM559395     3  0.0000     0.9145 0.000 0.000 1.000 0.000 NA
#> GSM559397     3  0.0000     0.9145 0.000 0.000 1.000 0.000 NA
#> GSM559401     3  0.0000     0.9145 0.000 0.000 1.000 0.000 NA
#> GSM559414     3  0.0000     0.9145 0.000 0.000 1.000 0.000 NA
#> GSM559422     3  0.4256     0.6363 0.000 0.000 0.564 0.000 NA
#> GSM559424     3  0.0898     0.9102 0.000 0.000 0.972 0.020 NA
#> GSM559431     2  0.0324     0.9059 0.000 0.992 0.000 0.004 NA
#> GSM559432     3  0.4268     0.6293 0.000 0.000 0.556 0.000 NA
#> GSM559381     1  0.3532     0.5857 0.832 0.000 0.000 0.092 NA
#> GSM559382     4  0.7126     0.2497 0.032 0.304 0.000 0.468 NA
#> GSM559384     1  0.3543     0.6114 0.828 0.000 0.000 0.112 NA
#> GSM559385     1  0.3565     0.5580 0.816 0.000 0.000 0.040 NA
#> GSM559386     4  0.6372     0.2367 0.376 0.000 0.000 0.456 NA
#> GSM559388     4  0.6553     0.1365 0.004 0.368 0.000 0.452 NA
#> GSM559389     1  0.3242     0.5672 0.852 0.000 0.000 0.076 NA
#> GSM559390     4  0.3532     0.3905 0.128 0.000 0.000 0.824 NA
#> GSM559392     2  0.3184     0.8779 0.000 0.852 0.000 0.048 NA
#> GSM559393     1  0.6361     0.0439 0.484 0.000 0.000 0.340 NA
#> GSM559394     1  0.3803     0.5557 0.804 0.000 0.000 0.056 NA
#> GSM559396     1  0.5727     0.4091 0.560 0.000 0.000 0.340 NA
#> GSM559398     2  0.1549     0.9009 0.000 0.944 0.000 0.016 NA
#> GSM559399     1  0.3639     0.5319 0.812 0.000 0.000 0.144 NA
#> GSM559400     4  0.5605     0.4411 0.012 0.172 0.000 0.672 NA
#> GSM559402     1  0.3930     0.5978 0.792 0.000 0.000 0.152 NA
#> GSM559403     1  0.3262     0.5685 0.840 0.000 0.000 0.036 NA
#> GSM559404     1  0.4303     0.5598 0.752 0.000 0.000 0.056 NA
#> GSM559405     1  0.0451     0.6184 0.988 0.000 0.000 0.004 NA
#> GSM559406     1  0.5447     0.3723 0.500 0.000 0.000 0.440 NA
#> GSM559407     1  0.4049     0.5947 0.780 0.000 0.000 0.164 NA
#> GSM559408     1  0.5622     0.3926 0.508 0.000 0.000 0.416 NA
#> GSM559409     1  0.5703     0.3967 0.508 0.000 0.000 0.408 NA
#> GSM559410     1  0.1403     0.6188 0.952 0.000 0.000 0.024 NA
#> GSM559411     1  0.5928     0.4046 0.500 0.000 0.000 0.392 NA
#> GSM559412     1  0.5826     0.3915 0.500 0.000 0.000 0.404 NA
#> GSM559413     1  0.6019     0.4019 0.500 0.000 0.000 0.380 NA
#> GSM559415     1  0.3595     0.5388 0.816 0.000 0.000 0.140 NA
#> GSM559416     4  0.3231     0.3031 0.196 0.000 0.000 0.800 NA
#> GSM559417     4  0.3003     0.3194 0.188 0.000 0.000 0.812 NA
#> GSM559418     1  0.5145     0.1985 0.612 0.000 0.000 0.332 NA
#> GSM559419     4  0.4686    -0.1650 0.384 0.000 0.000 0.596 NA
#> GSM559420     1  0.4190     0.5938 0.768 0.000 0.000 0.172 NA
#> GSM559421     2  0.2735     0.8927 0.000 0.880 0.000 0.036 NA
#> GSM559423     2  0.3390     0.8749 0.000 0.840 0.000 0.060 NA
#> GSM559425     2  0.0000     0.9077 0.000 1.000 0.000 0.000 NA
#> GSM559426     2  0.3276     0.8659 0.000 0.836 0.000 0.032 NA
#> GSM559427     2  0.0000     0.9077 0.000 1.000 0.000 0.000 NA
#> GSM559428     4  0.7328     0.1986 0.028 0.292 0.000 0.408 NA
#> GSM559429     2  0.4252     0.8074 0.000 0.764 0.000 0.064 NA
#> GSM559430     2  0.0000     0.9077 0.000 1.000 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
#> GSM559383     3  0.1151     0.9487 0.012 0.000 0.956 0.000 0.000 0.032
#> GSM559387     3  0.0000     0.9679 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559391     3  0.1151     0.9487 0.012 0.000 0.956 0.000 0.000 0.032
#> GSM559395     3  0.0000     0.9679 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559397     3  0.0000     0.9679 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559401     3  0.0291     0.9614 0.004 0.000 0.992 0.000 0.004 0.000
#> GSM559414     3  0.0000     0.9679 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559422     5  0.3817     0.9749 0.000 0.000 0.432 0.000 0.568 0.000
#> GSM559424     3  0.1151     0.9487 0.012 0.000 0.956 0.000 0.000 0.032
#> GSM559431     2  0.1232     0.7825 0.024 0.956 0.000 0.000 0.016 0.004
#> GSM559432     5  0.4032     0.9753 0.000 0.000 0.420 0.000 0.572 0.008
#> GSM559381     1  0.6238     0.1789 0.452 0.000 0.000 0.392 0.056 0.100
#> GSM559382     6  0.3837     0.5939 0.068 0.140 0.000 0.000 0.008 0.784
#> GSM559384     4  0.5351     0.0571 0.388 0.000 0.000 0.528 0.064 0.020
#> GSM559385     1  0.5380     0.5903 0.660 0.000 0.000 0.192 0.104 0.044
#> GSM559386     6  0.3826     0.5436 0.236 0.000 0.000 0.012 0.016 0.736
#> GSM559388     6  0.3727     0.5380 0.040 0.188 0.000 0.000 0.004 0.768
#> GSM559389     1  0.4378     0.6229 0.704 0.000 0.000 0.240 0.016 0.040
#> GSM559390     6  0.6037     0.0252 0.068 0.000 0.000 0.408 0.064 0.460
#> GSM559392     2  0.3314     0.7102 0.000 0.740 0.000 0.000 0.004 0.256
#> GSM559393     1  0.4754     0.4537 0.692 0.000 0.000 0.016 0.080 0.212
#> GSM559394     1  0.4702     0.6190 0.724 0.000 0.000 0.164 0.080 0.032
#> GSM559396     4  0.6695     0.2695 0.256 0.000 0.000 0.504 0.100 0.140
#> GSM559398     2  0.1908     0.7695 0.000 0.900 0.000 0.000 0.004 0.096
#> GSM559399     1  0.4740     0.6034 0.696 0.000 0.000 0.220 0.032 0.052
#> GSM559400     6  0.5131     0.5924 0.052 0.060 0.000 0.084 0.060 0.744
#> GSM559402     4  0.5017     0.2282 0.312 0.000 0.000 0.612 0.060 0.016
#> GSM559403     1  0.4837     0.6116 0.692 0.000 0.000 0.208 0.076 0.024
#> GSM559404     4  0.5828    -0.1455 0.356 0.000 0.000 0.516 0.096 0.032
#> GSM559405     1  0.4010     0.4571 0.584 0.000 0.000 0.408 0.008 0.000
#> GSM559406     4  0.2924     0.5319 0.024 0.000 0.000 0.868 0.040 0.068
#> GSM559407     4  0.4986     0.2411 0.304 0.000 0.000 0.620 0.060 0.016
#> GSM559408     4  0.1464     0.5577 0.016 0.000 0.000 0.944 0.004 0.036
#> GSM559409     4  0.1148     0.5601 0.016 0.000 0.000 0.960 0.004 0.020
#> GSM559410     1  0.4200     0.4994 0.592 0.000 0.000 0.392 0.012 0.004
#> GSM559411     4  0.1307     0.5543 0.008 0.000 0.000 0.952 0.032 0.008
#> GSM559412     4  0.0914     0.5591 0.000 0.000 0.000 0.968 0.016 0.016
#> GSM559413     4  0.0777     0.5579 0.000 0.000 0.000 0.972 0.024 0.004
#> GSM559415     1  0.4700     0.6053 0.704 0.000 0.000 0.212 0.040 0.044
#> GSM559416     4  0.6855     0.1138 0.152 0.000 0.000 0.448 0.092 0.308
#> GSM559417     4  0.6830     0.0855 0.144 0.000 0.000 0.444 0.092 0.320
#> GSM559418     1  0.4922     0.5507 0.712 0.000 0.000 0.096 0.040 0.152
#> GSM559419     4  0.6340     0.3407 0.236 0.000 0.000 0.548 0.068 0.148
#> GSM559420     4  0.5407     0.2150 0.340 0.000 0.000 0.564 0.072 0.024
#> GSM559421     2  0.3189     0.7244 0.000 0.760 0.000 0.000 0.004 0.236
#> GSM559423     2  0.4525     0.6596 0.020 0.672 0.000 0.000 0.032 0.276
#> GSM559425     2  0.0820     0.7859 0.016 0.972 0.000 0.000 0.012 0.000
#> GSM559426     2  0.5434     0.6489 0.052 0.664 0.000 0.000 0.112 0.172
#> GSM559427     2  0.0820     0.7859 0.016 0.972 0.000 0.000 0.012 0.000
#> GSM559428     6  0.6158     0.4450 0.112 0.132 0.000 0.000 0.152 0.604
#> GSM559429     2  0.6369     0.4752 0.068 0.536 0.000 0.000 0.140 0.256
#> GSM559430     2  0.0000     0.7875 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-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 disease.state(p) k
#> SD:kmeans 28               NA 2
#> SD:kmeans 52         8.27e-11 3
#> SD:kmeans 36         1.30e-07 4
#> SD:kmeans 34         3.24e-07 5
#> SD:kmeans 36         6.48e-06 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 21167 rows and 52 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.571           0.918       0.933         0.4814 0.517   0.517
#> 3 3 1.000           0.982       0.993         0.3439 0.773   0.586
#> 4 4 0.866           0.932       0.954         0.1661 0.851   0.600
#> 5 5 0.804           0.698       0.839         0.0574 0.907   0.658
#> 6 6 0.781           0.547       0.789         0.0331 0.965   0.844

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
#> GSM559383     1   0.184      0.923 0.972 0.028
#> GSM559387     1   0.184      0.923 0.972 0.028
#> GSM559391     1   0.184      0.923 0.972 0.028
#> GSM559395     1   0.184      0.923 0.972 0.028
#> GSM559397     1   0.184      0.923 0.972 0.028
#> GSM559401     1   0.184      0.923 0.972 0.028
#> GSM559414     1   0.184      0.923 0.972 0.028
#> GSM559422     2   0.871      0.656 0.292 0.708
#> GSM559424     1   0.184      0.923 0.972 0.028
#> GSM559431     2   0.000      0.946 0.000 1.000
#> GSM559432     2   0.518      0.857 0.116 0.884
#> GSM559381     1   0.662      0.863 0.828 0.172
#> GSM559382     2   0.118      0.954 0.016 0.984
#> GSM559384     1   0.518      0.914 0.884 0.116
#> GSM559385     1   0.518      0.914 0.884 0.116
#> GSM559386     2   0.184      0.947 0.028 0.972
#> GSM559388     2   0.118      0.954 0.016 0.984
#> GSM559389     1   0.662      0.863 0.828 0.172
#> GSM559390     1   0.000      0.930 1.000 0.000
#> GSM559392     2   0.118      0.954 0.016 0.984
#> GSM559393     2   0.184      0.947 0.028 0.972
#> GSM559394     1   0.518      0.914 0.884 0.116
#> GSM559396     1   0.118      0.924 0.984 0.016
#> GSM559398     2   0.118      0.954 0.016 0.984
#> GSM559399     1   0.518      0.914 0.884 0.116
#> GSM559400     2   0.518      0.857 0.116 0.884
#> GSM559402     1   0.518      0.914 0.884 0.116
#> GSM559403     1   0.518      0.914 0.884 0.116
#> GSM559404     1   0.000      0.930 1.000 0.000
#> GSM559405     1   0.518      0.914 0.884 0.116
#> GSM559406     1   0.000      0.930 1.000 0.000
#> GSM559407     1   0.518      0.914 0.884 0.116
#> GSM559408     1   0.163      0.931 0.976 0.024
#> GSM559409     1   0.118      0.931 0.984 0.016
#> GSM559410     1   0.518      0.914 0.884 0.116
#> GSM559411     1   0.000      0.930 1.000 0.000
#> GSM559412     1   0.000      0.930 1.000 0.000
#> GSM559413     1   0.000      0.930 1.000 0.000
#> GSM559415     1   0.518      0.914 0.884 0.116
#> GSM559416     1   0.260      0.927 0.956 0.044
#> GSM559417     2   0.795      0.746 0.240 0.760
#> GSM559418     2   0.184      0.947 0.028 0.972
#> GSM559419     1   0.469      0.919 0.900 0.100
#> GSM559420     1   0.469      0.919 0.900 0.100
#> GSM559421     2   0.118      0.954 0.016 0.984
#> GSM559423     2   0.118      0.954 0.016 0.984
#> GSM559425     2   0.118      0.954 0.016 0.984
#> GSM559426     2   0.118      0.954 0.016 0.984
#> GSM559427     2   0.118      0.954 0.016 0.984
#> GSM559428     2   0.000      0.946 0.000 1.000
#> GSM559429     2   0.000      0.946 0.000 1.000
#> GSM559430     2   0.118      0.954 0.016 0.984

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM559383     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559387     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559391     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559395     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559397     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559401     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559414     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559422     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559424     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559431     2  0.0000      0.980 0.000 1.000 0.000
#> GSM559432     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559381     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559382     2  0.0000      0.980 0.000 1.000 0.000
#> GSM559384     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559385     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559386     2  0.0000      0.980 0.000 1.000 0.000
#> GSM559388     2  0.0000      0.980 0.000 1.000 0.000
#> GSM559389     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559390     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559392     2  0.0000      0.980 0.000 1.000 0.000
#> GSM559393     2  0.0592      0.967 0.012 0.988 0.000
#> GSM559394     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559396     3  0.0237      0.995 0.004 0.000 0.996
#> GSM559398     2  0.0000      0.980 0.000 1.000 0.000
#> GSM559399     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559400     2  0.0000      0.980 0.000 1.000 0.000
#> GSM559402     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559403     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559404     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559405     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559406     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559407     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559408     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559409     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559410     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559411     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559412     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559413     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559415     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559416     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559417     1  0.3038      0.880 0.896 0.104 0.000
#> GSM559418     2  0.5178      0.654 0.256 0.744 0.000
#> GSM559419     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559420     1  0.0000      0.995 1.000 0.000 0.000
#> GSM559421     2  0.0000      0.980 0.000 1.000 0.000
#> GSM559423     2  0.0000      0.980 0.000 1.000 0.000
#> GSM559425     2  0.0000      0.980 0.000 1.000 0.000
#> GSM559426     2  0.0000      0.980 0.000 1.000 0.000
#> GSM559427     2  0.0000      0.980 0.000 1.000 0.000
#> GSM559428     2  0.0000      0.980 0.000 1.000 0.000
#> GSM559429     2  0.0000      0.980 0.000 1.000 0.000
#> GSM559430     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
#> GSM559383     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM559387     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM559391     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM559395     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM559397     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM559401     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM559414     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM559422     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM559424     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM559431     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM559432     3  0.0469      0.985 0.000 0.012 0.988 0.000
#> GSM559381     1  0.1389      0.898 0.952 0.000 0.000 0.048
#> GSM559382     2  0.0188      0.979 0.000 0.996 0.000 0.004
#> GSM559384     1  0.2149      0.878 0.912 0.000 0.000 0.088
#> GSM559385     1  0.0000      0.900 1.000 0.000 0.000 0.000
#> GSM559386     2  0.3164      0.884 0.064 0.884 0.000 0.052
#> GSM559388     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM559389     1  0.0000      0.900 1.000 0.000 0.000 0.000
#> GSM559390     4  0.0921      0.923 0.028 0.000 0.000 0.972
#> GSM559392     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM559393     1  0.2053      0.856 0.924 0.072 0.000 0.004
#> GSM559394     1  0.0469      0.898 0.988 0.000 0.000 0.012
#> GSM559396     3  0.0817      0.974 0.000 0.000 0.976 0.024
#> GSM559398     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM559399     1  0.2589      0.859 0.884 0.000 0.000 0.116
#> GSM559400     2  0.2921      0.839 0.000 0.860 0.000 0.140
#> GSM559402     1  0.3649      0.772 0.796 0.000 0.000 0.204
#> GSM559403     1  0.0000      0.900 1.000 0.000 0.000 0.000
#> GSM559404     1  0.1022      0.901 0.968 0.000 0.000 0.032
#> GSM559405     1  0.1022      0.901 0.968 0.000 0.000 0.032
#> GSM559406     4  0.2345      0.943 0.100 0.000 0.000 0.900
#> GSM559407     1  0.3837      0.747 0.776 0.000 0.000 0.224
#> GSM559408     4  0.2469      0.943 0.108 0.000 0.000 0.892
#> GSM559409     4  0.2530      0.943 0.112 0.000 0.000 0.888
#> GSM559410     1  0.1557      0.897 0.944 0.000 0.000 0.056
#> GSM559411     4  0.2530      0.943 0.112 0.000 0.000 0.888
#> GSM559412     4  0.2530      0.943 0.112 0.000 0.000 0.888
#> GSM559413     4  0.2530      0.943 0.112 0.000 0.000 0.888
#> GSM559415     1  0.2704      0.858 0.876 0.000 0.000 0.124
#> GSM559416     4  0.0000      0.912 0.000 0.000 0.000 1.000
#> GSM559417     4  0.0000      0.912 0.000 0.000 0.000 1.000
#> GSM559418     1  0.3497      0.839 0.860 0.036 0.000 0.104
#> GSM559419     4  0.0336      0.916 0.008 0.000 0.000 0.992
#> GSM559420     1  0.4164      0.709 0.736 0.000 0.000 0.264
#> GSM559421     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM559423     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM559425     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM559426     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM559427     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM559428     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM559429     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM559430     2  0.0000      0.982 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
#> GSM559383     3  0.0000     0.9529 0.000 0.000 1.000 0.000 0.000
#> GSM559387     3  0.0000     0.9529 0.000 0.000 1.000 0.000 0.000
#> GSM559391     3  0.0000     0.9529 0.000 0.000 1.000 0.000 0.000
#> GSM559395     3  0.0000     0.9529 0.000 0.000 1.000 0.000 0.000
#> GSM559397     3  0.0000     0.9529 0.000 0.000 1.000 0.000 0.000
#> GSM559401     3  0.0000     0.9529 0.000 0.000 1.000 0.000 0.000
#> GSM559414     3  0.0000     0.9529 0.000 0.000 1.000 0.000 0.000
#> GSM559422     3  0.0579     0.9440 0.008 0.000 0.984 0.008 0.000
#> GSM559424     3  0.0000     0.9529 0.000 0.000 1.000 0.000 0.000
#> GSM559431     2  0.0000     0.9382 0.000 1.000 0.000 0.000 0.000
#> GSM559432     3  0.1770     0.8974 0.008 0.048 0.936 0.008 0.000
#> GSM559381     1  0.4306     0.3818 0.660 0.000 0.000 0.012 0.328
#> GSM559382     2  0.1828     0.9066 0.028 0.936 0.000 0.004 0.032
#> GSM559384     1  0.2930     0.5626 0.832 0.000 0.000 0.004 0.164
#> GSM559385     5  0.1341     0.7783 0.056 0.000 0.000 0.000 0.944
#> GSM559386     2  0.6358     0.5633 0.064 0.632 0.000 0.104 0.200
#> GSM559388     2  0.1372     0.9188 0.024 0.956 0.000 0.004 0.016
#> GSM559389     5  0.2719     0.7417 0.144 0.000 0.000 0.004 0.852
#> GSM559390     4  0.3495     0.6639 0.152 0.000 0.000 0.816 0.032
#> GSM559392     2  0.0000     0.9382 0.000 1.000 0.000 0.000 0.000
#> GSM559393     5  0.1082     0.7513 0.028 0.008 0.000 0.000 0.964
#> GSM559394     5  0.1197     0.7786 0.048 0.000 0.000 0.000 0.952
#> GSM559396     3  0.4478     0.4816 0.360 0.000 0.628 0.004 0.008
#> GSM559398     2  0.0000     0.9382 0.000 1.000 0.000 0.000 0.000
#> GSM559399     5  0.5405     0.7064 0.136 0.000 0.000 0.204 0.660
#> GSM559400     2  0.4387     0.4867 0.012 0.640 0.000 0.348 0.000
#> GSM559402     1  0.2020     0.5849 0.900 0.000 0.000 0.000 0.100
#> GSM559403     5  0.2020     0.7713 0.100 0.000 0.000 0.000 0.900
#> GSM559404     1  0.4470     0.3447 0.616 0.000 0.000 0.012 0.372
#> GSM559405     1  0.4287    -0.0388 0.540 0.000 0.000 0.000 0.460
#> GSM559406     4  0.4225     0.2894 0.364 0.000 0.000 0.632 0.004
#> GSM559407     1  0.2193     0.5848 0.900 0.000 0.000 0.008 0.092
#> GSM559408     1  0.4450    -0.0351 0.508 0.000 0.000 0.488 0.004
#> GSM559409     1  0.4464     0.1714 0.584 0.000 0.000 0.408 0.008
#> GSM559410     5  0.4872     0.2309 0.436 0.000 0.000 0.024 0.540
#> GSM559411     1  0.3534     0.4101 0.744 0.000 0.000 0.256 0.000
#> GSM559412     1  0.4350     0.2057 0.588 0.000 0.000 0.408 0.004
#> GSM559413     1  0.4084     0.3389 0.668 0.000 0.000 0.328 0.004
#> GSM559415     5  0.5164     0.7098 0.096 0.000 0.000 0.232 0.672
#> GSM559416     4  0.0794     0.7313 0.028 0.000 0.000 0.972 0.000
#> GSM559417     4  0.0865     0.7307 0.024 0.004 0.000 0.972 0.000
#> GSM559418     5  0.5324     0.6988 0.072 0.016 0.000 0.232 0.680
#> GSM559419     4  0.3882     0.5705 0.224 0.000 0.000 0.756 0.020
#> GSM559420     1  0.3906     0.5014 0.800 0.000 0.000 0.132 0.068
#> GSM559421     2  0.0000     0.9382 0.000 1.000 0.000 0.000 0.000
#> GSM559423     2  0.0000     0.9382 0.000 1.000 0.000 0.000 0.000
#> GSM559425     2  0.0000     0.9382 0.000 1.000 0.000 0.000 0.000
#> GSM559426     2  0.0162     0.9370 0.004 0.996 0.000 0.000 0.000
#> GSM559427     2  0.0000     0.9382 0.000 1.000 0.000 0.000 0.000
#> GSM559428     2  0.1483     0.9192 0.028 0.952 0.000 0.012 0.008
#> GSM559429     2  0.0833     0.9288 0.016 0.976 0.000 0.004 0.004
#> GSM559430     2  0.0000     0.9382 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
#> GSM559383     3  0.0146   0.914801 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM559387     3  0.0000   0.915374 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559391     3  0.0146   0.914801 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM559395     3  0.0000   0.915374 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559397     3  0.0000   0.915374 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559401     3  0.0146   0.914136 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM559414     3  0.0000   0.915374 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559422     3  0.2145   0.859434 0.012 0.000 0.904 0.004 0.004 0.076
#> GSM559424     3  0.0146   0.914801 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM559431     2  0.0000   0.875174 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559432     3  0.3331   0.803246 0.008 0.060 0.844 0.004 0.004 0.080
#> GSM559381     6  0.6042   0.000000 0.212 0.004 0.000 0.360 0.000 0.424
#> GSM559382     2  0.3264   0.788116 0.012 0.796 0.000 0.000 0.008 0.184
#> GSM559384     4  0.5269  -0.247684 0.088 0.000 0.000 0.604 0.016 0.292
#> GSM559385     1  0.1168   0.628381 0.956 0.000 0.000 0.016 0.000 0.028
#> GSM559386     2  0.6950   0.195084 0.136 0.412 0.000 0.008 0.080 0.364
#> GSM559388     2  0.2333   0.828547 0.004 0.872 0.000 0.000 0.004 0.120
#> GSM559389     1  0.4300   0.384322 0.712 0.000 0.000 0.080 0.000 0.208
#> GSM559390     5  0.4730   0.532472 0.008 0.000 0.000 0.184 0.696 0.112
#> GSM559392     2  0.0790   0.871559 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM559393     1  0.1765   0.582994 0.904 0.000 0.000 0.000 0.000 0.096
#> GSM559394     1  0.0748   0.640108 0.976 0.000 0.000 0.016 0.004 0.004
#> GSM559396     3  0.6332  -0.076423 0.000 0.000 0.408 0.264 0.012 0.316
#> GSM559398     2  0.0632   0.873444 0.000 0.976 0.000 0.000 0.000 0.024
#> GSM559399     1  0.6681   0.461879 0.508 0.000 0.000 0.080 0.204 0.208
#> GSM559400     2  0.5653   0.216136 0.000 0.496 0.000 0.004 0.360 0.140
#> GSM559402     4  0.3351   0.076968 0.040 0.000 0.000 0.800 0.000 0.160
#> GSM559403     1  0.1950   0.613654 0.912 0.000 0.000 0.064 0.000 0.024
#> GSM559404     4  0.5027  -0.049062 0.324 0.000 0.000 0.600 0.012 0.064
#> GSM559405     4  0.5681  -0.337238 0.416 0.000 0.000 0.428 0.000 0.156
#> GSM559406     4  0.4472  -0.000703 0.000 0.000 0.000 0.496 0.476 0.028
#> GSM559407     4  0.3457   0.125477 0.052 0.000 0.000 0.808 0.004 0.136
#> GSM559408     4  0.4254   0.311889 0.004 0.000 0.000 0.624 0.352 0.020
#> GSM559409     4  0.4255   0.408131 0.012 0.000 0.000 0.680 0.284 0.024
#> GSM559410     4  0.5816  -0.183573 0.428 0.000 0.000 0.432 0.012 0.128
#> GSM559411     4  0.3381   0.399554 0.000 0.000 0.000 0.800 0.156 0.044
#> GSM559412     4  0.3650   0.424069 0.004 0.000 0.000 0.716 0.272 0.008
#> GSM559413     4  0.2902   0.425151 0.000 0.000 0.000 0.800 0.196 0.004
#> GSM559415     1  0.6152   0.523638 0.548 0.000 0.000 0.044 0.256 0.152
#> GSM559416     5  0.0806   0.766677 0.000 0.000 0.000 0.020 0.972 0.008
#> GSM559417     5  0.0993   0.766864 0.000 0.000 0.000 0.024 0.964 0.012
#> GSM559418     1  0.6701   0.487105 0.496 0.020 0.000 0.040 0.292 0.152
#> GSM559419     5  0.5041   0.551543 0.024 0.000 0.000 0.128 0.688 0.160
#> GSM559420     4  0.5766  -0.211403 0.036 0.000 0.000 0.572 0.104 0.288
#> GSM559421     2  0.0632   0.873954 0.000 0.976 0.000 0.000 0.000 0.024
#> GSM559423     2  0.0260   0.874955 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM559425     2  0.0000   0.875174 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559426     2  0.0790   0.867898 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM559427     2  0.0000   0.875174 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559428     2  0.3240   0.732849 0.000 0.752 0.000 0.000 0.004 0.244
#> GSM559429     2  0.2092   0.823455 0.000 0.876 0.000 0.000 0.000 0.124
#> GSM559430     2  0.0000   0.875174 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-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 disease.state(p) k
#> SD:skmeans 52         6.10e-01 2
#> SD:skmeans 52         1.31e-09 3
#> SD:skmeans 52         6.69e-09 4
#> SD:skmeans 40         3.95e-07 5
#> SD:skmeans 32         3.80e-06 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 21167 rows and 52 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 1.000           0.966       0.973         0.3268 0.683   0.683
#> 3 3 1.000           0.958       0.985         0.7857 0.729   0.603
#> 4 4 0.855           0.932       0.947         0.2300 0.853   0.652
#> 5 5 0.823           0.902       0.929         0.0234 0.988   0.958
#> 6 6 0.758           0.794       0.871         0.0325 0.981   0.932

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
#> GSM559383     2  0.3114      0.993 0.056 0.944
#> GSM559387     2  0.3114      0.993 0.056 0.944
#> GSM559391     2  0.3114      0.993 0.056 0.944
#> GSM559395     2  0.3114      0.993 0.056 0.944
#> GSM559397     2  0.3114      0.993 0.056 0.944
#> GSM559401     2  0.3114      0.993 0.056 0.944
#> GSM559414     2  0.3114      0.993 0.056 0.944
#> GSM559422     2  0.3114      0.993 0.056 0.944
#> GSM559424     2  0.3114      0.993 0.056 0.944
#> GSM559431     1  0.3114      0.950 0.944 0.056
#> GSM559432     2  0.0000      0.940 0.000 1.000
#> GSM559381     1  0.0000      0.976 1.000 0.000
#> GSM559382     1  0.0000      0.976 1.000 0.000
#> GSM559384     1  0.0000      0.976 1.000 0.000
#> GSM559385     1  0.0000      0.976 1.000 0.000
#> GSM559386     1  0.0000      0.976 1.000 0.000
#> GSM559388     1  0.0376      0.974 0.996 0.004
#> GSM559389     1  0.0000      0.976 1.000 0.000
#> GSM559390     1  0.0000      0.976 1.000 0.000
#> GSM559392     1  0.3114      0.950 0.944 0.056
#> GSM559393     1  0.0000      0.976 1.000 0.000
#> GSM559394     1  0.0000      0.976 1.000 0.000
#> GSM559396     1  0.0000      0.976 1.000 0.000
#> GSM559398     1  0.3114      0.950 0.944 0.056
#> GSM559399     1  0.0000      0.976 1.000 0.000
#> GSM559400     1  0.3114      0.950 0.944 0.056
#> GSM559402     1  0.0000      0.976 1.000 0.000
#> GSM559403     1  0.0000      0.976 1.000 0.000
#> GSM559404     1  0.6801      0.771 0.820 0.180
#> GSM559405     1  0.0000      0.976 1.000 0.000
#> GSM559406     1  0.0672      0.971 0.992 0.008
#> GSM559407     1  0.0000      0.976 1.000 0.000
#> GSM559408     1  0.0000      0.976 1.000 0.000
#> GSM559409     1  0.0000      0.976 1.000 0.000
#> GSM559410     1  0.0000      0.976 1.000 0.000
#> GSM559411     1  0.0000      0.976 1.000 0.000
#> GSM559412     1  0.0000      0.976 1.000 0.000
#> GSM559413     1  0.5178      0.860 0.884 0.116
#> GSM559415     1  0.0000      0.976 1.000 0.000
#> GSM559416     1  0.0000      0.976 1.000 0.000
#> GSM559417     1  0.0000      0.976 1.000 0.000
#> GSM559418     1  0.0000      0.976 1.000 0.000
#> GSM559419     1  0.0000      0.976 1.000 0.000
#> GSM559420     1  0.0000      0.976 1.000 0.000
#> GSM559421     1  0.3114      0.950 0.944 0.056
#> GSM559423     1  0.3114      0.950 0.944 0.056
#> GSM559425     1  0.3114      0.950 0.944 0.056
#> GSM559426     1  0.3114      0.950 0.944 0.056
#> GSM559427     1  0.3114      0.950 0.944 0.056
#> GSM559428     1  0.0000      0.976 1.000 0.000
#> GSM559429     1  0.3114      0.950 0.944 0.056
#> GSM559430     1  0.3114      0.950 0.944 0.056

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2 p3
#> GSM559383     3   0.000      1.000 0.000 0.000  1
#> GSM559387     3   0.000      1.000 0.000 0.000  1
#> GSM559391     3   0.000      1.000 0.000 0.000  1
#> GSM559395     3   0.000      1.000 0.000 0.000  1
#> GSM559397     3   0.000      1.000 0.000 0.000  1
#> GSM559401     3   0.000      1.000 0.000 0.000  1
#> GSM559414     3   0.000      1.000 0.000 0.000  1
#> GSM559422     3   0.000      1.000 0.000 0.000  1
#> GSM559424     3   0.000      1.000 0.000 0.000  1
#> GSM559431     2   0.000      0.931 0.000 1.000  0
#> GSM559432     3   0.000      1.000 0.000 0.000  1
#> GSM559381     1   0.000      0.991 1.000 0.000  0
#> GSM559382     1   0.460      0.726 0.796 0.204  0
#> GSM559384     1   0.000      0.991 1.000 0.000  0
#> GSM559385     1   0.000      0.991 1.000 0.000  0
#> GSM559386     1   0.000      0.991 1.000 0.000  0
#> GSM559388     2   0.619      0.284 0.420 0.580  0
#> GSM559389     1   0.000      0.991 1.000 0.000  0
#> GSM559390     1   0.000      0.991 1.000 0.000  0
#> GSM559392     2   0.000      0.931 0.000 1.000  0
#> GSM559393     1   0.000      0.991 1.000 0.000  0
#> GSM559394     1   0.000      0.991 1.000 0.000  0
#> GSM559396     1   0.000      0.991 1.000 0.000  0
#> GSM559398     2   0.000      0.931 0.000 1.000  0
#> GSM559399     1   0.000      0.991 1.000 0.000  0
#> GSM559400     2   0.341      0.796 0.124 0.876  0
#> GSM559402     1   0.000      0.991 1.000 0.000  0
#> GSM559403     1   0.000      0.991 1.000 0.000  0
#> GSM559404     1   0.000      0.991 1.000 0.000  0
#> GSM559405     1   0.000      0.991 1.000 0.000  0
#> GSM559406     1   0.000      0.991 1.000 0.000  0
#> GSM559407     1   0.000      0.991 1.000 0.000  0
#> GSM559408     1   0.000      0.991 1.000 0.000  0
#> GSM559409     1   0.000      0.991 1.000 0.000  0
#> GSM559410     1   0.000      0.991 1.000 0.000  0
#> GSM559411     1   0.000      0.991 1.000 0.000  0
#> GSM559412     1   0.000      0.991 1.000 0.000  0
#> GSM559413     1   0.000      0.991 1.000 0.000  0
#> GSM559415     1   0.000      0.991 1.000 0.000  0
#> GSM559416     1   0.000      0.991 1.000 0.000  0
#> GSM559417     1   0.000      0.991 1.000 0.000  0
#> GSM559418     1   0.000      0.991 1.000 0.000  0
#> GSM559419     1   0.000      0.991 1.000 0.000  0
#> GSM559420     1   0.000      0.991 1.000 0.000  0
#> GSM559421     2   0.000      0.931 0.000 1.000  0
#> GSM559423     2   0.000      0.931 0.000 1.000  0
#> GSM559425     2   0.000      0.931 0.000 1.000  0
#> GSM559426     2   0.000      0.931 0.000 1.000  0
#> GSM559427     2   0.000      0.931 0.000 1.000  0
#> GSM559428     1   0.116      0.964 0.972 0.028  0
#> GSM559429     2   0.000      0.931 0.000 1.000  0
#> GSM559430     2   0.000      0.931 0.000 1.000  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> GSM559383     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM559387     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM559391     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM559395     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM559397     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM559401     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM559414     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM559422     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM559424     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM559431     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM559432     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM559381     1   0.000      0.946 1.000 0.000  0 0.000
#> GSM559382     4   0.422      0.859 0.100 0.076  0 0.824
#> GSM559384     1   0.000      0.946 1.000 0.000  0 0.000
#> GSM559385     1   0.000      0.946 1.000 0.000  0 0.000
#> GSM559386     4   0.241      0.884 0.104 0.000  0 0.896
#> GSM559388     4   0.518      0.817 0.120 0.120  0 0.760
#> GSM559389     1   0.000      0.946 1.000 0.000  0 0.000
#> GSM559390     4   0.000      0.887 0.000 0.000  0 1.000
#> GSM559392     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM559393     1   0.000      0.946 1.000 0.000  0 0.000
#> GSM559394     1   0.000      0.946 1.000 0.000  0 0.000
#> GSM559396     1   0.000      0.946 1.000 0.000  0 0.000
#> GSM559398     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM559399     1   0.000      0.946 1.000 0.000  0 0.000
#> GSM559400     4   0.234      0.884 0.100 0.000  0 0.900
#> GSM559402     1   0.000      0.946 1.000 0.000  0 0.000
#> GSM559403     1   0.000      0.946 1.000 0.000  0 0.000
#> GSM559404     1   0.000      0.946 1.000 0.000  0 0.000
#> GSM559405     1   0.000      0.946 1.000 0.000  0 0.000
#> GSM559406     4   0.000      0.887 0.000 0.000  0 1.000
#> GSM559407     1   0.121      0.929 0.960 0.000  0 0.040
#> GSM559408     1   0.234      0.898 0.900 0.000  0 0.100
#> GSM559409     1   0.234      0.898 0.900 0.000  0 0.100
#> GSM559410     1   0.234      0.898 0.900 0.000  0 0.100
#> GSM559411     1   0.234      0.898 0.900 0.000  0 0.100
#> GSM559412     1   0.234      0.898 0.900 0.000  0 0.100
#> GSM559413     1   0.234      0.898 0.900 0.000  0 0.100
#> GSM559415     1   0.000      0.946 1.000 0.000  0 0.000
#> GSM559416     4   0.000      0.887 0.000 0.000  0 1.000
#> GSM559417     4   0.000      0.887 0.000 0.000  0 1.000
#> GSM559418     1   0.000      0.946 1.000 0.000  0 0.000
#> GSM559419     1   0.496      0.215 0.552 0.000  0 0.448
#> GSM559420     1   0.000      0.946 1.000 0.000  0 0.000
#> GSM559421     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM559423     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM559425     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM559426     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM559427     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM559428     4   0.433      0.767 0.244 0.008  0 0.748
#> GSM559429     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM559430     2   0.000      1.000 0.000 1.000  0 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
#> GSM559383     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559387     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559391     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559395     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559397     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559401     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559414     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559422     5  0.3452      1.000 0.000 0.000 0.244 0.000 0.756
#> GSM559424     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559431     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM559432     5  0.3452      1.000 0.000 0.000 0.244 0.000 0.756
#> GSM559381     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> GSM559382     4  0.5148      0.787 0.100 0.084 0.000 0.752 0.064
#> GSM559384     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> GSM559385     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> GSM559386     4  0.2669      0.826 0.104 0.000 0.000 0.876 0.020
#> GSM559388     4  0.6123      0.717 0.100 0.156 0.000 0.668 0.076
#> GSM559389     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> GSM559390     4  0.0000      0.832 0.000 0.000 0.000 1.000 0.000
#> GSM559392     2  0.1270      0.922 0.000 0.948 0.000 0.000 0.052
#> GSM559393     1  0.0609      0.931 0.980 0.000 0.000 0.000 0.020
#> GSM559394     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> GSM559396     1  0.0162      0.940 0.996 0.000 0.000 0.000 0.004
#> GSM559398     2  0.0162      0.941 0.000 0.996 0.000 0.000 0.004
#> GSM559399     1  0.0162      0.940 0.996 0.000 0.000 0.004 0.000
#> GSM559400     4  0.2707      0.827 0.100 0.000 0.000 0.876 0.024
#> GSM559402     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> GSM559403     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> GSM559404     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> GSM559405     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> GSM559406     4  0.0162      0.831 0.004 0.000 0.000 0.996 0.000
#> GSM559407     1  0.1043      0.925 0.960 0.000 0.000 0.040 0.000
#> GSM559408     1  0.2280      0.882 0.880 0.000 0.000 0.120 0.000
#> GSM559409     1  0.2329      0.880 0.876 0.000 0.000 0.124 0.000
#> GSM559410     1  0.2020      0.893 0.900 0.000 0.000 0.100 0.000
#> GSM559411     1  0.2020      0.893 0.900 0.000 0.000 0.100 0.000
#> GSM559412     1  0.2280      0.882 0.880 0.000 0.000 0.120 0.000
#> GSM559413     1  0.2280      0.882 0.880 0.000 0.000 0.120 0.000
#> GSM559415     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> GSM559416     4  0.0000      0.832 0.000 0.000 0.000 1.000 0.000
#> GSM559417     4  0.0000      0.832 0.000 0.000 0.000 1.000 0.000
#> GSM559418     1  0.0162      0.940 0.996 0.000 0.000 0.004 0.000
#> GSM559419     1  0.4278      0.240 0.548 0.000 0.000 0.452 0.000
#> GSM559420     1  0.0162      0.940 0.996 0.000 0.000 0.004 0.000
#> GSM559421     2  0.1270      0.922 0.000 0.948 0.000 0.000 0.052
#> GSM559423     2  0.1851      0.910 0.000 0.912 0.000 0.000 0.088
#> GSM559425     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM559426     2  0.2690      0.855 0.000 0.844 0.000 0.000 0.156
#> GSM559427     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM559428     4  0.5525      0.702 0.124 0.000 0.000 0.636 0.240
#> GSM559429     2  0.3039      0.829 0.000 0.808 0.000 0.000 0.192
#> GSM559430     2  0.0000      0.942 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
#> GSM559383     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559387     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559391     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559395     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559397     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559401     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559414     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559422     5  0.1610     1.0000 0.000 0.000 0.084 0.000 0.916 0.000
#> GSM559424     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559431     2  0.0547     0.8849 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM559432     5  0.1610     1.0000 0.000 0.000 0.084 0.000 0.916 0.000
#> GSM559381     1  0.0000     0.8950 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559382     4  0.5855     0.2364 0.072 0.080 0.000 0.616 0.004 0.228
#> GSM559384     1  0.0000     0.8950 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559385     1  0.0000     0.8950 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559386     4  0.3315     0.5821 0.076 0.000 0.000 0.820 0.000 0.104
#> GSM559388     6  0.6823     0.0976 0.064 0.156 0.000 0.384 0.004 0.392
#> GSM559389     1  0.0000     0.8950 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559390     4  0.0000     0.7120 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM559392     2  0.2964     0.7827 0.000 0.792 0.000 0.000 0.004 0.204
#> GSM559393     1  0.2631     0.7720 0.820 0.000 0.000 0.000 0.000 0.180
#> GSM559394     1  0.0000     0.8950 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559396     1  0.2389     0.8608 0.888 0.000 0.000 0.052 0.060 0.000
#> GSM559398     2  0.1411     0.8677 0.000 0.936 0.000 0.000 0.004 0.060
#> GSM559399     1  0.1957     0.8479 0.888 0.000 0.000 0.112 0.000 0.000
#> GSM559400     4  0.4176     0.4789 0.064 0.000 0.000 0.716 0.000 0.220
#> GSM559402     1  0.0937     0.8854 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM559403     1  0.0000     0.8950 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559404     1  0.0000     0.8950 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559405     1  0.0000     0.8950 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559406     4  0.1957     0.5864 0.112 0.000 0.000 0.888 0.000 0.000
#> GSM559407     1  0.0713     0.8901 0.972 0.000 0.000 0.028 0.000 0.000
#> GSM559408     1  0.2562     0.8207 0.828 0.000 0.000 0.172 0.000 0.000
#> GSM559409     1  0.2793     0.8113 0.800 0.000 0.000 0.200 0.000 0.000
#> GSM559410     1  0.2048     0.8531 0.880 0.000 0.000 0.120 0.000 0.000
#> GSM559411     1  0.2997     0.8489 0.844 0.000 0.000 0.096 0.060 0.000
#> GSM559412     1  0.2562     0.8207 0.828 0.000 0.000 0.172 0.000 0.000
#> GSM559413     1  0.3763     0.7865 0.768 0.000 0.000 0.172 0.060 0.000
#> GSM559415     1  0.0146     0.8944 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM559416     4  0.0000     0.7120 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM559417     4  0.0146     0.7105 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM559418     1  0.1957     0.8479 0.888 0.000 0.000 0.112 0.000 0.000
#> GSM559419     1  0.4471     0.2798 0.500 0.000 0.000 0.472 0.028 0.000
#> GSM559420     1  0.1957     0.8479 0.888 0.000 0.000 0.112 0.000 0.000
#> GSM559421     2  0.2738     0.8042 0.000 0.820 0.000 0.000 0.004 0.176
#> GSM559423     2  0.2838     0.8176 0.000 0.808 0.000 0.000 0.004 0.188
#> GSM559425     2  0.0547     0.8849 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM559426     2  0.2454     0.7685 0.000 0.840 0.000 0.000 0.000 0.160
#> GSM559427     2  0.0547     0.8849 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM559428     6  0.4972     0.2069 0.080 0.000 0.000 0.352 0.000 0.568
#> GSM559429     6  0.2823     0.1437 0.000 0.204 0.000 0.000 0.000 0.796
#> GSM559430     2  0.0000     0.8844 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-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 disease.state(p) k
#> SD:pam 52         1.99e-10 2
#> SD:pam 51         1.24e-10 3
#> SD:pam 51         6.63e-10 4
#> SD:pam 51         2.87e-09 5
#> SD:pam 46         2.54e-08 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 21167 rows and 52 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.981       0.987         0.3279 0.683   0.683
#> 3 3 0.687           0.819       0.911         0.8960 0.704   0.567
#> 4 4 0.703           0.562       0.820         0.1283 0.873   0.695
#> 5 5 0.707           0.772       0.808         0.0624 0.910   0.715
#> 6 6 0.715           0.707       0.818         0.0400 0.955   0.820

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
#> GSM559383     2  0.0000      1.000 0.000 1.000
#> GSM559387     2  0.0000      1.000 0.000 1.000
#> GSM559391     2  0.0000      1.000 0.000 1.000
#> GSM559395     2  0.0000      1.000 0.000 1.000
#> GSM559397     2  0.0000      1.000 0.000 1.000
#> GSM559401     2  0.0000      1.000 0.000 1.000
#> GSM559414     2  0.0000      1.000 0.000 1.000
#> GSM559422     2  0.0000      1.000 0.000 1.000
#> GSM559424     2  0.0000      1.000 0.000 1.000
#> GSM559431     1  0.4815      0.908 0.896 0.104
#> GSM559432     2  0.0000      1.000 0.000 1.000
#> GSM559381     1  0.0000      0.984 1.000 0.000
#> GSM559382     1  0.1843      0.976 0.972 0.028
#> GSM559384     1  0.0000      0.984 1.000 0.000
#> GSM559385     1  0.0000      0.984 1.000 0.000
#> GSM559386     1  0.1184      0.980 0.984 0.016
#> GSM559388     1  0.1843      0.976 0.972 0.028
#> GSM559389     1  0.0000      0.984 1.000 0.000
#> GSM559390     1  0.0000      0.984 1.000 0.000
#> GSM559392     1  0.1843      0.976 0.972 0.028
#> GSM559393     1  0.0000      0.984 1.000 0.000
#> GSM559394     1  0.0000      0.984 1.000 0.000
#> GSM559396     1  0.2236      0.970 0.964 0.036
#> GSM559398     1  0.1843      0.976 0.972 0.028
#> GSM559399     1  0.0000      0.984 1.000 0.000
#> GSM559400     1  0.1843      0.976 0.972 0.028
#> GSM559402     1  0.0000      0.984 1.000 0.000
#> GSM559403     1  0.0000      0.984 1.000 0.000
#> GSM559404     1  0.0000      0.984 1.000 0.000
#> GSM559405     1  0.0000      0.984 1.000 0.000
#> GSM559406     1  0.0000      0.984 1.000 0.000
#> GSM559407     1  0.0000      0.984 1.000 0.000
#> GSM559408     1  0.0000      0.984 1.000 0.000
#> GSM559409     1  0.0000      0.984 1.000 0.000
#> GSM559410     1  0.0000      0.984 1.000 0.000
#> GSM559411     1  0.0000      0.984 1.000 0.000
#> GSM559412     1  0.0000      0.984 1.000 0.000
#> GSM559413     1  0.0000      0.984 1.000 0.000
#> GSM559415     1  0.0000      0.984 1.000 0.000
#> GSM559416     1  0.0000      0.984 1.000 0.000
#> GSM559417     1  0.0000      0.984 1.000 0.000
#> GSM559418     1  0.0672      0.982 0.992 0.008
#> GSM559419     1  0.0000      0.984 1.000 0.000
#> GSM559420     1  0.0000      0.984 1.000 0.000
#> GSM559421     1  0.1843      0.976 0.972 0.028
#> GSM559423     1  0.1843      0.976 0.972 0.028
#> GSM559425     1  0.1843      0.976 0.972 0.028
#> GSM559426     1  0.1843      0.976 0.972 0.028
#> GSM559427     1  0.1843      0.976 0.972 0.028
#> GSM559428     1  0.4815      0.908 0.896 0.104
#> GSM559429     1  0.4815      0.908 0.896 0.104
#> GSM559430     1  0.1843      0.976 0.972 0.028

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM559383     3  0.0000      0.994 0.000 0.000 1.000
#> GSM559387     3  0.0000      0.994 0.000 0.000 1.000
#> GSM559391     3  0.0000      0.994 0.000 0.000 1.000
#> GSM559395     3  0.0000      0.994 0.000 0.000 1.000
#> GSM559397     3  0.0000      0.994 0.000 0.000 1.000
#> GSM559401     3  0.0000      0.994 0.000 0.000 1.000
#> GSM559414     3  0.0000      0.994 0.000 0.000 1.000
#> GSM559422     3  0.0000      0.994 0.000 0.000 1.000
#> GSM559424     3  0.0000      0.994 0.000 0.000 1.000
#> GSM559431     2  0.0000      0.910 0.000 1.000 0.000
#> GSM559432     3  0.1860      0.944 0.000 0.052 0.948
#> GSM559381     1  0.1529      0.849 0.960 0.040 0.000
#> GSM559382     2  0.0424      0.905 0.008 0.992 0.000
#> GSM559384     1  0.2537      0.843 0.920 0.080 0.000
#> GSM559385     1  0.5016      0.622 0.760 0.240 0.000
#> GSM559386     2  0.6154      0.200 0.408 0.592 0.000
#> GSM559388     2  0.0000      0.910 0.000 1.000 0.000
#> GSM559389     1  0.0000      0.843 1.000 0.000 0.000
#> GSM559390     1  0.4842      0.750 0.776 0.224 0.000
#> GSM559392     2  0.0000      0.910 0.000 1.000 0.000
#> GSM559393     1  0.5016      0.622 0.760 0.240 0.000
#> GSM559394     1  0.5016      0.622 0.760 0.240 0.000
#> GSM559396     1  0.6180      0.589 0.660 0.332 0.008
#> GSM559398     2  0.0000      0.910 0.000 1.000 0.000
#> GSM559399     1  0.2261      0.846 0.932 0.068 0.000
#> GSM559400     1  0.6280      0.266 0.540 0.460 0.000
#> GSM559402     1  0.0237      0.845 0.996 0.004 0.000
#> GSM559403     1  0.0000      0.843 1.000 0.000 0.000
#> GSM559404     1  0.2261      0.829 0.932 0.068 0.000
#> GSM559405     1  0.0000      0.843 1.000 0.000 0.000
#> GSM559406     1  0.4842      0.750 0.776 0.224 0.000
#> GSM559407     1  0.0237      0.845 0.996 0.004 0.000
#> GSM559408     1  0.0592      0.846 0.988 0.012 0.000
#> GSM559409     1  0.1643      0.850 0.956 0.044 0.000
#> GSM559410     1  0.0000      0.843 1.000 0.000 0.000
#> GSM559411     1  0.4842      0.750 0.776 0.224 0.000
#> GSM559412     1  0.3116      0.833 0.892 0.108 0.000
#> GSM559413     1  0.4842      0.750 0.776 0.224 0.000
#> GSM559415     1  0.0000      0.843 1.000 0.000 0.000
#> GSM559416     1  0.0747      0.847 0.984 0.016 0.000
#> GSM559417     1  0.2796      0.840 0.908 0.092 0.000
#> GSM559418     1  0.6180      0.376 0.584 0.416 0.000
#> GSM559419     1  0.2261      0.847 0.932 0.068 0.000
#> GSM559420     1  0.4452      0.778 0.808 0.192 0.000
#> GSM559421     2  0.0000      0.910 0.000 1.000 0.000
#> GSM559423     2  0.0000      0.910 0.000 1.000 0.000
#> GSM559425     2  0.0000      0.910 0.000 1.000 0.000
#> GSM559426     2  0.0000      0.910 0.000 1.000 0.000
#> GSM559427     2  0.0000      0.910 0.000 1.000 0.000
#> GSM559428     2  0.5016      0.626 0.240 0.760 0.000
#> GSM559429     2  0.5016      0.626 0.240 0.760 0.000
#> GSM559430     2  0.0000      0.910 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
#> GSM559383     3  0.0000     0.9252 0.000 0.000 1.000 0.000
#> GSM559387     3  0.0000     0.9252 0.000 0.000 1.000 0.000
#> GSM559391     3  0.0000     0.9252 0.000 0.000 1.000 0.000
#> GSM559395     3  0.0000     0.9252 0.000 0.000 1.000 0.000
#> GSM559397     3  0.0000     0.9252 0.000 0.000 1.000 0.000
#> GSM559401     3  0.3610     0.8603 0.000 0.000 0.800 0.200
#> GSM559414     3  0.0000     0.9252 0.000 0.000 1.000 0.000
#> GSM559422     3  0.4454     0.8099 0.000 0.000 0.692 0.308
#> GSM559424     3  0.2053     0.8779 0.072 0.000 0.924 0.004
#> GSM559431     2  0.0188     0.9558 0.004 0.996 0.000 0.000
#> GSM559432     3  0.4855     0.7529 0.000 0.000 0.600 0.400
#> GSM559381     1  0.4981    -0.1815 0.536 0.000 0.000 0.464
#> GSM559382     2  0.0817     0.9444 0.024 0.976 0.000 0.000
#> GSM559384     1  0.4866     0.0398 0.596 0.000 0.000 0.404
#> GSM559385     4  0.4477     0.9014 0.312 0.000 0.000 0.688
#> GSM559386     1  0.7654    -0.2054 0.464 0.252 0.000 0.284
#> GSM559388     2  0.0188     0.9553 0.000 0.996 0.000 0.004
#> GSM559389     1  0.4992    -0.2295 0.524 0.000 0.000 0.476
#> GSM559390     1  0.1305     0.4545 0.960 0.036 0.000 0.004
#> GSM559392     2  0.0000     0.9573 0.000 1.000 0.000 0.000
#> GSM559393     4  0.4477     0.9014 0.312 0.000 0.000 0.688
#> GSM559394     4  0.4477     0.9014 0.312 0.000 0.000 0.688
#> GSM559396     1  0.3765     0.2958 0.812 0.180 0.004 0.004
#> GSM559398     2  0.0000     0.9573 0.000 1.000 0.000 0.000
#> GSM559399     1  0.4624     0.1768 0.660 0.000 0.000 0.340
#> GSM559400     2  0.5088     0.4712 0.424 0.572 0.000 0.004
#> GSM559402     1  0.4624     0.1783 0.660 0.000 0.000 0.340
#> GSM559403     1  0.5000    -0.3227 0.504 0.000 0.000 0.496
#> GSM559404     4  0.4877     0.6389 0.408 0.000 0.000 0.592
#> GSM559405     1  0.4992    -0.2295 0.524 0.000 0.000 0.476
#> GSM559406     1  0.1305     0.4545 0.960 0.036 0.000 0.004
#> GSM559407     1  0.4564     0.2043 0.672 0.000 0.000 0.328
#> GSM559408     1  0.2704     0.4453 0.876 0.000 0.000 0.124
#> GSM559409     1  0.3764     0.3834 0.784 0.000 0.000 0.216
#> GSM559410     1  0.4661     0.1535 0.652 0.000 0.000 0.348
#> GSM559411     1  0.1305     0.4567 0.960 0.036 0.000 0.004
#> GSM559412     1  0.1211     0.4682 0.960 0.000 0.000 0.040
#> GSM559413     1  0.0469     0.4634 0.988 0.000 0.000 0.012
#> GSM559415     1  0.4981    -0.2024 0.536 0.000 0.000 0.464
#> GSM559416     1  0.3243     0.4390 0.876 0.036 0.000 0.088
#> GSM559417     1  0.3243     0.4390 0.876 0.036 0.000 0.088
#> GSM559418     1  0.6709    -0.2617 0.508 0.092 0.000 0.400
#> GSM559419     1  0.3731     0.4387 0.844 0.036 0.000 0.120
#> GSM559420     1  0.4546     0.3284 0.732 0.012 0.000 0.256
#> GSM559421     2  0.0000     0.9573 0.000 1.000 0.000 0.000
#> GSM559423     2  0.0000     0.9573 0.000 1.000 0.000 0.000
#> GSM559425     2  0.0000     0.9573 0.000 1.000 0.000 0.000
#> GSM559426     2  0.0000     0.9573 0.000 1.000 0.000 0.000
#> GSM559427     2  0.0000     0.9573 0.000 1.000 0.000 0.000
#> GSM559428     2  0.1792     0.9075 0.068 0.932 0.000 0.000
#> GSM559429     2  0.0469     0.9522 0.012 0.988 0.000 0.000
#> GSM559430     2  0.0000     0.9573 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
#> GSM559383     3  0.0000      0.880 0.000 0.000 1.000 0.000 0.000
#> GSM559387     3  0.0000      0.880 0.000 0.000 1.000 0.000 0.000
#> GSM559391     3  0.0404      0.877 0.000 0.000 0.988 0.012 0.000
#> GSM559395     3  0.0000      0.880 0.000 0.000 1.000 0.000 0.000
#> GSM559397     3  0.0000      0.880 0.000 0.000 1.000 0.000 0.000
#> GSM559401     3  0.5484      0.716 0.000 0.000 0.640 0.240 0.120
#> GSM559414     3  0.0000      0.880 0.000 0.000 1.000 0.000 0.000
#> GSM559422     3  0.5888      0.678 0.000 0.000 0.576 0.288 0.136
#> GSM559424     3  0.1043      0.865 0.000 0.000 0.960 0.040 0.000
#> GSM559431     2  0.1671      0.882 0.000 0.924 0.000 0.000 0.076
#> GSM559432     3  0.6309      0.628 0.000 0.000 0.520 0.288 0.192
#> GSM559381     1  0.0324      0.815 0.992 0.004 0.000 0.000 0.004
#> GSM559382     2  0.3130      0.785 0.096 0.856 0.000 0.048 0.000
#> GSM559384     1  0.0566      0.812 0.984 0.000 0.000 0.012 0.004
#> GSM559385     5  0.4114      0.968 0.376 0.000 0.000 0.000 0.624
#> GSM559386     1  0.3132      0.587 0.820 0.172 0.000 0.000 0.008
#> GSM559388     2  0.0510      0.886 0.016 0.984 0.000 0.000 0.000
#> GSM559389     1  0.0451      0.811 0.988 0.004 0.000 0.000 0.008
#> GSM559390     4  0.5971      0.804 0.396 0.000 0.000 0.492 0.112
#> GSM559392     2  0.0000      0.890 0.000 1.000 0.000 0.000 0.000
#> GSM559393     5  0.4251      0.964 0.372 0.004 0.000 0.000 0.624
#> GSM559394     5  0.4114      0.968 0.376 0.000 0.000 0.000 0.624
#> GSM559396     4  0.5161      0.697 0.260 0.044 0.000 0.676 0.020
#> GSM559398     2  0.1410      0.884 0.000 0.940 0.000 0.000 0.060
#> GSM559399     1  0.0451      0.814 0.988 0.000 0.000 0.008 0.004
#> GSM559400     2  0.6230      0.328 0.008 0.480 0.000 0.400 0.112
#> GSM559402     1  0.1195      0.807 0.960 0.000 0.000 0.012 0.028
#> GSM559403     1  0.1792      0.720 0.916 0.000 0.000 0.000 0.084
#> GSM559404     5  0.4557      0.905 0.404 0.000 0.000 0.012 0.584
#> GSM559405     1  0.0162      0.813 0.996 0.000 0.000 0.000 0.004
#> GSM559406     4  0.4138      0.812 0.384 0.000 0.000 0.616 0.000
#> GSM559407     1  0.1195      0.807 0.960 0.000 0.000 0.012 0.028
#> GSM559408     1  0.3695      0.597 0.800 0.000 0.000 0.164 0.036
#> GSM559409     1  0.3772      0.597 0.792 0.000 0.000 0.172 0.036
#> GSM559410     1  0.0451      0.814 0.988 0.000 0.000 0.008 0.004
#> GSM559411     4  0.4242      0.796 0.428 0.000 0.000 0.572 0.000
#> GSM559412     1  0.3724      0.535 0.776 0.000 0.000 0.204 0.020
#> GSM559413     1  0.4390     -0.457 0.568 0.000 0.000 0.428 0.004
#> GSM559415     1  0.0486      0.814 0.988 0.004 0.000 0.004 0.004
#> GSM559416     4  0.5338      0.839 0.400 0.000 0.000 0.544 0.056
#> GSM559417     4  0.5345      0.839 0.404 0.000 0.000 0.540 0.056
#> GSM559418     1  0.0992      0.799 0.968 0.024 0.000 0.000 0.008
#> GSM559419     4  0.5106      0.729 0.456 0.000 0.000 0.508 0.036
#> GSM559420     1  0.3922      0.569 0.780 0.000 0.000 0.180 0.040
#> GSM559421     2  0.0000      0.890 0.000 1.000 0.000 0.000 0.000
#> GSM559423     2  0.0000      0.890 0.000 1.000 0.000 0.000 0.000
#> GSM559425     2  0.1410      0.884 0.000 0.940 0.000 0.000 0.060
#> GSM559426     2  0.0162      0.889 0.004 0.996 0.000 0.000 0.000
#> GSM559427     2  0.1410      0.884 0.000 0.940 0.000 0.000 0.060
#> GSM559428     2  0.4735      0.639 0.012 0.668 0.000 0.300 0.020
#> GSM559429     2  0.3357      0.811 0.012 0.836 0.000 0.136 0.016
#> GSM559430     2  0.1270      0.886 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
#> GSM559383     3  0.0547   0.836783 0.000 0.000 0.980 0.000 0.020 0.000
#> GSM559387     3  0.0000   0.843048 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559391     3  0.3023   0.748649 0.000 0.000 0.828 0.140 0.032 0.000
#> GSM559395     3  0.0363   0.836157 0.000 0.000 0.988 0.000 0.012 0.000
#> GSM559397     3  0.0000   0.843048 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559401     3  0.3797  -0.222702 0.000 0.000 0.580 0.000 0.420 0.000
#> GSM559414     3  0.0000   0.843048 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559422     5  0.3288   1.000000 0.000 0.000 0.276 0.000 0.724 0.000
#> GSM559424     3  0.3023   0.748649 0.000 0.000 0.828 0.140 0.032 0.000
#> GSM559431     2  0.4462   0.797170 0.000 0.712 0.000 0.152 0.136 0.000
#> GSM559432     5  0.3288   1.000000 0.000 0.000 0.276 0.000 0.724 0.000
#> GSM559381     1  0.0000   0.742473 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559382     2  0.1082   0.868721 0.000 0.956 0.000 0.040 0.000 0.004
#> GSM559384     1  0.1644   0.736078 0.932 0.000 0.000 0.000 0.040 0.028
#> GSM559385     6  0.2491   0.984436 0.164 0.000 0.000 0.000 0.000 0.836
#> GSM559386     1  0.2320   0.622842 0.864 0.132 0.000 0.000 0.000 0.004
#> GSM559388     2  0.0000   0.878280 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559389     1  0.0363   0.742446 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM559390     4  0.5510   0.732402 0.292 0.000 0.000 0.584 0.020 0.104
#> GSM559392     2  0.0000   0.878280 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559393     6  0.2664   0.975428 0.184 0.000 0.000 0.000 0.000 0.816
#> GSM559394     6  0.2562   0.985542 0.172 0.000 0.000 0.000 0.000 0.828
#> GSM559396     4  0.3699   0.624829 0.160 0.000 0.000 0.788 0.040 0.012
#> GSM559398     2  0.2300   0.851415 0.000 0.856 0.000 0.144 0.000 0.000
#> GSM559399     1  0.0260   0.742631 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM559400     2  0.5990   0.463123 0.000 0.576 0.000 0.252 0.052 0.120
#> GSM559402     1  0.0551   0.741108 0.984 0.000 0.000 0.004 0.004 0.008
#> GSM559403     1  0.2416   0.610173 0.844 0.000 0.000 0.000 0.000 0.156
#> GSM559404     6  0.2527   0.983803 0.168 0.000 0.000 0.000 0.000 0.832
#> GSM559405     1  0.0547   0.741421 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM559406     1  0.4468   0.000782 0.560 0.000 0.000 0.408 0.032 0.000
#> GSM559407     1  0.1622   0.727065 0.940 0.000 0.000 0.028 0.016 0.016
#> GSM559408     1  0.5073   0.502179 0.692 0.000 0.000 0.180 0.084 0.044
#> GSM559409     1  0.4915   0.530966 0.712 0.000 0.000 0.160 0.084 0.044
#> GSM559410     1  0.0632   0.740726 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM559411     4  0.4532   0.270860 0.468 0.000 0.000 0.500 0.032 0.000
#> GSM559412     1  0.5330   0.414606 0.648 0.000 0.000 0.228 0.084 0.040
#> GSM559413     1  0.4709   0.178045 0.596 0.000 0.000 0.352 0.048 0.004
#> GSM559415     1  0.0632   0.740726 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM559416     4  0.4096   0.751258 0.304 0.000 0.000 0.672 0.008 0.016
#> GSM559417     4  0.4717   0.759303 0.308 0.000 0.000 0.632 0.008 0.052
#> GSM559418     1  0.0993   0.735942 0.964 0.012 0.000 0.000 0.000 0.024
#> GSM559419     1  0.5535  -0.158291 0.516 0.000 0.000 0.392 0.048 0.044
#> GSM559420     1  0.4739   0.553571 0.732 0.000 0.000 0.140 0.084 0.044
#> GSM559421     2  0.0000   0.878280 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559423     2  0.0000   0.878280 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559425     2  0.2553   0.848100 0.000 0.848 0.000 0.144 0.008 0.000
#> GSM559426     2  0.0820   0.871008 0.016 0.972 0.000 0.000 0.000 0.012
#> GSM559427     2  0.2553   0.848100 0.000 0.848 0.000 0.144 0.008 0.000
#> GSM559428     2  0.2890   0.822456 0.004 0.844 0.000 0.024 0.128 0.000
#> GSM559429     2  0.2667   0.826717 0.000 0.852 0.000 0.020 0.128 0.000
#> GSM559430     2  0.2300   0.851415 0.000 0.856 0.000 0.144 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-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 disease.state(p) k
#> SD:mclust 52         1.99e-10 2
#> SD:mclust 49         3.24e-10 3
#> SD:mclust 27         9.27e-06 4
#> SD:mclust 50         4.77e-09 5
#> SD:mclust 45         1.75e-07 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 21167 rows and 52 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 0.422           0.782       0.858         0.4516 0.527   0.527
#> 3 3 0.998           0.948       0.978         0.3760 0.687   0.490
#> 4 4 0.730           0.769       0.885         0.1802 0.855   0.638
#> 5 5 0.700           0.638       0.793         0.0693 0.922   0.729
#> 6 6 0.716           0.631       0.786         0.0509 0.847   0.451

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
#> GSM559383     1   0.000      0.752 1.000 0.000
#> GSM559387     1   0.000      0.752 1.000 0.000
#> GSM559391     1   0.000      0.752 1.000 0.000
#> GSM559395     1   0.000      0.752 1.000 0.000
#> GSM559397     1   0.000      0.752 1.000 0.000
#> GSM559401     1   0.000      0.752 1.000 0.000
#> GSM559414     1   0.000      0.752 1.000 0.000
#> GSM559422     1   0.000      0.752 1.000 0.000
#> GSM559424     1   0.000      0.752 1.000 0.000
#> GSM559431     2   0.327      0.883 0.060 0.940
#> GSM559432     1   0.999     -0.205 0.516 0.484
#> GSM559381     1   0.999      0.459 0.516 0.484
#> GSM559382     2   0.000      0.947 0.000 1.000
#> GSM559384     1   0.738      0.832 0.792 0.208
#> GSM559385     1   0.760      0.828 0.780 0.220
#> GSM559386     2   0.000      0.947 0.000 1.000
#> GSM559388     2   0.000      0.947 0.000 1.000
#> GSM559389     1   0.981      0.602 0.580 0.420
#> GSM559390     1   0.808      0.813 0.752 0.248
#> GSM559392     2   0.000      0.947 0.000 1.000
#> GSM559393     2   0.118      0.931 0.016 0.984
#> GSM559394     1   0.971      0.637 0.600 0.400
#> GSM559396     1   0.697      0.829 0.812 0.188
#> GSM559398     2   0.000      0.947 0.000 1.000
#> GSM559399     1   0.997      0.500 0.532 0.468
#> GSM559400     2   0.000      0.947 0.000 1.000
#> GSM559402     1   0.909      0.747 0.676 0.324
#> GSM559403     1   0.855      0.790 0.720 0.280
#> GSM559404     1   0.697      0.829 0.812 0.188
#> GSM559405     1   0.760      0.828 0.780 0.220
#> GSM559406     1   0.730      0.831 0.796 0.204
#> GSM559407     1   0.753      0.830 0.784 0.216
#> GSM559408     1   0.738      0.832 0.792 0.208
#> GSM559409     1   0.738      0.832 0.792 0.208
#> GSM559410     1   0.876      0.776 0.704 0.296
#> GSM559411     1   0.738      0.832 0.792 0.208
#> GSM559412     1   0.738      0.832 0.792 0.208
#> GSM559413     1   0.730      0.831 0.796 0.204
#> GSM559415     2   0.992     -0.305 0.448 0.552
#> GSM559416     1   0.921      0.737 0.664 0.336
#> GSM559417     2   0.402      0.847 0.080 0.920
#> GSM559418     2   0.000      0.947 0.000 1.000
#> GSM559419     1   0.861      0.788 0.716 0.284
#> GSM559420     1   0.745      0.831 0.788 0.212
#> GSM559421     2   0.000      0.947 0.000 1.000
#> GSM559423     2   0.000      0.947 0.000 1.000
#> GSM559425     2   0.000      0.947 0.000 1.000
#> GSM559426     2   0.000      0.947 0.000 1.000
#> GSM559427     2   0.000      0.947 0.000 1.000
#> GSM559428     2   0.388      0.863 0.076 0.924
#> GSM559429     2   0.000      0.947 0.000 1.000
#> GSM559430     2   0.000      0.947 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
#> GSM559383     3   0.000      1.000 0.000 0.000 1.000
#> GSM559387     3   0.000      1.000 0.000 0.000 1.000
#> GSM559391     3   0.000      1.000 0.000 0.000 1.000
#> GSM559395     3   0.000      1.000 0.000 0.000 1.000
#> GSM559397     3   0.000      1.000 0.000 0.000 1.000
#> GSM559401     3   0.000      1.000 0.000 0.000 1.000
#> GSM559414     3   0.000      1.000 0.000 0.000 1.000
#> GSM559422     3   0.000      1.000 0.000 0.000 1.000
#> GSM559424     3   0.000      1.000 0.000 0.000 1.000
#> GSM559431     2   0.000      0.991 0.000 1.000 0.000
#> GSM559432     3   0.000      1.000 0.000 0.000 1.000
#> GSM559381     1   0.000      0.961 1.000 0.000 0.000
#> GSM559382     2   0.000      0.991 0.000 1.000 0.000
#> GSM559384     1   0.000      0.961 1.000 0.000 0.000
#> GSM559385     1   0.000      0.961 1.000 0.000 0.000
#> GSM559386     1   0.522      0.664 0.740 0.260 0.000
#> GSM559388     2   0.000      0.991 0.000 1.000 0.000
#> GSM559389     1   0.000      0.961 1.000 0.000 0.000
#> GSM559390     1   0.000      0.961 1.000 0.000 0.000
#> GSM559392     2   0.000      0.991 0.000 1.000 0.000
#> GSM559393     1   0.382      0.821 0.852 0.148 0.000
#> GSM559394     1   0.000      0.961 1.000 0.000 0.000
#> GSM559396     1   0.288      0.875 0.904 0.000 0.096
#> GSM559398     2   0.000      0.991 0.000 1.000 0.000
#> GSM559399     1   0.000      0.961 1.000 0.000 0.000
#> GSM559400     2   0.210      0.927 0.052 0.944 0.004
#> GSM559402     1   0.000      0.961 1.000 0.000 0.000
#> GSM559403     1   0.000      0.961 1.000 0.000 0.000
#> GSM559404     1   0.000      0.961 1.000 0.000 0.000
#> GSM559405     1   0.000      0.961 1.000 0.000 0.000
#> GSM559406     1   0.000      0.961 1.000 0.000 0.000
#> GSM559407     1   0.000      0.961 1.000 0.000 0.000
#> GSM559408     1   0.000      0.961 1.000 0.000 0.000
#> GSM559409     1   0.000      0.961 1.000 0.000 0.000
#> GSM559410     1   0.000      0.961 1.000 0.000 0.000
#> GSM559411     1   0.000      0.961 1.000 0.000 0.000
#> GSM559412     1   0.000      0.961 1.000 0.000 0.000
#> GSM559413     1   0.000      0.961 1.000 0.000 0.000
#> GSM559415     1   0.000      0.961 1.000 0.000 0.000
#> GSM559416     1   0.000      0.961 1.000 0.000 0.000
#> GSM559417     1   0.153      0.929 0.960 0.040 0.000
#> GSM559418     1   0.630      0.154 0.528 0.472 0.000
#> GSM559419     1   0.000      0.961 1.000 0.000 0.000
#> GSM559420     1   0.000      0.961 1.000 0.000 0.000
#> GSM559421     2   0.000      0.991 0.000 1.000 0.000
#> GSM559423     2   0.000      0.991 0.000 1.000 0.000
#> GSM559425     2   0.000      0.991 0.000 1.000 0.000
#> GSM559426     2   0.000      0.991 0.000 1.000 0.000
#> GSM559427     2   0.000      0.991 0.000 1.000 0.000
#> GSM559428     2   0.175      0.947 0.000 0.952 0.048
#> GSM559429     2   0.000      0.991 0.000 1.000 0.000
#> GSM559430     2   0.000      0.991 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
#> GSM559383     3  0.4730     0.4682 0.000 0.000 0.636 0.364
#> GSM559387     3  0.1792     0.9102 0.000 0.000 0.932 0.068
#> GSM559391     4  0.4713     0.2554 0.000 0.000 0.360 0.640
#> GSM559395     3  0.1302     0.9196 0.000 0.000 0.956 0.044
#> GSM559397     3  0.1557     0.9163 0.000 0.000 0.944 0.056
#> GSM559401     3  0.0000     0.9131 0.000 0.000 1.000 0.000
#> GSM559414     3  0.1302     0.9197 0.000 0.000 0.956 0.044
#> GSM559422     3  0.0592     0.9061 0.000 0.000 0.984 0.016
#> GSM559424     4  0.4304     0.4330 0.000 0.000 0.284 0.716
#> GSM559431     2  0.0817     0.9365 0.000 0.976 0.000 0.024
#> GSM559432     3  0.0336     0.9103 0.000 0.000 0.992 0.008
#> GSM559381     1  0.0336     0.8559 0.992 0.000 0.000 0.008
#> GSM559382     2  0.2342     0.8916 0.008 0.912 0.000 0.080
#> GSM559384     1  0.1940     0.8240 0.924 0.000 0.000 0.076
#> GSM559385     1  0.0469     0.8554 0.988 0.000 0.000 0.012
#> GSM559386     1  0.5894     0.3452 0.568 0.392 0.000 0.040
#> GSM559388     2  0.1151     0.9298 0.008 0.968 0.000 0.024
#> GSM559389     1  0.0336     0.8549 0.992 0.000 0.000 0.008
#> GSM559390     4  0.2466     0.7734 0.096 0.000 0.004 0.900
#> GSM559392     2  0.0707     0.9338 0.000 0.980 0.000 0.020
#> GSM559393     1  0.2845     0.7992 0.896 0.076 0.000 0.028
#> GSM559394     1  0.0895     0.8504 0.976 0.004 0.000 0.020
#> GSM559396     4  0.3820     0.6937 0.100 0.016 0.028 0.856
#> GSM559398     2  0.0707     0.9338 0.000 0.980 0.000 0.020
#> GSM559399     1  0.0188     0.8571 0.996 0.000 0.000 0.004
#> GSM559400     2  0.5214     0.4514 0.008 0.624 0.004 0.364
#> GSM559402     1  0.1474     0.8446 0.948 0.000 0.000 0.052
#> GSM559403     1  0.0188     0.8571 0.996 0.000 0.000 0.004
#> GSM559404     1  0.0188     0.8571 0.996 0.000 0.000 0.004
#> GSM559405     1  0.0188     0.8571 0.996 0.000 0.000 0.004
#> GSM559406     4  0.3311     0.7515 0.172 0.000 0.000 0.828
#> GSM559407     1  0.2469     0.8008 0.892 0.000 0.000 0.108
#> GSM559408     1  0.4406     0.5468 0.700 0.000 0.000 0.300
#> GSM559409     1  0.2760     0.7828 0.872 0.000 0.000 0.128
#> GSM559410     1  0.0188     0.8571 0.996 0.000 0.000 0.004
#> GSM559411     4  0.2530     0.7763 0.112 0.000 0.000 0.888
#> GSM559412     1  0.4804     0.3479 0.616 0.000 0.000 0.384
#> GSM559413     4  0.4977     0.1198 0.460 0.000 0.000 0.540
#> GSM559415     1  0.0336     0.8549 0.992 0.000 0.000 0.008
#> GSM559416     4  0.2741     0.7742 0.096 0.012 0.000 0.892
#> GSM559417     4  0.5417     0.6582 0.088 0.180 0.000 0.732
#> GSM559418     1  0.3695     0.7314 0.828 0.156 0.000 0.016
#> GSM559419     4  0.3123     0.7642 0.156 0.000 0.000 0.844
#> GSM559420     1  0.4961     0.0751 0.552 0.000 0.000 0.448
#> GSM559421     2  0.1576     0.9240 0.004 0.948 0.000 0.048
#> GSM559423     2  0.1209     0.9341 0.004 0.964 0.000 0.032
#> GSM559425     2  0.0592     0.9373 0.000 0.984 0.000 0.016
#> GSM559426     2  0.1398     0.9318 0.004 0.956 0.000 0.040
#> GSM559427     2  0.0336     0.9357 0.000 0.992 0.000 0.008
#> GSM559428     2  0.3292     0.8785 0.004 0.880 0.080 0.036
#> GSM559429     2  0.1398     0.9318 0.004 0.956 0.000 0.040
#> GSM559430     2  0.0657     0.9375 0.004 0.984 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM559383     5  0.5953   -0.18051 0.000 0.000 0.384 0.112 0.504
#> GSM559387     3  0.4617    0.52827 0.000 0.000 0.552 0.012 0.436
#> GSM559391     5  0.5756    0.55620 0.000 0.000 0.112 0.312 0.576
#> GSM559395     3  0.4582    0.56805 0.000 0.000 0.572 0.012 0.416
#> GSM559397     3  0.4425    0.59967 0.000 0.000 0.600 0.008 0.392
#> GSM559401     3  0.2074    0.59567 0.000 0.000 0.896 0.000 0.104
#> GSM559414     3  0.4436    0.59732 0.000 0.000 0.596 0.008 0.396
#> GSM559422     3  0.0000    0.55617 0.000 0.000 1.000 0.000 0.000
#> GSM559424     5  0.5498    0.55841 0.000 0.000 0.080 0.340 0.580
#> GSM559431     2  0.3845    0.78982 0.000 0.760 0.012 0.004 0.224
#> GSM559432     3  0.0162    0.55923 0.000 0.000 0.996 0.000 0.004
#> GSM559381     1  0.1469    0.79731 0.948 0.000 0.000 0.016 0.036
#> GSM559382     2  0.3852    0.60294 0.000 0.760 0.000 0.220 0.020
#> GSM559384     1  0.4206    0.63305 0.708 0.000 0.000 0.020 0.272
#> GSM559385     1  0.0000    0.80366 1.000 0.000 0.000 0.000 0.000
#> GSM559386     1  0.6105    0.25413 0.512 0.368 0.000 0.116 0.004
#> GSM559388     2  0.2824    0.75240 0.008 0.880 0.000 0.088 0.024
#> GSM559389     1  0.0451    0.80378 0.988 0.000 0.000 0.004 0.008
#> GSM559390     4  0.1179    0.73371 0.016 0.004 0.000 0.964 0.016
#> GSM559392     2  0.0898    0.80764 0.000 0.972 0.000 0.008 0.020
#> GSM559393     1  0.1130    0.79865 0.968 0.004 0.004 0.012 0.012
#> GSM559394     1  0.0404    0.80298 0.988 0.000 0.000 0.000 0.012
#> GSM559396     5  0.2775    0.33289 0.036 0.008 0.000 0.068 0.888
#> GSM559398     2  0.0992    0.80622 0.000 0.968 0.000 0.008 0.024
#> GSM559399     1  0.0566    0.80234 0.984 0.004 0.000 0.000 0.012
#> GSM559400     4  0.5319    0.40531 0.000 0.360 0.008 0.588 0.044
#> GSM559402     1  0.5074    0.61653 0.700 0.000 0.000 0.168 0.132
#> GSM559403     1  0.0000    0.80366 1.000 0.000 0.000 0.000 0.000
#> GSM559404     1  0.0880    0.79676 0.968 0.000 0.000 0.032 0.000
#> GSM559405     1  0.0162    0.80369 0.996 0.000 0.000 0.004 0.000
#> GSM559406     4  0.1484    0.74695 0.048 0.000 0.000 0.944 0.008
#> GSM559407     1  0.5309    0.47662 0.644 0.000 0.000 0.264 0.092
#> GSM559408     4  0.3561    0.63257 0.260 0.000 0.000 0.740 0.000
#> GSM559409     1  0.4440    0.00967 0.528 0.000 0.000 0.468 0.004
#> GSM559410     1  0.1282    0.79187 0.952 0.000 0.000 0.044 0.004
#> GSM559411     4  0.4029    0.52624 0.024 0.000 0.000 0.744 0.232
#> GSM559412     4  0.4575    0.66254 0.236 0.000 0.000 0.712 0.052
#> GSM559413     4  0.5137    0.65732 0.208 0.000 0.000 0.684 0.108
#> GSM559415     1  0.1041    0.80073 0.964 0.000 0.000 0.004 0.032
#> GSM559416     4  0.1095    0.73346 0.008 0.012 0.000 0.968 0.012
#> GSM559417     4  0.2959    0.70077 0.008 0.112 0.000 0.864 0.016
#> GSM559418     1  0.4914    0.44972 0.628 0.336 0.000 0.004 0.032
#> GSM559419     4  0.2153    0.73538 0.040 0.000 0.000 0.916 0.044
#> GSM559420     1  0.6674    0.19578 0.436 0.000 0.000 0.260 0.304
#> GSM559421     2  0.1106    0.81897 0.000 0.964 0.000 0.012 0.024
#> GSM559423     2  0.4152    0.76163 0.000 0.692 0.000 0.012 0.296
#> GSM559425     2  0.2377    0.81861 0.000 0.872 0.000 0.000 0.128
#> GSM559426     2  0.4108    0.75516 0.000 0.684 0.000 0.008 0.308
#> GSM559427     2  0.0566    0.81747 0.000 0.984 0.000 0.004 0.012
#> GSM559428     2  0.6359    0.62822 0.000 0.532 0.152 0.008 0.308
#> GSM559429     2  0.4165    0.74780 0.000 0.672 0.000 0.008 0.320
#> GSM559430     2  0.1732    0.82389 0.000 0.920 0.000 0.000 0.080

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM559383     3  0.1082     0.8372 0.000 0.000 0.956 0.004 0.040 0.000
#> GSM559387     3  0.2260     0.8532 0.000 0.000 0.860 0.000 0.140 0.000
#> GSM559391     3  0.0935     0.7977 0.000 0.000 0.964 0.032 0.004 0.000
#> GSM559395     3  0.2340     0.8508 0.000 0.000 0.852 0.000 0.148 0.000
#> GSM559397     3  0.2762     0.8171 0.000 0.000 0.804 0.000 0.196 0.000
#> GSM559401     5  0.3175     0.7193 0.000 0.000 0.256 0.000 0.744 0.000
#> GSM559414     3  0.2854     0.8040 0.000 0.000 0.792 0.000 0.208 0.000
#> GSM559422     5  0.1714     0.8806 0.000 0.000 0.092 0.000 0.908 0.000
#> GSM559424     3  0.0935     0.7980 0.000 0.000 0.964 0.032 0.004 0.000
#> GSM559431     6  0.4853     0.1414 0.000 0.456 0.000 0.000 0.056 0.488
#> GSM559432     5  0.1765     0.8826 0.000 0.000 0.096 0.000 0.904 0.000
#> GSM559381     1  0.3698     0.7749 0.788 0.000 0.000 0.028 0.020 0.164
#> GSM559382     2  0.4768     0.5343 0.040 0.728 0.000 0.164 0.004 0.064
#> GSM559384     1  0.5691     0.5154 0.564 0.000 0.032 0.028 0.036 0.340
#> GSM559385     1  0.0862     0.8294 0.972 0.004 0.000 0.000 0.008 0.016
#> GSM559386     1  0.6542     0.2830 0.504 0.312 0.000 0.104 0.008 0.072
#> GSM559388     2  0.2699     0.6050 0.068 0.880 0.000 0.020 0.000 0.032
#> GSM559389     1  0.1667     0.8296 0.936 0.004 0.000 0.008 0.008 0.044
#> GSM559390     4  0.1830     0.7744 0.004 0.016 0.016 0.936 0.004 0.024
#> GSM559392     2  0.0603     0.6428 0.000 0.980 0.000 0.000 0.004 0.016
#> GSM559393     1  0.2716     0.7861 0.868 0.096 0.000 0.000 0.008 0.028
#> GSM559394     1  0.1908     0.8176 0.924 0.044 0.000 0.000 0.012 0.020
#> GSM559396     6  0.5377    -0.1154 0.004 0.000 0.460 0.028 0.040 0.468
#> GSM559398     2  0.0291     0.6426 0.000 0.992 0.000 0.004 0.000 0.004
#> GSM559399     1  0.2019     0.8289 0.924 0.032 0.000 0.004 0.020 0.020
#> GSM559400     2  0.4537     0.1104 0.000 0.488 0.000 0.484 0.004 0.024
#> GSM559402     4  0.7086     0.2198 0.276 0.008 0.008 0.384 0.032 0.292
#> GSM559403     1  0.0405     0.8310 0.988 0.008 0.000 0.000 0.004 0.000
#> GSM559404     1  0.3243     0.8027 0.844 0.000 0.000 0.064 0.016 0.076
#> GSM559405     1  0.1914     0.8302 0.920 0.000 0.000 0.016 0.008 0.056
#> GSM559406     4  0.1381     0.7841 0.020 0.004 0.000 0.952 0.004 0.020
#> GSM559407     4  0.6659     0.5581 0.172 0.008 0.016 0.552 0.040 0.212
#> GSM559408     4  0.1854     0.7962 0.020 0.004 0.000 0.932 0.016 0.028
#> GSM559409     4  0.4543     0.6117 0.256 0.000 0.004 0.688 0.016 0.036
#> GSM559410     1  0.2763     0.8079 0.868 0.000 0.000 0.088 0.008 0.036
#> GSM559411     4  0.5354     0.7066 0.012 0.004 0.092 0.692 0.032 0.168
#> GSM559412     4  0.2556     0.7879 0.008 0.000 0.000 0.864 0.008 0.120
#> GSM559413     4  0.3526     0.7705 0.008 0.000 0.004 0.808 0.036 0.144
#> GSM559415     1  0.3995     0.7401 0.768 0.000 0.000 0.032 0.028 0.172
#> GSM559416     4  0.0914     0.7822 0.000 0.016 0.016 0.968 0.000 0.000
#> GSM559417     4  0.1059     0.7866 0.000 0.016 0.000 0.964 0.016 0.004
#> GSM559418     2  0.6200     0.0894 0.376 0.488 0.000 0.024 0.024 0.088
#> GSM559419     4  0.2238     0.7976 0.004 0.004 0.016 0.900 0.000 0.076
#> GSM559420     6  0.8152    -0.1809 0.248 0.008 0.128 0.224 0.032 0.360
#> GSM559421     2  0.2778     0.5889 0.000 0.824 0.000 0.000 0.008 0.168
#> GSM559423     6  0.3935     0.4447 0.004 0.292 0.000 0.000 0.016 0.688
#> GSM559425     2  0.3288     0.4151 0.000 0.724 0.000 0.000 0.000 0.276
#> GSM559426     6  0.3468     0.4892 0.004 0.284 0.000 0.000 0.000 0.712
#> GSM559427     2  0.2135     0.6029 0.000 0.872 0.000 0.000 0.000 0.128
#> GSM559428     6  0.4830     0.4743 0.000 0.172 0.000 0.000 0.160 0.668
#> GSM559429     6  0.3652     0.5014 0.000 0.264 0.000 0.000 0.016 0.720
#> GSM559430     2  0.3161     0.5085 0.000 0.776 0.000 0.000 0.008 0.216

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 disease.state(p) k
#> SD:NMF 49         1.10e-01 2
#> SD:NMF 51         1.31e-10 3
#> SD:NMF 44         3.12e-08 4
#> SD:NMF 44         7.87e-08 5
#> SD:NMF 41         9.38e-08 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 21167 rows and 52 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 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 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.409           0.807       0.871         0.3753 0.618   0.618
#> 3 3 0.662           0.830       0.897         0.4484 0.781   0.646
#> 4 4 0.530           0.787       0.828         0.1909 0.957   0.895
#> 5 5 0.658           0.654       0.807         0.1100 0.969   0.918
#> 6 6 0.643           0.445       0.776         0.0479 0.947   0.852

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
#> GSM559383     1  0.6973      0.766 0.812 0.188
#> GSM559387     1  0.6973      0.766 0.812 0.188
#> GSM559391     1  0.6973      0.766 0.812 0.188
#> GSM559395     1  0.6973      0.766 0.812 0.188
#> GSM559397     1  0.6973      0.766 0.812 0.188
#> GSM559401     1  0.6973      0.766 0.812 0.188
#> GSM559414     1  0.6973      0.766 0.812 0.188
#> GSM559422     1  0.8763      0.676 0.704 0.296
#> GSM559424     1  0.6973      0.766 0.812 0.188
#> GSM559431     2  0.6973      0.904 0.188 0.812
#> GSM559432     1  0.8763      0.676 0.704 0.296
#> GSM559381     1  0.2948      0.849 0.948 0.052
#> GSM559382     1  0.9815     -0.190 0.580 0.420
#> GSM559384     1  0.0000      0.882 1.000 0.000
#> GSM559385     1  0.0000      0.882 1.000 0.000
#> GSM559386     1  0.9000      0.279 0.684 0.316
#> GSM559388     2  0.9460      0.745 0.364 0.636
#> GSM559389     1  0.2948      0.849 0.948 0.052
#> GSM559390     1  0.2948      0.850 0.948 0.052
#> GSM559392     2  0.6973      0.904 0.188 0.812
#> GSM559393     1  0.0376      0.881 0.996 0.004
#> GSM559394     1  0.0000      0.882 1.000 0.000
#> GSM559396     1  0.0000      0.882 1.000 0.000
#> GSM559398     2  0.6973      0.904 0.188 0.812
#> GSM559399     1  0.0000      0.882 1.000 0.000
#> GSM559400     2  0.9522      0.734 0.372 0.628
#> GSM559402     1  0.0000      0.882 1.000 0.000
#> GSM559403     1  0.0000      0.882 1.000 0.000
#> GSM559404     1  0.0000      0.882 1.000 0.000
#> GSM559405     1  0.2948      0.849 0.948 0.052
#> GSM559406     1  0.0376      0.881 0.996 0.004
#> GSM559407     1  0.0000      0.882 1.000 0.000
#> GSM559408     1  0.0000      0.882 1.000 0.000
#> GSM559409     1  0.0000      0.882 1.000 0.000
#> GSM559410     1  0.0000      0.882 1.000 0.000
#> GSM559411     1  0.0000      0.882 1.000 0.000
#> GSM559412     1  0.0000      0.882 1.000 0.000
#> GSM559413     1  0.0000      0.882 1.000 0.000
#> GSM559415     1  0.2778      0.852 0.952 0.048
#> GSM559416     1  0.3733      0.828 0.928 0.072
#> GSM559417     1  0.3733      0.828 0.928 0.072
#> GSM559418     1  0.2778      0.852 0.952 0.048
#> GSM559419     1  0.0000      0.882 1.000 0.000
#> GSM559420     1  0.0000      0.882 1.000 0.000
#> GSM559421     2  0.6973      0.904 0.188 0.812
#> GSM559423     2  0.7219      0.901 0.200 0.800
#> GSM559425     2  0.6973      0.904 0.188 0.812
#> GSM559426     2  0.7674      0.888 0.224 0.776
#> GSM559427     2  0.6973      0.904 0.188 0.812
#> GSM559428     2  0.9970      0.513 0.468 0.532
#> GSM559429     2  0.9358      0.756 0.352 0.648
#> GSM559430     2  0.6973      0.904 0.188 0.812

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM559383     3  0.5810     0.8648 0.336 0.000 0.664
#> GSM559387     3  0.5810     0.8648 0.336 0.000 0.664
#> GSM559391     3  0.5810     0.8648 0.336 0.000 0.664
#> GSM559395     3  0.5810     0.8648 0.336 0.000 0.664
#> GSM559397     3  0.5810     0.8648 0.336 0.000 0.664
#> GSM559401     3  0.4750     0.7886 0.216 0.000 0.784
#> GSM559414     3  0.5810     0.8648 0.336 0.000 0.664
#> GSM559422     3  0.0747     0.5675 0.000 0.016 0.984
#> GSM559424     3  0.5810     0.8648 0.336 0.000 0.664
#> GSM559431     2  0.0237     0.8463 0.000 0.996 0.004
#> GSM559432     3  0.0747     0.5675 0.000 0.016 0.984
#> GSM559381     1  0.2537     0.8707 0.920 0.080 0.000
#> GSM559382     1  0.6520    -0.0811 0.508 0.488 0.004
#> GSM559384     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559385     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559386     1  0.6148     0.3953 0.640 0.356 0.004
#> GSM559388     2  0.5656     0.6357 0.284 0.712 0.004
#> GSM559389     1  0.2537     0.8707 0.920 0.080 0.000
#> GSM559390     1  0.1989     0.8981 0.948 0.048 0.004
#> GSM559392     2  0.1289     0.8635 0.032 0.968 0.000
#> GSM559393     1  0.1163     0.9129 0.972 0.028 0.000
#> GSM559394     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559396     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559398     2  0.1289     0.8635 0.032 0.968 0.000
#> GSM559399     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559400     2  0.5815     0.6102 0.304 0.692 0.004
#> GSM559402     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559403     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559404     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559405     1  0.2537     0.8707 0.920 0.080 0.000
#> GSM559406     1  0.0237     0.9263 0.996 0.000 0.004
#> GSM559407     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559408     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559409     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559410     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559411     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559412     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559413     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559415     1  0.1878     0.8980 0.952 0.044 0.004
#> GSM559416     1  0.2496     0.8776 0.928 0.068 0.004
#> GSM559417     1  0.2496     0.8776 0.928 0.068 0.004
#> GSM559418     1  0.1878     0.8980 0.952 0.044 0.004
#> GSM559419     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559420     1  0.0000     0.9285 1.000 0.000 0.000
#> GSM559421     2  0.1289     0.8635 0.032 0.968 0.000
#> GSM559423     2  0.1765     0.8603 0.040 0.956 0.004
#> GSM559425     2  0.0424     0.8551 0.008 0.992 0.000
#> GSM559426     2  0.1753     0.8509 0.048 0.952 0.000
#> GSM559427     2  0.0424     0.8551 0.008 0.992 0.000
#> GSM559428     2  0.5785     0.5123 0.332 0.668 0.000
#> GSM559429     2  0.4235     0.7204 0.176 0.824 0.000
#> GSM559430     2  0.0424     0.8551 0.008 0.992 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM559383     3  0.3486     0.9672 0.188 0.000 0.812 0.000
#> GSM559387     3  0.3486     0.9672 0.188 0.000 0.812 0.000
#> GSM559391     3  0.3486     0.9672 0.188 0.000 0.812 0.000
#> GSM559395     3  0.3486     0.9672 0.188 0.000 0.812 0.000
#> GSM559397     3  0.3486     0.9672 0.188 0.000 0.812 0.000
#> GSM559401     3  0.3978     0.7200 0.108 0.000 0.836 0.056
#> GSM559414     3  0.3486     0.9672 0.188 0.000 0.812 0.000
#> GSM559422     4  0.4941     1.0000 0.000 0.000 0.436 0.564
#> GSM559424     3  0.3486     0.9672 0.188 0.000 0.812 0.000
#> GSM559431     2  0.2329     0.7593 0.000 0.916 0.012 0.072
#> GSM559432     4  0.4941     1.0000 0.000 0.000 0.436 0.564
#> GSM559381     1  0.5021     0.7200 0.724 0.036 0.000 0.240
#> GSM559382     2  0.7968     0.3611 0.264 0.408 0.004 0.324
#> GSM559384     1  0.0895     0.8408 0.976 0.000 0.004 0.020
#> GSM559385     1  0.4646     0.7853 0.796 0.000 0.120 0.084
#> GSM559386     1  0.7977     0.0417 0.412 0.280 0.004 0.304
#> GSM559388     2  0.5988     0.6302 0.100 0.676 0.000 0.224
#> GSM559389     1  0.5021     0.7200 0.724 0.036 0.000 0.240
#> GSM559390     1  0.4126     0.7660 0.776 0.004 0.004 0.216
#> GSM559392     2  0.1022     0.7942 0.000 0.968 0.000 0.032
#> GSM559393     1  0.5680     0.7618 0.752 0.020 0.120 0.108
#> GSM559394     1  0.4646     0.7853 0.796 0.000 0.120 0.084
#> GSM559396     1  0.0895     0.8408 0.976 0.000 0.004 0.020
#> GSM559398     2  0.1022     0.7942 0.000 0.968 0.000 0.032
#> GSM559399     1  0.1022     0.8415 0.968 0.000 0.000 0.032
#> GSM559400     2  0.6175     0.6233 0.092 0.664 0.004 0.240
#> GSM559402     1  0.2149     0.8118 0.912 0.000 0.088 0.000
#> GSM559403     1  0.1724     0.8426 0.948 0.000 0.020 0.032
#> GSM559404     1  0.3658     0.7505 0.836 0.000 0.144 0.020
#> GSM559405     1  0.5021     0.7200 0.724 0.036 0.000 0.240
#> GSM559406     1  0.2773     0.8240 0.880 0.000 0.004 0.116
#> GSM559407     1  0.2149     0.8118 0.912 0.000 0.088 0.000
#> GSM559408     1  0.0336     0.8405 0.992 0.000 0.008 0.000
#> GSM559409     1  0.0336     0.8405 0.992 0.000 0.008 0.000
#> GSM559410     1  0.3082     0.8198 0.884 0.000 0.084 0.032
#> GSM559411     1  0.0336     0.8405 0.992 0.000 0.008 0.000
#> GSM559412     1  0.2216     0.8093 0.908 0.000 0.092 0.000
#> GSM559413     1  0.2216     0.8093 0.908 0.000 0.092 0.000
#> GSM559415     1  0.3501     0.8082 0.848 0.020 0.000 0.132
#> GSM559416     1  0.4854     0.7365 0.732 0.020 0.004 0.244
#> GSM559417     1  0.4854     0.7365 0.732 0.020 0.004 0.244
#> GSM559418     1  0.3501     0.8082 0.848 0.020 0.000 0.132
#> GSM559419     1  0.0376     0.8416 0.992 0.000 0.004 0.004
#> GSM559420     1  0.0376     0.8416 0.992 0.000 0.004 0.004
#> GSM559421     2  0.1022     0.7942 0.000 0.968 0.000 0.032
#> GSM559423     2  0.1389     0.7932 0.000 0.952 0.000 0.048
#> GSM559425     2  0.1767     0.7732 0.000 0.944 0.012 0.044
#> GSM559426     2  0.3047     0.7629 0.012 0.872 0.000 0.116
#> GSM559427     2  0.1767     0.7732 0.000 0.944 0.012 0.044
#> GSM559428     2  0.7117     0.5360 0.196 0.584 0.004 0.216
#> GSM559429     2  0.5574     0.6709 0.092 0.732 0.004 0.172
#> GSM559430     2  0.0188     0.7895 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
#> GSM559383     3  0.1043      0.981 0.040 0.000 0.960 0.000 0.000
#> GSM559387     3  0.1043      0.981 0.040 0.000 0.960 0.000 0.000
#> GSM559391     3  0.1043      0.981 0.040 0.000 0.960 0.000 0.000
#> GSM559395     3  0.1043      0.981 0.040 0.000 0.960 0.000 0.000
#> GSM559397     3  0.1043      0.981 0.040 0.000 0.960 0.000 0.000
#> GSM559401     3  0.2077      0.849 0.000 0.000 0.920 0.040 0.040
#> GSM559414     3  0.1043      0.981 0.040 0.000 0.960 0.000 0.000
#> GSM559422     5  0.4666      1.000 0.000 0.000 0.040 0.284 0.676
#> GSM559424     3  0.1043      0.981 0.040 0.000 0.960 0.000 0.000
#> GSM559431     2  0.2293      0.734 0.000 0.900 0.000 0.084 0.016
#> GSM559432     5  0.4666      1.000 0.000 0.000 0.040 0.284 0.676
#> GSM559381     1  0.4761      0.299 0.616 0.028 0.000 0.356 0.000
#> GSM559382     4  0.6272      0.579 0.152 0.380 0.000 0.468 0.000
#> GSM559384     1  0.1430      0.713 0.944 0.000 0.000 0.052 0.004
#> GSM559385     1  0.6448      0.494 0.560 0.000 0.052 0.076 0.312
#> GSM559386     4  0.6641      0.681 0.296 0.256 0.000 0.448 0.000
#> GSM559388     2  0.4522      0.280 0.024 0.660 0.000 0.316 0.000
#> GSM559389     1  0.4761      0.299 0.616 0.028 0.000 0.356 0.000
#> GSM559390     1  0.3857      0.472 0.688 0.000 0.000 0.312 0.000
#> GSM559392     2  0.1197      0.763 0.000 0.952 0.000 0.048 0.000
#> GSM559393     1  0.7285      0.422 0.508 0.016 0.052 0.112 0.312
#> GSM559394     1  0.6448      0.494 0.560 0.000 0.052 0.076 0.312
#> GSM559396     1  0.1410      0.710 0.940 0.000 0.000 0.060 0.000
#> GSM559398     2  0.1197      0.763 0.000 0.952 0.000 0.048 0.000
#> GSM559399     1  0.1469      0.721 0.948 0.000 0.000 0.036 0.016
#> GSM559400     2  0.4467      0.277 0.016 0.640 0.000 0.344 0.000
#> GSM559402     1  0.2389      0.701 0.880 0.000 0.004 0.000 0.116
#> GSM559403     1  0.2157      0.724 0.920 0.000 0.004 0.036 0.040
#> GSM559404     1  0.5654      0.474 0.592 0.000 0.076 0.008 0.324
#> GSM559405     1  0.4761      0.299 0.616 0.028 0.000 0.356 0.000
#> GSM559406     1  0.3048      0.639 0.820 0.000 0.000 0.176 0.004
#> GSM559407     1  0.2389      0.701 0.880 0.000 0.004 0.000 0.116
#> GSM559408     1  0.0451      0.724 0.988 0.000 0.000 0.008 0.004
#> GSM559409     1  0.0451      0.724 0.988 0.000 0.000 0.008 0.004
#> GSM559410     1  0.3222      0.707 0.852 0.000 0.004 0.036 0.108
#> GSM559411     1  0.0609      0.724 0.980 0.000 0.000 0.000 0.020
#> GSM559412     1  0.2970      0.677 0.828 0.000 0.004 0.000 0.168
#> GSM559413     1  0.2970      0.677 0.828 0.000 0.004 0.000 0.168
#> GSM559415     1  0.3779      0.583 0.752 0.012 0.000 0.236 0.000
#> GSM559416     1  0.4565      0.276 0.580 0.012 0.000 0.408 0.000
#> GSM559417     1  0.4565      0.276 0.580 0.012 0.000 0.408 0.000
#> GSM559418     1  0.3779      0.583 0.752 0.012 0.000 0.236 0.000
#> GSM559419     1  0.0290      0.724 0.992 0.000 0.000 0.008 0.000
#> GSM559420     1  0.0290      0.724 0.992 0.000 0.000 0.008 0.000
#> GSM559421     2  0.1341      0.763 0.000 0.944 0.000 0.056 0.000
#> GSM559423     2  0.1544      0.760 0.000 0.932 0.000 0.068 0.000
#> GSM559425     2  0.1478      0.748 0.000 0.936 0.000 0.064 0.000
#> GSM559426     2  0.2864      0.684 0.012 0.852 0.000 0.136 0.000
#> GSM559427     2  0.1478      0.748 0.000 0.936 0.000 0.064 0.000
#> GSM559428     2  0.6054     -0.226 0.148 0.548 0.000 0.304 0.000
#> GSM559429     2  0.4873      0.403 0.068 0.688 0.000 0.244 0.000
#> GSM559430     2  0.0794      0.764 0.000 0.972 0.000 0.028 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
#> GSM559383     3  0.0000     0.9824 0.000 0.000 1.000 0.000 0.00 0.000
#> GSM559387     3  0.0000     0.9824 0.000 0.000 1.000 0.000 0.00 0.000
#> GSM559391     3  0.0000     0.9824 0.000 0.000 1.000 0.000 0.00 0.000
#> GSM559395     3  0.0000     0.9824 0.000 0.000 1.000 0.000 0.00 0.000
#> GSM559397     3  0.0000     0.9824 0.000 0.000 1.000 0.000 0.00 0.000
#> GSM559401     3  0.2048     0.8632 0.000 0.000 0.880 0.000 0.12 0.000
#> GSM559414     3  0.0000     0.9824 0.000 0.000 1.000 0.000 0.00 0.000
#> GSM559422     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.00 0.000
#> GSM559424     3  0.0000     0.9824 0.000 0.000 1.000 0.000 0.00 0.000
#> GSM559431     2  0.4626     0.5726 0.000 0.692 0.000 0.172 0.00 0.136
#> GSM559432     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.00 0.000
#> GSM559381     1  0.5975     0.2058 0.580 0.028 0.012 0.116 0.00 0.264
#> GSM559382     2  0.7510    -0.1912 0.116 0.396 0.012 0.196 0.00 0.280
#> GSM559384     1  0.1682     0.5251 0.928 0.000 0.000 0.052 0.00 0.020
#> GSM559385     1  0.3868    -0.8547 0.504 0.000 0.000 0.496 0.00 0.000
#> GSM559386     6  0.7941     0.0887 0.260 0.264 0.012 0.184 0.00 0.280
#> GSM559388     2  0.4838     0.4160 0.004 0.676 0.000 0.192 0.00 0.128
#> GSM559389     1  0.5975     0.2058 0.580 0.028 0.012 0.116 0.00 0.264
#> GSM559390     1  0.4785     0.3210 0.660 0.004 0.012 0.052 0.00 0.272
#> GSM559392     2  0.0000     0.6803 0.000 1.000 0.000 0.000 0.00 0.000
#> GSM559393     4  0.4869     0.0000 0.456 0.024 0.000 0.500 0.00 0.020
#> GSM559394     1  0.3868    -0.8547 0.504 0.000 0.000 0.496 0.00 0.000
#> GSM559396     1  0.1845     0.5251 0.920 0.000 0.000 0.052 0.00 0.028
#> GSM559398     2  0.0260     0.6804 0.000 0.992 0.000 0.000 0.00 0.008
#> GSM559399     1  0.1501     0.4968 0.924 0.000 0.000 0.076 0.00 0.000
#> GSM559400     2  0.4949     0.4253 0.004 0.644 0.000 0.104 0.00 0.248
#> GSM559402     1  0.2135     0.3783 0.872 0.000 0.000 0.128 0.00 0.000
#> GSM559403     1  0.1814     0.4735 0.900 0.000 0.000 0.100 0.00 0.000
#> GSM559404     1  0.3862    -0.6616 0.524 0.000 0.000 0.476 0.00 0.000
#> GSM559405     1  0.5975     0.2058 0.580 0.028 0.012 0.116 0.00 0.264
#> GSM559406     1  0.3477     0.4549 0.808 0.004 0.000 0.056 0.00 0.132
#> GSM559407     1  0.2135     0.3783 0.872 0.000 0.000 0.128 0.00 0.000
#> GSM559408     1  0.0520     0.5303 0.984 0.000 0.000 0.008 0.00 0.008
#> GSM559409     1  0.0520     0.5303 0.984 0.000 0.000 0.008 0.00 0.008
#> GSM559410     1  0.2562     0.3537 0.828 0.000 0.000 0.172 0.00 0.000
#> GSM559411     1  0.1010     0.5186 0.960 0.000 0.000 0.036 0.00 0.004
#> GSM559412     1  0.2838     0.2601 0.808 0.000 0.000 0.188 0.00 0.004
#> GSM559413     1  0.2871     0.2505 0.804 0.000 0.000 0.192 0.00 0.004
#> GSM559415     1  0.4295     0.3905 0.720 0.020 0.000 0.224 0.00 0.036
#> GSM559416     1  0.5930     0.2681 0.564 0.024 0.000 0.192 0.00 0.220
#> GSM559417     1  0.5930     0.2681 0.564 0.024 0.000 0.192 0.00 0.220
#> GSM559418     1  0.4295     0.3905 0.720 0.020 0.000 0.224 0.00 0.036
#> GSM559419     1  0.0405     0.5299 0.988 0.000 0.000 0.008 0.00 0.004
#> GSM559420     1  0.0405     0.5299 0.988 0.000 0.000 0.008 0.00 0.004
#> GSM559421     2  0.0937     0.6677 0.000 0.960 0.000 0.000 0.00 0.040
#> GSM559423     2  0.2747     0.6127 0.000 0.860 0.000 0.044 0.00 0.096
#> GSM559425     2  0.3901     0.6236 0.000 0.768 0.000 0.136 0.00 0.096
#> GSM559426     6  0.4833     0.1237 0.000 0.428 0.000 0.056 0.00 0.516
#> GSM559427     2  0.3901     0.6236 0.000 0.768 0.000 0.136 0.00 0.096
#> GSM559428     6  0.5183     0.4180 0.120 0.176 0.012 0.012 0.00 0.680
#> GSM559429     6  0.4332     0.3735 0.000 0.228 0.000 0.072 0.00 0.700
#> GSM559430     2  0.2106     0.6670 0.000 0.904 0.000 0.032 0.00 0.064

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 disease.state(p) k
#> CV:hclust 50         2.90e-01 2
#> CV:hclust 50         2.05e-10 3
#> CV:hclust 50         1.11e-09 4
#> CV:hclust 38         8.67e-07 5
#> CV:hclust 25         8.49e-05 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 21167 rows and 52 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 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 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.497           0.756       0.795         0.3757 0.581   0.581
#> 3 3 1.000           0.975       0.981         0.6180 0.793   0.647
#> 4 4 0.677           0.706       0.824         0.1463 0.931   0.825
#> 5 5 0.659           0.592       0.743         0.0882 0.923   0.777
#> 6 6 0.674           0.544       0.702         0.0667 0.836   0.485

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
#> GSM559383     1   0.118      0.445 0.984 0.016
#> GSM559387     1   0.118      0.445 0.984 0.016
#> GSM559391     1   0.118      0.445 0.984 0.016
#> GSM559395     1   0.118      0.445 0.984 0.016
#> GSM559397     1   0.118      0.445 0.984 0.016
#> GSM559401     1   0.118      0.445 0.984 0.016
#> GSM559414     1   0.118      0.445 0.984 0.016
#> GSM559422     1   0.343      0.387 0.936 0.064
#> GSM559424     1   0.118      0.445 0.984 0.016
#> GSM559431     2   0.000      0.936 0.000 1.000
#> GSM559432     2   0.993      0.347 0.452 0.548
#> GSM559381     1   0.993      0.787 0.548 0.452
#> GSM559382     2   0.141      0.911 0.020 0.980
#> GSM559384     1   0.993      0.787 0.548 0.452
#> GSM559385     1   0.993      0.787 0.548 0.452
#> GSM559386     1   0.995      0.776 0.540 0.460
#> GSM559388     2   0.000      0.936 0.000 1.000
#> GSM559389     1   0.993      0.787 0.548 0.452
#> GSM559390     1   0.993      0.787 0.548 0.452
#> GSM559392     2   0.000      0.936 0.000 1.000
#> GSM559393     1   0.994      0.782 0.544 0.456
#> GSM559394     1   0.993      0.787 0.548 0.452
#> GSM559396     1   0.993      0.787 0.548 0.452
#> GSM559398     2   0.000      0.936 0.000 1.000
#> GSM559399     1   0.993      0.787 0.548 0.452
#> GSM559400     2   0.141      0.909 0.020 0.980
#> GSM559402     1   0.993      0.787 0.548 0.452
#> GSM559403     1   0.993      0.787 0.548 0.452
#> GSM559404     1   0.990      0.781 0.560 0.440
#> GSM559405     1   0.993      0.787 0.548 0.452
#> GSM559406     1   0.990      0.781 0.560 0.440
#> GSM559407     1   0.993      0.787 0.548 0.452
#> GSM559408     1   0.993      0.787 0.548 0.452
#> GSM559409     1   0.993      0.787 0.548 0.452
#> GSM559410     1   0.993      0.787 0.548 0.452
#> GSM559411     1   0.990      0.781 0.560 0.440
#> GSM559412     1   0.990      0.781 0.560 0.440
#> GSM559413     1   0.990      0.781 0.560 0.440
#> GSM559415     1   0.993      0.787 0.548 0.452
#> GSM559416     1   0.993      0.787 0.548 0.452
#> GSM559417     1   0.993      0.787 0.548 0.452
#> GSM559418     1   0.994      0.782 0.544 0.456
#> GSM559419     1   0.993      0.787 0.548 0.452
#> GSM559420     1   0.993      0.787 0.548 0.452
#> GSM559421     2   0.000      0.936 0.000 1.000
#> GSM559423     2   0.000      0.936 0.000 1.000
#> GSM559425     2   0.000      0.936 0.000 1.000
#> GSM559426     2   0.000      0.936 0.000 1.000
#> GSM559427     2   0.000      0.936 0.000 1.000
#> GSM559428     2   0.141      0.911 0.020 0.980
#> GSM559429     2   0.000      0.936 0.000 1.000
#> GSM559430     2   0.000      0.936 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
#> GSM559383     3  0.1643      0.988 0.044 0.000 0.956
#> GSM559387     3  0.1643      0.988 0.044 0.000 0.956
#> GSM559391     3  0.1643      0.988 0.044 0.000 0.956
#> GSM559395     3  0.1643      0.988 0.044 0.000 0.956
#> GSM559397     3  0.1643      0.988 0.044 0.000 0.956
#> GSM559401     3  0.1643      0.988 0.044 0.000 0.956
#> GSM559414     3  0.1643      0.988 0.044 0.000 0.956
#> GSM559422     3  0.0424      0.954 0.008 0.000 0.992
#> GSM559424     3  0.1643      0.988 0.044 0.000 0.956
#> GSM559431     2  0.0424      0.964 0.000 0.992 0.008
#> GSM559432     3  0.0237      0.944 0.000 0.004 0.996
#> GSM559381     1  0.0237      0.990 0.996 0.004 0.000
#> GSM559382     2  0.3039      0.923 0.044 0.920 0.036
#> GSM559384     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559385     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559386     1  0.1832      0.958 0.956 0.008 0.036
#> GSM559388     2  0.1411      0.953 0.000 0.964 0.036
#> GSM559389     1  0.0237      0.990 0.996 0.004 0.000
#> GSM559390     1  0.0592      0.984 0.988 0.000 0.012
#> GSM559392     2  0.0000      0.964 0.000 1.000 0.000
#> GSM559393     1  0.1832      0.958 0.956 0.008 0.036
#> GSM559394     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559396     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559398     2  0.0424      0.964 0.000 0.992 0.008
#> GSM559399     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559400     2  0.4915      0.806 0.132 0.832 0.036
#> GSM559402     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559403     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559404     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559405     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559406     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559407     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559408     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559409     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559410     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559411     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559412     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559413     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559415     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559416     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559417     1  0.1647      0.961 0.960 0.004 0.036
#> GSM559418     1  0.1832      0.958 0.956 0.008 0.036
#> GSM559419     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559420     1  0.0000      0.992 1.000 0.000 0.000
#> GSM559421     2  0.0000      0.964 0.000 1.000 0.000
#> GSM559423     2  0.1031      0.959 0.000 0.976 0.024
#> GSM559425     2  0.0424      0.964 0.000 0.992 0.008
#> GSM559426     2  0.0000      0.964 0.000 1.000 0.000
#> GSM559427     2  0.0424      0.964 0.000 0.992 0.008
#> GSM559428     2  0.3039      0.923 0.044 0.920 0.036
#> GSM559429     2  0.1031      0.959 0.000 0.976 0.024
#> GSM559430     2  0.0424      0.964 0.000 0.992 0.008

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM559383     3  0.0188    0.95679 0.000 0.000 0.996 0.004
#> GSM559387     3  0.0000    0.95751 0.000 0.000 1.000 0.000
#> GSM559391     3  0.0188    0.95679 0.000 0.000 0.996 0.004
#> GSM559395     3  0.0000    0.95751 0.000 0.000 1.000 0.000
#> GSM559397     3  0.0000    0.95751 0.000 0.000 1.000 0.000
#> GSM559401     3  0.0000    0.95751 0.000 0.000 1.000 0.000
#> GSM559414     3  0.0000    0.95751 0.000 0.000 1.000 0.000
#> GSM559422     3  0.4008    0.81993 0.000 0.000 0.756 0.244
#> GSM559424     3  0.0188    0.95679 0.000 0.000 0.996 0.004
#> GSM559431     2  0.0336    0.84863 0.000 0.992 0.000 0.008
#> GSM559432     3  0.4008    0.81993 0.000 0.000 0.756 0.244
#> GSM559381     1  0.4454    0.74220 0.692 0.000 0.000 0.308
#> GSM559382     4  0.5508   -0.03453 0.016 0.476 0.000 0.508
#> GSM559384     1  0.3356    0.79573 0.824 0.000 0.000 0.176
#> GSM559385     1  0.4356    0.75152 0.708 0.000 0.000 0.292
#> GSM559386     4  0.4543   -0.00163 0.324 0.000 0.000 0.676
#> GSM559388     2  0.4925    0.16550 0.000 0.572 0.000 0.428
#> GSM559389     1  0.4624    0.71270 0.660 0.000 0.000 0.340
#> GSM559390     1  0.4250    0.42975 0.724 0.000 0.000 0.276
#> GSM559392     2  0.3123    0.82103 0.000 0.844 0.000 0.156
#> GSM559393     4  0.4564   -0.04922 0.328 0.000 0.000 0.672
#> GSM559394     1  0.4382    0.75035 0.704 0.000 0.000 0.296
#> GSM559396     1  0.3610    0.79439 0.800 0.000 0.000 0.200
#> GSM559398     2  0.0817    0.85204 0.000 0.976 0.000 0.024
#> GSM559399     1  0.4522    0.74240 0.680 0.000 0.000 0.320
#> GSM559400     4  0.7412    0.12340 0.168 0.388 0.000 0.444
#> GSM559402     1  0.3219    0.79590 0.836 0.000 0.000 0.164
#> GSM559403     1  0.4331    0.75364 0.712 0.000 0.000 0.288
#> GSM559404     1  0.4040    0.78065 0.752 0.000 0.000 0.248
#> GSM559405     1  0.3907    0.77854 0.768 0.000 0.000 0.232
#> GSM559406     1  0.0592    0.75015 0.984 0.000 0.000 0.016
#> GSM559407     1  0.3074    0.79496 0.848 0.000 0.000 0.152
#> GSM559408     1  0.0000    0.75891 1.000 0.000 0.000 0.000
#> GSM559409     1  0.0000    0.75891 1.000 0.000 0.000 0.000
#> GSM559410     1  0.3764    0.78504 0.784 0.000 0.000 0.216
#> GSM559411     1  0.0707    0.75466 0.980 0.000 0.000 0.020
#> GSM559412     1  0.0707    0.75466 0.980 0.000 0.000 0.020
#> GSM559413     1  0.0707    0.75466 0.980 0.000 0.000 0.020
#> GSM559415     1  0.4522    0.74170 0.680 0.000 0.000 0.320
#> GSM559416     1  0.3444    0.59305 0.816 0.000 0.000 0.184
#> GSM559417     1  0.3688    0.55254 0.792 0.000 0.000 0.208
#> GSM559418     1  0.4989    0.51813 0.528 0.000 0.000 0.472
#> GSM559419     1  0.2281    0.72587 0.904 0.000 0.000 0.096
#> GSM559420     1  0.3219    0.79601 0.836 0.000 0.000 0.164
#> GSM559421     2  0.2345    0.85013 0.000 0.900 0.000 0.100
#> GSM559423     2  0.3266    0.80943 0.000 0.832 0.000 0.168
#> GSM559425     2  0.0000    0.85143 0.000 1.000 0.000 0.000
#> GSM559426     2  0.2469    0.84723 0.000 0.892 0.000 0.108
#> GSM559427     2  0.0000    0.85143 0.000 1.000 0.000 0.000
#> GSM559428     4  0.5510   -0.06143 0.016 0.480 0.000 0.504
#> GSM559429     2  0.3266    0.81293 0.000 0.832 0.000 0.168
#> GSM559430     2  0.0000    0.85143 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
#> GSM559383     3  0.0609    0.90963 0.000 0.000 0.980 0.020 NA
#> GSM559387     3  0.0000    0.91239 0.000 0.000 1.000 0.000 NA
#> GSM559391     3  0.0609    0.90963 0.000 0.000 0.980 0.020 NA
#> GSM559395     3  0.0000    0.91239 0.000 0.000 1.000 0.000 NA
#> GSM559397     3  0.0000    0.91239 0.000 0.000 1.000 0.000 NA
#> GSM559401     3  0.0000    0.91239 0.000 0.000 1.000 0.000 NA
#> GSM559414     3  0.0000    0.91239 0.000 0.000 1.000 0.000 NA
#> GSM559422     3  0.4425    0.61454 0.000 0.000 0.544 0.004 NA
#> GSM559424     3  0.0609    0.90963 0.000 0.000 0.980 0.020 NA
#> GSM559431     2  0.0671    0.81506 0.000 0.980 0.000 0.004 NA
#> GSM559432     3  0.4641    0.60324 0.000 0.000 0.532 0.012 NA
#> GSM559381     1  0.3779    0.58047 0.804 0.000 0.000 0.144 NA
#> GSM559382     4  0.6165    0.27890 0.040 0.220 0.000 0.632 NA
#> GSM559384     1  0.1568    0.66097 0.944 0.000 0.000 0.036 NA
#> GSM559385     1  0.4890    0.54902 0.680 0.000 0.000 0.064 NA
#> GSM559386     4  0.5839    0.43850 0.248 0.004 0.000 0.612 NA
#> GSM559388     4  0.5825    0.06219 0.000 0.320 0.000 0.564 NA
#> GSM559389     1  0.4934    0.55929 0.708 0.000 0.000 0.104 NA
#> GSM559390     4  0.3957    0.19026 0.280 0.000 0.000 0.712 NA
#> GSM559392     2  0.5305    0.72280 0.000 0.672 0.000 0.196 NA
#> GSM559393     4  0.6796    0.02692 0.328 0.000 0.000 0.376 NA
#> GSM559394     1  0.5059    0.54006 0.668 0.000 0.000 0.076 NA
#> GSM559396     1  0.3002    0.63416 0.856 0.000 0.000 0.116 NA
#> GSM559398     2  0.1661    0.81446 0.000 0.940 0.000 0.036 NA
#> GSM559399     1  0.4836    0.56873 0.716 0.000 0.000 0.096 NA
#> GSM559400     4  0.4733    0.35025 0.008 0.152 0.000 0.748 NA
#> GSM559402     1  0.1670    0.65783 0.936 0.000 0.000 0.052 NA
#> GSM559403     1  0.4890    0.54902 0.680 0.000 0.000 0.064 NA
#> GSM559404     1  0.4298    0.60158 0.756 0.000 0.000 0.060 NA
#> GSM559405     1  0.2573    0.64534 0.880 0.000 0.000 0.016 NA
#> GSM559406     1  0.5027    0.49735 0.640 0.000 0.000 0.304 NA
#> GSM559407     1  0.1764    0.65655 0.928 0.000 0.000 0.064 NA
#> GSM559408     1  0.4967    0.51980 0.660 0.000 0.000 0.280 NA
#> GSM559409     1  0.4878    0.52737 0.676 0.000 0.000 0.264 NA
#> GSM559410     1  0.3565    0.63029 0.800 0.000 0.000 0.024 NA
#> GSM559411     1  0.4890    0.52760 0.680 0.000 0.000 0.256 NA
#> GSM559412     1  0.4937    0.52620 0.672 0.000 0.000 0.264 NA
#> GSM559413     1  0.4914    0.52756 0.676 0.000 0.000 0.260 NA
#> GSM559415     1  0.4998    0.55713 0.700 0.000 0.000 0.104 NA
#> GSM559416     4  0.4930   -0.03626 0.388 0.000 0.000 0.580 NA
#> GSM559417     4  0.4898    0.00102 0.376 0.000 0.000 0.592 NA
#> GSM559418     1  0.6102    0.33691 0.568 0.000 0.000 0.232 NA
#> GSM559419     1  0.4966    0.36040 0.564 0.000 0.000 0.404 NA
#> GSM559420     1  0.2325    0.65256 0.904 0.000 0.000 0.068 NA
#> GSM559421     2  0.4351    0.79447 0.000 0.768 0.000 0.132 NA
#> GSM559423     2  0.5367    0.74616 0.000 0.668 0.000 0.184 NA
#> GSM559425     2  0.0404    0.81718 0.000 0.988 0.000 0.000 NA
#> GSM559426     2  0.4764    0.78151 0.000 0.732 0.000 0.140 NA
#> GSM559427     2  0.0404    0.81718 0.000 0.988 0.000 0.000 NA
#> GSM559428     4  0.6867    0.21261 0.048 0.224 0.000 0.560 NA
#> GSM559429     2  0.5109    0.75723 0.000 0.696 0.000 0.172 NA
#> GSM559430     2  0.0510    0.81793 0.000 0.984 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
#> GSM559383     3  0.0622     0.9766 0.012 0.000 0.980 0.000 0.000 0.008
#> GSM559387     3  0.0000     0.9829 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559391     3  0.0622     0.9766 0.012 0.000 0.980 0.000 0.000 0.008
#> GSM559395     3  0.0146     0.9829 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM559397     3  0.0000     0.9829 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559401     3  0.0260     0.9759 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM559414     3  0.0000     0.9829 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559422     5  0.3862     0.9826 0.000 0.000 0.476 0.000 0.524 0.000
#> GSM559424     3  0.0622     0.9766 0.012 0.000 0.980 0.000 0.000 0.008
#> GSM559431     2  0.1003     0.6895 0.000 0.964 0.000 0.000 0.016 0.020
#> GSM559432     5  0.3857     0.9828 0.000 0.000 0.468 0.000 0.532 0.000
#> GSM559381     1  0.6917     0.1100 0.376 0.000 0.000 0.364 0.072 0.188
#> GSM559382     6  0.3150     0.5791 0.104 0.064 0.000 0.000 0.000 0.832
#> GSM559384     4  0.5310     0.1550 0.332 0.000 0.000 0.576 0.072 0.020
#> GSM559385     1  0.4606     0.6579 0.708 0.000 0.000 0.208 0.064 0.020
#> GSM559386     6  0.3192     0.5573 0.216 0.000 0.000 0.004 0.004 0.776
#> GSM559388     6  0.3852     0.5272 0.064 0.120 0.000 0.000 0.020 0.796
#> GSM559389     1  0.5606     0.5907 0.644 0.000 0.000 0.192 0.060 0.104
#> GSM559390     6  0.7139     0.0615 0.116 0.000 0.000 0.328 0.164 0.392
#> GSM559392     2  0.4636     0.3915 0.004 0.532 0.000 0.000 0.032 0.432
#> GSM559393     1  0.4317     0.5117 0.740 0.000 0.000 0.016 0.064 0.180
#> GSM559394     1  0.4170     0.6653 0.740 0.000 0.000 0.192 0.060 0.008
#> GSM559396     4  0.6266     0.2096 0.292 0.000 0.000 0.532 0.084 0.092
#> GSM559398     2  0.2750     0.6509 0.000 0.844 0.000 0.000 0.020 0.136
#> GSM559399     1  0.3753     0.6446 0.788 0.000 0.000 0.156 0.040 0.016
#> GSM559400     6  0.5523     0.5190 0.060 0.032 0.000 0.052 0.168 0.688
#> GSM559402     4  0.4978     0.2780 0.268 0.000 0.000 0.644 0.072 0.016
#> GSM559403     1  0.4213     0.6519 0.708 0.000 0.000 0.240 0.048 0.004
#> GSM559404     4  0.5282     0.1470 0.244 0.000 0.000 0.636 0.096 0.024
#> GSM559405     1  0.5285     0.2695 0.488 0.000 0.000 0.436 0.060 0.016
#> GSM559406     4  0.2870     0.5362 0.004 0.000 0.000 0.856 0.100 0.040
#> GSM559407     4  0.4729     0.3004 0.256 0.000 0.000 0.668 0.064 0.012
#> GSM559408     4  0.1923     0.5595 0.004 0.000 0.000 0.916 0.064 0.016
#> GSM559409     4  0.1196     0.5678 0.000 0.000 0.000 0.952 0.040 0.008
#> GSM559410     1  0.3706     0.5353 0.620 0.000 0.000 0.380 0.000 0.000
#> GSM559411     4  0.0508     0.5653 0.012 0.000 0.000 0.984 0.004 0.000
#> GSM559412     4  0.1010     0.5670 0.004 0.000 0.000 0.960 0.036 0.000
#> GSM559413     4  0.0260     0.5642 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM559415     1  0.3473     0.6443 0.812 0.000 0.000 0.136 0.040 0.012
#> GSM559416     4  0.7386     0.1414 0.200 0.000 0.000 0.412 0.188 0.200
#> GSM559417     4  0.7396     0.1085 0.188 0.000 0.000 0.408 0.188 0.216
#> GSM559418     1  0.3236     0.6061 0.852 0.000 0.000 0.060 0.040 0.048
#> GSM559419     4  0.7074     0.2656 0.268 0.000 0.000 0.444 0.168 0.120
#> GSM559420     4  0.5356     0.1955 0.348 0.000 0.000 0.560 0.072 0.020
#> GSM559421     2  0.4446     0.4902 0.004 0.600 0.000 0.000 0.028 0.368
#> GSM559423     6  0.5503    -0.4437 0.016 0.448 0.000 0.000 0.080 0.456
#> GSM559425     2  0.0146     0.7032 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM559426     2  0.5504     0.4573 0.024 0.564 0.000 0.000 0.084 0.328
#> GSM559427     2  0.0146     0.7032 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM559428     6  0.4167     0.4969 0.072 0.056 0.000 0.000 0.084 0.788
#> GSM559429     2  0.5992     0.3351 0.032 0.464 0.000 0.000 0.108 0.396
#> GSM559430     2  0.0291     0.7036 0.000 0.992 0.000 0.000 0.004 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-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 disease.state(p) k
#> CV:kmeans 42         7.20e-01 2
#> CV:kmeans 52         8.27e-11 3
#> CV:kmeans 45         1.93e-09 4
#> CV:kmeans 40         1.97e-08 5
#> CV:kmeans 34         1.26e-05 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 21167 rows and 52 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 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 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.524           0.899       0.912         0.4755 0.517   0.517
#> 3 3 1.000           0.969       0.989         0.3554 0.773   0.586
#> 4 4 0.847           0.907       0.931         0.1694 0.851   0.600
#> 5 5 0.771           0.690       0.843         0.0574 0.913   0.674
#> 6 6 0.759           0.539       0.765         0.0349 0.956   0.797

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
#> GSM559383     1  0.6801      0.845 0.820 0.180
#> GSM559387     1  0.6801      0.845 0.820 0.180
#> GSM559391     1  0.6801      0.845 0.820 0.180
#> GSM559395     1  0.6801      0.845 0.820 0.180
#> GSM559397     1  0.6801      0.845 0.820 0.180
#> GSM559401     1  0.6801      0.845 0.820 0.180
#> GSM559414     1  0.6801      0.845 0.820 0.180
#> GSM559422     2  0.1414      0.858 0.020 0.980
#> GSM559424     1  0.6801      0.845 0.820 0.180
#> GSM559431     2  0.0000      0.871 0.000 1.000
#> GSM559432     2  0.1414      0.858 0.020 0.980
#> GSM559381     1  0.1414      0.931 0.980 0.020
#> GSM559382     2  0.5408      0.928 0.124 0.876
#> GSM559384     1  0.1414      0.931 0.980 0.020
#> GSM559385     1  0.1414      0.931 0.980 0.020
#> GSM559386     2  0.6801      0.889 0.180 0.820
#> GSM559388     2  0.5842      0.919 0.140 0.860
#> GSM559389     1  0.1414      0.931 0.980 0.020
#> GSM559390     1  0.0000      0.930 1.000 0.000
#> GSM559392     2  0.5408      0.928 0.124 0.876
#> GSM559393     2  0.6801      0.889 0.180 0.820
#> GSM559394     1  0.1414      0.931 0.980 0.020
#> GSM559396     1  0.5519      0.867 0.872 0.128
#> GSM559398     2  0.5408      0.928 0.124 0.876
#> GSM559399     1  0.1414      0.931 0.980 0.020
#> GSM559400     2  0.3584      0.889 0.068 0.932
#> GSM559402     1  0.1414      0.931 0.980 0.020
#> GSM559403     1  0.1414      0.931 0.980 0.020
#> GSM559404     1  0.3274      0.906 0.940 0.060
#> GSM559405     1  0.1414      0.931 0.980 0.020
#> GSM559406     1  0.0000      0.930 1.000 0.000
#> GSM559407     1  0.1414      0.931 0.980 0.020
#> GSM559408     1  0.0672      0.931 0.992 0.008
#> GSM559409     1  0.0672      0.931 0.992 0.008
#> GSM559410     1  0.1414      0.931 0.980 0.020
#> GSM559411     1  0.0000      0.930 1.000 0.000
#> GSM559412     1  0.0000      0.930 1.000 0.000
#> GSM559413     1  0.2603      0.913 0.956 0.044
#> GSM559415     1  0.1414      0.931 0.980 0.020
#> GSM559416     1  0.0672      0.931 0.992 0.008
#> GSM559417     2  0.9552      0.607 0.376 0.624
#> GSM559418     2  0.6801      0.889 0.180 0.820
#> GSM559419     1  0.1414      0.931 0.980 0.020
#> GSM559420     1  0.1414      0.931 0.980 0.020
#> GSM559421     2  0.5408      0.928 0.124 0.876
#> GSM559423     2  0.5408      0.928 0.124 0.876
#> GSM559425     2  0.5408      0.928 0.124 0.876
#> GSM559426     2  0.5408      0.928 0.124 0.876
#> GSM559427     2  0.5408      0.928 0.124 0.876
#> GSM559428     2  0.0000      0.871 0.000 1.000
#> GSM559429     2  0.0000      0.871 0.000 1.000
#> GSM559430     2  0.5408      0.928 0.124 0.876

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2 p3
#> GSM559383     3   0.000      1.000 0.000 0.000  1
#> GSM559387     3   0.000      1.000 0.000 0.000  1
#> GSM559391     3   0.000      1.000 0.000 0.000  1
#> GSM559395     3   0.000      1.000 0.000 0.000  1
#> GSM559397     3   0.000      1.000 0.000 0.000  1
#> GSM559401     3   0.000      1.000 0.000 0.000  1
#> GSM559414     3   0.000      1.000 0.000 0.000  1
#> GSM559422     3   0.000      1.000 0.000 0.000  1
#> GSM559424     3   0.000      1.000 0.000 0.000  1
#> GSM559431     2   0.000      0.956 0.000 1.000  0
#> GSM559432     3   0.000      1.000 0.000 0.000  1
#> GSM559381     1   0.000      1.000 1.000 0.000  0
#> GSM559382     2   0.000      0.956 0.000 1.000  0
#> GSM559384     1   0.000      1.000 1.000 0.000  0
#> GSM559385     1   0.000      1.000 1.000 0.000  0
#> GSM559386     2   0.000      0.956 0.000 1.000  0
#> GSM559388     2   0.000      0.956 0.000 1.000  0
#> GSM559389     1   0.000      1.000 1.000 0.000  0
#> GSM559390     1   0.000      1.000 1.000 0.000  0
#> GSM559392     2   0.000      0.956 0.000 1.000  0
#> GSM559393     2   0.362      0.809 0.136 0.864  0
#> GSM559394     1   0.000      1.000 1.000 0.000  0
#> GSM559396     3   0.000      1.000 0.000 0.000  1
#> GSM559398     2   0.000      0.956 0.000 1.000  0
#> GSM559399     1   0.000      1.000 1.000 0.000  0
#> GSM559400     2   0.000      0.956 0.000 1.000  0
#> GSM559402     1   0.000      1.000 1.000 0.000  0
#> GSM559403     1   0.000      1.000 1.000 0.000  0
#> GSM559404     1   0.000      1.000 1.000 0.000  0
#> GSM559405     1   0.000      1.000 1.000 0.000  0
#> GSM559406     1   0.000      1.000 1.000 0.000  0
#> GSM559407     1   0.000      1.000 1.000 0.000  0
#> GSM559408     1   0.000      1.000 1.000 0.000  0
#> GSM559409     1   0.000      1.000 1.000 0.000  0
#> GSM559410     1   0.000      1.000 1.000 0.000  0
#> GSM559411     1   0.000      1.000 1.000 0.000  0
#> GSM559412     1   0.000      1.000 1.000 0.000  0
#> GSM559413     1   0.000      1.000 1.000 0.000  0
#> GSM559415     1   0.000      1.000 1.000 0.000  0
#> GSM559416     1   0.000      1.000 1.000 0.000  0
#> GSM559417     1   0.000      1.000 1.000 0.000  0
#> GSM559418     2   0.623      0.250 0.436 0.564  0
#> GSM559419     1   0.000      1.000 1.000 0.000  0
#> GSM559420     1   0.000      1.000 1.000 0.000  0
#> GSM559421     2   0.000      0.956 0.000 1.000  0
#> GSM559423     2   0.000      0.956 0.000 1.000  0
#> GSM559425     2   0.000      0.956 0.000 1.000  0
#> GSM559426     2   0.000      0.956 0.000 1.000  0
#> GSM559427     2   0.000      0.956 0.000 1.000  0
#> GSM559428     2   0.000      0.956 0.000 1.000  0
#> GSM559429     2   0.000      0.956 0.000 1.000  0
#> GSM559430     2   0.000      0.956 0.000 1.000  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2   p3    p4
#> GSM559383     3  0.0000      0.989 0.000 0.000 1.00 0.000
#> GSM559387     3  0.0000      0.989 0.000 0.000 1.00 0.000
#> GSM559391     3  0.0000      0.989 0.000 0.000 1.00 0.000
#> GSM559395     3  0.0000      0.989 0.000 0.000 1.00 0.000
#> GSM559397     3  0.0000      0.989 0.000 0.000 1.00 0.000
#> GSM559401     3  0.0000      0.989 0.000 0.000 1.00 0.000
#> GSM559414     3  0.0000      0.989 0.000 0.000 1.00 0.000
#> GSM559422     3  0.0000      0.989 0.000 0.000 1.00 0.000
#> GSM559424     3  0.0000      0.989 0.000 0.000 1.00 0.000
#> GSM559431     2  0.0000      0.986 0.000 1.000 0.00 0.000
#> GSM559432     3  0.1637      0.932 0.000 0.060 0.94 0.000
#> GSM559381     1  0.2921      0.830 0.860 0.000 0.00 0.140
#> GSM559382     2  0.0000      0.986 0.000 1.000 0.00 0.000
#> GSM559384     1  0.3311      0.806 0.828 0.000 0.00 0.172
#> GSM559385     1  0.0000      0.848 1.000 0.000 0.00 0.000
#> GSM559386     2  0.2775      0.894 0.084 0.896 0.00 0.020
#> GSM559388     2  0.0000      0.986 0.000 1.000 0.00 0.000
#> GSM559389     1  0.0707      0.851 0.980 0.000 0.00 0.020
#> GSM559390     4  0.0707      0.917 0.020 0.000 0.00 0.980
#> GSM559392     2  0.0000      0.986 0.000 1.000 0.00 0.000
#> GSM559393     1  0.1389      0.826 0.952 0.048 0.00 0.000
#> GSM559394     1  0.0336      0.847 0.992 0.000 0.00 0.008
#> GSM559396     3  0.1211      0.954 0.000 0.000 0.96 0.040
#> GSM559398     2  0.0000      0.986 0.000 1.000 0.00 0.000
#> GSM559399     1  0.2345      0.827 0.900 0.000 0.00 0.100
#> GSM559400     2  0.2345      0.891 0.000 0.900 0.00 0.100
#> GSM559402     1  0.4382      0.665 0.704 0.000 0.00 0.296
#> GSM559403     1  0.0188      0.849 0.996 0.000 0.00 0.004
#> GSM559404     1  0.2760      0.837 0.872 0.000 0.00 0.128
#> GSM559405     1  0.2530      0.842 0.888 0.000 0.00 0.112
#> GSM559406     4  0.2216      0.936 0.092 0.000 0.00 0.908
#> GSM559407     1  0.4585      0.605 0.668 0.000 0.00 0.332
#> GSM559408     4  0.2345      0.937 0.100 0.000 0.00 0.900
#> GSM559409     4  0.2469      0.933 0.108 0.000 0.00 0.892
#> GSM559410     1  0.2345      0.847 0.900 0.000 0.00 0.100
#> GSM559411     4  0.2408      0.937 0.104 0.000 0.00 0.896
#> GSM559412     4  0.2408      0.937 0.104 0.000 0.00 0.896
#> GSM559413     4  0.2408      0.937 0.104 0.000 0.00 0.896
#> GSM559415     1  0.2345      0.810 0.900 0.000 0.00 0.100
#> GSM559416     4  0.0592      0.901 0.016 0.000 0.00 0.984
#> GSM559417     4  0.0779      0.898 0.016 0.004 0.00 0.980
#> GSM559418     1  0.2924      0.801 0.884 0.016 0.00 0.100
#> GSM559419     4  0.0817      0.903 0.024 0.000 0.00 0.976
#> GSM559420     1  0.4907      0.458 0.580 0.000 0.00 0.420
#> GSM559421     2  0.0000      0.986 0.000 1.000 0.00 0.000
#> GSM559423     2  0.0000      0.986 0.000 1.000 0.00 0.000
#> GSM559425     2  0.0000      0.986 0.000 1.000 0.00 0.000
#> GSM559426     2  0.0000      0.986 0.000 1.000 0.00 0.000
#> GSM559427     2  0.0000      0.986 0.000 1.000 0.00 0.000
#> GSM559428     2  0.0000      0.986 0.000 1.000 0.00 0.000
#> GSM559429     2  0.0000      0.986 0.000 1.000 0.00 0.000
#> GSM559430     2  0.0000      0.986 0.000 1.000 0.00 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
#> GSM559383     3  0.0000    0.93187 0.000 0.000 1.000 0.000 0.000
#> GSM559387     3  0.0000    0.93187 0.000 0.000 1.000 0.000 0.000
#> GSM559391     3  0.0000    0.93187 0.000 0.000 1.000 0.000 0.000
#> GSM559395     3  0.0000    0.93187 0.000 0.000 1.000 0.000 0.000
#> GSM559397     3  0.0000    0.93187 0.000 0.000 1.000 0.000 0.000
#> GSM559401     3  0.0000    0.93187 0.000 0.000 1.000 0.000 0.000
#> GSM559414     3  0.0000    0.93187 0.000 0.000 1.000 0.000 0.000
#> GSM559422     3  0.0898    0.91630 0.020 0.000 0.972 0.008 0.000
#> GSM559424     3  0.0000    0.93187 0.000 0.000 1.000 0.000 0.000
#> GSM559431     2  0.0404    0.93341 0.012 0.988 0.000 0.000 0.000
#> GSM559432     3  0.2899    0.81573 0.020 0.100 0.872 0.008 0.000
#> GSM559381     1  0.4138    0.43833 0.708 0.000 0.000 0.016 0.276
#> GSM559382     2  0.2599    0.89530 0.044 0.904 0.000 0.024 0.028
#> GSM559384     1  0.3452    0.59517 0.820 0.000 0.000 0.032 0.148
#> GSM559385     5  0.0880    0.77085 0.032 0.000 0.000 0.000 0.968
#> GSM559386     2  0.6471    0.54140 0.084 0.612 0.000 0.076 0.228
#> GSM559388     2  0.1173    0.92553 0.020 0.964 0.000 0.012 0.004
#> GSM559389     5  0.4063    0.53087 0.280 0.000 0.000 0.012 0.708
#> GSM559390     4  0.3848    0.60543 0.172 0.000 0.000 0.788 0.040
#> GSM559392     2  0.0324    0.93570 0.004 0.992 0.000 0.004 0.000
#> GSM559393     5  0.1041    0.75024 0.032 0.004 0.000 0.000 0.964
#> GSM559394     5  0.0963    0.77309 0.036 0.000 0.000 0.000 0.964
#> GSM559396     3  0.5328    0.16023 0.468 0.000 0.492 0.028 0.012
#> GSM559398     2  0.0324    0.93570 0.004 0.992 0.000 0.004 0.000
#> GSM559399     5  0.5166    0.69407 0.108 0.000 0.000 0.212 0.680
#> GSM559400     2  0.4674    0.59481 0.024 0.676 0.000 0.292 0.008
#> GSM559402     1  0.3192    0.61203 0.848 0.000 0.000 0.040 0.112
#> GSM559403     5  0.1608    0.76137 0.072 0.000 0.000 0.000 0.928
#> GSM559404     1  0.4622    0.56231 0.684 0.000 0.000 0.040 0.276
#> GSM559405     1  0.4256    0.17987 0.564 0.000 0.000 0.000 0.436
#> GSM559406     4  0.4626    0.37314 0.364 0.000 0.000 0.616 0.020
#> GSM559407     1  0.3705    0.60676 0.816 0.000 0.000 0.064 0.120
#> GSM559408     4  0.4829    0.04987 0.480 0.000 0.000 0.500 0.020
#> GSM559409     1  0.4848    0.00951 0.556 0.000 0.000 0.420 0.024
#> GSM559410     5  0.5043    0.29642 0.356 0.000 0.000 0.044 0.600
#> GSM559411     1  0.3992    0.39913 0.720 0.000 0.000 0.268 0.012
#> GSM559412     1  0.4744    0.08718 0.572 0.000 0.000 0.408 0.020
#> GSM559413     1  0.4437    0.32171 0.664 0.000 0.000 0.316 0.020
#> GSM559415     5  0.4342    0.71817 0.040 0.000 0.000 0.232 0.728
#> GSM559416     4  0.0963    0.66264 0.036 0.000 0.000 0.964 0.000
#> GSM559417     4  0.0963    0.66264 0.036 0.000 0.000 0.964 0.000
#> GSM559418     5  0.4587    0.71954 0.040 0.008 0.000 0.228 0.724
#> GSM559419     4  0.3409    0.60079 0.144 0.000 0.000 0.824 0.032
#> GSM559420     1  0.4277    0.52844 0.768 0.000 0.000 0.156 0.076
#> GSM559421     2  0.0162    0.93632 0.000 0.996 0.000 0.004 0.000
#> GSM559423     2  0.0000    0.93655 0.000 1.000 0.000 0.000 0.000
#> GSM559425     2  0.0000    0.93655 0.000 1.000 0.000 0.000 0.000
#> GSM559426     2  0.0162    0.93625 0.004 0.996 0.000 0.000 0.000
#> GSM559427     2  0.0000    0.93655 0.000 1.000 0.000 0.000 0.000
#> GSM559428     2  0.2312    0.89764 0.060 0.912 0.000 0.012 0.016
#> GSM559429     2  0.0703    0.93037 0.024 0.976 0.000 0.000 0.000
#> GSM559430     2  0.0000    0.93655 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
#> GSM559383     3  0.0000     0.9008 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559387     3  0.0000     0.9008 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559391     3  0.0000     0.9008 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559395     3  0.0000     0.9008 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559397     3  0.0146     0.9002 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM559401     3  0.0603     0.8939 0.000 0.000 0.980 0.000 0.004 0.016
#> GSM559414     3  0.0146     0.9002 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM559422     3  0.2331     0.8394 0.000 0.000 0.888 0.000 0.032 0.080
#> GSM559424     3  0.0000     0.9008 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559431     2  0.0777     0.8650 0.000 0.972 0.000 0.000 0.004 0.024
#> GSM559432     3  0.4357     0.7202 0.000 0.104 0.768 0.000 0.040 0.088
#> GSM559381     6  0.6162     0.4505 0.208 0.008 0.000 0.216 0.020 0.548
#> GSM559382     2  0.4776     0.7254 0.036 0.712 0.000 0.000 0.068 0.184
#> GSM559384     6  0.6296     0.3114 0.112 0.000 0.000 0.416 0.052 0.420
#> GSM559385     1  0.1245     0.5486 0.952 0.000 0.000 0.032 0.000 0.016
#> GSM559386     2  0.7442     0.2179 0.156 0.376 0.000 0.020 0.100 0.348
#> GSM559388     2  0.2803     0.8225 0.004 0.864 0.000 0.000 0.048 0.084
#> GSM559389     1  0.5171    -0.0855 0.512 0.000 0.000 0.076 0.004 0.408
#> GSM559390     5  0.6290     0.3795 0.032 0.000 0.000 0.332 0.472 0.164
#> GSM559392     2  0.1088     0.8641 0.000 0.960 0.000 0.000 0.024 0.016
#> GSM559393     1  0.2122     0.5059 0.900 0.000 0.000 0.000 0.024 0.076
#> GSM559394     1  0.1218     0.5573 0.956 0.000 0.000 0.028 0.012 0.004
#> GSM559396     3  0.7120    -0.2563 0.008 0.000 0.352 0.236 0.056 0.348
#> GSM559398     2  0.0914     0.8661 0.000 0.968 0.000 0.000 0.016 0.016
#> GSM559399     1  0.6584     0.3921 0.460 0.000 0.000 0.056 0.320 0.164
#> GSM559400     2  0.5827     0.4348 0.008 0.552 0.000 0.012 0.300 0.128
#> GSM559402     4  0.5516    -0.3115 0.080 0.000 0.000 0.584 0.032 0.304
#> GSM559403     1  0.2309     0.5359 0.888 0.000 0.000 0.084 0.000 0.028
#> GSM559404     4  0.5438    -0.0924 0.284 0.000 0.000 0.572 0.004 0.140
#> GSM559405     1  0.6572    -0.3497 0.372 0.000 0.000 0.332 0.024 0.272
#> GSM559406     4  0.4527     0.1761 0.012 0.000 0.000 0.664 0.284 0.040
#> GSM559407     4  0.5421    -0.1219 0.088 0.000 0.000 0.636 0.040 0.236
#> GSM559408     4  0.3420     0.3876 0.008 0.000 0.000 0.776 0.204 0.012
#> GSM559409     4  0.3033     0.5010 0.012 0.000 0.000 0.848 0.108 0.032
#> GSM559410     1  0.6041     0.1823 0.512 0.000 0.000 0.348 0.068 0.072
#> GSM559411     4  0.1297     0.4896 0.000 0.000 0.000 0.948 0.012 0.040
#> GSM559412     4  0.2400     0.5153 0.004 0.000 0.000 0.872 0.116 0.008
#> GSM559413     4  0.0692     0.5237 0.000 0.000 0.000 0.976 0.020 0.004
#> GSM559415     1  0.5218     0.4308 0.544 0.000 0.000 0.012 0.376 0.068
#> GSM559416     5  0.3329     0.7382 0.004 0.000 0.000 0.236 0.756 0.004
#> GSM559417     5  0.3543     0.7394 0.004 0.000 0.000 0.212 0.764 0.020
#> GSM559418     1  0.5269     0.4174 0.532 0.008 0.000 0.000 0.380 0.080
#> GSM559419     5  0.4988     0.6208 0.024 0.000 0.000 0.224 0.672 0.080
#> GSM559420     4  0.6570    -0.4708 0.052 0.000 0.000 0.400 0.156 0.392
#> GSM559421     2  0.0508     0.8688 0.000 0.984 0.000 0.000 0.004 0.012
#> GSM559423     2  0.0260     0.8696 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM559425     2  0.0146     0.8693 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM559426     2  0.0806     0.8668 0.000 0.972 0.000 0.000 0.008 0.020
#> GSM559427     2  0.0000     0.8697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559428     2  0.4312     0.7237 0.008 0.724 0.000 0.000 0.064 0.204
#> GSM559429     2  0.2679     0.8178 0.000 0.864 0.000 0.000 0.040 0.096
#> GSM559430     2  0.0000     0.8697 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-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 disease.state(p) k
#> CV:skmeans 52         6.10e-01 2
#> CV:skmeans 51         1.98e-09 3
#> CV:skmeans 51         1.01e-08 4
#> CV:skmeans 42         1.66e-07 5
#> CV:skmeans 33         8.40e-06 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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

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

collect_plots(res)

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 1.000           0.975       0.974         0.3202 0.683   0.683
#> 3 3 0.999           0.962       0.985         0.7828 0.743   0.624
#> 4 4 0.832           0.895       0.944         0.2335 0.860   0.677
#> 5 5 0.825           0.886       0.934         0.0233 0.988   0.959
#> 6 6 0.850           0.830       0.917         0.0230 0.993   0.976

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
#> GSM559383     2   0.358      0.992 0.068 0.932
#> GSM559387     2   0.358      0.992 0.068 0.932
#> GSM559391     2   0.358      0.992 0.068 0.932
#> GSM559395     2   0.358      0.992 0.068 0.932
#> GSM559397     2   0.358      0.992 0.068 0.932
#> GSM559401     2   0.358      0.992 0.068 0.932
#> GSM559414     2   0.358      0.992 0.068 0.932
#> GSM559422     2   0.358      0.992 0.068 0.932
#> GSM559424     2   0.358      0.992 0.068 0.932
#> GSM559431     1   0.358      0.945 0.932 0.068
#> GSM559432     2   0.000      0.929 0.000 1.000
#> GSM559381     1   0.000      0.981 1.000 0.000
#> GSM559382     1   0.000      0.981 1.000 0.000
#> GSM559384     1   0.000      0.981 1.000 0.000
#> GSM559385     1   0.000      0.981 1.000 0.000
#> GSM559386     1   0.000      0.981 1.000 0.000
#> GSM559388     1   0.118      0.973 0.984 0.016
#> GSM559389     1   0.000      0.981 1.000 0.000
#> GSM559390     1   0.000      0.981 1.000 0.000
#> GSM559392     1   0.358      0.945 0.932 0.068
#> GSM559393     1   0.000      0.981 1.000 0.000
#> GSM559394     1   0.000      0.981 1.000 0.000
#> GSM559396     1   0.000      0.981 1.000 0.000
#> GSM559398     1   0.358      0.945 0.932 0.068
#> GSM559399     1   0.000      0.981 1.000 0.000
#> GSM559400     1   0.311      0.952 0.944 0.056
#> GSM559402     1   0.000      0.981 1.000 0.000
#> GSM559403     1   0.000      0.981 1.000 0.000
#> GSM559404     1   0.000      0.981 1.000 0.000
#> GSM559405     1   0.000      0.981 1.000 0.000
#> GSM559406     1   0.000      0.981 1.000 0.000
#> GSM559407     1   0.000      0.981 1.000 0.000
#> GSM559408     1   0.000      0.981 1.000 0.000
#> GSM559409     1   0.000      0.981 1.000 0.000
#> GSM559410     1   0.000      0.981 1.000 0.000
#> GSM559411     1   0.000      0.981 1.000 0.000
#> GSM559412     1   0.000      0.981 1.000 0.000
#> GSM559413     1   0.000      0.981 1.000 0.000
#> GSM559415     1   0.000      0.981 1.000 0.000
#> GSM559416     1   0.000      0.981 1.000 0.000
#> GSM559417     1   0.000      0.981 1.000 0.000
#> GSM559418     1   0.000      0.981 1.000 0.000
#> GSM559419     1   0.000      0.981 1.000 0.000
#> GSM559420     1   0.000      0.981 1.000 0.000
#> GSM559421     1   0.358      0.945 0.932 0.068
#> GSM559423     1   0.358      0.945 0.932 0.068
#> GSM559425     1   0.358      0.945 0.932 0.068
#> GSM559426     1   0.358      0.945 0.932 0.068
#> GSM559427     1   0.358      0.945 0.932 0.068
#> GSM559428     1   0.000      0.981 1.000 0.000
#> GSM559429     1   0.295      0.954 0.948 0.052
#> GSM559430     1   0.358      0.945 0.932 0.068

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2   p3
#> GSM559383     3  0.0000      0.979 0.000 0.000 1.00
#> GSM559387     3  0.0000      0.979 0.000 0.000 1.00
#> GSM559391     3  0.0000      0.979 0.000 0.000 1.00
#> GSM559395     3  0.0000      0.979 0.000 0.000 1.00
#> GSM559397     3  0.0000      0.979 0.000 0.000 1.00
#> GSM559401     3  0.0000      0.979 0.000 0.000 1.00
#> GSM559414     3  0.0000      0.979 0.000 0.000 1.00
#> GSM559422     3  0.0000      0.979 0.000 0.000 1.00
#> GSM559424     3  0.0000      0.979 0.000 0.000 1.00
#> GSM559431     2  0.0000      0.942 0.000 1.000 0.00
#> GSM559432     3  0.4291      0.775 0.000 0.180 0.82
#> GSM559381     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559382     1  0.0747      0.977 0.984 0.016 0.00
#> GSM559384     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559385     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559386     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559388     1  0.4399      0.760 0.812 0.188 0.00
#> GSM559389     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559390     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559392     2  0.1529      0.909 0.040 0.960 0.00
#> GSM559393     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559394     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559396     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559398     2  0.0000      0.942 0.000 1.000 0.00
#> GSM559399     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559400     2  0.5431      0.578 0.284 0.716 0.00
#> GSM559402     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559403     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559404     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559405     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559406     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559407     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559408     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559409     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559410     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559411     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559412     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559413     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559415     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559416     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559417     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559418     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559419     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559420     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559421     2  0.0000      0.942 0.000 1.000 0.00
#> GSM559423     2  0.0000      0.942 0.000 1.000 0.00
#> GSM559425     2  0.0000      0.942 0.000 1.000 0.00
#> GSM559426     2  0.0000      0.942 0.000 1.000 0.00
#> GSM559427     2  0.0000      0.942 0.000 1.000 0.00
#> GSM559428     1  0.0000      0.993 1.000 0.000 0.00
#> GSM559429     2  0.2261      0.876 0.068 0.932 0.00
#> GSM559430     2  0.0000      0.942 0.000 1.000 0.00

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2   p3    p4
#> GSM559383     3  0.0000      0.978 0.000 0.000 1.00 0.000
#> GSM559387     3  0.0000      0.978 0.000 0.000 1.00 0.000
#> GSM559391     3  0.0000      0.978 0.000 0.000 1.00 0.000
#> GSM559395     3  0.0000      0.978 0.000 0.000 1.00 0.000
#> GSM559397     3  0.0000      0.978 0.000 0.000 1.00 0.000
#> GSM559401     3  0.0000      0.978 0.000 0.000 1.00 0.000
#> GSM559414     3  0.0000      0.978 0.000 0.000 1.00 0.000
#> GSM559422     3  0.0000      0.978 0.000 0.000 1.00 0.000
#> GSM559424     3  0.0000      0.978 0.000 0.000 1.00 0.000
#> GSM559431     2  0.0000      0.977 0.000 1.000 0.00 0.000
#> GSM559432     3  0.3400      0.778 0.000 0.180 0.82 0.000
#> GSM559381     1  0.0000      0.924 1.000 0.000 0.00 0.000
#> GSM559382     4  0.3311      0.811 0.172 0.000 0.00 0.828
#> GSM559384     1  0.0000      0.924 1.000 0.000 0.00 0.000
#> GSM559385     1  0.0000      0.924 1.000 0.000 0.00 0.000
#> GSM559386     4  0.4543      0.695 0.324 0.000 0.00 0.676
#> GSM559388     4  0.5321      0.716 0.296 0.032 0.00 0.672
#> GSM559389     1  0.0000      0.924 1.000 0.000 0.00 0.000
#> GSM559390     4  0.0336      0.808 0.008 0.000 0.00 0.992
#> GSM559392     2  0.2892      0.878 0.068 0.896 0.00 0.036
#> GSM559393     1  0.0000      0.924 1.000 0.000 0.00 0.000
#> GSM559394     1  0.0000      0.924 1.000 0.000 0.00 0.000
#> GSM559396     1  0.0000      0.924 1.000 0.000 0.00 0.000
#> GSM559398     2  0.0336      0.975 0.000 0.992 0.00 0.008
#> GSM559399     1  0.0000      0.924 1.000 0.000 0.00 0.000
#> GSM559400     4  0.3219      0.809 0.164 0.000 0.00 0.836
#> GSM559402     1  0.0000      0.924 1.000 0.000 0.00 0.000
#> GSM559403     1  0.0000      0.924 1.000 0.000 0.00 0.000
#> GSM559404     1  0.0000      0.924 1.000 0.000 0.00 0.000
#> GSM559405     1  0.0000      0.924 1.000 0.000 0.00 0.000
#> GSM559406     4  0.1302      0.822 0.044 0.000 0.00 0.956
#> GSM559407     1  0.1637      0.893 0.940 0.000 0.00 0.060
#> GSM559408     1  0.3219      0.823 0.836 0.000 0.00 0.164
#> GSM559409     1  0.3219      0.823 0.836 0.000 0.00 0.164
#> GSM559410     1  0.3219      0.823 0.836 0.000 0.00 0.164
#> GSM559411     1  0.3219      0.823 0.836 0.000 0.00 0.164
#> GSM559412     1  0.3219      0.823 0.836 0.000 0.00 0.164
#> GSM559413     1  0.3219      0.823 0.836 0.000 0.00 0.164
#> GSM559415     1  0.0000      0.924 1.000 0.000 0.00 0.000
#> GSM559416     4  0.1118      0.822 0.036 0.000 0.00 0.964
#> GSM559417     4  0.1302      0.825 0.044 0.000 0.00 0.956
#> GSM559418     1  0.0000      0.924 1.000 0.000 0.00 0.000
#> GSM559419     1  0.1716      0.875 0.936 0.000 0.00 0.064
#> GSM559420     1  0.0000      0.924 1.000 0.000 0.00 0.000
#> GSM559421     2  0.1118      0.960 0.000 0.964 0.00 0.036
#> GSM559423     2  0.1042      0.960 0.020 0.972 0.00 0.008
#> GSM559425     2  0.0000      0.977 0.000 1.000 0.00 0.000
#> GSM559426     2  0.0000      0.977 0.000 1.000 0.00 0.000
#> GSM559427     2  0.0000      0.977 0.000 1.000 0.00 0.000
#> GSM559428     1  0.4382      0.444 0.704 0.000 0.00 0.296
#> GSM559429     2  0.0336      0.974 0.008 0.992 0.00 0.000
#> GSM559430     2  0.0000      0.977 0.000 1.000 0.00 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
#> GSM559383     3  0.0000      1.000 0.000 0.000 1.00 0.000 0.000
#> GSM559387     3  0.0000      1.000 0.000 0.000 1.00 0.000 0.000
#> GSM559391     3  0.0000      1.000 0.000 0.000 1.00 0.000 0.000
#> GSM559395     3  0.0000      1.000 0.000 0.000 1.00 0.000 0.000
#> GSM559397     3  0.0000      1.000 0.000 0.000 1.00 0.000 0.000
#> GSM559401     3  0.0000      1.000 0.000 0.000 1.00 0.000 0.000
#> GSM559414     3  0.0000      1.000 0.000 0.000 1.00 0.000 0.000
#> GSM559422     5  0.2732      1.000 0.000 0.000 0.16 0.000 0.840
#> GSM559424     3  0.0000      1.000 0.000 0.000 1.00 0.000 0.000
#> GSM559431     2  0.0000      0.942 0.000 1.000 0.00 0.000 0.000
#> GSM559432     5  0.2732      1.000 0.000 0.000 0.16 0.000 0.840
#> GSM559381     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM559382     4  0.3093      0.756 0.168 0.000 0.00 0.824 0.008
#> GSM559384     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM559385     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM559386     4  0.4366      0.615 0.320 0.000 0.00 0.664 0.016
#> GSM559388     4  0.5996      0.657 0.192 0.024 0.00 0.644 0.140
#> GSM559389     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM559390     4  0.0162      0.757 0.004 0.000 0.00 0.996 0.000
#> GSM559392     2  0.3521      0.856 0.008 0.824 0.00 0.024 0.144
#> GSM559393     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM559394     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM559396     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM559398     2  0.2439      0.888 0.000 0.876 0.00 0.004 0.120
#> GSM559399     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM559400     4  0.2773      0.756 0.164 0.000 0.00 0.836 0.000
#> GSM559402     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM559403     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM559404     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM559405     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM559406     4  0.0880      0.768 0.032 0.000 0.00 0.968 0.000
#> GSM559407     1  0.1410      0.895 0.940 0.000 0.00 0.060 0.000
#> GSM559408     1  0.2773      0.827 0.836 0.000 0.00 0.164 0.000
#> GSM559409     1  0.2773      0.827 0.836 0.000 0.00 0.164 0.000
#> GSM559410     1  0.2773      0.827 0.836 0.000 0.00 0.164 0.000
#> GSM559411     1  0.2773      0.827 0.836 0.000 0.00 0.164 0.000
#> GSM559412     1  0.2773      0.827 0.836 0.000 0.00 0.164 0.000
#> GSM559413     1  0.2773      0.827 0.836 0.000 0.00 0.164 0.000
#> GSM559415     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM559416     4  0.0703      0.769 0.024 0.000 0.00 0.976 0.000
#> GSM559417     4  0.0880      0.773 0.032 0.000 0.00 0.968 0.000
#> GSM559418     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM559419     1  0.1845      0.870 0.928 0.000 0.00 0.056 0.016
#> GSM559420     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM559421     2  0.3241      0.863 0.000 0.832 0.00 0.024 0.144
#> GSM559423     2  0.1082      0.934 0.008 0.964 0.00 0.000 0.028
#> GSM559425     2  0.0000      0.942 0.000 1.000 0.00 0.000 0.000
#> GSM559426     2  0.0510      0.938 0.000 0.984 0.00 0.000 0.016
#> GSM559427     2  0.0000      0.942 0.000 1.000 0.00 0.000 0.000
#> GSM559428     1  0.4206      0.444 0.696 0.000 0.00 0.288 0.016
#> GSM559429     2  0.0798      0.935 0.008 0.976 0.00 0.000 0.016
#> GSM559430     2  0.0290      0.941 0.000 0.992 0.00 0.000 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
#> GSM559383     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> GSM559387     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> GSM559391     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> GSM559395     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> GSM559397     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> GSM559401     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> GSM559414     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> GSM559422     5  0.0000      1.000 0.000 0.000  0 0.000  1 0.000
#> GSM559424     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> GSM559431     2  0.0146      0.796 0.000 0.996  0 0.000  0 0.004
#> GSM559432     5  0.0000      1.000 0.000 0.000  0 0.000  1 0.000
#> GSM559381     1  0.0000      0.929 1.000 0.000  0 0.000  0 0.000
#> GSM559382     4  0.3469      0.716 0.088 0.000  0 0.808  0 0.104
#> GSM559384     1  0.0000      0.929 1.000 0.000  0 0.000  0 0.000
#> GSM559385     1  0.0000      0.929 1.000 0.000  0 0.000  0 0.000
#> GSM559386     4  0.4892      0.548 0.248 0.000  0 0.640  0 0.112
#> GSM559388     4  0.5712      0.388 0.096 0.020  0 0.468  0 0.416
#> GSM559389     1  0.0000      0.929 1.000 0.000  0 0.000  0 0.000
#> GSM559390     4  0.0000      0.757 0.000 0.000  0 1.000  0 0.000
#> GSM559392     2  0.3684      0.603 0.000 0.628  0 0.000  0 0.372
#> GSM559393     1  0.1204      0.898 0.944 0.000  0 0.000  0 0.056
#> GSM559394     1  0.0000      0.929 1.000 0.000  0 0.000  0 0.000
#> GSM559396     1  0.0000      0.929 1.000 0.000  0 0.000  0 0.000
#> GSM559398     2  0.2730      0.722 0.000 0.808  0 0.000  0 0.192
#> GSM559399     1  0.0000      0.929 1.000 0.000  0 0.000  0 0.000
#> GSM559400     4  0.3327      0.719 0.088 0.000  0 0.820  0 0.092
#> GSM559402     1  0.0000      0.929 1.000 0.000  0 0.000  0 0.000
#> GSM559403     1  0.0000      0.929 1.000 0.000  0 0.000  0 0.000
#> GSM559404     1  0.0000      0.929 1.000 0.000  0 0.000  0 0.000
#> GSM559405     1  0.0000      0.929 1.000 0.000  0 0.000  0 0.000
#> GSM559406     4  0.0260      0.757 0.008 0.000  0 0.992  0 0.000
#> GSM559407     1  0.0632      0.919 0.976 0.000  0 0.024  0 0.000
#> GSM559408     1  0.2631      0.822 0.820 0.000  0 0.180  0 0.000
#> GSM559409     1  0.2631      0.822 0.820 0.000  0 0.180  0 0.000
#> GSM559410     1  0.2454      0.838 0.840 0.000  0 0.160  0 0.000
#> GSM559411     1  0.1765      0.878 0.904 0.000  0 0.096  0 0.000
#> GSM559412     1  0.2631      0.822 0.820 0.000  0 0.180  0 0.000
#> GSM559413     1  0.2631      0.822 0.820 0.000  0 0.180  0 0.000
#> GSM559415     1  0.0000      0.929 1.000 0.000  0 0.000  0 0.000
#> GSM559416     4  0.0000      0.757 0.000 0.000  0 1.000  0 0.000
#> GSM559417     4  0.0632      0.754 0.024 0.000  0 0.976  0 0.000
#> GSM559418     1  0.0000      0.929 1.000 0.000  0 0.000  0 0.000
#> GSM559419     1  0.1549      0.891 0.936 0.000  0 0.044  0 0.020
#> GSM559420     1  0.0000      0.929 1.000 0.000  0 0.000  0 0.000
#> GSM559421     2  0.3547      0.649 0.000 0.668  0 0.000  0 0.332
#> GSM559423     2  0.2416      0.763 0.000 0.844  0 0.000  0 0.156
#> GSM559425     2  0.0000      0.798 0.000 1.000  0 0.000  0 0.000
#> GSM559426     2  0.1610      0.779 0.000 0.916  0 0.000  0 0.084
#> GSM559427     2  0.0000      0.798 0.000 1.000  0 0.000  0 0.000
#> GSM559428     1  0.5048      0.344 0.616 0.000  0 0.264  0 0.120
#> GSM559429     6  0.3547      0.000 0.000 0.332  0 0.000  0 0.668
#> GSM559430     2  0.0547      0.802 0.000 0.980  0 0.000  0 0.020

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

consensus_heatmap(res, k = 2)

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 disease.state(p) k
#> CV:pam 52         1.99e-10 2
#> CV:pam 52         7.80e-11 3
#> CV:pam 51         6.63e-10 4
#> CV:pam 51         2.87e-09 5
#> CV:pam 49         6.75e-09 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 21167 rows and 52 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 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-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 1.000           0.976       0.986         0.3306 0.683   0.683
#> 3 3 0.628           0.842       0.908         0.8546 0.716   0.584
#> 4 4 0.699           0.548       0.805         0.1460 0.925   0.811
#> 5 5 0.683           0.670       0.801         0.0472 0.851   0.607
#> 6 6 0.730           0.633       0.787         0.0484 0.948   0.830

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
#> GSM559383     2  0.0000      1.000 0.000 1.000
#> GSM559387     2  0.0000      1.000 0.000 1.000
#> GSM559391     2  0.0000      1.000 0.000 1.000
#> GSM559395     2  0.0000      1.000 0.000 1.000
#> GSM559397     2  0.0000      1.000 0.000 1.000
#> GSM559401     2  0.0000      1.000 0.000 1.000
#> GSM559414     2  0.0000      1.000 0.000 1.000
#> GSM559422     2  0.0000      1.000 0.000 1.000
#> GSM559424     2  0.0000      1.000 0.000 1.000
#> GSM559431     1  0.6148      0.844 0.848 0.152
#> GSM559432     2  0.0000      1.000 0.000 1.000
#> GSM559381     1  0.0000      0.982 1.000 0.000
#> GSM559382     1  0.1414      0.976 0.980 0.020
#> GSM559384     1  0.0000      0.982 1.000 0.000
#> GSM559385     1  0.0376      0.981 0.996 0.004
#> GSM559386     1  0.0000      0.982 1.000 0.000
#> GSM559388     1  0.1414      0.976 0.980 0.020
#> GSM559389     1  0.0000      0.982 1.000 0.000
#> GSM559390     1  0.0000      0.982 1.000 0.000
#> GSM559392     1  0.1414      0.976 0.980 0.020
#> GSM559393     1  0.0376      0.981 0.996 0.004
#> GSM559394     1  0.0376      0.981 0.996 0.004
#> GSM559396     1  0.2778      0.956 0.952 0.048
#> GSM559398     1  0.1414      0.976 0.980 0.020
#> GSM559399     1  0.0000      0.982 1.000 0.000
#> GSM559400     1  0.1414      0.976 0.980 0.020
#> GSM559402     1  0.0000      0.982 1.000 0.000
#> GSM559403     1  0.0376      0.981 0.996 0.004
#> GSM559404     1  0.0376      0.981 0.996 0.004
#> GSM559405     1  0.0000      0.982 1.000 0.000
#> GSM559406     1  0.0000      0.982 1.000 0.000
#> GSM559407     1  0.0000      0.982 1.000 0.000
#> GSM559408     1  0.0000      0.982 1.000 0.000
#> GSM559409     1  0.0000      0.982 1.000 0.000
#> GSM559410     1  0.0000      0.982 1.000 0.000
#> GSM559411     1  0.0000      0.982 1.000 0.000
#> GSM559412     1  0.0000      0.982 1.000 0.000
#> GSM559413     1  0.0000      0.982 1.000 0.000
#> GSM559415     1  0.0000      0.982 1.000 0.000
#> GSM559416     1  0.0376      0.981 0.996 0.004
#> GSM559417     1  0.0000      0.982 1.000 0.000
#> GSM559418     1  0.0000      0.982 1.000 0.000
#> GSM559419     1  0.0000      0.982 1.000 0.000
#> GSM559420     1  0.0000      0.982 1.000 0.000
#> GSM559421     1  0.1414      0.976 0.980 0.020
#> GSM559423     1  0.1414      0.976 0.980 0.020
#> GSM559425     1  0.1414      0.976 0.980 0.020
#> GSM559426     1  0.1414      0.976 0.980 0.020
#> GSM559427     1  0.1414      0.976 0.980 0.020
#> GSM559428     1  0.6148      0.844 0.848 0.152
#> GSM559429     1  0.6148      0.844 0.848 0.152
#> GSM559430     1  0.1414      0.976 0.980 0.020

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2   p3
#> GSM559383     3  0.0000      0.998 0.000 0.000 1.00
#> GSM559387     3  0.0000      0.998 0.000 0.000 1.00
#> GSM559391     3  0.0000      0.998 0.000 0.000 1.00
#> GSM559395     3  0.0000      0.998 0.000 0.000 1.00
#> GSM559397     3  0.0000      0.998 0.000 0.000 1.00
#> GSM559401     3  0.0000      0.998 0.000 0.000 1.00
#> GSM559414     3  0.0000      0.998 0.000 0.000 1.00
#> GSM559422     3  0.0000      0.998 0.000 0.000 1.00
#> GSM559424     3  0.0000      0.998 0.000 0.000 1.00
#> GSM559431     2  0.0424      0.908 0.008 0.992 0.00
#> GSM559432     3  0.0892      0.979 0.000 0.020 0.98
#> GSM559381     1  0.2796      0.846 0.908 0.092 0.00
#> GSM559382     2  0.3192      0.866 0.112 0.888 0.00
#> GSM559384     1  0.2878      0.847 0.904 0.096 0.00
#> GSM559385     1  0.4504      0.690 0.804 0.196 0.00
#> GSM559386     1  0.6095      0.468 0.608 0.392 0.00
#> GSM559388     2  0.1529      0.934 0.040 0.960 0.00
#> GSM559389     1  0.0237      0.845 0.996 0.004 0.00
#> GSM559390     1  0.4399      0.805 0.812 0.188 0.00
#> GSM559392     2  0.1411      0.936 0.036 0.964 0.00
#> GSM559393     1  0.4452      0.691 0.808 0.192 0.00
#> GSM559394     1  0.4504      0.690 0.804 0.196 0.00
#> GSM559396     1  0.5785      0.646 0.668 0.332 0.00
#> GSM559398     2  0.1411      0.936 0.036 0.964 0.00
#> GSM559399     1  0.2711      0.847 0.912 0.088 0.00
#> GSM559400     1  0.6225      0.403 0.568 0.432 0.00
#> GSM559402     1  0.0747      0.848 0.984 0.016 0.00
#> GSM559403     1  0.0424      0.844 0.992 0.008 0.00
#> GSM559404     1  0.3340      0.801 0.880 0.120 0.00
#> GSM559405     1  0.0237      0.845 0.996 0.004 0.00
#> GSM559406     1  0.4555      0.796 0.800 0.200 0.00
#> GSM559407     1  0.0237      0.845 0.996 0.004 0.00
#> GSM559408     1  0.0424      0.848 0.992 0.008 0.00
#> GSM559409     1  0.1964      0.851 0.944 0.056 0.00
#> GSM559410     1  0.0237      0.845 0.996 0.004 0.00
#> GSM559411     1  0.4452      0.802 0.808 0.192 0.00
#> GSM559412     1  0.4002      0.812 0.840 0.160 0.00
#> GSM559413     1  0.4605      0.795 0.796 0.204 0.00
#> GSM559415     1  0.1031      0.845 0.976 0.024 0.00
#> GSM559416     1  0.0000      0.845 1.000 0.000 0.00
#> GSM559417     1  0.2878      0.846 0.904 0.096 0.00
#> GSM559418     1  0.6140      0.436 0.596 0.404 0.00
#> GSM559419     1  0.0424      0.848 0.992 0.008 0.00
#> GSM559420     1  0.3816      0.820 0.852 0.148 0.00
#> GSM559421     2  0.1411      0.936 0.036 0.964 0.00
#> GSM559423     2  0.1411      0.936 0.036 0.964 0.00
#> GSM559425     2  0.1411      0.936 0.036 0.964 0.00
#> GSM559426     2  0.1289      0.933 0.032 0.968 0.00
#> GSM559427     2  0.1411      0.936 0.036 0.964 0.00
#> GSM559428     2  0.5016      0.626 0.240 0.760 0.00
#> GSM559429     2  0.4750      0.664 0.216 0.784 0.00
#> GSM559430     2  0.1411      0.936 0.036 0.964 0.00

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM559383     3  0.0000      0.941 0.000 0.000 1.000 0.000
#> GSM559387     3  0.0000      0.941 0.000 0.000 1.000 0.000
#> GSM559391     3  0.0469      0.936 0.000 0.000 0.988 0.012
#> GSM559395     3  0.0000      0.941 0.000 0.000 1.000 0.000
#> GSM559397     3  0.0000      0.941 0.000 0.000 1.000 0.000
#> GSM559401     3  0.0707      0.936 0.000 0.000 0.980 0.020
#> GSM559414     3  0.0000      0.941 0.000 0.000 1.000 0.000
#> GSM559422     3  0.4431      0.798 0.000 0.000 0.696 0.304
#> GSM559424     3  0.2011      0.885 0.000 0.000 0.920 0.080
#> GSM559431     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM559432     3  0.4431      0.798 0.000 0.000 0.696 0.304
#> GSM559381     1  0.0469      0.616 0.988 0.000 0.000 0.012
#> GSM559382     2  0.2125      0.875 0.004 0.920 0.000 0.076
#> GSM559384     1  0.1022      0.616 0.968 0.000 0.000 0.032
#> GSM559385     1  0.3266      0.552 0.832 0.000 0.000 0.168
#> GSM559386     1  0.2197      0.589 0.916 0.080 0.000 0.004
#> GSM559388     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM559389     1  0.0779      0.615 0.980 0.004 0.000 0.016
#> GSM559390     4  0.4998      0.438 0.488 0.000 0.000 0.512
#> GSM559392     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM559393     1  0.3266      0.552 0.832 0.000 0.000 0.168
#> GSM559394     1  0.3266      0.552 0.832 0.000 0.000 0.168
#> GSM559396     1  0.7100     -0.149 0.512 0.084 0.016 0.388
#> GSM559398     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM559399     1  0.2081      0.602 0.916 0.000 0.000 0.084
#> GSM559400     4  0.5764     -0.181 0.028 0.452 0.000 0.520
#> GSM559402     1  0.2011      0.604 0.920 0.000 0.000 0.080
#> GSM559403     1  0.2281      0.592 0.904 0.000 0.000 0.096
#> GSM559404     1  0.3486      0.539 0.812 0.000 0.000 0.188
#> GSM559405     1  0.0779      0.615 0.980 0.004 0.000 0.016
#> GSM559406     4  0.4998      0.438 0.488 0.000 0.000 0.512
#> GSM559407     1  0.2149      0.600 0.912 0.000 0.000 0.088
#> GSM559408     1  0.4955     -0.367 0.556 0.000 0.000 0.444
#> GSM559409     1  0.4790     -0.210 0.620 0.000 0.000 0.380
#> GSM559410     1  0.2266      0.602 0.912 0.004 0.000 0.084
#> GSM559411     4  0.4998      0.438 0.488 0.000 0.000 0.512
#> GSM559412     1  0.4961     -0.389 0.552 0.000 0.000 0.448
#> GSM559413     1  0.4994     -0.505 0.520 0.000 0.000 0.480
#> GSM559415     1  0.1978      0.609 0.928 0.004 0.000 0.068
#> GSM559416     1  0.4955     -0.337 0.556 0.000 0.000 0.444
#> GSM559417     1  0.4955     -0.337 0.556 0.000 0.000 0.444
#> GSM559418     1  0.2542      0.585 0.904 0.084 0.000 0.012
#> GSM559419     1  0.4955     -0.337 0.556 0.000 0.000 0.444
#> GSM559420     1  0.4477      0.160 0.688 0.000 0.000 0.312
#> GSM559421     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM559423     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM559425     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM559426     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM559427     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM559428     2  0.7002      0.339 0.164 0.568 0.000 0.268
#> GSM559429     2  0.4370      0.739 0.156 0.800 0.000 0.044
#> GSM559430     2  0.0000      0.938 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
#> GSM559383     3  0.0000     0.9764 0.000 0.000 1.000 0.000 0.000
#> GSM559387     3  0.0000     0.9764 0.000 0.000 1.000 0.000 0.000
#> GSM559391     3  0.0000     0.9764 0.000 0.000 1.000 0.000 0.000
#> GSM559395     3  0.0000     0.9764 0.000 0.000 1.000 0.000 0.000
#> GSM559397     3  0.0000     0.9764 0.000 0.000 1.000 0.000 0.000
#> GSM559401     3  0.2561     0.8196 0.000 0.000 0.856 0.000 0.144
#> GSM559414     3  0.0000     0.9764 0.000 0.000 1.000 0.000 0.000
#> GSM559422     5  0.5645    -0.0982 0.000 0.000 0.376 0.084 0.540
#> GSM559424     3  0.0162     0.9738 0.000 0.000 0.996 0.004 0.000
#> GSM559431     2  0.3174     0.8610 0.004 0.844 0.020 0.132 0.000
#> GSM559432     5  0.5645    -0.0982 0.000 0.000 0.376 0.084 0.540
#> GSM559381     1  0.4403     0.5500 0.560 0.004 0.000 0.000 0.436
#> GSM559382     2  0.4078     0.8050 0.096 0.816 0.000 0.064 0.024
#> GSM559384     1  0.4415     0.5466 0.552 0.004 0.000 0.000 0.444
#> GSM559385     4  0.6172     0.9703 0.176 0.000 0.000 0.544 0.280
#> GSM559386     1  0.6932     0.3911 0.480 0.064 0.000 0.092 0.364
#> GSM559388     2  0.0000     0.8913 0.000 1.000 0.000 0.000 0.000
#> GSM559389     1  0.6038     0.3341 0.448 0.004 0.000 0.100 0.448
#> GSM559390     1  0.2753     0.5558 0.856 0.000 0.000 0.136 0.008
#> GSM559392     2  0.0000     0.8913 0.000 1.000 0.000 0.000 0.000
#> GSM559393     4  0.6248     0.9518 0.176 0.000 0.000 0.524 0.300
#> GSM559394     4  0.6172     0.9703 0.176 0.000 0.000 0.544 0.280
#> GSM559396     1  0.4610     0.4931 0.760 0.008 0.000 0.140 0.092
#> GSM559398     2  0.1544     0.8853 0.000 0.932 0.000 0.068 0.000
#> GSM559399     1  0.4273     0.5452 0.552 0.000 0.000 0.000 0.448
#> GSM559400     2  0.6488     0.4816 0.272 0.516 0.000 0.208 0.004
#> GSM559402     1  0.4403     0.5500 0.560 0.004 0.000 0.000 0.436
#> GSM559403     5  0.6145    -0.6789 0.436 0.004 0.000 0.112 0.448
#> GSM559404     4  0.6066     0.9338 0.188 0.000 0.000 0.572 0.240
#> GSM559405     1  0.4425     0.5393 0.544 0.004 0.000 0.000 0.452
#> GSM559406     1  0.1341     0.5634 0.944 0.000 0.000 0.056 0.000
#> GSM559407     1  0.4201     0.5618 0.592 0.000 0.000 0.000 0.408
#> GSM559408     1  0.1544     0.6212 0.932 0.000 0.000 0.000 0.068
#> GSM559409     1  0.1792     0.6228 0.916 0.000 0.000 0.000 0.084
#> GSM559410     1  0.4273     0.5452 0.552 0.000 0.000 0.000 0.448
#> GSM559411     1  0.0451     0.5942 0.988 0.000 0.000 0.008 0.004
#> GSM559412     1  0.1571     0.6192 0.936 0.000 0.000 0.004 0.060
#> GSM559413     1  0.1106     0.6069 0.964 0.000 0.000 0.012 0.024
#> GSM559415     1  0.4425     0.5393 0.544 0.004 0.000 0.000 0.452
#> GSM559416     1  0.2798     0.5032 0.852 0.000 0.000 0.140 0.008
#> GSM559417     1  0.2136     0.5691 0.904 0.000 0.000 0.088 0.008
#> GSM559418     1  0.4425     0.5393 0.544 0.004 0.000 0.000 0.452
#> GSM559419     1  0.0290     0.5985 0.992 0.000 0.000 0.000 0.008
#> GSM559420     1  0.3109     0.5941 0.800 0.000 0.000 0.000 0.200
#> GSM559421     2  0.0404     0.8916 0.000 0.988 0.000 0.012 0.000
#> GSM559423     2  0.0000     0.8913 0.000 1.000 0.000 0.000 0.000
#> GSM559425     2  0.1544     0.8853 0.000 0.932 0.000 0.068 0.000
#> GSM559426     2  0.0566     0.8891 0.000 0.984 0.000 0.012 0.004
#> GSM559427     2  0.1544     0.8853 0.000 0.932 0.000 0.068 0.000
#> GSM559428     2  0.5887     0.6786 0.164 0.668 0.000 0.136 0.032
#> GSM559429     2  0.3351     0.8308 0.028 0.836 0.000 0.132 0.004
#> GSM559430     2  0.1544     0.8853 0.000 0.932 0.000 0.068 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
#> GSM559383     3  0.0000      0.933 0.000 0.000 1.000 0.000 0.000 NA
#> GSM559387     3  0.0000      0.933 0.000 0.000 1.000 0.000 0.000 NA
#> GSM559391     3  0.1556      0.902 0.000 0.000 0.920 0.000 0.000 NA
#> GSM559395     3  0.0000      0.933 0.000 0.000 1.000 0.000 0.000 NA
#> GSM559397     3  0.0000      0.933 0.000 0.000 1.000 0.000 0.000 NA
#> GSM559401     3  0.4614      0.617 0.000 0.000 0.684 0.000 0.208 NA
#> GSM559414     3  0.0000      0.933 0.000 0.000 1.000 0.000 0.000 NA
#> GSM559422     5  0.6212     -0.129 0.000 0.000 0.292 0.012 0.456 NA
#> GSM559424     3  0.1556      0.902 0.000 0.000 0.920 0.000 0.000 NA
#> GSM559431     2  0.4110      0.737 0.000 0.608 0.000 0.016 0.000 NA
#> GSM559432     5  0.6216     -0.124 0.000 0.000 0.288 0.012 0.456 NA
#> GSM559381     1  0.0000      0.695 1.000 0.000 0.000 0.000 0.000 NA
#> GSM559382     2  0.1554      0.823 0.004 0.940 0.000 0.004 0.044 NA
#> GSM559384     1  0.0551      0.694 0.984 0.000 0.000 0.004 0.004 NA
#> GSM559385     4  0.2793      0.983 0.200 0.000 0.000 0.800 0.000 NA
#> GSM559386     1  0.2402      0.603 0.856 0.140 0.000 0.000 0.004 NA
#> GSM559388     2  0.0000      0.836 0.000 1.000 0.000 0.000 0.000 NA
#> GSM559389     1  0.0000      0.695 1.000 0.000 0.000 0.000 0.000 NA
#> GSM559390     1  0.7260      0.166 0.404 0.000 0.000 0.116 0.248 NA
#> GSM559392     2  0.0000      0.836 0.000 1.000 0.000 0.000 0.000 NA
#> GSM559393     4  0.2823      0.980 0.204 0.000 0.000 0.796 0.000 NA
#> GSM559394     4  0.2793      0.983 0.200 0.000 0.000 0.800 0.000 NA
#> GSM559396     5  0.6564     -0.200 0.320 0.000 0.000 0.032 0.420 NA
#> GSM559398     2  0.3198      0.782 0.000 0.740 0.000 0.000 0.000 NA
#> GSM559399     1  0.0405      0.694 0.988 0.000 0.000 0.004 0.008 NA
#> GSM559400     2  0.6225      0.472 0.000 0.576 0.000 0.152 0.072 NA
#> GSM559402     1  0.0363      0.695 0.988 0.000 0.000 0.000 0.012 NA
#> GSM559403     1  0.2048      0.602 0.880 0.000 0.000 0.120 0.000 NA
#> GSM559404     4  0.2562      0.952 0.172 0.000 0.000 0.828 0.000 NA
#> GSM559405     1  0.0146      0.694 0.996 0.000 0.000 0.004 0.000 NA
#> GSM559406     1  0.4165      0.412 0.536 0.000 0.000 0.000 0.452 NA
#> GSM559407     1  0.1267      0.684 0.940 0.000 0.000 0.000 0.060 NA
#> GSM559408     1  0.4118      0.487 0.592 0.000 0.000 0.004 0.396 NA
#> GSM559409     1  0.4100      0.489 0.600 0.000 0.000 0.004 0.388 NA
#> GSM559410     1  0.0405      0.694 0.988 0.000 0.000 0.004 0.008 NA
#> GSM559411     5  0.3998     -0.519 0.492 0.000 0.000 0.000 0.504 NA
#> GSM559412     1  0.4127      0.486 0.588 0.000 0.000 0.004 0.400 NA
#> GSM559413     1  0.3789      0.473 0.584 0.000 0.000 0.000 0.416 NA
#> GSM559415     1  0.0146      0.694 0.996 0.000 0.000 0.004 0.000 NA
#> GSM559416     1  0.6139      0.171 0.384 0.000 0.000 0.004 0.372 NA
#> GSM559417     1  0.6208      0.223 0.416 0.000 0.000 0.012 0.364 NA
#> GSM559418     1  0.0260      0.694 0.992 0.000 0.000 0.008 0.000 NA
#> GSM559419     1  0.4124      0.369 0.516 0.000 0.000 0.004 0.476 NA
#> GSM559420     1  0.3290      0.589 0.744 0.000 0.000 0.004 0.252 NA
#> GSM559421     2  0.0632      0.838 0.000 0.976 0.000 0.000 0.000 NA
#> GSM559423     2  0.0000      0.836 0.000 1.000 0.000 0.000 0.000 NA
#> GSM559425     2  0.3330      0.774 0.000 0.716 0.000 0.000 0.000 NA
#> GSM559426     2  0.1003      0.833 0.020 0.964 0.000 0.000 0.000 NA
#> GSM559427     2  0.3330      0.774 0.000 0.716 0.000 0.000 0.000 NA
#> GSM559428     2  0.3277      0.782 0.008 0.836 0.000 0.020 0.016 NA
#> GSM559429     2  0.2745      0.799 0.000 0.860 0.000 0.020 0.008 NA
#> GSM559430     2  0.3266      0.780 0.000 0.728 0.000 0.000 0.000 NA

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

consensus_heatmap(res, k = 2)

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 disease.state(p) k
#> CV:mclust 52         1.99e-10 2
#> CV:mclust 49         3.24e-10 3
#> CV:mclust 38         5.20e-08 4
#> CV:mclust 45         1.55e-08 5
#> CV:mclust 38         3.39e-07 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 21167 rows and 52 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 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 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.418           0.820       0.861         0.4504 0.527   0.527
#> 3 3 1.000           0.973       0.988         0.3671 0.702   0.509
#> 4 4 0.707           0.703       0.854         0.1689 0.867   0.665
#> 5 5 0.702           0.637       0.817         0.0822 0.845   0.524
#> 6 6 0.740           0.657       0.799         0.0565 0.870   0.514

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
#> GSM559383     1  0.7815      0.756 0.768 0.232
#> GSM559387     1  0.7815      0.756 0.768 0.232
#> GSM559391     1  0.7815      0.756 0.768 0.232
#> GSM559395     1  0.7815      0.756 0.768 0.232
#> GSM559397     1  0.7815      0.756 0.768 0.232
#> GSM559401     1  0.7815      0.756 0.768 0.232
#> GSM559414     1  0.7815      0.756 0.768 0.232
#> GSM559422     1  0.7815      0.756 0.768 0.232
#> GSM559424     1  0.7815      0.756 0.768 0.232
#> GSM559431     2  0.3114      0.757 0.056 0.944
#> GSM559432     2  0.7376      0.449 0.208 0.792
#> GSM559381     1  0.7139      0.617 0.804 0.196
#> GSM559382     2  0.7815      0.928 0.232 0.768
#> GSM559384     1  0.0000      0.865 1.000 0.000
#> GSM559385     1  0.0000      0.865 1.000 0.000
#> GSM559386     2  0.7815      0.928 0.232 0.768
#> GSM559388     2  0.7815      0.928 0.232 0.768
#> GSM559389     1  0.6148      0.695 0.848 0.152
#> GSM559390     1  0.0672      0.860 0.992 0.008
#> GSM559392     2  0.7815      0.928 0.232 0.768
#> GSM559393     2  0.8016      0.916 0.244 0.756
#> GSM559394     1  0.5946      0.707 0.856 0.144
#> GSM559396     1  0.1633      0.858 0.976 0.024
#> GSM559398     2  0.7815      0.928 0.232 0.768
#> GSM559399     1  0.6247      0.688 0.844 0.156
#> GSM559400     2  0.7815      0.928 0.232 0.768
#> GSM559402     1  0.0000      0.865 1.000 0.000
#> GSM559403     1  0.0672      0.860 0.992 0.008
#> GSM559404     1  0.3274      0.844 0.940 0.060
#> GSM559405     1  0.0000      0.865 1.000 0.000
#> GSM559406     1  0.0000      0.865 1.000 0.000
#> GSM559407     1  0.0000      0.865 1.000 0.000
#> GSM559408     1  0.0000      0.865 1.000 0.000
#> GSM559409     1  0.0000      0.865 1.000 0.000
#> GSM559410     1  0.0376      0.863 0.996 0.004
#> GSM559411     1  0.0000      0.865 1.000 0.000
#> GSM559412     1  0.0000      0.865 1.000 0.000
#> GSM559413     1  0.1414      0.859 0.980 0.020
#> GSM559415     1  0.8713      0.373 0.708 0.292
#> GSM559416     1  0.0672      0.861 0.992 0.008
#> GSM559417     2  0.9963      0.524 0.464 0.536
#> GSM559418     2  0.7815      0.928 0.232 0.768
#> GSM559419     1  0.0672      0.860 0.992 0.008
#> GSM559420     1  0.0000      0.865 1.000 0.000
#> GSM559421     2  0.7815      0.928 0.232 0.768
#> GSM559423     2  0.7815      0.928 0.232 0.768
#> GSM559425     2  0.7815      0.928 0.232 0.768
#> GSM559426     2  0.7815      0.928 0.232 0.768
#> GSM559427     2  0.7815      0.928 0.232 0.768
#> GSM559428     2  0.2778      0.749 0.048 0.952
#> GSM559429     2  0.7815      0.928 0.232 0.768
#> GSM559430     2  0.7815      0.928 0.232 0.768

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM559383     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559387     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559391     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559395     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559397     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559401     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559414     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559422     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559424     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559431     2  0.0000      0.986 0.000 1.000 0.000
#> GSM559432     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559381     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559382     2  0.0000      0.986 0.000 1.000 0.000
#> GSM559384     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559385     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559386     1  0.5178      0.664 0.744 0.256 0.000
#> GSM559388     2  0.0000      0.986 0.000 1.000 0.000
#> GSM559389     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559390     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559392     2  0.0000      0.986 0.000 1.000 0.000
#> GSM559393     1  0.1031      0.961 0.976 0.024 0.000
#> GSM559394     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559396     1  0.0592      0.972 0.988 0.000 0.012
#> GSM559398     2  0.0000      0.986 0.000 1.000 0.000
#> GSM559399     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559400     2  0.3340      0.834 0.120 0.880 0.000
#> GSM559402     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559403     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559404     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559405     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559406     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559407     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559408     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559409     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559410     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559411     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559412     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559413     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559415     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559416     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559417     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559418     1  0.4235      0.790 0.824 0.176 0.000
#> GSM559419     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559420     1  0.0000      0.982 1.000 0.000 0.000
#> GSM559421     2  0.0000      0.986 0.000 1.000 0.000
#> GSM559423     2  0.0000      0.986 0.000 1.000 0.000
#> GSM559425     2  0.0000      0.986 0.000 1.000 0.000
#> GSM559426     2  0.0000      0.986 0.000 1.000 0.000
#> GSM559427     2  0.0000      0.986 0.000 1.000 0.000
#> GSM559428     2  0.1163      0.962 0.000 0.972 0.028
#> GSM559429     2  0.0000      0.986 0.000 1.000 0.000
#> GSM559430     2  0.0000      0.986 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
#> GSM559383     3  0.4898     0.5533 0.000 0.000 0.584 0.416
#> GSM559387     3  0.3610     0.8426 0.000 0.000 0.800 0.200
#> GSM559391     4  0.4916    -0.2863 0.000 0.000 0.424 0.576
#> GSM559395     3  0.3528     0.8466 0.000 0.000 0.808 0.192
#> GSM559397     3  0.3266     0.8532 0.000 0.000 0.832 0.168
#> GSM559401     3  0.0000     0.8207 0.000 0.000 1.000 0.000
#> GSM559414     3  0.3074     0.8540 0.000 0.000 0.848 0.152
#> GSM559422     3  0.1792     0.7935 0.000 0.000 0.932 0.068
#> GSM559424     4  0.4605    -0.0161 0.000 0.000 0.336 0.664
#> GSM559431     2  0.2216     0.9130 0.000 0.908 0.000 0.092
#> GSM559432     3  0.1792     0.7935 0.000 0.000 0.932 0.068
#> GSM559381     1  0.0817     0.8122 0.976 0.000 0.000 0.024
#> GSM559382     2  0.1211     0.9229 0.000 0.960 0.000 0.040
#> GSM559384     1  0.1792     0.7837 0.932 0.000 0.000 0.068
#> GSM559385     1  0.0188     0.8168 0.996 0.000 0.000 0.004
#> GSM559386     1  0.5856     0.0931 0.504 0.464 0.000 0.032
#> GSM559388     2  0.0188     0.9411 0.000 0.996 0.000 0.004
#> GSM559389     1  0.0000     0.8183 1.000 0.000 0.000 0.000
#> GSM559390     4  0.3764     0.6726 0.172 0.000 0.012 0.816
#> GSM559392     2  0.0188     0.9411 0.000 0.996 0.000 0.004
#> GSM559393     1  0.1677     0.7830 0.948 0.040 0.000 0.012
#> GSM559394     1  0.0336     0.8149 0.992 0.000 0.000 0.008
#> GSM559396     4  0.4004     0.5641 0.164 0.000 0.024 0.812
#> GSM559398     2  0.0188     0.9411 0.000 0.996 0.000 0.004
#> GSM559399     1  0.0188     0.8177 0.996 0.000 0.000 0.004
#> GSM559400     2  0.5393     0.6034 0.000 0.688 0.044 0.268
#> GSM559402     1  0.1557     0.7961 0.944 0.000 0.000 0.056
#> GSM559403     1  0.0000     0.8183 1.000 0.000 0.000 0.000
#> GSM559404     1  0.0000     0.8183 1.000 0.000 0.000 0.000
#> GSM559405     1  0.0000     0.8183 1.000 0.000 0.000 0.000
#> GSM559406     4  0.4564     0.5831 0.328 0.000 0.000 0.672
#> GSM559407     1  0.2149     0.7738 0.912 0.000 0.000 0.088
#> GSM559408     1  0.4730     0.3549 0.636 0.000 0.000 0.364
#> GSM559409     1  0.3486     0.6669 0.812 0.000 0.000 0.188
#> GSM559410     1  0.0000     0.8183 1.000 0.000 0.000 0.000
#> GSM559411     4  0.4103     0.6607 0.256 0.000 0.000 0.744
#> GSM559412     1  0.4804     0.2988 0.616 0.000 0.000 0.384
#> GSM559413     1  0.4916     0.1617 0.576 0.000 0.000 0.424
#> GSM559415     1  0.0000     0.8183 1.000 0.000 0.000 0.000
#> GSM559416     4  0.4331     0.6372 0.288 0.000 0.000 0.712
#> GSM559417     4  0.6966     0.5239 0.268 0.160 0.000 0.572
#> GSM559418     1  0.1940     0.7662 0.924 0.076 0.000 0.000
#> GSM559419     4  0.4522     0.5953 0.320 0.000 0.000 0.680
#> GSM559420     1  0.4941    -0.0347 0.564 0.000 0.000 0.436
#> GSM559421     2  0.0000     0.9415 0.000 1.000 0.000 0.000
#> GSM559423     2  0.1389     0.9324 0.000 0.952 0.000 0.048
#> GSM559425     2  0.0592     0.9398 0.000 0.984 0.000 0.016
#> GSM559426     2  0.1389     0.9324 0.000 0.952 0.000 0.048
#> GSM559427     2  0.0000     0.9415 0.000 1.000 0.000 0.000
#> GSM559428     2  0.4662     0.8272 0.000 0.796 0.092 0.112
#> GSM559429     2  0.2149     0.9169 0.000 0.912 0.000 0.088
#> GSM559430     2  0.0000     0.9415 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
#> GSM559383     3  0.2653      0.665 0.000 0.000 0.880 0.096 0.024
#> GSM559387     3  0.0404      0.679 0.000 0.000 0.988 0.012 0.000
#> GSM559391     3  0.4615      0.577 0.000 0.000 0.700 0.252 0.048
#> GSM559395     3  0.0671      0.673 0.000 0.000 0.980 0.004 0.016
#> GSM559397     3  0.0798      0.675 0.000 0.000 0.976 0.008 0.016
#> GSM559401     3  0.4950     -0.011 0.000 0.000 0.612 0.040 0.348
#> GSM559414     3  0.0794      0.662 0.000 0.000 0.972 0.000 0.028
#> GSM559422     5  0.5058      0.316 0.000 0.000 0.384 0.040 0.576
#> GSM559424     3  0.4866      0.548 0.000 0.000 0.664 0.284 0.052
#> GSM559431     2  0.3983      0.545 0.000 0.660 0.000 0.000 0.340
#> GSM559432     5  0.5058      0.317 0.000 0.000 0.384 0.040 0.576
#> GSM559381     1  0.1915      0.855 0.928 0.000 0.000 0.040 0.032
#> GSM559382     2  0.2477      0.708 0.008 0.892 0.000 0.092 0.008
#> GSM559384     1  0.3804      0.767 0.812 0.000 0.004 0.052 0.132
#> GSM559385     1  0.0324      0.867 0.992 0.000 0.000 0.004 0.004
#> GSM559386     2  0.5688      0.289 0.372 0.548 0.000 0.076 0.004
#> GSM559388     2  0.1731      0.747 0.008 0.940 0.000 0.040 0.012
#> GSM559389     1  0.0579      0.865 0.984 0.000 0.000 0.008 0.008
#> GSM559390     4  0.1834      0.771 0.032 0.008 0.016 0.940 0.004
#> GSM559392     2  0.0451      0.773 0.000 0.988 0.000 0.004 0.008
#> GSM559393     1  0.1173      0.856 0.964 0.012 0.000 0.004 0.020
#> GSM559394     1  0.0671      0.865 0.980 0.000 0.000 0.004 0.016
#> GSM559396     3  0.7380      0.194 0.100 0.000 0.408 0.096 0.396
#> GSM559398     2  0.0324      0.772 0.000 0.992 0.000 0.004 0.004
#> GSM559399     1  0.0566      0.869 0.984 0.000 0.000 0.012 0.004
#> GSM559400     4  0.5161      0.343 0.000 0.396 0.012 0.568 0.024
#> GSM559402     1  0.3863      0.729 0.796 0.000 0.000 0.152 0.052
#> GSM559403     1  0.0324      0.867 0.992 0.000 0.000 0.004 0.004
#> GSM559404     1  0.0880      0.865 0.968 0.000 0.000 0.032 0.000
#> GSM559405     1  0.0404      0.869 0.988 0.000 0.000 0.012 0.000
#> GSM559406     4  0.1928      0.796 0.072 0.004 0.000 0.920 0.004
#> GSM559407     1  0.5114      0.337 0.608 0.000 0.000 0.340 0.052
#> GSM559408     4  0.3662      0.702 0.252 0.000 0.000 0.744 0.004
#> GSM559409     4  0.4359      0.391 0.412 0.000 0.000 0.584 0.004
#> GSM559410     1  0.0963      0.863 0.964 0.000 0.000 0.036 0.000
#> GSM559411     4  0.3823      0.736 0.064 0.000 0.028 0.836 0.072
#> GSM559412     4  0.3696      0.746 0.212 0.000 0.000 0.772 0.016
#> GSM559413     4  0.4302      0.734 0.208 0.000 0.000 0.744 0.048
#> GSM559415     1  0.0671      0.869 0.980 0.000 0.000 0.016 0.004
#> GSM559416     4  0.1444      0.785 0.040 0.012 0.000 0.948 0.000
#> GSM559417     4  0.3209      0.763 0.032 0.088 0.000 0.864 0.016
#> GSM559418     1  0.4190      0.595 0.724 0.256 0.000 0.012 0.008
#> GSM559419     4  0.2052      0.798 0.080 0.004 0.000 0.912 0.004
#> GSM559420     1  0.6656      0.176 0.492 0.000 0.028 0.360 0.120
#> GSM559421     2  0.0566      0.776 0.000 0.984 0.000 0.004 0.012
#> GSM559423     2  0.4162      0.602 0.004 0.680 0.000 0.004 0.312
#> GSM559425     2  0.1851      0.758 0.000 0.912 0.000 0.000 0.088
#> GSM559426     2  0.4181      0.595 0.004 0.676 0.000 0.004 0.316
#> GSM559427     2  0.0510      0.775 0.000 0.984 0.000 0.000 0.016
#> GSM559428     5  0.4604     -0.424 0.000 0.428 0.012 0.000 0.560
#> GSM559429     2  0.4524      0.453 0.004 0.572 0.000 0.004 0.420
#> GSM559430     2  0.0880      0.775 0.000 0.968 0.000 0.000 0.032

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM559383     3  0.0000     0.9230 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559387     3  0.1387     0.9367 0.000 0.000 0.932 0.000 0.068 0.000
#> GSM559391     3  0.0363     0.9162 0.000 0.000 0.988 0.000 0.012 0.000
#> GSM559395     3  0.1444     0.9359 0.000 0.000 0.928 0.000 0.072 0.000
#> GSM559397     3  0.1556     0.9316 0.000 0.000 0.920 0.000 0.080 0.000
#> GSM559401     5  0.3695     0.3809 0.000 0.000 0.376 0.000 0.624 0.000
#> GSM559414     3  0.1714     0.9215 0.000 0.000 0.908 0.000 0.092 0.000
#> GSM559422     5  0.1007     0.7780 0.000 0.000 0.044 0.000 0.956 0.000
#> GSM559424     3  0.0508     0.9124 0.000 0.000 0.984 0.004 0.012 0.000
#> GSM559431     6  0.5659    -0.3020 0.000 0.420 0.000 0.000 0.152 0.428
#> GSM559432     5  0.1007     0.7780 0.000 0.000 0.044 0.000 0.956 0.000
#> GSM559381     1  0.5660     0.5278 0.576 0.008 0.000 0.292 0.012 0.112
#> GSM559382     2  0.2500     0.5032 0.036 0.896 0.000 0.036 0.000 0.032
#> GSM559384     1  0.6234     0.4530 0.520 0.004 0.012 0.320 0.020 0.124
#> GSM559385     1  0.0748     0.7759 0.976 0.016 0.000 0.004 0.004 0.000
#> GSM559386     1  0.5898     0.3156 0.536 0.328 0.000 0.092 0.000 0.044
#> GSM559388     2  0.4203     0.7071 0.056 0.720 0.000 0.004 0.000 0.220
#> GSM559389     1  0.1546     0.7828 0.944 0.004 0.000 0.020 0.004 0.028
#> GSM559390     4  0.4204     0.7212 0.004 0.272 0.036 0.688 0.000 0.000
#> GSM559392     2  0.3547     0.7592 0.004 0.696 0.000 0.000 0.000 0.300
#> GSM559393     1  0.1471     0.7623 0.932 0.064 0.000 0.004 0.000 0.000
#> GSM559394     1  0.1074     0.7761 0.960 0.028 0.000 0.012 0.000 0.000
#> GSM559396     6  0.6183     0.2397 0.008 0.000 0.208 0.220 0.020 0.544
#> GSM559398     2  0.3371     0.7586 0.000 0.708 0.000 0.000 0.000 0.292
#> GSM559399     1  0.2002     0.7831 0.908 0.012 0.000 0.076 0.004 0.000
#> GSM559400     2  0.2848     0.3237 0.000 0.816 0.000 0.176 0.008 0.000
#> GSM559402     4  0.5150     0.2951 0.280 0.004 0.008 0.640 0.016 0.052
#> GSM559403     1  0.0508     0.7778 0.984 0.012 0.000 0.004 0.000 0.000
#> GSM559404     1  0.2615     0.7701 0.872 0.004 0.000 0.104 0.012 0.008
#> GSM559405     1  0.2113     0.7808 0.896 0.004 0.000 0.092 0.000 0.008
#> GSM559406     4  0.4115     0.7228 0.004 0.268 0.032 0.696 0.000 0.000
#> GSM559407     4  0.3722     0.5827 0.160 0.004 0.008 0.796 0.012 0.020
#> GSM559408     4  0.3215     0.7410 0.004 0.240 0.000 0.756 0.000 0.000
#> GSM559409     4  0.4853     0.6819 0.172 0.124 0.000 0.692 0.012 0.000
#> GSM559410     1  0.2320     0.7665 0.864 0.004 0.000 0.132 0.000 0.000
#> GSM559411     4  0.3023     0.6834 0.012 0.000 0.072 0.868 0.032 0.016
#> GSM559412     4  0.1682     0.7337 0.020 0.052 0.000 0.928 0.000 0.000
#> GSM559413     4  0.1967     0.7034 0.028 0.004 0.004 0.928 0.028 0.008
#> GSM559415     1  0.3564     0.7031 0.768 0.004 0.000 0.204 0.000 0.024
#> GSM559416     4  0.4032     0.7280 0.004 0.268 0.020 0.704 0.004 0.000
#> GSM559417     4  0.3788     0.7287 0.004 0.272 0.008 0.712 0.004 0.000
#> GSM559418     1  0.6737    -0.0452 0.424 0.348 0.000 0.068 0.000 0.160
#> GSM559419     4  0.3483     0.7470 0.004 0.176 0.024 0.792 0.004 0.000
#> GSM559420     4  0.6037     0.4411 0.096 0.008 0.044 0.640 0.020 0.192
#> GSM559421     2  0.3659     0.7517 0.000 0.636 0.000 0.000 0.000 0.364
#> GSM559423     6  0.1082     0.6229 0.000 0.040 0.000 0.004 0.000 0.956
#> GSM559425     2  0.3747     0.7239 0.000 0.604 0.000 0.000 0.000 0.396
#> GSM559426     6  0.1075     0.6129 0.000 0.048 0.000 0.000 0.000 0.952
#> GSM559427     2  0.3634     0.7551 0.000 0.644 0.000 0.000 0.000 0.356
#> GSM559428     6  0.3518     0.4793 0.000 0.012 0.000 0.000 0.256 0.732
#> GSM559429     6  0.1168     0.6402 0.000 0.016 0.000 0.000 0.028 0.956
#> GSM559430     2  0.3727     0.7356 0.000 0.612 0.000 0.000 0.000 0.388

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 disease.state(p) k
#> CV:NMF 50         1.22e-01 2
#> CV:NMF 52         8.27e-11 3
#> CV:NMF 45         1.58e-08 4
#> CV:NMF 41         1.10e-07 5
#> CV:NMF 42         5.89e-08 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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

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

collect_plots(res)

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.685           0.833       0.931         0.3644 0.638   0.638
#> 3 3 0.385           0.617       0.801         0.5297 0.743   0.603
#> 4 4 0.408           0.609       0.741         0.1979 0.928   0.830
#> 5 5 0.577           0.615       0.756         0.1158 0.836   0.597
#> 6 6 0.642           0.567       0.755         0.0481 0.876   0.564

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
#> GSM559383     1  0.0000     0.9370 1.000 0.000
#> GSM559387     1  0.0000     0.9370 1.000 0.000
#> GSM559391     1  0.0000     0.9370 1.000 0.000
#> GSM559395     1  0.0000     0.9370 1.000 0.000
#> GSM559397     1  0.0000     0.9370 1.000 0.000
#> GSM559401     1  0.0000     0.9370 1.000 0.000
#> GSM559414     1  0.0000     0.9370 1.000 0.000
#> GSM559422     1  0.4298     0.8723 0.912 0.088
#> GSM559424     1  0.0000     0.9370 1.000 0.000
#> GSM559431     2  0.0000     0.8495 0.000 1.000
#> GSM559432     1  0.4562     0.8644 0.904 0.096
#> GSM559381     1  0.6712     0.7686 0.824 0.176
#> GSM559382     1  0.9393     0.4054 0.644 0.356
#> GSM559384     1  0.0000     0.9370 1.000 0.000
#> GSM559385     1  0.0672     0.9357 0.992 0.008
#> GSM559386     1  0.8813     0.5456 0.700 0.300
#> GSM559388     2  0.9954     0.2011 0.460 0.540
#> GSM559389     1  0.3274     0.8995 0.940 0.060
#> GSM559390     1  0.5294     0.8346 0.880 0.120
#> GSM559392     2  0.0000     0.8495 0.000 1.000
#> GSM559393     1  0.0672     0.9357 0.992 0.008
#> GSM559394     1  0.0672     0.9357 0.992 0.008
#> GSM559396     1  0.0000     0.9370 1.000 0.000
#> GSM559398     2  0.0000     0.8495 0.000 1.000
#> GSM559399     1  0.0376     0.9367 0.996 0.004
#> GSM559400     1  0.9996    -0.0374 0.512 0.488
#> GSM559402     1  0.0376     0.9367 0.996 0.004
#> GSM559403     1  0.0672     0.9357 0.992 0.008
#> GSM559404     1  0.0000     0.9370 1.000 0.000
#> GSM559405     1  0.0672     0.9358 0.992 0.008
#> GSM559406     1  0.0376     0.9362 0.996 0.004
#> GSM559407     1  0.0376     0.9367 0.996 0.004
#> GSM559408     1  0.0000     0.9370 1.000 0.000
#> GSM559409     1  0.0000     0.9370 1.000 0.000
#> GSM559410     1  0.0672     0.9357 0.992 0.008
#> GSM559411     1  0.0000     0.9370 1.000 0.000
#> GSM559412     1  0.0000     0.9370 1.000 0.000
#> GSM559413     1  0.0000     0.9370 1.000 0.000
#> GSM559415     1  0.2043     0.9219 0.968 0.032
#> GSM559416     1  0.6048     0.8083 0.852 0.148
#> GSM559417     1  0.6148     0.8032 0.848 0.152
#> GSM559418     1  0.2423     0.9162 0.960 0.040
#> GSM559419     1  0.0376     0.9367 0.996 0.004
#> GSM559420     1  0.0376     0.9367 0.996 0.004
#> GSM559421     2  0.0000     0.8495 0.000 1.000
#> GSM559423     2  0.4431     0.8109 0.092 0.908
#> GSM559425     2  0.0000     0.8495 0.000 1.000
#> GSM559426     2  0.7528     0.7130 0.216 0.784
#> GSM559427     2  0.0000     0.8495 0.000 1.000
#> GSM559428     2  0.9996     0.1038 0.488 0.512
#> GSM559429     2  0.7674     0.7036 0.224 0.776
#> GSM559430     2  0.0000     0.8495 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
#> GSM559383     3  0.6192      0.740 0.420 0.000 0.580
#> GSM559387     3  0.6192      0.740 0.420 0.000 0.580
#> GSM559391     3  0.6192      0.740 0.420 0.000 0.580
#> GSM559395     3  0.6192      0.740 0.420 0.000 0.580
#> GSM559397     3  0.6192      0.740 0.420 0.000 0.580
#> GSM559401     3  0.6008      0.491 0.372 0.000 0.628
#> GSM559414     3  0.6192      0.740 0.420 0.000 0.580
#> GSM559422     3  0.5845      0.464 0.308 0.004 0.688
#> GSM559424     3  0.6192      0.740 0.420 0.000 0.580
#> GSM559431     2  0.0000      0.793 0.000 1.000 0.000
#> GSM559432     3  0.6172      0.461 0.308 0.012 0.680
#> GSM559381     1  0.6044      0.510 0.772 0.172 0.056
#> GSM559382     1  0.7150      0.260 0.616 0.348 0.036
#> GSM559384     1  0.2625      0.688 0.916 0.000 0.084
#> GSM559385     1  0.0424      0.725 0.992 0.000 0.008
#> GSM559386     1  0.7616      0.299 0.636 0.292 0.072
#> GSM559388     2  0.7446      0.271 0.432 0.532 0.036
#> GSM559389     1  0.4095      0.646 0.880 0.056 0.064
#> GSM559390     1  0.5695      0.572 0.804 0.120 0.076
#> GSM559392     2  0.0000      0.793 0.000 1.000 0.000
#> GSM559393     1  0.0424      0.725 0.992 0.000 0.008
#> GSM559394     1  0.0424      0.725 0.992 0.000 0.008
#> GSM559396     1  0.2625      0.688 0.916 0.000 0.084
#> GSM559398     2  0.0000      0.793 0.000 1.000 0.000
#> GSM559399     1  0.0592      0.725 0.988 0.000 0.012
#> GSM559400     2  0.9059      0.127 0.380 0.480 0.140
#> GSM559402     1  0.2165      0.714 0.936 0.000 0.064
#> GSM559403     1  0.0747      0.725 0.984 0.000 0.016
#> GSM559404     1  0.5678      0.411 0.684 0.000 0.316
#> GSM559405     1  0.2301      0.717 0.936 0.004 0.060
#> GSM559406     1  0.5785      0.469 0.696 0.004 0.300
#> GSM559407     1  0.2165      0.714 0.936 0.000 0.064
#> GSM559408     1  0.5016      0.533 0.760 0.000 0.240
#> GSM559409     1  0.5016      0.533 0.760 0.000 0.240
#> GSM559410     1  0.2261      0.717 0.932 0.000 0.068
#> GSM559411     1  0.4931      0.561 0.768 0.000 0.232
#> GSM559412     1  0.5678      0.411 0.684 0.000 0.316
#> GSM559413     1  0.5678      0.411 0.684 0.000 0.316
#> GSM559415     1  0.2056      0.707 0.952 0.024 0.024
#> GSM559416     1  0.7104      0.419 0.724 0.140 0.136
#> GSM559417     1  0.7163      0.412 0.720 0.144 0.136
#> GSM559418     1  0.2313      0.702 0.944 0.032 0.024
#> GSM559419     1  0.0000      0.726 1.000 0.000 0.000
#> GSM559420     1  0.0000      0.726 1.000 0.000 0.000
#> GSM559421     2  0.0000      0.793 0.000 1.000 0.000
#> GSM559423     2  0.2945      0.763 0.088 0.908 0.004
#> GSM559425     2  0.0000      0.793 0.000 1.000 0.000
#> GSM559426     2  0.4931      0.685 0.212 0.784 0.004
#> GSM559427     2  0.0000      0.793 0.000 1.000 0.000
#> GSM559428     2  0.7974      0.246 0.436 0.504 0.060
#> GSM559429     2  0.5024      0.677 0.220 0.776 0.004
#> GSM559430     2  0.0000      0.793 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
#> GSM559383     3  0.3400      0.880 0.180 0.000 0.820 0.000
#> GSM559387     3  0.3400      0.880 0.180 0.000 0.820 0.000
#> GSM559391     3  0.3400      0.880 0.180 0.000 0.820 0.000
#> GSM559395     3  0.3400      0.880 0.180 0.000 0.820 0.000
#> GSM559397     3  0.3539      0.876 0.176 0.000 0.820 0.004
#> GSM559401     4  0.4985      0.833 0.000 0.000 0.468 0.532
#> GSM559414     3  0.3539      0.876 0.176 0.000 0.820 0.004
#> GSM559422     4  0.4697      0.921 0.000 0.000 0.356 0.644
#> GSM559424     3  0.3400      0.880 0.180 0.000 0.820 0.000
#> GSM559431     2  0.0000      0.778 0.000 1.000 0.000 0.000
#> GSM559432     4  0.5007      0.920 0.000 0.008 0.356 0.636
#> GSM559381     1  0.5652      0.577 0.736 0.080 0.012 0.172
#> GSM559382     1  0.6805      0.281 0.592 0.260 0.000 0.148
#> GSM559384     1  0.5175      0.608 0.760 0.000 0.120 0.120
#> GSM559385     1  0.0188      0.689 0.996 0.000 0.000 0.004
#> GSM559386     1  0.6756      0.360 0.612 0.188 0.000 0.200
#> GSM559388     2  0.7182      0.189 0.412 0.452 0.000 0.136
#> GSM559389     1  0.3896      0.651 0.844 0.012 0.024 0.120
#> GSM559390     1  0.5834      0.616 0.744 0.076 0.032 0.148
#> GSM559392     2  0.0000      0.778 0.000 1.000 0.000 0.000
#> GSM559393     1  0.0188      0.689 0.996 0.000 0.000 0.004
#> GSM559394     1  0.0188      0.689 0.996 0.000 0.000 0.004
#> GSM559396     1  0.5175      0.608 0.760 0.000 0.120 0.120
#> GSM559398     2  0.0000      0.778 0.000 1.000 0.000 0.000
#> GSM559399     1  0.1151      0.687 0.968 0.000 0.024 0.008
#> GSM559400     2  0.8780      0.110 0.368 0.396 0.068 0.168
#> GSM559402     1  0.4956      0.624 0.776 0.000 0.108 0.116
#> GSM559403     1  0.0779      0.688 0.980 0.000 0.016 0.004
#> GSM559404     3  0.6833      0.261 0.272 0.000 0.584 0.144
#> GSM559405     1  0.2593      0.678 0.892 0.000 0.104 0.004
#> GSM559406     1  0.6665      0.343 0.544 0.000 0.360 0.096
#> GSM559407     1  0.4956      0.624 0.776 0.000 0.108 0.116
#> GSM559408     1  0.6887      0.305 0.528 0.000 0.356 0.116
#> GSM559409     1  0.6887      0.305 0.528 0.000 0.356 0.116
#> GSM559410     1  0.2675      0.679 0.892 0.000 0.100 0.008
#> GSM559411     1  0.6774      0.389 0.568 0.000 0.312 0.120
#> GSM559412     1  0.7047      0.105 0.440 0.000 0.440 0.120
#> GSM559413     1  0.7047      0.105 0.440 0.000 0.440 0.120
#> GSM559415     1  0.1902      0.679 0.932 0.000 0.004 0.064
#> GSM559416     1  0.6488      0.535 0.688 0.044 0.068 0.200
#> GSM559417     1  0.6523      0.532 0.684 0.044 0.068 0.204
#> GSM559418     1  0.1940      0.675 0.924 0.000 0.000 0.076
#> GSM559419     1  0.3278      0.662 0.864 0.000 0.020 0.116
#> GSM559420     1  0.3278      0.662 0.864 0.000 0.020 0.116
#> GSM559421     2  0.0336      0.776 0.000 0.992 0.000 0.008
#> GSM559423     2  0.3601      0.731 0.084 0.860 0.000 0.056
#> GSM559425     2  0.0000      0.778 0.000 1.000 0.000 0.000
#> GSM559426     2  0.5530      0.642 0.212 0.712 0.000 0.076
#> GSM559427     2  0.0000      0.778 0.000 1.000 0.000 0.000
#> GSM559428     1  0.7546     -0.197 0.412 0.400 0.000 0.188
#> GSM559429     2  0.5598      0.635 0.220 0.704 0.000 0.076
#> GSM559430     2  0.0000      0.778 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
#> GSM559383     3  0.0404     0.9979 0.012 0.000 0.988 0.000 0.000
#> GSM559387     3  0.0404     0.9979 0.012 0.000 0.988 0.000 0.000
#> GSM559391     3  0.0404     0.9979 0.012 0.000 0.988 0.000 0.000
#> GSM559395     3  0.0404     0.9979 0.012 0.000 0.988 0.000 0.000
#> GSM559397     3  0.0566     0.9947 0.012 0.000 0.984 0.000 0.004
#> GSM559401     5  0.4161     0.6549 0.000 0.000 0.392 0.000 0.608
#> GSM559414     3  0.0566     0.9947 0.012 0.000 0.984 0.000 0.004
#> GSM559422     5  0.2813     0.8604 0.000 0.000 0.168 0.000 0.832
#> GSM559424     3  0.0404     0.9979 0.012 0.000 0.988 0.000 0.000
#> GSM559431     2  0.0000     0.8637 0.000 1.000 0.000 0.000 0.000
#> GSM559432     5  0.3093     0.8598 0.000 0.008 0.168 0.000 0.824
#> GSM559381     4  0.4060     0.4837 0.360 0.000 0.000 0.640 0.000
#> GSM559382     4  0.5565     0.5904 0.216 0.144 0.000 0.640 0.000
#> GSM559384     1  0.4982     0.5059 0.708 0.000 0.228 0.032 0.032
#> GSM559385     1  0.4417     0.5672 0.760 0.000 0.000 0.092 0.148
#> GSM559386     4  0.4736     0.6144 0.216 0.072 0.000 0.712 0.000
#> GSM559388     4  0.5908     0.2619 0.108 0.380 0.000 0.512 0.000
#> GSM559389     1  0.4546     0.3031 0.668 0.000 0.028 0.304 0.000
#> GSM559390     4  0.5061     0.3298 0.432 0.000 0.012 0.540 0.016
#> GSM559392     2  0.0000     0.8637 0.000 1.000 0.000 0.000 0.000
#> GSM559393     1  0.4417     0.5672 0.760 0.000 0.000 0.092 0.148
#> GSM559394     1  0.4417     0.5672 0.760 0.000 0.000 0.092 0.148
#> GSM559396     1  0.4982     0.5059 0.708 0.000 0.228 0.032 0.032
#> GSM559398     2  0.0000     0.8637 0.000 1.000 0.000 0.000 0.000
#> GSM559399     1  0.5001     0.5792 0.744 0.000 0.028 0.080 0.148
#> GSM559400     4  0.8046     0.2707 0.084 0.352 0.152 0.396 0.016
#> GSM559402     1  0.1597     0.6052 0.940 0.000 0.048 0.012 0.000
#> GSM559403     1  0.5189     0.5764 0.732 0.000 0.032 0.088 0.148
#> GSM559404     1  0.7058    -0.0308 0.376 0.000 0.360 0.252 0.012
#> GSM559405     1  0.4839     0.5993 0.760 0.000 0.044 0.052 0.144
#> GSM559406     1  0.6845     0.3644 0.496 0.000 0.232 0.256 0.016
#> GSM559407     1  0.1597     0.6052 0.940 0.000 0.048 0.012 0.000
#> GSM559408     1  0.5384     0.4849 0.664 0.000 0.228 0.104 0.004
#> GSM559409     1  0.5384     0.4849 0.664 0.000 0.228 0.104 0.004
#> GSM559410     1  0.4945     0.5976 0.752 0.000 0.044 0.056 0.148
#> GSM559411     1  0.5007     0.5223 0.720 0.000 0.176 0.096 0.008
#> GSM559412     1  0.6022     0.4279 0.592 0.000 0.268 0.132 0.008
#> GSM559413     1  0.6022     0.4279 0.592 0.000 0.268 0.132 0.008
#> GSM559415     1  0.5202     0.5069 0.700 0.000 0.004 0.148 0.148
#> GSM559416     4  0.6606     0.3103 0.384 0.000 0.164 0.444 0.008
#> GSM559417     4  0.6602     0.3178 0.380 0.000 0.164 0.448 0.008
#> GSM559418     1  0.5198     0.4868 0.688 0.000 0.000 0.164 0.148
#> GSM559419     1  0.1331     0.6030 0.952 0.000 0.008 0.040 0.000
#> GSM559420     1  0.1331     0.6030 0.952 0.000 0.008 0.040 0.000
#> GSM559421     2  0.0609     0.8542 0.000 0.980 0.000 0.020 0.000
#> GSM559423     2  0.3074     0.7121 0.000 0.804 0.000 0.196 0.000
#> GSM559425     2  0.0000     0.8637 0.000 1.000 0.000 0.000 0.000
#> GSM559426     2  0.4210     0.4423 0.000 0.588 0.000 0.412 0.000
#> GSM559427     2  0.0000     0.8637 0.000 1.000 0.000 0.000 0.000
#> GSM559428     4  0.4983     0.3662 0.064 0.272 0.000 0.664 0.000
#> GSM559429     2  0.4235     0.4204 0.000 0.576 0.000 0.424 0.000
#> GSM559430     2  0.0000     0.8637 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
#> GSM559383     3  0.0260     0.9981 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM559387     3  0.0260     0.9981 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM559391     3  0.0260     0.9981 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM559395     3  0.0260     0.9981 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM559397     3  0.0405     0.9951 0.000 0.000 0.988 0.008 0.004 0.000
#> GSM559401     5  0.3737     0.3645 0.000 0.000 0.392 0.000 0.608 0.000
#> GSM559414     3  0.0405     0.9951 0.000 0.000 0.988 0.008 0.004 0.000
#> GSM559422     5  0.0000     0.7732 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM559424     3  0.0260     0.9981 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM559431     2  0.0000     0.9543 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559432     5  0.0260     0.7719 0.000 0.008 0.000 0.000 0.992 0.000
#> GSM559381     6  0.5102     0.3858 0.212 0.000 0.000 0.160 0.000 0.628
#> GSM559382     6  0.4896     0.5527 0.212 0.120 0.000 0.004 0.000 0.664
#> GSM559384     4  0.6007     0.0586 0.324 0.000 0.216 0.456 0.000 0.004
#> GSM559385     1  0.3446     0.8113 0.692 0.000 0.000 0.308 0.000 0.000
#> GSM559386     6  0.4031     0.5478 0.212 0.048 0.000 0.004 0.000 0.736
#> GSM559388     6  0.4938     0.3286 0.076 0.356 0.000 0.000 0.000 0.568
#> GSM559389     1  0.6488     0.3305 0.440 0.000 0.028 0.236 0.000 0.296
#> GSM559390     6  0.5751     0.1718 0.208 0.000 0.000 0.288 0.000 0.504
#> GSM559392     2  0.0000     0.9543 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559393     1  0.3446     0.8113 0.692 0.000 0.000 0.308 0.000 0.000
#> GSM559394     1  0.3446     0.8113 0.692 0.000 0.000 0.308 0.000 0.000
#> GSM559396     4  0.6007     0.0586 0.324 0.000 0.216 0.456 0.000 0.004
#> GSM559398     2  0.0000     0.9543 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559399     1  0.4134     0.7910 0.656 0.000 0.028 0.316 0.000 0.000
#> GSM559400     6  0.6346     0.2193 0.028 0.348 0.124 0.004 0.008 0.488
#> GSM559402     4  0.3695     0.0099 0.376 0.000 0.000 0.624 0.000 0.000
#> GSM559403     1  0.4118     0.7921 0.660 0.000 0.028 0.312 0.000 0.000
#> GSM559404     4  0.3620     0.2104 0.248 0.000 0.008 0.736 0.000 0.008
#> GSM559405     1  0.4039     0.6359 0.568 0.000 0.000 0.424 0.000 0.008
#> GSM559406     4  0.4521     0.3770 0.072 0.000 0.024 0.732 0.000 0.172
#> GSM559407     4  0.3695     0.0099 0.376 0.000 0.000 0.624 0.000 0.000
#> GSM559408     4  0.2122     0.5171 0.076 0.000 0.024 0.900 0.000 0.000
#> GSM559409     4  0.2122     0.5171 0.076 0.000 0.024 0.900 0.000 0.000
#> GSM559410     1  0.3789     0.6501 0.584 0.000 0.000 0.416 0.000 0.000
#> GSM559411     4  0.2135     0.4754 0.128 0.000 0.000 0.872 0.000 0.000
#> GSM559412     4  0.0000     0.5104 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM559413     4  0.0000     0.5104 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM559415     1  0.3780     0.7721 0.728 0.000 0.004 0.248 0.000 0.020
#> GSM559416     6  0.6518     0.2896 0.296 0.000 0.124 0.080 0.000 0.500
#> GSM559417     6  0.6476     0.2969 0.296 0.000 0.124 0.076 0.000 0.504
#> GSM559418     1  0.3791     0.7549 0.732 0.000 0.000 0.236 0.000 0.032
#> GSM559419     4  0.3993    -0.3012 0.476 0.000 0.004 0.520 0.000 0.000
#> GSM559420     4  0.3993    -0.3012 0.476 0.000 0.004 0.520 0.000 0.000
#> GSM559421     2  0.0603     0.9383 0.004 0.980 0.000 0.000 0.000 0.016
#> GSM559423     2  0.3245     0.6323 0.008 0.764 0.000 0.000 0.000 0.228
#> GSM559425     2  0.0000     0.9543 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559426     6  0.4121     0.1108 0.016 0.380 0.000 0.000 0.000 0.604
#> GSM559427     2  0.0000     0.9543 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559428     6  0.1327     0.4678 0.000 0.064 0.000 0.000 0.000 0.936
#> GSM559429     6  0.4088     0.1366 0.016 0.368 0.000 0.000 0.000 0.616
#> GSM559430     2  0.0000     0.9543 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 disease.state(p) k
#> MAD:hclust 48         5.03e-01 2
#> MAD:hclust 38         8.40e-08 3
#> MAD:hclust 40         9.62e-08 4
#> MAD:hclust 35         3.15e-06 5
#> MAD:hclust 32         3.76e-05 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 21167 rows and 52 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.491           0.786       0.850         0.4141 0.538   0.538
#> 3 3 1.000           0.969       0.978         0.4717 0.740   0.563
#> 4 4 0.681           0.616       0.814         0.1623 0.876   0.696
#> 5 5 0.665           0.640       0.770         0.0882 0.910   0.720
#> 6 6 0.694           0.578       0.737         0.0555 0.851   0.504

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
#> GSM559383     1  0.0938      0.733 0.988 0.012
#> GSM559387     1  0.0938      0.733 0.988 0.012
#> GSM559391     1  0.0938      0.733 0.988 0.012
#> GSM559395     1  0.0938      0.733 0.988 0.012
#> GSM559397     1  0.0938      0.733 0.988 0.012
#> GSM559401     1  0.0938      0.733 0.988 0.012
#> GSM559414     1  0.0938      0.733 0.988 0.012
#> GSM559422     1  0.0938      0.733 0.988 0.012
#> GSM559424     1  0.0938      0.733 0.988 0.012
#> GSM559431     2  0.0000      0.875 0.000 1.000
#> GSM559432     2  0.8267      0.604 0.260 0.740
#> GSM559381     1  0.8267      0.876 0.740 0.260
#> GSM559382     2  0.0000      0.875 0.000 1.000
#> GSM559384     1  0.8267      0.876 0.740 0.260
#> GSM559385     1  0.8267      0.876 0.740 0.260
#> GSM559386     2  0.9850     -0.105 0.428 0.572
#> GSM559388     2  0.0000      0.875 0.000 1.000
#> GSM559389     1  0.8267      0.876 0.740 0.260
#> GSM559390     1  0.8267      0.876 0.740 0.260
#> GSM559392     2  0.0000      0.875 0.000 1.000
#> GSM559393     2  0.9896     -0.154 0.440 0.560
#> GSM559394     1  0.8267      0.876 0.740 0.260
#> GSM559396     1  0.7528      0.860 0.784 0.216
#> GSM559398     2  0.0000      0.875 0.000 1.000
#> GSM559399     1  0.8267      0.876 0.740 0.260
#> GSM559400     2  0.0000      0.875 0.000 1.000
#> GSM559402     1  0.8267      0.876 0.740 0.260
#> GSM559403     1  0.8267      0.876 0.740 0.260
#> GSM559404     1  0.7139      0.861 0.804 0.196
#> GSM559405     1  0.8267      0.876 0.740 0.260
#> GSM559406     1  0.7219      0.863 0.800 0.200
#> GSM559407     1  0.8267      0.876 0.740 0.260
#> GSM559408     1  0.8267      0.876 0.740 0.260
#> GSM559409     1  0.8207      0.876 0.744 0.256
#> GSM559410     1  0.8267      0.876 0.740 0.260
#> GSM559411     1  0.7219      0.863 0.800 0.200
#> GSM559412     1  0.7299      0.864 0.796 0.204
#> GSM559413     1  0.7139      0.861 0.804 0.196
#> GSM559415     1  0.8267      0.876 0.740 0.260
#> GSM559416     1  0.8267      0.876 0.740 0.260
#> GSM559417     1  0.8267      0.876 0.740 0.260
#> GSM559418     2  0.9881     -0.137 0.436 0.564
#> GSM559419     1  0.8267      0.876 0.740 0.260
#> GSM559420     1  0.8267      0.876 0.740 0.260
#> GSM559421     2  0.0000      0.875 0.000 1.000
#> GSM559423     2  0.0000      0.875 0.000 1.000
#> GSM559425     2  0.0000      0.875 0.000 1.000
#> GSM559426     2  0.0000      0.875 0.000 1.000
#> GSM559427     2  0.0000      0.875 0.000 1.000
#> GSM559428     2  0.0000      0.875 0.000 1.000
#> GSM559429     2  0.0000      0.875 0.000 1.000
#> GSM559430     2  0.0000      0.875 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
#> GSM559383     3  0.1643      0.993 0.044 0.000 0.956
#> GSM559387     3  0.1643      0.993 0.044 0.000 0.956
#> GSM559391     3  0.1643      0.993 0.044 0.000 0.956
#> GSM559395     3  0.1643      0.993 0.044 0.000 0.956
#> GSM559397     3  0.1643      0.993 0.044 0.000 0.956
#> GSM559401     3  0.1643      0.993 0.044 0.000 0.956
#> GSM559414     3  0.1643      0.993 0.044 0.000 0.956
#> GSM559422     3  0.0000      0.940 0.000 0.000 1.000
#> GSM559424     3  0.1643      0.993 0.044 0.000 0.956
#> GSM559431     2  0.0000      0.966 0.000 1.000 0.000
#> GSM559432     2  0.5785      0.559 0.000 0.668 0.332
#> GSM559381     1  0.0424      0.984 0.992 0.000 0.008
#> GSM559382     2  0.1643      0.948 0.000 0.956 0.044
#> GSM559384     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559385     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559386     1  0.2793      0.936 0.928 0.028 0.044
#> GSM559388     2  0.1529      0.949 0.000 0.960 0.040
#> GSM559389     1  0.0424      0.984 0.992 0.000 0.008
#> GSM559390     1  0.1529      0.962 0.960 0.000 0.040
#> GSM559392     2  0.0000      0.966 0.000 1.000 0.000
#> GSM559393     1  0.2063      0.954 0.948 0.008 0.044
#> GSM559394     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559396     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559398     2  0.0000      0.966 0.000 1.000 0.000
#> GSM559399     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559400     2  0.1643      0.948 0.000 0.956 0.044
#> GSM559402     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559403     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559404     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559405     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559406     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559407     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559408     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559409     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559410     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559411     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559412     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559413     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559415     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559416     1  0.1163      0.971 0.972 0.000 0.028
#> GSM559417     1  0.1529      0.962 0.960 0.000 0.040
#> GSM559418     1  0.1950      0.957 0.952 0.008 0.040
#> GSM559419     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559420     1  0.0000      0.989 1.000 0.000 0.000
#> GSM559421     2  0.0000      0.966 0.000 1.000 0.000
#> GSM559423     2  0.0000      0.966 0.000 1.000 0.000
#> GSM559425     2  0.0000      0.966 0.000 1.000 0.000
#> GSM559426     2  0.0000      0.966 0.000 1.000 0.000
#> GSM559427     2  0.0000      0.966 0.000 1.000 0.000
#> GSM559428     2  0.1643      0.948 0.000 0.956 0.044
#> GSM559429     2  0.0000      0.966 0.000 1.000 0.000
#> GSM559430     2  0.0000      0.966 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
#> GSM559383     3  0.0000     0.9157 0.000 0.000 1.000 0.000
#> GSM559387     3  0.0000     0.9157 0.000 0.000 1.000 0.000
#> GSM559391     3  0.0000     0.9157 0.000 0.000 1.000 0.000
#> GSM559395     3  0.0000     0.9157 0.000 0.000 1.000 0.000
#> GSM559397     3  0.0000     0.9157 0.000 0.000 1.000 0.000
#> GSM559401     3  0.1474     0.8938 0.000 0.000 0.948 0.052
#> GSM559414     3  0.0000     0.9157 0.000 0.000 1.000 0.000
#> GSM559422     3  0.4624     0.7026 0.000 0.000 0.660 0.340
#> GSM559424     3  0.0000     0.9157 0.000 0.000 1.000 0.000
#> GSM559431     2  0.0000     0.9447 0.000 1.000 0.000 0.000
#> GSM559432     3  0.7694     0.3845 0.000 0.244 0.448 0.308
#> GSM559381     1  0.2647     0.6881 0.880 0.000 0.000 0.120
#> GSM559382     4  0.5294    -0.1328 0.008 0.484 0.000 0.508
#> GSM559384     1  0.1940     0.7387 0.924 0.000 0.000 0.076
#> GSM559385     1  0.2281     0.6941 0.904 0.000 0.000 0.096
#> GSM559386     1  0.5755    -0.0431 0.528 0.028 0.000 0.444
#> GSM559388     2  0.4790     0.2828 0.000 0.620 0.000 0.380
#> GSM559389     1  0.3219     0.6554 0.836 0.000 0.000 0.164
#> GSM559390     4  0.4888    -0.0429 0.412 0.000 0.000 0.588
#> GSM559392     2  0.0188     0.9443 0.000 0.996 0.000 0.004
#> GSM559393     4  0.4941     0.0383 0.436 0.000 0.000 0.564
#> GSM559394     1  0.3024     0.6785 0.852 0.000 0.000 0.148
#> GSM559396     1  0.5510     0.4188 0.600 0.000 0.024 0.376
#> GSM559398     2  0.0000     0.9447 0.000 1.000 0.000 0.000
#> GSM559399     1  0.3975     0.5264 0.760 0.000 0.000 0.240
#> GSM559400     4  0.4746     0.0170 0.000 0.368 0.000 0.632
#> GSM559402     1  0.1557     0.7357 0.944 0.000 0.000 0.056
#> GSM559403     1  0.2011     0.7045 0.920 0.000 0.000 0.080
#> GSM559404     1  0.1940     0.7103 0.924 0.000 0.000 0.076
#> GSM559405     1  0.0336     0.7303 0.992 0.000 0.000 0.008
#> GSM559406     1  0.3649     0.6747 0.796 0.000 0.000 0.204
#> GSM559407     1  0.1637     0.7350 0.940 0.000 0.000 0.060
#> GSM559408     1  0.3569     0.6818 0.804 0.000 0.000 0.196
#> GSM559409     1  0.3569     0.6818 0.804 0.000 0.000 0.196
#> GSM559410     1  0.0707     0.7309 0.980 0.000 0.000 0.020
#> GSM559411     1  0.3569     0.6818 0.804 0.000 0.000 0.196
#> GSM559412     1  0.3569     0.6818 0.804 0.000 0.000 0.196
#> GSM559413     1  0.3569     0.6818 0.804 0.000 0.000 0.196
#> GSM559415     1  0.3837     0.5547 0.776 0.000 0.000 0.224
#> GSM559416     4  0.4994    -0.1831 0.480 0.000 0.000 0.520
#> GSM559417     4  0.4977    -0.1271 0.460 0.000 0.000 0.540
#> GSM559418     1  0.4866     0.1421 0.596 0.000 0.000 0.404
#> GSM559419     1  0.4961     0.2785 0.552 0.000 0.000 0.448
#> GSM559420     1  0.2408     0.7333 0.896 0.000 0.000 0.104
#> GSM559421     2  0.0188     0.9443 0.000 0.996 0.000 0.004
#> GSM559423     2  0.0469     0.9413 0.000 0.988 0.000 0.012
#> GSM559425     2  0.0000     0.9447 0.000 1.000 0.000 0.000
#> GSM559426     2  0.0921     0.9313 0.000 0.972 0.000 0.028
#> GSM559427     2  0.0000     0.9447 0.000 1.000 0.000 0.000
#> GSM559428     4  0.5288    -0.1008 0.008 0.472 0.000 0.520
#> GSM559429     2  0.1022     0.9281 0.000 0.968 0.000 0.032
#> GSM559430     2  0.0000     0.9447 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
#> GSM559383     3  0.0162     0.9678 0.000 0.000 0.996 0.004 0.000
#> GSM559387     3  0.0000     0.9671 0.000 0.000 1.000 0.000 0.000
#> GSM559391     3  0.0162     0.9678 0.000 0.000 0.996 0.004 0.000
#> GSM559395     3  0.0162     0.9678 0.000 0.000 0.996 0.004 0.000
#> GSM559397     3  0.0000     0.9671 0.000 0.000 1.000 0.000 0.000
#> GSM559401     3  0.2424     0.7513 0.000 0.000 0.868 0.000 0.132
#> GSM559414     3  0.0000     0.9671 0.000 0.000 1.000 0.000 0.000
#> GSM559422     5  0.4588     0.6890 0.000 0.000 0.380 0.016 0.604
#> GSM559424     3  0.0162     0.9678 0.000 0.000 0.996 0.004 0.000
#> GSM559431     2  0.0000     0.9628 0.000 1.000 0.000 0.000 0.000
#> GSM559432     5  0.6318     0.7320 0.000 0.124 0.288 0.020 0.568
#> GSM559381     1  0.4431     0.5385 0.732 0.000 0.000 0.216 0.052
#> GSM559382     4  0.5781     0.4396 0.004 0.200 0.000 0.632 0.164
#> GSM559384     1  0.1725     0.6585 0.936 0.000 0.000 0.020 0.044
#> GSM559385     1  0.4933     0.5464 0.692 0.000 0.000 0.080 0.228
#> GSM559386     4  0.5269     0.5294 0.180 0.024 0.000 0.712 0.084
#> GSM559388     4  0.5313     0.2877 0.000 0.388 0.000 0.556 0.056
#> GSM559389     1  0.5490     0.4570 0.644 0.000 0.000 0.228 0.128
#> GSM559390     4  0.3039     0.5064 0.152 0.000 0.000 0.836 0.012
#> GSM559392     2  0.1041     0.9507 0.000 0.964 0.000 0.004 0.032
#> GSM559393     4  0.6599     0.2986 0.268 0.000 0.000 0.464 0.268
#> GSM559394     1  0.5464     0.5020 0.648 0.000 0.000 0.128 0.224
#> GSM559396     1  0.6602    -0.0816 0.444 0.000 0.044 0.432 0.080
#> GSM559398     2  0.0955     0.9503 0.000 0.968 0.000 0.004 0.028
#> GSM559399     1  0.5652     0.1379 0.552 0.000 0.000 0.360 0.088
#> GSM559400     4  0.5904     0.3405 0.000 0.172 0.000 0.596 0.232
#> GSM559402     1  0.0693     0.6617 0.980 0.000 0.000 0.008 0.012
#> GSM559403     1  0.4212     0.5972 0.776 0.000 0.000 0.080 0.144
#> GSM559404     1  0.4676     0.6121 0.720 0.000 0.000 0.072 0.208
#> GSM559405     1  0.2304     0.6496 0.908 0.000 0.000 0.044 0.048
#> GSM559406     1  0.5149     0.5512 0.680 0.000 0.000 0.216 0.104
#> GSM559407     1  0.0807     0.6620 0.976 0.000 0.000 0.012 0.012
#> GSM559408     1  0.4934     0.5718 0.708 0.000 0.000 0.188 0.104
#> GSM559409     1  0.4934     0.5718 0.708 0.000 0.000 0.188 0.104
#> GSM559410     1  0.2370     0.6542 0.904 0.000 0.000 0.040 0.056
#> GSM559411     1  0.5006     0.5738 0.704 0.000 0.000 0.180 0.116
#> GSM559412     1  0.5006     0.5715 0.704 0.000 0.000 0.180 0.116
#> GSM559413     1  0.5006     0.5715 0.704 0.000 0.000 0.180 0.116
#> GSM559415     1  0.5652     0.1751 0.564 0.000 0.000 0.344 0.092
#> GSM559416     4  0.4479     0.4056 0.264 0.000 0.000 0.700 0.036
#> GSM559417     4  0.4297     0.4457 0.236 0.000 0.000 0.728 0.036
#> GSM559418     4  0.5708     0.2482 0.384 0.000 0.000 0.528 0.088
#> GSM559419     4  0.4966     0.1507 0.404 0.000 0.000 0.564 0.032
#> GSM559420     1  0.2676     0.6276 0.884 0.000 0.000 0.080 0.036
#> GSM559421     2  0.0451     0.9615 0.000 0.988 0.000 0.008 0.004
#> GSM559423     2  0.0898     0.9561 0.000 0.972 0.000 0.020 0.008
#> GSM559425     2  0.0000     0.9628 0.000 1.000 0.000 0.000 0.000
#> GSM559426     2  0.2446     0.9045 0.000 0.900 0.000 0.056 0.044
#> GSM559427     2  0.0000     0.9628 0.000 1.000 0.000 0.000 0.000
#> GSM559428     4  0.5604     0.4448 0.008 0.180 0.000 0.664 0.148
#> GSM559429     2  0.2992     0.8769 0.000 0.868 0.000 0.068 0.064
#> GSM559430     2  0.0000     0.9628 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
#> GSM559383     3  0.1074     0.9420 0.012 0.000 0.960 0.000 0.000 0.028
#> GSM559387     3  0.0000     0.9413 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559391     3  0.1168     0.9406 0.016 0.000 0.956 0.000 0.000 0.028
#> GSM559395     3  0.0820     0.9434 0.012 0.000 0.972 0.000 0.000 0.016
#> GSM559397     3  0.0000     0.9413 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559401     3  0.2597     0.7054 0.000 0.000 0.824 0.000 0.176 0.000
#> GSM559414     3  0.0000     0.9413 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559422     5  0.3500     0.8496 0.000 0.000 0.204 0.000 0.768 0.028
#> GSM559424     3  0.1168     0.9406 0.016 0.000 0.956 0.000 0.000 0.028
#> GSM559431     2  0.0000     0.9278 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559432     5  0.5310     0.8481 0.000 0.056 0.176 0.000 0.676 0.092
#> GSM559381     1  0.6487     0.3282 0.504 0.000 0.000 0.268 0.056 0.172
#> GSM559382     6  0.4387     0.6393 0.104 0.152 0.000 0.000 0.008 0.736
#> GSM559384     1  0.5406     0.2337 0.556 0.000 0.000 0.356 0.048 0.040
#> GSM559385     1  0.6484     0.3629 0.536 0.000 0.000 0.208 0.184 0.072
#> GSM559386     6  0.3578     0.4893 0.340 0.000 0.000 0.000 0.000 0.660
#> GSM559388     6  0.4859     0.5653 0.084 0.304 0.000 0.000 0.000 0.612
#> GSM559389     1  0.4633     0.4738 0.736 0.000 0.000 0.148 0.036 0.080
#> GSM559390     6  0.6323     0.3789 0.156 0.000 0.000 0.296 0.044 0.504
#> GSM559392     2  0.1296     0.9092 0.004 0.948 0.000 0.000 0.004 0.044
#> GSM559393     1  0.5625     0.1902 0.548 0.000 0.000 0.004 0.168 0.280
#> GSM559394     1  0.5904     0.4228 0.620 0.000 0.000 0.144 0.168 0.068
#> GSM559396     1  0.7484     0.1754 0.416 0.000 0.044 0.300 0.060 0.180
#> GSM559398     2  0.1155     0.9091 0.004 0.956 0.000 0.000 0.004 0.036
#> GSM559399     1  0.2579     0.4975 0.876 0.000 0.000 0.088 0.004 0.032
#> GSM559400     6  0.6004     0.4453 0.088 0.080 0.000 0.000 0.248 0.584
#> GSM559402     4  0.5496    -0.0263 0.404 0.000 0.000 0.508 0.048 0.040
#> GSM559403     1  0.5523     0.3497 0.604 0.000 0.000 0.280 0.068 0.048
#> GSM559404     4  0.5474     0.3677 0.196 0.000 0.000 0.656 0.080 0.068
#> GSM559405     1  0.5089     0.1665 0.532 0.000 0.000 0.408 0.032 0.028
#> GSM559406     4  0.2224     0.6695 0.020 0.000 0.000 0.904 0.012 0.064
#> GSM559407     4  0.5434     0.0742 0.368 0.000 0.000 0.544 0.048 0.040
#> GSM559408     4  0.0993     0.7196 0.012 0.000 0.000 0.964 0.000 0.024
#> GSM559409     4  0.0806     0.7232 0.008 0.000 0.000 0.972 0.000 0.020
#> GSM559410     1  0.4080     0.1365 0.536 0.000 0.000 0.456 0.008 0.000
#> GSM559411     4  0.1180     0.7140 0.012 0.000 0.000 0.960 0.012 0.016
#> GSM559412     4  0.0146     0.7255 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM559413     4  0.0146     0.7255 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM559415     1  0.3101     0.4991 0.852 0.000 0.000 0.092 0.024 0.032
#> GSM559416     1  0.6986    -0.1507 0.328 0.000 0.000 0.324 0.056 0.292
#> GSM559417     1  0.6950    -0.1737 0.328 0.000 0.000 0.320 0.052 0.300
#> GSM559418     1  0.2793     0.4593 0.872 0.000 0.000 0.024 0.024 0.080
#> GSM559419     1  0.6144     0.2030 0.492 0.000 0.000 0.336 0.032 0.140
#> GSM559420     1  0.5475     0.2497 0.564 0.000 0.000 0.340 0.052 0.044
#> GSM559421     2  0.0508     0.9257 0.004 0.984 0.000 0.000 0.000 0.012
#> GSM559423     2  0.1036     0.9191 0.008 0.964 0.000 0.000 0.004 0.024
#> GSM559425     2  0.0000     0.9278 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559426     2  0.3280     0.7892 0.004 0.808 0.000 0.000 0.028 0.160
#> GSM559427     2  0.0000     0.9278 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559428     6  0.4560     0.5951 0.080 0.140 0.000 0.000 0.036 0.744
#> GSM559429     2  0.4133     0.6617 0.008 0.708 0.000 0.000 0.032 0.252
#> GSM559430     2  0.0000     0.9278 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-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 disease.state(p) k
#> MAD:kmeans 49         5.19e-01 2
#> MAD:kmeans 52         9.23e-10 3
#> MAD:kmeans 39         3.60e-08 4
#> MAD:kmeans 39         5.73e-07 5
#> MAD:kmeans 29         4.63e-05 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 21167 rows and 52 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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 0.847           0.945       0.976         0.4862 0.517   0.517
#> 3 3 1.000           0.960       0.985         0.3389 0.773   0.586
#> 4 4 0.844           0.852       0.908         0.1514 0.851   0.600
#> 5 5 0.801           0.688       0.830         0.0582 0.857   0.526
#> 6 6 0.772           0.549       0.783         0.0341 0.990   0.955

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
#> GSM559383     1   0.000      0.972 1.000 0.000
#> GSM559387     1   0.000      0.972 1.000 0.000
#> GSM559391     1   0.000      0.972 1.000 0.000
#> GSM559395     1   0.000      0.972 1.000 0.000
#> GSM559397     1   0.000      0.972 1.000 0.000
#> GSM559401     1   0.000      0.972 1.000 0.000
#> GSM559414     1   0.000      0.972 1.000 0.000
#> GSM559422     2   0.839      0.625 0.268 0.732
#> GSM559424     1   0.000      0.972 1.000 0.000
#> GSM559431     2   0.000      0.975 0.000 1.000
#> GSM559432     2   0.000      0.975 0.000 1.000
#> GSM559381     1   0.722      0.752 0.800 0.200
#> GSM559382     2   0.000      0.975 0.000 1.000
#> GSM559384     1   0.000      0.972 1.000 0.000
#> GSM559385     1   0.000      0.972 1.000 0.000
#> GSM559386     2   0.000      0.975 0.000 1.000
#> GSM559388     2   0.000      0.975 0.000 1.000
#> GSM559389     1   0.722      0.752 0.800 0.200
#> GSM559390     1   0.605      0.821 0.852 0.148
#> GSM559392     2   0.000      0.975 0.000 1.000
#> GSM559393     2   0.000      0.975 0.000 1.000
#> GSM559394     1   0.000      0.972 1.000 0.000
#> GSM559396     1   0.000      0.972 1.000 0.000
#> GSM559398     2   0.000      0.975 0.000 1.000
#> GSM559399     1   0.000      0.972 1.000 0.000
#> GSM559400     2   0.000      0.975 0.000 1.000
#> GSM559402     1   0.000      0.972 1.000 0.000
#> GSM559403     1   0.000      0.972 1.000 0.000
#> GSM559404     1   0.000      0.972 1.000 0.000
#> GSM559405     1   0.000      0.972 1.000 0.000
#> GSM559406     1   0.000      0.972 1.000 0.000
#> GSM559407     1   0.000      0.972 1.000 0.000
#> GSM559408     1   0.000      0.972 1.000 0.000
#> GSM559409     1   0.000      0.972 1.000 0.000
#> GSM559410     1   0.000      0.972 1.000 0.000
#> GSM559411     1   0.000      0.972 1.000 0.000
#> GSM559412     1   0.000      0.972 1.000 0.000
#> GSM559413     1   0.000      0.972 1.000 0.000
#> GSM559415     1   0.000      0.972 1.000 0.000
#> GSM559416     1   0.833      0.643 0.736 0.264
#> GSM559417     2   0.671      0.775 0.176 0.824
#> GSM559418     2   0.000      0.975 0.000 1.000
#> GSM559419     1   0.000      0.972 1.000 0.000
#> GSM559420     1   0.000      0.972 1.000 0.000
#> GSM559421     2   0.000      0.975 0.000 1.000
#> GSM559423     2   0.000      0.975 0.000 1.000
#> GSM559425     2   0.000      0.975 0.000 1.000
#> GSM559426     2   0.000      0.975 0.000 1.000
#> GSM559427     2   0.000      0.975 0.000 1.000
#> GSM559428     2   0.000      0.975 0.000 1.000
#> GSM559429     2   0.000      0.975 0.000 1.000
#> GSM559430     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
#> GSM559383     3  0.0000     0.9882 0.000 0.000 1.000
#> GSM559387     3  0.0000     0.9882 0.000 0.000 1.000
#> GSM559391     3  0.0000     0.9882 0.000 0.000 1.000
#> GSM559395     3  0.0000     0.9882 0.000 0.000 1.000
#> GSM559397     3  0.0000     0.9882 0.000 0.000 1.000
#> GSM559401     3  0.0000     0.9882 0.000 0.000 1.000
#> GSM559414     3  0.0000     0.9882 0.000 0.000 1.000
#> GSM559422     3  0.0000     0.9882 0.000 0.000 1.000
#> GSM559424     3  0.0000     0.9882 0.000 0.000 1.000
#> GSM559431     2  0.0000     0.9988 0.000 1.000 0.000
#> GSM559432     3  0.3267     0.8680 0.000 0.116 0.884
#> GSM559381     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559382     2  0.0000     0.9988 0.000 1.000 0.000
#> GSM559384     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559385     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559386     2  0.0000     0.9988 0.000 1.000 0.000
#> GSM559388     2  0.0000     0.9988 0.000 1.000 0.000
#> GSM559389     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559390     1  0.3340     0.8460 0.880 0.000 0.120
#> GSM559392     2  0.0000     0.9988 0.000 1.000 0.000
#> GSM559393     2  0.0000     0.9988 0.000 1.000 0.000
#> GSM559394     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559396     3  0.0000     0.9882 0.000 0.000 1.000
#> GSM559398     2  0.0000     0.9988 0.000 1.000 0.000
#> GSM559399     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559400     2  0.0000     0.9988 0.000 1.000 0.000
#> GSM559402     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559403     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559404     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559405     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559406     1  0.1163     0.9461 0.972 0.000 0.028
#> GSM559407     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559408     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559409     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559410     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559411     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559412     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559413     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559415     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559416     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559417     1  0.6308     0.0302 0.508 0.492 0.000
#> GSM559418     2  0.0747     0.9806 0.016 0.984 0.000
#> GSM559419     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559420     1  0.0000     0.9698 1.000 0.000 0.000
#> GSM559421     2  0.0000     0.9988 0.000 1.000 0.000
#> GSM559423     2  0.0000     0.9988 0.000 1.000 0.000
#> GSM559425     2  0.0000     0.9988 0.000 1.000 0.000
#> GSM559426     2  0.0000     0.9988 0.000 1.000 0.000
#> GSM559427     2  0.0000     0.9988 0.000 1.000 0.000
#> GSM559428     2  0.0000     0.9988 0.000 1.000 0.000
#> GSM559429     2  0.0000     0.9988 0.000 1.000 0.000
#> GSM559430     2  0.0000     0.9988 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
#> GSM559383     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM559387     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM559391     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM559395     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM559397     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM559401     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM559414     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM559422     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM559424     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM559431     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM559432     3  0.4898      0.286 0.000 0.416 0.584 0.000
#> GSM559381     1  0.4431      0.816 0.696 0.000 0.000 0.304
#> GSM559382     2  0.0188      0.989 0.004 0.996 0.000 0.000
#> GSM559384     1  0.4382      0.817 0.704 0.000 0.000 0.296
#> GSM559385     1  0.4040      0.819 0.752 0.000 0.000 0.248
#> GSM559386     2  0.2737      0.886 0.104 0.888 0.000 0.008
#> GSM559388     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM559389     1  0.4008      0.819 0.756 0.000 0.000 0.244
#> GSM559390     4  0.3486      0.777 0.188 0.000 0.000 0.812
#> GSM559392     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM559393     1  0.4804      0.355 0.616 0.384 0.000 0.000
#> GSM559394     1  0.3801      0.814 0.780 0.000 0.000 0.220
#> GSM559396     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM559398     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM559399     1  0.0469      0.664 0.988 0.000 0.000 0.012
#> GSM559400     2  0.0469      0.982 0.000 0.988 0.000 0.012
#> GSM559402     1  0.4804      0.753 0.616 0.000 0.000 0.384
#> GSM559403     1  0.4072      0.819 0.748 0.000 0.000 0.252
#> GSM559404     1  0.4431      0.817 0.696 0.000 0.000 0.304
#> GSM559405     1  0.4356      0.819 0.708 0.000 0.000 0.292
#> GSM559406     4  0.1610      0.813 0.016 0.000 0.032 0.952
#> GSM559407     1  0.4877      0.722 0.592 0.000 0.000 0.408
#> GSM559408     4  0.1022      0.819 0.032 0.000 0.000 0.968
#> GSM559409     4  0.1118      0.818 0.036 0.000 0.000 0.964
#> GSM559410     1  0.4543      0.808 0.676 0.000 0.000 0.324
#> GSM559411     4  0.1118      0.818 0.036 0.000 0.000 0.964
#> GSM559412     4  0.1118      0.818 0.036 0.000 0.000 0.964
#> GSM559413     4  0.1118      0.818 0.036 0.000 0.000 0.964
#> GSM559415     1  0.1022      0.647 0.968 0.000 0.000 0.032
#> GSM559416     4  0.4220      0.750 0.248 0.004 0.000 0.748
#> GSM559417     4  0.4220      0.750 0.248 0.004 0.000 0.748
#> GSM559418     1  0.2596      0.596 0.908 0.068 0.000 0.024
#> GSM559419     4  0.4040      0.752 0.248 0.000 0.000 0.752
#> GSM559420     1  0.4277      0.724 0.720 0.000 0.000 0.280
#> GSM559421     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM559423     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM559425     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM559426     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM559427     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM559428     2  0.0188      0.989 0.004 0.996 0.000 0.000
#> GSM559429     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM559430     2  0.0000      0.991 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
#> GSM559383     3  0.0000    0.98311 0.000 0.000 1.000 0.000 0.000
#> GSM559387     3  0.0000    0.98311 0.000 0.000 1.000 0.000 0.000
#> GSM559391     3  0.0000    0.98311 0.000 0.000 1.000 0.000 0.000
#> GSM559395     3  0.0000    0.98311 0.000 0.000 1.000 0.000 0.000
#> GSM559397     3  0.0000    0.98311 0.000 0.000 1.000 0.000 0.000
#> GSM559401     3  0.0000    0.98311 0.000 0.000 1.000 0.000 0.000
#> GSM559414     3  0.0000    0.98311 0.000 0.000 1.000 0.000 0.000
#> GSM559422     3  0.2983    0.86648 0.000 0.000 0.864 0.040 0.096
#> GSM559424     3  0.0000    0.98311 0.000 0.000 1.000 0.000 0.000
#> GSM559431     2  0.0000    0.92782 0.000 1.000 0.000 0.000 0.000
#> GSM559432     2  0.5318    0.05860 0.000 0.496 0.460 0.040 0.004
#> GSM559381     1  0.6545    0.40954 0.464 0.000 0.000 0.220 0.316
#> GSM559382     2  0.1281    0.90450 0.000 0.956 0.000 0.012 0.032
#> GSM559384     1  0.6528    0.44998 0.480 0.000 0.000 0.236 0.284
#> GSM559385     5  0.0955    0.86656 0.028 0.000 0.000 0.004 0.968
#> GSM559386     2  0.5648    0.60395 0.020 0.680 0.000 0.160 0.140
#> GSM559388     2  0.0579    0.92136 0.000 0.984 0.000 0.008 0.008
#> GSM559389     5  0.3037    0.80959 0.040 0.000 0.000 0.100 0.860
#> GSM559390     1  0.4886   -0.00479 0.596 0.000 0.000 0.372 0.032
#> GSM559392     2  0.0000    0.92782 0.000 1.000 0.000 0.000 0.000
#> GSM559393     5  0.2588    0.76212 0.000 0.048 0.000 0.060 0.892
#> GSM559394     5  0.1106    0.86151 0.024 0.000 0.000 0.012 0.964
#> GSM559396     3  0.0912    0.96124 0.012 0.000 0.972 0.016 0.000
#> GSM559398     2  0.0000    0.92782 0.000 1.000 0.000 0.000 0.000
#> GSM559399     4  0.4708    0.19633 0.016 0.000 0.000 0.548 0.436
#> GSM559400     2  0.2674    0.81854 0.000 0.856 0.000 0.140 0.004
#> GSM559402     1  0.5984    0.54385 0.588 0.000 0.000 0.208 0.204
#> GSM559403     5  0.2329    0.79003 0.124 0.000 0.000 0.000 0.876
#> GSM559404     1  0.5512    0.53573 0.620 0.000 0.000 0.104 0.276
#> GSM559405     1  0.6218    0.41019 0.488 0.000 0.000 0.148 0.364
#> GSM559406     1  0.3002    0.47664 0.856 0.000 0.028 0.116 0.000
#> GSM559407     1  0.5904    0.54937 0.600 0.000 0.000 0.196 0.204
#> GSM559408     1  0.0880    0.57464 0.968 0.000 0.000 0.032 0.000
#> GSM559409     1  0.0703    0.57883 0.976 0.000 0.000 0.024 0.000
#> GSM559410     1  0.5968    0.36864 0.512 0.000 0.000 0.116 0.372
#> GSM559411     1  0.0880    0.59265 0.968 0.000 0.000 0.032 0.000
#> GSM559412     1  0.0290    0.58820 0.992 0.000 0.000 0.008 0.000
#> GSM559413     1  0.0000    0.58982 1.000 0.000 0.000 0.000 0.000
#> GSM559415     4  0.4294    0.21349 0.000 0.000 0.000 0.532 0.468
#> GSM559416     4  0.3837    0.45739 0.308 0.000 0.000 0.692 0.000
#> GSM559417     4  0.4047    0.44280 0.320 0.000 0.000 0.676 0.004
#> GSM559418     4  0.4590    0.26485 0.000 0.012 0.000 0.568 0.420
#> GSM559419     4  0.3990    0.46208 0.308 0.000 0.000 0.688 0.004
#> GSM559420     4  0.6169   -0.21410 0.392 0.000 0.000 0.472 0.136
#> GSM559421     2  0.0000    0.92782 0.000 1.000 0.000 0.000 0.000
#> GSM559423     2  0.0000    0.92782 0.000 1.000 0.000 0.000 0.000
#> GSM559425     2  0.0000    0.92782 0.000 1.000 0.000 0.000 0.000
#> GSM559426     2  0.0000    0.92782 0.000 1.000 0.000 0.000 0.000
#> GSM559427     2  0.0000    0.92782 0.000 1.000 0.000 0.000 0.000
#> GSM559428     2  0.1012    0.91337 0.000 0.968 0.000 0.020 0.012
#> GSM559429     2  0.0000    0.92782 0.000 1.000 0.000 0.000 0.000
#> GSM559430     2  0.0000    0.92782 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
#> GSM559383     3  0.0000    0.93756 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559387     3  0.0000    0.93756 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559391     3  0.0000    0.93756 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559395     3  0.0000    0.93756 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559397     3  0.0000    0.93756 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559401     3  0.0858    0.91986 0.004 0.000 0.968 0.000 0.000 0.028
#> GSM559414     3  0.0000    0.93756 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559422     3  0.5698    0.45415 0.176 0.000 0.556 0.000 0.008 0.260
#> GSM559424     3  0.0000    0.93756 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559431     2  0.0000    0.85963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559432     2  0.6579    0.07712 0.012 0.388 0.312 0.000 0.008 0.280
#> GSM559381     6  0.7076    0.00000 0.196 0.000 0.000 0.308 0.092 0.404
#> GSM559382     2  0.3499    0.76579 0.032 0.796 0.000 0.000 0.008 0.164
#> GSM559384     4  0.7481   -0.41494 0.168 0.000 0.000 0.376 0.212 0.244
#> GSM559385     1  0.1708    0.78967 0.932 0.000 0.000 0.040 0.004 0.024
#> GSM559386     2  0.7019    0.24612 0.100 0.428 0.000 0.016 0.100 0.356
#> GSM559388     2  0.1781    0.83569 0.008 0.924 0.000 0.000 0.008 0.060
#> GSM559389     1  0.5169    0.49319 0.672 0.000 0.000 0.056 0.060 0.212
#> GSM559390     4  0.6526   -0.17084 0.020 0.000 0.000 0.360 0.340 0.280
#> GSM559392     2  0.0260    0.85841 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM559393     1  0.2317    0.72101 0.900 0.016 0.000 0.000 0.020 0.064
#> GSM559394     1  0.1218    0.78556 0.956 0.000 0.000 0.028 0.012 0.004
#> GSM559396     3  0.2661    0.83310 0.000 0.000 0.872 0.016 0.016 0.096
#> GSM559398     2  0.0260    0.85841 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM559399     5  0.5232    0.38517 0.316 0.000 0.000 0.012 0.588 0.084
#> GSM559400     2  0.5282    0.49113 0.004 0.584 0.000 0.000 0.116 0.296
#> GSM559402     4  0.6445   -0.07341 0.108 0.000 0.000 0.564 0.148 0.180
#> GSM559403     1  0.3351    0.66181 0.820 0.000 0.000 0.136 0.016 0.028
#> GSM559404     4  0.4484    0.24049 0.160 0.000 0.000 0.744 0.056 0.040
#> GSM559405     4  0.6716   -0.23296 0.252 0.000 0.000 0.504 0.104 0.140
#> GSM559406     4  0.3627    0.39693 0.004 0.000 0.052 0.824 0.096 0.024
#> GSM559407     4  0.6043    0.03652 0.100 0.000 0.000 0.616 0.136 0.148
#> GSM559408     4  0.1082    0.49525 0.000 0.000 0.000 0.956 0.040 0.004
#> GSM559409     4  0.0692    0.50274 0.000 0.000 0.000 0.976 0.020 0.004
#> GSM559410     4  0.6094   -0.00339 0.268 0.000 0.000 0.556 0.124 0.052
#> GSM559411     4  0.1245    0.48480 0.000 0.000 0.000 0.952 0.016 0.032
#> GSM559412     4  0.0547    0.50336 0.000 0.000 0.000 0.980 0.020 0.000
#> GSM559413     4  0.0260    0.50200 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM559415     5  0.4486    0.36872 0.384 0.000 0.000 0.004 0.584 0.028
#> GSM559416     5  0.3551    0.50541 0.000 0.000 0.000 0.168 0.784 0.048
#> GSM559417     5  0.4314    0.47037 0.000 0.000 0.000 0.184 0.720 0.096
#> GSM559418     5  0.4774    0.40543 0.336 0.020 0.000 0.000 0.612 0.032
#> GSM559419     5  0.3377    0.50783 0.000 0.000 0.000 0.188 0.784 0.028
#> GSM559420     5  0.7102   -0.30176 0.100 0.000 0.000 0.236 0.432 0.232
#> GSM559421     2  0.0000    0.85963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559423     2  0.0363    0.85805 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM559425     2  0.0000    0.85963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559426     2  0.1411    0.84402 0.000 0.936 0.000 0.000 0.004 0.060
#> GSM559427     2  0.0000    0.85963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559428     2  0.3089    0.77139 0.004 0.800 0.000 0.000 0.008 0.188
#> GSM559429     2  0.1908    0.83012 0.000 0.900 0.000 0.000 0.004 0.096
#> GSM559430     2  0.0000    0.85963 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-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 disease.state(p) k
#> MAD:skmeans 52         6.10e-01 2
#> MAD:skmeans 51         2.00e-09 3
#> MAD:skmeans 50         2.17e-08 4
#> MAD:skmeans 38         2.79e-06 5
#> MAD:skmeans 31         1.82e-04 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 21167 rows and 52 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 0.473           0.747       0.840         0.3720 0.599   0.599
#> 3 3 0.967           0.927       0.973         0.6302 0.633   0.463
#> 4 4 0.816           0.878       0.934         0.2014 0.843   0.625
#> 5 5 0.829           0.881       0.931         0.0240 0.986   0.948
#> 6 6 0.719           0.629       0.830         0.0523 0.946   0.803

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
#> GSM559383     2   0.000     0.8100 0.000 1.000
#> GSM559387     2   0.000     0.8100 0.000 1.000
#> GSM559391     2   0.000     0.8100 0.000 1.000
#> GSM559395     2   0.000     0.8100 0.000 1.000
#> GSM559397     2   0.000     0.8100 0.000 1.000
#> GSM559401     2   0.000     0.8100 0.000 1.000
#> GSM559414     2   0.000     0.8100 0.000 1.000
#> GSM559422     2   0.000     0.8100 0.000 1.000
#> GSM559424     2   0.000     0.8100 0.000 1.000
#> GSM559431     1   0.000     0.7287 1.000 0.000
#> GSM559432     2   0.821     0.5685 0.256 0.744
#> GSM559381     1   0.821     0.8521 0.744 0.256
#> GSM559382     1   0.821     0.8521 0.744 0.256
#> GSM559384     1   0.821     0.8521 0.744 0.256
#> GSM559385     1   0.821     0.8521 0.744 0.256
#> GSM559386     1   0.821     0.8521 0.744 0.256
#> GSM559388     1   0.000     0.7287 1.000 0.000
#> GSM559389     1   0.821     0.8521 0.744 0.256
#> GSM559390     1   0.821     0.8521 0.744 0.256
#> GSM559392     1   0.000     0.7287 1.000 0.000
#> GSM559393     1   0.821     0.8521 0.744 0.256
#> GSM559394     1   0.821     0.8521 0.744 0.256
#> GSM559396     2   0.985    -0.0779 0.428 0.572
#> GSM559398     1   0.000     0.7287 1.000 0.000
#> GSM559399     1   0.821     0.8521 0.744 0.256
#> GSM559400     1   0.295     0.6696 0.948 0.052
#> GSM559402     1   0.821     0.8521 0.744 0.256
#> GSM559403     1   0.821     0.8521 0.744 0.256
#> GSM559404     2   0.997    -0.2184 0.468 0.532
#> GSM559405     1   0.821     0.8521 0.744 0.256
#> GSM559406     2   0.861     0.4397 0.284 0.716
#> GSM559407     1   0.821     0.8521 0.744 0.256
#> GSM559408     1   0.821     0.8521 0.744 0.256
#> GSM559409     1   0.821     0.8521 0.744 0.256
#> GSM559410     1   0.821     0.8521 0.744 0.256
#> GSM559411     1   0.881     0.7922 0.700 0.300
#> GSM559412     1   0.821     0.8521 0.744 0.256
#> GSM559413     2   0.958     0.1588 0.380 0.620
#> GSM559415     1   0.821     0.8521 0.744 0.256
#> GSM559416     1   0.821     0.8521 0.744 0.256
#> GSM559417     1   0.821     0.8521 0.744 0.256
#> GSM559418     1   0.821     0.8521 0.744 0.256
#> GSM559419     1   0.821     0.8521 0.744 0.256
#> GSM559420     1   0.821     0.8521 0.744 0.256
#> GSM559421     1   0.000     0.7287 1.000 0.000
#> GSM559423     1   0.000     0.7287 1.000 0.000
#> GSM559425     1   0.000     0.7287 1.000 0.000
#> GSM559426     1   0.000     0.7287 1.000 0.000
#> GSM559427     1   0.000     0.7287 1.000 0.000
#> GSM559428     1   0.163     0.7399 0.976 0.024
#> GSM559429     1   0.000     0.7287 1.000 0.000
#> GSM559430     1   0.000     0.7287 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM559383     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559387     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559391     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559395     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559397     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559401     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559414     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559422     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559424     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559431     2  0.0000      0.939 0.000 1.000 0.000
#> GSM559432     2  0.6295      0.120 0.000 0.528 0.472
#> GSM559381     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559382     1  0.5760      0.506 0.672 0.328 0.000
#> GSM559384     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559385     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559386     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559388     2  0.0592      0.927 0.012 0.988 0.000
#> GSM559389     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559390     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559392     2  0.0000      0.939 0.000 1.000 0.000
#> GSM559393     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559394     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559396     1  0.6062      0.380 0.616 0.000 0.384
#> GSM559398     2  0.0000      0.939 0.000 1.000 0.000
#> GSM559399     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559400     2  0.0000      0.939 0.000 1.000 0.000
#> GSM559402     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559403     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559404     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559405     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559406     1  0.0237      0.970 0.996 0.000 0.004
#> GSM559407     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559408     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559409     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559410     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559411     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559412     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559413     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559415     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559416     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559417     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559418     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559419     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559420     1  0.0000      0.974 1.000 0.000 0.000
#> GSM559421     2  0.0000      0.939 0.000 1.000 0.000
#> GSM559423     2  0.0000      0.939 0.000 1.000 0.000
#> GSM559425     2  0.0000      0.939 0.000 1.000 0.000
#> GSM559426     2  0.0000      0.939 0.000 1.000 0.000
#> GSM559427     2  0.0000      0.939 0.000 1.000 0.000
#> GSM559428     2  0.4750      0.668 0.216 0.784 0.000
#> GSM559429     2  0.0000      0.939 0.000 1.000 0.000
#> GSM559430     2  0.0000      0.939 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
#> GSM559383     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM559387     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM559391     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM559395     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM559397     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM559401     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM559414     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM559422     3  0.0188      0.995 0.004 0.000 0.996 0.000
#> GSM559424     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM559431     2  0.0000      0.951 0.000 1.000 0.000 0.000
#> GSM559432     2  0.4985      0.129 0.000 0.532 0.468 0.000
#> GSM559381     1  0.0000      0.901 1.000 0.000 0.000 0.000
#> GSM559382     4  0.3688      0.845 0.208 0.000 0.000 0.792
#> GSM559384     1  0.0000      0.901 1.000 0.000 0.000 0.000
#> GSM559385     1  0.0000      0.901 1.000 0.000 0.000 0.000
#> GSM559386     4  0.3688      0.845 0.208 0.000 0.000 0.792
#> GSM559388     4  0.3870      0.844 0.208 0.004 0.000 0.788
#> GSM559389     1  0.0000      0.901 1.000 0.000 0.000 0.000
#> GSM559390     4  0.0000      0.835 0.000 0.000 0.000 1.000
#> GSM559392     2  0.0000      0.951 0.000 1.000 0.000 0.000
#> GSM559393     1  0.0000      0.901 1.000 0.000 0.000 0.000
#> GSM559394     1  0.0000      0.901 1.000 0.000 0.000 0.000
#> GSM559396     1  0.4790      0.443 0.620 0.000 0.380 0.000
#> GSM559398     2  0.0000      0.951 0.000 1.000 0.000 0.000
#> GSM559399     1  0.0000      0.901 1.000 0.000 0.000 0.000
#> GSM559400     4  0.4499      0.835 0.160 0.048 0.000 0.792
#> GSM559402     1  0.0000      0.901 1.000 0.000 0.000 0.000
#> GSM559403     1  0.0000      0.901 1.000 0.000 0.000 0.000
#> GSM559404     1  0.0000      0.901 1.000 0.000 0.000 0.000
#> GSM559405     1  0.0000      0.901 1.000 0.000 0.000 0.000
#> GSM559406     4  0.0000      0.835 0.000 0.000 0.000 1.000
#> GSM559407     1  0.2814      0.842 0.868 0.000 0.000 0.132
#> GSM559408     1  0.3688      0.800 0.792 0.000 0.000 0.208
#> GSM559409     1  0.3688      0.800 0.792 0.000 0.000 0.208
#> GSM559410     1  0.3688      0.800 0.792 0.000 0.000 0.208
#> GSM559411     1  0.3688      0.800 0.792 0.000 0.000 0.208
#> GSM559412     1  0.3688      0.800 0.792 0.000 0.000 0.208
#> GSM559413     1  0.3688      0.800 0.792 0.000 0.000 0.208
#> GSM559415     1  0.0000      0.901 1.000 0.000 0.000 0.000
#> GSM559416     4  0.0000      0.835 0.000 0.000 0.000 1.000
#> GSM559417     4  0.0000      0.835 0.000 0.000 0.000 1.000
#> GSM559418     1  0.0000      0.901 1.000 0.000 0.000 0.000
#> GSM559419     4  0.2921      0.773 0.140 0.000 0.000 0.860
#> GSM559420     1  0.0000      0.901 1.000 0.000 0.000 0.000
#> GSM559421     2  0.0000      0.951 0.000 1.000 0.000 0.000
#> GSM559423     2  0.0000      0.951 0.000 1.000 0.000 0.000
#> GSM559425     2  0.0000      0.951 0.000 1.000 0.000 0.000
#> GSM559426     2  0.0000      0.951 0.000 1.000 0.000 0.000
#> GSM559427     2  0.0000      0.951 0.000 1.000 0.000 0.000
#> GSM559428     4  0.3688      0.845 0.208 0.000 0.000 0.792
#> GSM559429     2  0.0000      0.951 0.000 1.000 0.000 0.000
#> GSM559430     2  0.0000      0.951 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
#> GSM559383     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559387     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559391     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559395     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559397     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559401     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559414     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559422     5  0.1908      1.000 0.000 0.000 0.092 0.000 0.908
#> GSM559424     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM559431     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000
#> GSM559432     5  0.1908      1.000 0.000 0.000 0.092 0.000 0.908
#> GSM559381     1  0.0000      0.897 1.000 0.000 0.000 0.000 0.000
#> GSM559382     4  0.4205      0.750 0.208 0.008 0.000 0.756 0.028
#> GSM559384     1  0.0000      0.897 1.000 0.000 0.000 0.000 0.000
#> GSM559385     1  0.0000      0.897 1.000 0.000 0.000 0.000 0.000
#> GSM559386     4  0.3333      0.754 0.208 0.000 0.000 0.788 0.004
#> GSM559388     4  0.4592      0.743 0.208 0.024 0.000 0.740 0.028
#> GSM559389     1  0.0000      0.897 1.000 0.000 0.000 0.000 0.000
#> GSM559390     4  0.0000      0.780 0.000 0.000 0.000 1.000 0.000
#> GSM559392     2  0.0609      0.979 0.000 0.980 0.000 0.000 0.020
#> GSM559393     1  0.0162      0.895 0.996 0.000 0.000 0.000 0.004
#> GSM559394     1  0.0000      0.897 1.000 0.000 0.000 0.000 0.000
#> GSM559396     1  0.5113      0.448 0.604 0.000 0.352 0.004 0.040
#> GSM559398     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000
#> GSM559399     1  0.0000      0.897 1.000 0.000 0.000 0.000 0.000
#> GSM559400     4  0.3455      0.668 0.008 0.000 0.000 0.784 0.208
#> GSM559402     1  0.0000      0.897 1.000 0.000 0.000 0.000 0.000
#> GSM559403     1  0.0000      0.897 1.000 0.000 0.000 0.000 0.000
#> GSM559404     1  0.0000      0.897 1.000 0.000 0.000 0.000 0.000
#> GSM559405     1  0.0000      0.897 1.000 0.000 0.000 0.000 0.000
#> GSM559406     4  0.0162      0.779 0.004 0.000 0.000 0.996 0.000
#> GSM559407     1  0.2424      0.837 0.868 0.000 0.000 0.132 0.000
#> GSM559408     1  0.3210      0.790 0.788 0.000 0.000 0.212 0.000
#> GSM559409     1  0.4224      0.763 0.744 0.000 0.000 0.216 0.040
#> GSM559410     1  0.3177      0.793 0.792 0.000 0.000 0.208 0.000
#> GSM559411     1  0.4224      0.763 0.744 0.000 0.000 0.216 0.040
#> GSM559412     1  0.3210      0.790 0.788 0.000 0.000 0.212 0.000
#> GSM559413     1  0.4193      0.765 0.748 0.000 0.000 0.212 0.040
#> GSM559415     1  0.0000      0.897 1.000 0.000 0.000 0.000 0.000
#> GSM559416     4  0.0000      0.780 0.000 0.000 0.000 1.000 0.000
#> GSM559417     4  0.0000      0.780 0.000 0.000 0.000 1.000 0.000
#> GSM559418     1  0.0162      0.895 0.996 0.000 0.000 0.004 0.000
#> GSM559419     4  0.3262      0.682 0.124 0.000 0.000 0.840 0.036
#> GSM559420     1  0.0162      0.895 0.996 0.000 0.000 0.004 0.000
#> GSM559421     2  0.0609      0.979 0.000 0.980 0.000 0.000 0.020
#> GSM559423     2  0.0404      0.984 0.000 0.988 0.000 0.000 0.012
#> GSM559425     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000
#> GSM559426     2  0.0703      0.978 0.000 0.976 0.000 0.000 0.024
#> GSM559427     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000
#> GSM559428     4  0.4369      0.744 0.208 0.000 0.000 0.740 0.052
#> GSM559429     2  0.0880      0.974 0.000 0.968 0.000 0.000 0.032
#> GSM559430     2  0.0000      0.988 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
#> GSM559383     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559387     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559391     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559395     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559397     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559401     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559414     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559422     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM559424     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559431     2  0.0000     0.8931 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559432     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM559381     1  0.0000     0.7956 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559382     6  0.5655     0.9203 0.132 0.004 0.000 0.408 0.000 0.456
#> GSM559384     1  0.2092     0.7708 0.876 0.000 0.000 0.124 0.000 0.000
#> GSM559385     1  0.0000     0.7956 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559386     4  0.4558    -0.3085 0.132 0.000 0.000 0.700 0.000 0.168
#> GSM559388     6  0.5767     0.9202 0.124 0.012 0.000 0.392 0.000 0.472
#> GSM559389     1  0.0000     0.7956 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559390     4  0.2340     0.1941 0.000 0.000 0.000 0.852 0.000 0.148
#> GSM559392     2  0.2996     0.7434 0.000 0.772 0.000 0.000 0.000 0.228
#> GSM559393     1  0.3954     0.3439 0.636 0.000 0.000 0.012 0.000 0.352
#> GSM559394     1  0.0000     0.7956 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559396     4  0.6319     0.0728 0.308 0.000 0.036 0.488 0.000 0.168
#> GSM559398     2  0.2597     0.7815 0.000 0.824 0.000 0.000 0.000 0.176
#> GSM559399     1  0.4088     0.2623 0.616 0.000 0.000 0.368 0.000 0.016
#> GSM559400     4  0.5466    -0.6624 0.000 0.000 0.000 0.472 0.124 0.404
#> GSM559402     1  0.2092     0.7708 0.876 0.000 0.000 0.124 0.000 0.000
#> GSM559403     1  0.0000     0.7956 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559404     1  0.0000     0.7956 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559405     1  0.0000     0.7956 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559406     4  0.5571    -0.0130 0.356 0.000 0.000 0.496 0.000 0.148
#> GSM559407     1  0.2053     0.7769 0.888 0.000 0.000 0.108 0.000 0.004
#> GSM559408     1  0.2706     0.7583 0.852 0.000 0.000 0.024 0.000 0.124
#> GSM559409     1  0.4037     0.6897 0.736 0.000 0.000 0.064 0.000 0.200
#> GSM559410     1  0.2346     0.7657 0.868 0.000 0.000 0.008 0.000 0.124
#> GSM559411     1  0.4494     0.6398 0.692 0.000 0.000 0.092 0.000 0.216
#> GSM559412     1  0.2790     0.7557 0.844 0.000 0.000 0.024 0.000 0.132
#> GSM559413     1  0.3876     0.6382 0.700 0.000 0.000 0.024 0.000 0.276
#> GSM559415     1  0.3778     0.5556 0.696 0.000 0.000 0.288 0.000 0.016
#> GSM559416     4  0.0458     0.2138 0.000 0.000 0.000 0.984 0.000 0.016
#> GSM559417     4  0.2219     0.2054 0.000 0.000 0.000 0.864 0.000 0.136
#> GSM559418     1  0.4121     0.2362 0.604 0.000 0.000 0.380 0.000 0.016
#> GSM559419     4  0.3717     0.2784 0.072 0.000 0.000 0.780 0.000 0.148
#> GSM559420     4  0.3868    -0.2749 0.496 0.000 0.000 0.504 0.000 0.000
#> GSM559421     2  0.1141     0.8725 0.000 0.948 0.000 0.000 0.000 0.052
#> GSM559423     2  0.0363     0.8897 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM559425     2  0.0000     0.8931 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559426     2  0.0790     0.8819 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM559427     2  0.0000     0.8931 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559428     4  0.5390    -0.5519 0.132 0.000 0.000 0.540 0.000 0.328
#> GSM559429     2  0.3797     0.4527 0.000 0.580 0.000 0.000 0.000 0.420
#> GSM559430     2  0.0000     0.8931 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-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 disease.state(p) k
#> MAD:pam 48         1.09e-09 2
#> MAD:pam 50         2.49e-10 3
#> MAD:pam 50         1.26e-09 4
#> MAD:pam 51         2.87e-09 5
#> MAD:pam 38         8.67e-07 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 21167 rows and 52 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 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-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.978       0.974         0.3244 0.683   0.683
#> 3 3 0.979           0.962       0.977         0.9025 0.704   0.567
#> 4 4 0.770           0.819       0.871         0.1028 0.988   0.969
#> 5 5 0.736           0.771       0.802         0.0905 0.834   0.572
#> 6 6 0.858           0.864       0.921         0.0715 0.952   0.800

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
#> GSM559383     2  0.2778      1.000 0.048 0.952
#> GSM559387     2  0.2778      1.000 0.048 0.952
#> GSM559391     2  0.2778      1.000 0.048 0.952
#> GSM559395     2  0.2778      1.000 0.048 0.952
#> GSM559397     2  0.2778      1.000 0.048 0.952
#> GSM559401     2  0.2778      1.000 0.048 0.952
#> GSM559414     2  0.2778      1.000 0.048 0.952
#> GSM559422     2  0.2778      1.000 0.048 0.952
#> GSM559424     2  0.2778      1.000 0.048 0.952
#> GSM559431     1  0.3114      0.961 0.944 0.056
#> GSM559432     2  0.2778      1.000 0.048 0.952
#> GSM559381     1  0.0376      0.979 0.996 0.004
#> GSM559382     1  0.2778      0.964 0.952 0.048
#> GSM559384     1  0.0000      0.979 1.000 0.000
#> GSM559385     1  0.0000      0.979 1.000 0.000
#> GSM559386     1  0.0376      0.979 0.996 0.004
#> GSM559388     1  0.3114      0.961 0.944 0.056
#> GSM559389     1  0.0000      0.979 1.000 0.000
#> GSM559390     1  0.0938      0.975 0.988 0.012
#> GSM559392     1  0.3114      0.961 0.944 0.056
#> GSM559393     1  0.0000      0.979 1.000 0.000
#> GSM559394     1  0.0000      0.979 1.000 0.000
#> GSM559396     1  0.1414      0.973 0.980 0.020
#> GSM559398     1  0.3114      0.961 0.944 0.056
#> GSM559399     1  0.0376      0.979 0.996 0.004
#> GSM559400     1  0.2236      0.972 0.964 0.036
#> GSM559402     1  0.0376      0.979 0.996 0.004
#> GSM559403     1  0.0000      0.979 1.000 0.000
#> GSM559404     1  0.0000      0.979 1.000 0.000
#> GSM559405     1  0.0000      0.979 1.000 0.000
#> GSM559406     1  0.0938      0.975 0.988 0.012
#> GSM559407     1  0.0376      0.979 0.996 0.004
#> GSM559408     1  0.0938      0.975 0.988 0.012
#> GSM559409     1  0.0000      0.979 1.000 0.000
#> GSM559410     1  0.0000      0.979 1.000 0.000
#> GSM559411     1  0.0938      0.975 0.988 0.012
#> GSM559412     1  0.0938      0.975 0.988 0.012
#> GSM559413     1  0.0938      0.975 0.988 0.012
#> GSM559415     1  0.0376      0.979 0.996 0.004
#> GSM559416     1  0.0938      0.975 0.988 0.012
#> GSM559417     1  0.0938      0.975 0.988 0.012
#> GSM559418     1  0.0000      0.979 1.000 0.000
#> GSM559419     1  0.0672      0.976 0.992 0.008
#> GSM559420     1  0.0000      0.979 1.000 0.000
#> GSM559421     1  0.3114      0.961 0.944 0.056
#> GSM559423     1  0.3114      0.961 0.944 0.056
#> GSM559425     1  0.3114      0.961 0.944 0.056
#> GSM559426     1  0.3114      0.961 0.944 0.056
#> GSM559427     1  0.3114      0.961 0.944 0.056
#> GSM559428     1  0.2948      0.962 0.948 0.052
#> GSM559429     1  0.2948      0.962 0.948 0.052
#> GSM559430     1  0.3114      0.961 0.944 0.056

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM559383     3  0.0000      0.986 0.000 0.000 1.000
#> GSM559387     3  0.0000      0.986 0.000 0.000 1.000
#> GSM559391     3  0.0000      0.986 0.000 0.000 1.000
#> GSM559395     3  0.0000      0.986 0.000 0.000 1.000
#> GSM559397     3  0.0000      0.986 0.000 0.000 1.000
#> GSM559401     3  0.0000      0.986 0.000 0.000 1.000
#> GSM559414     3  0.0000      0.986 0.000 0.000 1.000
#> GSM559422     3  0.0000      0.986 0.000 0.000 1.000
#> GSM559424     3  0.0000      0.986 0.000 0.000 1.000
#> GSM559431     2  0.0000      0.984 0.000 1.000 0.000
#> GSM559432     3  0.3412      0.857 0.000 0.124 0.876
#> GSM559381     1  0.0000      0.967 1.000 0.000 0.000
#> GSM559382     2  0.0747      0.974 0.016 0.984 0.000
#> GSM559384     1  0.0000      0.967 1.000 0.000 0.000
#> GSM559385     1  0.1620      0.958 0.964 0.024 0.012
#> GSM559386     1  0.2537      0.927 0.920 0.080 0.000
#> GSM559388     2  0.0237      0.983 0.004 0.996 0.000
#> GSM559389     1  0.1289      0.959 0.968 0.032 0.000
#> GSM559390     1  0.2537      0.927 0.920 0.080 0.000
#> GSM559392     2  0.0000      0.984 0.000 1.000 0.000
#> GSM559393     1  0.1620      0.958 0.964 0.024 0.012
#> GSM559394     1  0.1620      0.958 0.964 0.024 0.012
#> GSM559396     1  0.5268      0.756 0.776 0.212 0.012
#> GSM559398     2  0.0000      0.984 0.000 1.000 0.000
#> GSM559399     1  0.0000      0.967 1.000 0.000 0.000
#> GSM559400     2  0.2229      0.948 0.044 0.944 0.012
#> GSM559402     1  0.0000      0.967 1.000 0.000 0.000
#> GSM559403     1  0.1289      0.959 0.968 0.032 0.000
#> GSM559404     1  0.1289      0.959 0.968 0.032 0.000
#> GSM559405     1  0.0000      0.967 1.000 0.000 0.000
#> GSM559406     1  0.3459      0.908 0.892 0.096 0.012
#> GSM559407     1  0.0000      0.967 1.000 0.000 0.000
#> GSM559408     1  0.0000      0.967 1.000 0.000 0.000
#> GSM559409     1  0.0000      0.967 1.000 0.000 0.000
#> GSM559410     1  0.0000      0.967 1.000 0.000 0.000
#> GSM559411     1  0.2066      0.942 0.940 0.060 0.000
#> GSM559412     1  0.0237      0.967 0.996 0.004 0.000
#> GSM559413     1  0.2066      0.942 0.940 0.060 0.000
#> GSM559415     1  0.0000      0.967 1.000 0.000 0.000
#> GSM559416     1  0.0892      0.964 0.980 0.020 0.000
#> GSM559417     1  0.1031      0.963 0.976 0.024 0.000
#> GSM559418     1  0.1031      0.963 0.976 0.024 0.000
#> GSM559419     1  0.0424      0.966 0.992 0.008 0.000
#> GSM559420     1  0.0747      0.965 0.984 0.016 0.000
#> GSM559421     2  0.0000      0.984 0.000 1.000 0.000
#> GSM559423     2  0.0000      0.984 0.000 1.000 0.000
#> GSM559425     2  0.0000      0.984 0.000 1.000 0.000
#> GSM559426     2  0.0237      0.983 0.004 0.996 0.000
#> GSM559427     2  0.0000      0.984 0.000 1.000 0.000
#> GSM559428     2  0.2116      0.952 0.040 0.948 0.012
#> GSM559429     2  0.2063      0.951 0.044 0.948 0.008
#> GSM559430     2  0.0000      0.984 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
#> GSM559383     3  0.0000      0.892 0.000 0.000 1.000 0.000
#> GSM559387     3  0.0000      0.892 0.000 0.000 1.000 0.000
#> GSM559391     3  0.0000      0.892 0.000 0.000 1.000 0.000
#> GSM559395     3  0.0000      0.892 0.000 0.000 1.000 0.000
#> GSM559397     3  0.0000      0.892 0.000 0.000 1.000 0.000
#> GSM559401     3  0.4933     -0.626 0.000 0.000 0.568 0.432
#> GSM559414     3  0.0000      0.892 0.000 0.000 1.000 0.000
#> GSM559422     4  0.4877      0.991 0.000 0.000 0.408 0.592
#> GSM559424     3  0.0000      0.892 0.000 0.000 1.000 0.000
#> GSM559431     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM559432     4  0.4866      0.991 0.000 0.000 0.404 0.596
#> GSM559381     1  0.2973      0.800 0.856 0.000 0.000 0.144
#> GSM559382     2  0.0336      0.971 0.000 0.992 0.000 0.008
#> GSM559384     1  0.0000      0.816 1.000 0.000 0.000 0.000
#> GSM559385     1  0.3486      0.786 0.812 0.000 0.000 0.188
#> GSM559386     1  0.5674      0.743 0.720 0.148 0.000 0.132
#> GSM559388     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM559389     1  0.2973      0.800 0.856 0.000 0.000 0.144
#> GSM559390     1  0.4853      0.754 0.744 0.036 0.000 0.220
#> GSM559392     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM559393     1  0.4163      0.773 0.792 0.020 0.000 0.188
#> GSM559394     1  0.3486      0.786 0.812 0.000 0.000 0.188
#> GSM559396     1  0.7882      0.401 0.488 0.280 0.012 0.220
#> GSM559398     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM559399     1  0.2408      0.809 0.896 0.000 0.000 0.104
#> GSM559400     2  0.3688      0.731 0.000 0.792 0.000 0.208
#> GSM559402     1  0.1211      0.816 0.960 0.000 0.000 0.040
#> GSM559403     1  0.3311      0.793 0.828 0.000 0.000 0.172
#> GSM559404     1  0.3444      0.788 0.816 0.000 0.000 0.184
#> GSM559405     1  0.2973      0.800 0.856 0.000 0.000 0.144
#> GSM559406     1  0.5179      0.740 0.728 0.052 0.000 0.220
#> GSM559407     1  0.0000      0.816 1.000 0.000 0.000 0.000
#> GSM559408     1  0.3649      0.777 0.796 0.000 0.000 0.204
#> GSM559409     1  0.3569      0.780 0.804 0.000 0.000 0.196
#> GSM559410     1  0.0000      0.816 1.000 0.000 0.000 0.000
#> GSM559411     1  0.4364      0.766 0.764 0.016 0.000 0.220
#> GSM559412     1  0.3726      0.774 0.788 0.000 0.000 0.212
#> GSM559413     1  0.3801      0.771 0.780 0.000 0.000 0.220
#> GSM559415     1  0.2973      0.800 0.856 0.000 0.000 0.144
#> GSM559416     1  0.4574      0.763 0.756 0.024 0.000 0.220
#> GSM559417     1  0.4574      0.763 0.756 0.024 0.000 0.220
#> GSM559418     1  0.3441      0.800 0.856 0.024 0.000 0.120
#> GSM559419     1  0.4290      0.770 0.772 0.016 0.000 0.212
#> GSM559420     1  0.1970      0.810 0.932 0.008 0.000 0.060
#> GSM559421     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM559423     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM559425     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM559426     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM559427     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM559428     2  0.1389      0.933 0.000 0.952 0.000 0.048
#> GSM559429     2  0.0336      0.971 0.000 0.992 0.000 0.008
#> GSM559430     2  0.0000      0.976 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
#> GSM559383     3  0.0000      0.854 0.000 0.000 1.000 0.000 0.000
#> GSM559387     3  0.0000      0.854 0.000 0.000 1.000 0.000 0.000
#> GSM559391     3  0.0404      0.851 0.000 0.000 0.988 0.012 0.000
#> GSM559395     3  0.0000      0.854 0.000 0.000 1.000 0.000 0.000
#> GSM559397     3  0.0000      0.854 0.000 0.000 1.000 0.000 0.000
#> GSM559401     3  0.5426      0.680 0.000 0.000 0.640 0.252 0.108
#> GSM559414     3  0.0000      0.854 0.000 0.000 1.000 0.000 0.000
#> GSM559422     3  0.6725      0.527 0.000 0.000 0.420 0.288 0.292
#> GSM559424     3  0.0703      0.848 0.000 0.000 0.976 0.024 0.000
#> GSM559431     2  0.0000      0.911 0.000 1.000 0.000 0.000 0.000
#> GSM559432     3  0.6779      0.489 0.000 0.000 0.384 0.284 0.332
#> GSM559381     1  0.0000      0.816 1.000 0.000 0.000 0.000 0.000
#> GSM559382     2  0.3687      0.821 0.028 0.792 0.000 0.180 0.000
#> GSM559384     1  0.1484      0.792 0.944 0.000 0.000 0.008 0.048
#> GSM559385     5  0.3752      0.935 0.292 0.000 0.000 0.000 0.708
#> GSM559386     1  0.2535      0.713 0.892 0.076 0.000 0.032 0.000
#> GSM559388     2  0.1544      0.893 0.000 0.932 0.000 0.068 0.000
#> GSM559389     1  0.0955      0.794 0.968 0.004 0.000 0.000 0.028
#> GSM559390     4  0.4446      0.909 0.400 0.008 0.000 0.592 0.000
#> GSM559392     2  0.0404      0.909 0.000 0.988 0.000 0.012 0.000
#> GSM559393     5  0.4890      0.866 0.224 0.008 0.000 0.060 0.708
#> GSM559394     5  0.3796      0.936 0.300 0.000 0.000 0.000 0.700
#> GSM559396     4  0.5158      0.793 0.308 0.040 0.012 0.640 0.000
#> GSM559398     2  0.0000      0.911 0.000 1.000 0.000 0.000 0.000
#> GSM559399     1  0.0000      0.816 1.000 0.000 0.000 0.000 0.000
#> GSM559400     2  0.4455      0.555 0.008 0.588 0.000 0.404 0.000
#> GSM559402     1  0.0000      0.816 1.000 0.000 0.000 0.000 0.000
#> GSM559403     1  0.4166      0.180 0.648 0.004 0.000 0.000 0.348
#> GSM559404     5  0.4270      0.909 0.320 0.000 0.000 0.012 0.668
#> GSM559405     1  0.0000      0.816 1.000 0.000 0.000 0.000 0.000
#> GSM559406     4  0.4575      0.903 0.392 0.008 0.000 0.596 0.004
#> GSM559407     1  0.0000      0.816 1.000 0.000 0.000 0.000 0.000
#> GSM559408     1  0.3039      0.559 0.808 0.000 0.000 0.192 0.000
#> GSM559409     1  0.1608      0.768 0.928 0.000 0.000 0.072 0.000
#> GSM559410     1  0.0000      0.816 1.000 0.000 0.000 0.000 0.000
#> GSM559411     4  0.4273      0.838 0.448 0.000 0.000 0.552 0.000
#> GSM559412     1  0.3177      0.530 0.792 0.000 0.000 0.208 0.000
#> GSM559413     1  0.3990      0.151 0.688 0.000 0.000 0.308 0.004
#> GSM559415     1  0.0000      0.816 1.000 0.000 0.000 0.000 0.000
#> GSM559416     4  0.4201      0.907 0.408 0.000 0.000 0.592 0.000
#> GSM559417     4  0.4235      0.892 0.424 0.000 0.000 0.576 0.000
#> GSM559418     1  0.1331      0.775 0.952 0.008 0.000 0.040 0.000
#> GSM559419     1  0.4114     -0.232 0.624 0.000 0.000 0.376 0.000
#> GSM559420     1  0.1410      0.766 0.940 0.000 0.000 0.060 0.000
#> GSM559421     2  0.0000      0.911 0.000 1.000 0.000 0.000 0.000
#> GSM559423     2  0.1478      0.894 0.000 0.936 0.000 0.064 0.000
#> GSM559425     2  0.0000      0.911 0.000 1.000 0.000 0.000 0.000
#> GSM559426     2  0.0000      0.911 0.000 1.000 0.000 0.000 0.000
#> GSM559427     2  0.0000      0.911 0.000 1.000 0.000 0.000 0.000
#> GSM559428     2  0.4150      0.789 0.036 0.748 0.000 0.216 0.000
#> GSM559429     2  0.4054      0.798 0.036 0.760 0.000 0.204 0.000
#> GSM559430     2  0.0000      0.911 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
#> GSM559383     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559387     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559391     3  0.0865      0.965 0.000 0.000 0.964 0.036 0.000 0.000
#> GSM559395     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559397     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559401     5  0.3309      0.859 0.000 0.000 0.280 0.000 0.720 0.000
#> GSM559414     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559422     5  0.2631      0.937 0.000 0.000 0.180 0.000 0.820 0.000
#> GSM559424     3  0.0865      0.965 0.000 0.000 0.964 0.036 0.000 0.000
#> GSM559431     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559432     5  0.2631      0.937 0.000 0.000 0.180 0.000 0.820 0.000
#> GSM559381     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559382     2  0.2384      0.898 0.000 0.884 0.000 0.032 0.084 0.000
#> GSM559384     1  0.2066      0.867 0.904 0.000 0.000 0.000 0.024 0.072
#> GSM559385     6  0.0000      0.854 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559386     1  0.1625      0.867 0.928 0.060 0.000 0.012 0.000 0.000
#> GSM559388     2  0.0260      0.952 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM559389     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559390     4  0.2384      0.785 0.048 0.000 0.000 0.888 0.064 0.000
#> GSM559392     2  0.0260      0.952 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM559393     6  0.0000      0.854 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559394     6  0.0000      0.854 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559396     4  0.1812      0.715 0.008 0.000 0.000 0.912 0.080 0.000
#> GSM559398     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559399     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559400     2  0.4200      0.743 0.000 0.740 0.000 0.120 0.140 0.000
#> GSM559402     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559403     6  0.3428      0.531 0.304 0.000 0.000 0.000 0.000 0.696
#> GSM559404     6  0.1267      0.828 0.060 0.000 0.000 0.000 0.000 0.940
#> GSM559405     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559406     4  0.2136      0.769 0.048 0.000 0.000 0.904 0.048 0.000
#> GSM559407     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559408     1  0.3364      0.761 0.780 0.000 0.000 0.196 0.024 0.000
#> GSM559409     1  0.2988      0.810 0.824 0.000 0.000 0.152 0.024 0.000
#> GSM559410     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559411     4  0.3309      0.591 0.280 0.000 0.000 0.720 0.000 0.000
#> GSM559412     1  0.3364      0.761 0.780 0.000 0.000 0.196 0.024 0.000
#> GSM559413     1  0.3266      0.675 0.728 0.000 0.000 0.272 0.000 0.000
#> GSM559415     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559416     4  0.2258      0.785 0.044 0.000 0.000 0.896 0.060 0.000
#> GSM559417     4  0.2258      0.785 0.044 0.000 0.000 0.896 0.060 0.000
#> GSM559418     1  0.0622      0.903 0.980 0.000 0.000 0.008 0.000 0.012
#> GSM559419     4  0.3774      0.278 0.408 0.000 0.000 0.592 0.000 0.000
#> GSM559420     1  0.2165      0.853 0.884 0.000 0.000 0.108 0.008 0.000
#> GSM559421     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559423     2  0.0260      0.952 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM559425     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559426     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559427     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559428     2  0.2537      0.891 0.000 0.872 0.000 0.032 0.096 0.000
#> GSM559429     2  0.2487      0.893 0.000 0.876 0.000 0.032 0.092 0.000
#> GSM559430     2  0.0000      0.953 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-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 disease.state(p) k
#> MAD:mclust 52         1.99e-10 2
#> MAD:mclust 52         8.27e-11 3
#> MAD:mclust 50         1.37e-09 4
#> MAD:mclust 48         1.40e-08 5
#> MAD:mclust 51         1.14e-08 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 21167 rows and 52 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 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-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.880           0.944       0.973         0.4788 0.527   0.527
#> 3 3 0.969           0.917       0.968         0.3424 0.775   0.593
#> 4 4 0.680           0.625       0.834         0.1157 0.825   0.570
#> 5 5 0.654           0.671       0.795         0.0905 0.839   0.516
#> 6 6 0.671           0.633       0.771         0.0556 0.916   0.654

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
#> GSM559383     1  0.0000      0.964 1.000 0.000
#> GSM559387     1  0.0000      0.964 1.000 0.000
#> GSM559391     1  0.0000      0.964 1.000 0.000
#> GSM559395     1  0.0000      0.964 1.000 0.000
#> GSM559397     1  0.0000      0.964 1.000 0.000
#> GSM559401     1  0.0000      0.964 1.000 0.000
#> GSM559414     1  0.0000      0.964 1.000 0.000
#> GSM559422     1  0.0000      0.964 1.000 0.000
#> GSM559424     1  0.0000      0.964 1.000 0.000
#> GSM559431     2  0.0000      0.983 0.000 1.000
#> GSM559432     2  0.3431      0.922 0.064 0.936
#> GSM559381     1  0.7950      0.721 0.760 0.240
#> GSM559382     2  0.0000      0.983 0.000 1.000
#> GSM559384     1  0.0000      0.964 1.000 0.000
#> GSM559385     1  0.0000      0.964 1.000 0.000
#> GSM559386     2  0.0000      0.983 0.000 1.000
#> GSM559388     2  0.0000      0.983 0.000 1.000
#> GSM559389     1  0.7883      0.727 0.764 0.236
#> GSM559390     1  0.0376      0.963 0.996 0.004
#> GSM559392     2  0.0000      0.983 0.000 1.000
#> GSM559393     2  0.0000      0.983 0.000 1.000
#> GSM559394     1  0.5408      0.864 0.876 0.124
#> GSM559396     1  0.0000      0.964 1.000 0.000
#> GSM559398     2  0.0000      0.983 0.000 1.000
#> GSM559399     1  0.3879      0.909 0.924 0.076
#> GSM559400     2  0.0000      0.983 0.000 1.000
#> GSM559402     1  0.1633      0.950 0.976 0.024
#> GSM559403     1  0.0672      0.961 0.992 0.008
#> GSM559404     1  0.0000      0.964 1.000 0.000
#> GSM559405     1  0.0376      0.963 0.996 0.004
#> GSM559406     1  0.0000      0.964 1.000 0.000
#> GSM559407     1  0.0000      0.964 1.000 0.000
#> GSM559408     1  0.0000      0.964 1.000 0.000
#> GSM559409     1  0.0000      0.964 1.000 0.000
#> GSM559410     1  0.0672      0.961 0.992 0.008
#> GSM559411     1  0.0000      0.964 1.000 0.000
#> GSM559412     1  0.0000      0.964 1.000 0.000
#> GSM559413     1  0.0000      0.964 1.000 0.000
#> GSM559415     1  0.8443      0.668 0.728 0.272
#> GSM559416     1  0.5408      0.858 0.876 0.124
#> GSM559417     2  0.7815      0.687 0.232 0.768
#> GSM559418     2  0.0000      0.983 0.000 1.000
#> GSM559419     1  0.0672      0.961 0.992 0.008
#> GSM559420     1  0.0000      0.964 1.000 0.000
#> GSM559421     2  0.0000      0.983 0.000 1.000
#> GSM559423     2  0.0000      0.983 0.000 1.000
#> GSM559425     2  0.0000      0.983 0.000 1.000
#> GSM559426     2  0.0000      0.983 0.000 1.000
#> GSM559427     2  0.0000      0.983 0.000 1.000
#> GSM559428     2  0.0000      0.983 0.000 1.000
#> GSM559429     2  0.0000      0.983 0.000 1.000
#> GSM559430     2  0.0000      0.983 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
#> GSM559383     3  0.0000      0.996 0.000 0.000 1.000
#> GSM559387     3  0.0000      0.996 0.000 0.000 1.000
#> GSM559391     3  0.0000      0.996 0.000 0.000 1.000
#> GSM559395     3  0.0000      0.996 0.000 0.000 1.000
#> GSM559397     3  0.0000      0.996 0.000 0.000 1.000
#> GSM559401     3  0.0000      0.996 0.000 0.000 1.000
#> GSM559414     3  0.0000      0.996 0.000 0.000 1.000
#> GSM559422     3  0.0000      0.996 0.000 0.000 1.000
#> GSM559424     3  0.0000      0.996 0.000 0.000 1.000
#> GSM559431     2  0.0000      0.915 0.000 1.000 0.000
#> GSM559432     3  0.0000      0.996 0.000 0.000 1.000
#> GSM559381     1  0.0237      0.974 0.996 0.004 0.000
#> GSM559382     2  0.0000      0.915 0.000 1.000 0.000
#> GSM559384     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559385     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559386     2  0.6126      0.380 0.400 0.600 0.000
#> GSM559388     2  0.0000      0.915 0.000 1.000 0.000
#> GSM559389     1  0.0237      0.974 0.996 0.004 0.000
#> GSM559390     1  0.1411      0.944 0.964 0.000 0.036
#> GSM559392     2  0.0000      0.915 0.000 1.000 0.000
#> GSM559393     2  0.6062      0.420 0.384 0.616 0.000
#> GSM559394     1  0.0237      0.974 0.996 0.004 0.000
#> GSM559396     3  0.1411      0.958 0.036 0.000 0.964
#> GSM559398     2  0.0000      0.915 0.000 1.000 0.000
#> GSM559399     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559400     2  0.1753      0.876 0.000 0.952 0.048
#> GSM559402     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559403     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559404     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559405     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559406     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559407     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559408     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559409     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559410     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559411     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559412     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559413     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559415     1  0.0237      0.974 0.996 0.004 0.000
#> GSM559416     1  0.1411      0.942 0.964 0.036 0.000
#> GSM559417     1  0.6168      0.202 0.588 0.412 0.000
#> GSM559418     2  0.5465      0.608 0.288 0.712 0.000
#> GSM559419     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559420     1  0.0000      0.976 1.000 0.000 0.000
#> GSM559421     2  0.0000      0.915 0.000 1.000 0.000
#> GSM559423     2  0.0000      0.915 0.000 1.000 0.000
#> GSM559425     2  0.0000      0.915 0.000 1.000 0.000
#> GSM559426     2  0.0000      0.915 0.000 1.000 0.000
#> GSM559427     2  0.0000      0.915 0.000 1.000 0.000
#> GSM559428     2  0.0000      0.915 0.000 1.000 0.000
#> GSM559429     2  0.0000      0.915 0.000 1.000 0.000
#> GSM559430     2  0.0000      0.915 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
#> GSM559383     4  0.4543    -0.1049 0.000 0.000 0.324 0.676
#> GSM559387     4  0.4994    -0.5326 0.000 0.000 0.480 0.520
#> GSM559391     4  0.3907     0.1696 0.000 0.000 0.232 0.768
#> GSM559395     3  0.5000     0.4407 0.000 0.000 0.504 0.496
#> GSM559397     3  0.4817     0.5811 0.000 0.000 0.612 0.388
#> GSM559401     3  0.2281     0.6571 0.000 0.000 0.904 0.096
#> GSM559414     3  0.4985     0.4956 0.000 0.000 0.532 0.468
#> GSM559422     3  0.0469     0.6366 0.000 0.000 0.988 0.012
#> GSM559424     4  0.3764     0.2012 0.000 0.000 0.216 0.784
#> GSM559431     2  0.0188     0.9101 0.000 0.996 0.000 0.004
#> GSM559432     3  0.0188     0.6251 0.000 0.004 0.996 0.000
#> GSM559381     1  0.0921     0.8235 0.972 0.000 0.000 0.028
#> GSM559382     2  0.1305     0.9010 0.000 0.960 0.036 0.004
#> GSM559384     1  0.2216     0.7984 0.908 0.000 0.000 0.092
#> GSM559385     1  0.0672     0.8183 0.984 0.000 0.008 0.008
#> GSM559386     2  0.5987     0.0351 0.440 0.520 0.000 0.040
#> GSM559388     2  0.0927     0.9078 0.000 0.976 0.016 0.008
#> GSM559389     1  0.0707     0.8234 0.980 0.000 0.000 0.020
#> GSM559390     4  0.5309     0.3285 0.280 0.028 0.004 0.688
#> GSM559392     2  0.0895     0.9081 0.000 0.976 0.020 0.004
#> GSM559393     1  0.5422     0.6116 0.740 0.040 0.200 0.020
#> GSM559394     1  0.3737     0.7086 0.840 0.004 0.136 0.020
#> GSM559396     4  0.3552     0.2957 0.024 0.000 0.128 0.848
#> GSM559398     2  0.0817     0.9069 0.000 0.976 0.024 0.000
#> GSM559399     1  0.1302     0.8216 0.956 0.000 0.000 0.044
#> GSM559400     2  0.3691     0.8257 0.000 0.856 0.076 0.068
#> GSM559402     1  0.1940     0.8137 0.924 0.000 0.000 0.076
#> GSM559403     1  0.0469     0.8199 0.988 0.000 0.000 0.012
#> GSM559404     1  0.0188     0.8219 0.996 0.000 0.000 0.004
#> GSM559405     1  0.0000     0.8226 1.000 0.000 0.000 0.000
#> GSM559406     1  0.5000     0.2189 0.504 0.000 0.000 0.496
#> GSM559407     1  0.2530     0.8003 0.888 0.000 0.000 0.112
#> GSM559408     1  0.4164     0.6734 0.736 0.000 0.000 0.264
#> GSM559409     1  0.2589     0.7976 0.884 0.000 0.000 0.116
#> GSM559410     1  0.0336     0.8238 0.992 0.000 0.000 0.008
#> GSM559411     4  0.4008     0.4195 0.244 0.000 0.000 0.756
#> GSM559412     1  0.4356     0.6411 0.708 0.000 0.000 0.292
#> GSM559413     1  0.4605     0.5807 0.664 0.000 0.000 0.336
#> GSM559415     1  0.0376     0.8222 0.992 0.004 0.000 0.004
#> GSM559416     4  0.6054     0.3292 0.088 0.256 0.000 0.656
#> GSM559417     2  0.6570     0.3317 0.080 0.572 0.004 0.344
#> GSM559418     1  0.5143     0.4221 0.628 0.360 0.000 0.012
#> GSM559419     4  0.5125     0.0407 0.388 0.008 0.000 0.604
#> GSM559420     1  0.4713     0.4319 0.640 0.000 0.000 0.360
#> GSM559421     2  0.0336     0.9095 0.000 0.992 0.000 0.008
#> GSM559423     2  0.1059     0.9075 0.000 0.972 0.016 0.012
#> GSM559425     2  0.0000     0.9104 0.000 1.000 0.000 0.000
#> GSM559426     2  0.0592     0.9086 0.000 0.984 0.000 0.016
#> GSM559427     2  0.0188     0.9101 0.000 0.996 0.000 0.004
#> GSM559428     2  0.0592     0.9089 0.000 0.984 0.000 0.016
#> GSM559429     2  0.0592     0.9086 0.000 0.984 0.000 0.016
#> GSM559430     2  0.0188     0.9103 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
#> GSM559383     3  0.1571     0.7932 0.000 0.000 0.936 0.060 0.004
#> GSM559387     3  0.1282     0.7911 0.000 0.000 0.952 0.004 0.044
#> GSM559391     3  0.3152     0.7530 0.000 0.000 0.840 0.136 0.024
#> GSM559395     3  0.1282     0.7915 0.000 0.000 0.952 0.004 0.044
#> GSM559397     3  0.2329     0.7073 0.000 0.000 0.876 0.000 0.124
#> GSM559401     5  0.4074     0.5844 0.000 0.000 0.364 0.000 0.636
#> GSM559414     3  0.1908     0.7491 0.000 0.000 0.908 0.000 0.092
#> GSM559422     5  0.3796     0.6613 0.000 0.000 0.300 0.000 0.700
#> GSM559424     3  0.2997     0.7498 0.000 0.000 0.840 0.148 0.012
#> GSM559431     2  0.1741     0.8024 0.000 0.936 0.000 0.024 0.040
#> GSM559432     5  0.3752     0.6629 0.000 0.000 0.292 0.000 0.708
#> GSM559381     1  0.2060     0.7921 0.924 0.008 0.000 0.052 0.016
#> GSM559382     2  0.3003     0.7822 0.000 0.864 0.000 0.044 0.092
#> GSM559384     1  0.5055     0.6769 0.760 0.004 0.068 0.048 0.120
#> GSM559385     1  0.0324     0.7970 0.992 0.000 0.000 0.004 0.004
#> GSM559386     2  0.7233     0.0753 0.384 0.424 0.000 0.136 0.056
#> GSM559388     2  0.4562     0.7337 0.004 0.760 0.000 0.108 0.128
#> GSM559389     1  0.0671     0.7966 0.980 0.004 0.000 0.000 0.016
#> GSM559390     4  0.3947     0.6880 0.036 0.028 0.068 0.844 0.024
#> GSM559392     2  0.3651     0.7721 0.004 0.828 0.000 0.060 0.108
#> GSM559393     1  0.4937     0.6337 0.740 0.060 0.000 0.028 0.172
#> GSM559394     1  0.2612     0.7479 0.868 0.000 0.000 0.008 0.124
#> GSM559396     3  0.5912     0.6020 0.004 0.076 0.700 0.096 0.124
#> GSM559398     2  0.4025     0.7545 0.000 0.792 0.000 0.076 0.132
#> GSM559399     1  0.2554     0.7831 0.896 0.008 0.000 0.076 0.020
#> GSM559400     5  0.6649     0.1903 0.000 0.216 0.004 0.308 0.472
#> GSM559402     1  0.3787     0.7359 0.824 0.008 0.000 0.104 0.064
#> GSM559403     1  0.0162     0.7975 0.996 0.000 0.000 0.000 0.004
#> GSM559404     1  0.1478     0.7820 0.936 0.000 0.000 0.064 0.000
#> GSM559405     1  0.0671     0.7973 0.980 0.000 0.000 0.016 0.004
#> GSM559406     4  0.4668     0.7520 0.168 0.000 0.076 0.748 0.008
#> GSM559407     1  0.5111    -0.2755 0.500 0.000 0.000 0.464 0.036
#> GSM559408     4  0.4152     0.6783 0.296 0.000 0.000 0.692 0.012
#> GSM559409     4  0.4641     0.3795 0.456 0.000 0.000 0.532 0.012
#> GSM559410     1  0.2488     0.7395 0.872 0.000 0.000 0.124 0.004
#> GSM559411     4  0.5974     0.6815 0.108 0.000 0.176 0.668 0.048
#> GSM559412     4  0.4403     0.6707 0.316 0.000 0.004 0.668 0.012
#> GSM559413     4  0.4839     0.6789 0.304 0.000 0.012 0.660 0.024
#> GSM559415     1  0.4204     0.7324 0.808 0.028 0.000 0.104 0.060
#> GSM559416     4  0.2735     0.6522 0.004 0.036 0.056 0.896 0.008
#> GSM559417     4  0.2894     0.6006 0.004 0.084 0.000 0.876 0.036
#> GSM559418     2  0.6571     0.3517 0.348 0.524 0.000 0.068 0.060
#> GSM559419     4  0.5127     0.7435 0.132 0.000 0.096 0.740 0.032
#> GSM559420     1  0.8029     0.2187 0.448 0.004 0.248 0.176 0.124
#> GSM559421     2  0.1915     0.8060 0.000 0.928 0.000 0.032 0.040
#> GSM559423     2  0.3008     0.7726 0.004 0.868 0.000 0.036 0.092
#> GSM559425     2  0.1386     0.8060 0.000 0.952 0.000 0.032 0.016
#> GSM559426     2  0.3030     0.7699 0.004 0.868 0.000 0.040 0.088
#> GSM559427     2  0.3159     0.7842 0.000 0.856 0.000 0.056 0.088
#> GSM559428     2  0.2927     0.7701 0.000 0.868 0.000 0.040 0.092
#> GSM559429     2  0.3161     0.7661 0.004 0.860 0.000 0.044 0.092
#> GSM559430     2  0.1117     0.8056 0.000 0.964 0.000 0.016 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
#> GSM559383     3  0.1010     0.8801 0.000 0.000 0.960 0.000 0.036 0.004
#> GSM559387     3  0.1910     0.8738 0.000 0.000 0.892 0.000 0.108 0.000
#> GSM559391     3  0.1053     0.8511 0.000 0.000 0.964 0.004 0.020 0.012
#> GSM559395     3  0.1714     0.8789 0.000 0.000 0.908 0.000 0.092 0.000
#> GSM559397     3  0.2838     0.8140 0.000 0.000 0.808 0.000 0.188 0.004
#> GSM559401     5  0.2003     0.9500 0.000 0.000 0.116 0.000 0.884 0.000
#> GSM559414     3  0.2882     0.8193 0.000 0.000 0.812 0.000 0.180 0.008
#> GSM559422     5  0.1444     0.9648 0.000 0.000 0.072 0.000 0.928 0.000
#> GSM559424     3  0.0881     0.8682 0.000 0.000 0.972 0.008 0.012 0.008
#> GSM559431     6  0.3975     0.4363 0.000 0.452 0.000 0.004 0.000 0.544
#> GSM559432     5  0.1753     0.9699 0.000 0.000 0.084 0.000 0.912 0.004
#> GSM559381     1  0.4903     0.6717 0.740 0.036 0.004 0.072 0.012 0.136
#> GSM559382     2  0.5766     0.0416 0.040 0.584 0.000 0.064 0.012 0.300
#> GSM559384     1  0.5888     0.6085 0.636 0.004 0.100 0.044 0.012 0.204
#> GSM559385     1  0.1452     0.7283 0.948 0.020 0.000 0.012 0.000 0.020
#> GSM559386     1  0.7840     0.1044 0.340 0.212 0.000 0.176 0.012 0.260
#> GSM559388     2  0.1691     0.4677 0.028 0.940 0.000 0.012 0.008 0.012
#> GSM559389     1  0.2159     0.7281 0.916 0.040 0.000 0.016 0.004 0.024
#> GSM559390     4  0.3172     0.8163 0.008 0.104 0.008 0.852 0.016 0.012
#> GSM559392     2  0.2051     0.4600 0.004 0.896 0.000 0.000 0.004 0.096
#> GSM559393     1  0.4224     0.5688 0.700 0.256 0.000 0.000 0.036 0.008
#> GSM559394     1  0.2374     0.7192 0.904 0.028 0.000 0.004 0.048 0.016
#> GSM559396     3  0.2730     0.7822 0.004 0.000 0.864 0.004 0.020 0.108
#> GSM559398     2  0.1555     0.4741 0.004 0.932 0.000 0.000 0.004 0.060
#> GSM559399     1  0.5023     0.6150 0.700 0.208 0.008 0.020 0.012 0.052
#> GSM559400     2  0.5843     0.1186 0.000 0.516 0.000 0.220 0.260 0.004
#> GSM559402     1  0.5880     0.4868 0.572 0.000 0.020 0.284 0.012 0.112
#> GSM559403     1  0.0603     0.7269 0.980 0.000 0.000 0.016 0.000 0.004
#> GSM559404     1  0.3997     0.6790 0.776 0.000 0.000 0.108 0.008 0.108
#> GSM559405     1  0.1700     0.7293 0.928 0.000 0.000 0.048 0.000 0.024
#> GSM559406     4  0.3080     0.8467 0.032 0.036 0.020 0.880 0.012 0.020
#> GSM559407     4  0.4893     0.6372 0.204 0.004 0.020 0.712 0.028 0.032
#> GSM559408     4  0.1059     0.8706 0.016 0.016 0.004 0.964 0.000 0.000
#> GSM559409     4  0.3948     0.6888 0.208 0.020 0.000 0.752 0.004 0.016
#> GSM559410     1  0.3277     0.6739 0.792 0.000 0.000 0.188 0.004 0.016
#> GSM559411     4  0.4057     0.8175 0.020 0.000 0.116 0.800 0.032 0.032
#> GSM559412     4  0.1168     0.8662 0.028 0.000 0.000 0.956 0.000 0.016
#> GSM559413     4  0.1793     0.8628 0.036 0.000 0.000 0.928 0.004 0.032
#> GSM559415     1  0.5941     0.6035 0.632 0.040 0.000 0.152 0.016 0.160
#> GSM559416     4  0.2843     0.8474 0.004 0.060 0.040 0.880 0.008 0.008
#> GSM559417     4  0.2151     0.8615 0.004 0.040 0.016 0.920 0.012 0.008
#> GSM559418     2  0.6295     0.0879 0.332 0.456 0.000 0.024 0.000 0.188
#> GSM559419     4  0.3198     0.8497 0.024 0.000 0.060 0.864 0.020 0.032
#> GSM559420     1  0.7827     0.2136 0.320 0.012 0.304 0.092 0.012 0.260
#> GSM559421     2  0.3756    -0.1195 0.000 0.600 0.000 0.000 0.000 0.400
#> GSM559423     6  0.3420     0.7188 0.012 0.240 0.000 0.000 0.000 0.748
#> GSM559425     2  0.3899    -0.1841 0.000 0.592 0.000 0.004 0.000 0.404
#> GSM559426     6  0.3133     0.7615 0.008 0.212 0.000 0.000 0.000 0.780
#> GSM559427     2  0.3052     0.3323 0.000 0.780 0.000 0.004 0.000 0.216
#> GSM559428     6  0.3250     0.7546 0.004 0.196 0.012 0.000 0.000 0.788
#> GSM559429     6  0.3121     0.7475 0.004 0.180 0.012 0.000 0.000 0.804
#> GSM559430     6  0.3866     0.3651 0.000 0.484 0.000 0.000 0.000 0.516

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 disease.state(p) k
#> MAD:NMF 52         2.84e-01 2
#> MAD:NMF 49         4.55e-09 3
#> MAD:NMF 36         7.39e-07 4
#> MAD:NMF 46         2.74e-07 5
#> MAD:NMF 38         9.49e-07 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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

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

collect_plots(res)

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 0.788           0.961       0.973         0.4173 0.566   0.566
#> 3 3 0.684           0.818       0.904         0.5718 0.759   0.573
#> 4 4 0.713           0.682       0.827         0.0640 0.989   0.965
#> 5 5 0.736           0.660       0.781         0.0917 0.891   0.671
#> 6 6 0.773           0.710       0.855         0.0338 0.958   0.826

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
#> GSM559383     2  0.0000      0.990 0.000 1.000
#> GSM559387     2  0.0000      0.990 0.000 1.000
#> GSM559391     2  0.0000      0.990 0.000 1.000
#> GSM559395     2  0.0000      0.990 0.000 1.000
#> GSM559397     1  0.0000      0.929 1.000 0.000
#> GSM559401     2  0.0000      0.990 0.000 1.000
#> GSM559414     2  0.0000      0.990 0.000 1.000
#> GSM559422     1  0.6973      0.843 0.812 0.188
#> GSM559424     2  0.0000      0.990 0.000 1.000
#> GSM559431     2  0.0938      0.989 0.012 0.988
#> GSM559432     2  0.0938      0.989 0.012 0.988
#> GSM559381     1  0.0000      0.929 1.000 0.000
#> GSM559382     1  0.0000      0.929 1.000 0.000
#> GSM559384     1  0.0000      0.929 1.000 0.000
#> GSM559385     2  0.0376      0.990 0.004 0.996
#> GSM559386     1  0.0000      0.929 1.000 0.000
#> GSM559388     2  0.1184      0.989 0.016 0.984
#> GSM559389     1  0.0000      0.929 1.000 0.000
#> GSM559390     2  0.2778      0.955 0.048 0.952
#> GSM559392     2  0.1184      0.989 0.016 0.984
#> GSM559393     2  0.0376      0.990 0.004 0.996
#> GSM559394     2  0.0376      0.990 0.004 0.996
#> GSM559396     1  0.4690      0.906 0.900 0.100
#> GSM559398     2  0.0938      0.989 0.012 0.988
#> GSM559399     2  0.0672      0.990 0.008 0.992
#> GSM559400     2  0.1184      0.989 0.016 0.984
#> GSM559402     2  0.3114      0.942 0.056 0.944
#> GSM559403     2  0.0376      0.990 0.004 0.996
#> GSM559404     1  0.6973      0.847 0.812 0.188
#> GSM559405     1  0.0000      0.929 1.000 0.000
#> GSM559406     1  0.4690      0.906 0.900 0.100
#> GSM559407     2  0.0376      0.990 0.004 0.996
#> GSM559408     1  0.4690      0.906 0.900 0.100
#> GSM559409     2  0.0376      0.990 0.004 0.996
#> GSM559410     2  0.0000      0.990 0.000 1.000
#> GSM559411     2  0.0000      0.990 0.000 1.000
#> GSM559412     1  0.6973      0.847 0.812 0.188
#> GSM559413     1  0.6973      0.847 0.812 0.188
#> GSM559415     2  0.0672      0.990 0.008 0.992
#> GSM559416     2  0.0672      0.990 0.008 0.992
#> GSM559417     2  0.0672      0.990 0.008 0.992
#> GSM559418     2  0.0672      0.990 0.008 0.992
#> GSM559419     2  0.1843      0.976 0.028 0.972
#> GSM559420     1  0.0000      0.929 1.000 0.000
#> GSM559421     2  0.1184      0.989 0.016 0.984
#> GSM559423     2  0.1184      0.989 0.016 0.984
#> GSM559425     2  0.0938      0.989 0.012 0.988
#> GSM559426     2  0.0938      0.989 0.012 0.988
#> GSM559427     2  0.0938      0.989 0.012 0.988
#> GSM559428     1  0.0000      0.929 1.000 0.000
#> GSM559429     2  0.1184      0.989 0.016 0.984
#> GSM559430     2  0.0938      0.989 0.012 0.988

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM559383     3  0.0237      0.925 0.000 0.004 0.996
#> GSM559387     3  0.0000      0.923 0.000 0.000 1.000
#> GSM559391     3  0.0237      0.925 0.000 0.004 0.996
#> GSM559395     3  0.0000      0.923 0.000 0.000 1.000
#> GSM559397     1  0.0000      0.927 1.000 0.000 0.000
#> GSM559401     3  0.0000      0.923 0.000 0.000 1.000
#> GSM559414     3  0.0000      0.923 0.000 0.000 1.000
#> GSM559422     1  0.4399      0.838 0.812 0.000 0.188
#> GSM559424     3  0.1529      0.900 0.000 0.040 0.960
#> GSM559431     2  0.0000      0.814 0.000 1.000 0.000
#> GSM559432     2  0.1964      0.812 0.000 0.944 0.056
#> GSM559381     1  0.0000      0.927 1.000 0.000 0.000
#> GSM559382     1  0.0000      0.927 1.000 0.000 0.000
#> GSM559384     1  0.0000      0.927 1.000 0.000 0.000
#> GSM559385     3  0.0661      0.923 0.004 0.008 0.988
#> GSM559386     1  0.0000      0.927 1.000 0.000 0.000
#> GSM559388     2  0.1267      0.820 0.004 0.972 0.024
#> GSM559389     1  0.0000      0.927 1.000 0.000 0.000
#> GSM559390     2  0.7442      0.535 0.044 0.588 0.368
#> GSM559392     2  0.1765      0.822 0.004 0.956 0.040
#> GSM559393     3  0.6033      0.354 0.004 0.336 0.660
#> GSM559394     3  0.6008      0.367 0.004 0.332 0.664
#> GSM559396     1  0.2959      0.903 0.900 0.000 0.100
#> GSM559398     2  0.0000      0.814 0.000 1.000 0.000
#> GSM559399     2  0.6247      0.569 0.004 0.620 0.376
#> GSM559400     2  0.2301      0.818 0.004 0.936 0.060
#> GSM559402     3  0.4458      0.818 0.056 0.080 0.864
#> GSM559403     3  0.0661      0.923 0.004 0.008 0.988
#> GSM559404     1  0.4399      0.839 0.812 0.000 0.188
#> GSM559405     1  0.0000      0.927 1.000 0.000 0.000
#> GSM559406     1  0.2959      0.903 0.900 0.000 0.100
#> GSM559407     3  0.0661      0.923 0.004 0.008 0.988
#> GSM559408     1  0.2959      0.903 0.900 0.000 0.100
#> GSM559409     3  0.0829      0.921 0.004 0.012 0.984
#> GSM559410     3  0.0000      0.923 0.000 0.000 1.000
#> GSM559411     3  0.0237      0.925 0.000 0.004 0.996
#> GSM559412     1  0.4399      0.839 0.812 0.000 0.188
#> GSM559413     1  0.4399      0.839 0.812 0.000 0.188
#> GSM559415     2  0.6247      0.569 0.004 0.620 0.376
#> GSM559416     2  0.6209      0.582 0.004 0.628 0.368
#> GSM559417     2  0.6081      0.612 0.004 0.652 0.344
#> GSM559418     2  0.6209      0.582 0.004 0.628 0.368
#> GSM559419     2  0.6899      0.569 0.024 0.612 0.364
#> GSM559420     1  0.0000      0.927 1.000 0.000 0.000
#> GSM559421     2  0.1765      0.822 0.004 0.956 0.040
#> GSM559423     2  0.1765      0.822 0.004 0.956 0.040
#> GSM559425     2  0.0000      0.814 0.000 1.000 0.000
#> GSM559426     2  0.0000      0.814 0.000 1.000 0.000
#> GSM559427     2  0.0000      0.814 0.000 1.000 0.000
#> GSM559428     1  0.0000      0.927 1.000 0.000 0.000
#> GSM559429     2  0.3112      0.803 0.004 0.900 0.096
#> GSM559430     2  0.0000      0.814 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
#> GSM559383     3  0.0895      0.872 0.020 0.004 0.976 0.000
#> GSM559387     3  0.2149      0.843 0.000 0.000 0.912 0.088
#> GSM559391     3  0.0188      0.876 0.000 0.004 0.996 0.000
#> GSM559395     3  0.2149      0.843 0.000 0.000 0.912 0.088
#> GSM559397     1  0.3942      0.576 0.764 0.000 0.000 0.236
#> GSM559401     3  0.2149      0.843 0.000 0.000 0.912 0.088
#> GSM559414     3  0.2149      0.843 0.000 0.000 0.912 0.088
#> GSM559422     1  0.2334      0.568 0.908 0.004 0.088 0.000
#> GSM559424     3  0.1302      0.861 0.000 0.044 0.956 0.000
#> GSM559431     2  0.1474      0.789 0.000 0.948 0.000 0.052
#> GSM559432     2  0.3009      0.792 0.000 0.892 0.056 0.052
#> GSM559381     1  0.4843      0.528 0.604 0.000 0.000 0.396
#> GSM559382     1  0.4843      0.528 0.604 0.000 0.000 0.396
#> GSM559384     1  0.4431      0.566 0.696 0.000 0.000 0.304
#> GSM559385     3  0.0524      0.877 0.004 0.008 0.988 0.000
#> GSM559386     1  0.4843      0.528 0.604 0.000 0.000 0.396
#> GSM559388     2  0.2383      0.799 0.004 0.924 0.024 0.048
#> GSM559389     1  0.4843      0.528 0.604 0.000 0.000 0.396
#> GSM559390     2  0.6022      0.562 0.048 0.612 0.336 0.004
#> GSM559392     2  0.0844      0.801 0.004 0.980 0.012 0.004
#> GSM559393     3  0.5064      0.304 0.004 0.360 0.632 0.004
#> GSM559394     3  0.5030      0.321 0.004 0.352 0.640 0.004
#> GSM559396     1  0.2401      0.607 0.904 0.004 0.000 0.092
#> GSM559398     2  0.1474      0.789 0.000 0.948 0.000 0.052
#> GSM559399     2  0.5013      0.590 0.004 0.644 0.348 0.004
#> GSM559400     2  0.1863      0.803 0.004 0.944 0.040 0.012
#> GSM559402     3  0.4535      0.758 0.080 0.104 0.812 0.004
#> GSM559403     3  0.0524      0.877 0.004 0.008 0.988 0.000
#> GSM559404     1  0.2216      0.569 0.908 0.000 0.092 0.000
#> GSM559405     1  0.4843      0.528 0.604 0.000 0.000 0.396
#> GSM559406     1  0.0188      0.604 0.996 0.004 0.000 0.000
#> GSM559407     3  0.0524      0.877 0.004 0.008 0.988 0.000
#> GSM559408     1  0.0188      0.604 0.996 0.004 0.000 0.000
#> GSM559409     3  0.1284      0.869 0.024 0.012 0.964 0.000
#> GSM559410     3  0.2149      0.843 0.000 0.000 0.912 0.088
#> GSM559411     3  0.0188      0.876 0.000 0.004 0.996 0.000
#> GSM559412     1  0.2216      0.569 0.908 0.000 0.092 0.000
#> GSM559413     1  0.2216      0.569 0.908 0.000 0.092 0.000
#> GSM559415     2  0.5030      0.585 0.004 0.640 0.352 0.004
#> GSM559416     2  0.4995      0.598 0.004 0.648 0.344 0.004
#> GSM559417     2  0.4854      0.629 0.004 0.676 0.316 0.004
#> GSM559418     2  0.4976      0.601 0.004 0.652 0.340 0.004
#> GSM559419     2  0.5525      0.590 0.024 0.636 0.336 0.004
#> GSM559420     1  0.4843      0.528 0.604 0.000 0.000 0.396
#> GSM559421     2  0.0844      0.801 0.004 0.980 0.012 0.004
#> GSM559423     2  0.0844      0.801 0.004 0.980 0.012 0.004
#> GSM559425     2  0.1474      0.789 0.000 0.948 0.000 0.052
#> GSM559426     2  0.1474      0.789 0.000 0.948 0.000 0.052
#> GSM559427     2  0.1474      0.789 0.000 0.948 0.000 0.052
#> GSM559428     4  0.2973      0.000 0.144 0.000 0.000 0.856
#> GSM559429     2  0.1978      0.794 0.004 0.928 0.068 0.000
#> GSM559430     2  0.1474      0.789 0.000 0.948 0.000 0.052

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM559383     3  0.4181     0.8235 0.000 0.000 0.712 0.268 0.020
#> GSM559387     3  0.0771     0.7409 0.000 0.004 0.976 0.020 0.000
#> GSM559391     3  0.3612     0.8293 0.000 0.000 0.732 0.268 0.000
#> GSM559395     3  0.0771     0.7409 0.000 0.004 0.976 0.020 0.000
#> GSM559397     1  0.2732     0.5790 0.840 0.000 0.000 0.000 0.160
#> GSM559401     3  0.0771     0.7409 0.000 0.004 0.976 0.020 0.000
#> GSM559414     3  0.0162     0.7214 0.000 0.004 0.996 0.000 0.000
#> GSM559422     1  0.5818     0.5750 0.460 0.000 0.000 0.092 0.448
#> GSM559424     3  0.3857     0.7929 0.000 0.000 0.688 0.312 0.000
#> GSM559431     2  0.0162     0.9826 0.000 0.996 0.000 0.004 0.000
#> GSM559432     2  0.1628     0.8982 0.000 0.936 0.008 0.056 0.000
#> GSM559381     1  0.0000     0.5414 1.000 0.000 0.000 0.000 0.000
#> GSM559382     1  0.0000     0.5414 1.000 0.000 0.000 0.000 0.000
#> GSM559384     1  0.2329     0.5830 0.876 0.000 0.000 0.000 0.124
#> GSM559385     3  0.3661     0.8278 0.000 0.000 0.724 0.276 0.000
#> GSM559386     1  0.0000     0.5414 1.000 0.000 0.000 0.000 0.000
#> GSM559388     4  0.4283     0.2632 0.000 0.456 0.000 0.544 0.000
#> GSM559389     1  0.0000     0.5414 1.000 0.000 0.000 0.000 0.000
#> GSM559390     4  0.2760     0.6828 0.028 0.000 0.064 0.892 0.016
#> GSM559392     4  0.3586     0.5706 0.000 0.264 0.000 0.736 0.000
#> GSM559393     4  0.4045     0.0605 0.000 0.000 0.356 0.644 0.000
#> GSM559394     4  0.4074     0.0330 0.000 0.000 0.364 0.636 0.000
#> GSM559396     1  0.4298     0.6138 0.640 0.000 0.000 0.008 0.352
#> GSM559398     2  0.0290     0.9790 0.000 0.992 0.000 0.008 0.000
#> GSM559399     4  0.1608     0.7000 0.000 0.000 0.072 0.928 0.000
#> GSM559400     4  0.3814     0.5693 0.000 0.276 0.004 0.720 0.000
#> GSM559402     3  0.5879     0.6009 0.028 0.000 0.540 0.384 0.048
#> GSM559403     3  0.3661     0.8278 0.000 0.000 0.724 0.276 0.000
#> GSM559404     1  0.5921     0.5730 0.456 0.000 0.004 0.088 0.452
#> GSM559405     1  0.0000     0.5414 1.000 0.000 0.000 0.000 0.000
#> GSM559406     1  0.4528     0.6091 0.548 0.000 0.000 0.008 0.444
#> GSM559407     3  0.3661     0.8278 0.000 0.000 0.724 0.276 0.000
#> GSM559408     1  0.4528     0.6091 0.548 0.000 0.000 0.008 0.444
#> GSM559409     3  0.4252     0.8165 0.000 0.000 0.700 0.280 0.020
#> GSM559410     3  0.0162     0.7214 0.000 0.004 0.996 0.000 0.000
#> GSM559411     3  0.3612     0.8293 0.000 0.000 0.732 0.268 0.000
#> GSM559412     1  0.5921     0.5730 0.456 0.000 0.004 0.088 0.452
#> GSM559413     1  0.5921     0.5730 0.456 0.000 0.004 0.088 0.452
#> GSM559415     4  0.1671     0.6972 0.000 0.000 0.076 0.924 0.000
#> GSM559416     4  0.1544     0.7028 0.000 0.000 0.068 0.932 0.000
#> GSM559417     4  0.1043     0.7081 0.000 0.000 0.040 0.960 0.000
#> GSM559418     4  0.1478     0.7042 0.000 0.000 0.064 0.936 0.000
#> GSM559419     4  0.2141     0.6986 0.016 0.000 0.064 0.916 0.004
#> GSM559420     1  0.0000     0.5414 1.000 0.000 0.000 0.000 0.000
#> GSM559421     4  0.3586     0.5706 0.000 0.264 0.000 0.736 0.000
#> GSM559423     4  0.3586     0.5706 0.000 0.264 0.000 0.736 0.000
#> GSM559425     2  0.0162     0.9826 0.000 0.996 0.000 0.004 0.000
#> GSM559426     2  0.0162     0.9826 0.000 0.996 0.000 0.004 0.000
#> GSM559427     2  0.0162     0.9826 0.000 0.996 0.000 0.004 0.000
#> GSM559428     5  0.4278     0.0000 0.452 0.000 0.000 0.000 0.548
#> GSM559429     4  0.4167     0.6066 0.000 0.252 0.024 0.724 0.000
#> GSM559430     2  0.0162     0.9826 0.000 0.996 0.000 0.004 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
#> GSM559383     3  0.3834     0.8214 0.268 0.000 0.708 0.024 0.000 0.000
#> GSM559387     3  0.0951     0.7173 0.020 0.000 0.968 0.008 0.004 0.000
#> GSM559391     3  0.3383     0.8266 0.268 0.000 0.728 0.004 0.000 0.000
#> GSM559395     3  0.0951     0.7173 0.020 0.000 0.968 0.008 0.004 0.000
#> GSM559397     6  0.3126     0.5634 0.000 0.000 0.000 0.248 0.000 0.752
#> GSM559401     3  0.0951     0.7173 0.020 0.000 0.968 0.008 0.004 0.000
#> GSM559414     3  0.0405     0.6957 0.000 0.000 0.988 0.008 0.004 0.000
#> GSM559422     4  0.0508     0.7118 0.004 0.000 0.000 0.984 0.000 0.012
#> GSM559424     3  0.3601     0.7902 0.312 0.000 0.684 0.004 0.000 0.000
#> GSM559431     2  0.0000     0.9813 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559432     2  0.1434     0.8896 0.048 0.940 0.012 0.000 0.000 0.000
#> GSM559381     6  0.0000     0.9289 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559382     6  0.0000     0.9289 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559384     6  0.2092     0.7911 0.000 0.000 0.000 0.124 0.000 0.876
#> GSM559385     3  0.3426     0.8251 0.276 0.000 0.720 0.004 0.000 0.000
#> GSM559386     6  0.0000     0.9289 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559388     1  0.3847     0.2715 0.544 0.456 0.000 0.000 0.000 0.000
#> GSM559389     6  0.0000     0.9289 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559390     1  0.2258     0.6873 0.896 0.000 0.060 0.044 0.000 0.000
#> GSM559392     1  0.3360     0.5754 0.732 0.264 0.000 0.000 0.004 0.000
#> GSM559393     1  0.3756     0.0600 0.644 0.000 0.352 0.004 0.000 0.000
#> GSM559394     1  0.3782     0.0326 0.636 0.000 0.360 0.004 0.000 0.000
#> GSM559396     4  0.4072     0.3694 0.008 0.000 0.000 0.544 0.000 0.448
#> GSM559398     2  0.0146     0.9773 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM559399     1  0.1387     0.7019 0.932 0.000 0.068 0.000 0.000 0.000
#> GSM559400     1  0.3288     0.5738 0.724 0.276 0.000 0.000 0.000 0.000
#> GSM559402     3  0.5044     0.6018 0.384 0.000 0.536 0.080 0.000 0.000
#> GSM559403     3  0.3426     0.8251 0.276 0.000 0.720 0.004 0.000 0.000
#> GSM559404     4  0.0260     0.7120 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM559405     6  0.0000     0.9289 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559406     4  0.3861     0.5609 0.008 0.000 0.000 0.640 0.000 0.352
#> GSM559407     3  0.3426     0.8251 0.276 0.000 0.720 0.004 0.000 0.000
#> GSM559408     4  0.3861     0.5609 0.008 0.000 0.000 0.640 0.000 0.352
#> GSM559409     3  0.3897     0.8144 0.280 0.000 0.696 0.024 0.000 0.000
#> GSM559410     3  0.0405     0.6957 0.000 0.000 0.988 0.008 0.004 0.000
#> GSM559411     3  0.3383     0.8266 0.268 0.000 0.728 0.004 0.000 0.000
#> GSM559412     4  0.0260     0.7120 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM559413     4  0.0260     0.7120 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM559415     1  0.1444     0.6991 0.928 0.000 0.072 0.000 0.000 0.000
#> GSM559416     1  0.1327     0.7046 0.936 0.000 0.064 0.000 0.000 0.000
#> GSM559417     1  0.0865     0.7098 0.964 0.000 0.036 0.000 0.000 0.000
#> GSM559418     1  0.1267     0.7061 0.940 0.000 0.060 0.000 0.000 0.000
#> GSM559419     1  0.1807     0.7016 0.920 0.000 0.060 0.020 0.000 0.000
#> GSM559420     6  0.0000     0.9289 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559421     1  0.3360     0.5754 0.732 0.264 0.000 0.000 0.004 0.000
#> GSM559423     1  0.3360     0.5754 0.732 0.264 0.000 0.000 0.004 0.000
#> GSM559425     2  0.0000     0.9813 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559426     2  0.0000     0.9813 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559427     2  0.0000     0.9813 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559428     5  0.0260     0.0000 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM559429     1  0.3665     0.6109 0.728 0.252 0.020 0.000 0.000 0.000
#> GSM559430     2  0.0000     0.9813 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-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 disease.state(p) k
#> ATC:hclust 52           0.5152 2
#> ATC:hclust 50           0.0116 3
#> ATC:hclust 49           0.0136 4
#> ATC:hclust 48           0.0163 5
#> ATC:hclust 47           0.0408 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 21167 rows and 52 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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 0.479           0.832       0.843         0.4186 0.566   0.566
#> 3 3 1.000           0.998       0.995         0.5689 0.775   0.601
#> 4 4 0.694           0.741       0.776         0.1151 0.889   0.680
#> 5 5 0.770           0.675       0.784         0.0658 0.804   0.413
#> 6 6 0.764           0.789       0.839         0.0379 0.941   0.751

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
#> GSM559383     2  0.0000      0.791 0.000 1.000
#> GSM559387     2  0.0000      0.791 0.000 1.000
#> GSM559391     2  0.0000      0.791 0.000 1.000
#> GSM559395     2  0.0376      0.791 0.004 0.996
#> GSM559397     1  0.9358      0.999 0.648 0.352
#> GSM559401     2  0.0000      0.791 0.000 1.000
#> GSM559414     2  0.0000      0.791 0.000 1.000
#> GSM559422     1  0.9358      0.999 0.648 0.352
#> GSM559424     2  0.0000      0.791 0.000 1.000
#> GSM559431     2  0.9427      0.705 0.360 0.640
#> GSM559432     2  0.9358      0.702 0.352 0.648
#> GSM559381     1  0.9358      0.999 0.648 0.352
#> GSM559382     1  0.9358      0.999 0.648 0.352
#> GSM559384     1  0.9358      0.999 0.648 0.352
#> GSM559385     2  0.0000      0.791 0.000 1.000
#> GSM559386     1  0.9358      0.999 0.648 0.352
#> GSM559388     2  0.9427      0.705 0.360 0.640
#> GSM559389     1  0.9358      0.999 0.648 0.352
#> GSM559390     2  0.0672      0.788 0.008 0.992
#> GSM559392     2  0.9427      0.705 0.360 0.640
#> GSM559393     2  0.0672      0.788 0.008 0.992
#> GSM559394     2  0.0000      0.791 0.000 1.000
#> GSM559396     1  0.9358      0.999 0.648 0.352
#> GSM559398     2  0.9427      0.705 0.360 0.640
#> GSM559399     2  0.0672      0.788 0.008 0.992
#> GSM559400     2  0.9427      0.705 0.360 0.640
#> GSM559402     2  0.0672      0.788 0.008 0.992
#> GSM559403     2  0.0000      0.791 0.000 1.000
#> GSM559404     1  0.9427      0.988 0.640 0.360
#> GSM559405     1  0.9358      0.999 0.648 0.352
#> GSM559406     1  0.9358      0.999 0.648 0.352
#> GSM559407     2  0.0000      0.791 0.000 1.000
#> GSM559408     1  0.9358      0.999 0.648 0.352
#> GSM559409     2  0.0000      0.791 0.000 1.000
#> GSM559410     2  0.0000      0.791 0.000 1.000
#> GSM559411     2  0.0000      0.791 0.000 1.000
#> GSM559412     1  0.9358      0.999 0.648 0.352
#> GSM559413     1  0.9358      0.999 0.648 0.352
#> GSM559415     2  0.0938      0.789 0.012 0.988
#> GSM559416     2  0.4939      0.765 0.108 0.892
#> GSM559417     2  0.0938      0.789 0.012 0.988
#> GSM559418     2  0.0672      0.788 0.008 0.992
#> GSM559419     2  0.0672      0.788 0.008 0.992
#> GSM559420     1  0.9358      0.999 0.648 0.352
#> GSM559421     2  0.9427      0.705 0.360 0.640
#> GSM559423     2  0.9358      0.706 0.352 0.648
#> GSM559425     2  0.9427      0.705 0.360 0.640
#> GSM559426     2  0.9427      0.705 0.360 0.640
#> GSM559427     2  0.9427      0.705 0.360 0.640
#> GSM559428     1  0.9358      0.999 0.648 0.352
#> GSM559429     2  0.9427      0.705 0.360 0.640
#> GSM559430     2  0.9427      0.705 0.360 0.640

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM559383     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559387     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559391     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559395     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559397     1  0.0000      0.999 1.000 0.000 0.000
#> GSM559401     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559414     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559422     1  0.0000      0.999 1.000 0.000 0.000
#> GSM559424     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559431     2  0.0747      0.997 0.000 0.984 0.016
#> GSM559432     2  0.0747      0.997 0.000 0.984 0.016
#> GSM559381     1  0.0000      0.999 1.000 0.000 0.000
#> GSM559382     1  0.0000      0.999 1.000 0.000 0.000
#> GSM559384     1  0.0000      0.999 1.000 0.000 0.000
#> GSM559385     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559386     1  0.0000      0.999 1.000 0.000 0.000
#> GSM559388     2  0.0747      0.997 0.000 0.984 0.016
#> GSM559389     1  0.0000      0.999 1.000 0.000 0.000
#> GSM559390     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559392     2  0.0747      0.997 0.000 0.984 0.016
#> GSM559393     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559394     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559396     1  0.0000      0.999 1.000 0.000 0.000
#> GSM559398     2  0.0747      0.997 0.000 0.984 0.016
#> GSM559399     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559400     2  0.0747      0.997 0.000 0.984 0.016
#> GSM559402     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559403     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559404     1  0.0000      0.999 1.000 0.000 0.000
#> GSM559405     1  0.0000      0.999 1.000 0.000 0.000
#> GSM559406     1  0.0000      0.999 1.000 0.000 0.000
#> GSM559407     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559408     1  0.0000      0.999 1.000 0.000 0.000
#> GSM559409     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559410     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559411     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559412     1  0.0000      0.999 1.000 0.000 0.000
#> GSM559413     1  0.0000      0.999 1.000 0.000 0.000
#> GSM559415     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559416     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559417     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559418     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559419     3  0.0000      1.000 0.000 0.000 1.000
#> GSM559420     1  0.0000      0.999 1.000 0.000 0.000
#> GSM559421     2  0.0747      0.997 0.000 0.984 0.016
#> GSM559423     2  0.0747      0.997 0.000 0.984 0.016
#> GSM559425     2  0.0747      0.997 0.000 0.984 0.016
#> GSM559426     2  0.0747      0.997 0.000 0.984 0.016
#> GSM559427     2  0.0747      0.997 0.000 0.984 0.016
#> GSM559428     1  0.0747      0.988 0.984 0.016 0.000
#> GSM559429     2  0.1860      0.959 0.000 0.948 0.052
#> GSM559430     2  0.0747      0.997 0.000 0.984 0.016

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM559383     3  0.4331      0.649 0.000 0.000 0.712 0.288
#> GSM559387     3  0.0000      0.755 0.000 0.000 1.000 0.000
#> GSM559391     3  0.0000      0.755 0.000 0.000 1.000 0.000
#> GSM559395     3  0.0000      0.755 0.000 0.000 1.000 0.000
#> GSM559397     1  0.3311      0.836 0.828 0.000 0.000 0.172
#> GSM559401     3  0.0000      0.755 0.000 0.000 1.000 0.000
#> GSM559414     3  0.0000      0.755 0.000 0.000 1.000 0.000
#> GSM559422     1  0.4898      0.774 0.584 0.000 0.000 0.416
#> GSM559424     3  0.4222      0.671 0.000 0.000 0.728 0.272
#> GSM559431     2  0.0188      0.830 0.000 0.996 0.000 0.004
#> GSM559432     2  0.0188      0.830 0.000 0.996 0.000 0.004
#> GSM559381     1  0.0000      0.828 1.000 0.000 0.000 0.000
#> GSM559382     1  0.0000      0.828 1.000 0.000 0.000 0.000
#> GSM559384     1  0.3610      0.834 0.800 0.000 0.000 0.200
#> GSM559385     3  0.4250      0.666 0.000 0.000 0.724 0.276
#> GSM559386     1  0.0000      0.828 1.000 0.000 0.000 0.000
#> GSM559388     2  0.3444      0.756 0.000 0.816 0.000 0.184
#> GSM559389     1  0.0000      0.828 1.000 0.000 0.000 0.000
#> GSM559390     4  0.4164      0.797 0.000 0.000 0.264 0.736
#> GSM559392     2  0.4790      0.590 0.000 0.620 0.000 0.380
#> GSM559393     4  0.4624      0.780 0.000 0.000 0.340 0.660
#> GSM559394     3  0.4222      0.671 0.000 0.000 0.728 0.272
#> GSM559396     1  0.4585      0.813 0.668 0.000 0.000 0.332
#> GSM559398     2  0.0000      0.830 0.000 1.000 0.000 0.000
#> GSM559399     4  0.4730      0.753 0.000 0.000 0.364 0.636
#> GSM559400     2  0.4941      0.496 0.000 0.564 0.000 0.436
#> GSM559402     4  0.4250      0.789 0.000 0.000 0.276 0.724
#> GSM559403     3  0.4250      0.666 0.000 0.000 0.724 0.276
#> GSM559404     1  0.4697      0.811 0.644 0.000 0.000 0.356
#> GSM559405     1  0.0000      0.828 1.000 0.000 0.000 0.000
#> GSM559406     1  0.4898      0.774 0.584 0.000 0.000 0.416
#> GSM559407     3  0.4222      0.671 0.000 0.000 0.728 0.272
#> GSM559408     1  0.4916      0.767 0.576 0.000 0.000 0.424
#> GSM559409     3  0.4331      0.646 0.000 0.000 0.712 0.288
#> GSM559410     3  0.0000      0.755 0.000 0.000 1.000 0.000
#> GSM559411     3  0.0000      0.755 0.000 0.000 1.000 0.000
#> GSM559412     1  0.4697      0.811 0.644 0.000 0.000 0.356
#> GSM559413     1  0.4697      0.811 0.644 0.000 0.000 0.356
#> GSM559415     4  0.4761      0.743 0.000 0.000 0.372 0.628
#> GSM559416     4  0.4761      0.743 0.000 0.000 0.372 0.628
#> GSM559417     4  0.4222      0.807 0.000 0.000 0.272 0.728
#> GSM559418     4  0.4331      0.809 0.000 0.000 0.288 0.712
#> GSM559419     4  0.4277      0.809 0.000 0.000 0.280 0.720
#> GSM559420     1  0.0000      0.828 1.000 0.000 0.000 0.000
#> GSM559421     2  0.4356      0.681 0.000 0.708 0.000 0.292
#> GSM559423     2  0.4961      0.477 0.000 0.552 0.000 0.448
#> GSM559425     2  0.0000      0.830 0.000 1.000 0.000 0.000
#> GSM559426     2  0.0188      0.830 0.000 0.996 0.000 0.004
#> GSM559427     2  0.0000      0.830 0.000 1.000 0.000 0.000
#> GSM559428     1  0.1302      0.806 0.956 0.000 0.000 0.044
#> GSM559429     4  0.5112     -0.255 0.000 0.436 0.004 0.560
#> GSM559430     2  0.0188      0.830 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
#> GSM559383     1  0.5348     0.1736 0.492 0.000 0.456 0.052 0.000
#> GSM559387     3  0.1357     0.9873 0.048 0.000 0.948 0.000 0.004
#> GSM559391     3  0.1544     0.9727 0.068 0.000 0.932 0.000 0.000
#> GSM559395     3  0.1357     0.9873 0.048 0.000 0.948 0.000 0.004
#> GSM559397     4  0.3333     0.4681 0.000 0.000 0.004 0.788 0.208
#> GSM559401     3  0.1357     0.9873 0.048 0.000 0.948 0.000 0.004
#> GSM559414     3  0.1357     0.9873 0.048 0.000 0.948 0.000 0.004
#> GSM559422     4  0.1124     0.8759 0.036 0.000 0.004 0.960 0.000
#> GSM559424     1  0.4278     0.2448 0.548 0.000 0.452 0.000 0.000
#> GSM559431     2  0.0404     0.8401 0.000 0.988 0.012 0.000 0.000
#> GSM559432     2  0.0703     0.8365 0.000 0.976 0.024 0.000 0.000
#> GSM559381     5  0.4192     0.9536 0.000 0.000 0.000 0.404 0.596
#> GSM559382     5  0.4126     0.9435 0.000 0.000 0.000 0.380 0.620
#> GSM559384     4  0.2230     0.7478 0.000 0.000 0.000 0.884 0.116
#> GSM559385     1  0.4890     0.2267 0.524 0.000 0.452 0.024 0.000
#> GSM559386     5  0.4138     0.9457 0.000 0.000 0.000 0.384 0.616
#> GSM559388     2  0.6127     0.5723 0.220 0.584 0.004 0.000 0.192
#> GSM559389     5  0.4192     0.9536 0.000 0.000 0.000 0.404 0.596
#> GSM559390     1  0.0794     0.6495 0.972 0.000 0.000 0.028 0.000
#> GSM559392     1  0.6896    -0.1870 0.436 0.252 0.000 0.008 0.304
#> GSM559393     1  0.0451     0.6519 0.988 0.000 0.008 0.004 0.000
#> GSM559394     1  0.4262     0.2631 0.560 0.000 0.440 0.000 0.000
#> GSM559396     4  0.2450     0.8242 0.028 0.000 0.000 0.896 0.076
#> GSM559398     2  0.3662     0.7463 0.004 0.744 0.000 0.000 0.252
#> GSM559399     1  0.0566     0.6514 0.984 0.000 0.012 0.004 0.000
#> GSM559400     1  0.6408     0.0704 0.544 0.180 0.000 0.008 0.268
#> GSM559402     1  0.3969     0.4595 0.692 0.000 0.004 0.304 0.000
#> GSM559403     1  0.4890     0.2267 0.524 0.000 0.452 0.024 0.000
#> GSM559404     4  0.0854     0.8842 0.012 0.000 0.004 0.976 0.008
#> GSM559405     5  0.4192     0.9536 0.000 0.000 0.000 0.404 0.596
#> GSM559406     4  0.0963     0.8765 0.036 0.000 0.000 0.964 0.000
#> GSM559407     1  0.4890     0.2267 0.524 0.000 0.452 0.024 0.000
#> GSM559408     4  0.0963     0.8765 0.036 0.000 0.000 0.964 0.000
#> GSM559409     1  0.5161     0.2223 0.516 0.000 0.444 0.040 0.000
#> GSM559410     3  0.1981     0.9783 0.048 0.000 0.924 0.000 0.028
#> GSM559411     3  0.1764     0.9752 0.064 0.000 0.928 0.000 0.008
#> GSM559412     4  0.0854     0.8842 0.012 0.000 0.004 0.976 0.008
#> GSM559413     4  0.0854     0.8842 0.012 0.000 0.004 0.976 0.008
#> GSM559415     1  0.0609     0.6494 0.980 0.000 0.020 0.000 0.000
#> GSM559416     1  0.0771     0.6500 0.976 0.000 0.020 0.000 0.004
#> GSM559417     1  0.0771     0.6515 0.976 0.000 0.000 0.020 0.004
#> GSM559418     1  0.0771     0.6515 0.976 0.000 0.000 0.020 0.004
#> GSM559419     1  0.0771     0.6515 0.976 0.000 0.000 0.020 0.004
#> GSM559420     5  0.4192     0.9536 0.000 0.000 0.000 0.404 0.596
#> GSM559421     2  0.6791     0.2734 0.356 0.360 0.000 0.000 0.284
#> GSM559423     1  0.6462     0.0492 0.528 0.176 0.000 0.008 0.288
#> GSM559425     2  0.0865     0.8389 0.004 0.972 0.000 0.000 0.024
#> GSM559426     2  0.0510     0.8400 0.000 0.984 0.016 0.000 0.000
#> GSM559427     2  0.0865     0.8389 0.004 0.972 0.000 0.000 0.024
#> GSM559428     5  0.4773     0.8231 0.008 0.000 0.024 0.312 0.656
#> GSM559429     1  0.3488     0.5523 0.860 0.072 0.016 0.008 0.044
#> GSM559430     2  0.0404     0.8401 0.000 0.988 0.012 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
#> GSM559383     1  0.5238      0.578 0.588 0.020 0.324 0.068 0.000 0.000
#> GSM559387     3  0.0146      0.971 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM559391     3  0.1562      0.942 0.032 0.004 0.940 0.024 0.000 0.000
#> GSM559395     3  0.0146      0.971 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM559397     4  0.4958      0.659 0.000 0.076 0.000 0.560 0.000 0.364
#> GSM559401     3  0.0436      0.971 0.004 0.004 0.988 0.004 0.000 0.000
#> GSM559414     3  0.0436      0.971 0.004 0.004 0.988 0.004 0.000 0.000
#> GSM559422     4  0.5153      0.848 0.028 0.116 0.000 0.676 0.000 0.180
#> GSM559424     1  0.4373      0.615 0.624 0.004 0.344 0.028 0.000 0.000
#> GSM559431     5  0.0000      0.923 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM559432     5  0.1138      0.909 0.000 0.012 0.004 0.024 0.960 0.000
#> GSM559381     6  0.0363      0.951 0.000 0.000 0.000 0.012 0.000 0.988
#> GSM559382     6  0.0260      0.949 0.000 0.008 0.000 0.000 0.000 0.992
#> GSM559384     4  0.3592      0.769 0.000 0.000 0.000 0.656 0.000 0.344
#> GSM559385     1  0.4479      0.619 0.624 0.004 0.336 0.036 0.000 0.000
#> GSM559386     6  0.0260      0.949 0.000 0.008 0.000 0.000 0.000 0.992
#> GSM559388     2  0.6305      0.438 0.180 0.408 0.004 0.016 0.392 0.000
#> GSM559389     6  0.0363      0.951 0.000 0.000 0.000 0.012 0.000 0.988
#> GSM559390     1  0.1245      0.726 0.952 0.032 0.000 0.016 0.000 0.000
#> GSM559392     2  0.4382      0.767 0.200 0.716 0.000 0.000 0.080 0.004
#> GSM559393     1  0.0000      0.732 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559394     1  0.4093      0.659 0.680 0.004 0.292 0.024 0.000 0.000
#> GSM559396     4  0.4767      0.797 0.020 0.036 0.000 0.628 0.000 0.316
#> GSM559398     2  0.4508      0.243 0.000 0.568 0.000 0.036 0.396 0.000
#> GSM559399     1  0.0603      0.735 0.980 0.004 0.016 0.000 0.000 0.000
#> GSM559400     2  0.4601      0.729 0.312 0.628 0.000 0.000 0.060 0.000
#> GSM559402     1  0.3248      0.662 0.804 0.032 0.000 0.164 0.000 0.000
#> GSM559403     1  0.4479      0.619 0.624 0.004 0.336 0.036 0.000 0.000
#> GSM559404     4  0.3198      0.880 0.008 0.008 0.000 0.796 0.000 0.188
#> GSM559405     6  0.0713      0.939 0.000 0.000 0.000 0.028 0.000 0.972
#> GSM559406     4  0.4130      0.870 0.028 0.036 0.000 0.756 0.000 0.180
#> GSM559407     1  0.4479      0.619 0.624 0.004 0.336 0.036 0.000 0.000
#> GSM559408     4  0.4130      0.870 0.028 0.036 0.000 0.756 0.000 0.180
#> GSM559409     1  0.4809      0.635 0.640 0.020 0.296 0.044 0.000 0.000
#> GSM559410     3  0.1565      0.950 0.004 0.028 0.940 0.028 0.000 0.000
#> GSM559411     3  0.1485      0.949 0.024 0.004 0.944 0.028 0.000 0.000
#> GSM559412     4  0.3198      0.880 0.008 0.008 0.000 0.796 0.000 0.188
#> GSM559413     4  0.3198      0.880 0.008 0.008 0.000 0.796 0.000 0.188
#> GSM559415     1  0.0603      0.735 0.980 0.004 0.016 0.000 0.000 0.000
#> GSM559416     1  0.0820      0.729 0.972 0.016 0.012 0.000 0.000 0.000
#> GSM559417     1  0.0777      0.720 0.972 0.024 0.000 0.004 0.000 0.000
#> GSM559418     1  0.0458      0.726 0.984 0.016 0.000 0.000 0.000 0.000
#> GSM559419     1  0.0508      0.728 0.984 0.012 0.000 0.004 0.000 0.000
#> GSM559420     6  0.0260      0.951 0.000 0.000 0.000 0.008 0.000 0.992
#> GSM559421     2  0.4402      0.760 0.184 0.712 0.000 0.000 0.104 0.000
#> GSM559423     2  0.4465      0.753 0.260 0.684 0.000 0.004 0.048 0.004
#> GSM559425     5  0.2706      0.856 0.000 0.104 0.000 0.036 0.860 0.000
#> GSM559426     5  0.0725      0.917 0.000 0.012 0.000 0.012 0.976 0.000
#> GSM559427     5  0.2706      0.856 0.000 0.104 0.000 0.036 0.860 0.000
#> GSM559428     6  0.3449      0.778 0.000 0.116 0.000 0.076 0.000 0.808
#> GSM559429     1  0.3693      0.493 0.800 0.148 0.004 0.020 0.028 0.000
#> GSM559430     5  0.0000      0.923 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-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 disease.state(p) k
#> ATC:kmeans 52          0.51516 2
#> ATC:kmeans 52          0.33864 3
#> ATC:kmeans 49          0.02175 4
#> ATC:kmeans 39          0.00349 5
#> ATC:kmeans 49          0.01469 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 21167 rows and 52 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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           0.969       0.987         0.5002 0.497   0.497
#> 3 3 1.000           0.993       0.996         0.3567 0.738   0.515
#> 4 4 0.898           0.901       0.926         0.0867 0.926   0.776
#> 5 5 0.857           0.894       0.909         0.0712 0.942   0.781
#> 6 6 0.846           0.798       0.853         0.0391 0.973   0.869

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
#> GSM559383     1   0.000      0.971 1.000 0.000
#> GSM559387     2   0.000      0.999 0.000 1.000
#> GSM559391     2   0.000      0.999 0.000 1.000
#> GSM559395     2   0.000      0.999 0.000 1.000
#> GSM559397     1   0.000      0.971 1.000 0.000
#> GSM559401     2   0.000      0.999 0.000 1.000
#> GSM559414     2   0.184      0.970 0.028 0.972
#> GSM559422     1   0.000      0.971 1.000 0.000
#> GSM559424     2   0.000      0.999 0.000 1.000
#> GSM559431     2   0.000      0.999 0.000 1.000
#> GSM559432     2   0.000      0.999 0.000 1.000
#> GSM559381     1   0.000      0.971 1.000 0.000
#> GSM559382     1   0.000      0.971 1.000 0.000
#> GSM559384     1   0.000      0.971 1.000 0.000
#> GSM559385     2   0.000      0.999 0.000 1.000
#> GSM559386     1   0.000      0.971 1.000 0.000
#> GSM559388     2   0.000      0.999 0.000 1.000
#> GSM559389     1   0.000      0.971 1.000 0.000
#> GSM559390     1   0.000      0.971 1.000 0.000
#> GSM559392     1   0.981      0.298 0.580 0.420
#> GSM559393     2   0.000      0.999 0.000 1.000
#> GSM559394     2   0.000      0.999 0.000 1.000
#> GSM559396     1   0.000      0.971 1.000 0.000
#> GSM559398     2   0.000      0.999 0.000 1.000
#> GSM559399     2   0.000      0.999 0.000 1.000
#> GSM559400     2   0.000      0.999 0.000 1.000
#> GSM559402     1   0.000      0.971 1.000 0.000
#> GSM559403     2   0.000      0.999 0.000 1.000
#> GSM559404     1   0.000      0.971 1.000 0.000
#> GSM559405     1   0.000      0.971 1.000 0.000
#> GSM559406     1   0.000      0.971 1.000 0.000
#> GSM559407     2   0.000      0.999 0.000 1.000
#> GSM559408     1   0.000      0.971 1.000 0.000
#> GSM559409     1   0.184      0.948 0.972 0.028
#> GSM559410     2   0.000      0.999 0.000 1.000
#> GSM559411     2   0.000      0.999 0.000 1.000
#> GSM559412     1   0.000      0.971 1.000 0.000
#> GSM559413     1   0.000      0.971 1.000 0.000
#> GSM559415     2   0.000      0.999 0.000 1.000
#> GSM559416     2   0.000      0.999 0.000 1.000
#> GSM559417     2   0.000      0.999 0.000 1.000
#> GSM559418     2   0.000      0.999 0.000 1.000
#> GSM559419     1   0.671      0.783 0.824 0.176
#> GSM559420     1   0.000      0.971 1.000 0.000
#> GSM559421     2   0.000      0.999 0.000 1.000
#> GSM559423     1   0.000      0.971 1.000 0.000
#> GSM559425     2   0.000      0.999 0.000 1.000
#> GSM559426     2   0.000      0.999 0.000 1.000
#> GSM559427     2   0.000      0.999 0.000 1.000
#> GSM559428     1   0.000      0.971 1.000 0.000
#> GSM559429     2   0.000      0.999 0.000 1.000
#> GSM559430     2   0.000      0.999 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
#> GSM559383     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559387     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559391     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559395     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559397     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559401     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559414     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559422     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559424     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559431     2  0.0000      1.000 0.000 1.000 0.000
#> GSM559432     2  0.0000      1.000 0.000 1.000 0.000
#> GSM559381     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559382     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559384     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559385     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559386     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559388     2  0.0000      1.000 0.000 1.000 0.000
#> GSM559389     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559390     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559392     2  0.0000      1.000 0.000 1.000 0.000
#> GSM559393     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559394     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559396     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559398     2  0.0000      1.000 0.000 1.000 0.000
#> GSM559399     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559400     2  0.0000      1.000 0.000 1.000 0.000
#> GSM559402     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559403     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559404     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559405     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559406     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559407     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559408     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559409     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559410     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559411     3  0.0000      0.999 0.000 0.000 1.000
#> GSM559412     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559413     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559415     3  0.0424      0.992 0.000 0.008 0.992
#> GSM559416     2  0.0000      1.000 0.000 1.000 0.000
#> GSM559417     2  0.0000      1.000 0.000 1.000 0.000
#> GSM559418     2  0.0000      1.000 0.000 1.000 0.000
#> GSM559419     1  0.5449      0.808 0.816 0.116 0.068
#> GSM559420     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559421     2  0.0000      1.000 0.000 1.000 0.000
#> GSM559423     2  0.0000      1.000 0.000 1.000 0.000
#> GSM559425     2  0.0000      1.000 0.000 1.000 0.000
#> GSM559426     2  0.0000      1.000 0.000 1.000 0.000
#> GSM559427     2  0.0000      1.000 0.000 1.000 0.000
#> GSM559428     1  0.0000      0.991 1.000 0.000 0.000
#> GSM559429     2  0.0000      1.000 0.000 1.000 0.000
#> GSM559430     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
#> GSM559383     3  0.1004      0.971 0.024 0.000 0.972 0.004
#> GSM559387     3  0.0188      0.992 0.000 0.000 0.996 0.004
#> GSM559391     3  0.0188      0.992 0.000 0.000 0.996 0.004
#> GSM559395     3  0.0188      0.992 0.000 0.000 0.996 0.004
#> GSM559397     1  0.3907      0.904 0.768 0.000 0.000 0.232
#> GSM559401     3  0.0188      0.992 0.000 0.000 0.996 0.004
#> GSM559414     3  0.0188      0.992 0.000 0.000 0.996 0.004
#> GSM559422     1  0.3873      0.904 0.772 0.000 0.000 0.228
#> GSM559424     3  0.0336      0.990 0.000 0.000 0.992 0.008
#> GSM559431     2  0.1118      0.956 0.000 0.964 0.000 0.036
#> GSM559432     2  0.1211      0.954 0.000 0.960 0.000 0.040
#> GSM559381     1  0.3942      0.904 0.764 0.000 0.000 0.236
#> GSM559382     1  0.3942      0.904 0.764 0.000 0.000 0.236
#> GSM559384     1  0.3907      0.904 0.768 0.000 0.000 0.232
#> GSM559385     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM559386     1  0.3942      0.904 0.764 0.000 0.000 0.236
#> GSM559388     2  0.1211      0.954 0.000 0.960 0.000 0.040
#> GSM559389     1  0.3942      0.904 0.764 0.000 0.000 0.236
#> GSM559390     1  0.0188      0.846 0.996 0.000 0.000 0.004
#> GSM559392     2  0.1118      0.950 0.000 0.964 0.000 0.036
#> GSM559393     3  0.0817      0.972 0.000 0.000 0.976 0.024
#> GSM559394     3  0.0336      0.988 0.000 0.000 0.992 0.008
#> GSM559396     1  0.3942      0.904 0.764 0.000 0.000 0.236
#> GSM559398     2  0.1118      0.950 0.000 0.964 0.000 0.036
#> GSM559399     4  0.4500      0.545 0.000 0.000 0.316 0.684
#> GSM559400     2  0.1118      0.950 0.000 0.964 0.000 0.036
#> GSM559402     1  0.0188      0.843 0.996 0.000 0.004 0.000
#> GSM559403     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM559404     1  0.0000      0.846 1.000 0.000 0.000 0.000
#> GSM559405     1  0.3907      0.904 0.768 0.000 0.000 0.232
#> GSM559406     1  0.0000      0.846 1.000 0.000 0.000 0.000
#> GSM559407     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM559408     1  0.0000      0.846 1.000 0.000 0.000 0.000
#> GSM559409     3  0.0707      0.976 0.020 0.000 0.980 0.000
#> GSM559410     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM559411     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM559412     1  0.0000      0.846 1.000 0.000 0.000 0.000
#> GSM559413     1  0.0000      0.846 1.000 0.000 0.000 0.000
#> GSM559415     4  0.5021      0.652 0.000 0.036 0.240 0.724
#> GSM559416     4  0.4250      0.679 0.000 0.276 0.000 0.724
#> GSM559417     4  0.4522      0.616 0.000 0.320 0.000 0.680
#> GSM559418     4  0.4331      0.668 0.000 0.288 0.000 0.712
#> GSM559419     4  0.2922      0.624 0.104 0.008 0.004 0.884
#> GSM559420     1  0.3942      0.904 0.764 0.000 0.000 0.236
#> GSM559421     2  0.1118      0.950 0.000 0.964 0.000 0.036
#> GSM559423     2  0.1302      0.944 0.000 0.956 0.000 0.044
#> GSM559425     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> GSM559426     2  0.1211      0.954 0.000 0.960 0.000 0.040
#> GSM559427     2  0.0188      0.958 0.000 0.996 0.000 0.004
#> GSM559428     1  0.3942      0.904 0.764 0.000 0.000 0.236
#> GSM559429     2  0.1118      0.956 0.000 0.964 0.000 0.036
#> GSM559430     2  0.1118      0.956 0.000 0.964 0.000 0.036

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM559383     3  0.1341      0.919 0.000 0.000 0.944 0.000 0.056
#> GSM559387     3  0.0000      0.954 0.000 0.000 1.000 0.000 0.000
#> GSM559391     3  0.0000      0.954 0.000 0.000 1.000 0.000 0.000
#> GSM559395     3  0.0000      0.954 0.000 0.000 1.000 0.000 0.000
#> GSM559397     1  0.0880      0.960 0.968 0.000 0.000 0.000 0.032
#> GSM559401     3  0.0000      0.954 0.000 0.000 1.000 0.000 0.000
#> GSM559414     3  0.0000      0.954 0.000 0.000 1.000 0.000 0.000
#> GSM559422     1  0.1544      0.919 0.932 0.000 0.000 0.000 0.068
#> GSM559424     3  0.0000      0.954 0.000 0.000 1.000 0.000 0.000
#> GSM559431     2  0.3513      0.815 0.000 0.800 0.000 0.180 0.020
#> GSM559432     2  0.3513      0.815 0.000 0.800 0.000 0.180 0.020
#> GSM559381     1  0.0000      0.988 1.000 0.000 0.000 0.000 0.000
#> GSM559382     1  0.0000      0.988 1.000 0.000 0.000 0.000 0.000
#> GSM559384     1  0.0162      0.985 0.996 0.000 0.000 0.000 0.004
#> GSM559385     3  0.1965      0.951 0.000 0.000 0.924 0.024 0.052
#> GSM559386     1  0.0000      0.988 1.000 0.000 0.000 0.000 0.000
#> GSM559388     2  0.3419      0.815 0.000 0.804 0.000 0.180 0.016
#> GSM559389     1  0.0000      0.988 1.000 0.000 0.000 0.000 0.000
#> GSM559390     5  0.3003      0.959 0.188 0.000 0.000 0.000 0.812
#> GSM559392     2  0.2616      0.805 0.000 0.888 0.000 0.036 0.076
#> GSM559393     3  0.2795      0.925 0.000 0.000 0.880 0.064 0.056
#> GSM559394     3  0.2790      0.923 0.000 0.000 0.880 0.068 0.052
#> GSM559396     1  0.0000      0.988 1.000 0.000 0.000 0.000 0.000
#> GSM559398     2  0.2278      0.815 0.000 0.908 0.000 0.032 0.060
#> GSM559399     4  0.4141      0.588 0.000 0.000 0.236 0.736 0.028
#> GSM559400     2  0.2278      0.815 0.000 0.908 0.000 0.032 0.060
#> GSM559402     5  0.2329      0.932 0.124 0.000 0.000 0.000 0.876
#> GSM559403     3  0.1893      0.952 0.000 0.000 0.928 0.024 0.048
#> GSM559404     5  0.2813      0.984 0.168 0.000 0.000 0.000 0.832
#> GSM559405     1  0.0000      0.988 1.000 0.000 0.000 0.000 0.000
#> GSM559406     5  0.2813      0.984 0.168 0.000 0.000 0.000 0.832
#> GSM559407     3  0.1741      0.953 0.000 0.000 0.936 0.024 0.040
#> GSM559408     5  0.2813      0.984 0.168 0.000 0.000 0.000 0.832
#> GSM559409     3  0.2011      0.934 0.000 0.000 0.908 0.004 0.088
#> GSM559410     3  0.1661      0.954 0.000 0.000 0.940 0.024 0.036
#> GSM559411     3  0.1661      0.954 0.000 0.000 0.940 0.024 0.036
#> GSM559412     5  0.2813      0.984 0.168 0.000 0.000 0.000 0.832
#> GSM559413     5  0.2813      0.984 0.168 0.000 0.000 0.000 0.832
#> GSM559415     4  0.1682      0.780 0.000 0.032 0.012 0.944 0.012
#> GSM559416     4  0.1410      0.773 0.000 0.060 0.000 0.940 0.000
#> GSM559417     4  0.4420      0.602 0.000 0.280 0.000 0.692 0.028
#> GSM559418     4  0.2660      0.723 0.000 0.128 0.000 0.864 0.008
#> GSM559419     4  0.4469      0.682 0.120 0.020 0.000 0.784 0.076
#> GSM559420     1  0.0000      0.988 1.000 0.000 0.000 0.000 0.000
#> GSM559421     2  0.2491      0.810 0.000 0.896 0.000 0.036 0.068
#> GSM559423     2  0.3011      0.797 0.012 0.876 0.000 0.036 0.076
#> GSM559425     2  0.0000      0.832 0.000 1.000 0.000 0.000 0.000
#> GSM559426     2  0.3513      0.815 0.000 0.800 0.000 0.180 0.020
#> GSM559427     2  0.0162      0.832 0.000 0.996 0.000 0.000 0.004
#> GSM559428     1  0.0000      0.988 1.000 0.000 0.000 0.000 0.000
#> GSM559429     2  0.3513      0.815 0.000 0.800 0.000 0.180 0.020
#> GSM559430     2  0.3513      0.815 0.000 0.800 0.000 0.180 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
#> GSM559383     3  0.1686      0.828 0.000 0.000 0.924 0.064 0.012 0.000
#> GSM559387     3  0.0146      0.856 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM559391     3  0.0146      0.856 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM559395     3  0.0363      0.856 0.012 0.000 0.988 0.000 0.000 0.000
#> GSM559397     6  0.1116      0.950 0.008 0.000 0.000 0.028 0.004 0.960
#> GSM559401     3  0.0146      0.856 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM559414     3  0.0405      0.856 0.000 0.000 0.988 0.004 0.008 0.000
#> GSM559422     6  0.2957      0.815 0.008 0.000 0.000 0.140 0.016 0.836
#> GSM559424     3  0.1285      0.847 0.052 0.000 0.944 0.000 0.004 0.000
#> GSM559431     2  0.0000      0.770 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559432     2  0.0146      0.767 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM559381     6  0.0000      0.978 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559382     6  0.0000      0.978 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559384     6  0.0260      0.973 0.000 0.000 0.000 0.008 0.000 0.992
#> GSM559385     3  0.4493      0.806 0.084 0.000 0.736 0.020 0.160 0.000
#> GSM559386     6  0.0000      0.978 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559388     2  0.1219      0.736 0.004 0.948 0.000 0.000 0.048 0.000
#> GSM559389     6  0.0000      0.978 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559390     4  0.3420      0.859 0.040 0.000 0.000 0.840 0.060 0.060
#> GSM559392     5  0.3782      0.915 0.000 0.412 0.000 0.000 0.588 0.000
#> GSM559393     3  0.6009      0.601 0.192 0.000 0.536 0.020 0.252 0.000
#> GSM559394     3  0.5543      0.623 0.248 0.000 0.572 0.004 0.176 0.000
#> GSM559396     6  0.0000      0.978 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559398     5  0.3854      0.873 0.000 0.464 0.000 0.000 0.536 0.000
#> GSM559399     1  0.3644      0.620 0.792 0.000 0.120 0.000 0.088 0.000
#> GSM559400     2  0.3868     -0.808 0.000 0.508 0.000 0.000 0.492 0.000
#> GSM559402     4  0.0862      0.927 0.008 0.000 0.000 0.972 0.004 0.016
#> GSM559403     3  0.4091      0.826 0.064 0.000 0.772 0.020 0.144 0.000
#> GSM559404     4  0.1204      0.968 0.000 0.000 0.000 0.944 0.000 0.056
#> GSM559405     6  0.0000      0.978 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559406     4  0.1204      0.968 0.000 0.000 0.000 0.944 0.000 0.056
#> GSM559407     3  0.3935      0.833 0.064 0.000 0.788 0.020 0.128 0.000
#> GSM559408     4  0.1204      0.968 0.000 0.000 0.000 0.944 0.000 0.056
#> GSM559409     3  0.3784      0.810 0.008 0.000 0.792 0.124 0.076 0.000
#> GSM559410     3  0.2870      0.852 0.040 0.000 0.856 0.004 0.100 0.000
#> GSM559411     3  0.2963      0.853 0.036 0.000 0.856 0.012 0.096 0.000
#> GSM559412     4  0.1204      0.968 0.000 0.000 0.000 0.944 0.000 0.056
#> GSM559413     4  0.1204      0.968 0.000 0.000 0.000 0.944 0.000 0.056
#> GSM559415     1  0.2604      0.737 0.880 0.076 0.008 0.000 0.036 0.000
#> GSM559416     1  0.2762      0.724 0.804 0.196 0.000 0.000 0.000 0.000
#> GSM559417     1  0.4954      0.503 0.552 0.052 0.000 0.008 0.388 0.000
#> GSM559418     1  0.4924      0.674 0.668 0.212 0.000 0.008 0.112 0.000
#> GSM559419     1  0.4546      0.695 0.724 0.000 0.000 0.032 0.192 0.052
#> GSM559420     6  0.0000      0.978 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559421     5  0.3828      0.912 0.000 0.440 0.000 0.000 0.560 0.000
#> GSM559423     5  0.3955      0.878 0.000 0.384 0.000 0.000 0.608 0.008
#> GSM559425     2  0.2823      0.463 0.000 0.796 0.000 0.000 0.204 0.000
#> GSM559426     2  0.0146      0.767 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM559427     2  0.2996      0.393 0.000 0.772 0.000 0.000 0.228 0.000
#> GSM559428     6  0.0000      0.978 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559429     2  0.0000      0.770 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559430     2  0.0000      0.770 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-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 disease.state(p) k
#> ATC:skmeans 51           0.3921 2
#> ATC:skmeans 52           0.0476 3
#> ATC:skmeans 52           0.0319 4
#> ATC:skmeans 52           0.0466 5
#> ATC:skmeans 49           0.0623 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 21167 rows and 52 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 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-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 0.501           0.769       0.861         0.3287 0.735   0.735
#> 3 3 0.772           0.924       0.967         0.7559 0.667   0.551
#> 4 4 0.734           0.855       0.928         0.2663 0.791   0.524
#> 5 5 0.725           0.614       0.794         0.0791 0.864   0.551
#> 6 6 0.782           0.781       0.888         0.0447 0.834   0.396

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
#> GSM559383     1  0.0000      0.836 1.000 0.000
#> GSM559387     1  0.0000      0.836 1.000 0.000
#> GSM559391     1  0.0000      0.836 1.000 0.000
#> GSM559395     1  0.0000      0.836 1.000 0.000
#> GSM559397     1  0.8661      0.692 0.712 0.288
#> GSM559401     1  0.0000      0.836 1.000 0.000
#> GSM559414     1  0.0000      0.836 1.000 0.000
#> GSM559422     1  0.8207      0.708 0.744 0.256
#> GSM559424     1  0.0000      0.836 1.000 0.000
#> GSM559431     2  0.8661      1.000 0.288 0.712
#> GSM559432     2  0.8661      1.000 0.288 0.712
#> GSM559381     1  0.8661      0.692 0.712 0.288
#> GSM559382     1  0.8661      0.692 0.712 0.288
#> GSM559384     1  0.8661      0.692 0.712 0.288
#> GSM559385     1  0.0000      0.836 1.000 0.000
#> GSM559386     1  0.8661      0.692 0.712 0.288
#> GSM559388     1  0.9988     -0.510 0.520 0.480
#> GSM559389     1  0.8661      0.692 0.712 0.288
#> GSM559390     1  0.0000      0.836 1.000 0.000
#> GSM559392     1  0.9988     -0.510 0.520 0.480
#> GSM559393     1  0.0000      0.836 1.000 0.000
#> GSM559394     1  0.0000      0.836 1.000 0.000
#> GSM559396     1  0.0376      0.835 0.996 0.004
#> GSM559398     2  0.8661      1.000 0.288 0.712
#> GSM559399     1  0.0000      0.836 1.000 0.000
#> GSM559400     1  0.4562      0.724 0.904 0.096
#> GSM559402     1  0.0000      0.836 1.000 0.000
#> GSM559403     1  0.0000      0.836 1.000 0.000
#> GSM559404     1  0.8661      0.692 0.712 0.288
#> GSM559405     1  0.8661      0.692 0.712 0.288
#> GSM559406     1  0.0000      0.836 1.000 0.000
#> GSM559407     1  0.0000      0.836 1.000 0.000
#> GSM559408     1  0.0000      0.836 1.000 0.000
#> GSM559409     1  0.0000      0.836 1.000 0.000
#> GSM559410     1  0.0000      0.836 1.000 0.000
#> GSM559411     1  0.0000      0.836 1.000 0.000
#> GSM559412     1  0.8661      0.692 0.712 0.288
#> GSM559413     1  0.8661      0.692 0.712 0.288
#> GSM559415     1  0.0000      0.836 1.000 0.000
#> GSM559416     1  0.0000      0.836 1.000 0.000
#> GSM559417     1  0.0000      0.836 1.000 0.000
#> GSM559418     1  0.0000      0.836 1.000 0.000
#> GSM559419     1  0.0000      0.836 1.000 0.000
#> GSM559420     1  0.8661      0.692 0.712 0.288
#> GSM559421     2  0.8661      1.000 0.288 0.712
#> GSM559423     1  0.4562      0.724 0.904 0.096
#> GSM559425     2  0.8661      1.000 0.288 0.712
#> GSM559426     2  0.8661      1.000 0.288 0.712
#> GSM559427     2  0.8661      1.000 0.288 0.712
#> GSM559428     1  0.8661      0.692 0.712 0.288
#> GSM559429     1  0.2043      0.805 0.968 0.032
#> GSM559430     2  0.8661      1.000 0.288 0.712

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM559383     1   0.000      0.977 1.000 0.000 0.000
#> GSM559387     1   0.000      0.977 1.000 0.000 0.000
#> GSM559391     1   0.000      0.977 1.000 0.000 0.000
#> GSM559395     1   0.000      0.977 1.000 0.000 0.000
#> GSM559397     3   0.000      0.942 0.000 0.000 1.000
#> GSM559401     1   0.000      0.977 1.000 0.000 0.000
#> GSM559414     1   0.000      0.977 1.000 0.000 0.000
#> GSM559422     3   0.388      0.825 0.152 0.000 0.848
#> GSM559424     1   0.000      0.977 1.000 0.000 0.000
#> GSM559431     2   0.000      0.893 0.000 1.000 0.000
#> GSM559432     2   0.288      0.834 0.096 0.904 0.000
#> GSM559381     3   0.000      0.942 0.000 0.000 1.000
#> GSM559382     3   0.000      0.942 0.000 0.000 1.000
#> GSM559384     3   0.000      0.942 0.000 0.000 1.000
#> GSM559385     1   0.000      0.977 1.000 0.000 0.000
#> GSM559386     3   0.000      0.942 0.000 0.000 1.000
#> GSM559388     1   0.327      0.866 0.884 0.116 0.000
#> GSM559389     3   0.000      0.942 0.000 0.000 1.000
#> GSM559390     1   0.000      0.977 1.000 0.000 0.000
#> GSM559392     2   0.604      0.408 0.380 0.620 0.000
#> GSM559393     1   0.000      0.977 1.000 0.000 0.000
#> GSM559394     1   0.000      0.977 1.000 0.000 0.000
#> GSM559396     1   0.341      0.854 0.876 0.000 0.124
#> GSM559398     2   0.000      0.893 0.000 1.000 0.000
#> GSM559399     1   0.000      0.977 1.000 0.000 0.000
#> GSM559400     1   0.327      0.866 0.884 0.116 0.000
#> GSM559402     1   0.000      0.977 1.000 0.000 0.000
#> GSM559403     1   0.000      0.977 1.000 0.000 0.000
#> GSM559404     3   0.327      0.870 0.116 0.000 0.884
#> GSM559405     3   0.000      0.942 0.000 0.000 1.000
#> GSM559406     1   0.000      0.977 1.000 0.000 0.000
#> GSM559407     1   0.000      0.977 1.000 0.000 0.000
#> GSM559408     1   0.000      0.977 1.000 0.000 0.000
#> GSM559409     1   0.000      0.977 1.000 0.000 0.000
#> GSM559410     1   0.000      0.977 1.000 0.000 0.000
#> GSM559411     1   0.000      0.977 1.000 0.000 0.000
#> GSM559412     3   0.327      0.870 0.116 0.000 0.884
#> GSM559413     3   0.327      0.870 0.116 0.000 0.884
#> GSM559415     1   0.000      0.977 1.000 0.000 0.000
#> GSM559416     1   0.000      0.977 1.000 0.000 0.000
#> GSM559417     1   0.000      0.977 1.000 0.000 0.000
#> GSM559418     1   0.000      0.977 1.000 0.000 0.000
#> GSM559419     1   0.000      0.977 1.000 0.000 0.000
#> GSM559420     3   0.000      0.942 0.000 0.000 1.000
#> GSM559421     2   0.369      0.794 0.140 0.860 0.000
#> GSM559423     1   0.327      0.866 0.884 0.116 0.000
#> GSM559425     2   0.000      0.893 0.000 1.000 0.000
#> GSM559426     2   0.000      0.893 0.000 1.000 0.000
#> GSM559427     2   0.000      0.893 0.000 1.000 0.000
#> GSM559428     3   0.000      0.942 0.000 0.000 1.000
#> GSM559429     1   0.327      0.866 0.884 0.116 0.000
#> GSM559430     2   0.000      0.893 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
#> GSM559383     3  0.1389      0.862 0.000 0.000 0.952 0.048
#> GSM559387     3  0.0000      0.854 0.000 0.000 1.000 0.000
#> GSM559391     3  0.0000      0.854 0.000 0.000 1.000 0.000
#> GSM559395     3  0.0000      0.854 0.000 0.000 1.000 0.000
#> GSM559397     1  0.0000      0.908 1.000 0.000 0.000 0.000
#> GSM559401     3  0.0000      0.854 0.000 0.000 1.000 0.000
#> GSM559414     3  0.0000      0.854 0.000 0.000 1.000 0.000
#> GSM559422     4  0.4088      0.744 0.140 0.000 0.040 0.820
#> GSM559424     3  0.3528      0.855 0.000 0.000 0.808 0.192
#> GSM559431     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM559432     2  0.3569      0.778 0.000 0.804 0.196 0.000
#> GSM559381     1  0.0000      0.908 1.000 0.000 0.000 0.000
#> GSM559382     1  0.0000      0.908 1.000 0.000 0.000 0.000
#> GSM559384     1  0.0000      0.908 1.000 0.000 0.000 0.000
#> GSM559385     3  0.3528      0.855 0.000 0.000 0.808 0.192
#> GSM559386     1  0.0000      0.908 1.000 0.000 0.000 0.000
#> GSM559388     4  0.4193      0.613 0.000 0.268 0.000 0.732
#> GSM559389     1  0.0000      0.908 1.000 0.000 0.000 0.000
#> GSM559390     4  0.0000      0.934 0.000 0.000 0.000 1.000
#> GSM559392     4  0.1211      0.904 0.000 0.040 0.000 0.960
#> GSM559393     4  0.2921      0.808 0.000 0.000 0.140 0.860
#> GSM559394     3  0.4103      0.782 0.000 0.000 0.744 0.256
#> GSM559396     4  0.0000      0.934 0.000 0.000 0.000 1.000
#> GSM559398     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM559399     4  0.0000      0.934 0.000 0.000 0.000 1.000
#> GSM559400     4  0.0000      0.934 0.000 0.000 0.000 1.000
#> GSM559402     4  0.2921      0.808 0.000 0.000 0.140 0.860
#> GSM559403     3  0.3569      0.852 0.000 0.000 0.804 0.196
#> GSM559404     1  0.3105      0.790 0.856 0.000 0.140 0.004
#> GSM559405     1  0.0000      0.908 1.000 0.000 0.000 0.000
#> GSM559406     4  0.0707      0.922 0.000 0.000 0.020 0.980
#> GSM559407     3  0.3528      0.855 0.000 0.000 0.808 0.192
#> GSM559408     4  0.2921      0.808 0.000 0.000 0.140 0.860
#> GSM559409     3  0.3942      0.812 0.000 0.000 0.764 0.236
#> GSM559410     3  0.0000      0.854 0.000 0.000 1.000 0.000
#> GSM559411     3  0.3219      0.863 0.000 0.000 0.836 0.164
#> GSM559412     1  0.7220      0.011 0.440 0.000 0.140 0.420
#> GSM559413     1  0.3377      0.784 0.848 0.000 0.140 0.012
#> GSM559415     4  0.0000      0.934 0.000 0.000 0.000 1.000
#> GSM559416     4  0.0000      0.934 0.000 0.000 0.000 1.000
#> GSM559417     4  0.0000      0.934 0.000 0.000 0.000 1.000
#> GSM559418     4  0.0000      0.934 0.000 0.000 0.000 1.000
#> GSM559419     4  0.0000      0.934 0.000 0.000 0.000 1.000
#> GSM559420     1  0.0000      0.908 1.000 0.000 0.000 0.000
#> GSM559421     2  0.4193      0.608 0.000 0.732 0.000 0.268
#> GSM559423     4  0.0000      0.934 0.000 0.000 0.000 1.000
#> GSM559425     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM559426     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM559427     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM559428     1  0.0000      0.908 1.000 0.000 0.000 0.000
#> GSM559429     4  0.0000      0.934 0.000 0.000 0.000 1.000
#> GSM559430     2  0.0000      0.927 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
#> GSM559383     1  0.2886    -0.1367 0.844 0.000 0.148 0.008 0.000
#> GSM559387     3  0.4268     1.0000 0.444 0.000 0.556 0.000 0.000
#> GSM559391     1  0.4114    -0.6216 0.624 0.000 0.376 0.000 0.000
#> GSM559395     3  0.4268     1.0000 0.444 0.000 0.556 0.000 0.000
#> GSM559397     5  0.0703     0.9741 0.024 0.000 0.000 0.000 0.976
#> GSM559401     3  0.4268     1.0000 0.444 0.000 0.556 0.000 0.000
#> GSM559414     3  0.4268     1.0000 0.444 0.000 0.556 0.000 0.000
#> GSM559422     4  0.5884     0.2740 0.352 0.000 0.112 0.536 0.000
#> GSM559424     1  0.5104     0.1325 0.648 0.000 0.068 0.284 0.000
#> GSM559431     2  0.0000     0.8740 0.000 1.000 0.000 0.000 0.000
#> GSM559432     2  0.4907     0.1664 0.000 0.488 0.488 0.024 0.000
#> GSM559381     5  0.0000     0.9968 0.000 0.000 0.000 0.000 1.000
#> GSM559382     5  0.0000     0.9968 0.000 0.000 0.000 0.000 1.000
#> GSM559384     5  0.0000     0.9968 0.000 0.000 0.000 0.000 1.000
#> GSM559385     1  0.4418     0.2130 0.652 0.000 0.016 0.332 0.000
#> GSM559386     5  0.0000     0.9968 0.000 0.000 0.000 0.000 1.000
#> GSM559388     4  0.4430     0.6375 0.000 0.172 0.076 0.752 0.000
#> GSM559389     5  0.0000     0.9968 0.000 0.000 0.000 0.000 1.000
#> GSM559390     4  0.1741     0.7812 0.024 0.000 0.040 0.936 0.000
#> GSM559392     4  0.4732     0.5818 0.000 0.208 0.076 0.716 0.000
#> GSM559393     4  0.3336     0.5207 0.228 0.000 0.000 0.772 0.000
#> GSM559394     1  0.4418     0.2130 0.652 0.000 0.016 0.332 0.000
#> GSM559396     4  0.5845     0.2803 0.352 0.000 0.108 0.540 0.000
#> GSM559398     2  0.1671     0.8381 0.000 0.924 0.076 0.000 0.000
#> GSM559399     4  0.0880     0.7998 0.032 0.000 0.000 0.968 0.000
#> GSM559400     4  0.1671     0.7792 0.000 0.000 0.076 0.924 0.000
#> GSM559402     1  0.5689    -0.0598 0.480 0.000 0.080 0.440 0.000
#> GSM559403     1  0.4138     0.2737 0.616 0.000 0.000 0.384 0.000
#> GSM559404     1  0.5825     0.4127 0.556 0.000 0.368 0.052 0.024
#> GSM559405     5  0.0000     0.9968 0.000 0.000 0.000 0.000 1.000
#> GSM559406     1  0.6695     0.1802 0.392 0.000 0.368 0.240 0.000
#> GSM559407     1  0.4329     0.2169 0.672 0.000 0.016 0.312 0.000
#> GSM559408     1  0.5530     0.4052 0.556 0.000 0.368 0.076 0.000
#> GSM559409     1  0.2852     0.3109 0.828 0.000 0.000 0.172 0.000
#> GSM559410     3  0.4268     1.0000 0.444 0.000 0.556 0.000 0.000
#> GSM559411     1  0.4435    -0.5321 0.648 0.000 0.336 0.016 0.000
#> GSM559412     1  0.5774     0.4123 0.556 0.000 0.368 0.060 0.016
#> GSM559413     1  0.5774     0.4123 0.556 0.000 0.368 0.060 0.016
#> GSM559415     4  0.0880     0.7998 0.032 0.000 0.000 0.968 0.000
#> GSM559416     4  0.1270     0.7766 0.052 0.000 0.000 0.948 0.000
#> GSM559417     4  0.0000     0.8004 0.000 0.000 0.000 1.000 0.000
#> GSM559418     4  0.0880     0.7998 0.032 0.000 0.000 0.968 0.000
#> GSM559419     4  0.0880     0.7998 0.032 0.000 0.000 0.968 0.000
#> GSM559420     5  0.0000     0.9968 0.000 0.000 0.000 0.000 1.000
#> GSM559421     2  0.4933     0.5823 0.000 0.688 0.076 0.236 0.000
#> GSM559423     4  0.1671     0.7792 0.000 0.000 0.076 0.924 0.000
#> GSM559425     2  0.0000     0.8740 0.000 1.000 0.000 0.000 0.000
#> GSM559426     2  0.0000     0.8740 0.000 1.000 0.000 0.000 0.000
#> GSM559427     2  0.0000     0.8740 0.000 1.000 0.000 0.000 0.000
#> GSM559428     5  0.0000     0.9968 0.000 0.000 0.000 0.000 1.000
#> GSM559429     4  0.1270     0.7887 0.000 0.000 0.052 0.948 0.000
#> GSM559430     2  0.0000     0.8740 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
#> GSM559383     3  0.2805     0.7858 0.000 0.004 0.812 0.184 0.000 0.000
#> GSM559387     3  0.0000     0.8852 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559391     3  0.0937     0.8739 0.000 0.000 0.960 0.040 0.000 0.000
#> GSM559395     3  0.0000     0.8852 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559397     6  0.1075     0.9436 0.000 0.000 0.000 0.048 0.000 0.952
#> GSM559401     3  0.0000     0.8852 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559414     3  0.0000     0.8852 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559422     4  0.2762     0.7617 0.196 0.000 0.000 0.804 0.000 0.000
#> GSM559424     3  0.4919     0.5988 0.204 0.004 0.664 0.128 0.000 0.000
#> GSM559431     5  0.0000     0.8040 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM559432     5  0.4035     0.5794 0.004 0.196 0.056 0.000 0.744 0.000
#> GSM559381     6  0.0000     0.9877 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559382     6  0.0000     0.9877 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559384     6  0.0000     0.9877 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559385     1  0.4264     0.7180 0.744 0.004 0.124 0.128 0.000 0.000
#> GSM559386     6  0.0000     0.9877 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559388     1  0.3547     0.4222 0.668 0.332 0.000 0.000 0.000 0.000
#> GSM559389     6  0.0000     0.9877 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559390     1  0.1007     0.8223 0.956 0.000 0.000 0.044 0.000 0.000
#> GSM559392     2  0.1349     0.6570 0.056 0.940 0.000 0.004 0.000 0.000
#> GSM559393     1  0.2278     0.7935 0.868 0.004 0.000 0.128 0.000 0.000
#> GSM559394     1  0.3608     0.7624 0.800 0.004 0.068 0.128 0.000 0.000
#> GSM559396     4  0.2793     0.7592 0.200 0.000 0.000 0.800 0.000 0.000
#> GSM559398     2  0.3175     0.3605 0.000 0.744 0.000 0.000 0.256 0.000
#> GSM559399     1  0.0000     0.8473 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559400     2  0.3868     0.0164 0.496 0.504 0.000 0.000 0.000 0.000
#> GSM559402     4  0.2631     0.7463 0.180 0.000 0.000 0.820 0.000 0.000
#> GSM559403     1  0.3663     0.7605 0.796 0.004 0.072 0.128 0.000 0.000
#> GSM559404     4  0.0146     0.8419 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM559405     6  0.0000     0.9877 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559406     4  0.2003     0.7924 0.116 0.000 0.000 0.884 0.000 0.000
#> GSM559407     1  0.5044     0.5856 0.644 0.004 0.224 0.128 0.000 0.000
#> GSM559408     4  0.0000     0.8417 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM559409     4  0.4509     0.5989 0.104 0.004 0.180 0.712 0.000 0.000
#> GSM559410     3  0.0000     0.8852 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559411     3  0.3716     0.7696 0.076 0.004 0.792 0.128 0.000 0.000
#> GSM559412     4  0.0146     0.8419 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM559413     4  0.0146     0.8419 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM559415     1  0.0000     0.8473 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559416     1  0.0000     0.8473 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559417     1  0.0146     0.8465 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM559418     1  0.0000     0.8473 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM559419     1  0.0146     0.8465 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM559420     6  0.0000     0.9877 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559421     2  0.1267     0.6133 0.000 0.940 0.000 0.000 0.060 0.000
#> GSM559423     2  0.2320     0.6387 0.132 0.864 0.000 0.004 0.000 0.000
#> GSM559425     5  0.3244     0.6554 0.000 0.268 0.000 0.000 0.732 0.000
#> GSM559426     5  0.0000     0.8040 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM559427     5  0.3428     0.6119 0.000 0.304 0.000 0.000 0.696 0.000
#> GSM559428     6  0.1141     0.9539 0.000 0.052 0.000 0.000 0.000 0.948
#> GSM559429     1  0.0146     0.8457 0.996 0.004 0.000 0.000 0.000 0.000
#> GSM559430     5  0.0000     0.8040 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 disease.state(p) k
#> ATC:pam 50         1.000000 2
#> ATC:pam 51         0.816772 3
#> ATC:pam 51         0.014854 4
#> ATC:pam 34         0.000904 5
#> ATC:pam 49         0.000481 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 21167 rows and 52 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 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-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.451           0.781       0.770         0.3695 0.517   0.517
#> 3 3 0.509           0.822       0.850         0.7038 0.756   0.556
#> 4 4 0.765           0.789       0.900         0.1436 0.888   0.682
#> 5 5 0.697           0.788       0.856         0.0478 0.920   0.709
#> 6 6 0.749           0.710       0.813         0.0653 0.925   0.685

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
#> GSM559383     2   0.998     -0.831 0.476 0.524
#> GSM559387     2   0.833      0.594 0.264 0.736
#> GSM559391     1   0.991      0.998 0.556 0.444
#> GSM559395     2   0.738      0.633 0.208 0.792
#> GSM559397     2   0.991      0.481 0.444 0.556
#> GSM559401     2   0.991      0.481 0.444 0.556
#> GSM559414     2   0.991      0.481 0.444 0.556
#> GSM559422     2   0.991      0.481 0.444 0.556
#> GSM559424     1   0.991      0.998 0.556 0.444
#> GSM559431     2   0.184      0.774 0.028 0.972
#> GSM559432     2   0.991      0.481 0.444 0.556
#> GSM559381     2   0.000      0.792 0.000 1.000
#> GSM559382     2   0.000      0.792 0.000 1.000
#> GSM559384     2   0.000      0.792 0.000 1.000
#> GSM559385     1   0.991      0.998 0.556 0.444
#> GSM559386     2   0.000      0.792 0.000 1.000
#> GSM559388     2   0.000      0.792 0.000 1.000
#> GSM559389     2   0.000      0.792 0.000 1.000
#> GSM559390     1   0.991      0.998 0.556 0.444
#> GSM559392     2   0.000      0.792 0.000 1.000
#> GSM559393     1   0.991      0.998 0.556 0.444
#> GSM559394     1   0.992      0.992 0.552 0.448
#> GSM559396     2   0.861     -0.175 0.284 0.716
#> GSM559398     2   0.000      0.792 0.000 1.000
#> GSM559399     1   0.991      0.998 0.556 0.444
#> GSM559400     2   0.000      0.792 0.000 1.000
#> GSM559402     1   0.991      0.998 0.556 0.444
#> GSM559403     1   0.991      0.998 0.556 0.444
#> GSM559404     2   0.000      0.792 0.000 1.000
#> GSM559405     2   0.000      0.792 0.000 1.000
#> GSM559406     1   0.991      0.998 0.556 0.444
#> GSM559407     1   0.991      0.998 0.556 0.444
#> GSM559408     1   0.991      0.998 0.556 0.444
#> GSM559409     1   0.991      0.998 0.556 0.444
#> GSM559410     2   0.000      0.792 0.000 1.000
#> GSM559411     1   0.995      0.971 0.540 0.460
#> GSM559412     1   0.991      0.998 0.556 0.444
#> GSM559413     2   0.373      0.664 0.072 0.928
#> GSM559415     1   0.991      0.998 0.556 0.444
#> GSM559416     1   0.991      0.998 0.556 0.444
#> GSM559417     1   0.991      0.998 0.556 0.444
#> GSM559418     1   0.991      0.998 0.556 0.444
#> GSM559419     1   0.991      0.998 0.556 0.444
#> GSM559420     2   0.000      0.792 0.000 1.000
#> GSM559421     2   0.000      0.792 0.000 1.000
#> GSM559423     2   0.000      0.792 0.000 1.000
#> GSM559425     2   0.000      0.792 0.000 1.000
#> GSM559426     2   0.000      0.792 0.000 1.000
#> GSM559427     2   0.000      0.792 0.000 1.000
#> GSM559428     2   0.000      0.792 0.000 1.000
#> GSM559429     2   0.163      0.776 0.024 0.976
#> GSM559430     2   0.000      0.792 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
#> GSM559383     1  0.6359     0.0677 0.592 0.404 0.004
#> GSM559387     2  0.8109     0.7907 0.116 0.628 0.256
#> GSM559391     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559395     2  0.8331     0.7739 0.164 0.628 0.208
#> GSM559397     2  0.6204     0.6752 0.000 0.576 0.424
#> GSM559401     2  0.8109     0.7907 0.116 0.628 0.256
#> GSM559414     2  0.8109     0.7907 0.116 0.628 0.256
#> GSM559422     2  0.6008     0.7322 0.000 0.628 0.372
#> GSM559424     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559431     2  0.3619     0.7896 0.000 0.864 0.136
#> GSM559432     2  0.5178     0.7817 0.000 0.744 0.256
#> GSM559381     3  0.2537     0.8366 0.080 0.000 0.920
#> GSM559382     2  0.7513     0.6593 0.052 0.604 0.344
#> GSM559384     3  0.4796     0.8397 0.220 0.000 0.780
#> GSM559385     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559386     3  0.2537     0.8366 0.080 0.000 0.920
#> GSM559388     2  0.3134     0.7831 0.032 0.916 0.052
#> GSM559389     3  0.2537     0.8366 0.080 0.000 0.920
#> GSM559390     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559392     2  0.4270     0.7829 0.116 0.860 0.024
#> GSM559393     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559394     1  0.0424     0.9535 0.992 0.008 0.000
#> GSM559396     3  0.5497     0.7910 0.292 0.000 0.708
#> GSM559398     2  0.0000     0.7632 0.000 1.000 0.000
#> GSM559399     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559400     2  0.5988     0.7772 0.168 0.776 0.056
#> GSM559402     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559403     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559404     3  0.5260     0.7516 0.080 0.092 0.828
#> GSM559405     3  0.2537     0.8366 0.080 0.000 0.920
#> GSM559406     3  0.5760     0.7409 0.328 0.000 0.672
#> GSM559407     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559408     3  0.5882     0.7049 0.348 0.000 0.652
#> GSM559409     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559410     2  0.8350     0.7485 0.196 0.628 0.176
#> GSM559411     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559412     3  0.5497     0.7910 0.292 0.000 0.708
#> GSM559413     3  0.4887     0.8367 0.228 0.000 0.772
#> GSM559415     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559416     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559417     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559418     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559419     1  0.0000     0.9636 1.000 0.000 0.000
#> GSM559420     3  0.2682     0.8325 0.076 0.004 0.920
#> GSM559421     2  0.3267     0.7738 0.116 0.884 0.000
#> GSM559423     2  0.8028     0.7747 0.168 0.656 0.176
#> GSM559425     2  0.0000     0.7632 0.000 1.000 0.000
#> GSM559426     2  0.0592     0.7644 0.012 0.988 0.000
#> GSM559427     2  0.0000     0.7632 0.000 1.000 0.000
#> GSM559428     2  0.7513     0.6593 0.052 0.604 0.344
#> GSM559429     2  0.8028     0.7747 0.168 0.656 0.176
#> GSM559430     2  0.0000     0.7632 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
#> GSM559383     4  0.3649      0.689 0.000 0.000 0.204 0.796
#> GSM559387     3  0.1716      0.756 0.000 0.000 0.936 0.064
#> GSM559391     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559395     3  0.7812      0.167 0.000 0.256 0.396 0.348
#> GSM559397     3  0.1022      0.781 0.032 0.000 0.968 0.000
#> GSM559401     3  0.0000      0.785 0.000 0.000 1.000 0.000
#> GSM559414     3  0.0000      0.785 0.000 0.000 1.000 0.000
#> GSM559422     3  0.0000      0.785 0.000 0.000 1.000 0.000
#> GSM559424     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559431     2  0.1557      0.851 0.000 0.944 0.056 0.000
#> GSM559432     3  0.0000      0.785 0.000 0.000 1.000 0.000
#> GSM559381     1  0.0000      0.751 1.000 0.000 0.000 0.000
#> GSM559382     3  0.4992      0.393 0.476 0.000 0.524 0.000
#> GSM559384     1  0.3907      0.824 0.768 0.000 0.000 0.232
#> GSM559385     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559386     1  0.0000      0.751 1.000 0.000 0.000 0.000
#> GSM559388     2  0.3942      0.574 0.000 0.764 0.000 0.236
#> GSM559389     1  0.0000      0.751 1.000 0.000 0.000 0.000
#> GSM559390     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559392     2  0.0000      0.894 0.000 1.000 0.000 0.000
#> GSM559393     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559394     4  0.0592      0.932 0.000 0.016 0.000 0.984
#> GSM559396     1  0.4008      0.819 0.756 0.000 0.000 0.244
#> GSM559398     2  0.0000      0.894 0.000 1.000 0.000 0.000
#> GSM559399     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559400     2  0.1302      0.860 0.000 0.956 0.000 0.044
#> GSM559402     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559403     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559404     1  0.3942      0.824 0.764 0.000 0.000 0.236
#> GSM559405     1  0.0000      0.751 1.000 0.000 0.000 0.000
#> GSM559406     1  0.4134      0.803 0.740 0.000 0.000 0.260
#> GSM559407     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559408     1  0.4222      0.791 0.728 0.000 0.000 0.272
#> GSM559409     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559410     4  0.7824     -0.187 0.000 0.264 0.336 0.400
#> GSM559411     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559412     1  0.3942      0.824 0.764 0.000 0.000 0.236
#> GSM559413     1  0.3942      0.824 0.764 0.000 0.000 0.236
#> GSM559415     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559416     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559417     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559418     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559419     4  0.0000      0.948 0.000 0.000 0.000 1.000
#> GSM559420     1  0.0000      0.751 1.000 0.000 0.000 0.000
#> GSM559421     2  0.0000      0.894 0.000 1.000 0.000 0.000
#> GSM559423     3  0.5592      0.477 0.000 0.300 0.656 0.044
#> GSM559425     2  0.0000      0.894 0.000 1.000 0.000 0.000
#> GSM559426     2  0.0336      0.890 0.000 0.992 0.000 0.008
#> GSM559427     2  0.0000      0.894 0.000 1.000 0.000 0.000
#> GSM559428     3  0.4713      0.581 0.360 0.000 0.640 0.000
#> GSM559429     2  0.6738      0.148 0.000 0.544 0.352 0.104
#> GSM559430     2  0.0000      0.894 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
#> GSM559383     1  0.4047      0.404 0.676 0.000 0.320 0.004 0.000
#> GSM559387     3  0.1478      0.737 0.064 0.000 0.936 0.000 0.000
#> GSM559391     1  0.0324      0.940 0.992 0.000 0.004 0.004 0.000
#> GSM559395     3  0.3219      0.702 0.136 0.020 0.840 0.004 0.000
#> GSM559397     3  0.5198      0.660 0.000 0.000 0.688 0.164 0.148
#> GSM559401     3  0.0000      0.731 0.000 0.000 1.000 0.000 0.000
#> GSM559414     3  0.0000      0.731 0.000 0.000 1.000 0.000 0.000
#> GSM559422     3  0.3242      0.709 0.000 0.000 0.784 0.216 0.000
#> GSM559424     1  0.0162      0.941 0.996 0.000 0.000 0.004 0.000
#> GSM559431     2  0.1732      0.834 0.000 0.920 0.080 0.000 0.000
#> GSM559432     3  0.3242      0.709 0.000 0.000 0.784 0.216 0.000
#> GSM559381     5  0.2280      0.837 0.000 0.000 0.000 0.120 0.880
#> GSM559382     5  0.3885      0.535 0.000 0.000 0.268 0.008 0.724
#> GSM559384     4  0.5079      0.707 0.136 0.000 0.000 0.700 0.164
#> GSM559385     1  0.0162      0.941 0.996 0.000 0.000 0.004 0.000
#> GSM559386     5  0.2280      0.837 0.000 0.000 0.000 0.120 0.880
#> GSM559388     2  0.4555      0.595 0.224 0.720 0.000 0.056 0.000
#> GSM559389     5  0.2280      0.837 0.000 0.000 0.000 0.120 0.880
#> GSM559390     1  0.1364      0.932 0.952 0.000 0.000 0.036 0.012
#> GSM559392     2  0.0510      0.899 0.016 0.984 0.000 0.000 0.000
#> GSM559393     1  0.0566      0.941 0.984 0.000 0.000 0.004 0.012
#> GSM559394     1  0.0451      0.939 0.988 0.000 0.008 0.004 0.000
#> GSM559396     4  0.4645      0.766 0.204 0.000 0.000 0.724 0.072
#> GSM559398     2  0.0000      0.900 0.000 1.000 0.000 0.000 0.000
#> GSM559399     1  0.1124      0.935 0.960 0.000 0.000 0.036 0.004
#> GSM559400     2  0.2179      0.814 0.112 0.888 0.000 0.000 0.000
#> GSM559402     1  0.0162      0.941 0.996 0.000 0.000 0.000 0.004
#> GSM559403     1  0.0162      0.941 0.996 0.000 0.000 0.004 0.000
#> GSM559404     4  0.7397      0.168 0.056 0.000 0.248 0.480 0.216
#> GSM559405     5  0.2329      0.834 0.000 0.000 0.000 0.124 0.876
#> GSM559406     4  0.4840      0.729 0.320 0.000 0.000 0.640 0.040
#> GSM559407     1  0.0162      0.942 0.996 0.000 0.004 0.000 0.000
#> GSM559408     4  0.4836      0.681 0.356 0.000 0.000 0.612 0.032
#> GSM559409     1  0.0162      0.941 0.996 0.000 0.000 0.004 0.000
#> GSM559410     3  0.4706      0.470 0.344 0.020 0.632 0.004 0.000
#> GSM559411     1  0.1124      0.916 0.960 0.000 0.036 0.004 0.000
#> GSM559412     4  0.4605      0.773 0.192 0.000 0.000 0.732 0.076
#> GSM559413     4  0.4698      0.761 0.172 0.000 0.000 0.732 0.096
#> GSM559415     1  0.0880      0.937 0.968 0.000 0.000 0.032 0.000
#> GSM559416     1  0.0963      0.936 0.964 0.000 0.000 0.036 0.000
#> GSM559417     1  0.1918      0.918 0.928 0.000 0.000 0.036 0.036
#> GSM559418     1  0.1836      0.921 0.932 0.000 0.000 0.036 0.032
#> GSM559419     1  0.1918      0.918 0.928 0.000 0.000 0.036 0.036
#> GSM559420     5  0.2280      0.837 0.000 0.000 0.000 0.120 0.880
#> GSM559421     2  0.0510      0.899 0.016 0.984 0.000 0.000 0.000
#> GSM559423     3  0.7026      0.614 0.112 0.224 0.580 0.008 0.076
#> GSM559425     2  0.0000      0.900 0.000 1.000 0.000 0.000 0.000
#> GSM559426     2  0.2488      0.788 0.124 0.872 0.000 0.004 0.000
#> GSM559427     2  0.0000      0.900 0.000 1.000 0.000 0.000 0.000
#> GSM559428     5  0.3885      0.535 0.000 0.000 0.268 0.008 0.724
#> GSM559429     3  0.6506      0.377 0.208 0.324 0.468 0.000 0.000
#> GSM559430     2  0.0000      0.900 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
#> GSM559383     4  0.6245     -0.305 0.284 0.000 0.008 0.420 0.288 0.000
#> GSM559387     3  0.4372      0.805 0.028 0.000 0.692 0.020 0.260 0.000
#> GSM559391     1  0.3499      0.425 0.680 0.000 0.000 0.000 0.320 0.000
#> GSM559395     3  0.6153      0.616 0.088 0.008 0.540 0.052 0.312 0.000
#> GSM559397     3  0.3133      0.740 0.000 0.000 0.780 0.212 0.000 0.008
#> GSM559401     3  0.2945      0.840 0.000 0.000 0.824 0.020 0.156 0.000
#> GSM559414     3  0.2945      0.840 0.000 0.000 0.824 0.020 0.156 0.000
#> GSM559422     3  0.0363      0.827 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM559424     1  0.3876      0.454 0.700 0.000 0.000 0.024 0.276 0.000
#> GSM559431     2  0.1180      0.872 0.004 0.960 0.008 0.024 0.000 0.004
#> GSM559432     3  0.0000      0.829 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM559381     6  0.0000      0.890 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM559382     6  0.3323      0.778 0.000 0.000 0.008 0.204 0.008 0.780
#> GSM559384     4  0.4230      0.615 0.024 0.000 0.000 0.612 0.000 0.364
#> GSM559385     1  0.3428      0.452 0.696 0.000 0.000 0.000 0.304 0.000
#> GSM559386     6  0.0146      0.892 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM559388     2  0.3933      0.646 0.216 0.740 0.040 0.004 0.000 0.000
#> GSM559389     6  0.0146      0.892 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM559390     1  0.0603      0.722 0.980 0.000 0.000 0.004 0.016 0.000
#> GSM559392     2  0.0508      0.879 0.004 0.984 0.000 0.000 0.012 0.000
#> GSM559393     1  0.1341      0.712 0.948 0.000 0.000 0.024 0.028 0.000
#> GSM559394     1  0.5137      0.294 0.604 0.004 0.000 0.104 0.288 0.000
#> GSM559396     4  0.6059      0.725 0.084 0.000 0.088 0.600 0.004 0.224
#> GSM559398     2  0.0000      0.879 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559399     1  0.0547      0.726 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM559400     2  0.3441      0.770 0.140 0.816 0.000 0.012 0.028 0.004
#> GSM559402     1  0.0508      0.728 0.984 0.000 0.000 0.004 0.012 0.000
#> GSM559403     1  0.3371      0.470 0.708 0.000 0.000 0.000 0.292 0.000
#> GSM559404     4  0.4925      0.733 0.048 0.000 0.032 0.692 0.008 0.220
#> GSM559405     6  0.1471      0.851 0.004 0.000 0.064 0.000 0.000 0.932
#> GSM559406     4  0.4516      0.769 0.112 0.000 0.000 0.700 0.000 0.188
#> GSM559407     5  0.3765      0.708 0.404 0.000 0.000 0.000 0.596 0.000
#> GSM559408     4  0.4233      0.553 0.268 0.000 0.000 0.684 0.000 0.048
#> GSM559409     1  0.4371      0.400 0.664 0.000 0.000 0.052 0.284 0.000
#> GSM559410     5  0.4572      0.707 0.240 0.008 0.032 0.020 0.700 0.000
#> GSM559411     5  0.4105      0.784 0.348 0.000 0.000 0.020 0.632 0.000
#> GSM559412     4  0.4349      0.770 0.084 0.000 0.000 0.708 0.000 0.208
#> GSM559413     4  0.4255      0.762 0.068 0.000 0.000 0.708 0.000 0.224
#> GSM559415     1  0.0935      0.727 0.964 0.000 0.000 0.004 0.032 0.000
#> GSM559416     1  0.0692      0.728 0.976 0.000 0.000 0.000 0.020 0.004
#> GSM559417     1  0.1219      0.699 0.948 0.000 0.000 0.000 0.048 0.004
#> GSM559418     1  0.1152      0.707 0.952 0.000 0.000 0.004 0.044 0.000
#> GSM559419     1  0.1082      0.706 0.956 0.000 0.000 0.004 0.040 0.000
#> GSM559420     6  0.0146      0.892 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM559421     2  0.0508      0.879 0.004 0.984 0.000 0.000 0.012 0.000
#> GSM559423     2  0.6084      0.622 0.124 0.616 0.012 0.208 0.028 0.012
#> GSM559425     2  0.0000      0.879 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559426     2  0.1152      0.865 0.044 0.952 0.000 0.004 0.000 0.000
#> GSM559427     2  0.0000      0.879 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM559428     6  0.3381      0.772 0.000 0.000 0.008 0.212 0.008 0.772
#> GSM559429     2  0.5827      0.645 0.172 0.660 0.032 0.044 0.092 0.000
#> GSM559430     2  0.0146      0.880 0.004 0.996 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-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 disease.state(p) k
#> ATC:mclust 45         1.00e+00 2
#> ATC:mclust 51         2.34e-02 3
#> ATC:mclust 47         7.96e-05 4
#> ATC:mclust 48         2.46e-05 5
#> ATC:mclust 45         2.69e-07 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 21167 rows and 52 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.958       0.982         0.4051 0.599   0.599
#> 3 3 0.922           0.925       0.968         0.6577 0.660   0.463
#> 4 4 0.619           0.606       0.789         0.0956 0.900   0.715
#> 5 5 0.672           0.699       0.828         0.0743 0.881   0.595
#> 6 6 0.629           0.511       0.711         0.0380 0.956   0.801

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
#> GSM559383     1  0.0000      0.983 1.000 0.000
#> GSM559387     1  0.0000      0.983 1.000 0.000
#> GSM559391     1  0.0000      0.983 1.000 0.000
#> GSM559395     1  0.0000      0.983 1.000 0.000
#> GSM559397     1  0.0000      0.983 1.000 0.000
#> GSM559401     1  0.0000      0.983 1.000 0.000
#> GSM559414     1  0.0000      0.983 1.000 0.000
#> GSM559422     1  0.0000      0.983 1.000 0.000
#> GSM559424     1  0.0000      0.983 1.000 0.000
#> GSM559431     2  0.0000      0.973 0.000 1.000
#> GSM559432     2  0.0000      0.973 0.000 1.000
#> GSM559381     1  0.0000      0.983 1.000 0.000
#> GSM559382     1  0.0000      0.983 1.000 0.000
#> GSM559384     1  0.0000      0.983 1.000 0.000
#> GSM559385     1  0.0000      0.983 1.000 0.000
#> GSM559386     1  0.0000      0.983 1.000 0.000
#> GSM559388     2  0.0000      0.973 0.000 1.000
#> GSM559389     1  0.0000      0.983 1.000 0.000
#> GSM559390     1  0.0000      0.983 1.000 0.000
#> GSM559392     2  0.0000      0.973 0.000 1.000
#> GSM559393     1  0.0000      0.983 1.000 0.000
#> GSM559394     1  0.0000      0.983 1.000 0.000
#> GSM559396     1  0.0000      0.983 1.000 0.000
#> GSM559398     2  0.0000      0.973 0.000 1.000
#> GSM559399     1  0.0000      0.983 1.000 0.000
#> GSM559400     2  0.0000      0.973 0.000 1.000
#> GSM559402     1  0.0000      0.983 1.000 0.000
#> GSM559403     1  0.0000      0.983 1.000 0.000
#> GSM559404     1  0.0000      0.983 1.000 0.000
#> GSM559405     1  0.0000      0.983 1.000 0.000
#> GSM559406     1  0.0000      0.983 1.000 0.000
#> GSM559407     1  0.0000      0.983 1.000 0.000
#> GSM559408     1  0.0000      0.983 1.000 0.000
#> GSM559409     1  0.0000      0.983 1.000 0.000
#> GSM559410     1  0.0000      0.983 1.000 0.000
#> GSM559411     1  0.0000      0.983 1.000 0.000
#> GSM559412     1  0.0000      0.983 1.000 0.000
#> GSM559413     1  0.0000      0.983 1.000 0.000
#> GSM559415     1  0.1843      0.957 0.972 0.028
#> GSM559416     2  0.8713      0.577 0.292 0.708
#> GSM559417     1  0.8763      0.575 0.704 0.296
#> GSM559418     1  0.8267      0.643 0.740 0.260
#> GSM559419     1  0.0000      0.983 1.000 0.000
#> GSM559420     1  0.0000      0.983 1.000 0.000
#> GSM559421     2  0.0000      0.973 0.000 1.000
#> GSM559423     2  0.0938      0.965 0.012 0.988
#> GSM559425     2  0.0000      0.973 0.000 1.000
#> GSM559426     2  0.0000      0.973 0.000 1.000
#> GSM559427     2  0.0000      0.973 0.000 1.000
#> GSM559428     1  0.0000      0.983 1.000 0.000
#> GSM559429     2  0.2043      0.948 0.032 0.968
#> GSM559430     2  0.0000      0.973 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
#> GSM559383     3  0.0000      0.978 0.000 0.000 1.000
#> GSM559387     3  0.0000      0.978 0.000 0.000 1.000
#> GSM559391     3  0.0000      0.978 0.000 0.000 1.000
#> GSM559395     3  0.0000      0.978 0.000 0.000 1.000
#> GSM559397     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559401     3  0.0000      0.978 0.000 0.000 1.000
#> GSM559414     3  0.0000      0.978 0.000 0.000 1.000
#> GSM559422     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559424     3  0.0000      0.978 0.000 0.000 1.000
#> GSM559431     2  0.0000      0.956 0.000 1.000 0.000
#> GSM559432     2  0.0000      0.956 0.000 1.000 0.000
#> GSM559381     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559382     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559384     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559385     3  0.0000      0.978 0.000 0.000 1.000
#> GSM559386     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559388     2  0.0000      0.956 0.000 1.000 0.000
#> GSM559389     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559390     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559392     2  0.0424      0.952 0.008 0.992 0.000
#> GSM559393     1  0.7671      0.314 0.568 0.052 0.380
#> GSM559394     3  0.0000      0.978 0.000 0.000 1.000
#> GSM559396     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559398     2  0.0000      0.956 0.000 1.000 0.000
#> GSM559399     3  0.0475      0.971 0.004 0.004 0.992
#> GSM559400     2  0.0000      0.956 0.000 1.000 0.000
#> GSM559402     1  0.1289      0.933 0.968 0.000 0.032
#> GSM559403     3  0.0000      0.978 0.000 0.000 1.000
#> GSM559404     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559405     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559406     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559407     3  0.0000      0.978 0.000 0.000 1.000
#> GSM559408     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559409     3  0.0000      0.978 0.000 0.000 1.000
#> GSM559410     3  0.0000      0.978 0.000 0.000 1.000
#> GSM559411     3  0.0000      0.978 0.000 0.000 1.000
#> GSM559412     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559413     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559415     3  0.5621      0.532 0.000 0.308 0.692
#> GSM559416     2  0.3816      0.815 0.000 0.852 0.148
#> GSM559417     2  0.4974      0.702 0.236 0.764 0.000
#> GSM559418     2  0.4862      0.801 0.160 0.820 0.020
#> GSM559419     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559420     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559421     2  0.0000      0.956 0.000 1.000 0.000
#> GSM559423     1  0.5397      0.581 0.720 0.280 0.000
#> GSM559425     2  0.0000      0.956 0.000 1.000 0.000
#> GSM559426     2  0.0000      0.956 0.000 1.000 0.000
#> GSM559427     2  0.0000      0.956 0.000 1.000 0.000
#> GSM559428     1  0.0000      0.961 1.000 0.000 0.000
#> GSM559429     2  0.0424      0.952 0.008 0.992 0.000
#> GSM559430     2  0.0000      0.956 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
#> GSM559383     1  0.4999    -0.5177 0.508 0.000 0.492 0.000
#> GSM559387     3  0.4907     0.5639 0.420 0.000 0.580 0.000
#> GSM559391     1  0.1792     0.6407 0.932 0.000 0.068 0.000
#> GSM559395     3  0.4925     0.5567 0.428 0.000 0.572 0.000
#> GSM559397     4  0.1637     0.7835 0.000 0.000 0.060 0.940
#> GSM559401     3  0.4866     0.5729 0.404 0.000 0.596 0.000
#> GSM559414     3  0.6867     0.4833 0.384 0.000 0.508 0.108
#> GSM559422     3  0.4981     0.0414 0.000 0.000 0.536 0.464
#> GSM559424     1  0.2149     0.6458 0.912 0.000 0.088 0.000
#> GSM559431     2  0.0000     0.8099 0.000 1.000 0.000 0.000
#> GSM559432     2  0.4967     0.1901 0.000 0.548 0.452 0.000
#> GSM559381     4  0.0592     0.8016 0.000 0.000 0.016 0.984
#> GSM559382     4  0.2530     0.7997 0.000 0.000 0.112 0.888
#> GSM559384     4  0.2174     0.8121 0.052 0.000 0.020 0.928
#> GSM559385     1  0.0469     0.6733 0.988 0.000 0.012 0.000
#> GSM559386     4  0.0817     0.8094 0.000 0.000 0.024 0.976
#> GSM559388     2  0.0927     0.8050 0.016 0.976 0.008 0.000
#> GSM559389     4  0.0000     0.8064 0.000 0.000 0.000 1.000
#> GSM559390     4  0.7369     0.5325 0.196 0.000 0.292 0.512
#> GSM559392     2  0.2334     0.7799 0.000 0.908 0.088 0.004
#> GSM559393     1  0.7641     0.2751 0.592 0.120 0.052 0.236
#> GSM559394     1  0.2281     0.6328 0.904 0.000 0.096 0.000
#> GSM559396     4  0.5954     0.6582 0.052 0.000 0.344 0.604
#> GSM559398     2  0.0469     0.8084 0.000 0.988 0.012 0.000
#> GSM559399     1  0.3484     0.5704 0.844 0.004 0.144 0.008
#> GSM559400     2  0.4661     0.6772 0.016 0.728 0.256 0.000
#> GSM559402     1  0.6693    -0.0181 0.488 0.000 0.088 0.424
#> GSM559403     1  0.0188     0.6751 0.996 0.000 0.004 0.000
#> GSM559404     4  0.2578     0.8004 0.052 0.000 0.036 0.912
#> GSM559405     4  0.1109     0.7999 0.004 0.000 0.028 0.968
#> GSM559406     4  0.6351     0.6824 0.104 0.000 0.268 0.628
#> GSM559407     1  0.0592     0.6749 0.984 0.000 0.016 0.000
#> GSM559408     4  0.5897     0.7046 0.136 0.000 0.164 0.700
#> GSM559409     1  0.1182     0.6702 0.968 0.000 0.016 0.016
#> GSM559410     1  0.2704     0.5398 0.876 0.000 0.124 0.000
#> GSM559411     1  0.1637     0.6422 0.940 0.000 0.060 0.000
#> GSM559412     4  0.2363     0.8056 0.056 0.000 0.024 0.920
#> GSM559413     4  0.2385     0.8049 0.052 0.000 0.028 0.920
#> GSM559415     1  0.7085     0.2886 0.568 0.232 0.200 0.000
#> GSM559416     2  0.7001     0.0621 0.420 0.464 0.116 0.000
#> GSM559417     2  0.8869     0.3118 0.140 0.396 0.372 0.092
#> GSM559418     2  0.8311     0.3686 0.244 0.512 0.196 0.048
#> GSM559419     4  0.7216     0.5597 0.156 0.000 0.336 0.508
#> GSM559420     4  0.2654     0.8065 0.004 0.000 0.108 0.888
#> GSM559421     2  0.0000     0.8099 0.000 1.000 0.000 0.000
#> GSM559423     4  0.6508     0.4726 0.000 0.296 0.104 0.600
#> GSM559425     2  0.0000     0.8099 0.000 1.000 0.000 0.000
#> GSM559426     2  0.0000     0.8099 0.000 1.000 0.000 0.000
#> GSM559427     2  0.0000     0.8099 0.000 1.000 0.000 0.000
#> GSM559428     4  0.2408     0.8057 0.000 0.000 0.104 0.896
#> GSM559429     2  0.1743     0.7814 0.000 0.940 0.004 0.056
#> GSM559430     2  0.0000     0.8099 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
#> GSM559383     5  0.5813     0.2621 0.000 0.000 0.328 0.112 0.560
#> GSM559387     3  0.3305     0.7224 0.000 0.000 0.776 0.000 0.224
#> GSM559391     5  0.3241     0.7853 0.000 0.000 0.024 0.144 0.832
#> GSM559395     3  0.4588     0.6721 0.000 0.000 0.720 0.060 0.220
#> GSM559397     1  0.1831     0.8169 0.920 0.000 0.076 0.004 0.000
#> GSM559401     3  0.2329     0.7477 0.000 0.000 0.876 0.000 0.124
#> GSM559414     3  0.6077     0.3186 0.124 0.000 0.480 0.000 0.396
#> GSM559422     3  0.1502     0.6884 0.056 0.000 0.940 0.004 0.000
#> GSM559424     5  0.4341     0.5454 0.000 0.000 0.008 0.364 0.628
#> GSM559431     2  0.0000     0.9028 0.000 1.000 0.000 0.000 0.000
#> GSM559432     3  0.3282     0.6327 0.000 0.188 0.804 0.008 0.000
#> GSM559381     1  0.0451     0.8324 0.988 0.000 0.000 0.008 0.004
#> GSM559382     1  0.4002     0.7867 0.796 0.000 0.084 0.120 0.000
#> GSM559384     1  0.3265     0.8109 0.844 0.000 0.012 0.128 0.016
#> GSM559385     5  0.2719     0.7982 0.000 0.000 0.004 0.144 0.852
#> GSM559386     1  0.2069     0.8310 0.912 0.000 0.012 0.076 0.000
#> GSM559388     2  0.1851     0.8536 0.000 0.912 0.000 0.088 0.000
#> GSM559389     1  0.1430     0.8356 0.944 0.000 0.004 0.052 0.000
#> GSM559390     4  0.2863     0.7156 0.060 0.000 0.000 0.876 0.064
#> GSM559392     2  0.2570     0.8313 0.004 0.880 0.008 0.108 0.000
#> GSM559393     5  0.4058     0.7452 0.032 0.040 0.012 0.084 0.832
#> GSM559394     5  0.5002     0.5759 0.000 0.000 0.052 0.312 0.636
#> GSM559396     4  0.4042     0.6309 0.156 0.000 0.044 0.792 0.008
#> GSM559398     2  0.1124     0.8894 0.000 0.960 0.004 0.036 0.000
#> GSM559399     4  0.3336     0.5952 0.000 0.000 0.000 0.772 0.228
#> GSM559400     4  0.5868     0.1638 0.000 0.380 0.104 0.516 0.000
#> GSM559402     5  0.4520     0.6479 0.156 0.000 0.016 0.060 0.768
#> GSM559403     5  0.2806     0.7957 0.000 0.000 0.004 0.152 0.844
#> GSM559404     1  0.3068     0.7870 0.880 0.000 0.036 0.028 0.056
#> GSM559405     1  0.0960     0.8267 0.972 0.000 0.016 0.004 0.008
#> GSM559406     4  0.4125     0.5479 0.236 0.000 0.004 0.740 0.020
#> GSM559407     5  0.2136     0.7864 0.000 0.000 0.008 0.088 0.904
#> GSM559408     1  0.7048    -0.0233 0.388 0.000 0.016 0.220 0.376
#> GSM559409     5  0.3134     0.7838 0.028 0.000 0.012 0.096 0.864
#> GSM559410     5  0.0992     0.7416 0.000 0.000 0.024 0.008 0.968
#> GSM559411     5  0.1430     0.7891 0.000 0.000 0.004 0.052 0.944
#> GSM559412     1  0.2728     0.8046 0.896 0.000 0.016 0.040 0.048
#> GSM559413     1  0.2095     0.8179 0.928 0.000 0.020 0.028 0.024
#> GSM559415     4  0.3522     0.6100 0.000 0.004 0.004 0.780 0.212
#> GSM559416     4  0.3662     0.5540 0.000 0.004 0.000 0.744 0.252
#> GSM559417     4  0.2354     0.7195 0.000 0.020 0.032 0.916 0.032
#> GSM559418     2  0.7510     0.0136 0.044 0.452 0.012 0.332 0.160
#> GSM559419     4  0.1597     0.7219 0.012 0.000 0.000 0.940 0.048
#> GSM559420     1  0.3236     0.7999 0.828 0.000 0.020 0.152 0.000
#> GSM559421     2  0.0000     0.9028 0.000 1.000 0.000 0.000 0.000
#> GSM559423     1  0.6993     0.5034 0.556 0.248 0.084 0.112 0.000
#> GSM559425     2  0.0000     0.9028 0.000 1.000 0.000 0.000 0.000
#> GSM559426     2  0.0162     0.9012 0.000 0.996 0.000 0.004 0.000
#> GSM559427     2  0.0000     0.9028 0.000 1.000 0.000 0.000 0.000
#> GSM559428     1  0.3586     0.8044 0.828 0.000 0.076 0.096 0.000
#> GSM559429     2  0.2284     0.8263 0.096 0.896 0.000 0.004 0.004
#> GSM559430     2  0.0000     0.9028 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
#> GSM559383     1  0.8099   -0.02214 0.312 0.000 0.184 0.296 NA 0.032
#> GSM559387     3  0.3862    0.67916 0.100 0.000 0.796 0.016 NA 0.000
#> GSM559391     1  0.6137   -0.03583 0.464 0.000 0.048 0.388 NA 0.000
#> GSM559395     3  0.6059    0.44150 0.144 0.000 0.584 0.216 NA 0.000
#> GSM559397     6  0.3025    0.70902 0.000 0.000 0.024 0.000 NA 0.820
#> GSM559401     3  0.1010    0.70331 0.036 0.000 0.960 0.000 NA 0.000
#> GSM559414     3  0.6755    0.37283 0.208 0.000 0.416 0.000 NA 0.052
#> GSM559422     3  0.3140    0.66698 0.000 0.000 0.844 0.024 NA 0.024
#> GSM559424     4  0.5596    0.08709 0.400 0.000 0.028 0.500 NA 0.000
#> GSM559431     2  0.0547    0.86971 0.000 0.980 0.000 0.000 NA 0.000
#> GSM559432     3  0.2932    0.63255 0.000 0.164 0.820 0.000 NA 0.000
#> GSM559381     6  0.1814    0.71236 0.000 0.000 0.000 0.000 NA 0.900
#> GSM559382     6  0.3946    0.61805 0.000 0.000 0.004 0.052 NA 0.752
#> GSM559384     6  0.3331    0.70058 0.004 0.000 0.000 0.044 NA 0.816
#> GSM559385     1  0.2950    0.52229 0.828 0.000 0.000 0.148 NA 0.000
#> GSM559386     6  0.1434    0.70838 0.000 0.000 0.000 0.012 NA 0.940
#> GSM559388     2  0.4317    0.69434 0.012 0.732 0.012 0.212 NA 0.000
#> GSM559389     6  0.1152    0.70553 0.000 0.000 0.000 0.004 NA 0.952
#> GSM559390     4  0.4372    0.44607 0.128 0.000 0.000 0.764 NA 0.060
#> GSM559392     2  0.3807    0.78322 0.000 0.808 0.000 0.048 NA 0.040
#> GSM559393     1  0.6159    0.33500 0.604 0.016 0.008 0.128 NA 0.028
#> GSM559394     1  0.6312    0.32171 0.592 0.004 0.104 0.180 NA 0.000
#> GSM559396     4  0.5457    0.18191 0.000 0.000 0.004 0.544 NA 0.328
#> GSM559398     2  0.1867    0.84738 0.000 0.916 0.000 0.020 NA 0.000
#> GSM559399     4  0.4273    0.27385 0.380 0.000 0.000 0.596 NA 0.000
#> GSM559400     2  0.6916    0.35995 0.004 0.492 0.076 0.252 NA 0.004
#> GSM559402     1  0.6387    0.25743 0.576 0.000 0.000 0.120 NA 0.160
#> GSM559403     1  0.2531    0.51376 0.856 0.000 0.000 0.132 NA 0.000
#> GSM559404     6  0.4784    0.59867 0.032 0.000 0.004 0.012 NA 0.604
#> GSM559405     6  0.3081    0.68298 0.004 0.000 0.000 0.000 NA 0.776
#> GSM559406     4  0.6223   -0.02285 0.044 0.000 0.000 0.468 NA 0.368
#> GSM559407     1  0.1536    0.55510 0.940 0.000 0.000 0.040 NA 0.004
#> GSM559408     6  0.7386    0.06322 0.312 0.000 0.000 0.176 NA 0.360
#> GSM559409     1  0.3637    0.51280 0.820 0.000 0.000 0.096 NA 0.032
#> GSM559410     1  0.1592    0.55038 0.940 0.000 0.020 0.008 NA 0.000
#> GSM559411     1  0.2007    0.54555 0.920 0.000 0.012 0.036 NA 0.000
#> GSM559412     6  0.5869    0.54646 0.096 0.000 0.000 0.040 NA 0.540
#> GSM559413     6  0.5512    0.59081 0.064 0.000 0.000 0.044 NA 0.588
#> GSM559415     4  0.5662    0.01208 0.424 0.000 0.004 0.440 NA 0.000
#> GSM559416     4  0.4315    0.33719 0.328 0.000 0.000 0.636 NA 0.000
#> GSM559417     4  0.5911    0.42659 0.112 0.016 0.000 0.636 NA 0.048
#> GSM559418     1  0.8204    0.00974 0.312 0.300 0.000 0.192 NA 0.048
#> GSM559419     4  0.4673    0.46712 0.116 0.000 0.000 0.732 NA 0.028
#> GSM559420     6  0.3384    0.65874 0.000 0.000 0.000 0.068 NA 0.812
#> GSM559421     2  0.0363    0.87109 0.000 0.988 0.000 0.000 NA 0.000
#> GSM559423     6  0.7132    0.20586 0.000 0.212 0.004 0.076 NA 0.392
#> GSM559425     2  0.0146    0.87162 0.000 0.996 0.000 0.000 NA 0.000
#> GSM559426     2  0.1219    0.86045 0.000 0.948 0.000 0.004 NA 0.000
#> GSM559427     2  0.0000    0.87109 0.000 1.000 0.000 0.000 NA 0.000
#> GSM559428     6  0.3078    0.64135 0.000 0.000 0.000 0.012 NA 0.796
#> GSM559429     2  0.3317    0.77871 0.004 0.828 0.000 0.000 NA 0.088
#> GSM559430     2  0.0547    0.87054 0.000 0.980 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-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 disease.state(p) k
#> ATC:NMF 52         0.723848 2
#> ATC:NMF 51         0.032758 3
#> ATC:NMF 41         0.000842 4
#> ATC:NMF 47         0.000059 5
#> ATC:NMF 32         0.000164 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