cola Report for GDS4185

Date: 2019-12-25 21:17:39 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 21168 rows and 67 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] 21168    67

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:skmeans 3 1.000 0.993 0.997 ** 2
CV:skmeans 3 1.000 0.995 0.998 ** 2
CV:mclust 3 1.000 0.979 0.991 ** 2
CV:NMF 3 1.000 0.990 0.996 ** 2
MAD:skmeans 3 1.000 0.995 0.998 ** 2
ATC:hclust 2 1.000 1.000 1.000 **
ATC:kmeans 2 1.000 1.000 1.000 **
ATC:mclust 5 1.000 0.986 0.986 ** 3,4
ATC:pam 5 0.968 0.928 0.971 ** 2,3,4
SD:hclust 4 0.962 0.945 0.971 ** 2,3
MAD:hclust 5 0.961 0.823 0.921 ** 2,3,4
CV:pam 6 0.958 0.941 0.964 ** 2,3,4,5
ATC:NMF 4 0.940 0.890 0.947 * 2,3
SD:pam 5 0.931 0.951 0.954 * 2,3
MAD:mclust 4 0.920 0.955 0.949 * 2,3
CV:hclust 4 0.919 0.885 0.954 * 2,3
MAD:NMF 5 0.919 0.859 0.931 * 3,4
MAD:pam 6 0.917 0.932 0.962 * 3,4,5
SD:mclust 4 0.908 0.939 0.952 * 2,3
ATC:skmeans 5 0.907 0.947 0.898 * 2,3,4
SD:NMF 6 0.906 0.798 0.914 * 2,3
MAD:kmeans 3 0.646 0.932 0.878
SD:kmeans 2 0.552 0.830 0.878
CV:kmeans 2 0.323 0.874 0.896

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

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

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

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

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

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

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

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

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

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

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

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

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

Membership heatmap

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

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

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

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

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

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

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

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

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

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

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

Signature heatmap

Signature heatmaps for all methods. (What is a signature heatmap?)

Note in following heatmaps, rows are scaled.

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

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

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

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

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

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

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

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

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

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

Statistics table

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

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 1.000           1.000       1.000          0.426 0.575   0.575
#> CV:NMF      2 1.000           1.000       1.000          0.426 0.575   0.575
#> MAD:NMF     2 0.561           0.746       0.879          0.468 0.506   0.506
#> ATC:NMF     2 1.000           1.000       1.000          0.426 0.575   0.575
#> SD:skmeans  2 1.000           0.977       0.980          0.429 0.575   0.575
#> CV:skmeans  2 1.000           1.000       1.000          0.426 0.575   0.575
#> MAD:skmeans 2 1.000           0.988       0.988          0.474 0.525   0.525
#> ATC:skmeans 2 1.000           1.000       1.000          0.426 0.575   0.575
#> SD:mclust   2 1.000           0.997       0.997          0.426 0.575   0.575
#> CV:mclust   2 1.000           1.000       1.000          0.426 0.575   0.575
#> MAD:mclust  2 1.000           0.997       0.997          0.426 0.575   0.575
#> ATC:mclust  2 0.775           0.952       0.954          0.440 0.563   0.563
#> SD:kmeans   2 0.552           0.830       0.878          0.444 0.575   0.575
#> CV:kmeans   2 0.323           0.874       0.896          0.440 0.575   0.575
#> MAD:kmeans  2 0.552           0.784       0.858          0.447 0.575   0.575
#> ATC:kmeans  2 1.000           1.000       1.000          0.426 0.575   0.575
#> SD:pam      2 1.000           1.000       1.000          0.426 0.575   0.575
#> CV:pam      2 1.000           1.000       1.000          0.426 0.575   0.575
#> MAD:pam     2 0.569           0.902       0.936          0.447 0.563   0.563
#> ATC:pam     2 1.000           1.000       1.000          0.426 0.575   0.575
#> SD:hclust   2 1.000           1.000       1.000          0.426 0.575   0.575
#> CV:hclust   2 1.000           1.000       1.000          0.426 0.575   0.575
#> MAD:hclust  2 1.000           0.982       0.984          0.428 0.575   0.575
#> ATC:hclust  2 1.000           1.000       1.000          0.426 0.575   0.575
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 1.000           0.983       0.994          0.586 0.750   0.566
#> CV:NMF      3 1.000           0.990       0.996          0.586 0.750   0.566
#> MAD:NMF     3 1.000           0.979       0.993          0.442 0.750   0.538
#> ATC:NMF     3 0.941           0.978       0.976          0.563 0.751   0.567
#> SD:skmeans  3 1.000           0.993       0.997          0.575 0.750   0.566
#> CV:skmeans  3 1.000           0.995       0.998          0.586 0.750   0.566
#> MAD:skmeans 3 1.000           0.995       0.998          0.425 0.780   0.589
#> ATC:skmeans 3 1.000           1.000       1.000          0.584 0.751   0.567
#> SD:mclust   3 1.000           0.972       0.989          0.584 0.750   0.566
#> CV:mclust   3 1.000           0.979       0.991          0.585 0.750   0.566
#> MAD:mclust  3 1.000           0.990       0.995          0.585 0.750   0.566
#> ATC:mclust  3 1.000           1.000       1.000          0.534 0.744   0.553
#> SD:kmeans   3 0.709           0.932       0.857          0.401 0.750   0.566
#> CV:kmeans   3 0.651           0.941       0.850          0.409 0.750   0.566
#> MAD:kmeans  3 0.646           0.932       0.878          0.428 0.750   0.566
#> ATC:kmeans  3 0.688           0.938       0.869          0.470 0.751   0.567
#> SD:pam      3 1.000           0.975       0.990          0.585 0.751   0.567
#> CV:pam      3 1.000           0.987       0.994          0.584 0.751   0.567
#> MAD:pam     3 1.000           0.996       0.998          0.508 0.744   0.553
#> ATC:pam     3 1.000           0.998       0.999          0.584 0.751   0.567
#> SD:hclust   3 1.000           0.970       0.988          0.585 0.750   0.566
#> CV:hclust   3 1.000           0.986       0.994          0.586 0.750   0.566
#> MAD:hclust  3 1.000           0.962       0.986          0.576 0.750   0.566
#> ATC:hclust  3 0.623           0.864       0.865          0.432 0.791   0.637
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.936           0.883       0.954         0.0383 0.990   0.968
#> CV:NMF      4 0.909           0.911       0.934         0.0532 1.000   1.000
#> MAD:NMF     4 0.912           0.825       0.933         0.0505 0.970   0.910
#> ATC:NMF     4 0.940           0.890       0.947         0.0549 0.982   0.945
#> SD:skmeans  4 0.880           0.948       0.921         0.0803 0.940   0.816
#> CV:skmeans  4 0.881           0.954       0.934         0.0954 0.935   0.800
#> MAD:skmeans 4 0.881           0.952       0.931         0.0887 0.940   0.816
#> ATC:skmeans 4 1.000           0.989       0.990         0.0829 0.945   0.832
#> SD:mclust   4 0.908           0.939       0.952         0.0505 0.980   0.939
#> CV:mclust   4 0.877           0.854       0.881         0.0682 0.980   0.939
#> MAD:mclust  4 0.920           0.955       0.949         0.0443 0.980   0.939
#> ATC:mclust  4 1.000           0.994       0.997         0.0670 0.955   0.861
#> SD:kmeans   4 0.820           0.837       0.830         0.1522 0.979   0.938
#> CV:kmeans   4 0.829           0.852       0.822         0.1652 1.000   1.000
#> MAD:kmeans  4 0.817           0.746       0.821         0.1332 0.979   0.936
#> ATC:kmeans  4 0.790           0.841       0.819         0.1376 1.000   1.000
#> SD:pam      4 0.882           0.942       0.918         0.0903 0.930   0.789
#> CV:pam      4 1.000           0.976       0.977         0.0922 0.930   0.789
#> MAD:pam     4 1.000           0.980       0.988         0.0899 0.932   0.795
#> ATC:pam     4 0.900           0.880       0.844         0.0684 0.955   0.861
#> SD:hclust   4 0.962           0.945       0.971         0.0632 0.951   0.850
#> CV:hclust   4 0.919           0.885       0.954         0.0437 0.980   0.939
#> MAD:hclust  4 0.943           0.924       0.962         0.0611 0.951   0.850
#> ATC:hclust  4 0.580           0.858       0.845         0.0759 0.955   0.876
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.931           0.884       0.945         0.0178 0.990   0.967
#> CV:NMF      5 0.883           0.835       0.912         0.0342 0.945   0.830
#> MAD:NMF     5 0.919           0.859       0.931         0.0175 0.980   0.937
#> ATC:NMF     5 0.897           0.837       0.907         0.0387 0.982   0.942
#> SD:skmeans  5 0.885           0.933       0.888         0.0687 0.937   0.761
#> CV:skmeans  5 0.881           0.946       0.905         0.0641 0.941   0.774
#> MAD:skmeans 5 0.887           0.947       0.903         0.0678 0.937   0.761
#> ATC:skmeans 5 0.907           0.947       0.898         0.0600 0.932   0.750
#> SD:mclust   5 0.860           0.756       0.814         0.0674 0.962   0.877
#> CV:mclust   5 0.874           0.864       0.864         0.0828 0.877   0.608
#> MAD:mclust  5 0.886           0.939       0.937         0.0826 0.931   0.774
#> ATC:mclust  5 1.000           0.986       0.986         0.0330 0.979   0.926
#> SD:kmeans   5 0.758           0.632       0.706         0.0566 0.936   0.807
#> CV:kmeans   5 0.804           0.903       0.769         0.0599 0.876   0.619
#> MAD:kmeans  5 0.805           0.858       0.706         0.0666 0.878   0.612
#> ATC:kmeans  5 0.802           0.885       0.774         0.0753 0.877   0.624
#> SD:pam      5 0.931           0.951       0.954         0.0791 0.935   0.755
#> CV:pam      5 0.994           0.966       0.979         0.0843 0.926   0.726
#> MAD:pam     5 0.969           0.957       0.980         0.0872 0.935   0.756
#> ATC:pam     5 0.968           0.928       0.971         0.0715 0.937   0.778
#> SD:hclust   5 0.875           0.873       0.908         0.0378 0.986   0.948
#> CV:hclust   5 0.886           0.767       0.895         0.0419 0.972   0.910
#> MAD:hclust  5 0.961           0.823       0.921         0.0413 0.980   0.926
#> ATC:hclust  5 0.765           0.753       0.844         0.1051 0.972   0.915
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.906           0.798       0.914         0.0283 0.980   0.934
#> CV:NMF      6 0.840           0.855       0.901         0.0284 0.980   0.927
#> MAD:NMF     6 0.883           0.804       0.909         0.0265 0.970   0.903
#> ATC:NMF     6 0.866           0.820       0.905         0.0251 0.960   0.865
#> SD:skmeans  6 0.813           0.884       0.889         0.0359 0.989   0.946
#> CV:skmeans  6 0.845           0.870       0.897         0.0340 0.995   0.975
#> MAD:skmeans 6 0.861           0.856       0.879         0.0401 0.994   0.971
#> ATC:skmeans 6 0.860           0.902       0.877         0.0477 0.989   0.947
#> SD:mclust   6 0.758           0.568       0.736         0.0637 0.894   0.626
#> CV:mclust   6 0.823           0.857       0.854         0.0553 0.944   0.732
#> MAD:mclust  6 0.858           0.942       0.910         0.0832 0.890   0.565
#> ATC:mclust  6 0.893           0.888       0.899         0.1090 0.875   0.541
#> SD:kmeans   6 0.758           0.826       0.765         0.0543 0.892   0.632
#> CV:kmeans   6 0.763           0.671       0.714         0.0469 0.941   0.739
#> MAD:kmeans  6 0.768           0.720       0.772         0.0349 0.961   0.810
#> ATC:kmeans  6 0.810           0.910       0.796         0.0442 0.955   0.778
#> SD:pam      6 0.893           0.807       0.902         0.0467 0.966   0.831
#> CV:pam      6 0.958           0.941       0.964         0.0548 0.955   0.778
#> MAD:pam     6 0.917           0.932       0.962         0.0539 0.955   0.775
#> ATC:pam     6 0.896           0.910       0.926         0.0749 0.924   0.670
#> SD:hclust   6 0.856           0.751       0.851         0.0449 0.925   0.720
#> CV:hclust   6 0.872           0.750       0.849         0.0518 0.929   0.750
#> MAD:hclust  6 0.888           0.909       0.910         0.0551 0.929   0.730
#> ATC:hclust  6 0.843           0.879       0.883         0.1025 0.864   0.575

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) cell.type(p) k
#> SD:NMF      67            0.939     2.75e-14 2
#> CV:NMF      67            0.939     2.75e-14 2
#> MAD:NMF     62            1.000     1.38e-12 2
#> ATC:NMF     67            0.939     2.75e-14 2
#> SD:skmeans  67            0.939     2.75e-14 2
#> CV:skmeans  67            0.939     2.75e-14 2
#> MAD:skmeans 67            1.000     1.40e-13 2
#> ATC:skmeans 67            0.939     2.75e-14 2
#> SD:mclust   67            0.939     2.75e-14 2
#> CV:mclust   67            0.939     2.75e-14 2
#> MAD:mclust  67            0.939     2.75e-14 2
#> ATC:mclust  67            1.000     2.38e-13 2
#> SD:kmeans   67            0.939     2.75e-14 2
#> CV:kmeans   67            0.939     2.75e-14 2
#> MAD:kmeans  67            0.939     2.75e-14 2
#> ATC:kmeans  67            0.939     2.75e-14 2
#> SD:pam      67            0.939     2.75e-14 2
#> CV:pam      67            0.939     2.75e-14 2
#> MAD:pam     66            1.000     3.78e-13 2
#> ATC:pam     67            0.939     2.75e-14 2
#> SD:hclust   67            0.939     2.75e-14 2
#> CV:hclust   67            0.939     2.75e-14 2
#> MAD:hclust  67            0.939     2.75e-14 2
#> ATC:hclust  67            0.939     2.75e-14 2
test_to_known_factors(res_list, k = 3)
#>              n disease.state(p) cell.type(p) k
#> SD:NMF      66            0.920     2.62e-26 3
#> CV:NMF      67            0.927     9.68e-27 3
#> MAD:NMF     66            0.920     2.62e-26 3
#> ATC:NMF     67            0.940     1.87e-24 3
#> SD:skmeans  67            0.864     1.50e-25 3
#> CV:skmeans  67            0.927     9.68e-27 3
#> MAD:skmeans 67            0.864     1.50e-25 3
#> ATC:skmeans 67            0.940     1.87e-24 3
#> SD:mclust   65            0.924     7.14e-26 3
#> CV:mclust   67            0.927     9.68e-27 3
#> MAD:mclust  67            0.927     9.68e-27 3
#> ATC:mclust  67            0.940     1.87e-24 3
#> SD:kmeans   66            0.920     2.62e-26 3
#> CV:kmeans   67            0.927     9.68e-27 3
#> MAD:kmeans  66            0.920     2.62e-26 3
#> ATC:kmeans  67            0.940     1.87e-24 3
#> SD:pam      66            0.881     4.15e-25 3
#> CV:pam      67            0.940     1.87e-24 3
#> MAD:pam     67            0.940     1.87e-24 3
#> ATC:pam     67            0.940     1.87e-24 3
#> SD:hclust   65            0.924     7.14e-26 3
#> CV:hclust   67            0.927     9.68e-27 3
#> MAD:hclust  65            0.924     7.14e-26 3
#> ATC:hclust  67            0.860     4.00e-18 3
test_to_known_factors(res_list, k = 4)
#>              n disease.state(p) cell.type(p) k
#> SD:NMF      64            0.925     1.95e-25 4
#> CV:NMF      67            0.927     9.68e-27 4
#> MAD:NMF     62            0.927     1.47e-24 4
#> ATC:NMF     66            0.672     1.52e-22 4
#> SD:skmeans  67            0.716     4.07e-24 4
#> CV:skmeans  67            0.841     2.78e-25 4
#> MAD:skmeans 67            0.716     4.07e-24 4
#> ATC:skmeans 67            0.958     4.88e-23 4
#> SD:mclust   67            0.975     3.11e-25 4
#> CV:mclust   66            0.977     8.31e-25 4
#> MAD:mclust  67            0.975     3.11e-25 4
#> ATC:mclust  67            0.954     5.58e-23 4
#> SD:kmeans   66            0.920     2.62e-26 4
#> CV:kmeans   67            0.927     9.68e-27 4
#> MAD:kmeans  66            0.835     8.36e-25 4
#> ATC:kmeans  67            0.940     1.87e-24 4
#> SD:pam      67            0.716     4.07e-24 4
#> CV:pam      67            0.716     4.07e-24 4
#> MAD:pam     67            0.517     3.96e-24 4
#> ATC:pam     65            0.921     3.53e-22 4
#> SD:hclust   65            0.120     2.14e-24 4
#> CV:hclust   62            0.584     4.37e-23 4
#> MAD:hclust  65            0.120     2.14e-24 4
#> ATC:hclust  66            0.952     2.70e-16 4
test_to_known_factors(res_list, k = 5)
#>              n disease.state(p) cell.type(p) k
#> SD:NMF      64            0.498     5.95e-24 5
#> CV:NMF      65            0.222     4.59e-23 5
#> MAD:NMF     64            0.312     5.90e-24 5
#> ATC:NMF     62            0.320     7.14e-22 5
#> SD:skmeans  66            0.873     1.56e-23 5
#> CV:skmeans  67            0.933     6.06e-24 5
#> MAD:skmeans 67            0.844     7.80e-23 5
#> ATC:skmeans 67            0.989     7.25e-22 5
#> SD:mclust   65            0.980     4.41e-23 5
#> CV:mclust   64            0.994     1.10e-22 5
#> MAD:mclust  67            0.993     6.72e-24 5
#> ATC:mclust  67            0.981     6.76e-24 5
#> SD:kmeans   59            0.199     8.03e-22 5
#> CV:kmeans   67            0.933     6.06e-24 5
#> MAD:kmeans  64            0.967     1.07e-22 5
#> ATC:kmeans  67            0.989     7.25e-22 5
#> SD:pam      66            0.902     1.97e-22 5
#> CV:pam      67            0.933     6.06e-24 5
#> MAD:pam     67            0.654     7.35e-23 5
#> ATC:pam     64            0.973     1.48e-20 5
#> SD:hclust   62            0.155     4.94e-23 5
#> CV:hclust   54            0.906     6.80e-21 5
#> MAD:hclust  62            0.349     7.86e-22 5
#> ATC:hclust  56            0.949     1.02e-17 5
test_to_known_factors(res_list, k = 6)
#>              n disease.state(p) cell.type(p) k
#> SD:NMF      62           0.5478     3.77e-23 6
#> CV:NMF      66           0.0983     1.72e-23 6
#> MAD:NMF     63           0.4010     1.40e-23 6
#> ATC:NMF     63           0.2492     4.57e-21 6
#> SD:skmeans  65           0.9402     4.03e-23 6
#> CV:skmeans  65           0.9402     4.03e-23 6
#> MAD:skmeans 65           0.9402     4.03e-23 6
#> ATC:skmeans 67           0.7684     1.09e-20 6
#> SD:mclust   49           0.9098     1.37e-16 6
#> CV:mclust   64           0.9944     1.71e-21 6
#> MAD:mclust  67           0.9958     1.02e-22 6
#> ATC:mclust  65           0.9960     6.69e-22 6
#> SD:kmeans   66           0.8732     1.56e-23 6
#> CV:kmeans   61           0.9709     2.17e-21 6
#> MAD:kmeans  58           0.9756     5.56e-19 6
#> ATC:kmeans  67           0.9915     1.09e-20 6
#> SD:pam      59           0.8787     2.16e-18 6
#> CV:pam      67           0.9022     9.88e-23 6
#> MAD:pam     67           0.7529     1.15e-21 6
#> ATC:pam     64           0.9921     1.60e-19 6
#> SD:hclust   49           0.2267     6.56e-19 6
#> CV:hclust   57           0.6357     1.22e-19 6
#> MAD:hclust  65           0.1713     6.54e-22 6
#> ATC:hclust  66           0.7353     4.86e-15 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 21168 rows and 67 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 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 SD-hclust-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4257 0.575   0.575
#> 3 3 1.000           0.970       0.988         0.5851 0.750   0.566
#> 4 4 0.962           0.945       0.971         0.0632 0.951   0.850
#> 5 5 0.875           0.873       0.908         0.0378 0.986   0.948
#> 6 6 0.856           0.751       0.851         0.0449 0.925   0.720

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM260888     2       0          1  0  1
#> GSM260893     2       0          1  0  1
#> GSM260896     2       0          1  0  1
#> GSM260899     2       0          1  0  1
#> GSM260902     2       0          1  0  1
#> GSM260905     2       0          1  0  1
#> GSM260908     2       0          1  0  1
#> GSM260911     2       0          1  0  1
#> GSM260912     2       0          1  0  1
#> GSM260913     1       0          1  1  0
#> GSM260886     1       0          1  1  0
#> GSM260889     1       0          1  1  0
#> GSM260891     1       0          1  1  0
#> GSM260894     1       0          1  1  0
#> GSM260897     1       0          1  1  0
#> GSM260900     1       0          1  1  0
#> GSM260903     1       0          1  1  0
#> GSM260906     1       0          1  1  0
#> GSM260909     1       0          1  1  0
#> GSM260887     1       0          1  1  0
#> GSM260890     1       0          1  1  0
#> GSM260892     1       0          1  1  0
#> GSM260895     1       0          1  1  0
#> GSM260898     1       0          1  1  0
#> GSM260901     1       0          1  1  0
#> GSM260904     1       0          1  1  0
#> GSM260907     1       0          1  1  0
#> GSM260910     1       0          1  1  0
#> GSM260918     2       0          1  0  1
#> GSM260921     2       0          1  0  1
#> GSM260924     2       0          1  0  1
#> GSM260929     2       0          1  0  1
#> GSM260932     2       0          1  0  1
#> GSM260935     2       0          1  0  1
#> GSM260938     2       0          1  0  1
#> GSM260941     2       0          1  0  1
#> GSM260944     2       0          1  0  1
#> GSM260947     2       0          1  0  1
#> GSM260952     2       0          1  0  1
#> GSM260914     1       0          1  1  0
#> GSM260916     1       0          1  1  0
#> GSM260919     1       0          1  1  0
#> GSM260922     1       0          1  1  0
#> GSM260925     1       0          1  1  0
#> GSM260927     1       0          1  1  0
#> GSM260930     1       0          1  1  0
#> GSM260933     1       0          1  1  0
#> GSM260936     1       0          1  1  0
#> GSM260939     1       0          1  1  0
#> GSM260942     1       0          1  1  0
#> GSM260945     1       0          1  1  0
#> GSM260948     1       0          1  1  0
#> GSM260950     1       0          1  1  0
#> GSM260915     1       0          1  1  0
#> GSM260917     1       0          1  1  0
#> GSM260920     1       0          1  1  0
#> GSM260923     1       0          1  1  0
#> GSM260926     1       0          1  1  0
#> GSM260928     1       0          1  1  0
#> GSM260931     1       0          1  1  0
#> GSM260934     1       0          1  1  0
#> GSM260937     1       0          1  1  0
#> GSM260940     1       0          1  1  0
#> GSM260943     1       0          1  1  0
#> GSM260946     1       0          1  1  0
#> GSM260949     1       0          1  1  0
#> GSM260951     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM260888     2   0.000      1.000 0.000  1 0.000
#> GSM260893     2   0.000      1.000 0.000  1 0.000
#> GSM260896     2   0.000      1.000 0.000  1 0.000
#> GSM260899     2   0.000      1.000 0.000  1 0.000
#> GSM260902     2   0.000      1.000 0.000  1 0.000
#> GSM260905     2   0.000      1.000 0.000  1 0.000
#> GSM260908     2   0.000      1.000 0.000  1 0.000
#> GSM260911     2   0.000      1.000 0.000  1 0.000
#> GSM260912     2   0.000      1.000 0.000  1 0.000
#> GSM260913     3   0.000      0.965 0.000  0 1.000
#> GSM260886     1   0.000      1.000 1.000  0 0.000
#> GSM260889     1   0.000      1.000 1.000  0 0.000
#> GSM260891     1   0.000      1.000 1.000  0 0.000
#> GSM260894     1   0.000      1.000 1.000  0 0.000
#> GSM260897     1   0.000      1.000 1.000  0 0.000
#> GSM260900     1   0.000      1.000 1.000  0 0.000
#> GSM260903     1   0.000      1.000 1.000  0 0.000
#> GSM260906     1   0.000      1.000 1.000  0 0.000
#> GSM260909     1   0.000      1.000 1.000  0 0.000
#> GSM260887     3   0.000      0.965 0.000  0 1.000
#> GSM260890     3   0.000      0.965 0.000  0 1.000
#> GSM260892     3   0.000      0.965 0.000  0 1.000
#> GSM260895     3   0.597      0.447 0.364  0 0.636
#> GSM260898     3   0.000      0.965 0.000  0 1.000
#> GSM260901     3   0.000      0.965 0.000  0 1.000
#> GSM260904     3   0.000      0.965 0.000  0 1.000
#> GSM260907     3   0.000      0.965 0.000  0 1.000
#> GSM260910     3   0.000      0.965 0.000  0 1.000
#> GSM260918     2   0.000      1.000 0.000  1 0.000
#> GSM260921     2   0.000      1.000 0.000  1 0.000
#> GSM260924     2   0.000      1.000 0.000  1 0.000
#> GSM260929     2   0.000      1.000 0.000  1 0.000
#> GSM260932     2   0.000      1.000 0.000  1 0.000
#> GSM260935     2   0.000      1.000 0.000  1 0.000
#> GSM260938     2   0.000      1.000 0.000  1 0.000
#> GSM260941     2   0.000      1.000 0.000  1 0.000
#> GSM260944     2   0.000      1.000 0.000  1 0.000
#> GSM260947     2   0.000      1.000 0.000  1 0.000
#> GSM260952     2   0.000      1.000 0.000  1 0.000
#> GSM260914     1   0.000      1.000 1.000  0 0.000
#> GSM260916     1   0.000      1.000 1.000  0 0.000
#> GSM260919     1   0.000      1.000 1.000  0 0.000
#> GSM260922     1   0.000      1.000 1.000  0 0.000
#> GSM260925     1   0.000      1.000 1.000  0 0.000
#> GSM260927     1   0.000      1.000 1.000  0 0.000
#> GSM260930     1   0.000      1.000 1.000  0 0.000
#> GSM260933     1   0.000      1.000 1.000  0 0.000
#> GSM260936     1   0.000      1.000 1.000  0 0.000
#> GSM260939     1   0.000      1.000 1.000  0 0.000
#> GSM260942     1   0.000      1.000 1.000  0 0.000
#> GSM260945     1   0.000      1.000 1.000  0 0.000
#> GSM260948     1   0.000      1.000 1.000  0 0.000
#> GSM260950     1   0.000      1.000 1.000  0 0.000
#> GSM260915     3   0.000      0.965 0.000  0 1.000
#> GSM260917     3   0.000      0.965 0.000  0 1.000
#> GSM260920     3   0.000      0.965 0.000  0 1.000
#> GSM260923     3   0.000      0.965 0.000  0 1.000
#> GSM260926     3   0.000      0.965 0.000  0 1.000
#> GSM260928     3   0.618      0.318 0.416  0 0.584
#> GSM260931     3   0.000      0.965 0.000  0 1.000
#> GSM260934     3   0.000      0.965 0.000  0 1.000
#> GSM260937     3   0.000      0.965 0.000  0 1.000
#> GSM260940     3   0.000      0.965 0.000  0 1.000
#> GSM260943     3   0.000      0.965 0.000  0 1.000
#> GSM260946     3   0.000      0.965 0.000  0 1.000
#> GSM260949     3   0.000      0.965 0.000  0 1.000
#> GSM260951     3   0.000      0.965 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM260888     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260893     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260896     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260899     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260902     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260905     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260908     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260911     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260912     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260913     3  0.0000      0.901 0.000  0 1.000 0.000
#> GSM260886     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260889     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260891     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260894     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260897     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260900     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260903     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260906     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260909     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260887     3  0.0000      0.901 0.000  0 1.000 0.000
#> GSM260890     3  0.0000      0.901 0.000  0 1.000 0.000
#> GSM260892     3  0.0000      0.901 0.000  0 1.000 0.000
#> GSM260895     3  0.4730      0.399 0.364  0 0.636 0.000
#> GSM260898     3  0.1211      0.880 0.000  0 0.960 0.040
#> GSM260901     3  0.1211      0.880 0.000  0 0.960 0.040
#> GSM260904     3  0.0336      0.900 0.000  0 0.992 0.008
#> GSM260907     3  0.0336      0.900 0.000  0 0.992 0.008
#> GSM260910     3  0.0000      0.901 0.000  0 1.000 0.000
#> GSM260918     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260921     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260924     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260929     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260932     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260935     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260938     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260941     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260944     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260947     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260952     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260914     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260916     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260919     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260922     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260925     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260927     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260930     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260933     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260936     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260939     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260942     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260945     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260948     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260950     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260915     3  0.0000      0.901 0.000  0 1.000 0.000
#> GSM260917     3  0.3873      0.615 0.000  0 0.772 0.228
#> GSM260920     3  0.0336      0.900 0.000  0 0.992 0.008
#> GSM260923     3  0.0000      0.901 0.000  0 1.000 0.000
#> GSM260926     3  0.0000      0.901 0.000  0 1.000 0.000
#> GSM260928     3  0.4898      0.324 0.416  0 0.584 0.000
#> GSM260931     4  0.2921      0.947 0.000  0 0.140 0.860
#> GSM260934     3  0.1211      0.880 0.000  0 0.960 0.040
#> GSM260937     4  0.0000      0.831 0.000  0 0.000 1.000
#> GSM260940     4  0.3444      0.916 0.000  0 0.184 0.816
#> GSM260943     4  0.2921      0.947 0.000  0 0.140 0.860
#> GSM260946     4  0.3311      0.926 0.000  0 0.172 0.828
#> GSM260949     3  0.0336      0.900 0.000  0 0.992 0.008
#> GSM260951     4  0.2921      0.947 0.000  0 0.140 0.860

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM260888     2  0.0510      0.931 0.000 0.984 0.000 0.016 0.000
#> GSM260893     2  0.0510      0.931 0.000 0.984 0.000 0.016 0.000
#> GSM260896     2  0.0510      0.931 0.000 0.984 0.000 0.016 0.000
#> GSM260899     2  0.2329      0.935 0.000 0.876 0.000 0.124 0.000
#> GSM260902     2  0.2329      0.935 0.000 0.876 0.000 0.124 0.000
#> GSM260905     2  0.2329      0.935 0.000 0.876 0.000 0.124 0.000
#> GSM260908     2  0.2329      0.935 0.000 0.876 0.000 0.124 0.000
#> GSM260911     2  0.0510      0.931 0.000 0.984 0.000 0.016 0.000
#> GSM260912     2  0.0000      0.935 0.000 1.000 0.000 0.000 0.000
#> GSM260913     3  0.4126      0.465 0.000 0.000 0.620 0.380 0.000
#> GSM260886     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260891     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260894     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260897     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260900     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260903     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260906     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260909     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260887     3  0.0000      0.721 0.000 0.000 1.000 0.000 0.000
#> GSM260890     3  0.0000      0.721 0.000 0.000 1.000 0.000 0.000
#> GSM260892     3  0.4126      0.465 0.000 0.000 0.620 0.380 0.000
#> GSM260895     4  0.5500      0.778 0.072 0.000 0.376 0.552 0.000
#> GSM260898     3  0.2871      0.651 0.000 0.000 0.872 0.088 0.040
#> GSM260901     3  0.2871      0.651 0.000 0.000 0.872 0.088 0.040
#> GSM260904     3  0.2136      0.672 0.000 0.000 0.904 0.088 0.008
#> GSM260907     3  0.2136      0.672 0.000 0.000 0.904 0.088 0.008
#> GSM260910     3  0.0404      0.718 0.000 0.000 0.988 0.012 0.000
#> GSM260918     2  0.0000      0.935 0.000 1.000 0.000 0.000 0.000
#> GSM260921     2  0.0290      0.933 0.000 0.992 0.000 0.008 0.000
#> GSM260924     2  0.0510      0.931 0.000 0.984 0.000 0.016 0.000
#> GSM260929     2  0.0000      0.935 0.000 1.000 0.000 0.000 0.000
#> GSM260932     2  0.2329      0.935 0.000 0.876 0.000 0.124 0.000
#> GSM260935     2  0.2329      0.935 0.000 0.876 0.000 0.124 0.000
#> GSM260938     2  0.2329      0.935 0.000 0.876 0.000 0.124 0.000
#> GSM260941     2  0.2329      0.935 0.000 0.876 0.000 0.124 0.000
#> GSM260944     2  0.2329      0.935 0.000 0.876 0.000 0.124 0.000
#> GSM260947     2  0.2329      0.935 0.000 0.876 0.000 0.124 0.000
#> GSM260952     2  0.0162      0.935 0.000 0.996 0.000 0.004 0.000
#> GSM260914     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260916     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260919     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260922     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260925     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260927     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260930     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260933     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260936     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260939     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260942     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260945     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260948     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260950     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM260915     3  0.0000      0.721 0.000 0.000 1.000 0.000 0.000
#> GSM260917     3  0.3336      0.450 0.000 0.000 0.772 0.000 0.228
#> GSM260920     3  0.4392      0.464 0.000 0.000 0.612 0.380 0.008
#> GSM260923     3  0.1792      0.679 0.000 0.000 0.916 0.084 0.000
#> GSM260926     3  0.0000      0.721 0.000 0.000 1.000 0.000 0.000
#> GSM260928     4  0.6077      0.794 0.124 0.000 0.396 0.480 0.000
#> GSM260931     5  0.2516      0.933 0.000 0.000 0.140 0.000 0.860
#> GSM260934     3  0.2871      0.651 0.000 0.000 0.872 0.088 0.040
#> GSM260937     5  0.0000      0.761 0.000 0.000 0.000 0.000 1.000
#> GSM260940     5  0.2966      0.887 0.000 0.000 0.184 0.000 0.816
#> GSM260943     5  0.2516      0.933 0.000 0.000 0.140 0.000 0.860
#> GSM260946     5  0.3327      0.914 0.000 0.000 0.144 0.028 0.828
#> GSM260949     3  0.4354      0.475 0.000 0.000 0.624 0.368 0.008
#> GSM260951     5  0.2516      0.933 0.000 0.000 0.140 0.000 0.860

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM260888     2  0.2823     0.8452 0.000 0.796 0.000 0.000 0.000 0.204
#> GSM260893     2  0.2883     0.8480 0.000 0.788 0.000 0.000 0.000 0.212
#> GSM260896     2  0.2883     0.8480 0.000 0.788 0.000 0.000 0.000 0.212
#> GSM260899     6  0.0000     0.9652 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM260902     6  0.0000     0.9652 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM260905     6  0.2048     0.8454 0.000 0.120 0.000 0.000 0.000 0.880
#> GSM260908     6  0.2048     0.8454 0.000 0.120 0.000 0.000 0.000 0.880
#> GSM260911     2  0.2823     0.8452 0.000 0.796 0.000 0.000 0.000 0.204
#> GSM260912     2  0.3717     0.7951 0.000 0.616 0.000 0.000 0.000 0.384
#> GSM260913     4  0.1141     0.4012 0.000 0.000 0.000 0.948 0.052 0.000
#> GSM260886     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260891     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260894     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260897     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260900     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260903     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260906     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260909     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260887     4  0.3756     0.1736 0.000 0.000 0.000 0.600 0.400 0.000
#> GSM260890     4  0.3747     0.1861 0.000 0.000 0.000 0.604 0.396 0.000
#> GSM260892     4  0.1141     0.4012 0.000 0.000 0.000 0.948 0.052 0.000
#> GSM260895     5  0.2404     0.1454 0.016 0.000 0.000 0.112 0.872 0.000
#> GSM260898     5  0.4532     0.2786 0.000 0.000 0.032 0.468 0.500 0.000
#> GSM260901     5  0.4532     0.2786 0.000 0.000 0.032 0.468 0.500 0.000
#> GSM260904     5  0.3869     0.2024 0.000 0.000 0.000 0.500 0.500 0.000
#> GSM260907     5  0.3869     0.2024 0.000 0.000 0.000 0.500 0.500 0.000
#> GSM260910     4  0.3747     0.2031 0.000 0.000 0.000 0.604 0.396 0.000
#> GSM260918     2  0.3717     0.7951 0.000 0.616 0.000 0.000 0.000 0.384
#> GSM260921     2  0.3309     0.8395 0.000 0.720 0.000 0.000 0.000 0.280
#> GSM260924     2  0.0000     0.6493 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260929     2  0.3717     0.7951 0.000 0.616 0.000 0.000 0.000 0.384
#> GSM260932     6  0.0000     0.9652 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM260935     6  0.0000     0.9652 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM260938     6  0.0000     0.9652 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM260941     6  0.0000     0.9652 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM260944     6  0.0000     0.9652 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM260947     6  0.0000     0.9652 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM260952     2  0.3756     0.7749 0.000 0.600 0.000 0.000 0.000 0.400
#> GSM260914     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260916     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260919     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260922     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260925     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260927     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260930     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260933     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260936     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260939     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260942     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260945     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260948     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260950     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260915     4  0.3747     0.1861 0.000 0.000 0.000 0.604 0.396 0.000
#> GSM260917     4  0.5934     0.0272 0.000 0.000 0.228 0.444 0.328 0.000
#> GSM260920     4  0.0363     0.4185 0.000 0.000 0.000 0.988 0.012 0.000
#> GSM260923     4  0.3592     0.2757 0.000 0.000 0.000 0.656 0.344 0.000
#> GSM260926     4  0.3747     0.1861 0.000 0.000 0.000 0.604 0.396 0.000
#> GSM260928     5  0.1387     0.2023 0.068 0.000 0.000 0.000 0.932 0.000
#> GSM260931     3  0.2260     0.9374 0.000 0.000 0.860 0.140 0.000 0.000
#> GSM260934     5  0.4532     0.2786 0.000 0.000 0.032 0.468 0.500 0.000
#> GSM260937     3  0.0000     0.7987 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260940     3  0.2664     0.8958 0.000 0.000 0.816 0.184 0.000 0.000
#> GSM260943     3  0.2260     0.9374 0.000 0.000 0.860 0.140 0.000 0.000
#> GSM260946     3  0.3134     0.9163 0.000 0.000 0.820 0.144 0.036 0.000
#> GSM260949     4  0.0547     0.4219 0.000 0.000 0.000 0.980 0.020 0.000
#> GSM260951     3  0.2260     0.9374 0.000 0.000 0.860 0.140 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-hclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-hclust-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>            n disease.state(p) cell.type(p) k
#> SD:hclust 67            0.939     2.75e-14 2
#> SD:hclust 65            0.924     7.14e-26 3
#> SD:hclust 65            0.120     2.14e-24 4
#> SD:hclust 62            0.155     4.94e-23 5
#> SD:hclust 49            0.227     6.56e-19 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 21168 rows and 67 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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.552           0.830       0.878         0.4438 0.575   0.575
#> 3 3 0.709           0.932       0.857         0.4013 0.750   0.566
#> 4 4 0.820           0.837       0.830         0.1522 0.979   0.938
#> 5 5 0.758           0.632       0.706         0.0566 0.936   0.807
#> 6 6 0.758           0.826       0.765         0.0543 0.892   0.632

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
#> GSM260888     2   0.000      1.000 0.000 1.000
#> GSM260893     2   0.000      1.000 0.000 1.000
#> GSM260896     2   0.000      1.000 0.000 1.000
#> GSM260899     2   0.000      1.000 0.000 1.000
#> GSM260902     2   0.000      1.000 0.000 1.000
#> GSM260905     2   0.000      1.000 0.000 1.000
#> GSM260908     2   0.000      1.000 0.000 1.000
#> GSM260911     2   0.000      1.000 0.000 1.000
#> GSM260912     2   0.000      1.000 0.000 1.000
#> GSM260913     1   0.904      0.717 0.680 0.320
#> GSM260886     1   0.278      0.795 0.952 0.048
#> GSM260889     1   0.278      0.795 0.952 0.048
#> GSM260891     1   0.278      0.795 0.952 0.048
#> GSM260894     1   0.278      0.795 0.952 0.048
#> GSM260897     1   0.278      0.795 0.952 0.048
#> GSM260900     1   0.278      0.795 0.952 0.048
#> GSM260903     1   0.278      0.795 0.952 0.048
#> GSM260906     1   0.278      0.795 0.952 0.048
#> GSM260909     1   0.278      0.795 0.952 0.048
#> GSM260887     1   0.904      0.717 0.680 0.320
#> GSM260890     1   0.904      0.717 0.680 0.320
#> GSM260892     1   0.904      0.717 0.680 0.320
#> GSM260895     1   0.000      0.781 1.000 0.000
#> GSM260898     1   0.904      0.717 0.680 0.320
#> GSM260901     1   0.904      0.717 0.680 0.320
#> GSM260904     1   0.904      0.717 0.680 0.320
#> GSM260907     1   0.904      0.717 0.680 0.320
#> GSM260910     1   0.904      0.717 0.680 0.320
#> GSM260918     2   0.000      1.000 0.000 1.000
#> GSM260921     2   0.000      1.000 0.000 1.000
#> GSM260924     2   0.000      1.000 0.000 1.000
#> GSM260929     2   0.000      1.000 0.000 1.000
#> GSM260932     2   0.000      1.000 0.000 1.000
#> GSM260935     2   0.000      1.000 0.000 1.000
#> GSM260938     2   0.000      1.000 0.000 1.000
#> GSM260941     2   0.000      1.000 0.000 1.000
#> GSM260944     2   0.000      1.000 0.000 1.000
#> GSM260947     2   0.000      1.000 0.000 1.000
#> GSM260952     2   0.000      1.000 0.000 1.000
#> GSM260914     1   0.278      0.795 0.952 0.048
#> GSM260916     1   0.278      0.795 0.952 0.048
#> GSM260919     1   0.278      0.795 0.952 0.048
#> GSM260922     1   0.278      0.795 0.952 0.048
#> GSM260925     1   0.278      0.795 0.952 0.048
#> GSM260927     1   0.278      0.795 0.952 0.048
#> GSM260930     1   0.278      0.795 0.952 0.048
#> GSM260933     1   0.278      0.795 0.952 0.048
#> GSM260936     1   0.278      0.795 0.952 0.048
#> GSM260939     1   0.278      0.795 0.952 0.048
#> GSM260942     1   0.278      0.795 0.952 0.048
#> GSM260945     1   0.278      0.795 0.952 0.048
#> GSM260948     1   0.278      0.795 0.952 0.048
#> GSM260950     1   0.278      0.795 0.952 0.048
#> GSM260915     1   0.904      0.717 0.680 0.320
#> GSM260917     1   0.904      0.717 0.680 0.320
#> GSM260920     1   0.904      0.717 0.680 0.320
#> GSM260923     1   0.904      0.717 0.680 0.320
#> GSM260926     1   0.904      0.717 0.680 0.320
#> GSM260928     1   0.000      0.781 1.000 0.000
#> GSM260931     1   0.904      0.717 0.680 0.320
#> GSM260934     1   0.904      0.717 0.680 0.320
#> GSM260937     1   0.904      0.717 0.680 0.320
#> GSM260940     1   0.904      0.717 0.680 0.320
#> GSM260943     1   0.904      0.717 0.680 0.320
#> GSM260946     1   0.904      0.717 0.680 0.320
#> GSM260949     1   0.904      0.717 0.680 0.320
#> GSM260951     1   0.904      0.717 0.680 0.320

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM260888     2  0.0424      0.947 0.008 0.992 0.000
#> GSM260893     2  0.0424      0.947 0.008 0.992 0.000
#> GSM260896     2  0.0424      0.947 0.008 0.992 0.000
#> GSM260899     2  0.4178      0.926 0.172 0.828 0.000
#> GSM260902     2  0.4178      0.926 0.172 0.828 0.000
#> GSM260905     2  0.3192      0.945 0.112 0.888 0.000
#> GSM260908     2  0.3192      0.945 0.112 0.888 0.000
#> GSM260911     2  0.0424      0.947 0.008 0.992 0.000
#> GSM260912     2  0.0747      0.948 0.016 0.984 0.000
#> GSM260913     3  0.2774      0.955 0.008 0.072 0.920
#> GSM260886     1  0.5327      0.962 0.728 0.000 0.272
#> GSM260889     1  0.5327      0.962 0.728 0.000 0.272
#> GSM260891     1  0.5465      0.960 0.712 0.000 0.288
#> GSM260894     1  0.5327      0.962 0.728 0.000 0.272
#> GSM260897     1  0.4887      0.955 0.772 0.000 0.228
#> GSM260900     1  0.4750      0.955 0.784 0.000 0.216
#> GSM260903     1  0.4750      0.955 0.784 0.000 0.216
#> GSM260906     1  0.4750      0.955 0.784 0.000 0.216
#> GSM260909     1  0.5327      0.962 0.728 0.000 0.272
#> GSM260887     3  0.2774      0.955 0.008 0.072 0.920
#> GSM260890     3  0.2774      0.955 0.008 0.072 0.920
#> GSM260892     3  0.2774      0.955 0.008 0.072 0.920
#> GSM260895     3  0.0661      0.871 0.008 0.004 0.988
#> GSM260898     3  0.2845      0.955 0.012 0.068 0.920
#> GSM260901     3  0.2845      0.955 0.012 0.068 0.920
#> GSM260904     3  0.2845      0.955 0.012 0.068 0.920
#> GSM260907     3  0.2845      0.955 0.012 0.068 0.920
#> GSM260910     3  0.2774      0.955 0.008 0.072 0.920
#> GSM260918     2  0.1163      0.946 0.028 0.972 0.000
#> GSM260921     2  0.0892      0.946 0.020 0.980 0.000
#> GSM260924     2  0.1163      0.944 0.028 0.972 0.000
#> GSM260929     2  0.0237      0.948 0.004 0.996 0.000
#> GSM260932     2  0.4178      0.926 0.172 0.828 0.000
#> GSM260935     2  0.4178      0.926 0.172 0.828 0.000
#> GSM260938     2  0.3619      0.943 0.136 0.864 0.000
#> GSM260941     2  0.3619      0.943 0.136 0.864 0.000
#> GSM260944     2  0.3619      0.943 0.136 0.864 0.000
#> GSM260947     2  0.3619      0.943 0.136 0.864 0.000
#> GSM260952     2  0.1163      0.946 0.028 0.972 0.000
#> GSM260914     1  0.5327      0.962 0.728 0.000 0.272
#> GSM260916     1  0.5327      0.962 0.728 0.000 0.272
#> GSM260919     1  0.5397      0.962 0.720 0.000 0.280
#> GSM260922     1  0.5327      0.962 0.728 0.000 0.272
#> GSM260925     1  0.5327      0.962 0.728 0.000 0.272
#> GSM260927     1  0.5291      0.963 0.732 0.000 0.268
#> GSM260930     1  0.4887      0.955 0.772 0.000 0.228
#> GSM260933     1  0.4887      0.955 0.772 0.000 0.228
#> GSM260936     1  0.4931      0.954 0.768 0.000 0.232
#> GSM260939     1  0.4931      0.954 0.768 0.000 0.232
#> GSM260942     1  0.4931      0.954 0.768 0.000 0.232
#> GSM260945     1  0.4931      0.954 0.768 0.000 0.232
#> GSM260948     1  0.5363      0.962 0.724 0.000 0.276
#> GSM260950     1  0.5363      0.962 0.724 0.000 0.276
#> GSM260915     3  0.2774      0.955 0.008 0.072 0.920
#> GSM260917     3  0.2261      0.956 0.000 0.068 0.932
#> GSM260920     3  0.2774      0.955 0.008 0.072 0.920
#> GSM260923     3  0.2774      0.955 0.008 0.072 0.920
#> GSM260926     3  0.2774      0.955 0.008 0.072 0.920
#> GSM260928     3  0.6386     -0.336 0.412 0.004 0.584
#> GSM260931     3  0.2845      0.955 0.012 0.068 0.920
#> GSM260934     3  0.2845      0.955 0.012 0.068 0.920
#> GSM260937     3  0.2845      0.955 0.012 0.068 0.920
#> GSM260940     3  0.2845      0.955 0.012 0.068 0.920
#> GSM260943     3  0.2845      0.955 0.012 0.068 0.920
#> GSM260946     3  0.2845      0.955 0.012 0.068 0.920
#> GSM260949     3  0.2774      0.955 0.008 0.072 0.920
#> GSM260951     3  0.2261      0.956 0.000 0.068 0.932

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3 p4
#> GSM260888     2  0.3351     0.9134 0.000 0.844 0.008 NA
#> GSM260893     2  0.3351     0.9134 0.000 0.844 0.008 NA
#> GSM260896     2  0.3351     0.9134 0.000 0.844 0.008 NA
#> GSM260899     2  0.3324     0.8617 0.000 0.852 0.012 NA
#> GSM260902     2  0.3324     0.8617 0.000 0.852 0.012 NA
#> GSM260905     2  0.1510     0.9089 0.000 0.956 0.028 NA
#> GSM260908     2  0.1488     0.9078 0.000 0.956 0.032 NA
#> GSM260911     2  0.3351     0.9134 0.000 0.844 0.008 NA
#> GSM260912     2  0.3351     0.9142 0.000 0.844 0.008 NA
#> GSM260913     3  0.5716     0.8415 0.068 0.000 0.680 NA
#> GSM260886     1  0.0000     0.8317 1.000 0.000 0.000 NA
#> GSM260889     1  0.0000     0.8317 1.000 0.000 0.000 NA
#> GSM260891     1  0.0188     0.8323 0.996 0.000 0.000 NA
#> GSM260894     1  0.0000     0.8317 1.000 0.000 0.000 NA
#> GSM260897     1  0.5252     0.8011 0.644 0.000 0.020 NA
#> GSM260900     1  0.5252     0.8011 0.644 0.000 0.020 NA
#> GSM260903     1  0.5252     0.8011 0.644 0.000 0.020 NA
#> GSM260906     1  0.5252     0.8011 0.644 0.000 0.020 NA
#> GSM260909     1  0.0000     0.8317 1.000 0.000 0.000 NA
#> GSM260887     3  0.5716     0.8415 0.068 0.000 0.680 NA
#> GSM260890     3  0.5716     0.8415 0.068 0.000 0.680 NA
#> GSM260892     3  0.5716     0.8415 0.068 0.000 0.680 NA
#> GSM260895     3  0.7760     0.5634 0.288 0.000 0.436 NA
#> GSM260898     3  0.1762     0.8548 0.048 0.004 0.944 NA
#> GSM260901     3  0.1762     0.8548 0.048 0.004 0.944 NA
#> GSM260904     3  0.1762     0.8548 0.048 0.004 0.944 NA
#> GSM260907     3  0.1909     0.8524 0.048 0.004 0.940 NA
#> GSM260910     3  0.5716     0.8415 0.068 0.000 0.680 NA
#> GSM260918     2  0.3545     0.9126 0.000 0.828 0.008 NA
#> GSM260921     2  0.3625     0.9131 0.000 0.828 0.012 NA
#> GSM260924     2  0.3910     0.9083 0.000 0.820 0.024 NA
#> GSM260929     2  0.3249     0.9142 0.000 0.852 0.008 NA
#> GSM260932     2  0.3324     0.8617 0.000 0.852 0.012 NA
#> GSM260935     2  0.3324     0.8617 0.000 0.852 0.012 NA
#> GSM260938     2  0.1837     0.9049 0.000 0.944 0.028 NA
#> GSM260941     2  0.1837     0.9049 0.000 0.944 0.028 NA
#> GSM260944     2  0.1837     0.9049 0.000 0.944 0.028 NA
#> GSM260947     2  0.1837     0.9049 0.000 0.944 0.028 NA
#> GSM260952     2  0.3853     0.9126 0.000 0.820 0.020 NA
#> GSM260914     1  0.0000     0.8317 1.000 0.000 0.000 NA
#> GSM260916     1  0.0188     0.8316 0.996 0.004 0.000 NA
#> GSM260919     1  0.1940     0.8341 0.924 0.000 0.000 NA
#> GSM260922     1  0.0188     0.8316 0.996 0.004 0.000 NA
#> GSM260925     1  0.0000     0.8317 1.000 0.000 0.000 NA
#> GSM260927     1  0.0707     0.8339 0.980 0.000 0.000 NA
#> GSM260930     1  0.5252     0.8011 0.644 0.000 0.020 NA
#> GSM260933     1  0.5252     0.8011 0.644 0.000 0.020 NA
#> GSM260936     1  0.5306     0.7980 0.632 0.000 0.020 NA
#> GSM260939     1  0.5306     0.7980 0.632 0.000 0.020 NA
#> GSM260942     1  0.5306     0.7980 0.632 0.000 0.020 NA
#> GSM260945     1  0.5306     0.7980 0.632 0.000 0.020 NA
#> GSM260948     1  0.2081     0.8341 0.916 0.000 0.000 NA
#> GSM260950     1  0.2081     0.8341 0.916 0.000 0.000 NA
#> GSM260915     3  0.5716     0.8415 0.068 0.000 0.680 NA
#> GSM260917     3  0.1807     0.8542 0.052 0.000 0.940 NA
#> GSM260920     3  0.5716     0.8415 0.068 0.000 0.680 NA
#> GSM260923     3  0.5716     0.8415 0.068 0.000 0.680 NA
#> GSM260926     3  0.5716     0.8415 0.068 0.000 0.680 NA
#> GSM260928     1  0.7256     0.0761 0.540 0.000 0.256 NA
#> GSM260931     3  0.2946     0.8411 0.048 0.004 0.900 NA
#> GSM260934     3  0.1576     0.8542 0.048 0.004 0.948 NA
#> GSM260937     3  0.2946     0.8411 0.048 0.004 0.900 NA
#> GSM260940     3  0.2946     0.8411 0.048 0.004 0.900 NA
#> GSM260943     3  0.2946     0.8411 0.048 0.004 0.900 NA
#> GSM260946     3  0.2946     0.8411 0.048 0.004 0.900 NA
#> GSM260949     3  0.5716     0.8415 0.068 0.000 0.680 NA
#> GSM260951     3  0.2844     0.8433 0.052 0.000 0.900 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4 p5
#> GSM260888     2  0.4029      0.838 0.000 0.680 0.004 0.000 NA
#> GSM260893     2  0.3895      0.838 0.000 0.680 0.000 0.000 NA
#> GSM260896     2  0.3895      0.838 0.000 0.680 0.000 0.000 NA
#> GSM260899     2  0.4612      0.765 0.000 0.756 0.004 0.116 NA
#> GSM260902     2  0.4612      0.765 0.000 0.756 0.004 0.116 NA
#> GSM260905     2  0.1764      0.837 0.000 0.928 0.000 0.008 NA
#> GSM260908     2  0.1331      0.832 0.000 0.952 0.000 0.008 NA
#> GSM260911     2  0.3895      0.838 0.000 0.680 0.000 0.000 NA
#> GSM260912     2  0.3861      0.843 0.000 0.728 0.008 0.000 NA
#> GSM260913     3  0.1978      0.584 0.044 0.000 0.928 0.004 NA
#> GSM260886     1  0.0000      0.768 1.000 0.000 0.000 0.000 NA
#> GSM260889     1  0.0000      0.768 1.000 0.000 0.000 0.000 NA
#> GSM260891     1  0.1205      0.766 0.956 0.000 0.000 0.004 NA
#> GSM260894     1  0.1043      0.765 0.960 0.000 0.000 0.000 NA
#> GSM260897     1  0.6410      0.736 0.496 0.000 0.000 0.304 NA
#> GSM260900     1  0.6420      0.736 0.496 0.000 0.000 0.300 NA
#> GSM260903     1  0.6420      0.736 0.496 0.000 0.000 0.300 NA
#> GSM260906     1  0.6420      0.736 0.496 0.000 0.000 0.300 NA
#> GSM260909     1  0.1043      0.765 0.960 0.000 0.000 0.000 NA
#> GSM260887     3  0.1408      0.589 0.044 0.000 0.948 0.000 NA
#> GSM260890     3  0.1408      0.589 0.044 0.000 0.948 0.000 NA
#> GSM260892     3  0.1978      0.584 0.044 0.000 0.928 0.004 NA
#> GSM260895     3  0.5347      0.337 0.168 0.000 0.684 0.004 NA
#> GSM260898     3  0.5608     -0.565 0.028 0.000 0.560 0.380 NA
#> GSM260901     3  0.5608     -0.565 0.028 0.000 0.560 0.380 NA
#> GSM260904     3  0.5725     -0.553 0.028 0.000 0.560 0.372 NA
#> GSM260907     3  0.5627     -0.594 0.028 0.000 0.552 0.388 NA
#> GSM260910     3  0.1282      0.589 0.044 0.000 0.952 0.000 NA
#> GSM260918     2  0.4025      0.840 0.000 0.700 0.008 0.000 NA
#> GSM260921     2  0.3949      0.840 0.000 0.668 0.000 0.000 NA
#> GSM260924     2  0.5367      0.836 0.000 0.672 0.024 0.056 NA
#> GSM260929     2  0.3885      0.843 0.000 0.724 0.008 0.000 NA
#> GSM260932     2  0.4745      0.765 0.000 0.756 0.012 0.108 NA
#> GSM260935     2  0.4612      0.765 0.000 0.756 0.004 0.116 NA
#> GSM260938     2  0.1608      0.820 0.000 0.928 0.000 0.000 NA
#> GSM260941     2  0.1608      0.820 0.000 0.928 0.000 0.000 NA
#> GSM260944     2  0.1608      0.820 0.000 0.928 0.000 0.000 NA
#> GSM260947     2  0.1608      0.820 0.000 0.928 0.000 0.000 NA
#> GSM260952     2  0.4046      0.838 0.000 0.696 0.008 0.000 NA
#> GSM260914     1  0.0000      0.768 1.000 0.000 0.000 0.000 NA
#> GSM260916     1  0.0955      0.765 0.968 0.000 0.000 0.004 NA
#> GSM260919     1  0.2592      0.777 0.892 0.000 0.000 0.052 NA
#> GSM260922     1  0.0955      0.765 0.968 0.000 0.000 0.004 NA
#> GSM260925     1  0.0162      0.768 0.996 0.000 0.000 0.000 NA
#> GSM260927     1  0.1981      0.770 0.924 0.000 0.000 0.028 NA
#> GSM260930     1  0.6410      0.736 0.496 0.000 0.000 0.304 NA
#> GSM260933     1  0.6410      0.736 0.496 0.000 0.000 0.304 NA
#> GSM260936     1  0.6477      0.734 0.492 0.000 0.000 0.280 NA
#> GSM260939     1  0.6477      0.734 0.492 0.000 0.000 0.280 NA
#> GSM260942     1  0.6477      0.734 0.492 0.000 0.000 0.280 NA
#> GSM260945     1  0.6477      0.734 0.492 0.000 0.000 0.280 NA
#> GSM260948     1  0.3056      0.777 0.864 0.000 0.000 0.068 NA
#> GSM260950     1  0.2790      0.778 0.880 0.000 0.000 0.068 NA
#> GSM260915     3  0.1282      0.589 0.044 0.000 0.952 0.000 NA
#> GSM260917     3  0.5065     -0.665 0.036 0.000 0.544 0.420 NA
#> GSM260920     3  0.1978      0.584 0.044 0.000 0.928 0.004 NA
#> GSM260923     3  0.1408      0.589 0.044 0.000 0.948 0.000 NA
#> GSM260926     3  0.1282      0.589 0.044 0.000 0.952 0.000 NA
#> GSM260928     3  0.6806      0.164 0.360 0.000 0.468 0.024 NA
#> GSM260931     4  0.4961      0.954 0.028 0.000 0.448 0.524 NA
#> GSM260934     3  0.5608     -0.565 0.028 0.000 0.560 0.380 NA
#> GSM260937     4  0.5707      0.950 0.028 0.000 0.444 0.496 NA
#> GSM260940     4  0.4961      0.954 0.028 0.000 0.448 0.524 NA
#> GSM260943     4  0.5707      0.950 0.028 0.000 0.444 0.496 NA
#> GSM260946     4  0.4961      0.954 0.028 0.000 0.448 0.524 NA
#> GSM260949     3  0.1682      0.587 0.044 0.000 0.940 0.004 NA
#> GSM260951     4  0.5843      0.935 0.036 0.000 0.444 0.488 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
#> GSM260888     2  0.0603      0.787 0.004 0.980 0.016 0.000 0.000 NA
#> GSM260893     2  0.0508      0.787 0.004 0.984 0.012 0.000 0.000 NA
#> GSM260896     2  0.0508      0.787 0.004 0.984 0.012 0.000 0.000 NA
#> GSM260899     2  0.6531      0.682 0.084 0.452 0.104 0.000 0.000 NA
#> GSM260902     2  0.6531      0.682 0.084 0.452 0.104 0.000 0.000 NA
#> GSM260905     2  0.3844      0.784 0.008 0.676 0.000 0.004 0.000 NA
#> GSM260908     2  0.3996      0.777 0.008 0.636 0.000 0.004 0.000 NA
#> GSM260911     2  0.0653      0.787 0.004 0.980 0.012 0.000 0.000 NA
#> GSM260912     2  0.1204      0.793 0.000 0.944 0.000 0.000 0.000 NA
#> GSM260913     4  0.2009      0.859 0.040 0.000 0.000 0.916 0.004 NA
#> GSM260886     1  0.3795      0.889 0.632 0.000 0.000 0.004 0.364 NA
#> GSM260889     1  0.3795      0.889 0.632 0.000 0.000 0.004 0.364 NA
#> GSM260891     1  0.5551      0.856 0.532 0.000 0.028 0.004 0.376 NA
#> GSM260894     1  0.5574      0.858 0.540 0.000 0.028 0.004 0.364 NA
#> GSM260897     5  0.0000      0.940 0.000 0.000 0.000 0.000 1.000 NA
#> GSM260900     5  0.0291      0.938 0.004 0.000 0.000 0.000 0.992 NA
#> GSM260903     5  0.0146      0.940 0.000 0.000 0.004 0.000 0.996 NA
#> GSM260906     5  0.0146      0.940 0.000 0.000 0.004 0.000 0.996 NA
#> GSM260909     1  0.5476      0.859 0.548 0.000 0.028 0.004 0.364 NA
#> GSM260887     4  0.0862      0.874 0.016 0.000 0.000 0.972 0.004 NA
#> GSM260890     4  0.0551      0.876 0.004 0.000 0.000 0.984 0.004 NA
#> GSM260892     4  0.2009      0.859 0.040 0.000 0.000 0.916 0.004 NA
#> GSM260895     4  0.5284      0.599 0.088 0.000 0.032 0.664 0.004 NA
#> GSM260898     3  0.5150      0.846 0.036 0.000 0.596 0.336 0.008 NA
#> GSM260901     3  0.5174      0.840 0.036 0.000 0.588 0.344 0.008 NA
#> GSM260904     3  0.5298      0.837 0.036 0.000 0.584 0.340 0.008 NA
#> GSM260907     3  0.5180      0.852 0.036 0.000 0.604 0.324 0.008 NA
#> GSM260910     4  0.0291      0.877 0.004 0.000 0.000 0.992 0.004 NA
#> GSM260918     2  0.1444      0.792 0.000 0.928 0.000 0.000 0.000 NA
#> GSM260921     2  0.1812      0.790 0.000 0.912 0.008 0.000 0.000 NA
#> GSM260924     2  0.2568      0.777 0.096 0.876 0.016 0.000 0.000 NA
#> GSM260929     2  0.0790      0.793 0.000 0.968 0.000 0.000 0.000 NA
#> GSM260932     2  0.6531      0.682 0.084 0.452 0.104 0.000 0.000 NA
#> GSM260935     2  0.6531      0.682 0.084 0.452 0.104 0.000 0.000 NA
#> GSM260938     2  0.3982      0.759 0.004 0.536 0.000 0.000 0.000 NA
#> GSM260941     2  0.3854      0.759 0.000 0.536 0.000 0.000 0.000 NA
#> GSM260944     2  0.3854      0.759 0.000 0.536 0.000 0.000 0.000 NA
#> GSM260947     2  0.3854      0.759 0.000 0.536 0.000 0.000 0.000 NA
#> GSM260952     2  0.2562      0.789 0.000 0.828 0.000 0.000 0.000 NA
#> GSM260914     1  0.3930      0.889 0.628 0.000 0.000 0.004 0.364 NA
#> GSM260916     1  0.4421      0.883 0.620 0.000 0.012 0.004 0.352 NA
#> GSM260919     1  0.5238      0.763 0.508 0.000 0.024 0.004 0.428 NA
#> GSM260922     1  0.4421      0.883 0.620 0.000 0.012 0.004 0.352 NA
#> GSM260925     1  0.3795      0.889 0.632 0.000 0.000 0.004 0.364 NA
#> GSM260927     1  0.5702      0.816 0.480 0.000 0.028 0.004 0.420 NA
#> GSM260930     5  0.0291      0.938 0.004 0.000 0.000 0.000 0.992 NA
#> GSM260933     5  0.0291      0.938 0.004 0.000 0.000 0.000 0.992 NA
#> GSM260936     5  0.2403      0.910 0.020 0.000 0.040 0.000 0.900 NA
#> GSM260939     5  0.2403      0.910 0.020 0.000 0.040 0.000 0.900 NA
#> GSM260942     5  0.2403      0.910 0.020 0.000 0.040 0.000 0.900 NA
#> GSM260945     5  0.2103      0.917 0.020 0.000 0.040 0.000 0.916 NA
#> GSM260948     1  0.5260      0.721 0.484 0.000 0.028 0.004 0.452 NA
#> GSM260950     1  0.4988      0.753 0.512 0.000 0.020 0.004 0.440 NA
#> GSM260915     4  0.0405      0.875 0.008 0.000 0.000 0.988 0.004 NA
#> GSM260917     3  0.4413      0.839 0.016 0.000 0.620 0.352 0.004 NA
#> GSM260920     4  0.1708      0.862 0.024 0.000 0.000 0.932 0.004 NA
#> GSM260923     4  0.0767      0.875 0.012 0.000 0.000 0.976 0.004 NA
#> GSM260926     4  0.0405      0.875 0.008 0.000 0.000 0.988 0.004 NA
#> GSM260928     4  0.7306      0.406 0.156 0.000 0.032 0.492 0.096 NA
#> GSM260931     3  0.3217      0.865 0.000 0.000 0.768 0.224 0.008 NA
#> GSM260934     3  0.5137      0.849 0.036 0.000 0.600 0.332 0.008 NA
#> GSM260937     3  0.4957      0.840 0.044 0.000 0.688 0.224 0.008 NA
#> GSM260940     3  0.3357      0.865 0.004 0.000 0.764 0.224 0.008 NA
#> GSM260943     3  0.4830      0.843 0.036 0.000 0.696 0.224 0.008 NA
#> GSM260946     3  0.3357      0.865 0.004 0.000 0.764 0.224 0.008 NA
#> GSM260949     4  0.1194      0.871 0.008 0.000 0.000 0.956 0.004 NA
#> GSM260951     3  0.4813      0.841 0.036 0.000 0.692 0.228 0.004 NA

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

consensus_heatmap(res, k = 2)

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) cell.type(p) k
#> SD:kmeans 67            0.939     2.75e-14 2
#> SD:kmeans 66            0.920     2.62e-26 3
#> SD:kmeans 66            0.920     2.62e-26 4
#> SD:kmeans 59            0.199     8.03e-22 5
#> SD:kmeans 66            0.873     1.56e-23 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 21168 rows and 67 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 1.000           0.977       0.980         0.4287 0.575   0.575
#> 3 3 1.000           0.993       0.997         0.5750 0.750   0.566
#> 4 4 0.880           0.948       0.921         0.0803 0.940   0.816
#> 5 5 0.885           0.933       0.888         0.0687 0.937   0.761
#> 6 6 0.813           0.884       0.889         0.0359 0.989   0.946

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
#> GSM260888     2   0.000      1.000 0.00 1.00
#> GSM260893     2   0.000      1.000 0.00 1.00
#> GSM260896     2   0.000      1.000 0.00 1.00
#> GSM260899     2   0.000      1.000 0.00 1.00
#> GSM260902     2   0.000      1.000 0.00 1.00
#> GSM260905     2   0.000      1.000 0.00 1.00
#> GSM260908     2   0.000      1.000 0.00 1.00
#> GSM260911     2   0.000      1.000 0.00 1.00
#> GSM260912     2   0.000      1.000 0.00 1.00
#> GSM260913     1   0.327      0.965 0.94 0.06
#> GSM260886     1   0.000      0.970 1.00 0.00
#> GSM260889     1   0.000      0.970 1.00 0.00
#> GSM260891     1   0.000      0.970 1.00 0.00
#> GSM260894     1   0.000      0.970 1.00 0.00
#> GSM260897     1   0.000      0.970 1.00 0.00
#> GSM260900     1   0.000      0.970 1.00 0.00
#> GSM260903     1   0.000      0.970 1.00 0.00
#> GSM260906     1   0.000      0.970 1.00 0.00
#> GSM260909     1   0.000      0.970 1.00 0.00
#> GSM260887     1   0.327      0.965 0.94 0.06
#> GSM260890     1   0.327      0.965 0.94 0.06
#> GSM260892     1   0.327      0.965 0.94 0.06
#> GSM260895     1   0.000      0.970 1.00 0.00
#> GSM260898     1   0.327      0.965 0.94 0.06
#> GSM260901     1   0.327      0.965 0.94 0.06
#> GSM260904     1   0.327      0.965 0.94 0.06
#> GSM260907     1   0.327      0.965 0.94 0.06
#> GSM260910     1   0.327      0.965 0.94 0.06
#> GSM260918     2   0.000      1.000 0.00 1.00
#> GSM260921     2   0.000      1.000 0.00 1.00
#> GSM260924     2   0.000      1.000 0.00 1.00
#> GSM260929     2   0.000      1.000 0.00 1.00
#> GSM260932     2   0.000      1.000 0.00 1.00
#> GSM260935     2   0.000      1.000 0.00 1.00
#> GSM260938     2   0.000      1.000 0.00 1.00
#> GSM260941     2   0.000      1.000 0.00 1.00
#> GSM260944     2   0.000      1.000 0.00 1.00
#> GSM260947     2   0.000      1.000 0.00 1.00
#> GSM260952     2   0.000      1.000 0.00 1.00
#> GSM260914     1   0.000      0.970 1.00 0.00
#> GSM260916     1   0.000      0.970 1.00 0.00
#> GSM260919     1   0.000      0.970 1.00 0.00
#> GSM260922     1   0.000      0.970 1.00 0.00
#> GSM260925     1   0.000      0.970 1.00 0.00
#> GSM260927     1   0.000      0.970 1.00 0.00
#> GSM260930     1   0.000      0.970 1.00 0.00
#> GSM260933     1   0.000      0.970 1.00 0.00
#> GSM260936     1   0.000      0.970 1.00 0.00
#> GSM260939     1   0.000      0.970 1.00 0.00
#> GSM260942     1   0.000      0.970 1.00 0.00
#> GSM260945     1   0.000      0.970 1.00 0.00
#> GSM260948     1   0.000      0.970 1.00 0.00
#> GSM260950     1   0.000      0.970 1.00 0.00
#> GSM260915     1   0.327      0.965 0.94 0.06
#> GSM260917     1   0.327      0.965 0.94 0.06
#> GSM260920     1   0.327      0.965 0.94 0.06
#> GSM260923     1   0.327      0.965 0.94 0.06
#> GSM260926     1   0.327      0.965 0.94 0.06
#> GSM260928     1   0.000      0.970 1.00 0.00
#> GSM260931     1   0.327      0.965 0.94 0.06
#> GSM260934     1   0.327      0.965 0.94 0.06
#> GSM260937     1   0.327      0.965 0.94 0.06
#> GSM260940     1   0.327      0.965 0.94 0.06
#> GSM260943     1   0.327      0.965 0.94 0.06
#> GSM260946     1   0.327      0.965 0.94 0.06
#> GSM260949     1   0.327      0.965 0.94 0.06
#> GSM260951     1   0.327      0.965 0.94 0.06

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette  p1 p2  p3
#> GSM260888     2   0.000      1.000 0.0  1 0.0
#> GSM260893     2   0.000      1.000 0.0  1 0.0
#> GSM260896     2   0.000      1.000 0.0  1 0.0
#> GSM260899     2   0.000      1.000 0.0  1 0.0
#> GSM260902     2   0.000      1.000 0.0  1 0.0
#> GSM260905     2   0.000      1.000 0.0  1 0.0
#> GSM260908     2   0.000      1.000 0.0  1 0.0
#> GSM260911     2   0.000      1.000 0.0  1 0.0
#> GSM260912     2   0.000      1.000 0.0  1 0.0
#> GSM260913     3   0.000      1.000 0.0  0 1.0
#> GSM260886     1   0.000      0.991 1.0  0 0.0
#> GSM260889     1   0.000      0.991 1.0  0 0.0
#> GSM260891     1   0.000      0.991 1.0  0 0.0
#> GSM260894     1   0.000      0.991 1.0  0 0.0
#> GSM260897     1   0.000      0.991 1.0  0 0.0
#> GSM260900     1   0.000      0.991 1.0  0 0.0
#> GSM260903     1   0.000      0.991 1.0  0 0.0
#> GSM260906     1   0.000      0.991 1.0  0 0.0
#> GSM260909     1   0.000      0.991 1.0  0 0.0
#> GSM260887     3   0.000      1.000 0.0  0 1.0
#> GSM260890     3   0.000      1.000 0.0  0 1.0
#> GSM260892     3   0.000      1.000 0.0  0 1.0
#> GSM260895     3   0.000      1.000 0.0  0 1.0
#> GSM260898     3   0.000      1.000 0.0  0 1.0
#> GSM260901     3   0.000      1.000 0.0  0 1.0
#> GSM260904     3   0.000      1.000 0.0  0 1.0
#> GSM260907     3   0.000      1.000 0.0  0 1.0
#> GSM260910     3   0.000      1.000 0.0  0 1.0
#> GSM260918     2   0.000      1.000 0.0  1 0.0
#> GSM260921     2   0.000      1.000 0.0  1 0.0
#> GSM260924     2   0.000      1.000 0.0  1 0.0
#> GSM260929     2   0.000      1.000 0.0  1 0.0
#> GSM260932     2   0.000      1.000 0.0  1 0.0
#> GSM260935     2   0.000      1.000 0.0  1 0.0
#> GSM260938     2   0.000      1.000 0.0  1 0.0
#> GSM260941     2   0.000      1.000 0.0  1 0.0
#> GSM260944     2   0.000      1.000 0.0  1 0.0
#> GSM260947     2   0.000      1.000 0.0  1 0.0
#> GSM260952     2   0.000      1.000 0.0  1 0.0
#> GSM260914     1   0.000      0.991 1.0  0 0.0
#> GSM260916     1   0.000      0.991 1.0  0 0.0
#> GSM260919     1   0.000      0.991 1.0  0 0.0
#> GSM260922     1   0.000      0.991 1.0  0 0.0
#> GSM260925     1   0.000      0.991 1.0  0 0.0
#> GSM260927     1   0.000      0.991 1.0  0 0.0
#> GSM260930     1   0.000      0.991 1.0  0 0.0
#> GSM260933     1   0.000      0.991 1.0  0 0.0
#> GSM260936     1   0.000      0.991 1.0  0 0.0
#> GSM260939     1   0.000      0.991 1.0  0 0.0
#> GSM260942     1   0.000      0.991 1.0  0 0.0
#> GSM260945     1   0.000      0.991 1.0  0 0.0
#> GSM260948     1   0.000      0.991 1.0  0 0.0
#> GSM260950     1   0.000      0.991 1.0  0 0.0
#> GSM260915     3   0.000      1.000 0.0  0 1.0
#> GSM260917     3   0.000      1.000 0.0  0 1.0
#> GSM260920     3   0.000      1.000 0.0  0 1.0
#> GSM260923     3   0.000      1.000 0.0  0 1.0
#> GSM260926     3   0.000      1.000 0.0  0 1.0
#> GSM260928     1   0.455      0.750 0.8  0 0.2
#> GSM260931     3   0.000      1.000 0.0  0 1.0
#> GSM260934     3   0.000      1.000 0.0  0 1.0
#> GSM260937     3   0.000      1.000 0.0  0 1.0
#> GSM260940     3   0.000      1.000 0.0  0 1.0
#> GSM260943     3   0.000      1.000 0.0  0 1.0
#> GSM260946     3   0.000      1.000 0.0  0 1.0
#> GSM260949     3   0.000      1.000 0.0  0 1.0
#> GSM260951     3   0.000      1.000 0.0  0 1.0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM260888     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260893     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260896     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260899     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260902     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260905     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260908     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260911     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260912     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260913     4  0.4564      0.942 0.000  0 0.328 0.672
#> GSM260886     1  0.2973      0.929 0.856  0 0.000 0.144
#> GSM260889     1  0.2973      0.929 0.856  0 0.000 0.144
#> GSM260891     1  0.2973      0.929 0.856  0 0.000 0.144
#> GSM260894     1  0.2973      0.929 0.856  0 0.000 0.144
#> GSM260897     1  0.0000      0.914 1.000  0 0.000 0.000
#> GSM260900     1  0.0000      0.914 1.000  0 0.000 0.000
#> GSM260903     1  0.0000      0.914 1.000  0 0.000 0.000
#> GSM260906     1  0.0000      0.914 1.000  0 0.000 0.000
#> GSM260909     1  0.2973      0.929 0.856  0 0.000 0.144
#> GSM260887     4  0.4543      0.943 0.000  0 0.324 0.676
#> GSM260890     4  0.4543      0.943 0.000  0 0.324 0.676
#> GSM260892     4  0.4543      0.943 0.000  0 0.324 0.676
#> GSM260895     4  0.0188      0.561 0.000  0 0.004 0.996
#> GSM260898     3  0.0707      0.982 0.000  0 0.980 0.020
#> GSM260901     3  0.0707      0.982 0.000  0 0.980 0.020
#> GSM260904     3  0.0707      0.982 0.000  0 0.980 0.020
#> GSM260907     3  0.0707      0.982 0.000  0 0.980 0.020
#> GSM260910     4  0.4522      0.941 0.000  0 0.320 0.680
#> GSM260918     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260921     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260924     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260929     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260932     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260935     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260938     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260941     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260944     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260947     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260952     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260914     1  0.2973      0.929 0.856  0 0.000 0.144
#> GSM260916     1  0.2973      0.929 0.856  0 0.000 0.144
#> GSM260919     1  0.2760      0.930 0.872  0 0.000 0.128
#> GSM260922     1  0.2973      0.929 0.856  0 0.000 0.144
#> GSM260925     1  0.2973      0.929 0.856  0 0.000 0.144
#> GSM260927     1  0.2973      0.929 0.856  0 0.000 0.144
#> GSM260930     1  0.0000      0.914 1.000  0 0.000 0.000
#> GSM260933     1  0.0000      0.914 1.000  0 0.000 0.000
#> GSM260936     1  0.0000      0.914 1.000  0 0.000 0.000
#> GSM260939     1  0.0000      0.914 1.000  0 0.000 0.000
#> GSM260942     1  0.0000      0.914 1.000  0 0.000 0.000
#> GSM260945     1  0.0000      0.914 1.000  0 0.000 0.000
#> GSM260948     1  0.2760      0.930 0.872  0 0.000 0.128
#> GSM260950     1  0.2760      0.930 0.872  0 0.000 0.128
#> GSM260915     4  0.4543      0.943 0.000  0 0.324 0.676
#> GSM260917     3  0.0707      0.978 0.000  0 0.980 0.020
#> GSM260920     4  0.4605      0.931 0.000  0 0.336 0.664
#> GSM260923     4  0.4522      0.941 0.000  0 0.320 0.680
#> GSM260926     4  0.4564      0.942 0.000  0 0.328 0.672
#> GSM260928     1  0.4999      0.534 0.508  0 0.000 0.492
#> GSM260931     3  0.0000      0.985 0.000  0 1.000 0.000
#> GSM260934     3  0.0592      0.984 0.000  0 0.984 0.016
#> GSM260937     3  0.0000      0.985 0.000  0 1.000 0.000
#> GSM260940     3  0.0000      0.985 0.000  0 1.000 0.000
#> GSM260943     3  0.0000      0.985 0.000  0 1.000 0.000
#> GSM260946     3  0.0000      0.985 0.000  0 1.000 0.000
#> GSM260949     4  0.4564      0.942 0.000  0 0.328 0.672
#> GSM260951     3  0.0188      0.984 0.000  0 0.996 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
#> GSM260888     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000
#> GSM260893     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000
#> GSM260896     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000
#> GSM260899     2  0.2761      0.934 0.000 0.872 0.000 0.024 0.104
#> GSM260902     2  0.2761      0.934 0.000 0.872 0.000 0.024 0.104
#> GSM260905     2  0.1626      0.961 0.000 0.940 0.000 0.016 0.044
#> GSM260908     2  0.1626      0.961 0.000 0.940 0.000 0.016 0.044
#> GSM260911     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000
#> GSM260912     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000
#> GSM260913     4  0.1408      0.967 0.000 0.000 0.044 0.948 0.008
#> GSM260886     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0162      0.903 0.996 0.000 0.000 0.000 0.004
#> GSM260891     1  0.0290      0.898 0.992 0.000 0.000 0.000 0.008
#> GSM260894     1  0.0162      0.902 0.996 0.000 0.000 0.000 0.004
#> GSM260897     5  0.4182      0.997 0.400 0.000 0.000 0.000 0.600
#> GSM260900     5  0.4182      0.997 0.400 0.000 0.000 0.000 0.600
#> GSM260903     5  0.4182      0.997 0.400 0.000 0.000 0.000 0.600
#> GSM260906     5  0.4182      0.997 0.400 0.000 0.000 0.000 0.600
#> GSM260909     1  0.0162      0.902 0.996 0.000 0.000 0.000 0.004
#> GSM260887     4  0.1121      0.969 0.000 0.000 0.044 0.956 0.000
#> GSM260890     4  0.1121      0.969 0.000 0.000 0.044 0.956 0.000
#> GSM260892     4  0.1331      0.967 0.000 0.000 0.040 0.952 0.008
#> GSM260895     4  0.4527      0.709 0.040 0.000 0.000 0.700 0.260
#> GSM260898     3  0.2068      0.935 0.000 0.000 0.904 0.092 0.004
#> GSM260901     3  0.2068      0.935 0.000 0.000 0.904 0.092 0.004
#> GSM260904     3  0.2124      0.932 0.000 0.000 0.900 0.096 0.004
#> GSM260907     3  0.1892      0.940 0.000 0.000 0.916 0.080 0.004
#> GSM260910     4  0.1043      0.968 0.000 0.000 0.040 0.960 0.000
#> GSM260918     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000
#> GSM260921     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000
#> GSM260924     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000
#> GSM260929     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000
#> GSM260932     2  0.2761      0.934 0.000 0.872 0.000 0.024 0.104
#> GSM260935     2  0.2761      0.934 0.000 0.872 0.000 0.024 0.104
#> GSM260938     2  0.1701      0.960 0.000 0.936 0.000 0.016 0.048
#> GSM260941     2  0.1701      0.960 0.000 0.936 0.000 0.016 0.048
#> GSM260944     2  0.1701      0.960 0.000 0.936 0.000 0.016 0.048
#> GSM260947     2  0.1701      0.960 0.000 0.936 0.000 0.016 0.048
#> GSM260952     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000
#> GSM260914     1  0.0162      0.903 0.996 0.000 0.000 0.000 0.004
#> GSM260916     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM260919     1  0.1544      0.843 0.932 0.000 0.000 0.000 0.068
#> GSM260922     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM260925     1  0.0162      0.903 0.996 0.000 0.000 0.000 0.004
#> GSM260927     1  0.1732      0.816 0.920 0.000 0.000 0.000 0.080
#> GSM260930     5  0.4182      0.997 0.400 0.000 0.000 0.000 0.600
#> GSM260933     5  0.4182      0.997 0.400 0.000 0.000 0.000 0.600
#> GSM260936     5  0.4171      0.995 0.396 0.000 0.000 0.000 0.604
#> GSM260939     5  0.4171      0.995 0.396 0.000 0.000 0.000 0.604
#> GSM260942     5  0.4171      0.995 0.396 0.000 0.000 0.000 0.604
#> GSM260945     5  0.4171      0.995 0.396 0.000 0.000 0.000 0.604
#> GSM260948     1  0.2127      0.776 0.892 0.000 0.000 0.000 0.108
#> GSM260950     1  0.1544      0.843 0.932 0.000 0.000 0.000 0.068
#> GSM260915     4  0.1043      0.968 0.000 0.000 0.040 0.960 0.000
#> GSM260917     3  0.1851      0.926 0.000 0.000 0.912 0.088 0.000
#> GSM260920     4  0.1557      0.961 0.000 0.000 0.052 0.940 0.008
#> GSM260923     4  0.1043      0.968 0.000 0.000 0.040 0.960 0.000
#> GSM260926     4  0.1121      0.969 0.000 0.000 0.044 0.956 0.000
#> GSM260928     1  0.5949      0.332 0.532 0.000 0.000 0.120 0.348
#> GSM260931     3  0.0000      0.946 0.000 0.000 1.000 0.000 0.000
#> GSM260934     3  0.2011      0.937 0.000 0.000 0.908 0.088 0.004
#> GSM260937     3  0.0290      0.945 0.000 0.000 0.992 0.000 0.008
#> GSM260940     3  0.0000      0.946 0.000 0.000 1.000 0.000 0.000
#> GSM260943     3  0.0290      0.945 0.000 0.000 0.992 0.000 0.008
#> GSM260946     3  0.0000      0.946 0.000 0.000 1.000 0.000 0.000
#> GSM260949     4  0.1282      0.968 0.000 0.000 0.044 0.952 0.004
#> GSM260951     3  0.0290      0.945 0.000 0.000 0.992 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
#> GSM260888     2  0.2070     0.9083 0.000 0.892 0.000 0.000 0.008 0.100
#> GSM260893     2  0.2070     0.9083 0.000 0.892 0.000 0.000 0.008 0.100
#> GSM260896     2  0.2070     0.9083 0.000 0.892 0.000 0.000 0.008 0.100
#> GSM260899     2  0.3275     0.7991 0.000 0.816 0.000 0.004 0.036 0.144
#> GSM260902     2  0.3275     0.7991 0.000 0.816 0.000 0.004 0.036 0.144
#> GSM260905     2  0.0146     0.9022 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM260908     2  0.0260     0.9014 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM260911     2  0.2070     0.9083 0.000 0.892 0.000 0.000 0.008 0.100
#> GSM260912     2  0.1908     0.9098 0.000 0.900 0.000 0.000 0.004 0.096
#> GSM260913     4  0.1369     0.9650 0.000 0.000 0.016 0.952 0.016 0.016
#> GSM260886     1  0.0146     0.9177 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260889     1  0.0146     0.9177 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260891     1  0.1364     0.8996 0.944 0.000 0.000 0.004 0.004 0.048
#> GSM260894     1  0.1155     0.9060 0.956 0.000 0.000 0.004 0.004 0.036
#> GSM260897     5  0.2631     0.9751 0.180 0.000 0.000 0.000 0.820 0.000
#> GSM260900     5  0.2823     0.9635 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM260903     5  0.2730     0.9746 0.192 0.000 0.000 0.000 0.808 0.000
#> GSM260906     5  0.2730     0.9746 0.192 0.000 0.000 0.000 0.808 0.000
#> GSM260909     1  0.1082     0.9044 0.956 0.000 0.000 0.004 0.000 0.040
#> GSM260887     4  0.1086     0.9676 0.000 0.000 0.012 0.964 0.012 0.012
#> GSM260890     4  0.0363     0.9708 0.000 0.000 0.012 0.988 0.000 0.000
#> GSM260892     4  0.1269     0.9648 0.000 0.000 0.012 0.956 0.012 0.020
#> GSM260895     6  0.4179     0.0764 0.012 0.000 0.000 0.472 0.000 0.516
#> GSM260898     3  0.3485     0.8663 0.000 0.000 0.828 0.096 0.024 0.052
#> GSM260901     3  0.3580     0.8620 0.000 0.000 0.820 0.104 0.024 0.052
#> GSM260904     3  0.3533     0.8644 0.000 0.000 0.824 0.100 0.024 0.052
#> GSM260907     3  0.3470     0.8659 0.000 0.000 0.828 0.100 0.024 0.048
#> GSM260910     4  0.0806     0.9645 0.000 0.000 0.008 0.972 0.000 0.020
#> GSM260918     2  0.1908     0.9098 0.000 0.900 0.000 0.000 0.004 0.096
#> GSM260921     2  0.2118     0.9077 0.000 0.888 0.000 0.000 0.008 0.104
#> GSM260924     2  0.2118     0.9077 0.000 0.888 0.000 0.000 0.008 0.104
#> GSM260929     2  0.1908     0.9098 0.000 0.900 0.000 0.000 0.004 0.096
#> GSM260932     2  0.3275     0.7991 0.000 0.816 0.000 0.004 0.036 0.144
#> GSM260935     2  0.3275     0.7991 0.000 0.816 0.000 0.004 0.036 0.144
#> GSM260938     2  0.0858     0.8952 0.000 0.968 0.000 0.000 0.004 0.028
#> GSM260941     2  0.0603     0.8993 0.000 0.980 0.000 0.000 0.004 0.016
#> GSM260944     2  0.0603     0.8993 0.000 0.980 0.000 0.000 0.004 0.016
#> GSM260947     2  0.0603     0.8993 0.000 0.980 0.000 0.000 0.004 0.016
#> GSM260952     2  0.2006     0.9089 0.000 0.892 0.000 0.000 0.004 0.104
#> GSM260914     1  0.0291     0.9177 0.992 0.000 0.000 0.000 0.004 0.004
#> GSM260916     1  0.0260     0.9161 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM260919     1  0.2212     0.8448 0.880 0.000 0.000 0.000 0.112 0.008
#> GSM260922     1  0.0363     0.9157 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM260925     1  0.0405     0.9172 0.988 0.000 0.000 0.000 0.004 0.008
#> GSM260927     1  0.3186     0.8052 0.836 0.000 0.000 0.004 0.100 0.060
#> GSM260930     5  0.2730     0.9748 0.192 0.000 0.000 0.000 0.808 0.000
#> GSM260933     5  0.2730     0.9748 0.192 0.000 0.000 0.000 0.808 0.000
#> GSM260936     5  0.2841     0.9685 0.164 0.000 0.000 0.000 0.824 0.012
#> GSM260939     5  0.2841     0.9685 0.164 0.000 0.000 0.000 0.824 0.012
#> GSM260942     5  0.2841     0.9685 0.164 0.000 0.000 0.000 0.824 0.012
#> GSM260945     5  0.2743     0.9694 0.164 0.000 0.000 0.000 0.828 0.008
#> GSM260948     1  0.3168     0.7447 0.792 0.000 0.000 0.000 0.192 0.016
#> GSM260950     1  0.2631     0.8136 0.840 0.000 0.000 0.000 0.152 0.008
#> GSM260915     4  0.0820     0.9675 0.000 0.000 0.012 0.972 0.000 0.016
#> GSM260917     3  0.2651     0.8514 0.000 0.000 0.860 0.112 0.000 0.028
#> GSM260920     4  0.1148     0.9660 0.000 0.000 0.016 0.960 0.004 0.020
#> GSM260923     4  0.1364     0.9617 0.000 0.000 0.012 0.952 0.016 0.020
#> GSM260926     4  0.0964     0.9696 0.000 0.000 0.016 0.968 0.004 0.012
#> GSM260928     6  0.5787     0.3797 0.224 0.000 0.000 0.072 0.088 0.616
#> GSM260931     3  0.0260     0.8744 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM260934     3  0.3470     0.8659 0.000 0.000 0.828 0.100 0.024 0.048
#> GSM260937     3  0.2897     0.8093 0.000 0.000 0.852 0.000 0.088 0.060
#> GSM260940     3  0.0291     0.8750 0.000 0.000 0.992 0.000 0.004 0.004
#> GSM260943     3  0.1745     0.8530 0.000 0.000 0.924 0.000 0.020 0.056
#> GSM260946     3  0.0405     0.8737 0.000 0.000 0.988 0.000 0.004 0.008
#> GSM260949     4  0.1059     0.9681 0.000 0.000 0.016 0.964 0.004 0.016
#> GSM260951     3  0.1951     0.8513 0.000 0.000 0.916 0.004 0.020 0.060

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) cell.type(p) k
#> SD:skmeans 67            0.939     2.75e-14 2
#> SD:skmeans 67            0.864     1.50e-25 3
#> SD:skmeans 67            0.716     4.07e-24 4
#> SD:skmeans 66            0.873     1.56e-23 5
#> SD:skmeans 65            0.940     4.03e-23 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 21168 rows and 67 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 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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           1.000       1.000         0.4257 0.575   0.575
#> 3 3 1.000           0.975       0.990         0.5846 0.751   0.567
#> 4 4 0.882           0.942       0.918         0.0903 0.930   0.789
#> 5 5 0.931           0.951       0.954         0.0791 0.935   0.755
#> 6 6 0.893           0.807       0.902         0.0467 0.966   0.831

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM260888     2       0          1  0  1
#> GSM260893     2       0          1  0  1
#> GSM260896     2       0          1  0  1
#> GSM260899     2       0          1  0  1
#> GSM260902     2       0          1  0  1
#> GSM260905     2       0          1  0  1
#> GSM260908     2       0          1  0  1
#> GSM260911     2       0          1  0  1
#> GSM260912     2       0          1  0  1
#> GSM260913     1       0          1  1  0
#> GSM260886     1       0          1  1  0
#> GSM260889     1       0          1  1  0
#> GSM260891     1       0          1  1  0
#> GSM260894     1       0          1  1  0
#> GSM260897     1       0          1  1  0
#> GSM260900     1       0          1  1  0
#> GSM260903     1       0          1  1  0
#> GSM260906     1       0          1  1  0
#> GSM260909     1       0          1  1  0
#> GSM260887     1       0          1  1  0
#> GSM260890     1       0          1  1  0
#> GSM260892     1       0          1  1  0
#> GSM260895     1       0          1  1  0
#> GSM260898     1       0          1  1  0
#> GSM260901     1       0          1  1  0
#> GSM260904     1       0          1  1  0
#> GSM260907     1       0          1  1  0
#> GSM260910     1       0          1  1  0
#> GSM260918     2       0          1  0  1
#> GSM260921     2       0          1  0  1
#> GSM260924     2       0          1  0  1
#> GSM260929     2       0          1  0  1
#> GSM260932     2       0          1  0  1
#> GSM260935     2       0          1  0  1
#> GSM260938     2       0          1  0  1
#> GSM260941     2       0          1  0  1
#> GSM260944     2       0          1  0  1
#> GSM260947     2       0          1  0  1
#> GSM260952     2       0          1  0  1
#> GSM260914     1       0          1  1  0
#> GSM260916     1       0          1  1  0
#> GSM260919     1       0          1  1  0
#> GSM260922     1       0          1  1  0
#> GSM260925     1       0          1  1  0
#> GSM260927     1       0          1  1  0
#> GSM260930     1       0          1  1  0
#> GSM260933     1       0          1  1  0
#> GSM260936     1       0          1  1  0
#> GSM260939     1       0          1  1  0
#> GSM260942     1       0          1  1  0
#> GSM260945     1       0          1  1  0
#> GSM260948     1       0          1  1  0
#> GSM260950     1       0          1  1  0
#> GSM260915     1       0          1  1  0
#> GSM260917     1       0          1  1  0
#> GSM260920     1       0          1  1  0
#> GSM260923     1       0          1  1  0
#> GSM260926     1       0          1  1  0
#> GSM260928     1       0          1  1  0
#> GSM260931     1       0          1  1  0
#> GSM260934     1       0          1  1  0
#> GSM260937     1       0          1  1  0
#> GSM260940     1       0          1  1  0
#> GSM260943     1       0          1  1  0
#> GSM260946     1       0          1  1  0
#> GSM260949     1       0          1  1  0
#> GSM260951     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM260888     2   0.000      1.000 0.000  1 0.000
#> GSM260893     2   0.000      1.000 0.000  1 0.000
#> GSM260896     2   0.000      1.000 0.000  1 0.000
#> GSM260899     2   0.000      1.000 0.000  1 0.000
#> GSM260902     2   0.000      1.000 0.000  1 0.000
#> GSM260905     2   0.000      1.000 0.000  1 0.000
#> GSM260908     2   0.000      1.000 0.000  1 0.000
#> GSM260911     2   0.000      1.000 0.000  1 0.000
#> GSM260912     2   0.000      1.000 0.000  1 0.000
#> GSM260913     3   0.000      1.000 0.000  0 1.000
#> GSM260886     1   0.000      0.972 1.000  0 0.000
#> GSM260889     1   0.000      0.972 1.000  0 0.000
#> GSM260891     1   0.000      0.972 1.000  0 0.000
#> GSM260894     1   0.000      0.972 1.000  0 0.000
#> GSM260897     1   0.000      0.972 1.000  0 0.000
#> GSM260900     1   0.000      0.972 1.000  0 0.000
#> GSM260903     1   0.000      0.972 1.000  0 0.000
#> GSM260906     1   0.000      0.972 1.000  0 0.000
#> GSM260909     1   0.000      0.972 1.000  0 0.000
#> GSM260887     3   0.000      1.000 0.000  0 1.000
#> GSM260890     3   0.000      1.000 0.000  0 1.000
#> GSM260892     3   0.000      1.000 0.000  0 1.000
#> GSM260895     1   0.611      0.369 0.604  0 0.396
#> GSM260898     3   0.000      1.000 0.000  0 1.000
#> GSM260901     3   0.000      1.000 0.000  0 1.000
#> GSM260904     3   0.000      1.000 0.000  0 1.000
#> GSM260907     3   0.000      1.000 0.000  0 1.000
#> GSM260910     3   0.000      1.000 0.000  0 1.000
#> GSM260918     2   0.000      1.000 0.000  1 0.000
#> GSM260921     2   0.000      1.000 0.000  1 0.000
#> GSM260924     2   0.000      1.000 0.000  1 0.000
#> GSM260929     2   0.000      1.000 0.000  1 0.000
#> GSM260932     2   0.000      1.000 0.000  1 0.000
#> GSM260935     2   0.000      1.000 0.000  1 0.000
#> GSM260938     2   0.000      1.000 0.000  1 0.000
#> GSM260941     2   0.000      1.000 0.000  1 0.000
#> GSM260944     2   0.000      1.000 0.000  1 0.000
#> GSM260947     2   0.000      1.000 0.000  1 0.000
#> GSM260952     2   0.000      1.000 0.000  1 0.000
#> GSM260914     1   0.000      0.972 1.000  0 0.000
#> GSM260916     1   0.000      0.972 1.000  0 0.000
#> GSM260919     1   0.000      0.972 1.000  0 0.000
#> GSM260922     1   0.000      0.972 1.000  0 0.000
#> GSM260925     1   0.000      0.972 1.000  0 0.000
#> GSM260927     1   0.000      0.972 1.000  0 0.000
#> GSM260930     1   0.000      0.972 1.000  0 0.000
#> GSM260933     1   0.000      0.972 1.000  0 0.000
#> GSM260936     1   0.000      0.972 1.000  0 0.000
#> GSM260939     1   0.000      0.972 1.000  0 0.000
#> GSM260942     1   0.000      0.972 1.000  0 0.000
#> GSM260945     1   0.000      0.972 1.000  0 0.000
#> GSM260948     1   0.000      0.972 1.000  0 0.000
#> GSM260950     1   0.000      0.972 1.000  0 0.000
#> GSM260915     3   0.000      1.000 0.000  0 1.000
#> GSM260917     3   0.000      1.000 0.000  0 1.000
#> GSM260920     3   0.000      1.000 0.000  0 1.000
#> GSM260923     3   0.000      1.000 0.000  0 1.000
#> GSM260926     3   0.000      1.000 0.000  0 1.000
#> GSM260928     1   0.529      0.640 0.732  0 0.268
#> GSM260931     3   0.000      1.000 0.000  0 1.000
#> GSM260934     3   0.000      1.000 0.000  0 1.000
#> GSM260937     3   0.000      1.000 0.000  0 1.000
#> GSM260940     3   0.000      1.000 0.000  0 1.000
#> GSM260943     3   0.000      1.000 0.000  0 1.000
#> GSM260946     3   0.000      1.000 0.000  0 1.000
#> GSM260949     3   0.000      1.000 0.000  0 1.000
#> GSM260951     3   0.000      1.000 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM260888     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260893     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260896     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260899     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260902     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260905     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260908     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260911     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260912     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260913     4  0.3569      0.950 0.000  0 0.196 0.804
#> GSM260886     1  0.0188      0.907 0.996  0 0.000 0.004
#> GSM260889     1  0.0188      0.907 0.996  0 0.000 0.004
#> GSM260891     1  0.1474      0.911 0.948  0 0.000 0.052
#> GSM260894     1  0.0188      0.907 0.996  0 0.000 0.004
#> GSM260897     1  0.3528      0.911 0.808  0 0.000 0.192
#> GSM260900     1  0.3528      0.911 0.808  0 0.000 0.192
#> GSM260903     1  0.3528      0.911 0.808  0 0.000 0.192
#> GSM260906     1  0.3528      0.911 0.808  0 0.000 0.192
#> GSM260909     1  0.0188      0.907 0.996  0 0.000 0.004
#> GSM260887     4  0.3569      0.950 0.000  0 0.196 0.804
#> GSM260890     4  0.3569      0.950 0.000  0 0.196 0.804
#> GSM260892     4  0.3569      0.950 0.000  0 0.196 0.804
#> GSM260895     4  0.5383      0.753 0.160  0 0.100 0.740
#> GSM260898     3  0.0000      0.975 0.000  0 1.000 0.000
#> GSM260901     3  0.1302      0.931 0.000  0 0.956 0.044
#> GSM260904     3  0.3123      0.755 0.000  0 0.844 0.156
#> GSM260907     3  0.0000      0.975 0.000  0 1.000 0.000
#> GSM260910     4  0.3569      0.950 0.000  0 0.196 0.804
#> GSM260918     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260921     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260924     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260929     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260932     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260935     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260938     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260941     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260944     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260947     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260952     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260914     1  0.0188      0.907 0.996  0 0.000 0.004
#> GSM260916     1  0.0188      0.907 0.996  0 0.000 0.004
#> GSM260919     1  0.0188      0.907 0.996  0 0.000 0.004
#> GSM260922     1  0.0188      0.907 0.996  0 0.000 0.004
#> GSM260925     1  0.0188      0.907 0.996  0 0.000 0.004
#> GSM260927     1  0.3486      0.911 0.812  0 0.000 0.188
#> GSM260930     1  0.3528      0.911 0.808  0 0.000 0.192
#> GSM260933     1  0.3528      0.911 0.808  0 0.000 0.192
#> GSM260936     1  0.3528      0.911 0.808  0 0.000 0.192
#> GSM260939     1  0.3528      0.911 0.808  0 0.000 0.192
#> GSM260942     1  0.3528      0.911 0.808  0 0.000 0.192
#> GSM260945     1  0.3528      0.911 0.808  0 0.000 0.192
#> GSM260948     1  0.1389      0.911 0.952  0 0.000 0.048
#> GSM260950     1  0.0000      0.907 1.000  0 0.000 0.000
#> GSM260915     4  0.3569      0.950 0.000  0 0.196 0.804
#> GSM260917     3  0.0336      0.969 0.000  0 0.992 0.008
#> GSM260920     4  0.4843      0.638 0.000  0 0.396 0.604
#> GSM260923     4  0.3569      0.950 0.000  0 0.196 0.804
#> GSM260926     4  0.3569      0.950 0.000  0 0.196 0.804
#> GSM260928     1  0.4907      0.848 0.764  0 0.060 0.176
#> GSM260931     3  0.0000      0.975 0.000  0 1.000 0.000
#> GSM260934     3  0.0000      0.975 0.000  0 1.000 0.000
#> GSM260937     3  0.0000      0.975 0.000  0 1.000 0.000
#> GSM260940     3  0.0000      0.975 0.000  0 1.000 0.000
#> GSM260943     3  0.0000      0.975 0.000  0 1.000 0.000
#> GSM260946     3  0.0000      0.975 0.000  0 1.000 0.000
#> GSM260949     4  0.3569      0.950 0.000  0 0.196 0.804
#> GSM260951     3  0.0000      0.975 0.000  0 1.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
#> GSM260888     2  0.0162      0.995 0.000 0.996 0.000 0.000 0.004
#> GSM260893     2  0.0162      0.995 0.000 0.996 0.000 0.000 0.004
#> GSM260896     2  0.0162      0.995 0.000 0.996 0.000 0.000 0.004
#> GSM260899     2  0.0671      0.986 0.000 0.980 0.000 0.004 0.016
#> GSM260902     2  0.0671      0.986 0.000 0.980 0.000 0.004 0.016
#> GSM260905     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM260908     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM260911     2  0.0162      0.995 0.000 0.996 0.000 0.000 0.004
#> GSM260912     2  0.0162      0.995 0.000 0.996 0.000 0.000 0.004
#> GSM260913     4  0.0162      0.935 0.000 0.000 0.004 0.996 0.000
#> GSM260886     1  0.0000      0.971 1.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0000      0.971 1.000 0.000 0.000 0.000 0.000
#> GSM260891     1  0.1851      0.902 0.912 0.000 0.000 0.000 0.088
#> GSM260894     1  0.1908      0.888 0.908 0.000 0.000 0.000 0.092
#> GSM260897     5  0.2230      0.987 0.116 0.000 0.000 0.000 0.884
#> GSM260900     5  0.2230      0.987 0.116 0.000 0.000 0.000 0.884
#> GSM260903     5  0.2230      0.987 0.116 0.000 0.000 0.000 0.884
#> GSM260906     5  0.2230      0.987 0.116 0.000 0.000 0.000 0.884
#> GSM260909     1  0.0000      0.971 1.000 0.000 0.000 0.000 0.000
#> GSM260887     4  0.0162      0.935 0.000 0.000 0.004 0.996 0.000
#> GSM260890     4  0.0162      0.935 0.000 0.000 0.004 0.996 0.000
#> GSM260892     4  0.0162      0.935 0.000 0.000 0.004 0.996 0.000
#> GSM260895     4  0.5749      0.422 0.316 0.000 0.004 0.584 0.096
#> GSM260898     3  0.0000      0.966 0.000 0.000 1.000 0.000 0.000
#> GSM260901     3  0.1732      0.897 0.000 0.000 0.920 0.080 0.000
#> GSM260904     3  0.3452      0.669 0.000 0.000 0.756 0.244 0.000
#> GSM260907     3  0.0000      0.966 0.000 0.000 1.000 0.000 0.000
#> GSM260910     4  0.0162      0.935 0.000 0.000 0.004 0.996 0.000
#> GSM260918     2  0.0162      0.995 0.000 0.996 0.000 0.000 0.004
#> GSM260921     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM260924     2  0.0162      0.995 0.000 0.996 0.000 0.000 0.004
#> GSM260929     2  0.0162      0.995 0.000 0.996 0.000 0.000 0.004
#> GSM260932     2  0.0671      0.986 0.000 0.980 0.000 0.004 0.016
#> GSM260935     2  0.0671      0.986 0.000 0.980 0.000 0.004 0.016
#> GSM260938     2  0.0451      0.990 0.000 0.988 0.000 0.004 0.008
#> GSM260941     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM260944     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM260947     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> GSM260952     2  0.0162      0.995 0.000 0.996 0.000 0.000 0.004
#> GSM260914     1  0.0000      0.971 1.000 0.000 0.000 0.000 0.000
#> GSM260916     1  0.0000      0.971 1.000 0.000 0.000 0.000 0.000
#> GSM260919     1  0.0000      0.971 1.000 0.000 0.000 0.000 0.000
#> GSM260922     1  0.0000      0.971 1.000 0.000 0.000 0.000 0.000
#> GSM260925     1  0.0000      0.971 1.000 0.000 0.000 0.000 0.000
#> GSM260927     5  0.2471      0.967 0.136 0.000 0.000 0.000 0.864
#> GSM260930     5  0.2230      0.987 0.116 0.000 0.000 0.000 0.884
#> GSM260933     5  0.2230      0.987 0.116 0.000 0.000 0.000 0.884
#> GSM260936     5  0.2230      0.987 0.116 0.000 0.000 0.000 0.884
#> GSM260939     5  0.2230      0.987 0.116 0.000 0.000 0.000 0.884
#> GSM260942     5  0.2230      0.987 0.116 0.000 0.000 0.000 0.884
#> GSM260945     5  0.2230      0.987 0.116 0.000 0.000 0.000 0.884
#> GSM260948     1  0.1908      0.900 0.908 0.000 0.000 0.000 0.092
#> GSM260950     1  0.0162      0.969 0.996 0.000 0.000 0.000 0.004
#> GSM260915     4  0.0162      0.935 0.000 0.000 0.004 0.996 0.000
#> GSM260917     3  0.0703      0.950 0.000 0.000 0.976 0.024 0.000
#> GSM260920     4  0.3395      0.653 0.000 0.000 0.236 0.764 0.000
#> GSM260923     4  0.0162      0.935 0.000 0.000 0.004 0.996 0.000
#> GSM260926     4  0.0162      0.935 0.000 0.000 0.004 0.996 0.000
#> GSM260928     5  0.0992      0.879 0.024 0.000 0.000 0.008 0.968
#> GSM260931     3  0.0000      0.966 0.000 0.000 1.000 0.000 0.000
#> GSM260934     3  0.0000      0.966 0.000 0.000 1.000 0.000 0.000
#> GSM260937     3  0.0000      0.966 0.000 0.000 1.000 0.000 0.000
#> GSM260940     3  0.0000      0.966 0.000 0.000 1.000 0.000 0.000
#> GSM260943     3  0.0000      0.966 0.000 0.000 1.000 0.000 0.000
#> GSM260946     3  0.0000      0.966 0.000 0.000 1.000 0.000 0.000
#> GSM260949     4  0.0162      0.935 0.000 0.000 0.004 0.996 0.000
#> GSM260951     3  0.0000      0.966 0.000 0.000 1.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
#> GSM260888     2  0.0000     0.7084 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260893     2  0.0000     0.7084 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260896     2  0.0000     0.7084 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260899     6  0.2664     0.8176 0.000 0.184 0.000 0.000 0.000 0.816
#> GSM260902     6  0.2823     0.8142 0.000 0.204 0.000 0.000 0.000 0.796
#> GSM260905     2  0.3862     0.1007 0.000 0.524 0.000 0.000 0.000 0.476
#> GSM260908     2  0.3864     0.0991 0.000 0.520 0.000 0.000 0.000 0.480
#> GSM260911     2  0.0260     0.7042 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM260912     2  0.0000     0.7084 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260913     4  0.0000     0.9234 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260886     1  0.0000     0.9637 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0000     0.9637 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260891     1  0.2092     0.8679 0.876 0.000 0.000 0.000 0.124 0.000
#> GSM260894     1  0.1714     0.8886 0.908 0.000 0.000 0.000 0.092 0.000
#> GSM260897     5  0.1327     0.9810 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM260900     5  0.1327     0.9810 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM260903     5  0.1327     0.9810 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM260906     5  0.1327     0.9810 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM260909     1  0.0000     0.9637 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260887     4  0.0000     0.9234 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260890     4  0.0000     0.9234 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260892     4  0.0000     0.9234 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260895     4  0.6430     0.2827 0.316 0.000 0.000 0.492 0.064 0.128
#> GSM260898     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260901     3  0.1663     0.8884 0.000 0.000 0.912 0.088 0.000 0.000
#> GSM260904     3  0.3101     0.6740 0.000 0.000 0.756 0.244 0.000 0.000
#> GSM260907     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260910     4  0.0000     0.9234 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260918     2  0.0000     0.7084 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260921     2  0.3221     0.4681 0.000 0.736 0.000 0.000 0.000 0.264
#> GSM260924     2  0.0363     0.7042 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM260929     2  0.0260     0.7042 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM260932     6  0.2178     0.7850 0.000 0.132 0.000 0.000 0.000 0.868
#> GSM260935     6  0.3151     0.7641 0.000 0.252 0.000 0.000 0.000 0.748
#> GSM260938     6  0.3737     0.2703 0.000 0.392 0.000 0.000 0.000 0.608
#> GSM260941     2  0.3864     0.0991 0.000 0.520 0.000 0.000 0.000 0.480
#> GSM260944     2  0.3864     0.0991 0.000 0.520 0.000 0.000 0.000 0.480
#> GSM260947     2  0.3864     0.0991 0.000 0.520 0.000 0.000 0.000 0.480
#> GSM260952     2  0.0790     0.6936 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM260914     1  0.0000     0.9637 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260916     1  0.0000     0.9637 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260919     1  0.0000     0.9637 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260922     1  0.0000     0.9637 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260925     1  0.0000     0.9637 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260927     5  0.1610     0.9631 0.084 0.000 0.000 0.000 0.916 0.000
#> GSM260930     5  0.1327     0.9810 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM260933     5  0.1327     0.9810 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM260936     5  0.1327     0.9810 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM260939     5  0.1327     0.9810 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM260942     5  0.1327     0.9810 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM260945     5  0.1327     0.9810 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM260948     1  0.2178     0.8601 0.868 0.000 0.000 0.000 0.132 0.000
#> GSM260950     1  0.0260     0.9599 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260915     4  0.0000     0.9234 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260917     3  0.0632     0.9481 0.000 0.000 0.976 0.024 0.000 0.000
#> GSM260920     4  0.2996     0.6541 0.000 0.000 0.228 0.772 0.000 0.000
#> GSM260923     4  0.0000     0.9234 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260926     4  0.0000     0.9234 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260928     5  0.2531     0.7917 0.004 0.000 0.000 0.008 0.860 0.128
#> GSM260931     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260934     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260937     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260940     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260943     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260946     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260949     4  0.0000     0.9234 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260951     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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) cell.type(p) k
#> SD:pam 67            0.939     2.75e-14 2
#> SD:pam 66            0.881     4.15e-25 3
#> SD:pam 67            0.716     4.07e-24 4
#> SD:pam 66            0.902     1.97e-22 5
#> SD:pam 59            0.879     2.16e-18 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 21168 rows and 67 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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.997       0.997         0.4260 0.575   0.575
#> 3 3 1.000           0.972       0.989         0.5840 0.750   0.566
#> 4 4 0.908           0.939       0.952         0.0505 0.980   0.939
#> 5 5 0.860           0.756       0.814         0.0674 0.962   0.877
#> 6 6 0.758           0.568       0.736         0.0637 0.894   0.626

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM260888     2  0.0000      1.000 0.000 1.000
#> GSM260893     2  0.0000      1.000 0.000 1.000
#> GSM260896     2  0.0000      1.000 0.000 1.000
#> GSM260899     2  0.0000      1.000 0.000 1.000
#> GSM260902     2  0.0000      1.000 0.000 1.000
#> GSM260905     2  0.0000      1.000 0.000 1.000
#> GSM260908     2  0.0000      1.000 0.000 1.000
#> GSM260911     2  0.0000      1.000 0.000 1.000
#> GSM260912     2  0.0000      1.000 0.000 1.000
#> GSM260913     1  0.0672      0.996 0.992 0.008
#> GSM260886     1  0.0000      0.996 1.000 0.000
#> GSM260889     1  0.0000      0.996 1.000 0.000
#> GSM260891     1  0.0000      0.996 1.000 0.000
#> GSM260894     1  0.0000      0.996 1.000 0.000
#> GSM260897     1  0.0000      0.996 1.000 0.000
#> GSM260900     1  0.0000      0.996 1.000 0.000
#> GSM260903     1  0.0000      0.996 1.000 0.000
#> GSM260906     1  0.0000      0.996 1.000 0.000
#> GSM260909     1  0.0000      0.996 1.000 0.000
#> GSM260887     1  0.0672      0.996 0.992 0.008
#> GSM260890     1  0.0672      0.996 0.992 0.008
#> GSM260892     1  0.0672      0.996 0.992 0.008
#> GSM260895     1  0.0376      0.996 0.996 0.004
#> GSM260898     1  0.0672      0.996 0.992 0.008
#> GSM260901     1  0.0672      0.996 0.992 0.008
#> GSM260904     1  0.0672      0.996 0.992 0.008
#> GSM260907     1  0.0672      0.996 0.992 0.008
#> GSM260910     1  0.0672      0.996 0.992 0.008
#> GSM260918     2  0.0000      1.000 0.000 1.000
#> GSM260921     2  0.0000      1.000 0.000 1.000
#> GSM260924     2  0.0000      1.000 0.000 1.000
#> GSM260929     2  0.0000      1.000 0.000 1.000
#> GSM260932     2  0.0000      1.000 0.000 1.000
#> GSM260935     2  0.0000      1.000 0.000 1.000
#> GSM260938     2  0.0000      1.000 0.000 1.000
#> GSM260941     2  0.0000      1.000 0.000 1.000
#> GSM260944     2  0.0000      1.000 0.000 1.000
#> GSM260947     2  0.0000      1.000 0.000 1.000
#> GSM260952     2  0.0000      1.000 0.000 1.000
#> GSM260914     1  0.0000      0.996 1.000 0.000
#> GSM260916     1  0.0000      0.996 1.000 0.000
#> GSM260919     1  0.0000      0.996 1.000 0.000
#> GSM260922     1  0.0000      0.996 1.000 0.000
#> GSM260925     1  0.0000      0.996 1.000 0.000
#> GSM260927     1  0.0000      0.996 1.000 0.000
#> GSM260930     1  0.0000      0.996 1.000 0.000
#> GSM260933     1  0.0000      0.996 1.000 0.000
#> GSM260936     1  0.0000      0.996 1.000 0.000
#> GSM260939     1  0.0000      0.996 1.000 0.000
#> GSM260942     1  0.0000      0.996 1.000 0.000
#> GSM260945     1  0.0000      0.996 1.000 0.000
#> GSM260948     1  0.0000      0.996 1.000 0.000
#> GSM260950     1  0.0000      0.996 1.000 0.000
#> GSM260915     1  0.0672      0.996 0.992 0.008
#> GSM260917     1  0.0672      0.996 0.992 0.008
#> GSM260920     1  0.0672      0.996 0.992 0.008
#> GSM260923     1  0.0672      0.996 0.992 0.008
#> GSM260926     1  0.0672      0.996 0.992 0.008
#> GSM260928     1  0.0376      0.996 0.996 0.004
#> GSM260931     1  0.0672      0.996 0.992 0.008
#> GSM260934     1  0.0672      0.996 0.992 0.008
#> GSM260937     1  0.0672      0.996 0.992 0.008
#> GSM260940     1  0.0672      0.996 0.992 0.008
#> GSM260943     1  0.0672      0.996 0.992 0.008
#> GSM260946     1  0.0672      0.996 0.992 0.008
#> GSM260949     1  0.0672      0.996 0.992 0.008
#> GSM260951     1  0.0672      0.996 0.992 0.008

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM260888     2   0.000      1.000 0.000  1 0.000
#> GSM260893     2   0.000      1.000 0.000  1 0.000
#> GSM260896     2   0.000      1.000 0.000  1 0.000
#> GSM260899     2   0.000      1.000 0.000  1 0.000
#> GSM260902     2   0.000      1.000 0.000  1 0.000
#> GSM260905     2   0.000      1.000 0.000  1 0.000
#> GSM260908     2   0.000      1.000 0.000  1 0.000
#> GSM260911     2   0.000      1.000 0.000  1 0.000
#> GSM260912     2   0.000      1.000 0.000  1 0.000
#> GSM260913     3   0.000      0.966 0.000  0 1.000
#> GSM260886     1   0.000      1.000 1.000  0 0.000
#> GSM260889     1   0.000      1.000 1.000  0 0.000
#> GSM260891     1   0.000      1.000 1.000  0 0.000
#> GSM260894     1   0.000      1.000 1.000  0 0.000
#> GSM260897     1   0.000      1.000 1.000  0 0.000
#> GSM260900     1   0.000      1.000 1.000  0 0.000
#> GSM260903     1   0.000      1.000 1.000  0 0.000
#> GSM260906     1   0.000      1.000 1.000  0 0.000
#> GSM260909     1   0.000      1.000 1.000  0 0.000
#> GSM260887     3   0.000      0.966 0.000  0 1.000
#> GSM260890     3   0.000      0.966 0.000  0 1.000
#> GSM260892     3   0.000      0.966 0.000  0 1.000
#> GSM260895     3   0.599      0.443 0.368  0 0.632
#> GSM260898     3   0.000      0.966 0.000  0 1.000
#> GSM260901     3   0.000      0.966 0.000  0 1.000
#> GSM260904     3   0.000      0.966 0.000  0 1.000
#> GSM260907     3   0.000      0.966 0.000  0 1.000
#> GSM260910     3   0.000      0.966 0.000  0 1.000
#> GSM260918     2   0.000      1.000 0.000  1 0.000
#> GSM260921     2   0.000      1.000 0.000  1 0.000
#> GSM260924     2   0.000      1.000 0.000  1 0.000
#> GSM260929     2   0.000      1.000 0.000  1 0.000
#> GSM260932     2   0.000      1.000 0.000  1 0.000
#> GSM260935     2   0.000      1.000 0.000  1 0.000
#> GSM260938     2   0.000      1.000 0.000  1 0.000
#> GSM260941     2   0.000      1.000 0.000  1 0.000
#> GSM260944     2   0.000      1.000 0.000  1 0.000
#> GSM260947     2   0.000      1.000 0.000  1 0.000
#> GSM260952     2   0.000      1.000 0.000  1 0.000
#> GSM260914     1   0.000      1.000 1.000  0 0.000
#> GSM260916     1   0.000      1.000 1.000  0 0.000
#> GSM260919     1   0.000      1.000 1.000  0 0.000
#> GSM260922     1   0.000      1.000 1.000  0 0.000
#> GSM260925     1   0.000      1.000 1.000  0 0.000
#> GSM260927     1   0.000      1.000 1.000  0 0.000
#> GSM260930     1   0.000      1.000 1.000  0 0.000
#> GSM260933     1   0.000      1.000 1.000  0 0.000
#> GSM260936     1   0.000      1.000 1.000  0 0.000
#> GSM260939     1   0.000      1.000 1.000  0 0.000
#> GSM260942     1   0.000      1.000 1.000  0 0.000
#> GSM260945     1   0.000      1.000 1.000  0 0.000
#> GSM260948     1   0.000      1.000 1.000  0 0.000
#> GSM260950     1   0.000      1.000 1.000  0 0.000
#> GSM260915     3   0.000      0.966 0.000  0 1.000
#> GSM260917     3   0.000      0.966 0.000  0 1.000
#> GSM260920     3   0.000      0.966 0.000  0 1.000
#> GSM260923     3   0.000      0.966 0.000  0 1.000
#> GSM260926     3   0.000      0.966 0.000  0 1.000
#> GSM260928     3   0.601      0.433 0.372  0 0.628
#> GSM260931     3   0.000      0.966 0.000  0 1.000
#> GSM260934     3   0.000      0.966 0.000  0 1.000
#> GSM260937     3   0.000      0.966 0.000  0 1.000
#> GSM260940     3   0.000      0.966 0.000  0 1.000
#> GSM260943     3   0.000      0.966 0.000  0 1.000
#> GSM260946     3   0.000      0.966 0.000  0 1.000
#> GSM260949     3   0.000      0.966 0.000  0 1.000
#> GSM260951     3   0.000      0.966 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM260888     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260893     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260896     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260899     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260902     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260905     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260908     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260911     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260912     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260913     3  0.1474      0.938 0.000  0 0.948 0.052
#> GSM260886     1  0.2760      0.914 0.872  0 0.000 0.128
#> GSM260889     1  0.2760      0.914 0.872  0 0.000 0.128
#> GSM260891     1  0.4277      0.794 0.720  0 0.000 0.280
#> GSM260894     1  0.2921      0.910 0.860  0 0.000 0.140
#> GSM260897     1  0.0000      0.904 1.000  0 0.000 0.000
#> GSM260900     1  0.0000      0.904 1.000  0 0.000 0.000
#> GSM260903     1  0.0000      0.904 1.000  0 0.000 0.000
#> GSM260906     1  0.0000      0.904 1.000  0 0.000 0.000
#> GSM260909     1  0.3123      0.902 0.844  0 0.000 0.156
#> GSM260887     3  0.1474      0.938 0.000  0 0.948 0.052
#> GSM260890     3  0.1474      0.938 0.000  0 0.948 0.052
#> GSM260892     3  0.1637      0.935 0.000  0 0.940 0.060
#> GSM260895     4  0.4541      1.000 0.060  0 0.144 0.796
#> GSM260898     3  0.0336      0.944 0.000  0 0.992 0.008
#> GSM260901     3  0.0336      0.944 0.000  0 0.992 0.008
#> GSM260904     3  0.0336      0.944 0.000  0 0.992 0.008
#> GSM260907     3  0.0336      0.944 0.000  0 0.992 0.008
#> GSM260910     3  0.2281      0.911 0.000  0 0.904 0.096
#> GSM260918     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260921     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260924     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260929     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260932     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260935     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260938     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260941     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260944     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260947     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260952     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260914     1  0.2760      0.914 0.872  0 0.000 0.128
#> GSM260916     1  0.3907      0.846 0.768  0 0.000 0.232
#> GSM260919     1  0.2760      0.914 0.872  0 0.000 0.128
#> GSM260922     1  0.4103      0.823 0.744  0 0.000 0.256
#> GSM260925     1  0.2868      0.912 0.864  0 0.000 0.136
#> GSM260927     1  0.2760      0.914 0.872  0 0.000 0.128
#> GSM260930     1  0.0000      0.904 1.000  0 0.000 0.000
#> GSM260933     1  0.0000      0.904 1.000  0 0.000 0.000
#> GSM260936     1  0.0000      0.904 1.000  0 0.000 0.000
#> GSM260939     1  0.0592      0.896 0.984  0 0.000 0.016
#> GSM260942     1  0.0000      0.904 1.000  0 0.000 0.000
#> GSM260945     1  0.0000      0.904 1.000  0 0.000 0.000
#> GSM260948     1  0.2760      0.914 0.872  0 0.000 0.128
#> GSM260950     1  0.2760      0.914 0.872  0 0.000 0.128
#> GSM260915     3  0.1474      0.938 0.000  0 0.948 0.052
#> GSM260917     3  0.0592      0.944 0.000  0 0.984 0.016
#> GSM260920     3  0.1474      0.938 0.000  0 0.948 0.052
#> GSM260923     3  0.3444      0.810 0.000  0 0.816 0.184
#> GSM260926     3  0.2814      0.874 0.000  0 0.868 0.132
#> GSM260928     4  0.4541      1.000 0.060  0 0.144 0.796
#> GSM260931     3  0.0336      0.944 0.000  0 0.992 0.008
#> GSM260934     3  0.0336      0.944 0.000  0 0.992 0.008
#> GSM260937     3  0.3444      0.726 0.000  0 0.816 0.184
#> GSM260940     3  0.0336      0.944 0.000  0 0.992 0.008
#> GSM260943     3  0.0336      0.944 0.000  0 0.992 0.008
#> GSM260946     3  0.0336      0.944 0.000  0 0.992 0.008
#> GSM260949     3  0.1716      0.933 0.000  0 0.936 0.064
#> GSM260951     3  0.0000      0.945 0.000  0 1.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
#> GSM260888     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260893     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260896     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260899     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260902     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260905     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260908     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260911     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260912     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260913     3  0.0510      0.754 0.000 0.000 0.984 0.000 0.016
#> GSM260886     1  0.4470      0.491 0.616 0.000 0.000 0.012 0.372
#> GSM260889     1  0.4101      0.510 0.628 0.000 0.000 0.000 0.372
#> GSM260891     5  0.5940      0.772 0.140 0.000 0.000 0.292 0.568
#> GSM260894     1  0.4088      0.516 0.632 0.000 0.000 0.000 0.368
#> GSM260897     1  0.0162      0.672 0.996 0.000 0.000 0.000 0.004
#> GSM260900     1  0.0000      0.673 1.000 0.000 0.000 0.000 0.000
#> GSM260903     1  0.0000      0.673 1.000 0.000 0.000 0.000 0.000
#> GSM260906     1  0.0162      0.674 0.996 0.000 0.000 0.000 0.004
#> GSM260909     1  0.4101      0.510 0.628 0.000 0.000 0.000 0.372
#> GSM260887     3  0.0510      0.754 0.000 0.000 0.984 0.000 0.016
#> GSM260890     3  0.0510      0.748 0.000 0.000 0.984 0.000 0.016
#> GSM260892     3  0.0510      0.754 0.000 0.000 0.984 0.000 0.016
#> GSM260895     4  0.0290      0.633 0.000 0.000 0.008 0.992 0.000
#> GSM260898     3  0.4225      0.694 0.000 0.000 0.632 0.004 0.364
#> GSM260901     3  0.4225      0.690 0.000 0.000 0.632 0.004 0.364
#> GSM260904     3  0.4238      0.693 0.000 0.000 0.628 0.004 0.368
#> GSM260907     3  0.4238      0.693 0.000 0.000 0.628 0.004 0.368
#> GSM260910     3  0.1197      0.736 0.000 0.000 0.952 0.000 0.048
#> GSM260918     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260921     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260924     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260929     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260932     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260935     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260938     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260941     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260944     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260947     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260952     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260914     1  0.4101      0.510 0.628 0.000 0.000 0.000 0.372
#> GSM260916     5  0.6333      0.764 0.288 0.000 0.000 0.196 0.516
#> GSM260919     1  0.4030      0.537 0.648 0.000 0.000 0.000 0.352
#> GSM260922     5  0.6106      0.843 0.228 0.000 0.000 0.204 0.568
#> GSM260925     1  0.4101      0.510 0.628 0.000 0.000 0.000 0.372
#> GSM260927     1  0.4015      0.537 0.652 0.000 0.000 0.000 0.348
#> GSM260930     1  0.0290      0.673 0.992 0.000 0.000 0.000 0.008
#> GSM260933     1  0.0000      0.673 1.000 0.000 0.000 0.000 0.000
#> GSM260936     1  0.0609      0.662 0.980 0.000 0.000 0.000 0.020
#> GSM260939     1  0.0771      0.658 0.976 0.000 0.000 0.004 0.020
#> GSM260942     1  0.0609      0.662 0.980 0.000 0.000 0.000 0.020
#> GSM260945     1  0.0290      0.670 0.992 0.000 0.000 0.000 0.008
#> GSM260948     1  0.4511      0.507 0.628 0.000 0.000 0.016 0.356
#> GSM260950     1  0.3932      0.552 0.672 0.000 0.000 0.000 0.328
#> GSM260915     3  0.1041      0.743 0.000 0.000 0.964 0.004 0.032
#> GSM260917     3  0.0510      0.753 0.000 0.000 0.984 0.000 0.016
#> GSM260920     3  0.1197      0.736 0.000 0.000 0.952 0.000 0.048
#> GSM260923     3  0.3639      0.589 0.000 0.000 0.812 0.144 0.044
#> GSM260926     3  0.3216      0.635 0.000 0.000 0.848 0.108 0.044
#> GSM260928     4  0.0290      0.633 0.000 0.000 0.008 0.992 0.000
#> GSM260931     3  0.4238      0.693 0.000 0.000 0.628 0.004 0.368
#> GSM260934     3  0.4225      0.694 0.000 0.000 0.632 0.004 0.364
#> GSM260937     4  0.6304      0.265 0.000 0.000 0.156 0.460 0.384
#> GSM260940     3  0.4225      0.690 0.000 0.000 0.632 0.004 0.364
#> GSM260943     3  0.4238      0.693 0.000 0.000 0.628 0.004 0.368
#> GSM260946     3  0.4238      0.693 0.000 0.000 0.628 0.004 0.368
#> GSM260949     3  0.1357      0.734 0.000 0.000 0.948 0.004 0.048
#> GSM260951     3  0.2471      0.745 0.000 0.000 0.864 0.000 0.136

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM260888     2  0.2003     0.6945 0.000 0.884 0.000 0.000 0.000 0.116
#> GSM260893     2  0.0000     0.7275 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260896     2  0.2003     0.6948 0.000 0.884 0.000 0.000 0.000 0.116
#> GSM260899     6  0.3428     0.8887 0.000 0.304 0.000 0.000 0.000 0.696
#> GSM260902     6  0.3737     0.8285 0.000 0.392 0.000 0.000 0.000 0.608
#> GSM260905     6  0.3607     0.8716 0.000 0.348 0.000 0.000 0.000 0.652
#> GSM260908     2  0.3515    -0.1138 0.000 0.676 0.000 0.000 0.000 0.324
#> GSM260911     2  0.2491     0.6179 0.000 0.836 0.000 0.000 0.000 0.164
#> GSM260912     2  0.0000     0.7275 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260913     4  0.3868     0.4724 0.000 0.000 0.496 0.504 0.000 0.000
#> GSM260886     5  0.3747     0.4772 0.396 0.000 0.000 0.000 0.604 0.000
#> GSM260889     5  0.3747     0.4772 0.396 0.000 0.000 0.000 0.604 0.000
#> GSM260891     1  0.2260     0.8468 0.860 0.000 0.000 0.000 0.140 0.000
#> GSM260894     5  0.3747     0.4772 0.396 0.000 0.000 0.000 0.604 0.000
#> GSM260897     5  0.0547     0.6422 0.000 0.000 0.000 0.020 0.980 0.000
#> GSM260900     5  0.0632     0.6397 0.000 0.000 0.000 0.024 0.976 0.000
#> GSM260903     5  0.0777     0.6418 0.004 0.000 0.000 0.024 0.972 0.000
#> GSM260906     5  0.0777     0.6418 0.004 0.000 0.000 0.024 0.972 0.000
#> GSM260909     5  0.3765     0.4626 0.404 0.000 0.000 0.000 0.596 0.000
#> GSM260887     4  0.3868     0.4724 0.000 0.000 0.496 0.504 0.000 0.000
#> GSM260890     4  0.3175     0.6295 0.000 0.000 0.256 0.744 0.000 0.000
#> GSM260892     4  0.3867     0.4818 0.000 0.000 0.488 0.512 0.000 0.000
#> GSM260895     4  0.5803     0.0591 0.408 0.000 0.000 0.412 0.000 0.180
#> GSM260898     3  0.2703     0.7340 0.000 0.000 0.824 0.172 0.000 0.004
#> GSM260901     3  0.3215     0.6755 0.000 0.000 0.756 0.240 0.000 0.004
#> GSM260904     3  0.1285     0.6633 0.000 0.000 0.944 0.052 0.000 0.004
#> GSM260907     3  0.0547     0.6802 0.000 0.000 0.980 0.020 0.000 0.000
#> GSM260910     4  0.2941     0.6498 0.000 0.000 0.220 0.780 0.000 0.000
#> GSM260918     2  0.0000     0.7275 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260921     2  0.1204     0.7108 0.000 0.944 0.000 0.000 0.000 0.056
#> GSM260924     2  0.3126     0.5610 0.000 0.752 0.000 0.000 0.000 0.248
#> GSM260929     2  0.0146     0.7275 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM260932     6  0.3446     0.8906 0.000 0.308 0.000 0.000 0.000 0.692
#> GSM260935     6  0.3515     0.8910 0.000 0.324 0.000 0.000 0.000 0.676
#> GSM260938     6  0.3314     0.8317 0.004 0.256 0.000 0.000 0.000 0.740
#> GSM260941     6  0.3828     0.7287 0.000 0.440 0.000 0.000 0.000 0.560
#> GSM260944     2  0.3843    -0.5653 0.000 0.548 0.000 0.000 0.000 0.452
#> GSM260947     2  0.3868    -0.6584 0.000 0.508 0.000 0.000 0.000 0.492
#> GSM260952     2  0.0000     0.7275 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260914     5  0.3737     0.4822 0.392 0.000 0.000 0.000 0.608 0.000
#> GSM260916     1  0.3198     0.7804 0.740 0.000 0.000 0.000 0.260 0.000
#> GSM260919     5  0.3737     0.4803 0.392 0.000 0.000 0.000 0.608 0.000
#> GSM260922     1  0.2664     0.8788 0.816 0.000 0.000 0.000 0.184 0.000
#> GSM260925     5  0.3747     0.4772 0.396 0.000 0.000 0.000 0.604 0.000
#> GSM260927     5  0.3647     0.5034 0.360 0.000 0.000 0.000 0.640 0.000
#> GSM260930     5  0.0777     0.6418 0.004 0.000 0.000 0.024 0.972 0.000
#> GSM260933     5  0.0458     0.6490 0.016 0.000 0.000 0.000 0.984 0.000
#> GSM260936     5  0.1257     0.6394 0.028 0.000 0.000 0.000 0.952 0.020
#> GSM260939     5  0.1616     0.6253 0.048 0.000 0.000 0.000 0.932 0.020
#> GSM260942     5  0.1257     0.6394 0.028 0.000 0.000 0.000 0.952 0.020
#> GSM260945     5  0.0717     0.6446 0.008 0.000 0.000 0.000 0.976 0.016
#> GSM260948     5  0.3804     0.3857 0.424 0.000 0.000 0.000 0.576 0.000
#> GSM260950     5  0.3547     0.5172 0.332 0.000 0.000 0.000 0.668 0.000
#> GSM260915     4  0.3023     0.6458 0.000 0.000 0.232 0.768 0.000 0.000
#> GSM260917     4  0.3620     0.5322 0.000 0.000 0.352 0.648 0.000 0.000
#> GSM260920     4  0.2969     0.6488 0.000 0.000 0.224 0.776 0.000 0.000
#> GSM260923     4  0.2048     0.5913 0.000 0.000 0.120 0.880 0.000 0.000
#> GSM260926     4  0.2697     0.6395 0.000 0.000 0.188 0.812 0.000 0.000
#> GSM260928     4  0.5803     0.0591 0.408 0.000 0.000 0.412 0.000 0.180
#> GSM260931     3  0.0363     0.6832 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM260934     3  0.2562     0.7356 0.000 0.000 0.828 0.172 0.000 0.000
#> GSM260937     3  0.6617     0.3609 0.120 0.000 0.540 0.144 0.000 0.196
#> GSM260940     3  0.3629     0.6668 0.000 0.000 0.724 0.260 0.000 0.016
#> GSM260943     3  0.2595     0.7408 0.000 0.000 0.836 0.160 0.000 0.004
#> GSM260946     3  0.2416     0.7407 0.000 0.000 0.844 0.156 0.000 0.000
#> GSM260949     4  0.2941     0.6491 0.000 0.000 0.220 0.780 0.000 0.000
#> GSM260951     3  0.3810    -0.3445 0.000 0.000 0.572 0.428 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) cell.type(p) k
#> SD:mclust 67            0.939     2.75e-14 2
#> SD:mclust 65            0.924     7.14e-26 3
#> SD:mclust 67            0.975     3.11e-25 4
#> SD:mclust 65            0.980     4.41e-23 5
#> SD:mclust 49            0.910     1.37e-16 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 21168 rows and 67 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4257 0.575   0.575
#> 3 3 1.000           0.983       0.994         0.5858 0.750   0.566
#> 4 4 0.936           0.883       0.954         0.0383 0.990   0.968
#> 5 5 0.931           0.884       0.945         0.0178 0.990   0.967
#> 6 6 0.906           0.798       0.914         0.0283 0.980   0.934

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM260888     2       0          1  0  1
#> GSM260893     2       0          1  0  1
#> GSM260896     2       0          1  0  1
#> GSM260899     2       0          1  0  1
#> GSM260902     2       0          1  0  1
#> GSM260905     2       0          1  0  1
#> GSM260908     2       0          1  0  1
#> GSM260911     2       0          1  0  1
#> GSM260912     2       0          1  0  1
#> GSM260913     1       0          1  1  0
#> GSM260886     1       0          1  1  0
#> GSM260889     1       0          1  1  0
#> GSM260891     1       0          1  1  0
#> GSM260894     1       0          1  1  0
#> GSM260897     1       0          1  1  0
#> GSM260900     1       0          1  1  0
#> GSM260903     1       0          1  1  0
#> GSM260906     1       0          1  1  0
#> GSM260909     1       0          1  1  0
#> GSM260887     1       0          1  1  0
#> GSM260890     1       0          1  1  0
#> GSM260892     1       0          1  1  0
#> GSM260895     1       0          1  1  0
#> GSM260898     1       0          1  1  0
#> GSM260901     1       0          1  1  0
#> GSM260904     1       0          1  1  0
#> GSM260907     1       0          1  1  0
#> GSM260910     1       0          1  1  0
#> GSM260918     2       0          1  0  1
#> GSM260921     2       0          1  0  1
#> GSM260924     2       0          1  0  1
#> GSM260929     2       0          1  0  1
#> GSM260932     2       0          1  0  1
#> GSM260935     2       0          1  0  1
#> GSM260938     2       0          1  0  1
#> GSM260941     2       0          1  0  1
#> GSM260944     2       0          1  0  1
#> GSM260947     2       0          1  0  1
#> GSM260952     2       0          1  0  1
#> GSM260914     1       0          1  1  0
#> GSM260916     1       0          1  1  0
#> GSM260919     1       0          1  1  0
#> GSM260922     1       0          1  1  0
#> GSM260925     1       0          1  1  0
#> GSM260927     1       0          1  1  0
#> GSM260930     1       0          1  1  0
#> GSM260933     1       0          1  1  0
#> GSM260936     1       0          1  1  0
#> GSM260939     1       0          1  1  0
#> GSM260942     1       0          1  1  0
#> GSM260945     1       0          1  1  0
#> GSM260948     1       0          1  1  0
#> GSM260950     1       0          1  1  0
#> GSM260915     1       0          1  1  0
#> GSM260917     1       0          1  1  0
#> GSM260920     1       0          1  1  0
#> GSM260923     1       0          1  1  0
#> GSM260926     1       0          1  1  0
#> GSM260928     1       0          1  1  0
#> GSM260931     1       0          1  1  0
#> GSM260934     1       0          1  1  0
#> GSM260937     1       0          1  1  0
#> GSM260940     1       0          1  1  0
#> GSM260943     1       0          1  1  0
#> GSM260946     1       0          1  1  0
#> GSM260949     1       0          1  1  0
#> GSM260951     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM260888     2  0.0000      1.000 0.000  1 0.000
#> GSM260893     2  0.0000      1.000 0.000  1 0.000
#> GSM260896     2  0.0000      1.000 0.000  1 0.000
#> GSM260899     2  0.0000      1.000 0.000  1 0.000
#> GSM260902     2  0.0000      1.000 0.000  1 0.000
#> GSM260905     2  0.0000      1.000 0.000  1 0.000
#> GSM260908     2  0.0000      1.000 0.000  1 0.000
#> GSM260911     2  0.0000      1.000 0.000  1 0.000
#> GSM260912     2  0.0000      1.000 0.000  1 0.000
#> GSM260913     3  0.0000      0.981 0.000  0 1.000
#> GSM260886     1  0.0000      1.000 1.000  0 0.000
#> GSM260889     1  0.0000      1.000 1.000  0 0.000
#> GSM260891     1  0.0000      1.000 1.000  0 0.000
#> GSM260894     1  0.0000      1.000 1.000  0 0.000
#> GSM260897     1  0.0000      1.000 1.000  0 0.000
#> GSM260900     1  0.0000      1.000 1.000  0 0.000
#> GSM260903     1  0.0000      1.000 1.000  0 0.000
#> GSM260906     1  0.0000      1.000 1.000  0 0.000
#> GSM260909     1  0.0000      1.000 1.000  0 0.000
#> GSM260887     3  0.0000      0.981 0.000  0 1.000
#> GSM260890     3  0.0000      0.981 0.000  0 1.000
#> GSM260892     3  0.0000      0.981 0.000  0 1.000
#> GSM260895     3  0.0592      0.970 0.012  0 0.988
#> GSM260898     3  0.0000      0.981 0.000  0 1.000
#> GSM260901     3  0.0000      0.981 0.000  0 1.000
#> GSM260904     3  0.0000      0.981 0.000  0 1.000
#> GSM260907     3  0.0000      0.981 0.000  0 1.000
#> GSM260910     3  0.0000      0.981 0.000  0 1.000
#> GSM260918     2  0.0000      1.000 0.000  1 0.000
#> GSM260921     2  0.0000      1.000 0.000  1 0.000
#> GSM260924     2  0.0000      1.000 0.000  1 0.000
#> GSM260929     2  0.0000      1.000 0.000  1 0.000
#> GSM260932     2  0.0000      1.000 0.000  1 0.000
#> GSM260935     2  0.0000      1.000 0.000  1 0.000
#> GSM260938     2  0.0000      1.000 0.000  1 0.000
#> GSM260941     2  0.0000      1.000 0.000  1 0.000
#> GSM260944     2  0.0000      1.000 0.000  1 0.000
#> GSM260947     2  0.0000      1.000 0.000  1 0.000
#> GSM260952     2  0.0000      1.000 0.000  1 0.000
#> GSM260914     1  0.0000      1.000 1.000  0 0.000
#> GSM260916     1  0.0000      1.000 1.000  0 0.000
#> GSM260919     1  0.0000      1.000 1.000  0 0.000
#> GSM260922     1  0.0000      1.000 1.000  0 0.000
#> GSM260925     1  0.0000      1.000 1.000  0 0.000
#> GSM260927     1  0.0000      1.000 1.000  0 0.000
#> GSM260930     1  0.0000      1.000 1.000  0 0.000
#> GSM260933     1  0.0000      1.000 1.000  0 0.000
#> GSM260936     1  0.0000      1.000 1.000  0 0.000
#> GSM260939     1  0.0000      1.000 1.000  0 0.000
#> GSM260942     1  0.0000      1.000 1.000  0 0.000
#> GSM260945     1  0.0000      1.000 1.000  0 0.000
#> GSM260948     1  0.0000      1.000 1.000  0 0.000
#> GSM260950     1  0.0000      1.000 1.000  0 0.000
#> GSM260915     3  0.0000      0.981 0.000  0 1.000
#> GSM260917     3  0.0000      0.981 0.000  0 1.000
#> GSM260920     3  0.0000      0.981 0.000  0 1.000
#> GSM260923     3  0.0000      0.981 0.000  0 1.000
#> GSM260926     3  0.0000      0.981 0.000  0 1.000
#> GSM260928     3  0.6168      0.301 0.412  0 0.588
#> GSM260931     3  0.0000      0.981 0.000  0 1.000
#> GSM260934     3  0.0000      0.981 0.000  0 1.000
#> GSM260937     3  0.0000      0.981 0.000  0 1.000
#> GSM260940     3  0.0000      0.981 0.000  0 1.000
#> GSM260943     3  0.0000      0.981 0.000  0 1.000
#> GSM260946     3  0.0000      0.981 0.000  0 1.000
#> GSM260949     3  0.0000      0.981 0.000  0 1.000
#> GSM260951     3  0.0000      0.981 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM260888     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260893     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260896     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260899     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260902     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260905     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260908     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260911     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260912     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260913     3  0.0188      0.885 0.000  0 0.996 0.004
#> GSM260886     1  0.0817      0.942 0.976  0 0.000 0.024
#> GSM260889     1  0.0188      0.948 0.996  0 0.000 0.004
#> GSM260891     1  0.2216      0.898 0.908  0 0.000 0.092
#> GSM260894     1  0.0188      0.948 0.996  0 0.000 0.004
#> GSM260897     1  0.0817      0.945 0.976  0 0.000 0.024
#> GSM260900     1  0.0592      0.948 0.984  0 0.000 0.016
#> GSM260903     1  0.0592      0.948 0.984  0 0.000 0.016
#> GSM260906     1  0.0592      0.948 0.984  0 0.000 0.016
#> GSM260909     1  0.1022      0.938 0.968  0 0.000 0.032
#> GSM260887     3  0.0000      0.887 0.000  0 1.000 0.000
#> GSM260890     3  0.0000      0.887 0.000  0 1.000 0.000
#> GSM260892     3  0.2868      0.731 0.000  0 0.864 0.136
#> GSM260895     3  0.5137      0.331 0.024  0 0.680 0.296
#> GSM260898     3  0.0707      0.884 0.000  0 0.980 0.020
#> GSM260901     3  0.0817      0.882 0.000  0 0.976 0.024
#> GSM260904     3  0.0592      0.885 0.000  0 0.984 0.016
#> GSM260907     3  0.0592      0.885 0.000  0 0.984 0.016
#> GSM260910     3  0.2345      0.785 0.000  0 0.900 0.100
#> GSM260918     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260921     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260924     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260929     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260932     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260935     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260938     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260941     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260944     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260947     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260952     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260914     1  0.0469      0.947 0.988  0 0.000 0.012
#> GSM260916     1  0.3837      0.769 0.776  0 0.000 0.224
#> GSM260919     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM260922     1  0.3975      0.750 0.760  0 0.000 0.240
#> GSM260925     1  0.0469      0.947 0.988  0 0.000 0.012
#> GSM260927     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM260930     1  0.0592      0.948 0.984  0 0.000 0.016
#> GSM260933     1  0.0707      0.947 0.980  0 0.000 0.020
#> GSM260936     1  0.1792      0.921 0.932  0 0.000 0.068
#> GSM260939     1  0.4103      0.719 0.744  0 0.000 0.256
#> GSM260942     1  0.2345      0.897 0.900  0 0.000 0.100
#> GSM260945     1  0.0921      0.944 0.972  0 0.000 0.028
#> GSM260948     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM260950     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM260915     3  0.0000      0.887 0.000  0 1.000 0.000
#> GSM260917     3  0.0469      0.886 0.000  0 0.988 0.012
#> GSM260920     3  0.0000      0.887 0.000  0 1.000 0.000
#> GSM260923     3  0.0188      0.885 0.000  0 0.996 0.004
#> GSM260926     3  0.0000      0.887 0.000  0 1.000 0.000
#> GSM260928     3  0.4898     -0.030 0.416  0 0.584 0.000
#> GSM260931     3  0.1118      0.874 0.000  0 0.964 0.036
#> GSM260934     3  0.0707      0.884 0.000  0 0.980 0.020
#> GSM260937     4  0.4543      0.000 0.000  0 0.324 0.676
#> GSM260940     3  0.3907      0.524 0.000  0 0.768 0.232
#> GSM260943     3  0.2530      0.783 0.000  0 0.888 0.112
#> GSM260946     3  0.1211      0.871 0.000  0 0.960 0.040
#> GSM260949     3  0.0000      0.887 0.000  0 1.000 0.000
#> GSM260951     3  0.0707      0.883 0.000  0 0.980 0.020

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4 p5
#> GSM260888     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260893     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260896     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260899     2  0.1836     0.9444 0.000 0.932 0.000 0.032 NA
#> GSM260902     2  0.1117     0.9684 0.000 0.964 0.000 0.016 NA
#> GSM260905     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260908     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260911     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260912     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260913     3  0.0162     0.8570 0.000 0.000 0.996 0.004 NA
#> GSM260886     1  0.0609     0.9661 0.980 0.000 0.000 0.000 NA
#> GSM260889     1  0.0609     0.9661 0.980 0.000 0.000 0.000 NA
#> GSM260891     1  0.0880     0.9604 0.968 0.000 0.000 0.000 NA
#> GSM260894     1  0.0510     0.9690 0.984 0.000 0.000 0.000 NA
#> GSM260897     1  0.0290     0.9690 0.992 0.000 0.000 0.000 NA
#> GSM260900     1  0.0162     0.9698 0.996 0.000 0.000 0.000 NA
#> GSM260903     1  0.0162     0.9698 0.996 0.000 0.000 0.000 NA
#> GSM260906     1  0.0162     0.9698 0.996 0.000 0.000 0.000 NA
#> GSM260909     1  0.0609     0.9661 0.980 0.000 0.000 0.000 NA
#> GSM260887     3  0.0000     0.8569 0.000 0.000 1.000 0.000 NA
#> GSM260890     3  0.0880     0.8444 0.000 0.000 0.968 0.000 NA
#> GSM260892     3  0.3300     0.7024 0.000 0.000 0.792 0.004 NA
#> GSM260895     3  0.2605     0.7523 0.000 0.000 0.852 0.000 NA
#> GSM260898     3  0.0912     0.8543 0.000 0.000 0.972 0.016 NA
#> GSM260901     3  0.1310     0.8498 0.000 0.000 0.956 0.024 NA
#> GSM260904     3  0.0609     0.8560 0.000 0.000 0.980 0.020 NA
#> GSM260907     3  0.0703     0.8548 0.000 0.000 0.976 0.024 NA
#> GSM260910     3  0.2329     0.7737 0.000 0.000 0.876 0.000 NA
#> GSM260918     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260921     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260924     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260929     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260932     2  0.1753     0.9476 0.000 0.936 0.000 0.032 NA
#> GSM260935     2  0.1117     0.9684 0.000 0.964 0.000 0.016 NA
#> GSM260938     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260941     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260944     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260947     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260952     2  0.0000     0.9904 0.000 1.000 0.000 0.000 NA
#> GSM260914     1  0.0404     0.9682 0.988 0.000 0.000 0.000 NA
#> GSM260916     1  0.3395     0.7647 0.764 0.000 0.000 0.000 NA
#> GSM260919     1  0.0609     0.9666 0.980 0.000 0.000 0.000 NA
#> GSM260922     1  0.3480     0.7486 0.752 0.000 0.000 0.000 NA
#> GSM260925     1  0.0609     0.9661 0.980 0.000 0.000 0.000 NA
#> GSM260927     1  0.0162     0.9698 0.996 0.000 0.000 0.000 NA
#> GSM260930     1  0.0162     0.9698 0.996 0.000 0.000 0.000 NA
#> GSM260933     1  0.0290     0.9690 0.992 0.000 0.000 0.000 NA
#> GSM260936     1  0.0451     0.9670 0.988 0.000 0.000 0.008 NA
#> GSM260939     1  0.1205     0.9442 0.956 0.000 0.000 0.040 NA
#> GSM260942     1  0.0451     0.9670 0.988 0.000 0.000 0.008 NA
#> GSM260945     1  0.0162     0.9698 0.996 0.000 0.000 0.000 NA
#> GSM260948     1  0.0162     0.9698 0.996 0.000 0.000 0.000 NA
#> GSM260950     1  0.0000     0.9698 1.000 0.000 0.000 0.000 NA
#> GSM260915     3  0.0000     0.8569 0.000 0.000 1.000 0.000 NA
#> GSM260917     3  0.0609     0.8560 0.000 0.000 0.980 0.020 NA
#> GSM260920     3  0.0510     0.8560 0.000 0.000 0.984 0.016 NA
#> GSM260923     3  0.1197     0.8360 0.000 0.000 0.952 0.000 NA
#> GSM260926     3  0.0000     0.8569 0.000 0.000 1.000 0.000 NA
#> GSM260928     3  0.4903     0.4476 0.228 0.000 0.712 0.032 NA
#> GSM260931     3  0.3242     0.6447 0.000 0.000 0.784 0.216 NA
#> GSM260934     3  0.0609     0.8554 0.000 0.000 0.980 0.020 NA
#> GSM260937     4  0.2674     0.7753 0.000 0.000 0.140 0.856 NA
#> GSM260940     3  0.4219     0.0615 0.000 0.000 0.584 0.416 NA
#> GSM260943     4  0.3774     0.7215 0.000 0.000 0.296 0.704 NA
#> GSM260946     3  0.3452     0.5953 0.000 0.000 0.756 0.244 NA
#> GSM260949     3  0.0000     0.8569 0.000 0.000 1.000 0.000 NA
#> GSM260951     3  0.4045     0.3070 0.000 0.000 0.644 0.356 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
#> GSM260888     2  0.0547     0.9195 0.000 0.980 0.000 0.000 0.000 NA
#> GSM260893     2  0.0000     0.9227 0.000 1.000 0.000 0.000 0.000 NA
#> GSM260896     2  0.0146     0.9225 0.000 0.996 0.000 0.000 0.000 NA
#> GSM260899     2  0.3804     0.5740 0.000 0.576 0.000 0.000 0.000 NA
#> GSM260902     2  0.3499     0.6918 0.000 0.680 0.000 0.000 0.000 NA
#> GSM260905     2  0.0146     0.9223 0.004 0.996 0.000 0.000 0.000 NA
#> GSM260908     2  0.0260     0.9222 0.000 0.992 0.000 0.000 0.000 NA
#> GSM260911     2  0.0717     0.9178 0.008 0.976 0.000 0.000 0.000 NA
#> GSM260912     2  0.0000     0.9227 0.000 1.000 0.000 0.000 0.000 NA
#> GSM260913     4  0.0692     0.8765 0.004 0.000 0.020 0.976 0.000 NA
#> GSM260886     5  0.1007     0.8964 0.044 0.000 0.000 0.000 0.956 NA
#> GSM260889     5  0.0363     0.9114 0.012 0.000 0.000 0.000 0.988 NA
#> GSM260891     5  0.1857     0.8629 0.032 0.000 0.012 0.000 0.928 NA
#> GSM260894     5  0.0508     0.9118 0.012 0.000 0.004 0.000 0.984 NA
#> GSM260897     5  0.1523     0.8680 0.044 0.000 0.008 0.000 0.940 NA
#> GSM260900     5  0.0000     0.9124 0.000 0.000 0.000 0.000 1.000 NA
#> GSM260903     5  0.0363     0.9120 0.012 0.000 0.000 0.000 0.988 NA
#> GSM260906     5  0.0146     0.9126 0.004 0.000 0.000 0.000 0.996 NA
#> GSM260909     5  0.0922     0.9084 0.024 0.000 0.004 0.000 0.968 NA
#> GSM260887     4  0.0146     0.8758 0.000 0.000 0.004 0.996 0.000 NA
#> GSM260890     4  0.0291     0.8754 0.000 0.000 0.004 0.992 0.000 NA
#> GSM260892     4  0.2544     0.7619 0.140 0.000 0.004 0.852 0.000 NA
#> GSM260895     4  0.1621     0.8433 0.048 0.000 0.004 0.936 0.008 NA
#> GSM260898     4  0.0717     0.8771 0.000 0.000 0.008 0.976 0.000 NA
#> GSM260901     4  0.0632     0.8753 0.000 0.000 0.000 0.976 0.000 NA
#> GSM260904     4  0.0937     0.8676 0.000 0.000 0.040 0.960 0.000 NA
#> GSM260907     4  0.1141     0.8607 0.000 0.000 0.052 0.948 0.000 NA
#> GSM260910     4  0.0725     0.8692 0.012 0.000 0.012 0.976 0.000 NA
#> GSM260918     2  0.0000     0.9227 0.000 1.000 0.000 0.000 0.000 NA
#> GSM260921     2  0.0777     0.9182 0.004 0.972 0.000 0.000 0.000 NA
#> GSM260924     2  0.1124     0.9046 0.036 0.956 0.000 0.000 0.000 NA
#> GSM260929     2  0.0000     0.9227 0.000 1.000 0.000 0.000 0.000 NA
#> GSM260932     2  0.3774     0.5983 0.000 0.592 0.000 0.000 0.000 NA
#> GSM260935     2  0.3351     0.7218 0.000 0.712 0.000 0.000 0.000 NA
#> GSM260938     2  0.0692     0.9182 0.000 0.976 0.004 0.000 0.000 NA
#> GSM260941     2  0.0260     0.9225 0.000 0.992 0.000 0.000 0.000 NA
#> GSM260944     2  0.0363     0.9218 0.000 0.988 0.000 0.000 0.000 NA
#> GSM260947     2  0.0146     0.9225 0.000 0.996 0.000 0.000 0.000 NA
#> GSM260952     2  0.0146     0.9225 0.000 0.996 0.000 0.000 0.000 NA
#> GSM260914     5  0.1007     0.8959 0.044 0.000 0.000 0.000 0.956 NA
#> GSM260916     5  0.3592    -0.3859 0.344 0.000 0.000 0.000 0.656 NA
#> GSM260919     5  0.1267     0.8820 0.060 0.000 0.000 0.000 0.940 NA
#> GSM260922     1  0.3860     0.0000 0.528 0.000 0.000 0.000 0.472 NA
#> GSM260925     5  0.1075     0.8922 0.048 0.000 0.000 0.000 0.952 NA
#> GSM260927     5  0.0520     0.9121 0.008 0.000 0.008 0.000 0.984 NA
#> GSM260930     5  0.0260     0.9121 0.000 0.000 0.008 0.000 0.992 NA
#> GSM260933     5  0.0717     0.9065 0.016 0.000 0.008 0.000 0.976 NA
#> GSM260936     5  0.0914     0.9035 0.016 0.000 0.016 0.000 0.968 NA
#> GSM260939     5  0.1780     0.8438 0.048 0.000 0.028 0.000 0.924 NA
#> GSM260942     5  0.0972     0.8961 0.028 0.000 0.008 0.000 0.964 NA
#> GSM260945     5  0.0603     0.9081 0.016 0.000 0.004 0.000 0.980 NA
#> GSM260948     5  0.1644     0.8507 0.076 0.000 0.000 0.000 0.920 NA
#> GSM260950     5  0.0632     0.9080 0.024 0.000 0.000 0.000 0.976 NA
#> GSM260915     4  0.0000     0.8755 0.000 0.000 0.000 1.000 0.000 NA
#> GSM260917     4  0.1204     0.8583 0.000 0.000 0.056 0.944 0.000 NA
#> GSM260920     4  0.0725     0.8761 0.012 0.000 0.012 0.976 0.000 NA
#> GSM260923     4  0.0632     0.8708 0.024 0.000 0.000 0.976 0.000 NA
#> GSM260926     4  0.0146     0.8759 0.000 0.000 0.000 0.996 0.000 NA
#> GSM260928     4  0.5491     0.2761 0.084 0.000 0.020 0.624 0.260 NA
#> GSM260931     4  0.3288     0.5393 0.000 0.000 0.276 0.724 0.000 NA
#> GSM260934     4  0.0935     0.8705 0.000 0.000 0.032 0.964 0.000 NA
#> GSM260937     3  0.0972     0.5584 0.000 0.000 0.964 0.028 0.000 NA
#> GSM260940     4  0.3937     0.0231 0.000 0.000 0.424 0.572 0.000 NA
#> GSM260943     3  0.2805     0.6994 0.004 0.000 0.812 0.184 0.000 NA
#> GSM260946     4  0.3126     0.5973 0.000 0.000 0.248 0.752 0.000 NA
#> GSM260949     4  0.0405     0.8776 0.000 0.000 0.004 0.988 0.000 NA
#> GSM260951     3  0.3797     0.3285 0.000 0.000 0.580 0.420 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-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) cell.type(p) k
#> SD:NMF 67            0.939     2.75e-14 2
#> SD:NMF 66            0.920     2.62e-26 3
#> SD:NMF 64            0.925     1.95e-25 4
#> SD:NMF 64            0.498     5.95e-24 5
#> SD:NMF 62            0.548     3.77e-23 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 21168 rows and 67 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4257 0.575   0.575
#> 3 3 1.000           0.986       0.994         0.5856 0.750   0.566
#> 4 4 0.919           0.885       0.954         0.0437 0.980   0.939
#> 5 5 0.886           0.767       0.895         0.0419 0.972   0.910
#> 6 6 0.872           0.750       0.849         0.0518 0.929   0.750

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM260888     2       0          1  0  1
#> GSM260893     2       0          1  0  1
#> GSM260896     2       0          1  0  1
#> GSM260899     2       0          1  0  1
#> GSM260902     2       0          1  0  1
#> GSM260905     2       0          1  0  1
#> GSM260908     2       0          1  0  1
#> GSM260911     2       0          1  0  1
#> GSM260912     2       0          1  0  1
#> GSM260913     1       0          1  1  0
#> GSM260886     1       0          1  1  0
#> GSM260889     1       0          1  1  0
#> GSM260891     1       0          1  1  0
#> GSM260894     1       0          1  1  0
#> GSM260897     1       0          1  1  0
#> GSM260900     1       0          1  1  0
#> GSM260903     1       0          1  1  0
#> GSM260906     1       0          1  1  0
#> GSM260909     1       0          1  1  0
#> GSM260887     1       0          1  1  0
#> GSM260890     1       0          1  1  0
#> GSM260892     1       0          1  1  0
#> GSM260895     1       0          1  1  0
#> GSM260898     1       0          1  1  0
#> GSM260901     1       0          1  1  0
#> GSM260904     1       0          1  1  0
#> GSM260907     1       0          1  1  0
#> GSM260910     1       0          1  1  0
#> GSM260918     2       0          1  0  1
#> GSM260921     2       0          1  0  1
#> GSM260924     2       0          1  0  1
#> GSM260929     2       0          1  0  1
#> GSM260932     2       0          1  0  1
#> GSM260935     2       0          1  0  1
#> GSM260938     2       0          1  0  1
#> GSM260941     2       0          1  0  1
#> GSM260944     2       0          1  0  1
#> GSM260947     2       0          1  0  1
#> GSM260952     2       0          1  0  1
#> GSM260914     1       0          1  1  0
#> GSM260916     1       0          1  1  0
#> GSM260919     1       0          1  1  0
#> GSM260922     1       0          1  1  0
#> GSM260925     1       0          1  1  0
#> GSM260927     1       0          1  1  0
#> GSM260930     1       0          1  1  0
#> GSM260933     1       0          1  1  0
#> GSM260936     1       0          1  1  0
#> GSM260939     1       0          1  1  0
#> GSM260942     1       0          1  1  0
#> GSM260945     1       0          1  1  0
#> GSM260948     1       0          1  1  0
#> GSM260950     1       0          1  1  0
#> GSM260915     1       0          1  1  0
#> GSM260917     1       0          1  1  0
#> GSM260920     1       0          1  1  0
#> GSM260923     1       0          1  1  0
#> GSM260926     1       0          1  1  0
#> GSM260928     1       0          1  1  0
#> GSM260931     1       0          1  1  0
#> GSM260934     1       0          1  1  0
#> GSM260937     1       0          1  1  0
#> GSM260940     1       0          1  1  0
#> GSM260943     1       0          1  1  0
#> GSM260946     1       0          1  1  0
#> GSM260949     1       0          1  1  0
#> GSM260951     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM260888     2   0.000      1.000 0.000  1 0.000
#> GSM260893     2   0.000      1.000 0.000  1 0.000
#> GSM260896     2   0.000      1.000 0.000  1 0.000
#> GSM260899     2   0.000      1.000 0.000  1 0.000
#> GSM260902     2   0.000      1.000 0.000  1 0.000
#> GSM260905     2   0.000      1.000 0.000  1 0.000
#> GSM260908     2   0.000      1.000 0.000  1 0.000
#> GSM260911     2   0.000      1.000 0.000  1 0.000
#> GSM260912     2   0.000      1.000 0.000  1 0.000
#> GSM260913     3   0.000      0.982 0.000  0 1.000
#> GSM260886     1   0.000      1.000 1.000  0 0.000
#> GSM260889     1   0.000      1.000 1.000  0 0.000
#> GSM260891     1   0.000      1.000 1.000  0 0.000
#> GSM260894     1   0.000      1.000 1.000  0 0.000
#> GSM260897     1   0.000      1.000 1.000  0 0.000
#> GSM260900     1   0.000      1.000 1.000  0 0.000
#> GSM260903     1   0.000      1.000 1.000  0 0.000
#> GSM260906     1   0.000      1.000 1.000  0 0.000
#> GSM260909     1   0.000      1.000 1.000  0 0.000
#> GSM260887     3   0.000      0.982 0.000  0 1.000
#> GSM260890     3   0.000      0.982 0.000  0 1.000
#> GSM260892     3   0.000      0.982 0.000  0 1.000
#> GSM260895     3   0.312      0.875 0.108  0 0.892
#> GSM260898     3   0.000      0.982 0.000  0 1.000
#> GSM260901     3   0.000      0.982 0.000  0 1.000
#> GSM260904     3   0.000      0.982 0.000  0 1.000
#> GSM260907     3   0.000      0.982 0.000  0 1.000
#> GSM260910     3   0.000      0.982 0.000  0 1.000
#> GSM260918     2   0.000      1.000 0.000  1 0.000
#> GSM260921     2   0.000      1.000 0.000  1 0.000
#> GSM260924     2   0.000      1.000 0.000  1 0.000
#> GSM260929     2   0.000      1.000 0.000  1 0.000
#> GSM260932     2   0.000      1.000 0.000  1 0.000
#> GSM260935     2   0.000      1.000 0.000  1 0.000
#> GSM260938     2   0.000      1.000 0.000  1 0.000
#> GSM260941     2   0.000      1.000 0.000  1 0.000
#> GSM260944     2   0.000      1.000 0.000  1 0.000
#> GSM260947     2   0.000      1.000 0.000  1 0.000
#> GSM260952     2   0.000      1.000 0.000  1 0.000
#> GSM260914     1   0.000      1.000 1.000  0 0.000
#> GSM260916     1   0.000      1.000 1.000  0 0.000
#> GSM260919     1   0.000      1.000 1.000  0 0.000
#> GSM260922     1   0.000      1.000 1.000  0 0.000
#> GSM260925     1   0.000      1.000 1.000  0 0.000
#> GSM260927     1   0.000      1.000 1.000  0 0.000
#> GSM260930     1   0.000      1.000 1.000  0 0.000
#> GSM260933     1   0.000      1.000 1.000  0 0.000
#> GSM260936     1   0.000      1.000 1.000  0 0.000
#> GSM260939     1   0.000      1.000 1.000  0 0.000
#> GSM260942     1   0.000      1.000 1.000  0 0.000
#> GSM260945     1   0.000      1.000 1.000  0 0.000
#> GSM260948     1   0.000      1.000 1.000  0 0.000
#> GSM260950     1   0.000      1.000 1.000  0 0.000
#> GSM260915     3   0.000      0.982 0.000  0 1.000
#> GSM260917     3   0.000      0.982 0.000  0 1.000
#> GSM260920     3   0.000      0.982 0.000  0 1.000
#> GSM260923     3   0.000      0.982 0.000  0 1.000
#> GSM260926     3   0.000      0.982 0.000  0 1.000
#> GSM260928     3   0.546      0.606 0.288  0 0.712
#> GSM260931     3   0.000      0.982 0.000  0 1.000
#> GSM260934     3   0.000      0.982 0.000  0 1.000
#> GSM260937     3   0.000      0.982 0.000  0 1.000
#> GSM260940     3   0.000      0.982 0.000  0 1.000
#> GSM260943     3   0.000      0.982 0.000  0 1.000
#> GSM260946     3   0.000      0.982 0.000  0 1.000
#> GSM260949     3   0.000      0.982 0.000  0 1.000
#> GSM260951     3   0.000      0.982 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM260888     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260893     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260896     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260899     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260902     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260905     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260908     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260911     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260912     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260913     3  0.0000      0.816 0.000  0 1.000 0.000
#> GSM260886     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260889     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260891     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260894     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260897     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260900     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260903     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260906     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260909     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260887     3  0.0000      0.816 0.000  0 1.000 0.000
#> GSM260890     3  0.0000      0.816 0.000  0 1.000 0.000
#> GSM260892     3  0.0000      0.816 0.000  0 1.000 0.000
#> GSM260895     3  0.2469      0.685 0.108  0 0.892 0.000
#> GSM260898     3  0.3356      0.741 0.000  0 0.824 0.176
#> GSM260901     3  0.3356      0.741 0.000  0 0.824 0.176
#> GSM260904     3  0.2921      0.762 0.000  0 0.860 0.140
#> GSM260907     3  0.3356      0.741 0.000  0 0.824 0.176
#> GSM260910     3  0.0000      0.816 0.000  0 1.000 0.000
#> GSM260918     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260921     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260924     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260929     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260932     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260935     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260938     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260941     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260944     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260947     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260952     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260914     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260916     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260919     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260922     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260925     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260927     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260930     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260933     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260936     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260939     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260942     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260945     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260948     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260950     1  0.0000      1.000 1.000  0 0.000 0.000
#> GSM260915     3  0.0000      0.816 0.000  0 1.000 0.000
#> GSM260917     3  0.0469      0.810 0.000  0 0.988 0.012
#> GSM260920     3  0.0000      0.816 0.000  0 1.000 0.000
#> GSM260923     3  0.0000      0.816 0.000  0 1.000 0.000
#> GSM260926     3  0.0000      0.816 0.000  0 1.000 0.000
#> GSM260928     3  0.4331      0.396 0.288  0 0.712 0.000
#> GSM260931     3  0.4817      0.395 0.000  0 0.612 0.388
#> GSM260934     3  0.3356      0.741 0.000  0 0.824 0.176
#> GSM260937     4  0.0000      0.560 0.000  0 0.000 1.000
#> GSM260940     3  0.4817      0.395 0.000  0 0.612 0.388
#> GSM260943     3  0.4916      0.285 0.000  0 0.576 0.424
#> GSM260946     3  0.4431      0.574 0.000  0 0.696 0.304
#> GSM260949     3  0.0000      0.816 0.000  0 1.000 0.000
#> GSM260951     4  0.4624      0.284 0.000  0 0.340 0.660

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM260888     2  0.2020     0.9467 0.000 0.900 0.000 0.100 0.000
#> GSM260893     2  0.2020     0.9467 0.000 0.900 0.000 0.100 0.000
#> GSM260896     2  0.2020     0.9467 0.000 0.900 0.000 0.100 0.000
#> GSM260899     2  0.0162     0.9454 0.000 0.996 0.000 0.004 0.000
#> GSM260902     2  0.0162     0.9454 0.000 0.996 0.000 0.004 0.000
#> GSM260905     2  0.0000     0.9464 0.000 1.000 0.000 0.000 0.000
#> GSM260908     2  0.0000     0.9464 0.000 1.000 0.000 0.000 0.000
#> GSM260911     2  0.2020     0.9467 0.000 0.900 0.000 0.100 0.000
#> GSM260912     2  0.2074     0.9464 0.000 0.896 0.000 0.104 0.000
#> GSM260913     3  0.0162     0.6666 0.000 0.000 0.996 0.004 0.000
#> GSM260886     1  0.0000     0.9928 1.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0000     0.9928 1.000 0.000 0.000 0.000 0.000
#> GSM260891     1  0.0000     0.9928 1.000 0.000 0.000 0.000 0.000
#> GSM260894     1  0.0000     0.9928 1.000 0.000 0.000 0.000 0.000
#> GSM260897     1  0.0404     0.9919 0.988 0.000 0.000 0.012 0.000
#> GSM260900     1  0.0404     0.9919 0.988 0.000 0.000 0.012 0.000
#> GSM260903     1  0.0404     0.9919 0.988 0.000 0.000 0.012 0.000
#> GSM260906     1  0.0404     0.9919 0.988 0.000 0.000 0.012 0.000
#> GSM260909     1  0.0000     0.9928 1.000 0.000 0.000 0.000 0.000
#> GSM260887     3  0.1410     0.6601 0.000 0.000 0.940 0.060 0.000
#> GSM260890     3  0.1270     0.6626 0.000 0.000 0.948 0.052 0.000
#> GSM260892     3  0.0290     0.6659 0.000 0.000 0.992 0.008 0.000
#> GSM260895     4  0.4150     0.3905 0.000 0.000 0.388 0.612 0.000
#> GSM260898     3  0.6054     0.3152 0.000 0.000 0.568 0.260 0.172
#> GSM260901     3  0.6054     0.3152 0.000 0.000 0.568 0.260 0.172
#> GSM260904     3  0.5815     0.3507 0.000 0.000 0.592 0.272 0.136
#> GSM260907     3  0.6034     0.3198 0.000 0.000 0.572 0.256 0.172
#> GSM260910     3  0.0703     0.6643 0.000 0.000 0.976 0.024 0.000
#> GSM260918     2  0.2074     0.9464 0.000 0.896 0.000 0.104 0.000
#> GSM260921     2  0.2020     0.9467 0.000 0.900 0.000 0.100 0.000
#> GSM260924     2  0.2074     0.9452 0.000 0.896 0.000 0.104 0.000
#> GSM260929     2  0.2074     0.9464 0.000 0.896 0.000 0.104 0.000
#> GSM260932     2  0.0162     0.9454 0.000 0.996 0.000 0.004 0.000
#> GSM260935     2  0.0162     0.9454 0.000 0.996 0.000 0.004 0.000
#> GSM260938     2  0.0404     0.9432 0.000 0.988 0.000 0.012 0.000
#> GSM260941     2  0.0162     0.9462 0.000 0.996 0.000 0.004 0.000
#> GSM260944     2  0.0162     0.9462 0.000 0.996 0.000 0.004 0.000
#> GSM260947     2  0.0162     0.9462 0.000 0.996 0.000 0.004 0.000
#> GSM260952     2  0.2074     0.9464 0.000 0.896 0.000 0.104 0.000
#> GSM260914     1  0.0000     0.9928 1.000 0.000 0.000 0.000 0.000
#> GSM260916     1  0.0290     0.9890 0.992 0.000 0.000 0.008 0.000
#> GSM260919     1  0.0290     0.9890 0.992 0.000 0.000 0.008 0.000
#> GSM260922     1  0.0290     0.9890 0.992 0.000 0.000 0.008 0.000
#> GSM260925     1  0.0000     0.9928 1.000 0.000 0.000 0.000 0.000
#> GSM260927     1  0.0000     0.9928 1.000 0.000 0.000 0.000 0.000
#> GSM260930     1  0.0404     0.9919 0.988 0.000 0.000 0.012 0.000
#> GSM260933     1  0.0404     0.9919 0.988 0.000 0.000 0.012 0.000
#> GSM260936     1  0.0404     0.9919 0.988 0.000 0.000 0.012 0.000
#> GSM260939     1  0.0404     0.9919 0.988 0.000 0.000 0.012 0.000
#> GSM260942     1  0.0404     0.9919 0.988 0.000 0.000 0.012 0.000
#> GSM260945     1  0.0404     0.9919 0.988 0.000 0.000 0.012 0.000
#> GSM260948     1  0.0290     0.9890 0.992 0.000 0.000 0.008 0.000
#> GSM260950     1  0.0000     0.9928 1.000 0.000 0.000 0.000 0.000
#> GSM260915     3  0.0794     0.6640 0.000 0.000 0.972 0.028 0.000
#> GSM260917     3  0.1597     0.6523 0.000 0.000 0.940 0.048 0.012
#> GSM260920     3  0.0510     0.6651 0.000 0.000 0.984 0.016 0.000
#> GSM260923     3  0.0880     0.6624 0.000 0.000 0.968 0.032 0.000
#> GSM260926     3  0.0290     0.6664 0.000 0.000 0.992 0.008 0.000
#> GSM260928     4  0.3214     0.3640 0.120 0.000 0.036 0.844 0.000
#> GSM260931     3  0.6330    -0.2056 0.000 0.000 0.456 0.160 0.384
#> GSM260934     3  0.6054     0.3152 0.000 0.000 0.568 0.260 0.172
#> GSM260937     5  0.0000     0.0737 0.000 0.000 0.000 0.000 1.000
#> GSM260940     3  0.6356    -0.2155 0.000 0.000 0.452 0.164 0.384
#> GSM260943     5  0.6350    -0.0348 0.000 0.000 0.420 0.160 0.420
#> GSM260946     3  0.6575    -0.0452 0.000 0.000 0.464 0.236 0.300
#> GSM260949     3  0.0162     0.6672 0.000 0.000 0.996 0.004 0.000
#> GSM260951     5  0.4306     0.3940 0.000 0.000 0.328 0.012 0.660

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM260888     2  0.2597     0.8616 0.000 0.824 0.000 0.000 0.000 0.176
#> GSM260893     2  0.2730     0.8644 0.000 0.808 0.000 0.000 0.000 0.192
#> GSM260896     2  0.2631     0.8630 0.000 0.820 0.000 0.000 0.000 0.180
#> GSM260899     6  0.0632     0.9448 0.000 0.024 0.000 0.000 0.000 0.976
#> GSM260902     6  0.0632     0.9448 0.000 0.024 0.000 0.000 0.000 0.976
#> GSM260905     6  0.2340     0.8372 0.000 0.148 0.000 0.000 0.000 0.852
#> GSM260908     6  0.2048     0.8662 0.000 0.120 0.000 0.000 0.000 0.880
#> GSM260911     2  0.2597     0.8616 0.000 0.824 0.000 0.000 0.000 0.176
#> GSM260912     2  0.3747     0.7904 0.000 0.604 0.000 0.000 0.000 0.396
#> GSM260913     4  0.0622     0.7008 0.000 0.000 0.008 0.980 0.012 0.000
#> GSM260886     1  0.0146     0.9835 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260889     1  0.0146     0.9835 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260891     1  0.0146     0.9837 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260894     1  0.0146     0.9837 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260897     1  0.0458     0.9840 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM260900     1  0.0458     0.9840 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM260903     1  0.0458     0.9840 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM260906     1  0.0458     0.9840 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM260909     1  0.0146     0.9837 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260887     4  0.1124     0.6908 0.000 0.000 0.008 0.956 0.036 0.000
#> GSM260890     4  0.0972     0.6951 0.000 0.000 0.008 0.964 0.028 0.000
#> GSM260892     4  0.0717     0.7000 0.000 0.000 0.008 0.976 0.016 0.000
#> GSM260895     5  0.3727     0.4652 0.000 0.000 0.000 0.388 0.612 0.000
#> GSM260898     4  0.5437    -0.2096 0.000 0.008 0.416 0.484 0.092 0.000
#> GSM260901     4  0.5437    -0.2096 0.000 0.008 0.416 0.484 0.092 0.000
#> GSM260904     4  0.5502    -0.1383 0.000 0.008 0.380 0.508 0.104 0.000
#> GSM260907     4  0.5400    -0.2026 0.000 0.008 0.416 0.488 0.088 0.000
#> GSM260910     4  0.0260     0.6987 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM260918     2  0.3747     0.7904 0.000 0.604 0.000 0.000 0.000 0.396
#> GSM260921     2  0.3221     0.8554 0.000 0.736 0.000 0.000 0.000 0.264
#> GSM260924     2  0.2416     0.8414 0.000 0.844 0.000 0.000 0.000 0.156
#> GSM260929     2  0.3747     0.7904 0.000 0.604 0.000 0.000 0.000 0.396
#> GSM260932     6  0.0632     0.9448 0.000 0.024 0.000 0.000 0.000 0.976
#> GSM260935     6  0.0632     0.9448 0.000 0.024 0.000 0.000 0.000 0.976
#> GSM260938     6  0.0363     0.9285 0.000 0.012 0.000 0.000 0.000 0.988
#> GSM260941     6  0.0632     0.9364 0.000 0.024 0.000 0.000 0.000 0.976
#> GSM260944     6  0.0632     0.9364 0.000 0.024 0.000 0.000 0.000 0.976
#> GSM260947     6  0.0632     0.9364 0.000 0.024 0.000 0.000 0.000 0.976
#> GSM260952     2  0.3659     0.8160 0.000 0.636 0.000 0.000 0.000 0.364
#> GSM260914     1  0.0146     0.9835 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260916     1  0.0937     0.9628 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM260919     1  0.0937     0.9628 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM260922     1  0.0937     0.9628 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM260925     1  0.0146     0.9835 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260927     1  0.0146     0.9837 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260930     1  0.0458     0.9840 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM260933     1  0.0458     0.9840 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM260936     1  0.0458     0.9840 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM260939     1  0.0458     0.9840 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM260942     1  0.0458     0.9840 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM260945     1  0.0458     0.9840 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM260948     1  0.0937     0.9628 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM260950     1  0.0146     0.9835 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260915     4  0.0363     0.6985 0.000 0.000 0.000 0.988 0.012 0.000
#> GSM260917     4  0.2813     0.6226 0.000 0.008 0.092 0.864 0.036 0.000
#> GSM260920     4  0.1232     0.6948 0.000 0.004 0.024 0.956 0.016 0.000
#> GSM260923     4  0.0458     0.6968 0.000 0.000 0.000 0.984 0.016 0.000
#> GSM260926     4  0.0551     0.7018 0.000 0.004 0.004 0.984 0.008 0.000
#> GSM260928     5  0.3880     0.4519 0.056 0.000 0.112 0.032 0.800 0.000
#> GSM260931     3  0.3684     0.5754 0.000 0.000 0.628 0.372 0.000 0.000
#> GSM260934     4  0.5437    -0.2096 0.000 0.008 0.416 0.484 0.092 0.000
#> GSM260937     3  0.4354    -0.0894 0.000 0.132 0.724 0.000 0.144 0.000
#> GSM260940     3  0.3807     0.5798 0.000 0.000 0.628 0.368 0.004 0.000
#> GSM260943     3  0.3563     0.5962 0.000 0.000 0.664 0.336 0.000 0.000
#> GSM260946     3  0.4957     0.4630 0.000 0.000 0.544 0.384 0.072 0.000
#> GSM260949     4  0.0767     0.7007 0.000 0.004 0.012 0.976 0.008 0.000
#> GSM260951     3  0.6454     0.4589 0.000 0.080 0.532 0.252 0.136 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-hclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-hclust-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>            n disease.state(p) cell.type(p) k
#> CV:hclust 67            0.939     2.75e-14 2
#> CV:hclust 67            0.927     9.68e-27 3
#> CV:hclust 62            0.584     4.37e-23 4
#> CV:hclust 54            0.906     6.80e-21 5
#> CV:hclust 57            0.636     1.22e-19 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 21168 rows and 67 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.323           0.874       0.896         0.4405 0.575   0.575
#> 3 3 0.651           0.941       0.850         0.4088 0.750   0.566
#> 4 4 0.829           0.852       0.822         0.1652 1.000   1.000
#> 5 5 0.804           0.903       0.769         0.0599 0.876   0.619
#> 6 6 0.763           0.671       0.714         0.0469 0.941   0.739

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
#> GSM260888     2  0.0000      1.000 0.000 1.000
#> GSM260893     2  0.0000      1.000 0.000 1.000
#> GSM260896     2  0.0000      1.000 0.000 1.000
#> GSM260899     2  0.0000      1.000 0.000 1.000
#> GSM260902     2  0.0000      1.000 0.000 1.000
#> GSM260905     2  0.0000      1.000 0.000 1.000
#> GSM260908     2  0.0000      1.000 0.000 1.000
#> GSM260911     2  0.0000      1.000 0.000 1.000
#> GSM260912     2  0.0000      1.000 0.000 1.000
#> GSM260913     1  0.7376      0.807 0.792 0.208
#> GSM260886     1  0.4815      0.834 0.896 0.104
#> GSM260889     1  0.4815      0.834 0.896 0.104
#> GSM260891     1  0.4815      0.834 0.896 0.104
#> GSM260894     1  0.4815      0.834 0.896 0.104
#> GSM260897     1  0.4815      0.834 0.896 0.104
#> GSM260900     1  0.4815      0.834 0.896 0.104
#> GSM260903     1  0.4815      0.834 0.896 0.104
#> GSM260906     1  0.4815      0.834 0.896 0.104
#> GSM260909     1  0.4815      0.834 0.896 0.104
#> GSM260887     1  0.7376      0.807 0.792 0.208
#> GSM260890     1  0.7376      0.807 0.792 0.208
#> GSM260892     1  0.7376      0.807 0.792 0.208
#> GSM260895     1  0.0672      0.815 0.992 0.008
#> GSM260898     1  0.7376      0.807 0.792 0.208
#> GSM260901     1  0.7376      0.807 0.792 0.208
#> GSM260904     1  0.7376      0.807 0.792 0.208
#> GSM260907     1  0.7376      0.807 0.792 0.208
#> GSM260910     1  0.7376      0.807 0.792 0.208
#> GSM260918     2  0.0000      1.000 0.000 1.000
#> GSM260921     2  0.0000      1.000 0.000 1.000
#> GSM260924     2  0.0000      1.000 0.000 1.000
#> GSM260929     2  0.0000      1.000 0.000 1.000
#> GSM260932     2  0.0000      1.000 0.000 1.000
#> GSM260935     2  0.0000      1.000 0.000 1.000
#> GSM260938     2  0.0000      1.000 0.000 1.000
#> GSM260941     2  0.0000      1.000 0.000 1.000
#> GSM260944     2  0.0000      1.000 0.000 1.000
#> GSM260947     2  0.0000      1.000 0.000 1.000
#> GSM260952     2  0.0000      1.000 0.000 1.000
#> GSM260914     1  0.4815      0.834 0.896 0.104
#> GSM260916     1  0.4815      0.834 0.896 0.104
#> GSM260919     1  0.4815      0.834 0.896 0.104
#> GSM260922     1  0.4815      0.834 0.896 0.104
#> GSM260925     1  0.4815      0.834 0.896 0.104
#> GSM260927     1  0.4815      0.834 0.896 0.104
#> GSM260930     1  0.4815      0.834 0.896 0.104
#> GSM260933     1  0.4815      0.834 0.896 0.104
#> GSM260936     1  0.4815      0.834 0.896 0.104
#> GSM260939     1  0.4815      0.834 0.896 0.104
#> GSM260942     1  0.4815      0.834 0.896 0.104
#> GSM260945     1  0.4815      0.834 0.896 0.104
#> GSM260948     1  0.4815      0.834 0.896 0.104
#> GSM260950     1  0.4815      0.834 0.896 0.104
#> GSM260915     1  0.7376      0.807 0.792 0.208
#> GSM260917     1  0.7376      0.807 0.792 0.208
#> GSM260920     1  0.7376      0.807 0.792 0.208
#> GSM260923     1  0.7376      0.807 0.792 0.208
#> GSM260926     1  0.7376      0.807 0.792 0.208
#> GSM260928     1  0.0000      0.813 1.000 0.000
#> GSM260931     1  0.7376      0.807 0.792 0.208
#> GSM260934     1  0.7376      0.807 0.792 0.208
#> GSM260937     1  0.7376      0.807 0.792 0.208
#> GSM260940     1  0.7376      0.807 0.792 0.208
#> GSM260943     1  0.7376      0.807 0.792 0.208
#> GSM260946     1  0.7376      0.807 0.792 0.208
#> GSM260949     1  0.7376      0.807 0.792 0.208
#> GSM260951     1  0.7376      0.807 0.792 0.208

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM260888     2   0.382      0.940 0.148 0.852 0.000
#> GSM260893     2   0.382      0.940 0.148 0.852 0.000
#> GSM260896     2   0.382      0.940 0.148 0.852 0.000
#> GSM260899     2   0.226      0.921 0.068 0.932 0.000
#> GSM260902     2   0.226      0.921 0.068 0.932 0.000
#> GSM260905     2   0.153      0.937 0.040 0.960 0.000
#> GSM260908     2   0.116      0.934 0.028 0.972 0.000
#> GSM260911     2   0.382      0.940 0.148 0.852 0.000
#> GSM260912     2   0.382      0.940 0.148 0.852 0.000
#> GSM260913     3   0.186      0.954 0.000 0.052 0.948
#> GSM260886     1   0.573      0.946 0.676 0.000 0.324
#> GSM260889     1   0.573      0.946 0.676 0.000 0.324
#> GSM260891     1   0.573      0.946 0.676 0.000 0.324
#> GSM260894     1   0.573      0.946 0.676 0.000 0.324
#> GSM260897     1   0.480      0.932 0.780 0.000 0.220
#> GSM260900     1   0.480      0.932 0.780 0.000 0.220
#> GSM260903     1   0.480      0.932 0.780 0.000 0.220
#> GSM260906     1   0.480      0.932 0.780 0.000 0.220
#> GSM260909     1   0.573      0.946 0.676 0.000 0.324
#> GSM260887     3   0.186      0.954 0.000 0.052 0.948
#> GSM260890     3   0.186      0.954 0.000 0.052 0.948
#> GSM260892     3   0.186      0.954 0.000 0.052 0.948
#> GSM260895     3   0.000      0.895 0.000 0.000 1.000
#> GSM260898     3   0.399      0.951 0.052 0.064 0.884
#> GSM260901     3   0.399      0.951 0.052 0.064 0.884
#> GSM260904     3   0.399      0.951 0.052 0.064 0.884
#> GSM260907     3   0.399      0.951 0.052 0.064 0.884
#> GSM260910     3   0.186      0.954 0.000 0.052 0.948
#> GSM260918     2   0.394      0.940 0.156 0.844 0.000
#> GSM260921     2   0.382      0.940 0.148 0.852 0.000
#> GSM260924     2   0.388      0.939 0.152 0.848 0.000
#> GSM260929     2   0.375      0.940 0.144 0.856 0.000
#> GSM260932     2   0.226      0.921 0.068 0.932 0.000
#> GSM260935     2   0.226      0.921 0.068 0.932 0.000
#> GSM260938     2   0.141      0.934 0.036 0.964 0.000
#> GSM260941     2   0.141      0.934 0.036 0.964 0.000
#> GSM260944     2   0.141      0.934 0.036 0.964 0.000
#> GSM260947     2   0.141      0.934 0.036 0.964 0.000
#> GSM260952     2   0.406      0.938 0.164 0.836 0.000
#> GSM260914     1   0.573      0.946 0.676 0.000 0.324
#> GSM260916     1   0.573      0.946 0.676 0.000 0.324
#> GSM260919     1   0.573      0.946 0.676 0.000 0.324
#> GSM260922     1   0.573      0.946 0.676 0.000 0.324
#> GSM260925     1   0.573      0.946 0.676 0.000 0.324
#> GSM260927     1   0.573      0.946 0.676 0.000 0.324
#> GSM260930     1   0.480      0.932 0.780 0.000 0.220
#> GSM260933     1   0.480      0.932 0.780 0.000 0.220
#> GSM260936     1   0.480      0.932 0.780 0.000 0.220
#> GSM260939     1   0.480      0.932 0.780 0.000 0.220
#> GSM260942     1   0.480      0.932 0.780 0.000 0.220
#> GSM260945     1   0.480      0.932 0.780 0.000 0.220
#> GSM260948     1   0.562      0.944 0.692 0.000 0.308
#> GSM260950     1   0.573      0.946 0.676 0.000 0.324
#> GSM260915     3   0.186      0.954 0.000 0.052 0.948
#> GSM260917     3   0.318      0.955 0.024 0.064 0.912
#> GSM260920     3   0.186      0.954 0.000 0.052 0.948
#> GSM260923     3   0.186      0.954 0.000 0.052 0.948
#> GSM260926     3   0.186      0.954 0.000 0.052 0.948
#> GSM260928     3   0.000      0.895 0.000 0.000 1.000
#> GSM260931     3   0.399      0.951 0.052 0.064 0.884
#> GSM260934     3   0.399      0.951 0.052 0.064 0.884
#> GSM260937     3   0.399      0.951 0.052 0.064 0.884
#> GSM260940     3   0.399      0.951 0.052 0.064 0.884
#> GSM260943     3   0.399      0.951 0.052 0.064 0.884
#> GSM260946     3   0.399      0.951 0.052 0.064 0.884
#> GSM260949     3   0.186      0.954 0.000 0.052 0.948
#> GSM260951     3   0.318      0.955 0.024 0.064 0.912

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3 p4
#> GSM260888     2   0.358      0.911 0.004 0.816 0.000 NA
#> GSM260893     2   0.344      0.911 0.000 0.816 0.000 NA
#> GSM260896     2   0.344      0.911 0.000 0.816 0.000 NA
#> GSM260899     2   0.211      0.893 0.024 0.932 0.000 NA
#> GSM260902     2   0.211      0.893 0.024 0.932 0.000 NA
#> GSM260905     2   0.190      0.910 0.004 0.932 0.000 NA
#> GSM260908     2   0.131      0.906 0.004 0.960 0.000 NA
#> GSM260911     2   0.358      0.911 0.004 0.816 0.000 NA
#> GSM260912     2   0.336      0.914 0.000 0.824 0.000 NA
#> GSM260913     3   0.000      0.813 0.000 0.000 1.000 NA
#> GSM260886     1   0.572      0.867 0.632 0.000 0.044 NA
#> GSM260889     1   0.572      0.867 0.632 0.000 0.044 NA
#> GSM260891     1   0.574      0.866 0.628 0.000 0.044 NA
#> GSM260894     1   0.574      0.866 0.628 0.000 0.044 NA
#> GSM260897     1   0.112      0.825 0.964 0.000 0.036 NA
#> GSM260900     1   0.112      0.825 0.964 0.000 0.036 NA
#> GSM260903     1   0.112      0.825 0.964 0.000 0.036 NA
#> GSM260906     1   0.112      0.825 0.964 0.000 0.036 NA
#> GSM260909     1   0.574      0.866 0.628 0.000 0.044 NA
#> GSM260887     3   0.000      0.813 0.000 0.000 1.000 NA
#> GSM260890     3   0.000      0.813 0.000 0.000 1.000 NA
#> GSM260892     3   0.000      0.813 0.000 0.000 1.000 NA
#> GSM260895     3   0.156      0.774 0.000 0.000 0.944 NA
#> GSM260898     3   0.514      0.811 0.008 0.000 0.600 NA
#> GSM260901     3   0.514      0.811 0.008 0.000 0.600 NA
#> GSM260904     3   0.514      0.811 0.008 0.000 0.600 NA
#> GSM260907     3   0.514      0.811 0.008 0.000 0.600 NA
#> GSM260910     3   0.000      0.813 0.000 0.000 1.000 NA
#> GSM260918     2   0.336      0.914 0.000 0.824 0.000 NA
#> GSM260921     2   0.340      0.912 0.000 0.820 0.000 NA
#> GSM260924     2   0.389      0.908 0.012 0.804 0.000 NA
#> GSM260929     2   0.327      0.914 0.000 0.832 0.000 NA
#> GSM260932     2   0.211      0.893 0.024 0.932 0.000 NA
#> GSM260935     2   0.211      0.893 0.024 0.932 0.000 NA
#> GSM260938     2   0.121      0.906 0.000 0.960 0.000 NA
#> GSM260941     2   0.121      0.906 0.000 0.960 0.000 NA
#> GSM260944     2   0.121      0.906 0.000 0.960 0.000 NA
#> GSM260947     2   0.121      0.906 0.000 0.960 0.000 NA
#> GSM260952     2   0.349      0.913 0.000 0.812 0.000 NA
#> GSM260914     1   0.572      0.867 0.632 0.000 0.044 NA
#> GSM260916     1   0.572      0.867 0.632 0.000 0.044 NA
#> GSM260919     1   0.572      0.867 0.632 0.000 0.044 NA
#> GSM260922     1   0.572      0.867 0.632 0.000 0.044 NA
#> GSM260925     1   0.572      0.867 0.632 0.000 0.044 NA
#> GSM260927     1   0.574      0.866 0.628 0.000 0.044 NA
#> GSM260930     1   0.112      0.825 0.964 0.000 0.036 NA
#> GSM260933     1   0.112      0.825 0.964 0.000 0.036 NA
#> GSM260936     1   0.112      0.825 0.964 0.000 0.036 NA
#> GSM260939     1   0.112      0.825 0.964 0.000 0.036 NA
#> GSM260942     1   0.112      0.825 0.964 0.000 0.036 NA
#> GSM260945     1   0.112      0.825 0.964 0.000 0.036 NA
#> GSM260948     1   0.564      0.866 0.648 0.000 0.044 NA
#> GSM260950     1   0.572      0.867 0.632 0.000 0.044 NA
#> GSM260915     3   0.000      0.813 0.000 0.000 1.000 NA
#> GSM260917     3   0.456      0.813 0.000 0.000 0.672 NA
#> GSM260920     3   0.000      0.813 0.000 0.000 1.000 NA
#> GSM260923     3   0.000      0.813 0.000 0.000 1.000 NA
#> GSM260926     3   0.000      0.813 0.000 0.000 1.000 NA
#> GSM260928     3   0.156      0.774 0.000 0.000 0.944 NA
#> GSM260931     3   0.514      0.811 0.008 0.000 0.600 NA
#> GSM260934     3   0.514      0.811 0.008 0.000 0.600 NA
#> GSM260937     3   0.514      0.811 0.008 0.000 0.600 NA
#> GSM260940     3   0.514      0.811 0.008 0.000 0.600 NA
#> GSM260943     3   0.514      0.811 0.008 0.000 0.600 NA
#> GSM260946     3   0.514      0.811 0.008 0.000 0.600 NA
#> GSM260949     3   0.000      0.813 0.000 0.000 1.000 NA
#> GSM260951     3   0.483      0.810 0.000 0.000 0.608 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM260888     2  0.1179      0.842 0.000 0.964 0.004 0.016 0.016
#> GSM260893     2  0.0968      0.843 0.000 0.972 0.004 0.012 0.012
#> GSM260896     2  0.0968      0.843 0.000 0.972 0.004 0.012 0.012
#> GSM260899     2  0.5949      0.795 0.000 0.588 0.000 0.172 0.240
#> GSM260902     2  0.5949      0.795 0.000 0.588 0.000 0.172 0.240
#> GSM260905     2  0.4985      0.835 0.000 0.708 0.004 0.200 0.088
#> GSM260908     2  0.5127      0.832 0.000 0.692 0.004 0.212 0.092
#> GSM260911     2  0.0968      0.843 0.000 0.972 0.004 0.012 0.012
#> GSM260912     2  0.0404      0.845 0.000 0.988 0.000 0.012 0.000
#> GSM260913     4  0.5470      0.945 0.036 0.004 0.372 0.576 0.012
#> GSM260886     1  0.0000      0.954 1.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0162      0.953 0.996 0.000 0.000 0.004 0.000
#> GSM260891     1  0.1764      0.916 0.928 0.000 0.000 0.064 0.008
#> GSM260894     1  0.1764      0.916 0.928 0.000 0.000 0.064 0.008
#> GSM260897     5  0.5024      0.983 0.440 0.000 0.024 0.004 0.532
#> GSM260900     5  0.5099      0.983 0.440 0.000 0.028 0.004 0.528
#> GSM260903     5  0.5211      0.981 0.440 0.000 0.028 0.008 0.524
#> GSM260906     5  0.5211      0.981 0.440 0.000 0.028 0.008 0.524
#> GSM260909     1  0.1764      0.916 0.928 0.000 0.000 0.064 0.008
#> GSM260887     4  0.5255      0.947 0.036 0.004 0.372 0.584 0.004
#> GSM260890     4  0.5255      0.947 0.036 0.004 0.372 0.584 0.004
#> GSM260892     4  0.5730      0.943 0.036 0.004 0.372 0.564 0.024
#> GSM260895     4  0.6254      0.799 0.060 0.000 0.288 0.592 0.060
#> GSM260898     3  0.1580      0.937 0.012 0.004 0.952 0.016 0.016
#> GSM260901     3  0.1580      0.937 0.012 0.004 0.952 0.016 0.016
#> GSM260904     3  0.1580      0.937 0.012 0.004 0.952 0.016 0.016
#> GSM260907     3  0.1580      0.937 0.012 0.004 0.952 0.016 0.016
#> GSM260910     4  0.5470      0.945 0.036 0.004 0.372 0.576 0.012
#> GSM260918     2  0.1041      0.845 0.000 0.964 0.000 0.032 0.004
#> GSM260921     2  0.0833      0.843 0.000 0.976 0.004 0.016 0.004
#> GSM260924     2  0.1569      0.840 0.000 0.948 0.008 0.012 0.032
#> GSM260929     2  0.0162      0.845 0.000 0.996 0.000 0.004 0.000
#> GSM260932     2  0.5949      0.795 0.000 0.588 0.000 0.172 0.240
#> GSM260935     2  0.5949      0.795 0.000 0.588 0.000 0.172 0.240
#> GSM260938     2  0.5335      0.824 0.000 0.644 0.000 0.260 0.096
#> GSM260941     2  0.5312      0.825 0.000 0.648 0.000 0.256 0.096
#> GSM260944     2  0.5312      0.825 0.000 0.648 0.000 0.256 0.096
#> GSM260947     2  0.5312      0.825 0.000 0.648 0.000 0.256 0.096
#> GSM260952     2  0.1408      0.843 0.000 0.948 0.000 0.044 0.008
#> GSM260914     1  0.0000      0.954 1.000 0.000 0.000 0.000 0.000
#> GSM260916     1  0.0290      0.952 0.992 0.000 0.000 0.008 0.000
#> GSM260919     1  0.0404      0.950 0.988 0.000 0.000 0.012 0.000
#> GSM260922     1  0.0290      0.952 0.992 0.000 0.000 0.008 0.000
#> GSM260925     1  0.0000      0.954 1.000 0.000 0.000 0.000 0.000
#> GSM260927     1  0.1830      0.912 0.924 0.000 0.000 0.068 0.008
#> GSM260930     5  0.5136      0.982 0.440 0.000 0.024 0.008 0.528
#> GSM260933     5  0.5024      0.983 0.440 0.000 0.024 0.004 0.532
#> GSM260936     5  0.5560      0.970 0.440 0.000 0.024 0.028 0.508
#> GSM260939     5  0.5560      0.970 0.440 0.000 0.024 0.028 0.508
#> GSM260942     5  0.5235      0.980 0.440 0.000 0.024 0.012 0.524
#> GSM260945     5  0.5399      0.980 0.440 0.000 0.028 0.016 0.516
#> GSM260948     1  0.1493      0.902 0.948 0.000 0.000 0.028 0.024
#> GSM260950     1  0.0162      0.953 0.996 0.000 0.000 0.004 0.000
#> GSM260915     4  0.5369      0.947 0.036 0.004 0.372 0.580 0.008
#> GSM260917     3  0.3502      0.754 0.028 0.004 0.844 0.112 0.012
#> GSM260920     4  0.5563      0.944 0.036 0.004 0.372 0.572 0.016
#> GSM260923     4  0.5470      0.945 0.036 0.004 0.372 0.576 0.012
#> GSM260926     4  0.5255      0.947 0.036 0.004 0.372 0.584 0.004
#> GSM260928     4  0.6399      0.784 0.060 0.000 0.284 0.584 0.072
#> GSM260931     3  0.1074      0.932 0.012 0.004 0.968 0.000 0.016
#> GSM260934     3  0.1580      0.937 0.012 0.004 0.952 0.016 0.016
#> GSM260937     3  0.2166      0.905 0.012 0.004 0.912 0.000 0.072
#> GSM260940     3  0.0566      0.935 0.012 0.004 0.984 0.000 0.000
#> GSM260943     3  0.2166      0.905 0.012 0.004 0.912 0.000 0.072
#> GSM260946     3  0.0727      0.935 0.012 0.004 0.980 0.000 0.004
#> GSM260949     4  0.5369      0.947 0.036 0.004 0.372 0.580 0.008
#> GSM260951     3  0.2610      0.888 0.028 0.004 0.892 0.000 0.076

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5 p6
#> GSM260888     2  0.4724      0.598 0.004 0.480 0.480 0.000 0.000 NA
#> GSM260893     3  0.4184     -0.641 0.000 0.484 0.504 0.000 0.000 NA
#> GSM260896     3  0.4263     -0.641 0.000 0.480 0.504 0.000 0.000 NA
#> GSM260899     2  0.3975      0.686 0.000 0.716 0.040 0.000 0.000 NA
#> GSM260902     2  0.3975      0.686 0.000 0.716 0.040 0.000 0.000 NA
#> GSM260905     2  0.1845      0.736 0.008 0.916 0.072 0.000 0.000 NA
#> GSM260908     2  0.1340      0.737 0.008 0.948 0.040 0.000 0.000 NA
#> GSM260911     3  0.4183     -0.641 0.000 0.480 0.508 0.000 0.000 NA
#> GSM260912     2  0.4403      0.610 0.008 0.520 0.460 0.000 0.000 NA
#> GSM260913     4  0.1391      0.862 0.016 0.000 0.000 0.944 0.000 NA
#> GSM260886     1  0.3887      0.918 0.632 0.000 0.000 0.008 0.360 NA
#> GSM260889     1  0.4231      0.916 0.616 0.000 0.000 0.008 0.364 NA
#> GSM260891     1  0.5473      0.864 0.536 0.000 0.000 0.008 0.348 NA
#> GSM260894     1  0.5568      0.864 0.536 0.000 0.004 0.008 0.348 NA
#> GSM260897     5  0.0291      0.967 0.000 0.000 0.004 0.000 0.992 NA
#> GSM260900     5  0.0405      0.966 0.000 0.000 0.008 0.000 0.988 NA
#> GSM260903     5  0.0520      0.965 0.000 0.000 0.008 0.000 0.984 NA
#> GSM260906     5  0.0520      0.965 0.000 0.000 0.008 0.000 0.984 NA
#> GSM260909     1  0.5473      0.864 0.536 0.000 0.000 0.008 0.348 NA
#> GSM260887     4  0.0508      0.872 0.004 0.000 0.000 0.984 0.000 NA
#> GSM260890     4  0.0405      0.873 0.008 0.000 0.000 0.988 0.000 NA
#> GSM260892     4  0.1779      0.859 0.016 0.000 0.000 0.920 0.000 NA
#> GSM260895     4  0.3782      0.727 0.036 0.000 0.000 0.740 0.000 NA
#> GSM260898     3  0.7508      0.541 0.196 0.000 0.420 0.220 0.008 NA
#> GSM260901     3  0.7508      0.541 0.196 0.000 0.420 0.220 0.008 NA
#> GSM260904     3  0.7508      0.541 0.196 0.000 0.420 0.220 0.008 NA
#> GSM260907     3  0.7508      0.541 0.196 0.000 0.420 0.220 0.008 NA
#> GSM260910     4  0.0858      0.870 0.004 0.000 0.000 0.968 0.000 NA
#> GSM260918     2  0.4459      0.619 0.012 0.548 0.428 0.000 0.000 NA
#> GSM260921     3  0.4227     -0.647 0.004 0.492 0.496 0.000 0.000 NA
#> GSM260924     2  0.5804      0.604 0.044 0.468 0.420 0.000 0.000 NA
#> GSM260929     2  0.4565      0.602 0.008 0.496 0.476 0.000 0.000 NA
#> GSM260932     2  0.3975      0.686 0.000 0.716 0.040 0.000 0.000 NA
#> GSM260935     2  0.3975      0.686 0.000 0.716 0.040 0.000 0.000 NA
#> GSM260938     2  0.0146      0.735 0.004 0.996 0.000 0.000 0.000 NA
#> GSM260941     2  0.0146      0.735 0.004 0.996 0.000 0.000 0.000 NA
#> GSM260944     2  0.0146      0.735 0.004 0.996 0.000 0.000 0.000 NA
#> GSM260947     2  0.0146      0.735 0.004 0.996 0.000 0.000 0.000 NA
#> GSM260952     2  0.4447      0.621 0.012 0.556 0.420 0.000 0.000 NA
#> GSM260914     1  0.3887      0.918 0.632 0.000 0.000 0.008 0.360 NA
#> GSM260916     1  0.4767      0.905 0.592 0.000 0.000 0.008 0.356 NA
#> GSM260919     1  0.4957      0.900 0.584 0.000 0.004 0.008 0.356 NA
#> GSM260922     1  0.4824      0.900 0.588 0.000 0.000 0.008 0.356 NA
#> GSM260925     1  0.3887      0.918 0.632 0.000 0.000 0.008 0.360 NA
#> GSM260927     1  0.5578      0.861 0.532 0.000 0.004 0.008 0.352 NA
#> GSM260930     5  0.0363      0.965 0.000 0.000 0.012 0.000 0.988 NA
#> GSM260933     5  0.0260      0.966 0.000 0.000 0.008 0.000 0.992 NA
#> GSM260936     5  0.1765      0.939 0.000 0.000 0.024 0.000 0.924 NA
#> GSM260939     5  0.1700      0.939 0.000 0.000 0.024 0.000 0.928 NA
#> GSM260942     5  0.1225      0.953 0.000 0.000 0.012 0.000 0.952 NA
#> GSM260945     5  0.1049      0.962 0.000 0.000 0.008 0.000 0.960 NA
#> GSM260948     1  0.5322      0.859 0.540 0.000 0.008 0.008 0.380 NA
#> GSM260950     1  0.4022      0.918 0.628 0.000 0.004 0.008 0.360 NA
#> GSM260915     4  0.0891      0.871 0.008 0.000 0.000 0.968 0.000 NA
#> GSM260917     4  0.7369     -0.377 0.132 0.000 0.352 0.364 0.008 NA
#> GSM260920     4  0.1398      0.862 0.008 0.000 0.000 0.940 0.000 NA
#> GSM260923     4  0.0993      0.869 0.012 0.000 0.000 0.964 0.000 NA
#> GSM260926     4  0.0603      0.872 0.004 0.000 0.000 0.980 0.000 NA
#> GSM260928     4  0.4382      0.680 0.060 0.000 0.000 0.676 0.000 NA
#> GSM260931     3  0.7505      0.536 0.208 0.000 0.420 0.212 0.008 NA
#> GSM260934     3  0.7508      0.541 0.196 0.000 0.420 0.220 0.008 NA
#> GSM260937     3  0.7795      0.501 0.220 0.000 0.348 0.212 0.008 NA
#> GSM260940     3  0.7390      0.542 0.224 0.000 0.432 0.212 0.008 NA
#> GSM260943     3  0.7795      0.501 0.220 0.000 0.348 0.212 0.008 NA
#> GSM260946     3  0.7390      0.542 0.224 0.000 0.432 0.212 0.008 NA
#> GSM260949     4  0.0692      0.872 0.004 0.000 0.000 0.976 0.000 NA
#> GSM260951     3  0.7823      0.487 0.212 0.000 0.336 0.212 0.008 NA

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

consensus_heatmap(res, k = 2)

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) cell.type(p) k
#> CV:kmeans 67            0.939     2.75e-14 2
#> CV:kmeans 67            0.927     9.68e-27 3
#> CV:kmeans 67            0.927     9.68e-27 4
#> CV:kmeans 67            0.933     6.06e-24 5
#> CV:kmeans 61            0.971     2.17e-21 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 21168 rows and 67 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 1.000           1.000       1.000         0.4257 0.575   0.575
#> 3 3 1.000           0.995       0.998         0.5859 0.750   0.566
#> 4 4 0.881           0.954       0.934         0.0954 0.935   0.800
#> 5 5 0.881           0.946       0.905         0.0641 0.941   0.774
#> 6 6 0.845           0.870       0.897         0.0340 0.995   0.975

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
#> GSM260888     2       0          1  0  1
#> GSM260893     2       0          1  0  1
#> GSM260896     2       0          1  0  1
#> GSM260899     2       0          1  0  1
#> GSM260902     2       0          1  0  1
#> GSM260905     2       0          1  0  1
#> GSM260908     2       0          1  0  1
#> GSM260911     2       0          1  0  1
#> GSM260912     2       0          1  0  1
#> GSM260913     1       0          1  1  0
#> GSM260886     1       0          1  1  0
#> GSM260889     1       0          1  1  0
#> GSM260891     1       0          1  1  0
#> GSM260894     1       0          1  1  0
#> GSM260897     1       0          1  1  0
#> GSM260900     1       0          1  1  0
#> GSM260903     1       0          1  1  0
#> GSM260906     1       0          1  1  0
#> GSM260909     1       0          1  1  0
#> GSM260887     1       0          1  1  0
#> GSM260890     1       0          1  1  0
#> GSM260892     1       0          1  1  0
#> GSM260895     1       0          1  1  0
#> GSM260898     1       0          1  1  0
#> GSM260901     1       0          1  1  0
#> GSM260904     1       0          1  1  0
#> GSM260907     1       0          1  1  0
#> GSM260910     1       0          1  1  0
#> GSM260918     2       0          1  0  1
#> GSM260921     2       0          1  0  1
#> GSM260924     2       0          1  0  1
#> GSM260929     2       0          1  0  1
#> GSM260932     2       0          1  0  1
#> GSM260935     2       0          1  0  1
#> GSM260938     2       0          1  0  1
#> GSM260941     2       0          1  0  1
#> GSM260944     2       0          1  0  1
#> GSM260947     2       0          1  0  1
#> GSM260952     2       0          1  0  1
#> GSM260914     1       0          1  1  0
#> GSM260916     1       0          1  1  0
#> GSM260919     1       0          1  1  0
#> GSM260922     1       0          1  1  0
#> GSM260925     1       0          1  1  0
#> GSM260927     1       0          1  1  0
#> GSM260930     1       0          1  1  0
#> GSM260933     1       0          1  1  0
#> GSM260936     1       0          1  1  0
#> GSM260939     1       0          1  1  0
#> GSM260942     1       0          1  1  0
#> GSM260945     1       0          1  1  0
#> GSM260948     1       0          1  1  0
#> GSM260950     1       0          1  1  0
#> GSM260915     1       0          1  1  0
#> GSM260917     1       0          1  1  0
#> GSM260920     1       0          1  1  0
#> GSM260923     1       0          1  1  0
#> GSM260926     1       0          1  1  0
#> GSM260928     1       0          1  1  0
#> GSM260931     1       0          1  1  0
#> GSM260934     1       0          1  1  0
#> GSM260937     1       0          1  1  0
#> GSM260940     1       0          1  1  0
#> GSM260943     1       0          1  1  0
#> GSM260946     1       0          1  1  0
#> GSM260949     1       0          1  1  0
#> GSM260951     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM260888     2   0.000      1.000 0.000  1 0.000
#> GSM260893     2   0.000      1.000 0.000  1 0.000
#> GSM260896     2   0.000      1.000 0.000  1 0.000
#> GSM260899     2   0.000      1.000 0.000  1 0.000
#> GSM260902     2   0.000      1.000 0.000  1 0.000
#> GSM260905     2   0.000      1.000 0.000  1 0.000
#> GSM260908     2   0.000      1.000 0.000  1 0.000
#> GSM260911     2   0.000      1.000 0.000  1 0.000
#> GSM260912     2   0.000      1.000 0.000  1 0.000
#> GSM260913     3   0.000      0.993 0.000  0 1.000
#> GSM260886     1   0.000      1.000 1.000  0 0.000
#> GSM260889     1   0.000      1.000 1.000  0 0.000
#> GSM260891     1   0.000      1.000 1.000  0 0.000
#> GSM260894     1   0.000      1.000 1.000  0 0.000
#> GSM260897     1   0.000      1.000 1.000  0 0.000
#> GSM260900     1   0.000      1.000 1.000  0 0.000
#> GSM260903     1   0.000      1.000 1.000  0 0.000
#> GSM260906     1   0.000      1.000 1.000  0 0.000
#> GSM260909     1   0.000      1.000 1.000  0 0.000
#> GSM260887     3   0.000      0.993 0.000  0 1.000
#> GSM260890     3   0.000      0.993 0.000  0 1.000
#> GSM260892     3   0.000      0.993 0.000  0 1.000
#> GSM260895     3   0.000      0.993 0.000  0 1.000
#> GSM260898     3   0.000      0.993 0.000  0 1.000
#> GSM260901     3   0.000      0.993 0.000  0 1.000
#> GSM260904     3   0.000      0.993 0.000  0 1.000
#> GSM260907     3   0.000      0.993 0.000  0 1.000
#> GSM260910     3   0.000      0.993 0.000  0 1.000
#> GSM260918     2   0.000      1.000 0.000  1 0.000
#> GSM260921     2   0.000      1.000 0.000  1 0.000
#> GSM260924     2   0.000      1.000 0.000  1 0.000
#> GSM260929     2   0.000      1.000 0.000  1 0.000
#> GSM260932     2   0.000      1.000 0.000  1 0.000
#> GSM260935     2   0.000      1.000 0.000  1 0.000
#> GSM260938     2   0.000      1.000 0.000  1 0.000
#> GSM260941     2   0.000      1.000 0.000  1 0.000
#> GSM260944     2   0.000      1.000 0.000  1 0.000
#> GSM260947     2   0.000      1.000 0.000  1 0.000
#> GSM260952     2   0.000      1.000 0.000  1 0.000
#> GSM260914     1   0.000      1.000 1.000  0 0.000
#> GSM260916     1   0.000      1.000 1.000  0 0.000
#> GSM260919     1   0.000      1.000 1.000  0 0.000
#> GSM260922     1   0.000      1.000 1.000  0 0.000
#> GSM260925     1   0.000      1.000 1.000  0 0.000
#> GSM260927     1   0.000      1.000 1.000  0 0.000
#> GSM260930     1   0.000      1.000 1.000  0 0.000
#> GSM260933     1   0.000      1.000 1.000  0 0.000
#> GSM260936     1   0.000      1.000 1.000  0 0.000
#> GSM260939     1   0.000      1.000 1.000  0 0.000
#> GSM260942     1   0.000      1.000 1.000  0 0.000
#> GSM260945     1   0.000      1.000 1.000  0 0.000
#> GSM260948     1   0.000      1.000 1.000  0 0.000
#> GSM260950     1   0.000      1.000 1.000  0 0.000
#> GSM260915     3   0.000      0.993 0.000  0 1.000
#> GSM260917     3   0.000      0.993 0.000  0 1.000
#> GSM260920     3   0.000      0.993 0.000  0 1.000
#> GSM260923     3   0.000      0.993 0.000  0 1.000
#> GSM260926     3   0.000      0.993 0.000  0 1.000
#> GSM260928     3   0.382      0.826 0.148  0 0.852
#> GSM260931     3   0.000      0.993 0.000  0 1.000
#> GSM260934     3   0.000      0.993 0.000  0 1.000
#> GSM260937     3   0.000      0.993 0.000  0 1.000
#> GSM260940     3   0.000      0.993 0.000  0 1.000
#> GSM260943     3   0.000      0.993 0.000  0 1.000
#> GSM260946     3   0.000      0.993 0.000  0 1.000
#> GSM260949     3   0.000      0.993 0.000  0 1.000
#> GSM260951     3   0.000      0.993 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM260888     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260893     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260896     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260899     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260902     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260905     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260908     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260911     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260912     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260913     4  0.3569      0.960 0.000 0.000 0.196 0.804
#> GSM260886     1  0.2589      0.924 0.884 0.000 0.000 0.116
#> GSM260889     1  0.2589      0.924 0.884 0.000 0.000 0.116
#> GSM260891     1  0.2589      0.924 0.884 0.000 0.000 0.116
#> GSM260894     1  0.2589      0.924 0.884 0.000 0.000 0.116
#> GSM260897     1  0.1867      0.903 0.928 0.000 0.000 0.072
#> GSM260900     1  0.1867      0.903 0.928 0.000 0.000 0.072
#> GSM260903     1  0.1867      0.903 0.928 0.000 0.000 0.072
#> GSM260906     1  0.1867      0.903 0.928 0.000 0.000 0.072
#> GSM260909     1  0.2589      0.924 0.884 0.000 0.000 0.116
#> GSM260887     4  0.3528      0.962 0.000 0.000 0.192 0.808
#> GSM260890     4  0.3528      0.962 0.000 0.000 0.192 0.808
#> GSM260892     4  0.3528      0.962 0.000 0.000 0.192 0.808
#> GSM260895     4  0.2334      0.848 0.004 0.000 0.088 0.908
#> GSM260898     3  0.0188      0.983 0.000 0.000 0.996 0.004
#> GSM260901     3  0.0188      0.983 0.000 0.000 0.996 0.004
#> GSM260904     3  0.0336      0.981 0.000 0.000 0.992 0.008
#> GSM260907     3  0.0188      0.983 0.000 0.000 0.996 0.004
#> GSM260910     4  0.3528      0.962 0.000 0.000 0.192 0.808
#> GSM260918     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260921     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260924     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260929     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260932     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260935     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260938     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260941     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260944     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260947     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260952     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260914     1  0.2589      0.924 0.884 0.000 0.000 0.116
#> GSM260916     1  0.2589      0.924 0.884 0.000 0.000 0.116
#> GSM260919     1  0.2589      0.924 0.884 0.000 0.000 0.116
#> GSM260922     1  0.2589      0.924 0.884 0.000 0.000 0.116
#> GSM260925     1  0.2589      0.924 0.884 0.000 0.000 0.116
#> GSM260927     1  0.2530      0.924 0.888 0.000 0.000 0.112
#> GSM260930     1  0.1867      0.903 0.928 0.000 0.000 0.072
#> GSM260933     1  0.1867      0.903 0.928 0.000 0.000 0.072
#> GSM260936     1  0.1867      0.903 0.928 0.000 0.000 0.072
#> GSM260939     1  0.1867      0.903 0.928 0.000 0.000 0.072
#> GSM260942     1  0.1867      0.903 0.928 0.000 0.000 0.072
#> GSM260945     1  0.1867      0.903 0.928 0.000 0.000 0.072
#> GSM260948     1  0.2345      0.924 0.900 0.000 0.000 0.100
#> GSM260950     1  0.2589      0.924 0.884 0.000 0.000 0.116
#> GSM260915     4  0.3528      0.962 0.000 0.000 0.192 0.808
#> GSM260917     3  0.2589      0.839 0.000 0.000 0.884 0.116
#> GSM260920     4  0.3610      0.956 0.000 0.000 0.200 0.800
#> GSM260923     4  0.3528      0.962 0.000 0.000 0.192 0.808
#> GSM260926     4  0.3528      0.962 0.000 0.000 0.192 0.808
#> GSM260928     4  0.3229      0.787 0.048 0.000 0.072 0.880
#> GSM260931     3  0.0000      0.984 0.000 0.000 1.000 0.000
#> GSM260934     3  0.0000      0.984 0.000 0.000 1.000 0.000
#> GSM260937     3  0.0000      0.984 0.000 0.000 1.000 0.000
#> GSM260940     3  0.0000      0.984 0.000 0.000 1.000 0.000
#> GSM260943     3  0.0000      0.984 0.000 0.000 1.000 0.000
#> GSM260946     3  0.0000      0.984 0.000 0.000 1.000 0.000
#> GSM260949     4  0.3569      0.960 0.000 0.000 0.196 0.804
#> GSM260951     3  0.0336      0.979 0.000 0.000 0.992 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM260888     2  0.0000      0.945 0.000 1.000 0.000 0.000 0.000
#> GSM260893     2  0.0000      0.945 0.000 1.000 0.000 0.000 0.000
#> GSM260896     2  0.0000      0.945 0.000 1.000 0.000 0.000 0.000
#> GSM260899     2  0.3291      0.924 0.000 0.840 0.000 0.040 0.120
#> GSM260902     2  0.3291      0.924 0.000 0.840 0.000 0.040 0.120
#> GSM260905     2  0.2570      0.941 0.000 0.888 0.000 0.028 0.084
#> GSM260908     2  0.2511      0.941 0.000 0.892 0.000 0.028 0.080
#> GSM260911     2  0.0000      0.945 0.000 1.000 0.000 0.000 0.000
#> GSM260912     2  0.0000      0.945 0.000 1.000 0.000 0.000 0.000
#> GSM260913     4  0.1544      0.942 0.000 0.000 0.068 0.932 0.000
#> GSM260886     1  0.0290      0.968 0.992 0.000 0.000 0.000 0.008
#> GSM260889     1  0.0162      0.968 0.996 0.000 0.000 0.000 0.004
#> GSM260891     1  0.0798      0.950 0.976 0.000 0.000 0.008 0.016
#> GSM260894     1  0.0579      0.962 0.984 0.000 0.000 0.008 0.008
#> GSM260897     5  0.3684      0.993 0.280 0.000 0.000 0.000 0.720
#> GSM260900     5  0.3752      0.987 0.292 0.000 0.000 0.000 0.708
#> GSM260903     5  0.3730      0.991 0.288 0.000 0.000 0.000 0.712
#> GSM260906     5  0.3730      0.991 0.288 0.000 0.000 0.000 0.712
#> GSM260909     1  0.0579      0.961 0.984 0.000 0.000 0.008 0.008
#> GSM260887     4  0.1809      0.944 0.000 0.000 0.060 0.928 0.012
#> GSM260890     4  0.1410      0.944 0.000 0.000 0.060 0.940 0.000
#> GSM260892     4  0.1697      0.943 0.000 0.000 0.060 0.932 0.008
#> GSM260895     4  0.3712      0.826 0.052 0.000 0.004 0.820 0.124
#> GSM260898     3  0.0510      0.973 0.000 0.000 0.984 0.016 0.000
#> GSM260901     3  0.0794      0.969 0.000 0.000 0.972 0.028 0.000
#> GSM260904     3  0.0880      0.967 0.000 0.000 0.968 0.032 0.000
#> GSM260907     3  0.0609      0.972 0.000 0.000 0.980 0.020 0.000
#> GSM260910     4  0.1628      0.943 0.000 0.000 0.056 0.936 0.008
#> GSM260918     2  0.0000      0.945 0.000 1.000 0.000 0.000 0.000
#> GSM260921     2  0.0000      0.945 0.000 1.000 0.000 0.000 0.000
#> GSM260924     2  0.0000      0.945 0.000 1.000 0.000 0.000 0.000
#> GSM260929     2  0.0000      0.945 0.000 1.000 0.000 0.000 0.000
#> GSM260932     2  0.3291      0.924 0.000 0.840 0.000 0.040 0.120
#> GSM260935     2  0.3291      0.924 0.000 0.840 0.000 0.040 0.120
#> GSM260938     2  0.2628      0.940 0.000 0.884 0.000 0.028 0.088
#> GSM260941     2  0.2628      0.940 0.000 0.884 0.000 0.028 0.088
#> GSM260944     2  0.2628      0.940 0.000 0.884 0.000 0.028 0.088
#> GSM260947     2  0.2628      0.940 0.000 0.884 0.000 0.028 0.088
#> GSM260952     2  0.0000      0.945 0.000 1.000 0.000 0.000 0.000
#> GSM260914     1  0.0162      0.968 0.996 0.000 0.000 0.000 0.004
#> GSM260916     1  0.0162      0.968 0.996 0.000 0.000 0.000 0.004
#> GSM260919     1  0.0609      0.962 0.980 0.000 0.000 0.000 0.020
#> GSM260922     1  0.0404      0.967 0.988 0.000 0.000 0.000 0.012
#> GSM260925     1  0.0290      0.968 0.992 0.000 0.000 0.000 0.008
#> GSM260927     1  0.2249      0.857 0.896 0.000 0.000 0.008 0.096
#> GSM260930     5  0.3752      0.988 0.292 0.000 0.000 0.000 0.708
#> GSM260933     5  0.3707      0.992 0.284 0.000 0.000 0.000 0.716
#> GSM260936     5  0.3684      0.993 0.280 0.000 0.000 0.000 0.720
#> GSM260939     5  0.3684      0.993 0.280 0.000 0.000 0.000 0.720
#> GSM260942     5  0.3684      0.993 0.280 0.000 0.000 0.000 0.720
#> GSM260945     5  0.3684      0.993 0.280 0.000 0.000 0.000 0.720
#> GSM260948     1  0.1732      0.897 0.920 0.000 0.000 0.000 0.080
#> GSM260950     1  0.0703      0.960 0.976 0.000 0.000 0.000 0.024
#> GSM260915     4  0.1943      0.943 0.000 0.000 0.056 0.924 0.020
#> GSM260917     3  0.2848      0.819 0.000 0.000 0.840 0.156 0.004
#> GSM260920     4  0.2130      0.932 0.000 0.000 0.080 0.908 0.012
#> GSM260923     4  0.1502      0.943 0.000 0.000 0.056 0.940 0.004
#> GSM260926     4  0.1877      0.942 0.000 0.000 0.064 0.924 0.012
#> GSM260928     4  0.6136      0.612 0.180 0.000 0.016 0.616 0.188
#> GSM260931     3  0.0162      0.972 0.000 0.000 0.996 0.004 0.000
#> GSM260934     3  0.0609      0.972 0.000 0.000 0.980 0.020 0.000
#> GSM260937     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> GSM260940     3  0.0162      0.972 0.000 0.000 0.996 0.004 0.000
#> GSM260943     3  0.0162      0.972 0.000 0.000 0.996 0.004 0.000
#> GSM260946     3  0.0162      0.972 0.000 0.000 0.996 0.004 0.000
#> GSM260949     4  0.1809      0.943 0.000 0.000 0.060 0.928 0.012
#> GSM260951     3  0.1205      0.951 0.000 0.000 0.956 0.040 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM260888     2  0.0725      0.876 0.000 0.976 0.000 0.000 0.012 0.012
#> GSM260893     2  0.0725      0.876 0.000 0.976 0.000 0.000 0.012 0.012
#> GSM260896     2  0.0725      0.876 0.000 0.976 0.000 0.000 0.012 0.012
#> GSM260899     2  0.3464      0.793 0.000 0.688 0.000 0.000 0.000 0.312
#> GSM260902     2  0.3464      0.793 0.000 0.688 0.000 0.000 0.000 0.312
#> GSM260905     2  0.2520      0.872 0.000 0.844 0.000 0.000 0.004 0.152
#> GSM260908     2  0.2482      0.873 0.000 0.848 0.000 0.000 0.004 0.148
#> GSM260911     2  0.0820      0.874 0.000 0.972 0.000 0.000 0.012 0.016
#> GSM260912     2  0.0000      0.880 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260913     4  0.0984      0.922 0.000 0.000 0.012 0.968 0.012 0.008
#> GSM260886     1  0.0405      0.912 0.988 0.000 0.000 0.000 0.008 0.004
#> GSM260889     1  0.0993      0.911 0.964 0.000 0.000 0.000 0.024 0.012
#> GSM260891     1  0.2214      0.865 0.888 0.000 0.000 0.000 0.016 0.096
#> GSM260894     1  0.2258      0.871 0.896 0.000 0.000 0.000 0.044 0.060
#> GSM260897     5  0.1910      0.971 0.108 0.000 0.000 0.000 0.892 0.000
#> GSM260900     5  0.2783      0.943 0.148 0.000 0.000 0.000 0.836 0.016
#> GSM260903     5  0.2389      0.966 0.128 0.000 0.000 0.000 0.864 0.008
#> GSM260906     5  0.2302      0.969 0.120 0.000 0.000 0.000 0.872 0.008
#> GSM260909     1  0.1686      0.889 0.924 0.000 0.000 0.000 0.012 0.064
#> GSM260887     4  0.1232      0.918 0.000 0.000 0.016 0.956 0.004 0.024
#> GSM260890     4  0.0858      0.919 0.000 0.000 0.004 0.968 0.000 0.028
#> GSM260892     4  0.1065      0.921 0.000 0.000 0.008 0.964 0.008 0.020
#> GSM260895     4  0.4111      0.468 0.012 0.000 0.000 0.716 0.028 0.244
#> GSM260898     3  0.2480      0.901 0.000 0.000 0.896 0.028 0.028 0.048
#> GSM260901     3  0.2556      0.900 0.000 0.000 0.892 0.028 0.032 0.048
#> GSM260904     3  0.2886      0.889 0.000 0.000 0.872 0.040 0.028 0.060
#> GSM260907     3  0.2172      0.907 0.000 0.000 0.912 0.020 0.024 0.044
#> GSM260910     4  0.0508      0.920 0.000 0.000 0.004 0.984 0.000 0.012
#> GSM260918     2  0.0363      0.881 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM260921     2  0.0363      0.878 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM260924     2  0.0622      0.877 0.000 0.980 0.000 0.000 0.008 0.012
#> GSM260929     2  0.0291      0.881 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM260932     2  0.3464      0.793 0.000 0.688 0.000 0.000 0.000 0.312
#> GSM260935     2  0.3464      0.793 0.000 0.688 0.000 0.000 0.000 0.312
#> GSM260938     2  0.2902      0.859 0.000 0.800 0.000 0.000 0.004 0.196
#> GSM260941     2  0.2703      0.868 0.000 0.824 0.000 0.000 0.004 0.172
#> GSM260944     2  0.2668      0.869 0.000 0.828 0.000 0.000 0.004 0.168
#> GSM260947     2  0.2738      0.867 0.000 0.820 0.000 0.000 0.004 0.176
#> GSM260952     2  0.0363      0.879 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM260914     1  0.0260      0.912 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260916     1  0.0405      0.910 0.988 0.000 0.000 0.000 0.004 0.008
#> GSM260919     1  0.1498      0.897 0.940 0.000 0.000 0.000 0.032 0.028
#> GSM260922     1  0.0458      0.908 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM260925     1  0.0405      0.911 0.988 0.000 0.000 0.000 0.008 0.004
#> GSM260927     1  0.4203      0.616 0.716 0.000 0.000 0.000 0.216 0.068
#> GSM260930     5  0.2907      0.938 0.152 0.000 0.000 0.000 0.828 0.020
#> GSM260933     5  0.2581      0.964 0.120 0.000 0.000 0.000 0.860 0.020
#> GSM260936     5  0.2006      0.969 0.104 0.000 0.000 0.000 0.892 0.004
#> GSM260939     5  0.2118      0.969 0.104 0.000 0.000 0.000 0.888 0.008
#> GSM260942     5  0.2006      0.969 0.104 0.000 0.000 0.000 0.892 0.004
#> GSM260945     5  0.2118      0.969 0.104 0.000 0.000 0.000 0.888 0.008
#> GSM260948     1  0.3139      0.769 0.816 0.000 0.000 0.000 0.152 0.032
#> GSM260950     1  0.1225      0.906 0.952 0.000 0.000 0.000 0.036 0.012
#> GSM260915     4  0.1511      0.918 0.000 0.000 0.012 0.940 0.004 0.044
#> GSM260917     3  0.3991      0.650 0.000 0.000 0.748 0.200 0.008 0.044
#> GSM260920     4  0.2341      0.878 0.000 0.000 0.032 0.900 0.012 0.056
#> GSM260923     4  0.1307      0.918 0.000 0.000 0.008 0.952 0.008 0.032
#> GSM260926     4  0.1555      0.916 0.000 0.000 0.008 0.940 0.012 0.040
#> GSM260928     6  0.7192      0.000 0.124 0.000 0.036 0.228 0.100 0.512
#> GSM260931     3  0.0260      0.912 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM260934     3  0.2252      0.906 0.000 0.000 0.908 0.020 0.028 0.044
#> GSM260937     3  0.1141      0.899 0.000 0.000 0.948 0.000 0.000 0.052
#> GSM260940     3  0.0363      0.912 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM260943     3  0.1007      0.902 0.000 0.000 0.956 0.000 0.000 0.044
#> GSM260946     3  0.0146      0.912 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM260949     4  0.1453      0.917 0.000 0.000 0.008 0.944 0.008 0.040
#> GSM260951     3  0.1909      0.890 0.000 0.000 0.920 0.024 0.004 0.052

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) cell.type(p) k
#> CV:skmeans 67            0.939     2.75e-14 2
#> CV:skmeans 67            0.927     9.68e-27 3
#> CV:skmeans 67            0.841     2.78e-25 4
#> CV:skmeans 67            0.933     6.06e-24 5
#> CV:skmeans 65            0.940     4.03e-23 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 21168 rows and 67 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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           1.000       1.000         0.4257 0.575   0.575
#> 3 3 1.000           0.987       0.994         0.5842 0.751   0.567
#> 4 4 1.000           0.976       0.977         0.0922 0.930   0.789
#> 5 5 0.994           0.966       0.979         0.0843 0.926   0.726
#> 6 6 0.958           0.941       0.964         0.0548 0.955   0.778

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM260888     2       0          1  0  1
#> GSM260893     2       0          1  0  1
#> GSM260896     2       0          1  0  1
#> GSM260899     2       0          1  0  1
#> GSM260902     2       0          1  0  1
#> GSM260905     2       0          1  0  1
#> GSM260908     2       0          1  0  1
#> GSM260911     2       0          1  0  1
#> GSM260912     2       0          1  0  1
#> GSM260913     1       0          1  1  0
#> GSM260886     1       0          1  1  0
#> GSM260889     1       0          1  1  0
#> GSM260891     1       0          1  1  0
#> GSM260894     1       0          1  1  0
#> GSM260897     1       0          1  1  0
#> GSM260900     1       0          1  1  0
#> GSM260903     1       0          1  1  0
#> GSM260906     1       0          1  1  0
#> GSM260909     1       0          1  1  0
#> GSM260887     1       0          1  1  0
#> GSM260890     1       0          1  1  0
#> GSM260892     1       0          1  1  0
#> GSM260895     1       0          1  1  0
#> GSM260898     1       0          1  1  0
#> GSM260901     1       0          1  1  0
#> GSM260904     1       0          1  1  0
#> GSM260907     1       0          1  1  0
#> GSM260910     1       0          1  1  0
#> GSM260918     2       0          1  0  1
#> GSM260921     2       0          1  0  1
#> GSM260924     2       0          1  0  1
#> GSM260929     2       0          1  0  1
#> GSM260932     2       0          1  0  1
#> GSM260935     2       0          1  0  1
#> GSM260938     2       0          1  0  1
#> GSM260941     2       0          1  0  1
#> GSM260944     2       0          1  0  1
#> GSM260947     2       0          1  0  1
#> GSM260952     2       0          1  0  1
#> GSM260914     1       0          1  1  0
#> GSM260916     1       0          1  1  0
#> GSM260919     1       0          1  1  0
#> GSM260922     1       0          1  1  0
#> GSM260925     1       0          1  1  0
#> GSM260927     1       0          1  1  0
#> GSM260930     1       0          1  1  0
#> GSM260933     1       0          1  1  0
#> GSM260936     1       0          1  1  0
#> GSM260939     1       0          1  1  0
#> GSM260942     1       0          1  1  0
#> GSM260945     1       0          1  1  0
#> GSM260948     1       0          1  1  0
#> GSM260950     1       0          1  1  0
#> GSM260915     1       0          1  1  0
#> GSM260917     1       0          1  1  0
#> GSM260920     1       0          1  1  0
#> GSM260923     1       0          1  1  0
#> GSM260926     1       0          1  1  0
#> GSM260928     1       0          1  1  0
#> GSM260931     1       0          1  1  0
#> GSM260934     1       0          1  1  0
#> GSM260937     1       0          1  1  0
#> GSM260940     1       0          1  1  0
#> GSM260943     1       0          1  1  0
#> GSM260946     1       0          1  1  0
#> GSM260949     1       0          1  1  0
#> GSM260951     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM260888     2    0.00      1.000 0.000  1 0.000
#> GSM260893     2    0.00      1.000 0.000  1 0.000
#> GSM260896     2    0.00      1.000 0.000  1 0.000
#> GSM260899     2    0.00      1.000 0.000  1 0.000
#> GSM260902     2    0.00      1.000 0.000  1 0.000
#> GSM260905     2    0.00      1.000 0.000  1 0.000
#> GSM260908     2    0.00      1.000 0.000  1 0.000
#> GSM260911     2    0.00      1.000 0.000  1 0.000
#> GSM260912     2    0.00      1.000 0.000  1 0.000
#> GSM260913     3    0.00      1.000 0.000  0 1.000
#> GSM260886     1    0.00      0.983 1.000  0 0.000
#> GSM260889     1    0.00      0.983 1.000  0 0.000
#> GSM260891     1    0.00      0.983 1.000  0 0.000
#> GSM260894     1    0.00      0.983 1.000  0 0.000
#> GSM260897     1    0.00      0.983 1.000  0 0.000
#> GSM260900     1    0.00      0.983 1.000  0 0.000
#> GSM260903     1    0.00      0.983 1.000  0 0.000
#> GSM260906     1    0.00      0.983 1.000  0 0.000
#> GSM260909     1    0.00      0.983 1.000  0 0.000
#> GSM260887     3    0.00      1.000 0.000  0 1.000
#> GSM260890     3    0.00      1.000 0.000  0 1.000
#> GSM260892     3    0.00      1.000 0.000  0 1.000
#> GSM260895     1    0.45      0.766 0.804  0 0.196
#> GSM260898     3    0.00      1.000 0.000  0 1.000
#> GSM260901     3    0.00      1.000 0.000  0 1.000
#> GSM260904     3    0.00      1.000 0.000  0 1.000
#> GSM260907     3    0.00      1.000 0.000  0 1.000
#> GSM260910     3    0.00      1.000 0.000  0 1.000
#> GSM260918     2    0.00      1.000 0.000  1 0.000
#> GSM260921     2    0.00      1.000 0.000  1 0.000
#> GSM260924     2    0.00      1.000 0.000  1 0.000
#> GSM260929     2    0.00      1.000 0.000  1 0.000
#> GSM260932     2    0.00      1.000 0.000  1 0.000
#> GSM260935     2    0.00      1.000 0.000  1 0.000
#> GSM260938     2    0.00      1.000 0.000  1 0.000
#> GSM260941     2    0.00      1.000 0.000  1 0.000
#> GSM260944     2    0.00      1.000 0.000  1 0.000
#> GSM260947     2    0.00      1.000 0.000  1 0.000
#> GSM260952     2    0.00      1.000 0.000  1 0.000
#> GSM260914     1    0.00      0.983 1.000  0 0.000
#> GSM260916     1    0.00      0.983 1.000  0 0.000
#> GSM260919     1    0.00      0.983 1.000  0 0.000
#> GSM260922     1    0.00      0.983 1.000  0 0.000
#> GSM260925     1    0.00      0.983 1.000  0 0.000
#> GSM260927     1    0.00      0.983 1.000  0 0.000
#> GSM260930     1    0.00      0.983 1.000  0 0.000
#> GSM260933     1    0.00      0.983 1.000  0 0.000
#> GSM260936     1    0.00      0.983 1.000  0 0.000
#> GSM260939     1    0.00      0.983 1.000  0 0.000
#> GSM260942     1    0.00      0.983 1.000  0 0.000
#> GSM260945     1    0.00      0.983 1.000  0 0.000
#> GSM260948     1    0.00      0.983 1.000  0 0.000
#> GSM260950     1    0.00      0.983 1.000  0 0.000
#> GSM260915     3    0.00      1.000 0.000  0 1.000
#> GSM260917     3    0.00      1.000 0.000  0 1.000
#> GSM260920     3    0.00      1.000 0.000  0 1.000
#> GSM260923     3    0.00      1.000 0.000  0 1.000
#> GSM260926     3    0.00      1.000 0.000  0 1.000
#> GSM260928     1    0.46      0.754 0.796  0 0.204
#> GSM260931     3    0.00      1.000 0.000  0 1.000
#> GSM260934     3    0.00      1.000 0.000  0 1.000
#> GSM260937     3    0.00      1.000 0.000  0 1.000
#> GSM260940     3    0.00      1.000 0.000  0 1.000
#> GSM260943     3    0.00      1.000 0.000  0 1.000
#> GSM260946     3    0.00      1.000 0.000  0 1.000
#> GSM260949     3    0.00      1.000 0.000  0 1.000
#> GSM260951     3    0.00      1.000 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM260888     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260893     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260896     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260899     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260902     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260905     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260908     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260911     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260912     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260913     4  0.1867      0.965 0.000  0 0.072 0.928
#> GSM260886     1  0.0000      0.967 1.000  0 0.000 0.000
#> GSM260889     1  0.0000      0.967 1.000  0 0.000 0.000
#> GSM260891     1  0.0000      0.967 1.000  0 0.000 0.000
#> GSM260894     1  0.0000      0.967 1.000  0 0.000 0.000
#> GSM260897     1  0.1474      0.964 0.948  0 0.000 0.052
#> GSM260900     1  0.1474      0.964 0.948  0 0.000 0.052
#> GSM260903     1  0.1474      0.964 0.948  0 0.000 0.052
#> GSM260906     1  0.1474      0.964 0.948  0 0.000 0.052
#> GSM260909     1  0.0000      0.967 1.000  0 0.000 0.000
#> GSM260887     4  0.1474      0.980 0.000  0 0.052 0.948
#> GSM260890     4  0.1474      0.980 0.000  0 0.052 0.948
#> GSM260892     4  0.1474      0.980 0.000  0 0.052 0.948
#> GSM260895     4  0.1635      0.933 0.044  0 0.008 0.948
#> GSM260898     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM260901     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM260904     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM260907     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM260910     4  0.1474      0.980 0.000  0 0.052 0.948
#> GSM260918     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260921     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260924     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260929     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260932     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260935     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260938     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260941     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260944     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260947     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260952     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260914     1  0.0000      0.967 1.000  0 0.000 0.000
#> GSM260916     1  0.0000      0.967 1.000  0 0.000 0.000
#> GSM260919     1  0.0000      0.967 1.000  0 0.000 0.000
#> GSM260922     1  0.0000      0.967 1.000  0 0.000 0.000
#> GSM260925     1  0.0000      0.967 1.000  0 0.000 0.000
#> GSM260927     1  0.0817      0.966 0.976  0 0.000 0.024
#> GSM260930     1  0.1474      0.964 0.948  0 0.000 0.052
#> GSM260933     1  0.1474      0.964 0.948  0 0.000 0.052
#> GSM260936     1  0.1474      0.964 0.948  0 0.000 0.052
#> GSM260939     1  0.1474      0.964 0.948  0 0.000 0.052
#> GSM260942     1  0.1474      0.964 0.948  0 0.000 0.052
#> GSM260945     1  0.1474      0.964 0.948  0 0.000 0.052
#> GSM260948     1  0.0469      0.966 0.988  0 0.000 0.012
#> GSM260950     1  0.0000      0.967 1.000  0 0.000 0.000
#> GSM260915     4  0.1474      0.980 0.000  0 0.052 0.948
#> GSM260917     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM260920     4  0.3266      0.860 0.000  0 0.168 0.832
#> GSM260923     4  0.1474      0.980 0.000  0 0.052 0.948
#> GSM260926     4  0.1474      0.980 0.000  0 0.052 0.948
#> GSM260928     1  0.4957      0.579 0.668  0 0.012 0.320
#> GSM260931     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM260934     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM260937     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM260940     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM260943     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM260946     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM260949     4  0.1474      0.980 0.000  0 0.052 0.948
#> GSM260951     3  0.0000      1.000 0.000  0 1.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
#> GSM260888     2  0.0609      0.991 0.000 0.980 0.000 0.000 0.020
#> GSM260893     2  0.0609      0.991 0.000 0.980 0.000 0.000 0.020
#> GSM260896     2  0.0609      0.991 0.000 0.980 0.000 0.000 0.020
#> GSM260899     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000
#> GSM260902     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000
#> GSM260905     2  0.0290      0.992 0.000 0.992 0.000 0.000 0.008
#> GSM260908     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000
#> GSM260911     2  0.0609      0.991 0.000 0.980 0.000 0.000 0.020
#> GSM260912     2  0.0609      0.991 0.000 0.980 0.000 0.000 0.020
#> GSM260913     4  0.0703      0.937 0.000 0.000 0.024 0.976 0.000
#> GSM260886     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM260891     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM260894     1  0.0162      0.965 0.996 0.000 0.000 0.000 0.004
#> GSM260897     5  0.0609      0.985 0.020 0.000 0.000 0.000 0.980
#> GSM260900     5  0.2074      0.909 0.104 0.000 0.000 0.000 0.896
#> GSM260903     5  0.0609      0.985 0.020 0.000 0.000 0.000 0.980
#> GSM260906     5  0.0609      0.985 0.020 0.000 0.000 0.000 0.980
#> GSM260909     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM260887     4  0.0000      0.951 0.000 0.000 0.000 1.000 0.000
#> GSM260890     4  0.0000      0.951 0.000 0.000 0.000 1.000 0.000
#> GSM260892     4  0.0000      0.951 0.000 0.000 0.000 1.000 0.000
#> GSM260895     4  0.1965      0.874 0.096 0.000 0.000 0.904 0.000
#> GSM260898     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM260901     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM260904     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM260907     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM260910     4  0.0000      0.951 0.000 0.000 0.000 1.000 0.000
#> GSM260918     2  0.0609      0.991 0.000 0.980 0.000 0.000 0.020
#> GSM260921     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000
#> GSM260924     2  0.0609      0.991 0.000 0.980 0.000 0.000 0.020
#> GSM260929     2  0.0609      0.991 0.000 0.980 0.000 0.000 0.020
#> GSM260932     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000
#> GSM260935     2  0.0290      0.992 0.000 0.992 0.000 0.000 0.008
#> GSM260938     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000
#> GSM260941     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000
#> GSM260944     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000
#> GSM260947     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000
#> GSM260952     2  0.0404      0.992 0.000 0.988 0.000 0.000 0.012
#> GSM260914     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM260916     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM260919     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM260922     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM260925     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM260927     1  0.2852      0.785 0.828 0.000 0.000 0.000 0.172
#> GSM260930     5  0.1197      0.967 0.048 0.000 0.000 0.000 0.952
#> GSM260933     5  0.0963      0.976 0.036 0.000 0.000 0.000 0.964
#> GSM260936     5  0.0609      0.985 0.020 0.000 0.000 0.000 0.980
#> GSM260939     5  0.0609      0.985 0.020 0.000 0.000 0.000 0.980
#> GSM260942     5  0.0609      0.985 0.020 0.000 0.000 0.000 0.980
#> GSM260945     5  0.0609      0.985 0.020 0.000 0.000 0.000 0.980
#> GSM260948     1  0.3003      0.776 0.812 0.000 0.000 0.000 0.188
#> GSM260950     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM260915     4  0.0000      0.951 0.000 0.000 0.000 1.000 0.000
#> GSM260917     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM260920     4  0.2230      0.855 0.000 0.000 0.116 0.884 0.000
#> GSM260923     4  0.0000      0.951 0.000 0.000 0.000 1.000 0.000
#> GSM260926     4  0.0000      0.951 0.000 0.000 0.000 1.000 0.000
#> GSM260928     4  0.4040      0.624 0.016 0.000 0.000 0.724 0.260
#> GSM260931     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM260934     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM260937     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM260940     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM260943     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM260946     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM260949     4  0.0000      0.951 0.000 0.000 0.000 1.000 0.000
#> GSM260951     3  0.0000      1.000 0.000 0.000 1.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
#> GSM260888     2  0.0713      0.965 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM260893     2  0.0713      0.965 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM260896     2  0.0713      0.965 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM260899     6  0.1387      0.906 0.000 0.068 0.000 0.000 0.000 0.932
#> GSM260902     6  0.0260      0.929 0.000 0.008 0.000 0.000 0.000 0.992
#> GSM260905     6  0.2664      0.829 0.000 0.184 0.000 0.000 0.000 0.816
#> GSM260908     6  0.0790      0.940 0.000 0.032 0.000 0.000 0.000 0.968
#> GSM260911     2  0.0713      0.965 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM260912     2  0.0713      0.965 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM260913     4  0.1007      0.922 0.000 0.000 0.044 0.956 0.000 0.000
#> GSM260886     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260891     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260894     1  0.0146      0.965 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260897     5  0.0000      0.984 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260900     5  0.1663      0.906 0.088 0.000 0.000 0.000 0.912 0.000
#> GSM260903     5  0.0000      0.984 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260906     5  0.0000      0.984 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260909     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260887     4  0.0000      0.947 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260890     4  0.0000      0.947 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260892     4  0.0000      0.947 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260895     4  0.1765      0.869 0.096 0.000 0.000 0.904 0.000 0.000
#> GSM260898     3  0.0260      0.989 0.000 0.008 0.992 0.000 0.000 0.000
#> GSM260901     3  0.0260      0.989 0.000 0.008 0.992 0.000 0.000 0.000
#> GSM260904     3  0.0260      0.989 0.000 0.008 0.992 0.000 0.000 0.000
#> GSM260907     3  0.0260      0.989 0.000 0.008 0.992 0.000 0.000 0.000
#> GSM260910     4  0.0000      0.947 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260918     2  0.0790      0.963 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM260921     6  0.1556      0.915 0.000 0.080 0.000 0.000 0.000 0.920
#> GSM260924     2  0.1957      0.896 0.000 0.888 0.000 0.000 0.000 0.112
#> GSM260929     2  0.0790      0.963 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM260932     6  0.0000      0.927 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM260935     6  0.2823      0.773 0.000 0.204 0.000 0.000 0.000 0.796
#> GSM260938     6  0.0713      0.940 0.000 0.028 0.000 0.000 0.000 0.972
#> GSM260941     6  0.0790      0.940 0.000 0.032 0.000 0.000 0.000 0.968
#> GSM260944     6  0.0790      0.940 0.000 0.032 0.000 0.000 0.000 0.968
#> GSM260947     6  0.0790      0.940 0.000 0.032 0.000 0.000 0.000 0.968
#> GSM260952     2  0.2762      0.798 0.000 0.804 0.000 0.000 0.000 0.196
#> GSM260914     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260916     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260919     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260922     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260925     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260927     1  0.2631      0.780 0.820 0.000 0.000 0.000 0.180 0.000
#> GSM260930     5  0.0713      0.966 0.028 0.000 0.000 0.000 0.972 0.000
#> GSM260933     5  0.0547      0.972 0.020 0.000 0.000 0.000 0.980 0.000
#> GSM260936     5  0.0000      0.984 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260939     5  0.0000      0.984 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260942     5  0.0000      0.984 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260945     5  0.0000      0.984 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260948     1  0.2762      0.770 0.804 0.000 0.000 0.000 0.196 0.000
#> GSM260950     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260915     4  0.0000      0.947 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260917     3  0.0603      0.988 0.000 0.016 0.980 0.004 0.000 0.000
#> GSM260920     4  0.2320      0.838 0.000 0.004 0.132 0.864 0.000 0.000
#> GSM260923     4  0.0000      0.947 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260926     4  0.0000      0.947 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260928     4  0.3714      0.624 0.008 0.008 0.000 0.720 0.264 0.000
#> GSM260931     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260934     3  0.0260      0.989 0.000 0.008 0.992 0.000 0.000 0.000
#> GSM260937     3  0.0547      0.988 0.000 0.020 0.980 0.000 0.000 0.000
#> GSM260940     3  0.0547      0.988 0.000 0.020 0.980 0.000 0.000 0.000
#> GSM260943     3  0.0547      0.988 0.000 0.020 0.980 0.000 0.000 0.000
#> GSM260946     3  0.0260      0.990 0.000 0.008 0.992 0.000 0.000 0.000
#> GSM260949     4  0.0000      0.947 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260951     3  0.0547      0.988 0.000 0.020 0.980 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-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) cell.type(p) k
#> CV:pam 67            0.939     2.75e-14 2
#> CV:pam 67            0.940     1.87e-24 3
#> CV:pam 67            0.716     4.07e-24 4
#> CV:pam 67            0.933     6.06e-24 5
#> CV:pam 67            0.902     9.88e-23 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 21168 rows and 67 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 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-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           1.000       1.000         0.4257 0.575   0.575
#> 3 3 1.000           0.979       0.991         0.5852 0.750   0.566
#> 4 4 0.877           0.854       0.881         0.0682 0.980   0.939
#> 5 5 0.874           0.864       0.864         0.0828 0.877   0.608
#> 6 6 0.823           0.857       0.854         0.0553 0.944   0.732

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
#> GSM260888     2       0          1  0  1
#> GSM260893     2       0          1  0  1
#> GSM260896     2       0          1  0  1
#> GSM260899     2       0          1  0  1
#> GSM260902     2       0          1  0  1
#> GSM260905     2       0          1  0  1
#> GSM260908     2       0          1  0  1
#> GSM260911     2       0          1  0  1
#> GSM260912     2       0          1  0  1
#> GSM260913     1       0          1  1  0
#> GSM260886     1       0          1  1  0
#> GSM260889     1       0          1  1  0
#> GSM260891     1       0          1  1  0
#> GSM260894     1       0          1  1  0
#> GSM260897     1       0          1  1  0
#> GSM260900     1       0          1  1  0
#> GSM260903     1       0          1  1  0
#> GSM260906     1       0          1  1  0
#> GSM260909     1       0          1  1  0
#> GSM260887     1       0          1  1  0
#> GSM260890     1       0          1  1  0
#> GSM260892     1       0          1  1  0
#> GSM260895     1       0          1  1  0
#> GSM260898     1       0          1  1  0
#> GSM260901     1       0          1  1  0
#> GSM260904     1       0          1  1  0
#> GSM260907     1       0          1  1  0
#> GSM260910     1       0          1  1  0
#> GSM260918     2       0          1  0  1
#> GSM260921     2       0          1  0  1
#> GSM260924     2       0          1  0  1
#> GSM260929     2       0          1  0  1
#> GSM260932     2       0          1  0  1
#> GSM260935     2       0          1  0  1
#> GSM260938     2       0          1  0  1
#> GSM260941     2       0          1  0  1
#> GSM260944     2       0          1  0  1
#> GSM260947     2       0          1  0  1
#> GSM260952     2       0          1  0  1
#> GSM260914     1       0          1  1  0
#> GSM260916     1       0          1  1  0
#> GSM260919     1       0          1  1  0
#> GSM260922     1       0          1  1  0
#> GSM260925     1       0          1  1  0
#> GSM260927     1       0          1  1  0
#> GSM260930     1       0          1  1  0
#> GSM260933     1       0          1  1  0
#> GSM260936     1       0          1  1  0
#> GSM260939     1       0          1  1  0
#> GSM260942     1       0          1  1  0
#> GSM260945     1       0          1  1  0
#> GSM260948     1       0          1  1  0
#> GSM260950     1       0          1  1  0
#> GSM260915     1       0          1  1  0
#> GSM260917     1       0          1  1  0
#> GSM260920     1       0          1  1  0
#> GSM260923     1       0          1  1  0
#> GSM260926     1       0          1  1  0
#> GSM260928     1       0          1  1  0
#> GSM260931     1       0          1  1  0
#> GSM260934     1       0          1  1  0
#> GSM260937     1       0          1  1  0
#> GSM260940     1       0          1  1  0
#> GSM260943     1       0          1  1  0
#> GSM260946     1       0          1  1  0
#> GSM260949     1       0          1  1  0
#> GSM260951     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette  p1    p2    p3
#> GSM260888     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260893     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260896     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260899     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260902     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260905     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260908     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260911     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260912     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260913     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260886     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260889     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260891     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260894     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260897     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260900     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260903     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260906     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260909     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260887     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260890     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260892     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260895     3  0.5560      0.590 0.3 0.000 0.700
#> GSM260898     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260901     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260904     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260907     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260910     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260918     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260921     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260924     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260929     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260932     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260935     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260938     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260941     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260944     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260947     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260952     2  0.0000      1.000 0.0 1.000 0.000
#> GSM260914     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260916     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260919     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260922     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260925     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260927     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260930     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260933     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260936     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260939     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260942     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260945     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260948     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260950     1  0.0000      1.000 1.0 0.000 0.000
#> GSM260915     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260917     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260920     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260923     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260926     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260928     3  0.5560      0.590 0.3 0.000 0.700
#> GSM260931     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260934     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260937     3  0.0237      0.969 0.0 0.004 0.996
#> GSM260940     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260943     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260946     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260949     3  0.0000      0.973 0.0 0.000 1.000
#> GSM260951     3  0.0000      0.973 0.0 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM260888     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260893     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260896     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260899     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260902     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260905     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260908     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260911     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260912     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260913     3  0.0921      0.817 0.000  0 0.972 0.028
#> GSM260886     1  0.4855      0.801 0.600  0 0.000 0.400
#> GSM260889     1  0.4855      0.801 0.600  0 0.000 0.400
#> GSM260891     1  0.4967      0.770 0.548  0 0.000 0.452
#> GSM260894     1  0.4855      0.801 0.600  0 0.000 0.400
#> GSM260897     1  0.0000      0.739 1.000  0 0.000 0.000
#> GSM260900     1  0.0000      0.739 1.000  0 0.000 0.000
#> GSM260903     1  0.0000      0.739 1.000  0 0.000 0.000
#> GSM260906     1  0.0000      0.739 1.000  0 0.000 0.000
#> GSM260909     1  0.4855      0.801 0.600  0 0.000 0.400
#> GSM260887     3  0.0000      0.832 0.000  0 1.000 0.000
#> GSM260890     3  0.1022      0.815 0.000  0 0.968 0.032
#> GSM260892     3  0.0921      0.817 0.000  0 0.972 0.028
#> GSM260895     4  0.6213      1.000 0.052  0 0.464 0.484
#> GSM260898     3  0.2589      0.837 0.000  0 0.884 0.116
#> GSM260901     3  0.2589      0.837 0.000  0 0.884 0.116
#> GSM260904     3  0.2589      0.837 0.000  0 0.884 0.116
#> GSM260907     3  0.2589      0.837 0.000  0 0.884 0.116
#> GSM260910     3  0.0921      0.818 0.000  0 0.972 0.028
#> GSM260918     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260921     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260924     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260929     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260932     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260935     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260938     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260941     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260944     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260947     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260952     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260914     1  0.4855      0.801 0.600  0 0.000 0.400
#> GSM260916     1  0.4961      0.773 0.552  0 0.000 0.448
#> GSM260919     1  0.4866      0.799 0.596  0 0.000 0.404
#> GSM260922     1  0.4948      0.778 0.560  0 0.000 0.440
#> GSM260925     1  0.4855      0.801 0.600  0 0.000 0.400
#> GSM260927     1  0.4855      0.801 0.600  0 0.000 0.400
#> GSM260930     1  0.0000      0.739 1.000  0 0.000 0.000
#> GSM260933     1  0.0000      0.739 1.000  0 0.000 0.000
#> GSM260936     1  0.0000      0.739 1.000  0 0.000 0.000
#> GSM260939     1  0.0188      0.736 0.996  0 0.000 0.004
#> GSM260942     1  0.0000      0.739 1.000  0 0.000 0.000
#> GSM260945     1  0.0000      0.739 1.000  0 0.000 0.000
#> GSM260948     1  0.4866      0.799 0.596  0 0.000 0.404
#> GSM260950     1  0.4855      0.801 0.600  0 0.000 0.400
#> GSM260915     3  0.0921      0.818 0.000  0 0.972 0.028
#> GSM260917     3  0.1940      0.839 0.000  0 0.924 0.076
#> GSM260920     3  0.0921      0.818 0.000  0 0.972 0.028
#> GSM260923     3  0.2469      0.698 0.000  0 0.892 0.108
#> GSM260926     3  0.2011      0.750 0.000  0 0.920 0.080
#> GSM260928     4  0.6213      1.000 0.052  0 0.464 0.484
#> GSM260931     3  0.2589      0.837 0.000  0 0.884 0.116
#> GSM260934     3  0.2589      0.837 0.000  0 0.884 0.116
#> GSM260937     3  0.4500      0.324 0.000  0 0.684 0.316
#> GSM260940     3  0.2589      0.837 0.000  0 0.884 0.116
#> GSM260943     3  0.2589      0.837 0.000  0 0.884 0.116
#> GSM260946     3  0.2589      0.837 0.000  0 0.884 0.116
#> GSM260949     3  0.1716      0.775 0.000  0 0.936 0.064
#> GSM260951     3  0.1637      0.841 0.000  0 0.940 0.060

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM260888     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260893     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260896     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260899     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260902     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260905     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260908     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260911     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260912     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260913     4  0.2690      0.860 0.000 0.000 0.156 0.844 0.000
#> GSM260886     1  0.4291      0.780 0.536 0.000 0.000 0.000 0.464
#> GSM260889     1  0.4287      0.781 0.540 0.000 0.000 0.000 0.460
#> GSM260891     1  0.1121      0.521 0.956 0.000 0.000 0.000 0.044
#> GSM260894     1  0.4294      0.776 0.532 0.000 0.000 0.000 0.468
#> GSM260897     5  0.0162      0.996 0.004 0.000 0.000 0.000 0.996
#> GSM260900     5  0.0162      0.996 0.004 0.000 0.000 0.000 0.996
#> GSM260903     5  0.0162      0.996 0.004 0.000 0.000 0.000 0.996
#> GSM260906     5  0.0290      0.991 0.008 0.000 0.000 0.000 0.992
#> GSM260909     1  0.4249      0.776 0.568 0.000 0.000 0.000 0.432
#> GSM260887     4  0.2852      0.855 0.000 0.000 0.172 0.828 0.000
#> GSM260890     4  0.2773      0.860 0.000 0.000 0.164 0.836 0.000
#> GSM260892     4  0.2690      0.860 0.000 0.000 0.156 0.844 0.000
#> GSM260895     4  0.5185      0.399 0.384 0.000 0.048 0.568 0.000
#> GSM260898     3  0.0510      0.907 0.000 0.000 0.984 0.016 0.000
#> GSM260901     3  0.0510      0.907 0.000 0.000 0.984 0.016 0.000
#> GSM260904     3  0.0162      0.912 0.000 0.000 0.996 0.004 0.000
#> GSM260907     3  0.0162      0.912 0.000 0.000 0.996 0.004 0.000
#> GSM260910     4  0.2773      0.860 0.000 0.000 0.164 0.836 0.000
#> GSM260918     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260921     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260924     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260929     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260932     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260935     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260938     2  0.0671      0.986 0.016 0.980 0.000 0.004 0.000
#> GSM260941     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260944     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260947     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> GSM260952     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260914     1  0.4273      0.782 0.552 0.000 0.000 0.000 0.448
#> GSM260916     1  0.1341      0.531 0.944 0.000 0.000 0.000 0.056
#> GSM260919     1  0.4262      0.777 0.560 0.000 0.000 0.000 0.440
#> GSM260922     1  0.1341      0.531 0.944 0.000 0.000 0.000 0.056
#> GSM260925     1  0.4291      0.780 0.536 0.000 0.000 0.000 0.464
#> GSM260927     1  0.4300      0.768 0.524 0.000 0.000 0.000 0.476
#> GSM260930     5  0.0162      0.996 0.004 0.000 0.000 0.000 0.996
#> GSM260933     5  0.0162      0.996 0.004 0.000 0.000 0.000 0.996
#> GSM260936     5  0.0000      0.995 0.000 0.000 0.000 0.000 1.000
#> GSM260939     5  0.0000      0.995 0.000 0.000 0.000 0.000 1.000
#> GSM260942     5  0.0000      0.995 0.000 0.000 0.000 0.000 1.000
#> GSM260945     5  0.0000      0.995 0.000 0.000 0.000 0.000 1.000
#> GSM260948     1  0.4287      0.747 0.540 0.000 0.000 0.000 0.460
#> GSM260950     1  0.4300      0.768 0.524 0.000 0.000 0.000 0.476
#> GSM260915     4  0.2773      0.860 0.000 0.000 0.164 0.836 0.000
#> GSM260917     4  0.3932      0.647 0.000 0.000 0.328 0.672 0.000
#> GSM260920     4  0.2773      0.860 0.000 0.000 0.164 0.836 0.000
#> GSM260923     4  0.2488      0.817 0.004 0.000 0.124 0.872 0.000
#> GSM260926     4  0.2329      0.846 0.000 0.000 0.124 0.876 0.000
#> GSM260928     4  0.5185      0.399 0.384 0.000 0.048 0.568 0.000
#> GSM260931     3  0.0000      0.912 0.000 0.000 1.000 0.000 0.000
#> GSM260934     3  0.0162      0.912 0.000 0.000 0.996 0.004 0.000
#> GSM260937     3  0.3485      0.772 0.048 0.000 0.828 0.124 0.000
#> GSM260940     3  0.1211      0.900 0.016 0.000 0.960 0.024 0.000
#> GSM260943     3  0.0000      0.912 0.000 0.000 1.000 0.000 0.000
#> GSM260946     3  0.0000      0.912 0.000 0.000 1.000 0.000 0.000
#> GSM260949     4  0.2561      0.856 0.000 0.000 0.144 0.856 0.000
#> GSM260951     3  0.4300     -0.261 0.000 0.000 0.524 0.476 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
#> GSM260888     2  0.0713      0.921 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM260893     2  0.1663      0.929 0.000 0.912 0.000 0.000 0.000 0.088
#> GSM260896     2  0.0547      0.929 0.000 0.980 0.000 0.000 0.000 0.020
#> GSM260899     6  0.3175      0.894 0.000 0.256 0.000 0.000 0.000 0.744
#> GSM260902     6  0.2969      0.910 0.000 0.224 0.000 0.000 0.000 0.776
#> GSM260905     6  0.3409      0.886 0.000 0.300 0.000 0.000 0.000 0.700
#> GSM260908     6  0.3659      0.741 0.000 0.364 0.000 0.000 0.000 0.636
#> GSM260911     2  0.0632      0.921 0.000 0.976 0.000 0.000 0.000 0.024
#> GSM260912     2  0.1714      0.928 0.000 0.908 0.000 0.000 0.000 0.092
#> GSM260913     4  0.1075      0.852 0.000 0.000 0.048 0.952 0.000 0.000
#> GSM260886     1  0.3717      0.812 0.616 0.000 0.000 0.000 0.384 0.000
#> GSM260889     1  0.3717      0.812 0.616 0.000 0.000 0.000 0.384 0.000
#> GSM260891     1  0.0777      0.563 0.972 0.000 0.000 0.000 0.004 0.024
#> GSM260894     1  0.3737      0.807 0.608 0.000 0.000 0.000 0.392 0.000
#> GSM260897     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260900     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260903     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260906     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260909     1  0.3695      0.811 0.624 0.000 0.000 0.000 0.376 0.000
#> GSM260887     4  0.1075      0.852 0.000 0.000 0.048 0.952 0.000 0.000
#> GSM260890     4  0.0865      0.855 0.000 0.000 0.036 0.964 0.000 0.000
#> GSM260892     4  0.1007      0.853 0.000 0.000 0.044 0.956 0.000 0.000
#> GSM260895     4  0.6391      0.446 0.352 0.000 0.108 0.472 0.000 0.068
#> GSM260898     3  0.1267      0.974 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM260901     3  0.1444      0.968 0.000 0.000 0.928 0.072 0.000 0.000
#> GSM260904     3  0.1327      0.974 0.000 0.000 0.936 0.064 0.000 0.000
#> GSM260907     3  0.1327      0.974 0.000 0.000 0.936 0.064 0.000 0.000
#> GSM260910     4  0.0790      0.854 0.000 0.000 0.032 0.968 0.000 0.000
#> GSM260918     2  0.1663      0.929 0.000 0.912 0.000 0.000 0.000 0.088
#> GSM260921     2  0.0547      0.927 0.000 0.980 0.000 0.000 0.000 0.020
#> GSM260924     2  0.0790      0.918 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM260929     2  0.1663      0.929 0.000 0.912 0.000 0.000 0.000 0.088
#> GSM260932     6  0.3151      0.888 0.000 0.252 0.000 0.000 0.000 0.748
#> GSM260935     6  0.3101      0.911 0.000 0.244 0.000 0.000 0.000 0.756
#> GSM260938     6  0.1753      0.807 0.000 0.084 0.004 0.000 0.000 0.912
#> GSM260941     6  0.2664      0.901 0.000 0.184 0.000 0.000 0.000 0.816
#> GSM260944     6  0.3023      0.909 0.000 0.232 0.000 0.000 0.000 0.768
#> GSM260947     6  0.2854      0.909 0.000 0.208 0.000 0.000 0.000 0.792
#> GSM260952     2  0.1610      0.928 0.000 0.916 0.000 0.000 0.000 0.084
#> GSM260914     1  0.3695      0.812 0.624 0.000 0.000 0.000 0.376 0.000
#> GSM260916     1  0.0363      0.582 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM260919     1  0.3706      0.810 0.620 0.000 0.000 0.000 0.380 0.000
#> GSM260922     1  0.0260      0.580 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260925     1  0.3717      0.812 0.616 0.000 0.000 0.000 0.384 0.000
#> GSM260927     1  0.3774      0.792 0.592 0.000 0.000 0.000 0.408 0.000
#> GSM260930     5  0.0146      0.993 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM260933     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260936     5  0.0146      0.996 0.000 0.000 0.000 0.000 0.996 0.004
#> GSM260939     5  0.0146      0.996 0.000 0.000 0.000 0.000 0.996 0.004
#> GSM260942     5  0.0146      0.996 0.000 0.000 0.000 0.000 0.996 0.004
#> GSM260945     5  0.0146      0.996 0.000 0.000 0.000 0.000 0.996 0.004
#> GSM260948     1  0.3782      0.731 0.588 0.000 0.000 0.000 0.412 0.000
#> GSM260950     1  0.3833      0.744 0.556 0.000 0.000 0.000 0.444 0.000
#> GSM260915     4  0.0865      0.855 0.000 0.000 0.036 0.964 0.000 0.000
#> GSM260917     4  0.2941      0.678 0.000 0.000 0.220 0.780 0.000 0.000
#> GSM260920     4  0.0865      0.855 0.000 0.000 0.036 0.964 0.000 0.000
#> GSM260923     4  0.0632      0.844 0.000 0.000 0.024 0.976 0.000 0.000
#> GSM260926     4  0.0363      0.848 0.000 0.000 0.012 0.988 0.000 0.000
#> GSM260928     4  0.6423      0.441 0.352 0.000 0.112 0.468 0.000 0.068
#> GSM260931     3  0.1267      0.974 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM260934     3  0.1327      0.974 0.000 0.000 0.936 0.064 0.000 0.000
#> GSM260937     3  0.2688      0.807 0.000 0.000 0.868 0.064 0.000 0.068
#> GSM260940     3  0.1700      0.962 0.000 0.000 0.916 0.080 0.000 0.004
#> GSM260943     3  0.1267      0.974 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM260946     3  0.1267      0.974 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM260949     4  0.0458      0.850 0.000 0.000 0.016 0.984 0.000 0.000
#> GSM260951     4  0.3854      0.150 0.000 0.000 0.464 0.536 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-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) cell.type(p) k
#> CV:mclust 67            0.939     2.75e-14 2
#> CV:mclust 67            0.927     9.68e-27 3
#> CV:mclust 66            0.977     8.31e-25 4
#> CV:mclust 64            0.994     1.10e-22 5
#> CV:mclust 64            0.994     1.71e-21 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 21168 rows and 67 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 1.000           1.000       1.000         0.4257 0.575   0.575
#> 3 3 1.000           0.990       0.996         0.5859 0.750   0.566
#> 4 4 0.909           0.911       0.934         0.0532 1.000   1.000
#> 5 5 0.883           0.835       0.912         0.0342 0.945   0.830
#> 6 6 0.840           0.855       0.901         0.0284 0.980   0.927

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
#> GSM260888     2       0          1  0  1
#> GSM260893     2       0          1  0  1
#> GSM260896     2       0          1  0  1
#> GSM260899     2       0          1  0  1
#> GSM260902     2       0          1  0  1
#> GSM260905     2       0          1  0  1
#> GSM260908     2       0          1  0  1
#> GSM260911     2       0          1  0  1
#> GSM260912     2       0          1  0  1
#> GSM260913     1       0          1  1  0
#> GSM260886     1       0          1  1  0
#> GSM260889     1       0          1  1  0
#> GSM260891     1       0          1  1  0
#> GSM260894     1       0          1  1  0
#> GSM260897     1       0          1  1  0
#> GSM260900     1       0          1  1  0
#> GSM260903     1       0          1  1  0
#> GSM260906     1       0          1  1  0
#> GSM260909     1       0          1  1  0
#> GSM260887     1       0          1  1  0
#> GSM260890     1       0          1  1  0
#> GSM260892     1       0          1  1  0
#> GSM260895     1       0          1  1  0
#> GSM260898     1       0          1  1  0
#> GSM260901     1       0          1  1  0
#> GSM260904     1       0          1  1  0
#> GSM260907     1       0          1  1  0
#> GSM260910     1       0          1  1  0
#> GSM260918     2       0          1  0  1
#> GSM260921     2       0          1  0  1
#> GSM260924     2       0          1  0  1
#> GSM260929     2       0          1  0  1
#> GSM260932     2       0          1  0  1
#> GSM260935     2       0          1  0  1
#> GSM260938     2       0          1  0  1
#> GSM260941     2       0          1  0  1
#> GSM260944     2       0          1  0  1
#> GSM260947     2       0          1  0  1
#> GSM260952     2       0          1  0  1
#> GSM260914     1       0          1  1  0
#> GSM260916     1       0          1  1  0
#> GSM260919     1       0          1  1  0
#> GSM260922     1       0          1  1  0
#> GSM260925     1       0          1  1  0
#> GSM260927     1       0          1  1  0
#> GSM260930     1       0          1  1  0
#> GSM260933     1       0          1  1  0
#> GSM260936     1       0          1  1  0
#> GSM260939     1       0          1  1  0
#> GSM260942     1       0          1  1  0
#> GSM260945     1       0          1  1  0
#> GSM260948     1       0          1  1  0
#> GSM260950     1       0          1  1  0
#> GSM260915     1       0          1  1  0
#> GSM260917     1       0          1  1  0
#> GSM260920     1       0          1  1  0
#> GSM260923     1       0          1  1  0
#> GSM260926     1       0          1  1  0
#> GSM260928     1       0          1  1  0
#> GSM260931     1       0          1  1  0
#> GSM260934     1       0          1  1  0
#> GSM260937     1       0          1  1  0
#> GSM260940     1       0          1  1  0
#> GSM260943     1       0          1  1  0
#> GSM260946     1       0          1  1  0
#> GSM260949     1       0          1  1  0
#> GSM260951     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM260888     2   0.000      1.000 0.000  1 0.000
#> GSM260893     2   0.000      1.000 0.000  1 0.000
#> GSM260896     2   0.000      1.000 0.000  1 0.000
#> GSM260899     2   0.000      1.000 0.000  1 0.000
#> GSM260902     2   0.000      1.000 0.000  1 0.000
#> GSM260905     2   0.000      1.000 0.000  1 0.000
#> GSM260908     2   0.000      1.000 0.000  1 0.000
#> GSM260911     2   0.000      1.000 0.000  1 0.000
#> GSM260912     2   0.000      1.000 0.000  1 0.000
#> GSM260913     3   0.000      0.988 0.000  0 1.000
#> GSM260886     1   0.000      1.000 1.000  0 0.000
#> GSM260889     1   0.000      1.000 1.000  0 0.000
#> GSM260891     1   0.000      1.000 1.000  0 0.000
#> GSM260894     1   0.000      1.000 1.000  0 0.000
#> GSM260897     1   0.000      1.000 1.000  0 0.000
#> GSM260900     1   0.000      1.000 1.000  0 0.000
#> GSM260903     1   0.000      1.000 1.000  0 0.000
#> GSM260906     1   0.000      1.000 1.000  0 0.000
#> GSM260909     1   0.000      1.000 1.000  0 0.000
#> GSM260887     3   0.000      0.988 0.000  0 1.000
#> GSM260890     3   0.000      0.988 0.000  0 1.000
#> GSM260892     3   0.000      0.988 0.000  0 1.000
#> GSM260895     3   0.000      0.988 0.000  0 1.000
#> GSM260898     3   0.000      0.988 0.000  0 1.000
#> GSM260901     3   0.000      0.988 0.000  0 1.000
#> GSM260904     3   0.000      0.988 0.000  0 1.000
#> GSM260907     3   0.000      0.988 0.000  0 1.000
#> GSM260910     3   0.000      0.988 0.000  0 1.000
#> GSM260918     2   0.000      1.000 0.000  1 0.000
#> GSM260921     2   0.000      1.000 0.000  1 0.000
#> GSM260924     2   0.000      1.000 0.000  1 0.000
#> GSM260929     2   0.000      1.000 0.000  1 0.000
#> GSM260932     2   0.000      1.000 0.000  1 0.000
#> GSM260935     2   0.000      1.000 0.000  1 0.000
#> GSM260938     2   0.000      1.000 0.000  1 0.000
#> GSM260941     2   0.000      1.000 0.000  1 0.000
#> GSM260944     2   0.000      1.000 0.000  1 0.000
#> GSM260947     2   0.000      1.000 0.000  1 0.000
#> GSM260952     2   0.000      1.000 0.000  1 0.000
#> GSM260914     1   0.000      1.000 1.000  0 0.000
#> GSM260916     1   0.000      1.000 1.000  0 0.000
#> GSM260919     1   0.000      1.000 1.000  0 0.000
#> GSM260922     1   0.000      1.000 1.000  0 0.000
#> GSM260925     1   0.000      1.000 1.000  0 0.000
#> GSM260927     1   0.000      1.000 1.000  0 0.000
#> GSM260930     1   0.000      1.000 1.000  0 0.000
#> GSM260933     1   0.000      1.000 1.000  0 0.000
#> GSM260936     1   0.000      1.000 1.000  0 0.000
#> GSM260939     1   0.000      1.000 1.000  0 0.000
#> GSM260942     1   0.000      1.000 1.000  0 0.000
#> GSM260945     1   0.000      1.000 1.000  0 0.000
#> GSM260948     1   0.000      1.000 1.000  0 0.000
#> GSM260950     1   0.000      1.000 1.000  0 0.000
#> GSM260915     3   0.000      0.988 0.000  0 1.000
#> GSM260917     3   0.000      0.988 0.000  0 1.000
#> GSM260920     3   0.000      0.988 0.000  0 1.000
#> GSM260923     3   0.000      0.988 0.000  0 1.000
#> GSM260926     3   0.000      0.988 0.000  0 1.000
#> GSM260928     3   0.536      0.619 0.276  0 0.724
#> GSM260931     3   0.000      0.988 0.000  0 1.000
#> GSM260934     3   0.000      0.988 0.000  0 1.000
#> GSM260937     3   0.000      0.988 0.000  0 1.000
#> GSM260940     3   0.000      0.988 0.000  0 1.000
#> GSM260943     3   0.000      0.988 0.000  0 1.000
#> GSM260946     3   0.000      0.988 0.000  0 1.000
#> GSM260949     3   0.000      0.988 0.000  0 1.000
#> GSM260951     3   0.000      0.988 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3 p4
#> GSM260888     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260893     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260896     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260899     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260902     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260905     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260908     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260911     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260912     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260913     3  0.0188      0.936 0.000  0 0.996 NA
#> GSM260886     1  0.1022      0.910 0.968  0 0.000 NA
#> GSM260889     1  0.0188      0.915 0.996  0 0.000 NA
#> GSM260891     1  0.3486      0.828 0.812  0 0.000 NA
#> GSM260894     1  0.0336      0.914 0.992  0 0.000 NA
#> GSM260897     1  0.2281      0.895 0.904  0 0.000 NA
#> GSM260900     1  0.1118      0.913 0.964  0 0.000 NA
#> GSM260903     1  0.1118      0.913 0.964  0 0.000 NA
#> GSM260906     1  0.1211      0.912 0.960  0 0.000 NA
#> GSM260909     1  0.1118      0.908 0.964  0 0.000 NA
#> GSM260887     3  0.0188      0.936 0.000  0 0.996 NA
#> GSM260890     3  0.0188      0.936 0.000  0 0.996 NA
#> GSM260892     3  0.2973      0.859 0.000  0 0.856 NA
#> GSM260895     3  0.5402      0.513 0.012  0 0.516 NA
#> GSM260898     3  0.0707      0.933 0.000  0 0.980 NA
#> GSM260901     3  0.0817      0.932 0.000  0 0.976 NA
#> GSM260904     3  0.0188      0.935 0.000  0 0.996 NA
#> GSM260907     3  0.0469      0.935 0.000  0 0.988 NA
#> GSM260910     3  0.2011      0.902 0.000  0 0.920 NA
#> GSM260918     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260921     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260924     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260929     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260932     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260935     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260938     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260941     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260944     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260947     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260952     2  0.0000      1.000 0.000  1 0.000 NA
#> GSM260914     1  0.0707      0.912 0.980  0 0.000 NA
#> GSM260916     1  0.4907      0.644 0.580  0 0.000 NA
#> GSM260919     1  0.0188      0.915 0.996  0 0.000 NA
#> GSM260922     1  0.4925      0.636 0.572  0 0.000 NA
#> GSM260925     1  0.0817      0.911 0.976  0 0.000 NA
#> GSM260927     1  0.0188      0.915 0.996  0 0.000 NA
#> GSM260930     1  0.1118      0.913 0.964  0 0.000 NA
#> GSM260933     1  0.1557      0.908 0.944  0 0.000 NA
#> GSM260936     1  0.3123      0.868 0.844  0 0.000 NA
#> GSM260939     1  0.4925      0.664 0.572  0 0.000 NA
#> GSM260942     1  0.4522      0.758 0.680  0 0.000 NA
#> GSM260945     1  0.2921      0.876 0.860  0 0.000 NA
#> GSM260948     1  0.0000      0.915 1.000  0 0.000 NA
#> GSM260950     1  0.0000      0.915 1.000  0 0.000 NA
#> GSM260915     3  0.0188      0.936 0.000  0 0.996 NA
#> GSM260917     3  0.0000      0.936 0.000  0 1.000 NA
#> GSM260920     3  0.0188      0.936 0.000  0 0.996 NA
#> GSM260923     3  0.0336      0.935 0.000  0 0.992 NA
#> GSM260926     3  0.0188      0.936 0.000  0 0.996 NA
#> GSM260928     3  0.2760      0.829 0.128  0 0.872 NA
#> GSM260931     3  0.0592      0.934 0.000  0 0.984 NA
#> GSM260934     3  0.0592      0.934 0.000  0 0.984 NA
#> GSM260937     3  0.4999      0.533 0.000  0 0.508 NA
#> GSM260940     3  0.4382      0.743 0.000  0 0.704 NA
#> GSM260943     3  0.1867      0.911 0.000  0 0.928 NA
#> GSM260946     3  0.0707      0.933 0.000  0 0.980 NA
#> GSM260949     3  0.0188      0.936 0.000  0 0.996 NA
#> GSM260951     3  0.0336      0.935 0.000  0 0.992 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM260888     2  0.0290      0.981 0.000 0.992 0.000 0.008 0.000
#> GSM260893     2  0.0162      0.982 0.000 0.996 0.000 0.004 0.000
#> GSM260896     2  0.0162      0.982 0.000 0.996 0.000 0.004 0.000
#> GSM260899     2  0.2067      0.939 0.000 0.920 0.000 0.032 0.048
#> GSM260902     2  0.2067      0.939 0.000 0.920 0.000 0.032 0.048
#> GSM260905     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> GSM260908     2  0.0162      0.982 0.000 0.996 0.000 0.004 0.000
#> GSM260911     2  0.0162      0.982 0.000 0.996 0.000 0.004 0.000
#> GSM260912     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> GSM260913     3  0.0566      0.847 0.000 0.000 0.984 0.004 0.012
#> GSM260886     1  0.1197      0.872 0.952 0.000 0.000 0.048 0.000
#> GSM260889     1  0.0703      0.887 0.976 0.000 0.000 0.024 0.000
#> GSM260891     1  0.2795      0.754 0.872 0.000 0.000 0.100 0.028
#> GSM260894     1  0.0771      0.888 0.976 0.000 0.000 0.020 0.004
#> GSM260897     1  0.2777      0.790 0.864 0.000 0.000 0.120 0.016
#> GSM260900     1  0.1041      0.889 0.964 0.000 0.000 0.032 0.004
#> GSM260903     1  0.1124      0.887 0.960 0.000 0.000 0.036 0.004
#> GSM260906     1  0.1251      0.886 0.956 0.000 0.000 0.036 0.008
#> GSM260909     1  0.1597      0.865 0.940 0.000 0.000 0.048 0.012
#> GSM260887     3  0.0566      0.845 0.000 0.000 0.984 0.004 0.012
#> GSM260890     3  0.1216      0.836 0.000 0.000 0.960 0.020 0.020
#> GSM260892     3  0.3391      0.680 0.000 0.000 0.800 0.188 0.012
#> GSM260895     3  0.3883      0.645 0.000 0.000 0.780 0.184 0.036
#> GSM260898     3  0.0798      0.845 0.000 0.000 0.976 0.008 0.016
#> GSM260901     3  0.1117      0.841 0.000 0.000 0.964 0.016 0.020
#> GSM260904     3  0.0703      0.842 0.000 0.000 0.976 0.000 0.024
#> GSM260907     3  0.0880      0.837 0.000 0.000 0.968 0.000 0.032
#> GSM260910     3  0.2511      0.780 0.000 0.000 0.892 0.080 0.028
#> GSM260918     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> GSM260921     2  0.0162      0.982 0.000 0.996 0.000 0.004 0.000
#> GSM260924     2  0.0324      0.981 0.000 0.992 0.000 0.004 0.004
#> GSM260929     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> GSM260932     2  0.2359      0.928 0.000 0.904 0.000 0.036 0.060
#> GSM260935     2  0.2067      0.939 0.000 0.920 0.000 0.032 0.048
#> GSM260938     2  0.0162      0.982 0.000 0.996 0.000 0.004 0.000
#> GSM260941     2  0.0162      0.982 0.000 0.996 0.000 0.004 0.000
#> GSM260944     2  0.0162      0.982 0.000 0.996 0.000 0.004 0.000
#> GSM260947     2  0.0162      0.982 0.000 0.996 0.000 0.004 0.000
#> GSM260952     2  0.0162      0.982 0.000 0.996 0.000 0.004 0.000
#> GSM260914     1  0.1410      0.861 0.940 0.000 0.000 0.060 0.000
#> GSM260916     4  0.4273      0.980 0.448 0.000 0.000 0.552 0.000
#> GSM260919     1  0.0880      0.884 0.968 0.000 0.000 0.032 0.000
#> GSM260922     4  0.4278      0.980 0.452 0.000 0.000 0.548 0.000
#> GSM260925     1  0.1478      0.858 0.936 0.000 0.000 0.064 0.000
#> GSM260927     1  0.0162      0.893 0.996 0.000 0.000 0.000 0.004
#> GSM260930     1  0.0771      0.891 0.976 0.000 0.000 0.020 0.004
#> GSM260933     1  0.1697      0.871 0.932 0.000 0.000 0.060 0.008
#> GSM260936     1  0.1701      0.875 0.936 0.000 0.000 0.048 0.016
#> GSM260939     1  0.3812      0.688 0.812 0.000 0.000 0.092 0.096
#> GSM260942     1  0.2984      0.786 0.860 0.000 0.000 0.108 0.032
#> GSM260945     1  0.1740      0.871 0.932 0.000 0.000 0.056 0.012
#> GSM260948     1  0.1043      0.885 0.960 0.000 0.000 0.040 0.000
#> GSM260950     1  0.0609      0.891 0.980 0.000 0.000 0.020 0.000
#> GSM260915     3  0.0566      0.845 0.000 0.000 0.984 0.004 0.012
#> GSM260917     3  0.0510      0.846 0.000 0.000 0.984 0.000 0.016
#> GSM260920     3  0.0404      0.847 0.000 0.000 0.988 0.000 0.012
#> GSM260923     3  0.1444      0.827 0.000 0.000 0.948 0.040 0.012
#> GSM260926     3  0.0162      0.847 0.000 0.000 0.996 0.000 0.004
#> GSM260928     3  0.4428      0.650 0.088 0.000 0.800 0.044 0.068
#> GSM260931     3  0.4291     -0.491 0.000 0.000 0.536 0.000 0.464
#> GSM260934     3  0.0609      0.845 0.000 0.000 0.980 0.000 0.020
#> GSM260937     5  0.3242      0.808 0.000 0.000 0.216 0.000 0.784
#> GSM260940     5  0.3949      0.816 0.000 0.000 0.332 0.000 0.668
#> GSM260943     5  0.3534      0.838 0.000 0.000 0.256 0.000 0.744
#> GSM260946     3  0.4304     -0.546 0.000 0.000 0.516 0.000 0.484
#> GSM260949     3  0.0000      0.848 0.000 0.000 1.000 0.000 0.000
#> GSM260951     5  0.4278      0.613 0.000 0.000 0.452 0.000 0.548

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5 p6
#> GSM260888     2  0.1267      0.917 0.000 0.940 0.000 0.000 0.000 NA
#> GSM260893     2  0.0937      0.920 0.000 0.960 0.000 0.000 0.000 NA
#> GSM260896     2  0.1007      0.921 0.000 0.956 0.000 0.000 0.000 NA
#> GSM260899     2  0.3563      0.692 0.000 0.664 0.000 0.000 0.000 NA
#> GSM260902     2  0.3050      0.794 0.000 0.764 0.000 0.000 0.000 NA
#> GSM260905     2  0.0458      0.925 0.000 0.984 0.000 0.000 0.000 NA
#> GSM260908     2  0.1204      0.913 0.000 0.944 0.000 0.000 0.000 NA
#> GSM260911     2  0.0937      0.922 0.000 0.960 0.000 0.000 0.000 NA
#> GSM260912     2  0.0363      0.924 0.000 0.988 0.000 0.000 0.000 NA
#> GSM260913     4  0.0622      0.915 0.012 0.000 0.008 0.980 0.000 NA
#> GSM260886     5  0.1610      0.887 0.084 0.000 0.000 0.000 0.916 NA
#> GSM260889     5  0.1387      0.893 0.068 0.000 0.000 0.000 0.932 NA
#> GSM260891     5  0.3568      0.751 0.032 0.000 0.008 0.000 0.788 NA
#> GSM260894     5  0.1405      0.900 0.024 0.000 0.004 0.000 0.948 NA
#> GSM260897     5  0.1858      0.873 0.092 0.000 0.000 0.000 0.904 NA
#> GSM260900     5  0.0508      0.905 0.012 0.000 0.000 0.000 0.984 NA
#> GSM260903     5  0.1321      0.907 0.020 0.000 0.004 0.000 0.952 NA
#> GSM260906     5  0.1562      0.905 0.024 0.000 0.004 0.000 0.940 NA
#> GSM260909     5  0.2231      0.880 0.028 0.000 0.004 0.000 0.900 NA
#> GSM260887     4  0.0146      0.914 0.000 0.000 0.000 0.996 0.000 NA
#> GSM260890     4  0.0767      0.910 0.004 0.000 0.008 0.976 0.000 NA
#> GSM260892     4  0.2883      0.818 0.036 0.000 0.020 0.868 0.000 NA
#> GSM260895     4  0.3844      0.734 0.028 0.000 0.028 0.800 0.008 NA
#> GSM260898     4  0.1088      0.912 0.000 0.000 0.024 0.960 0.000 NA
#> GSM260901     4  0.1492      0.900 0.000 0.000 0.024 0.940 0.000 NA
#> GSM260904     4  0.0632      0.913 0.000 0.000 0.024 0.976 0.000 NA
#> GSM260907     4  0.0937      0.902 0.000 0.000 0.040 0.960 0.000 NA
#> GSM260910     4  0.1562      0.884 0.004 0.000 0.024 0.940 0.000 NA
#> GSM260918     2  0.0363      0.924 0.000 0.988 0.000 0.000 0.000 NA
#> GSM260921     2  0.0713      0.924 0.000 0.972 0.000 0.000 0.000 NA
#> GSM260924     2  0.1789      0.908 0.032 0.924 0.000 0.000 0.000 NA
#> GSM260929     2  0.0363      0.925 0.000 0.988 0.000 0.000 0.000 NA
#> GSM260932     2  0.3890      0.604 0.000 0.596 0.004 0.000 0.000 NA
#> GSM260935     2  0.2996      0.801 0.000 0.772 0.000 0.000 0.000 NA
#> GSM260938     2  0.0777      0.923 0.000 0.972 0.004 0.000 0.000 NA
#> GSM260941     2  0.0405      0.924 0.000 0.988 0.004 0.000 0.000 NA
#> GSM260944     2  0.0790      0.921 0.000 0.968 0.000 0.000 0.000 NA
#> GSM260947     2  0.0508      0.924 0.000 0.984 0.004 0.000 0.000 NA
#> GSM260952     2  0.0603      0.923 0.000 0.980 0.004 0.000 0.000 NA
#> GSM260914     5  0.2053      0.868 0.108 0.000 0.000 0.000 0.888 NA
#> GSM260916     1  0.3050      0.936 0.764 0.000 0.000 0.000 0.236 NA
#> GSM260919     5  0.1858      0.881 0.092 0.000 0.000 0.000 0.904 NA
#> GSM260922     1  0.2762      0.935 0.804 0.000 0.000 0.000 0.196 NA
#> GSM260925     5  0.1910      0.871 0.108 0.000 0.000 0.000 0.892 NA
#> GSM260927     5  0.2074      0.881 0.048 0.000 0.004 0.000 0.912 NA
#> GSM260930     5  0.0260      0.906 0.008 0.000 0.000 0.000 0.992 NA
#> GSM260933     5  0.0865      0.904 0.036 0.000 0.000 0.000 0.964 NA
#> GSM260936     5  0.1269      0.905 0.012 0.000 0.012 0.000 0.956 NA
#> GSM260939     5  0.2341      0.875 0.056 0.000 0.032 0.000 0.900 NA
#> GSM260942     5  0.2002      0.889 0.040 0.000 0.012 0.000 0.920 NA
#> GSM260945     5  0.1434      0.900 0.028 0.000 0.012 0.000 0.948 NA
#> GSM260948     5  0.3134      0.730 0.208 0.000 0.004 0.000 0.784 NA
#> GSM260950     5  0.0937      0.902 0.040 0.000 0.000 0.000 0.960 NA
#> GSM260915     4  0.0260      0.915 0.000 0.000 0.000 0.992 0.000 NA
#> GSM260917     4  0.0777      0.912 0.000 0.000 0.024 0.972 0.000 NA
#> GSM260920     4  0.1313      0.906 0.028 0.000 0.016 0.952 0.000 NA
#> GSM260923     4  0.0520      0.912 0.000 0.000 0.008 0.984 0.000 NA
#> GSM260926     4  0.0405      0.916 0.000 0.000 0.004 0.988 0.000 NA
#> GSM260928     4  0.6027      0.343 0.056 0.000 0.012 0.616 0.208 NA
#> GSM260931     3  0.3828      0.583 0.000 0.000 0.560 0.440 0.000 NA
#> GSM260934     4  0.1196      0.901 0.000 0.000 0.040 0.952 0.000 NA
#> GSM260937     3  0.1501      0.610 0.000 0.000 0.924 0.076 0.000 NA
#> GSM260940     3  0.3151      0.744 0.000 0.000 0.748 0.252 0.000 NA
#> GSM260943     3  0.1863      0.646 0.000 0.000 0.896 0.104 0.000 NA
#> GSM260946     3  0.3862      0.500 0.000 0.000 0.524 0.476 0.000 NA
#> GSM260949     4  0.0436      0.916 0.004 0.000 0.004 0.988 0.000 NA
#> GSM260951     3  0.3426      0.744 0.004 0.000 0.720 0.276 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-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) cell.type(p) k
#> CV:NMF 67           0.9388     2.75e-14 2
#> CV:NMF 67           0.9269     9.68e-27 3
#> CV:NMF 67           0.9269     9.68e-27 4
#> CV:NMF 65           0.2215     4.59e-23 5
#> CV:NMF 66           0.0983     1.72e-23 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 21168 rows and 67 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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 1.000           0.982       0.984         0.4281 0.575   0.575
#> 3 3 1.000           0.962       0.986         0.5762 0.750   0.566
#> 4 4 0.943           0.924       0.962         0.0611 0.951   0.850
#> 5 5 0.961           0.823       0.921         0.0413 0.980   0.926
#> 6 6 0.888           0.909       0.910         0.0551 0.929   0.730

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM260888     2   0.000      1.000 0.000 1.000
#> GSM260893     2   0.000      1.000 0.000 1.000
#> GSM260896     2   0.000      1.000 0.000 1.000
#> GSM260899     2   0.000      1.000 0.000 1.000
#> GSM260902     2   0.000      1.000 0.000 1.000
#> GSM260905     2   0.000      1.000 0.000 1.000
#> GSM260908     2   0.000      1.000 0.000 1.000
#> GSM260911     2   0.000      1.000 0.000 1.000
#> GSM260912     2   0.000      1.000 0.000 1.000
#> GSM260913     1   0.278      0.973 0.952 0.048
#> GSM260886     1   0.000      0.976 1.000 0.000
#> GSM260889     1   0.000      0.976 1.000 0.000
#> GSM260891     1   0.000      0.976 1.000 0.000
#> GSM260894     1   0.000      0.976 1.000 0.000
#> GSM260897     1   0.000      0.976 1.000 0.000
#> GSM260900     1   0.000      0.976 1.000 0.000
#> GSM260903     1   0.000      0.976 1.000 0.000
#> GSM260906     1   0.000      0.976 1.000 0.000
#> GSM260909     1   0.000      0.976 1.000 0.000
#> GSM260887     1   0.278      0.973 0.952 0.048
#> GSM260890     1   0.278      0.973 0.952 0.048
#> GSM260892     1   0.278      0.973 0.952 0.048
#> GSM260895     1   0.000      0.976 1.000 0.000
#> GSM260898     1   0.278      0.973 0.952 0.048
#> GSM260901     1   0.278      0.973 0.952 0.048
#> GSM260904     1   0.278      0.973 0.952 0.048
#> GSM260907     1   0.278      0.973 0.952 0.048
#> GSM260910     1   0.278      0.973 0.952 0.048
#> GSM260918     2   0.000      1.000 0.000 1.000
#> GSM260921     2   0.000      1.000 0.000 1.000
#> GSM260924     2   0.000      1.000 0.000 1.000
#> GSM260929     2   0.000      1.000 0.000 1.000
#> GSM260932     2   0.000      1.000 0.000 1.000
#> GSM260935     2   0.000      1.000 0.000 1.000
#> GSM260938     2   0.000      1.000 0.000 1.000
#> GSM260941     2   0.000      1.000 0.000 1.000
#> GSM260944     2   0.000      1.000 0.000 1.000
#> GSM260947     2   0.000      1.000 0.000 1.000
#> GSM260952     2   0.000      1.000 0.000 1.000
#> GSM260914     1   0.000      0.976 1.000 0.000
#> GSM260916     1   0.000      0.976 1.000 0.000
#> GSM260919     1   0.000      0.976 1.000 0.000
#> GSM260922     1   0.000      0.976 1.000 0.000
#> GSM260925     1   0.000      0.976 1.000 0.000
#> GSM260927     1   0.000      0.976 1.000 0.000
#> GSM260930     1   0.000      0.976 1.000 0.000
#> GSM260933     1   0.000      0.976 1.000 0.000
#> GSM260936     1   0.000      0.976 1.000 0.000
#> GSM260939     1   0.000      0.976 1.000 0.000
#> GSM260942     1   0.000      0.976 1.000 0.000
#> GSM260945     1   0.000      0.976 1.000 0.000
#> GSM260948     1   0.000      0.976 1.000 0.000
#> GSM260950     1   0.000      0.976 1.000 0.000
#> GSM260915     1   0.278      0.973 0.952 0.048
#> GSM260917     1   0.278      0.973 0.952 0.048
#> GSM260920     1   0.278      0.973 0.952 0.048
#> GSM260923     1   0.278      0.973 0.952 0.048
#> GSM260926     1   0.278      0.973 0.952 0.048
#> GSM260928     1   0.000      0.976 1.000 0.000
#> GSM260931     1   0.278      0.973 0.952 0.048
#> GSM260934     1   0.278      0.973 0.952 0.048
#> GSM260937     1   0.278      0.973 0.952 0.048
#> GSM260940     1   0.278      0.973 0.952 0.048
#> GSM260943     1   0.278      0.973 0.952 0.048
#> GSM260946     1   0.278      0.973 0.952 0.048
#> GSM260949     1   0.278      0.973 0.952 0.048
#> GSM260951     1   0.278      0.973 0.952 0.048

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM260888     2   0.000      1.000 0.000  1 0.000
#> GSM260893     2   0.000      1.000 0.000  1 0.000
#> GSM260896     2   0.000      1.000 0.000  1 0.000
#> GSM260899     2   0.000      1.000 0.000  1 0.000
#> GSM260902     2   0.000      1.000 0.000  1 0.000
#> GSM260905     2   0.000      1.000 0.000  1 0.000
#> GSM260908     2   0.000      1.000 0.000  1 0.000
#> GSM260911     2   0.000      1.000 0.000  1 0.000
#> GSM260912     2   0.000      1.000 0.000  1 0.000
#> GSM260913     3   0.000      0.958 0.000  0 1.000
#> GSM260886     1   0.000      1.000 1.000  0 0.000
#> GSM260889     1   0.000      1.000 1.000  0 0.000
#> GSM260891     1   0.000      1.000 1.000  0 0.000
#> GSM260894     1   0.000      1.000 1.000  0 0.000
#> GSM260897     1   0.000      1.000 1.000  0 0.000
#> GSM260900     1   0.000      1.000 1.000  0 0.000
#> GSM260903     1   0.000      1.000 1.000  0 0.000
#> GSM260906     1   0.000      1.000 1.000  0 0.000
#> GSM260909     1   0.000      1.000 1.000  0 0.000
#> GSM260887     3   0.000      0.958 0.000  0 1.000
#> GSM260890     3   0.000      0.958 0.000  0 1.000
#> GSM260892     3   0.000      0.958 0.000  0 1.000
#> GSM260895     3   0.627      0.209 0.452  0 0.548
#> GSM260898     3   0.000      0.958 0.000  0 1.000
#> GSM260901     3   0.000      0.958 0.000  0 1.000
#> GSM260904     3   0.000      0.958 0.000  0 1.000
#> GSM260907     3   0.000      0.958 0.000  0 1.000
#> GSM260910     3   0.000      0.958 0.000  0 1.000
#> GSM260918     2   0.000      1.000 0.000  1 0.000
#> GSM260921     2   0.000      1.000 0.000  1 0.000
#> GSM260924     2   0.000      1.000 0.000  1 0.000
#> GSM260929     2   0.000      1.000 0.000  1 0.000
#> GSM260932     2   0.000      1.000 0.000  1 0.000
#> GSM260935     2   0.000      1.000 0.000  1 0.000
#> GSM260938     2   0.000      1.000 0.000  1 0.000
#> GSM260941     2   0.000      1.000 0.000  1 0.000
#> GSM260944     2   0.000      1.000 0.000  1 0.000
#> GSM260947     2   0.000      1.000 0.000  1 0.000
#> GSM260952     2   0.000      1.000 0.000  1 0.000
#> GSM260914     1   0.000      1.000 1.000  0 0.000
#> GSM260916     1   0.000      1.000 1.000  0 0.000
#> GSM260919     1   0.000      1.000 1.000  0 0.000
#> GSM260922     1   0.000      1.000 1.000  0 0.000
#> GSM260925     1   0.000      1.000 1.000  0 0.000
#> GSM260927     1   0.000      1.000 1.000  0 0.000
#> GSM260930     1   0.000      1.000 1.000  0 0.000
#> GSM260933     1   0.000      1.000 1.000  0 0.000
#> GSM260936     1   0.000      1.000 1.000  0 0.000
#> GSM260939     1   0.000      1.000 1.000  0 0.000
#> GSM260942     1   0.000      1.000 1.000  0 0.000
#> GSM260945     1   0.000      1.000 1.000  0 0.000
#> GSM260948     1   0.000      1.000 1.000  0 0.000
#> GSM260950     1   0.000      1.000 1.000  0 0.000
#> GSM260915     3   0.000      0.958 0.000  0 1.000
#> GSM260917     3   0.000      0.958 0.000  0 1.000
#> GSM260920     3   0.000      0.958 0.000  0 1.000
#> GSM260923     3   0.000      0.958 0.000  0 1.000
#> GSM260926     3   0.000      0.958 0.000  0 1.000
#> GSM260928     3   0.629      0.158 0.468  0 0.532
#> GSM260931     3   0.000      0.958 0.000  0 1.000
#> GSM260934     3   0.000      0.958 0.000  0 1.000
#> GSM260937     3   0.000      0.958 0.000  0 1.000
#> GSM260940     3   0.000      0.958 0.000  0 1.000
#> GSM260943     3   0.000      0.958 0.000  0 1.000
#> GSM260946     3   0.000      0.958 0.000  0 1.000
#> GSM260949     3   0.000      0.958 0.000  0 1.000
#> GSM260951     3   0.000      0.958 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM260888     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260893     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260896     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260899     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260902     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260905     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260908     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260911     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260912     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260913     3   0.000      0.860 0.000  0 1.000 0.000
#> GSM260886     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260889     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260891     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260894     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260897     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260900     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260903     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260906     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260909     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260887     3   0.000      0.860 0.000  0 1.000 0.000
#> GSM260890     3   0.000      0.860 0.000  0 1.000 0.000
#> GSM260892     3   0.000      0.860 0.000  0 1.000 0.000
#> GSM260895     3   0.497      0.237 0.452  0 0.548 0.000
#> GSM260898     3   0.253      0.799 0.000  0 0.888 0.112
#> GSM260901     3   0.253      0.799 0.000  0 0.888 0.112
#> GSM260904     3   0.253      0.799 0.000  0 0.888 0.112
#> GSM260907     3   0.253      0.799 0.000  0 0.888 0.112
#> GSM260910     3   0.000      0.860 0.000  0 1.000 0.000
#> GSM260918     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260921     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260924     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260929     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260932     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260935     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260938     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260941     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260944     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260947     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260952     2   0.000      1.000 0.000  1 0.000 0.000
#> GSM260914     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260916     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260919     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260922     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260925     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260927     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260930     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260933     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260936     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260939     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260942     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260945     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260948     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260950     1   0.000      1.000 1.000  0 0.000 0.000
#> GSM260915     3   0.000      0.860 0.000  0 1.000 0.000
#> GSM260917     3   0.139      0.827 0.000  0 0.952 0.048
#> GSM260920     3   0.000      0.860 0.000  0 1.000 0.000
#> GSM260923     3   0.000      0.860 0.000  0 1.000 0.000
#> GSM260926     3   0.000      0.860 0.000  0 1.000 0.000
#> GSM260928     3   0.499      0.193 0.468  0 0.532 0.000
#> GSM260931     4   0.361      0.880 0.000  0 0.200 0.800
#> GSM260934     3   0.253      0.799 0.000  0 0.888 0.112
#> GSM260937     4   0.000      0.777 0.000  0 0.000 1.000
#> GSM260940     4   0.401      0.851 0.000  0 0.244 0.756
#> GSM260943     4   0.344      0.882 0.000  0 0.184 0.816
#> GSM260946     4   0.430      0.798 0.000  0 0.284 0.716
#> GSM260949     3   0.000      0.860 0.000  0 1.000 0.000
#> GSM260951     4   0.228      0.849 0.000  0 0.096 0.904

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1   p2    p3    p4    p5
#> GSM260888     2  0.0000      0.961 0.000 1.00 0.000 0.000 0.000
#> GSM260893     2  0.0000      0.961 0.000 1.00 0.000 0.000 0.000
#> GSM260896     2  0.0000      0.961 0.000 1.00 0.000 0.000 0.000
#> GSM260899     2  0.1732      0.961 0.000 0.92 0.000 0.080 0.000
#> GSM260902     2  0.1732      0.961 0.000 0.92 0.000 0.080 0.000
#> GSM260905     2  0.1732      0.961 0.000 0.92 0.000 0.080 0.000
#> GSM260908     2  0.1732      0.961 0.000 0.92 0.000 0.080 0.000
#> GSM260911     2  0.0000      0.961 0.000 1.00 0.000 0.000 0.000
#> GSM260912     2  0.0000      0.961 0.000 1.00 0.000 0.000 0.000
#> GSM260913     3  0.1478      0.725 0.000 0.00 0.936 0.064 0.000
#> GSM260886     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260889     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260891     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260894     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260897     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260900     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260903     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260906     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260909     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260887     3  0.0794      0.736 0.000 0.00 0.972 0.028 0.000
#> GSM260890     3  0.0404      0.744 0.000 0.00 0.988 0.012 0.000
#> GSM260892     3  0.1478      0.725 0.000 0.00 0.936 0.064 0.000
#> GSM260895     4  0.3362      0.608 0.076 0.00 0.080 0.844 0.000
#> GSM260898     3  0.5933     -0.261 0.000 0.00 0.448 0.448 0.104
#> GSM260901     3  0.5933     -0.261 0.000 0.00 0.448 0.448 0.104
#> GSM260904     3  0.5933     -0.261 0.000 0.00 0.448 0.448 0.104
#> GSM260907     3  0.5933     -0.261 0.000 0.00 0.448 0.448 0.104
#> GSM260910     3  0.0162      0.744 0.000 0.00 0.996 0.004 0.000
#> GSM260918     2  0.0000      0.961 0.000 1.00 0.000 0.000 0.000
#> GSM260921     2  0.0000      0.961 0.000 1.00 0.000 0.000 0.000
#> GSM260924     2  0.0000      0.961 0.000 1.00 0.000 0.000 0.000
#> GSM260929     2  0.0000      0.961 0.000 1.00 0.000 0.000 0.000
#> GSM260932     2  0.1732      0.961 0.000 0.92 0.000 0.080 0.000
#> GSM260935     2  0.1732      0.961 0.000 0.92 0.000 0.080 0.000
#> GSM260938     2  0.1732      0.961 0.000 0.92 0.000 0.080 0.000
#> GSM260941     2  0.1732      0.961 0.000 0.92 0.000 0.080 0.000
#> GSM260944     2  0.1732      0.961 0.000 0.92 0.000 0.080 0.000
#> GSM260947     2  0.1732      0.961 0.000 0.92 0.000 0.080 0.000
#> GSM260952     2  0.0000      0.961 0.000 1.00 0.000 0.000 0.000
#> GSM260914     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260916     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260919     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260922     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260925     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260927     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260930     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260933     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260936     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260939     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260942     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260945     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260948     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260950     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000
#> GSM260915     3  0.0510      0.742 0.000 0.00 0.984 0.016 0.000
#> GSM260917     3  0.1893      0.711 0.000 0.00 0.928 0.024 0.048
#> GSM260920     3  0.1478      0.725 0.000 0.00 0.936 0.064 0.000
#> GSM260923     3  0.0404      0.743 0.000 0.00 0.988 0.012 0.000
#> GSM260926     3  0.0404      0.744 0.000 0.00 0.988 0.012 0.000
#> GSM260928     4  0.3346      0.605 0.092 0.00 0.064 0.844 0.000
#> GSM260931     5  0.3462      0.852 0.000 0.00 0.196 0.012 0.792
#> GSM260934     4  0.5933     -0.157 0.000 0.00 0.448 0.448 0.104
#> GSM260937     5  0.0000      0.687 0.000 0.00 0.000 0.000 1.000
#> GSM260940     5  0.4270      0.832 0.000 0.00 0.204 0.048 0.748
#> GSM260943     5  0.3318      0.855 0.000 0.00 0.180 0.012 0.808
#> GSM260946     5  0.4883      0.791 0.000 0.00 0.200 0.092 0.708
#> GSM260949     3  0.1410      0.727 0.000 0.00 0.940 0.060 0.000
#> GSM260951     5  0.1965      0.801 0.000 0.00 0.096 0.000 0.904

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM260888     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260893     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260896     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260899     6  0.2260      0.932 0.000 0.140 0.000 0.000 0.000 0.860
#> GSM260902     6  0.2260      0.932 0.000 0.140 0.000 0.000 0.000 0.860
#> GSM260905     6  0.3727      0.634 0.000 0.388 0.000 0.000 0.000 0.612
#> GSM260908     6  0.3727      0.634 0.000 0.388 0.000 0.000 0.000 0.612
#> GSM260911     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260912     2  0.0458      0.986 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM260913     4  0.0146      0.914 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM260886     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260891     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260894     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260897     1  0.0260      0.996 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM260900     1  0.0260      0.996 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM260903     1  0.0260      0.996 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM260906     1  0.0260      0.996 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM260909     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260887     4  0.1765      0.915 0.000 0.000 0.000 0.904 0.096 0.000
#> GSM260890     4  0.1501      0.931 0.000 0.000 0.000 0.924 0.076 0.000
#> GSM260892     4  0.0146      0.914 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM260895     5  0.2245      0.418 0.040 0.000 0.000 0.036 0.908 0.016
#> GSM260898     5  0.5689      0.765 0.000 0.000 0.196 0.288 0.516 0.000
#> GSM260901     5  0.5689      0.765 0.000 0.000 0.196 0.288 0.516 0.000
#> GSM260904     5  0.5689      0.765 0.000 0.000 0.196 0.288 0.516 0.000
#> GSM260907     5  0.5689      0.765 0.000 0.000 0.196 0.288 0.516 0.000
#> GSM260910     4  0.1327      0.933 0.000 0.000 0.000 0.936 0.064 0.000
#> GSM260918     2  0.0458      0.986 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM260921     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260924     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260929     2  0.0458      0.986 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM260932     6  0.2260      0.932 0.000 0.140 0.000 0.000 0.000 0.860
#> GSM260935     6  0.2260      0.932 0.000 0.140 0.000 0.000 0.000 0.860
#> GSM260938     6  0.2260      0.932 0.000 0.140 0.000 0.000 0.000 0.860
#> GSM260941     6  0.2260      0.932 0.000 0.140 0.000 0.000 0.000 0.860
#> GSM260944     6  0.2260      0.932 0.000 0.140 0.000 0.000 0.000 0.860
#> GSM260947     6  0.2260      0.932 0.000 0.140 0.000 0.000 0.000 0.860
#> GSM260952     2  0.0458      0.986 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM260914     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260916     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260919     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260922     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260925     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260927     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260930     1  0.0260      0.996 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM260933     1  0.0260      0.996 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM260936     1  0.0260      0.996 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM260939     1  0.0260      0.996 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM260942     1  0.0260      0.996 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM260945     1  0.0260      0.996 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM260948     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260950     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260915     4  0.1556      0.928 0.000 0.000 0.000 0.920 0.080 0.000
#> GSM260917     4  0.3472      0.801 0.000 0.000 0.100 0.808 0.092 0.000
#> GSM260920     4  0.0260      0.913 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM260923     4  0.1204      0.932 0.000 0.000 0.000 0.944 0.056 0.000
#> GSM260926     4  0.1501      0.931 0.000 0.000 0.000 0.924 0.076 0.000
#> GSM260928     5  0.1801      0.418 0.056 0.000 0.000 0.004 0.924 0.016
#> GSM260931     3  0.1910      0.835 0.000 0.000 0.892 0.108 0.000 0.000
#> GSM260934     5  0.5689      0.765 0.000 0.000 0.196 0.288 0.516 0.000
#> GSM260937     3  0.2979      0.698 0.000 0.000 0.840 0.000 0.044 0.116
#> GSM260940     3  0.2843      0.810 0.000 0.000 0.848 0.116 0.036 0.000
#> GSM260943     3  0.1714      0.838 0.000 0.000 0.908 0.092 0.000 0.000
#> GSM260946     3  0.3558      0.754 0.000 0.000 0.800 0.112 0.088 0.000
#> GSM260949     4  0.0146      0.916 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM260951     3  0.3424      0.775 0.000 0.000 0.840 0.052 0.044 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-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) cell.type(p) k
#> MAD:hclust 67            0.939     2.75e-14 2
#> MAD:hclust 65            0.924     7.14e-26 3
#> MAD:hclust 65            0.120     2.14e-24 4
#> MAD:hclust 62            0.349     7.86e-22 5
#> MAD:hclust 65            0.171     6.54e-22 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 21168 rows and 67 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.552           0.784       0.858         0.4468 0.575   0.575
#> 3 3 0.646           0.932       0.878         0.4280 0.750   0.566
#> 4 4 0.817           0.746       0.821         0.1332 0.979   0.936
#> 5 5 0.805           0.858       0.706         0.0666 0.878   0.612
#> 6 6 0.768           0.720       0.772         0.0349 0.961   0.810

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
#> GSM260888     2  0.9732      0.991 0.404 0.596
#> GSM260893     2  0.9732      0.991 0.404 0.596
#> GSM260896     2  0.9732      0.991 0.404 0.596
#> GSM260899     2  0.9661      0.991 0.392 0.608
#> GSM260902     2  0.9661      0.991 0.392 0.608
#> GSM260905     2  0.9661      0.991 0.392 0.608
#> GSM260908     2  0.9661      0.991 0.392 0.608
#> GSM260911     2  0.9732      0.991 0.404 0.596
#> GSM260912     2  0.9732      0.991 0.404 0.596
#> GSM260913     1  0.0000      0.627 1.000 0.000
#> GSM260886     1  0.9754      0.759 0.592 0.408
#> GSM260889     1  0.9754      0.759 0.592 0.408
#> GSM260891     1  0.9754      0.759 0.592 0.408
#> GSM260894     1  0.9754      0.759 0.592 0.408
#> GSM260897     1  0.9815      0.758 0.580 0.420
#> GSM260900     1  0.9815      0.758 0.580 0.420
#> GSM260903     1  0.9815      0.758 0.580 0.420
#> GSM260906     1  0.9815      0.758 0.580 0.420
#> GSM260909     1  0.9754      0.759 0.592 0.408
#> GSM260887     1  0.0000      0.627 1.000 0.000
#> GSM260890     1  0.0000      0.627 1.000 0.000
#> GSM260892     1  0.0000      0.627 1.000 0.000
#> GSM260895     1  0.9661      0.756 0.608 0.392
#> GSM260898     1  0.0938      0.625 0.988 0.012
#> GSM260901     1  0.0938      0.625 0.988 0.012
#> GSM260904     1  0.0938      0.625 0.988 0.012
#> GSM260907     1  0.0938      0.625 0.988 0.012
#> GSM260910     1  0.0000      0.627 1.000 0.000
#> GSM260918     2  0.9732      0.991 0.404 0.596
#> GSM260921     2  0.9732      0.991 0.404 0.596
#> GSM260924     2  0.9732      0.991 0.404 0.596
#> GSM260929     2  0.9732      0.991 0.404 0.596
#> GSM260932     2  0.9661      0.991 0.392 0.608
#> GSM260935     2  0.9661      0.991 0.392 0.608
#> GSM260938     2  0.9661      0.991 0.392 0.608
#> GSM260941     2  0.9661      0.991 0.392 0.608
#> GSM260944     2  0.9661      0.991 0.392 0.608
#> GSM260947     2  0.9661      0.991 0.392 0.608
#> GSM260952     2  0.9732      0.991 0.404 0.596
#> GSM260914     1  0.9754      0.759 0.592 0.408
#> GSM260916     1  0.9754      0.759 0.592 0.408
#> GSM260919     1  0.9754      0.759 0.592 0.408
#> GSM260922     1  0.9754      0.759 0.592 0.408
#> GSM260925     1  0.9754      0.759 0.592 0.408
#> GSM260927     1  0.9754      0.759 0.592 0.408
#> GSM260930     1  0.9815      0.758 0.580 0.420
#> GSM260933     1  0.9815      0.758 0.580 0.420
#> GSM260936     1  0.9815      0.758 0.580 0.420
#> GSM260939     1  0.9815      0.758 0.580 0.420
#> GSM260942     1  0.9815      0.758 0.580 0.420
#> GSM260945     1  0.9815      0.758 0.580 0.420
#> GSM260948     1  0.9754      0.759 0.592 0.408
#> GSM260950     1  0.9754      0.759 0.592 0.408
#> GSM260915     1  0.0000      0.627 1.000 0.000
#> GSM260917     1  0.0000      0.627 1.000 0.000
#> GSM260920     1  0.0000      0.627 1.000 0.000
#> GSM260923     1  0.0000      0.627 1.000 0.000
#> GSM260926     1  0.0000      0.627 1.000 0.000
#> GSM260928     1  0.9661      0.756 0.608 0.392
#> GSM260931     1  0.0938      0.625 0.988 0.012
#> GSM260934     1  0.0938      0.625 0.988 0.012
#> GSM260937     1  0.0938      0.625 0.988 0.012
#> GSM260940     1  0.0938      0.625 0.988 0.012
#> GSM260943     1  0.0938      0.625 0.988 0.012
#> GSM260946     1  0.0938      0.625 0.988 0.012
#> GSM260949     1  0.0000      0.627 1.000 0.000
#> GSM260951     1  0.0000      0.627 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
#> GSM260888     2  0.0237      0.953 0.004 0.996 0.000
#> GSM260893     2  0.0237      0.953 0.004 0.996 0.000
#> GSM260896     2  0.0237      0.953 0.004 0.996 0.000
#> GSM260899     2  0.3784      0.945 0.004 0.864 0.132
#> GSM260902     2  0.3784      0.945 0.004 0.864 0.132
#> GSM260905     2  0.3349      0.951 0.004 0.888 0.108
#> GSM260908     2  0.3425      0.951 0.004 0.884 0.112
#> GSM260911     2  0.0237      0.953 0.004 0.996 0.000
#> GSM260912     2  0.0237      0.953 0.004 0.996 0.000
#> GSM260913     3  0.6775      0.966 0.164 0.096 0.740
#> GSM260886     1  0.0000      0.928 1.000 0.000 0.000
#> GSM260889     1  0.0000      0.928 1.000 0.000 0.000
#> GSM260891     1  0.0000      0.928 1.000 0.000 0.000
#> GSM260894     1  0.0000      0.928 1.000 0.000 0.000
#> GSM260897     1  0.3412      0.913 0.876 0.000 0.124
#> GSM260900     1  0.3412      0.913 0.876 0.000 0.124
#> GSM260903     1  0.3412      0.913 0.876 0.000 0.124
#> GSM260906     1  0.3412      0.913 0.876 0.000 0.124
#> GSM260909     1  0.0000      0.928 1.000 0.000 0.000
#> GSM260887     3  0.6775      0.966 0.164 0.096 0.740
#> GSM260890     3  0.6775      0.966 0.164 0.096 0.740
#> GSM260892     3  0.6775      0.966 0.164 0.096 0.740
#> GSM260895     3  0.5404      0.851 0.256 0.004 0.740
#> GSM260898     3  0.5931      0.964 0.124 0.084 0.792
#> GSM260901     3  0.5931      0.964 0.124 0.084 0.792
#> GSM260904     3  0.5931      0.964 0.124 0.084 0.792
#> GSM260907     3  0.5931      0.964 0.124 0.084 0.792
#> GSM260910     3  0.6775      0.966 0.164 0.096 0.740
#> GSM260918     2  0.0237      0.953 0.004 0.996 0.000
#> GSM260921     2  0.0237      0.953 0.004 0.996 0.000
#> GSM260924     2  0.0237      0.953 0.004 0.996 0.000
#> GSM260929     2  0.0237      0.953 0.004 0.996 0.000
#> GSM260932     2  0.3784      0.945 0.004 0.864 0.132
#> GSM260935     2  0.3784      0.945 0.004 0.864 0.132
#> GSM260938     2  0.3425      0.951 0.004 0.884 0.112
#> GSM260941     2  0.3425      0.951 0.004 0.884 0.112
#> GSM260944     2  0.3425      0.951 0.004 0.884 0.112
#> GSM260947     2  0.3425      0.951 0.004 0.884 0.112
#> GSM260952     2  0.0237      0.953 0.004 0.996 0.000
#> GSM260914     1  0.0000      0.928 1.000 0.000 0.000
#> GSM260916     1  0.0000      0.928 1.000 0.000 0.000
#> GSM260919     1  0.0000      0.928 1.000 0.000 0.000
#> GSM260922     1  0.0000      0.928 1.000 0.000 0.000
#> GSM260925     1  0.0000      0.928 1.000 0.000 0.000
#> GSM260927     1  0.0000      0.928 1.000 0.000 0.000
#> GSM260930     1  0.3412      0.913 0.876 0.000 0.124
#> GSM260933     1  0.3412      0.913 0.876 0.000 0.124
#> GSM260936     1  0.3412      0.913 0.876 0.000 0.124
#> GSM260939     1  0.3412      0.913 0.876 0.000 0.124
#> GSM260942     1  0.3412      0.913 0.876 0.000 0.124
#> GSM260945     1  0.3412      0.913 0.876 0.000 0.124
#> GSM260948     1  0.0424      0.928 0.992 0.000 0.008
#> GSM260950     1  0.0424      0.928 0.992 0.000 0.008
#> GSM260915     3  0.6775      0.966 0.164 0.096 0.740
#> GSM260917     3  0.6470      0.967 0.148 0.092 0.760
#> GSM260920     3  0.6775      0.966 0.164 0.096 0.740
#> GSM260923     3  0.6775      0.966 0.164 0.096 0.740
#> GSM260926     3  0.6775      0.966 0.164 0.096 0.740
#> GSM260928     1  0.6247      0.124 0.620 0.004 0.376
#> GSM260931     3  0.5931      0.964 0.124 0.084 0.792
#> GSM260934     3  0.5931      0.964 0.124 0.084 0.792
#> GSM260937     3  0.5931      0.964 0.124 0.084 0.792
#> GSM260940     3  0.5931      0.964 0.124 0.084 0.792
#> GSM260943     3  0.5931      0.964 0.124 0.084 0.792
#> GSM260946     3  0.5931      0.964 0.124 0.084 0.792
#> GSM260949     3  0.6775      0.966 0.164 0.096 0.740
#> GSM260951     3  0.6470      0.967 0.148 0.092 0.760

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM260888     2  0.0188      0.873 0.000 0.996 0.004 0.000
#> GSM260893     2  0.0188      0.873 0.000 0.996 0.004 0.000
#> GSM260896     2  0.0188      0.873 0.000 0.996 0.004 0.000
#> GSM260899     2  0.5203      0.814 0.000 0.636 0.016 0.348
#> GSM260902     2  0.5203      0.814 0.000 0.636 0.016 0.348
#> GSM260905     2  0.4088      0.863 0.000 0.764 0.004 0.232
#> GSM260908     2  0.4328      0.861 0.000 0.748 0.008 0.244
#> GSM260911     2  0.0188      0.873 0.000 0.996 0.004 0.000
#> GSM260912     2  0.0188      0.873 0.000 0.996 0.004 0.000
#> GSM260913     3  0.5228      0.573 0.036 0.000 0.696 0.268
#> GSM260886     1  0.4914      0.803 0.676 0.000 0.012 0.312
#> GSM260889     1  0.4914      0.803 0.676 0.000 0.012 0.312
#> GSM260891     1  0.4914      0.803 0.676 0.000 0.012 0.312
#> GSM260894     1  0.4914      0.803 0.676 0.000 0.012 0.312
#> GSM260897     1  0.0469      0.762 0.988 0.000 0.012 0.000
#> GSM260900     1  0.0469      0.762 0.988 0.000 0.012 0.000
#> GSM260903     1  0.0469      0.762 0.988 0.000 0.012 0.000
#> GSM260906     1  0.0469      0.762 0.988 0.000 0.012 0.000
#> GSM260909     1  0.4914      0.803 0.676 0.000 0.012 0.312
#> GSM260887     3  0.5228      0.573 0.036 0.000 0.696 0.268
#> GSM260890     3  0.5228      0.573 0.036 0.000 0.696 0.268
#> GSM260892     3  0.5228      0.573 0.036 0.000 0.696 0.268
#> GSM260895     4  0.5938      0.229 0.036 0.000 0.476 0.488
#> GSM260898     3  0.1118      0.703 0.036 0.000 0.964 0.000
#> GSM260901     3  0.1118      0.703 0.036 0.000 0.964 0.000
#> GSM260904     3  0.1118      0.703 0.036 0.000 0.964 0.000
#> GSM260907     3  0.1118      0.703 0.036 0.000 0.964 0.000
#> GSM260910     3  0.5228      0.573 0.036 0.000 0.696 0.268
#> GSM260918     2  0.0188      0.873 0.000 0.996 0.004 0.000
#> GSM260921     2  0.0188      0.873 0.000 0.996 0.004 0.000
#> GSM260924     2  0.0469      0.872 0.000 0.988 0.012 0.000
#> GSM260929     2  0.0188      0.873 0.000 0.996 0.004 0.000
#> GSM260932     2  0.5203      0.814 0.000 0.636 0.016 0.348
#> GSM260935     2  0.5203      0.814 0.000 0.636 0.016 0.348
#> GSM260938     2  0.4391      0.860 0.000 0.740 0.008 0.252
#> GSM260941     2  0.4391      0.860 0.000 0.740 0.008 0.252
#> GSM260944     2  0.4391      0.860 0.000 0.740 0.008 0.252
#> GSM260947     2  0.4391      0.860 0.000 0.740 0.008 0.252
#> GSM260952     2  0.0336      0.873 0.000 0.992 0.008 0.000
#> GSM260914     1  0.4914      0.803 0.676 0.000 0.012 0.312
#> GSM260916     1  0.4936      0.801 0.672 0.000 0.012 0.316
#> GSM260919     1  0.5068      0.803 0.676 0.004 0.012 0.308
#> GSM260922     1  0.4936      0.801 0.672 0.000 0.012 0.316
#> GSM260925     1  0.4914      0.803 0.676 0.000 0.012 0.312
#> GSM260927     1  0.4891      0.804 0.680 0.000 0.012 0.308
#> GSM260930     1  0.0469      0.762 0.988 0.000 0.012 0.000
#> GSM260933     1  0.0469      0.762 0.988 0.000 0.012 0.000
#> GSM260936     1  0.0657      0.762 0.984 0.004 0.012 0.000
#> GSM260939     1  0.0657      0.762 0.984 0.004 0.012 0.000
#> GSM260942     1  0.0657      0.762 0.984 0.004 0.012 0.000
#> GSM260945     1  0.0469      0.762 0.988 0.000 0.012 0.000
#> GSM260948     1  0.4948      0.804 0.696 0.004 0.012 0.288
#> GSM260950     1  0.4948      0.804 0.696 0.004 0.012 0.288
#> GSM260915     3  0.5228      0.573 0.036 0.000 0.696 0.268
#> GSM260917     3  0.2813      0.676 0.024 0.000 0.896 0.080
#> GSM260920     3  0.5228      0.573 0.036 0.000 0.696 0.268
#> GSM260923     3  0.5228      0.573 0.036 0.000 0.696 0.268
#> GSM260926     3  0.5228      0.573 0.036 0.000 0.696 0.268
#> GSM260928     4  0.7609      0.520 0.224 0.000 0.312 0.464
#> GSM260931     3  0.2319      0.684 0.036 0.000 0.924 0.040
#> GSM260934     3  0.1118      0.703 0.036 0.000 0.964 0.000
#> GSM260937     3  0.2319      0.684 0.036 0.000 0.924 0.040
#> GSM260940     3  0.2319      0.684 0.036 0.000 0.924 0.040
#> GSM260943     3  0.2319      0.684 0.036 0.000 0.924 0.040
#> GSM260946     3  0.2319      0.684 0.036 0.000 0.924 0.040
#> GSM260949     3  0.5228      0.573 0.036 0.000 0.696 0.268
#> GSM260951     3  0.2021      0.684 0.024 0.000 0.936 0.040

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM260888     2  0.0290      0.821 0.000 0.992 0.000 0.000 0.008
#> GSM260893     2  0.0162      0.821 0.000 0.996 0.000 0.000 0.004
#> GSM260896     2  0.0162      0.821 0.000 0.996 0.000 0.000 0.004
#> GSM260899     2  0.6155      0.779 0.000 0.556 0.004 0.292 0.148
#> GSM260902     2  0.6155      0.779 0.000 0.556 0.004 0.292 0.148
#> GSM260905     2  0.5728      0.808 0.000 0.640 0.004 0.172 0.184
#> GSM260908     2  0.5940      0.803 0.000 0.612 0.004 0.184 0.200
#> GSM260911     2  0.0000      0.821 0.000 1.000 0.000 0.000 0.000
#> GSM260912     2  0.0451      0.821 0.000 0.988 0.000 0.004 0.008
#> GSM260913     4  0.4792      0.848 0.004 0.004 0.424 0.560 0.008
#> GSM260886     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000
#> GSM260891     1  0.1478      0.928 0.936 0.000 0.000 0.064 0.000
#> GSM260894     1  0.1478      0.928 0.936 0.000 0.000 0.064 0.000
#> GSM260897     5  0.4383      0.990 0.424 0.000 0.000 0.004 0.572
#> GSM260900     5  0.4383      0.990 0.424 0.000 0.000 0.004 0.572
#> GSM260903     5  0.4497      0.988 0.424 0.000 0.000 0.008 0.568
#> GSM260906     5  0.4497      0.988 0.424 0.000 0.000 0.008 0.568
#> GSM260909     1  0.1478      0.928 0.936 0.000 0.000 0.064 0.000
#> GSM260887     4  0.4531      0.852 0.004 0.004 0.424 0.568 0.000
#> GSM260890     4  0.4531      0.852 0.004 0.004 0.424 0.568 0.000
#> GSM260892     4  0.4792      0.848 0.004 0.004 0.424 0.560 0.008
#> GSM260895     4  0.6635      0.485 0.160 0.000 0.180 0.604 0.056
#> GSM260898     3  0.2504      0.863 0.004 0.000 0.900 0.064 0.032
#> GSM260901     3  0.2504      0.863 0.004 0.000 0.900 0.064 0.032
#> GSM260904     3  0.2504      0.863 0.004 0.000 0.900 0.064 0.032
#> GSM260907     3  0.2504      0.863 0.004 0.000 0.900 0.064 0.032
#> GSM260910     4  0.4524      0.851 0.004 0.004 0.420 0.572 0.000
#> GSM260918     2  0.0451      0.821 0.000 0.988 0.000 0.004 0.008
#> GSM260921     2  0.0000      0.821 0.000 1.000 0.000 0.000 0.000
#> GSM260924     2  0.1202      0.818 0.000 0.960 0.004 0.004 0.032
#> GSM260929     2  0.0162      0.820 0.000 0.996 0.000 0.000 0.004
#> GSM260932     2  0.6155      0.779 0.000 0.556 0.004 0.292 0.148
#> GSM260935     2  0.6155      0.779 0.000 0.556 0.004 0.292 0.148
#> GSM260938     2  0.6132      0.797 0.000 0.584 0.004 0.200 0.212
#> GSM260941     2  0.6079      0.799 0.000 0.592 0.004 0.196 0.208
#> GSM260944     2  0.6079      0.799 0.000 0.592 0.004 0.196 0.208
#> GSM260947     2  0.6079      0.799 0.000 0.592 0.004 0.196 0.208
#> GSM260952     2  0.0807      0.820 0.000 0.976 0.000 0.012 0.012
#> GSM260914     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000
#> GSM260916     1  0.0290      0.960 0.992 0.000 0.000 0.008 0.000
#> GSM260919     1  0.0162      0.962 0.996 0.000 0.000 0.004 0.000
#> GSM260922     1  0.0290      0.960 0.992 0.000 0.000 0.008 0.000
#> GSM260925     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000
#> GSM260927     1  0.1544      0.925 0.932 0.000 0.000 0.068 0.000
#> GSM260930     5  0.4383      0.990 0.424 0.000 0.000 0.004 0.572
#> GSM260933     5  0.4383      0.990 0.424 0.000 0.000 0.004 0.572
#> GSM260936     5  0.4597      0.987 0.424 0.000 0.000 0.012 0.564
#> GSM260939     5  0.4597      0.987 0.424 0.000 0.000 0.012 0.564
#> GSM260942     5  0.4597      0.987 0.424 0.000 0.000 0.012 0.564
#> GSM260945     5  0.4597      0.987 0.424 0.000 0.000 0.012 0.564
#> GSM260948     1  0.0579      0.953 0.984 0.000 0.000 0.008 0.008
#> GSM260950     1  0.0404      0.955 0.988 0.000 0.000 0.000 0.012
#> GSM260915     4  0.4672      0.851 0.004 0.004 0.420 0.568 0.004
#> GSM260917     3  0.3844      0.360 0.004 0.004 0.736 0.256 0.000
#> GSM260920     4  0.4892      0.847 0.004 0.004 0.424 0.556 0.012
#> GSM260923     4  0.4531      0.852 0.004 0.004 0.424 0.568 0.000
#> GSM260926     4  0.4679      0.851 0.004 0.004 0.424 0.564 0.004
#> GSM260928     4  0.6772      0.343 0.288 0.000 0.108 0.548 0.056
#> GSM260931     3  0.0324      0.870 0.004 0.000 0.992 0.000 0.004
#> GSM260934     3  0.2504      0.863 0.004 0.000 0.900 0.064 0.032
#> GSM260937     3  0.1571      0.850 0.004 0.000 0.936 0.000 0.060
#> GSM260940     3  0.0324      0.870 0.004 0.000 0.992 0.000 0.004
#> GSM260943     3  0.1571      0.850 0.004 0.000 0.936 0.000 0.060
#> GSM260946     3  0.0324      0.870 0.004 0.000 0.992 0.000 0.004
#> GSM260949     4  0.4672      0.851 0.004 0.004 0.420 0.568 0.004
#> GSM260951     3  0.1864      0.843 0.004 0.004 0.924 0.000 0.068

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM260888     2  0.0520      0.639 0.000 0.984 0.008 0.000 0.008 0.000
#> GSM260893     2  0.0405      0.640 0.000 0.988 0.008 0.000 0.004 0.000
#> GSM260896     2  0.0405      0.640 0.000 0.988 0.008 0.000 0.004 0.000
#> GSM260899     6  0.6167      1.000 0.000 0.424 0.076 0.000 0.068 0.432
#> GSM260902     6  0.6167      1.000 0.000 0.424 0.076 0.000 0.068 0.432
#> GSM260905     2  0.4010     -0.110 0.000 0.584 0.000 0.000 0.008 0.408
#> GSM260908     2  0.4039     -0.152 0.000 0.568 0.000 0.000 0.008 0.424
#> GSM260911     2  0.0520      0.640 0.000 0.984 0.008 0.000 0.008 0.000
#> GSM260912     2  0.0260      0.640 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM260913     4  0.1405      0.822 0.004 0.000 0.000 0.948 0.024 0.024
#> GSM260886     1  0.0000      0.909 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0000      0.909 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260891     1  0.3042      0.809 0.836 0.000 0.032 0.000 0.004 0.128
#> GSM260894     1  0.3042      0.809 0.836 0.000 0.032 0.000 0.004 0.128
#> GSM260897     5  0.4209      0.956 0.396 0.000 0.012 0.000 0.588 0.004
#> GSM260900     5  0.4209      0.956 0.396 0.000 0.012 0.000 0.588 0.004
#> GSM260903     5  0.4293      0.953 0.396 0.000 0.016 0.000 0.584 0.004
#> GSM260906     5  0.4293      0.953 0.396 0.000 0.016 0.000 0.584 0.004
#> GSM260909     1  0.3042      0.809 0.836 0.000 0.032 0.000 0.004 0.128
#> GSM260887     4  0.0146      0.832 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM260890     4  0.0291      0.832 0.004 0.000 0.000 0.992 0.004 0.000
#> GSM260892     4  0.1405      0.822 0.004 0.000 0.000 0.948 0.024 0.024
#> GSM260895     4  0.6710      0.467 0.064 0.000 0.052 0.552 0.076 0.256
#> GSM260898     3  0.4677      0.861 0.000 0.000 0.640 0.308 0.028 0.024
#> GSM260901     3  0.4677      0.861 0.000 0.000 0.640 0.308 0.028 0.024
#> GSM260904     3  0.4407      0.860 0.000 0.000 0.648 0.316 0.020 0.016
#> GSM260907     3  0.4407      0.860 0.000 0.000 0.648 0.316 0.020 0.016
#> GSM260910     4  0.0146      0.832 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM260918     2  0.0260      0.640 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM260921     2  0.0260      0.640 0.000 0.992 0.008 0.000 0.000 0.000
#> GSM260924     2  0.2346      0.564 0.000 0.892 0.016 0.004 0.084 0.004
#> GSM260929     2  0.0260      0.640 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM260932     6  0.6167      1.000 0.000 0.424 0.076 0.000 0.068 0.432
#> GSM260935     6  0.6167      1.000 0.000 0.424 0.076 0.000 0.068 0.432
#> GSM260938     2  0.3866     -0.287 0.000 0.516 0.000 0.000 0.000 0.484
#> GSM260941     2  0.3857     -0.222 0.000 0.532 0.000 0.000 0.000 0.468
#> GSM260944     2  0.3857     -0.222 0.000 0.532 0.000 0.000 0.000 0.468
#> GSM260947     2  0.3857     -0.222 0.000 0.532 0.000 0.000 0.000 0.468
#> GSM260952     2  0.0603      0.633 0.000 0.980 0.000 0.000 0.004 0.016
#> GSM260914     1  0.0000      0.909 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260916     1  0.0146      0.908 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM260919     1  0.0777      0.897 0.972 0.000 0.024 0.000 0.000 0.004
#> GSM260922     1  0.0146      0.908 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM260925     1  0.0000      0.909 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260927     1  0.3550      0.783 0.812 0.000 0.032 0.000 0.024 0.132
#> GSM260930     5  0.4209      0.956 0.396 0.000 0.012 0.000 0.588 0.004
#> GSM260933     5  0.4209      0.956 0.396 0.000 0.012 0.000 0.588 0.004
#> GSM260936     5  0.5234      0.937 0.396 0.000 0.048 0.000 0.532 0.024
#> GSM260939     5  0.5234      0.937 0.396 0.000 0.048 0.000 0.532 0.024
#> GSM260942     5  0.5234      0.937 0.396 0.000 0.048 0.000 0.532 0.024
#> GSM260945     5  0.5123      0.944 0.396 0.000 0.040 0.000 0.540 0.024
#> GSM260948     1  0.1124      0.883 0.956 0.000 0.036 0.000 0.000 0.008
#> GSM260950     1  0.0603      0.900 0.980 0.000 0.016 0.000 0.004 0.000
#> GSM260915     4  0.0508      0.831 0.004 0.000 0.000 0.984 0.012 0.000
#> GSM260917     4  0.3807     -0.141 0.004 0.000 0.368 0.628 0.000 0.000
#> GSM260920     4  0.1562      0.821 0.004 0.000 0.000 0.940 0.032 0.024
#> GSM260923     4  0.0291      0.832 0.004 0.000 0.000 0.992 0.004 0.000
#> GSM260926     4  0.0508      0.832 0.004 0.000 0.000 0.984 0.012 0.000
#> GSM260928     4  0.7572      0.366 0.140 0.000 0.052 0.448 0.088 0.272
#> GSM260931     3  0.3023      0.871 0.000 0.000 0.768 0.232 0.000 0.000
#> GSM260934     3  0.4677      0.861 0.000 0.000 0.640 0.308 0.028 0.024
#> GSM260937     3  0.5762      0.806 0.000 0.000 0.608 0.232 0.112 0.048
#> GSM260940     3  0.3163      0.871 0.000 0.000 0.764 0.232 0.000 0.004
#> GSM260943     3  0.5762      0.806 0.000 0.000 0.608 0.232 0.112 0.048
#> GSM260946     3  0.3023      0.871 0.000 0.000 0.768 0.232 0.000 0.000
#> GSM260949     4  0.1218      0.827 0.004 0.000 0.000 0.956 0.028 0.012
#> GSM260951     3  0.6025      0.794 0.004 0.000 0.592 0.232 0.120 0.052

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) cell.type(p) k
#> MAD:kmeans 67            0.939     2.75e-14 2
#> MAD:kmeans 66            0.920     2.62e-26 3
#> MAD:kmeans 66            0.835     8.36e-25 4
#> MAD:kmeans 64            0.967     1.07e-22 5
#> MAD:kmeans 58            0.976     5.56e-19 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 21168 rows and 67 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 1.000           0.988       0.988         0.4737 0.525   0.525
#> 3 3 1.000           0.995       0.998         0.4250 0.780   0.589
#> 4 4 0.881           0.952       0.931         0.0887 0.940   0.816
#> 5 5 0.887           0.947       0.903         0.0678 0.937   0.761
#> 6 6 0.861           0.856       0.879         0.0401 0.994   0.971

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
#> GSM260888     2   0.000      0.980 0.000 1.000
#> GSM260893     2   0.000      0.980 0.000 1.000
#> GSM260896     2   0.000      0.980 0.000 1.000
#> GSM260899     2   0.000      0.980 0.000 1.000
#> GSM260902     2   0.000      0.980 0.000 1.000
#> GSM260905     2   0.000      0.980 0.000 1.000
#> GSM260908     2   0.000      0.980 0.000 1.000
#> GSM260911     2   0.000      0.980 0.000 1.000
#> GSM260912     2   0.000      0.980 0.000 1.000
#> GSM260913     2   0.224      0.982 0.036 0.964
#> GSM260886     1   0.000      1.000 1.000 0.000
#> GSM260889     1   0.000      1.000 1.000 0.000
#> GSM260891     1   0.000      1.000 1.000 0.000
#> GSM260894     1   0.000      1.000 1.000 0.000
#> GSM260897     1   0.000      1.000 1.000 0.000
#> GSM260900     1   0.000      1.000 1.000 0.000
#> GSM260903     1   0.000      1.000 1.000 0.000
#> GSM260906     1   0.000      1.000 1.000 0.000
#> GSM260909     1   0.000      1.000 1.000 0.000
#> GSM260887     2   0.224      0.982 0.036 0.964
#> GSM260890     2   0.224      0.982 0.036 0.964
#> GSM260892     2   0.224      0.982 0.036 0.964
#> GSM260895     1   0.000      1.000 1.000 0.000
#> GSM260898     2   0.224      0.982 0.036 0.964
#> GSM260901     2   0.224      0.982 0.036 0.964
#> GSM260904     2   0.224      0.982 0.036 0.964
#> GSM260907     2   0.224      0.982 0.036 0.964
#> GSM260910     2   0.224      0.982 0.036 0.964
#> GSM260918     2   0.000      0.980 0.000 1.000
#> GSM260921     2   0.000      0.980 0.000 1.000
#> GSM260924     2   0.000      0.980 0.000 1.000
#> GSM260929     2   0.000      0.980 0.000 1.000
#> GSM260932     2   0.000      0.980 0.000 1.000
#> GSM260935     2   0.000      0.980 0.000 1.000
#> GSM260938     2   0.000      0.980 0.000 1.000
#> GSM260941     2   0.000      0.980 0.000 1.000
#> GSM260944     2   0.000      0.980 0.000 1.000
#> GSM260947     2   0.000      0.980 0.000 1.000
#> GSM260952     2   0.000      0.980 0.000 1.000
#> GSM260914     1   0.000      1.000 1.000 0.000
#> GSM260916     1   0.000      1.000 1.000 0.000
#> GSM260919     1   0.000      1.000 1.000 0.000
#> GSM260922     1   0.000      1.000 1.000 0.000
#> GSM260925     1   0.000      1.000 1.000 0.000
#> GSM260927     1   0.000      1.000 1.000 0.000
#> GSM260930     1   0.000      1.000 1.000 0.000
#> GSM260933     1   0.000      1.000 1.000 0.000
#> GSM260936     1   0.000      1.000 1.000 0.000
#> GSM260939     1   0.000      1.000 1.000 0.000
#> GSM260942     1   0.000      1.000 1.000 0.000
#> GSM260945     1   0.000      1.000 1.000 0.000
#> GSM260948     1   0.000      1.000 1.000 0.000
#> GSM260950     1   0.000      1.000 1.000 0.000
#> GSM260915     2   0.224      0.982 0.036 0.964
#> GSM260917     2   0.224      0.982 0.036 0.964
#> GSM260920     2   0.224      0.982 0.036 0.964
#> GSM260923     2   0.224      0.982 0.036 0.964
#> GSM260926     2   0.224      0.982 0.036 0.964
#> GSM260928     1   0.000      1.000 1.000 0.000
#> GSM260931     2   0.224      0.982 0.036 0.964
#> GSM260934     2   0.224      0.982 0.036 0.964
#> GSM260937     2   0.224      0.982 0.036 0.964
#> GSM260940     2   0.224      0.982 0.036 0.964
#> GSM260943     2   0.224      0.982 0.036 0.964
#> GSM260946     2   0.224      0.982 0.036 0.964
#> GSM260949     2   0.224      0.982 0.036 0.964
#> GSM260951     2   0.224      0.982 0.036 0.964

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette   p1 p2   p3
#> GSM260888     2   0.000      1.000 0.00  1 0.00
#> GSM260893     2   0.000      1.000 0.00  1 0.00
#> GSM260896     2   0.000      1.000 0.00  1 0.00
#> GSM260899     2   0.000      1.000 0.00  1 0.00
#> GSM260902     2   0.000      1.000 0.00  1 0.00
#> GSM260905     2   0.000      1.000 0.00  1 0.00
#> GSM260908     2   0.000      1.000 0.00  1 0.00
#> GSM260911     2   0.000      1.000 0.00  1 0.00
#> GSM260912     2   0.000      1.000 0.00  1 0.00
#> GSM260913     3   0.000      0.993 0.00  0 1.00
#> GSM260886     1   0.000      1.000 1.00  0 0.00
#> GSM260889     1   0.000      1.000 1.00  0 0.00
#> GSM260891     1   0.000      1.000 1.00  0 0.00
#> GSM260894     1   0.000      1.000 1.00  0 0.00
#> GSM260897     1   0.000      1.000 1.00  0 0.00
#> GSM260900     1   0.000      1.000 1.00  0 0.00
#> GSM260903     1   0.000      1.000 1.00  0 0.00
#> GSM260906     1   0.000      1.000 1.00  0 0.00
#> GSM260909     1   0.000      1.000 1.00  0 0.00
#> GSM260887     3   0.000      0.993 0.00  0 1.00
#> GSM260890     3   0.000      0.993 0.00  0 1.00
#> GSM260892     3   0.000      0.993 0.00  0 1.00
#> GSM260895     3   0.369      0.837 0.14  0 0.86
#> GSM260898     3   0.000      0.993 0.00  0 1.00
#> GSM260901     3   0.000      0.993 0.00  0 1.00
#> GSM260904     3   0.000      0.993 0.00  0 1.00
#> GSM260907     3   0.000      0.993 0.00  0 1.00
#> GSM260910     3   0.000      0.993 0.00  0 1.00
#> GSM260918     2   0.000      1.000 0.00  1 0.00
#> GSM260921     2   0.000      1.000 0.00  1 0.00
#> GSM260924     2   0.000      1.000 0.00  1 0.00
#> GSM260929     2   0.000      1.000 0.00  1 0.00
#> GSM260932     2   0.000      1.000 0.00  1 0.00
#> GSM260935     2   0.000      1.000 0.00  1 0.00
#> GSM260938     2   0.000      1.000 0.00  1 0.00
#> GSM260941     2   0.000      1.000 0.00  1 0.00
#> GSM260944     2   0.000      1.000 0.00  1 0.00
#> GSM260947     2   0.000      1.000 0.00  1 0.00
#> GSM260952     2   0.000      1.000 0.00  1 0.00
#> GSM260914     1   0.000      1.000 1.00  0 0.00
#> GSM260916     1   0.000      1.000 1.00  0 0.00
#> GSM260919     1   0.000      1.000 1.00  0 0.00
#> GSM260922     1   0.000      1.000 1.00  0 0.00
#> GSM260925     1   0.000      1.000 1.00  0 0.00
#> GSM260927     1   0.000      1.000 1.00  0 0.00
#> GSM260930     1   0.000      1.000 1.00  0 0.00
#> GSM260933     1   0.000      1.000 1.00  0 0.00
#> GSM260936     1   0.000      1.000 1.00  0 0.00
#> GSM260939     1   0.000      1.000 1.00  0 0.00
#> GSM260942     1   0.000      1.000 1.00  0 0.00
#> GSM260945     1   0.000      1.000 1.00  0 0.00
#> GSM260948     1   0.000      1.000 1.00  0 0.00
#> GSM260950     1   0.000      1.000 1.00  0 0.00
#> GSM260915     3   0.000      0.993 0.00  0 1.00
#> GSM260917     3   0.000      0.993 0.00  0 1.00
#> GSM260920     3   0.000      0.993 0.00  0 1.00
#> GSM260923     3   0.000      0.993 0.00  0 1.00
#> GSM260926     3   0.000      0.993 0.00  0 1.00
#> GSM260928     1   0.000      1.000 1.00  0 0.00
#> GSM260931     3   0.000      0.993 0.00  0 1.00
#> GSM260934     3   0.000      0.993 0.00  0 1.00
#> GSM260937     3   0.000      0.993 0.00  0 1.00
#> GSM260940     3   0.000      0.993 0.00  0 1.00
#> GSM260943     3   0.000      0.993 0.00  0 1.00
#> GSM260946     3   0.000      0.993 0.00  0 1.00
#> GSM260949     3   0.000      0.993 0.00  0 1.00
#> GSM260951     3   0.000      0.993 0.00  0 1.00

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM260888     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM260893     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM260896     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM260899     2  0.0336      0.997 0.000 0.992 0.008 0.000
#> GSM260902     2  0.0336      0.997 0.000 0.992 0.008 0.000
#> GSM260905     2  0.0336      0.997 0.000 0.992 0.008 0.000
#> GSM260908     2  0.0336      0.997 0.000 0.992 0.008 0.000
#> GSM260911     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM260912     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM260913     4  0.0000      0.965 0.000 0.000 0.000 1.000
#> GSM260886     1  0.0188      0.922 0.996 0.000 0.004 0.000
#> GSM260889     1  0.0188      0.922 0.996 0.000 0.004 0.000
#> GSM260891     1  0.0188      0.922 0.996 0.000 0.004 0.000
#> GSM260894     1  0.0000      0.923 1.000 0.000 0.000 0.000
#> GSM260897     1  0.3356      0.899 0.824 0.000 0.176 0.000
#> GSM260900     1  0.3356      0.899 0.824 0.000 0.176 0.000
#> GSM260903     1  0.3356      0.899 0.824 0.000 0.176 0.000
#> GSM260906     1  0.3356      0.899 0.824 0.000 0.176 0.000
#> GSM260909     1  0.0188      0.922 0.996 0.000 0.004 0.000
#> GSM260887     4  0.0000      0.965 0.000 0.000 0.000 1.000
#> GSM260890     4  0.0000      0.965 0.000 0.000 0.000 1.000
#> GSM260892     4  0.0000      0.965 0.000 0.000 0.000 1.000
#> GSM260895     4  0.4595      0.684 0.176 0.000 0.044 0.780
#> GSM260898     3  0.3907      0.989 0.000 0.000 0.768 0.232
#> GSM260901     3  0.3907      0.989 0.000 0.000 0.768 0.232
#> GSM260904     3  0.3907      0.989 0.000 0.000 0.768 0.232
#> GSM260907     3  0.3907      0.989 0.000 0.000 0.768 0.232
#> GSM260910     4  0.0000      0.965 0.000 0.000 0.000 1.000
#> GSM260918     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM260921     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM260924     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM260929     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM260932     2  0.0336      0.997 0.000 0.992 0.008 0.000
#> GSM260935     2  0.0336      0.997 0.000 0.992 0.008 0.000
#> GSM260938     2  0.0336      0.997 0.000 0.992 0.008 0.000
#> GSM260941     2  0.0336      0.997 0.000 0.992 0.008 0.000
#> GSM260944     2  0.0336      0.997 0.000 0.992 0.008 0.000
#> GSM260947     2  0.0336      0.997 0.000 0.992 0.008 0.000
#> GSM260952     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM260914     1  0.0188      0.922 0.996 0.000 0.004 0.000
#> GSM260916     1  0.0188      0.922 0.996 0.000 0.004 0.000
#> GSM260919     1  0.0188      0.922 0.996 0.000 0.004 0.000
#> GSM260922     1  0.0188      0.922 0.996 0.000 0.004 0.000
#> GSM260925     1  0.0188      0.922 0.996 0.000 0.004 0.000
#> GSM260927     1  0.0000      0.923 1.000 0.000 0.000 0.000
#> GSM260930     1  0.3356      0.899 0.824 0.000 0.176 0.000
#> GSM260933     1  0.3356      0.899 0.824 0.000 0.176 0.000
#> GSM260936     1  0.3356      0.899 0.824 0.000 0.176 0.000
#> GSM260939     1  0.3356      0.899 0.824 0.000 0.176 0.000
#> GSM260942     1  0.3356      0.899 0.824 0.000 0.176 0.000
#> GSM260945     1  0.3356      0.899 0.824 0.000 0.176 0.000
#> GSM260948     1  0.0336      0.922 0.992 0.000 0.008 0.000
#> GSM260950     1  0.0336      0.923 0.992 0.000 0.008 0.000
#> GSM260915     4  0.0000      0.965 0.000 0.000 0.000 1.000
#> GSM260917     3  0.4431      0.896 0.000 0.000 0.696 0.304
#> GSM260920     4  0.0188      0.960 0.000 0.000 0.004 0.996
#> GSM260923     4  0.0000      0.965 0.000 0.000 0.000 1.000
#> GSM260926     4  0.0000      0.965 0.000 0.000 0.000 1.000
#> GSM260928     1  0.3793      0.792 0.844 0.000 0.044 0.112
#> GSM260931     3  0.3873      0.989 0.000 0.000 0.772 0.228
#> GSM260934     3  0.3907      0.989 0.000 0.000 0.768 0.232
#> GSM260937     3  0.3873      0.989 0.000 0.000 0.772 0.228
#> GSM260940     3  0.3873      0.989 0.000 0.000 0.772 0.228
#> GSM260943     3  0.3873      0.989 0.000 0.000 0.772 0.228
#> GSM260946     3  0.3873      0.989 0.000 0.000 0.772 0.228
#> GSM260949     4  0.0000      0.965 0.000 0.000 0.000 1.000
#> GSM260951     3  0.3873      0.989 0.000 0.000 0.772 0.228

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM260888     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM260893     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM260896     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM260899     2  0.3146      0.928 0.000 0.844 0.000 0.028 0.128
#> GSM260902     2  0.3146      0.928 0.000 0.844 0.000 0.028 0.128
#> GSM260905     2  0.2628      0.940 0.000 0.884 0.000 0.028 0.088
#> GSM260908     2  0.2685      0.939 0.000 0.880 0.000 0.028 0.092
#> GSM260911     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM260912     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM260913     4  0.1205      0.974 0.000 0.000 0.040 0.956 0.004
#> GSM260886     1  0.0000      0.956 1.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0000      0.956 1.000 0.000 0.000 0.000 0.000
#> GSM260891     1  0.0162      0.954 0.996 0.000 0.000 0.004 0.000
#> GSM260894     1  0.0162      0.954 0.996 0.000 0.000 0.004 0.000
#> GSM260897     5  0.3949      1.000 0.332 0.000 0.000 0.000 0.668
#> GSM260900     5  0.3949      1.000 0.332 0.000 0.000 0.000 0.668
#> GSM260903     5  0.3949      1.000 0.332 0.000 0.000 0.000 0.668
#> GSM260906     5  0.3949      1.000 0.332 0.000 0.000 0.000 0.668
#> GSM260909     1  0.0162      0.954 0.996 0.000 0.000 0.004 0.000
#> GSM260887     4  0.1331      0.973 0.000 0.000 0.040 0.952 0.008
#> GSM260890     4  0.1205      0.974 0.000 0.000 0.040 0.956 0.004
#> GSM260892     4  0.1205      0.974 0.000 0.000 0.040 0.956 0.004
#> GSM260895     4  0.4075      0.797 0.060 0.000 0.000 0.780 0.160
#> GSM260898     3  0.1168      0.959 0.000 0.000 0.960 0.032 0.008
#> GSM260901     3  0.1082      0.961 0.000 0.000 0.964 0.028 0.008
#> GSM260904     3  0.1251      0.957 0.000 0.000 0.956 0.036 0.008
#> GSM260907     3  0.1082      0.961 0.000 0.000 0.964 0.028 0.008
#> GSM260910     4  0.0963      0.973 0.000 0.000 0.036 0.964 0.000
#> GSM260918     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM260921     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM260924     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM260929     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM260932     2  0.3146      0.928 0.000 0.844 0.000 0.028 0.128
#> GSM260935     2  0.3146      0.928 0.000 0.844 0.000 0.028 0.128
#> GSM260938     2  0.2795      0.937 0.000 0.872 0.000 0.028 0.100
#> GSM260941     2  0.2740      0.938 0.000 0.876 0.000 0.028 0.096
#> GSM260944     2  0.2740      0.938 0.000 0.876 0.000 0.028 0.096
#> GSM260947     2  0.2740      0.938 0.000 0.876 0.000 0.028 0.096
#> GSM260952     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM260914     1  0.0000      0.956 1.000 0.000 0.000 0.000 0.000
#> GSM260916     1  0.0000      0.956 1.000 0.000 0.000 0.000 0.000
#> GSM260919     1  0.0000      0.956 1.000 0.000 0.000 0.000 0.000
#> GSM260922     1  0.0000      0.956 1.000 0.000 0.000 0.000 0.000
#> GSM260925     1  0.0000      0.956 1.000 0.000 0.000 0.000 0.000
#> GSM260927     1  0.1430      0.894 0.944 0.000 0.000 0.004 0.052
#> GSM260930     5  0.3949      1.000 0.332 0.000 0.000 0.000 0.668
#> GSM260933     5  0.3949      1.000 0.332 0.000 0.000 0.000 0.668
#> GSM260936     5  0.3949      1.000 0.332 0.000 0.000 0.000 0.668
#> GSM260939     5  0.3949      1.000 0.332 0.000 0.000 0.000 0.668
#> GSM260942     5  0.3949      1.000 0.332 0.000 0.000 0.000 0.668
#> GSM260945     5  0.3949      1.000 0.332 0.000 0.000 0.000 0.668
#> GSM260948     1  0.0963      0.918 0.964 0.000 0.000 0.000 0.036
#> GSM260950     1  0.0510      0.942 0.984 0.000 0.000 0.000 0.016
#> GSM260915     4  0.1251      0.973 0.000 0.000 0.036 0.956 0.008
#> GSM260917     3  0.3391      0.770 0.000 0.000 0.800 0.188 0.012
#> GSM260920     4  0.1484      0.970 0.000 0.000 0.048 0.944 0.008
#> GSM260923     4  0.1168      0.971 0.000 0.000 0.032 0.960 0.008
#> GSM260926     4  0.1408      0.973 0.000 0.000 0.044 0.948 0.008
#> GSM260928     1  0.5035      0.556 0.672 0.000 0.000 0.076 0.252
#> GSM260931     3  0.0000      0.962 0.000 0.000 1.000 0.000 0.000
#> GSM260934     3  0.0992      0.962 0.000 0.000 0.968 0.024 0.008
#> GSM260937     3  0.0510      0.959 0.000 0.000 0.984 0.000 0.016
#> GSM260940     3  0.0000      0.962 0.000 0.000 1.000 0.000 0.000
#> GSM260943     3  0.0510      0.959 0.000 0.000 0.984 0.000 0.016
#> GSM260946     3  0.0000      0.962 0.000 0.000 1.000 0.000 0.000
#> GSM260949     4  0.1408      0.973 0.000 0.000 0.044 0.948 0.008
#> GSM260951     3  0.0992      0.955 0.000 0.000 0.968 0.008 0.024

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM260888     2  0.0291     0.8075 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM260893     2  0.0291     0.8075 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM260896     2  0.0291     0.8075 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM260899     2  0.3810     0.7307 0.000 0.572 0.000 0.000 0.000 0.428
#> GSM260902     2  0.3810     0.7307 0.000 0.572 0.000 0.000 0.000 0.428
#> GSM260905     2  0.3371     0.7987 0.000 0.708 0.000 0.000 0.000 0.292
#> GSM260908     2  0.3390     0.7981 0.000 0.704 0.000 0.000 0.000 0.296
#> GSM260911     2  0.0291     0.8075 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM260912     2  0.0146     0.8106 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM260913     4  0.0405     0.9339 0.000 0.000 0.004 0.988 0.000 0.008
#> GSM260886     1  0.0291     0.9352 0.992 0.000 0.000 0.000 0.004 0.004
#> GSM260889     1  0.0146     0.9356 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260891     1  0.0937     0.9106 0.960 0.000 0.000 0.000 0.000 0.040
#> GSM260894     1  0.1010     0.9152 0.960 0.000 0.000 0.000 0.004 0.036
#> GSM260897     5  0.2048     0.9939 0.120 0.000 0.000 0.000 0.880 0.000
#> GSM260900     5  0.2234     0.9937 0.124 0.000 0.000 0.000 0.872 0.004
#> GSM260903     5  0.2092     0.9939 0.124 0.000 0.000 0.000 0.876 0.000
#> GSM260906     5  0.2234     0.9937 0.124 0.000 0.000 0.000 0.872 0.004
#> GSM260909     1  0.0790     0.9180 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM260887     4  0.0291     0.9348 0.000 0.000 0.004 0.992 0.000 0.004
#> GSM260890     4  0.0508     0.9342 0.000 0.000 0.004 0.984 0.000 0.012
#> GSM260892     4  0.0291     0.9345 0.000 0.000 0.004 0.992 0.000 0.004
#> GSM260895     4  0.5973     0.0695 0.068 0.000 0.000 0.484 0.060 0.388
#> GSM260898     3  0.1370     0.9123 0.000 0.000 0.948 0.036 0.004 0.012
#> GSM260901     3  0.1370     0.9123 0.000 0.000 0.948 0.036 0.004 0.012
#> GSM260904     3  0.1225     0.9131 0.000 0.000 0.952 0.036 0.000 0.012
#> GSM260907     3  0.1151     0.9141 0.000 0.000 0.956 0.032 0.000 0.012
#> GSM260910     4  0.0508     0.9341 0.000 0.000 0.004 0.984 0.000 0.012
#> GSM260918     2  0.0146     0.8106 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM260921     2  0.0291     0.8075 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM260924     2  0.0146     0.8088 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM260929     2  0.0146     0.8106 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM260932     2  0.3810     0.7307 0.000 0.572 0.000 0.000 0.000 0.428
#> GSM260935     2  0.3810     0.7307 0.000 0.572 0.000 0.000 0.000 0.428
#> GSM260938     2  0.3482     0.7928 0.000 0.684 0.000 0.000 0.000 0.316
#> GSM260941     2  0.3464     0.7943 0.000 0.688 0.000 0.000 0.000 0.312
#> GSM260944     2  0.3464     0.7943 0.000 0.688 0.000 0.000 0.000 0.312
#> GSM260947     2  0.3464     0.7943 0.000 0.688 0.000 0.000 0.000 0.312
#> GSM260952     2  0.0000     0.8098 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260914     1  0.0146     0.9356 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260916     1  0.0260     0.9337 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260919     1  0.0790     0.9185 0.968 0.000 0.000 0.000 0.032 0.000
#> GSM260922     1  0.0260     0.9337 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260925     1  0.0146     0.9356 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260927     1  0.2971     0.7163 0.844 0.000 0.000 0.000 0.104 0.052
#> GSM260930     5  0.2234     0.9937 0.124 0.000 0.000 0.000 0.872 0.004
#> GSM260933     5  0.2234     0.9937 0.124 0.000 0.000 0.000 0.872 0.004
#> GSM260936     5  0.2191     0.9930 0.120 0.000 0.000 0.000 0.876 0.004
#> GSM260939     5  0.2191     0.9930 0.120 0.000 0.000 0.000 0.876 0.004
#> GSM260942     5  0.2191     0.9930 0.120 0.000 0.000 0.000 0.876 0.004
#> GSM260945     5  0.2048     0.9939 0.120 0.000 0.000 0.000 0.880 0.000
#> GSM260948     1  0.1908     0.8105 0.900 0.000 0.000 0.000 0.096 0.004
#> GSM260950     1  0.1010     0.9143 0.960 0.000 0.000 0.000 0.036 0.004
#> GSM260915     4  0.0767     0.9331 0.000 0.000 0.012 0.976 0.004 0.008
#> GSM260917     3  0.4200     0.6361 0.000 0.000 0.696 0.264 0.008 0.032
#> GSM260920     4  0.1059     0.9229 0.000 0.000 0.016 0.964 0.004 0.016
#> GSM260923     4  0.1003     0.9243 0.000 0.000 0.004 0.964 0.004 0.028
#> GSM260926     4  0.0508     0.9336 0.000 0.000 0.012 0.984 0.000 0.004
#> GSM260928     6  0.6392     0.0000 0.360 0.000 0.000 0.056 0.124 0.460
#> GSM260931     3  0.0858     0.9082 0.000 0.000 0.968 0.000 0.004 0.028
#> GSM260934     3  0.1218     0.9141 0.000 0.000 0.956 0.028 0.004 0.012
#> GSM260937     3  0.2542     0.8746 0.000 0.000 0.876 0.000 0.044 0.080
#> GSM260940     3  0.0458     0.9106 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM260943     3  0.2404     0.8785 0.000 0.000 0.884 0.000 0.036 0.080
#> GSM260946     3  0.0260     0.9114 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM260949     4  0.0717     0.9307 0.000 0.000 0.008 0.976 0.000 0.016
#> GSM260951     3  0.3637     0.8436 0.000 0.000 0.824 0.056 0.040 0.080

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) cell.type(p) k
#> MAD:skmeans 67            1.000     1.40e-13 2
#> MAD:skmeans 67            0.864     1.50e-25 3
#> MAD:skmeans 67            0.716     4.07e-24 4
#> MAD:skmeans 67            0.844     7.80e-23 5
#> MAD:skmeans 65            0.940     4.03e-23 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 21168 rows and 67 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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.569           0.902       0.936         0.4471 0.563   0.563
#> 3 3 1.000           0.996       0.998         0.5082 0.744   0.553
#> 4 4 1.000           0.980       0.988         0.0899 0.932   0.795
#> 5 5 0.969           0.957       0.980         0.0872 0.935   0.756
#> 6 6 0.917           0.932       0.962         0.0539 0.955   0.775

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

suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 3 4 5

There is also optional best \(k\) = 3 4 5 that is worth to check.

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM260888     2   0.000      0.984 0.000 1.000
#> GSM260893     2   0.000      0.984 0.000 1.000
#> GSM260896     2   0.000      0.984 0.000 1.000
#> GSM260899     2   0.000      0.984 0.000 1.000
#> GSM260902     2   0.000      0.984 0.000 1.000
#> GSM260905     2   0.000      0.984 0.000 1.000
#> GSM260908     2   0.000      0.984 0.000 1.000
#> GSM260911     2   0.000      0.984 0.000 1.000
#> GSM260912     2   0.000      0.984 0.000 1.000
#> GSM260913     1   0.595      0.884 0.856 0.144
#> GSM260886     1   0.000      0.906 1.000 0.000
#> GSM260889     1   0.000      0.906 1.000 0.000
#> GSM260891     1   0.000      0.906 1.000 0.000
#> GSM260894     1   0.000      0.906 1.000 0.000
#> GSM260897     1   0.000      0.906 1.000 0.000
#> GSM260900     1   0.000      0.906 1.000 0.000
#> GSM260903     1   0.000      0.906 1.000 0.000
#> GSM260906     1   0.000      0.906 1.000 0.000
#> GSM260909     1   0.000      0.906 1.000 0.000
#> GSM260887     1   0.644      0.872 0.836 0.164
#> GSM260890     1   0.760      0.820 0.780 0.220
#> GSM260892     1   0.595      0.884 0.856 0.144
#> GSM260895     1   0.552      0.888 0.872 0.128
#> GSM260898     1   0.595      0.884 0.856 0.144
#> GSM260901     1   0.595      0.884 0.856 0.144
#> GSM260904     1   0.595      0.884 0.856 0.144
#> GSM260907     1   0.767      0.813 0.776 0.224
#> GSM260910     1   0.689      0.856 0.816 0.184
#> GSM260918     2   0.000      0.984 0.000 1.000
#> GSM260921     2   0.000      0.984 0.000 1.000
#> GSM260924     2   0.000      0.984 0.000 1.000
#> GSM260929     2   0.000      0.984 0.000 1.000
#> GSM260932     2   0.000      0.984 0.000 1.000
#> GSM260935     2   0.000      0.984 0.000 1.000
#> GSM260938     2   0.000      0.984 0.000 1.000
#> GSM260941     2   0.000      0.984 0.000 1.000
#> GSM260944     2   0.000      0.984 0.000 1.000
#> GSM260947     2   0.000      0.984 0.000 1.000
#> GSM260952     2   0.000      0.984 0.000 1.000
#> GSM260914     1   0.000      0.906 1.000 0.000
#> GSM260916     1   0.000      0.906 1.000 0.000
#> GSM260919     1   0.000      0.906 1.000 0.000
#> GSM260922     1   0.000      0.906 1.000 0.000
#> GSM260925     1   0.000      0.906 1.000 0.000
#> GSM260927     1   0.000      0.906 1.000 0.000
#> GSM260930     1   0.000      0.906 1.000 0.000
#> GSM260933     1   0.000      0.906 1.000 0.000
#> GSM260936     1   0.000      0.906 1.000 0.000
#> GSM260939     1   0.000      0.906 1.000 0.000
#> GSM260942     1   0.000      0.906 1.000 0.000
#> GSM260945     1   0.000      0.906 1.000 0.000
#> GSM260948     1   0.000      0.906 1.000 0.000
#> GSM260950     1   0.000      0.906 1.000 0.000
#> GSM260915     1   0.595      0.884 0.856 0.144
#> GSM260917     1   0.689      0.856 0.816 0.184
#> GSM260920     1   0.595      0.884 0.856 0.144
#> GSM260923     1   0.595      0.884 0.856 0.144
#> GSM260926     1   0.983      0.458 0.576 0.424
#> GSM260928     1   0.141      0.904 0.980 0.020
#> GSM260931     1   0.936      0.611 0.648 0.352
#> GSM260934     1   0.788      0.799 0.764 0.236
#> GSM260937     1   0.653      0.869 0.832 0.168
#> GSM260940     1   0.595      0.884 0.856 0.144
#> GSM260943     2   0.850      0.539 0.276 0.724
#> GSM260946     1   0.595      0.884 0.856 0.144
#> GSM260949     1   0.595      0.884 0.856 0.144
#> GSM260951     1   0.595      0.884 0.856 0.144

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM260888     2   0.000      1.000 0.000  1 0.000
#> GSM260893     2   0.000      1.000 0.000  1 0.000
#> GSM260896     2   0.000      1.000 0.000  1 0.000
#> GSM260899     2   0.000      1.000 0.000  1 0.000
#> GSM260902     2   0.000      1.000 0.000  1 0.000
#> GSM260905     2   0.000      1.000 0.000  1 0.000
#> GSM260908     2   0.000      1.000 0.000  1 0.000
#> GSM260911     2   0.000      1.000 0.000  1 0.000
#> GSM260912     2   0.000      1.000 0.000  1 0.000
#> GSM260913     3   0.000      1.000 0.000  0 1.000
#> GSM260886     1   0.000      0.995 1.000  0 0.000
#> GSM260889     1   0.000      0.995 1.000  0 0.000
#> GSM260891     1   0.000      0.995 1.000  0 0.000
#> GSM260894     1   0.000      0.995 1.000  0 0.000
#> GSM260897     1   0.000      0.995 1.000  0 0.000
#> GSM260900     1   0.000      0.995 1.000  0 0.000
#> GSM260903     1   0.000      0.995 1.000  0 0.000
#> GSM260906     1   0.000      0.995 1.000  0 0.000
#> GSM260909     1   0.000      0.995 1.000  0 0.000
#> GSM260887     3   0.000      1.000 0.000  0 1.000
#> GSM260890     3   0.000      1.000 0.000  0 1.000
#> GSM260892     3   0.000      1.000 0.000  0 1.000
#> GSM260895     1   0.271      0.906 0.912  0 0.088
#> GSM260898     3   0.000      1.000 0.000  0 1.000
#> GSM260901     3   0.000      1.000 0.000  0 1.000
#> GSM260904     3   0.000      1.000 0.000  0 1.000
#> GSM260907     3   0.000      1.000 0.000  0 1.000
#> GSM260910     3   0.000      1.000 0.000  0 1.000
#> GSM260918     2   0.000      1.000 0.000  1 0.000
#> GSM260921     2   0.000      1.000 0.000  1 0.000
#> GSM260924     2   0.000      1.000 0.000  1 0.000
#> GSM260929     2   0.000      1.000 0.000  1 0.000
#> GSM260932     2   0.000      1.000 0.000  1 0.000
#> GSM260935     2   0.000      1.000 0.000  1 0.000
#> GSM260938     2   0.000      1.000 0.000  1 0.000
#> GSM260941     2   0.000      1.000 0.000  1 0.000
#> GSM260944     2   0.000      1.000 0.000  1 0.000
#> GSM260947     2   0.000      1.000 0.000  1 0.000
#> GSM260952     2   0.000      1.000 0.000  1 0.000
#> GSM260914     1   0.000      0.995 1.000  0 0.000
#> GSM260916     1   0.000      0.995 1.000  0 0.000
#> GSM260919     1   0.000      0.995 1.000  0 0.000
#> GSM260922     1   0.000      0.995 1.000  0 0.000
#> GSM260925     1   0.000      0.995 1.000  0 0.000
#> GSM260927     1   0.000      0.995 1.000  0 0.000
#> GSM260930     1   0.000      0.995 1.000  0 0.000
#> GSM260933     1   0.000      0.995 1.000  0 0.000
#> GSM260936     1   0.000      0.995 1.000  0 0.000
#> GSM260939     1   0.000      0.995 1.000  0 0.000
#> GSM260942     1   0.000      0.995 1.000  0 0.000
#> GSM260945     1   0.000      0.995 1.000  0 0.000
#> GSM260948     1   0.000      0.995 1.000  0 0.000
#> GSM260950     1   0.000      0.995 1.000  0 0.000
#> GSM260915     3   0.000      1.000 0.000  0 1.000
#> GSM260917     3   0.000      1.000 0.000  0 1.000
#> GSM260920     3   0.000      1.000 0.000  0 1.000
#> GSM260923     3   0.000      1.000 0.000  0 1.000
#> GSM260926     3   0.000      1.000 0.000  0 1.000
#> GSM260928     1   0.153      0.958 0.960  0 0.040
#> GSM260931     3   0.000      1.000 0.000  0 1.000
#> GSM260934     3   0.000      1.000 0.000  0 1.000
#> GSM260937     3   0.000      1.000 0.000  0 1.000
#> GSM260940     3   0.000      1.000 0.000  0 1.000
#> GSM260943     3   0.000      1.000 0.000  0 1.000
#> GSM260946     3   0.000      1.000 0.000  0 1.000
#> GSM260949     3   0.000      1.000 0.000  0 1.000
#> GSM260951     3   0.000      1.000 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM260888     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260893     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260896     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260899     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260902     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260905     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260908     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260911     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260912     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260913     4  0.0336      0.999 0.000  0 0.008 0.992
#> GSM260886     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260889     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260891     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260894     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260897     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260900     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260903     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260906     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260909     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260887     4  0.0336      0.999 0.000  0 0.008 0.992
#> GSM260890     4  0.0336      0.999 0.000  0 0.008 0.992
#> GSM260892     4  0.0336      0.999 0.000  0 0.008 0.992
#> GSM260895     4  0.0188      0.995 0.000  0 0.004 0.996
#> GSM260898     3  0.0000      0.961 0.000  0 1.000 0.000
#> GSM260901     3  0.0000      0.961 0.000  0 1.000 0.000
#> GSM260904     3  0.2589      0.874 0.000  0 0.884 0.116
#> GSM260907     3  0.0000      0.961 0.000  0 1.000 0.000
#> GSM260910     4  0.0336      0.999 0.000  0 0.008 0.992
#> GSM260918     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260921     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260924     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260929     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260932     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260935     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260938     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260941     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260944     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260947     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260952     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260914     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260916     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260919     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260922     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260925     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260927     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260930     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260933     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260936     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260939     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260942     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260945     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260948     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260950     1  0.0188      0.990 0.996  0 0.000 0.004
#> GSM260915     4  0.0336      0.999 0.000  0 0.008 0.992
#> GSM260917     3  0.2149      0.899 0.000  0 0.912 0.088
#> GSM260920     3  0.4103      0.688 0.000  0 0.744 0.256
#> GSM260923     4  0.0336      0.999 0.000  0 0.008 0.992
#> GSM260926     4  0.0336      0.999 0.000  0 0.008 0.992
#> GSM260928     1  0.3074      0.826 0.848  0 0.000 0.152
#> GSM260931     3  0.0000      0.961 0.000  0 1.000 0.000
#> GSM260934     3  0.0000      0.961 0.000  0 1.000 0.000
#> GSM260937     3  0.0000      0.961 0.000  0 1.000 0.000
#> GSM260940     3  0.0000      0.961 0.000  0 1.000 0.000
#> GSM260943     3  0.0000      0.961 0.000  0 1.000 0.000
#> GSM260946     3  0.0000      0.961 0.000  0 1.000 0.000
#> GSM260949     4  0.0336      0.999 0.000  0 0.008 0.992
#> GSM260951     3  0.0000      0.961 0.000  0 1.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
#> GSM260888     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260893     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260896     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260899     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260902     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260905     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260908     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260911     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260912     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260913     4  0.0000      0.996 0.000  0 0.000 1.000 0.000
#> GSM260886     1  0.0000      0.967 1.000  0 0.000 0.000 0.000
#> GSM260889     1  0.0000      0.967 1.000  0 0.000 0.000 0.000
#> GSM260891     1  0.0000      0.967 1.000  0 0.000 0.000 0.000
#> GSM260894     1  0.2732      0.802 0.840  0 0.000 0.000 0.160
#> GSM260897     5  0.0000      0.963 0.000  0 0.000 0.000 1.000
#> GSM260900     5  0.0000      0.963 0.000  0 0.000 0.000 1.000
#> GSM260903     5  0.0000      0.963 0.000  0 0.000 0.000 1.000
#> GSM260906     5  0.0000      0.963 0.000  0 0.000 0.000 1.000
#> GSM260909     1  0.0000      0.967 1.000  0 0.000 0.000 0.000
#> GSM260887     4  0.0000      0.996 0.000  0 0.000 1.000 0.000
#> GSM260890     4  0.0000      0.996 0.000  0 0.000 1.000 0.000
#> GSM260892     4  0.0000      0.996 0.000  0 0.000 1.000 0.000
#> GSM260895     4  0.0963      0.961 0.036  0 0.000 0.964 0.000
#> GSM260898     3  0.0000      0.952 0.000  0 1.000 0.000 0.000
#> GSM260901     3  0.0000      0.952 0.000  0 1.000 0.000 0.000
#> GSM260904     3  0.2648      0.831 0.000  0 0.848 0.152 0.000
#> GSM260907     3  0.0000      0.952 0.000  0 1.000 0.000 0.000
#> GSM260910     4  0.0000      0.996 0.000  0 0.000 1.000 0.000
#> GSM260918     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260921     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260924     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260929     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260932     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260935     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260938     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260941     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260944     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260947     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260952     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260914     1  0.0000      0.967 1.000  0 0.000 0.000 0.000
#> GSM260916     1  0.0000      0.967 1.000  0 0.000 0.000 0.000
#> GSM260919     1  0.0000      0.967 1.000  0 0.000 0.000 0.000
#> GSM260922     1  0.0000      0.967 1.000  0 0.000 0.000 0.000
#> GSM260925     1  0.0000      0.967 1.000  0 0.000 0.000 0.000
#> GSM260927     5  0.3143      0.742 0.204  0 0.000 0.000 0.796
#> GSM260930     5  0.0000      0.963 0.000  0 0.000 0.000 1.000
#> GSM260933     5  0.0000      0.963 0.000  0 0.000 0.000 1.000
#> GSM260936     5  0.0000      0.963 0.000  0 0.000 0.000 1.000
#> GSM260939     5  0.0000      0.963 0.000  0 0.000 0.000 1.000
#> GSM260942     5  0.0000      0.963 0.000  0 0.000 0.000 1.000
#> GSM260945     5  0.0000      0.963 0.000  0 0.000 0.000 1.000
#> GSM260948     1  0.2966      0.779 0.816  0 0.000 0.000 0.184
#> GSM260950     1  0.0000      0.967 1.000  0 0.000 0.000 0.000
#> GSM260915     4  0.0000      0.996 0.000  0 0.000 1.000 0.000
#> GSM260917     3  0.2127      0.874 0.000  0 0.892 0.108 0.000
#> GSM260920     3  0.3837      0.604 0.000  0 0.692 0.308 0.000
#> GSM260923     4  0.0000      0.996 0.000  0 0.000 1.000 0.000
#> GSM260926     4  0.0000      0.996 0.000  0 0.000 1.000 0.000
#> GSM260928     5  0.3246      0.770 0.008  0 0.000 0.184 0.808
#> GSM260931     3  0.0000      0.952 0.000  0 1.000 0.000 0.000
#> GSM260934     3  0.0000      0.952 0.000  0 1.000 0.000 0.000
#> GSM260937     3  0.0000      0.952 0.000  0 1.000 0.000 0.000
#> GSM260940     3  0.0000      0.952 0.000  0 1.000 0.000 0.000
#> GSM260943     3  0.0000      0.952 0.000  0 1.000 0.000 0.000
#> GSM260946     3  0.0000      0.952 0.000  0 1.000 0.000 0.000
#> GSM260949     4  0.0000      0.996 0.000  0 0.000 1.000 0.000
#> GSM260951     3  0.0000      0.952 0.000  0 1.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
#> GSM260888     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260893     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260896     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260899     6  0.0632      0.878 0.000 0.024 0.000 0.000 0.000 0.976
#> GSM260902     6  0.0146      0.876 0.000 0.004 0.000 0.000 0.000 0.996
#> GSM260905     6  0.2631      0.876 0.000 0.180 0.000 0.000 0.000 0.820
#> GSM260908     6  0.2597      0.878 0.000 0.176 0.000 0.000 0.000 0.824
#> GSM260911     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260912     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260913     4  0.0000      0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260886     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260891     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260894     1  0.2454      0.802 0.840 0.000 0.000 0.000 0.160 0.000
#> GSM260897     5  0.0000      0.962 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260900     5  0.0000      0.962 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260903     5  0.0000      0.962 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260906     5  0.0000      0.962 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260909     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260887     4  0.0000      0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260890     4  0.0000      0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260892     4  0.0000      0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260895     4  0.1010      0.957 0.036 0.000 0.000 0.960 0.000 0.004
#> GSM260898     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260901     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260904     3  0.2416      0.827 0.000 0.000 0.844 0.156 0.000 0.000
#> GSM260907     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260910     4  0.0000      0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260918     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260921     2  0.2378      0.787 0.000 0.848 0.000 0.000 0.000 0.152
#> GSM260924     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260929     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260932     6  0.0547      0.878 0.000 0.020 0.000 0.000 0.000 0.980
#> GSM260935     6  0.2003      0.829 0.000 0.116 0.000 0.000 0.000 0.884
#> GSM260938     6  0.0146      0.876 0.000 0.004 0.000 0.000 0.000 0.996
#> GSM260941     6  0.2597      0.878 0.000 0.176 0.000 0.000 0.000 0.824
#> GSM260944     6  0.2454      0.883 0.000 0.160 0.000 0.000 0.000 0.840
#> GSM260947     6  0.2597      0.878 0.000 0.176 0.000 0.000 0.000 0.824
#> GSM260952     2  0.0146      0.976 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM260914     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260916     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260919     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260922     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260925     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260927     5  0.2823      0.742 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM260930     5  0.0000      0.962 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260933     5  0.0000      0.962 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260936     5  0.0000      0.962 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260939     5  0.0000      0.962 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260942     5  0.0000      0.962 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260945     5  0.0000      0.962 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM260948     1  0.2664      0.779 0.816 0.000 0.000 0.000 0.184 0.000
#> GSM260950     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260915     4  0.0000      0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260917     3  0.1910      0.873 0.000 0.000 0.892 0.108 0.000 0.000
#> GSM260920     3  0.3464      0.597 0.000 0.000 0.688 0.312 0.000 0.000
#> GSM260923     4  0.0000      0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260926     4  0.0000      0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260928     5  0.3056      0.767 0.008 0.000 0.000 0.184 0.804 0.004
#> GSM260931     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260934     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260937     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260940     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260943     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260946     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260949     4  0.0000      0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260951     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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) cell.type(p) k
#> MAD:pam 66            1.000     3.78e-13 2
#> MAD:pam 67            0.940     1.87e-24 3
#> MAD:pam 67            0.517     3.96e-24 4
#> MAD:pam 67            0.654     7.35e-23 5
#> MAD:pam 67            0.753     1.15e-21 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 21168 rows and 67 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 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 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.997       0.997         0.4260 0.575   0.575
#> 3 3 1.000           0.990       0.995         0.5847 0.750   0.566
#> 4 4 0.920           0.955       0.949         0.0443 0.980   0.939
#> 5 5 0.886           0.939       0.937         0.0826 0.931   0.774
#> 6 6 0.858           0.942       0.910         0.0832 0.890   0.565

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM260888     2  0.0000      1.000 0.000 1.000
#> GSM260893     2  0.0000      1.000 0.000 1.000
#> GSM260896     2  0.0000      1.000 0.000 1.000
#> GSM260899     2  0.0000      1.000 0.000 1.000
#> GSM260902     2  0.0000      1.000 0.000 1.000
#> GSM260905     2  0.0000      1.000 0.000 1.000
#> GSM260908     2  0.0000      1.000 0.000 1.000
#> GSM260911     2  0.0000      1.000 0.000 1.000
#> GSM260912     2  0.0000      1.000 0.000 1.000
#> GSM260913     1  0.0672      0.996 0.992 0.008
#> GSM260886     1  0.0000      0.996 1.000 0.000
#> GSM260889     1  0.0000      0.996 1.000 0.000
#> GSM260891     1  0.0000      0.996 1.000 0.000
#> GSM260894     1  0.0000      0.996 1.000 0.000
#> GSM260897     1  0.0000      0.996 1.000 0.000
#> GSM260900     1  0.0000      0.996 1.000 0.000
#> GSM260903     1  0.0000      0.996 1.000 0.000
#> GSM260906     1  0.0000      0.996 1.000 0.000
#> GSM260909     1  0.0000      0.996 1.000 0.000
#> GSM260887     1  0.0672      0.996 0.992 0.008
#> GSM260890     1  0.0672      0.996 0.992 0.008
#> GSM260892     1  0.0672      0.996 0.992 0.008
#> GSM260895     1  0.0672      0.996 0.992 0.008
#> GSM260898     1  0.0672      0.996 0.992 0.008
#> GSM260901     1  0.0672      0.996 0.992 0.008
#> GSM260904     1  0.0672      0.996 0.992 0.008
#> GSM260907     1  0.0672      0.996 0.992 0.008
#> GSM260910     1  0.0672      0.996 0.992 0.008
#> GSM260918     2  0.0000      1.000 0.000 1.000
#> GSM260921     2  0.0000      1.000 0.000 1.000
#> GSM260924     2  0.0000      1.000 0.000 1.000
#> GSM260929     2  0.0000      1.000 0.000 1.000
#> GSM260932     2  0.0000      1.000 0.000 1.000
#> GSM260935     2  0.0000      1.000 0.000 1.000
#> GSM260938     2  0.0000      1.000 0.000 1.000
#> GSM260941     2  0.0000      1.000 0.000 1.000
#> GSM260944     2  0.0000      1.000 0.000 1.000
#> GSM260947     2  0.0000      1.000 0.000 1.000
#> GSM260952     2  0.0000      1.000 0.000 1.000
#> GSM260914     1  0.0000      0.996 1.000 0.000
#> GSM260916     1  0.0000      0.996 1.000 0.000
#> GSM260919     1  0.0000      0.996 1.000 0.000
#> GSM260922     1  0.0000      0.996 1.000 0.000
#> GSM260925     1  0.0000      0.996 1.000 0.000
#> GSM260927     1  0.0000      0.996 1.000 0.000
#> GSM260930     1  0.0000      0.996 1.000 0.000
#> GSM260933     1  0.0000      0.996 1.000 0.000
#> GSM260936     1  0.0000      0.996 1.000 0.000
#> GSM260939     1  0.0000      0.996 1.000 0.000
#> GSM260942     1  0.0000      0.996 1.000 0.000
#> GSM260945     1  0.0000      0.996 1.000 0.000
#> GSM260948     1  0.0000      0.996 1.000 0.000
#> GSM260950     1  0.0000      0.996 1.000 0.000
#> GSM260915     1  0.0672      0.996 0.992 0.008
#> GSM260917     1  0.0672      0.996 0.992 0.008
#> GSM260920     1  0.0672      0.996 0.992 0.008
#> GSM260923     1  0.0672      0.996 0.992 0.008
#> GSM260926     1  0.0672      0.996 0.992 0.008
#> GSM260928     1  0.0672      0.996 0.992 0.008
#> GSM260931     1  0.0672      0.996 0.992 0.008
#> GSM260934     1  0.0672      0.996 0.992 0.008
#> GSM260937     1  0.0672      0.996 0.992 0.008
#> GSM260940     1  0.0672      0.996 0.992 0.008
#> GSM260943     1  0.0672      0.996 0.992 0.008
#> GSM260946     1  0.0672      0.996 0.992 0.008
#> GSM260949     1  0.0672      0.996 0.992 0.008
#> GSM260951     1  0.0672      0.996 0.992 0.008

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM260888     2   0.000      1.000 0.000  1 0.000
#> GSM260893     2   0.000      1.000 0.000  1 0.000
#> GSM260896     2   0.000      1.000 0.000  1 0.000
#> GSM260899     2   0.000      1.000 0.000  1 0.000
#> GSM260902     2   0.000      1.000 0.000  1 0.000
#> GSM260905     2   0.000      1.000 0.000  1 0.000
#> GSM260908     2   0.000      1.000 0.000  1 0.000
#> GSM260911     2   0.000      1.000 0.000  1 0.000
#> GSM260912     2   0.000      1.000 0.000  1 0.000
#> GSM260913     3   0.000      0.986 0.000  0 1.000
#> GSM260886     1   0.000      1.000 1.000  0 0.000
#> GSM260889     1   0.000      1.000 1.000  0 0.000
#> GSM260891     1   0.000      1.000 1.000  0 0.000
#> GSM260894     1   0.000      1.000 1.000  0 0.000
#> GSM260897     1   0.000      1.000 1.000  0 0.000
#> GSM260900     1   0.000      1.000 1.000  0 0.000
#> GSM260903     1   0.000      1.000 1.000  0 0.000
#> GSM260906     1   0.000      1.000 1.000  0 0.000
#> GSM260909     1   0.000      1.000 1.000  0 0.000
#> GSM260887     3   0.000      0.986 0.000  0 1.000
#> GSM260890     3   0.000      0.986 0.000  0 1.000
#> GSM260892     3   0.000      0.986 0.000  0 1.000
#> GSM260895     3   0.388      0.829 0.152  0 0.848
#> GSM260898     3   0.000      0.986 0.000  0 1.000
#> GSM260901     3   0.000      0.986 0.000  0 1.000
#> GSM260904     3   0.000      0.986 0.000  0 1.000
#> GSM260907     3   0.000      0.986 0.000  0 1.000
#> GSM260910     3   0.000      0.986 0.000  0 1.000
#> GSM260918     2   0.000      1.000 0.000  1 0.000
#> GSM260921     2   0.000      1.000 0.000  1 0.000
#> GSM260924     2   0.000      1.000 0.000  1 0.000
#> GSM260929     2   0.000      1.000 0.000  1 0.000
#> GSM260932     2   0.000      1.000 0.000  1 0.000
#> GSM260935     2   0.000      1.000 0.000  1 0.000
#> GSM260938     2   0.000      1.000 0.000  1 0.000
#> GSM260941     2   0.000      1.000 0.000  1 0.000
#> GSM260944     2   0.000      1.000 0.000  1 0.000
#> GSM260947     2   0.000      1.000 0.000  1 0.000
#> GSM260952     2   0.000      1.000 0.000  1 0.000
#> GSM260914     1   0.000      1.000 1.000  0 0.000
#> GSM260916     1   0.000      1.000 1.000  0 0.000
#> GSM260919     1   0.000      1.000 1.000  0 0.000
#> GSM260922     1   0.000      1.000 1.000  0 0.000
#> GSM260925     1   0.000      1.000 1.000  0 0.000
#> GSM260927     1   0.000      1.000 1.000  0 0.000
#> GSM260930     1   0.000      1.000 1.000  0 0.000
#> GSM260933     1   0.000      1.000 1.000  0 0.000
#> GSM260936     1   0.000      1.000 1.000  0 0.000
#> GSM260939     1   0.000      1.000 1.000  0 0.000
#> GSM260942     1   0.000      1.000 1.000  0 0.000
#> GSM260945     1   0.000      1.000 1.000  0 0.000
#> GSM260948     1   0.000      1.000 1.000  0 0.000
#> GSM260950     1   0.000      1.000 1.000  0 0.000
#> GSM260915     3   0.000      0.986 0.000  0 1.000
#> GSM260917     3   0.000      0.986 0.000  0 1.000
#> GSM260920     3   0.000      0.986 0.000  0 1.000
#> GSM260923     3   0.000      0.986 0.000  0 1.000
#> GSM260926     3   0.000      0.986 0.000  0 1.000
#> GSM260928     3   0.388      0.829 0.152  0 0.848
#> GSM260931     3   0.000      0.986 0.000  0 1.000
#> GSM260934     3   0.000      0.986 0.000  0 1.000
#> GSM260937     3   0.000      0.986 0.000  0 1.000
#> GSM260940     3   0.000      0.986 0.000  0 1.000
#> GSM260943     3   0.000      0.986 0.000  0 1.000
#> GSM260946     3   0.000      0.986 0.000  0 1.000
#> GSM260949     3   0.000      0.986 0.000  0 1.000
#> GSM260951     3   0.000      0.986 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM260888     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260893     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260896     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260899     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260902     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260905     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260908     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260911     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260912     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260913     3  0.0000      0.996 0.000  0 1.000 0.000
#> GSM260886     1  0.0469      0.882 0.988  0 0.000 0.012
#> GSM260889     1  0.0000      0.884 1.000  0 0.000 0.000
#> GSM260891     1  0.1118      0.869 0.964  0 0.000 0.036
#> GSM260894     1  0.0188      0.884 0.996  0 0.000 0.004
#> GSM260897     1  0.3873      0.866 0.772  0 0.000 0.228
#> GSM260900     1  0.3873      0.866 0.772  0 0.000 0.228
#> GSM260903     1  0.3873      0.866 0.772  0 0.000 0.228
#> GSM260906     1  0.3873      0.866 0.772  0 0.000 0.228
#> GSM260909     1  0.0188      0.884 0.996  0 0.000 0.004
#> GSM260887     3  0.0000      0.996 0.000  0 1.000 0.000
#> GSM260890     3  0.0000      0.996 0.000  0 1.000 0.000
#> GSM260892     3  0.0000      0.996 0.000  0 1.000 0.000
#> GSM260895     4  0.4453      1.000 0.012  0 0.244 0.744
#> GSM260898     3  0.0188      0.996 0.000  0 0.996 0.004
#> GSM260901     3  0.0188      0.996 0.000  0 0.996 0.004
#> GSM260904     3  0.0188      0.996 0.000  0 0.996 0.004
#> GSM260907     3  0.0188      0.996 0.000  0 0.996 0.004
#> GSM260910     3  0.0000      0.996 0.000  0 1.000 0.000
#> GSM260918     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260921     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260924     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260929     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260932     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260935     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260938     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260941     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260944     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260947     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260952     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM260914     1  0.0336      0.882 0.992  0 0.000 0.008
#> GSM260916     1  0.0817      0.876 0.976  0 0.000 0.024
#> GSM260919     1  0.0592      0.880 0.984  0 0.000 0.016
#> GSM260922     1  0.0921      0.874 0.972  0 0.000 0.028
#> GSM260925     1  0.0336      0.882 0.992  0 0.000 0.008
#> GSM260927     1  0.0188      0.885 0.996  0 0.000 0.004
#> GSM260930     1  0.3873      0.866 0.772  0 0.000 0.228
#> GSM260933     1  0.3873      0.866 0.772  0 0.000 0.228
#> GSM260936     1  0.3873      0.866 0.772  0 0.000 0.228
#> GSM260939     1  0.3873      0.866 0.772  0 0.000 0.228
#> GSM260942     1  0.3873      0.866 0.772  0 0.000 0.228
#> GSM260945     1  0.3873      0.866 0.772  0 0.000 0.228
#> GSM260948     1  0.1474      0.886 0.948  0 0.000 0.052
#> GSM260950     1  0.1940      0.885 0.924  0 0.000 0.076
#> GSM260915     3  0.0000      0.996 0.000  0 1.000 0.000
#> GSM260917     3  0.0000      0.996 0.000  0 1.000 0.000
#> GSM260920     3  0.0000      0.996 0.000  0 1.000 0.000
#> GSM260923     3  0.0000      0.996 0.000  0 1.000 0.000
#> GSM260926     3  0.0000      0.996 0.000  0 1.000 0.000
#> GSM260928     4  0.4453      1.000 0.012  0 0.244 0.744
#> GSM260931     3  0.0188      0.996 0.000  0 0.996 0.004
#> GSM260934     3  0.0188      0.996 0.000  0 0.996 0.004
#> GSM260937     3  0.0817      0.972 0.000  0 0.976 0.024
#> GSM260940     3  0.0188      0.996 0.000  0 0.996 0.004
#> GSM260943     3  0.0188      0.996 0.000  0 0.996 0.004
#> GSM260946     3  0.0188      0.996 0.000  0 0.996 0.004
#> GSM260949     3  0.0000      0.996 0.000  0 1.000 0.000
#> GSM260951     3  0.0000      0.996 0.000  0 1.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
#> GSM260888     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260893     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260896     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260899     2  0.0162      0.998 0.000 0.996 0.000 0.000 0.004
#> GSM260902     2  0.0162      0.998 0.000 0.996 0.000 0.000 0.004
#> GSM260905     2  0.0162      0.998 0.000 0.996 0.000 0.000 0.004
#> GSM260908     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260911     2  0.0162      0.998 0.000 0.996 0.000 0.000 0.004
#> GSM260912     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260913     3  0.0000      0.885 0.000 0.000 1.000 0.000 0.000
#> GSM260886     1  0.0865      0.949 0.972 0.000 0.000 0.024 0.004
#> GSM260889     1  0.0162      0.969 0.996 0.000 0.000 0.000 0.004
#> GSM260891     1  0.0290      0.963 0.992 0.000 0.000 0.008 0.000
#> GSM260894     1  0.0162      0.969 0.996 0.000 0.000 0.000 0.004
#> GSM260897     5  0.2648      0.998 0.152 0.000 0.000 0.000 0.848
#> GSM260900     5  0.2690      0.996 0.156 0.000 0.000 0.000 0.844
#> GSM260903     5  0.2690      0.996 0.156 0.000 0.000 0.000 0.844
#> GSM260906     5  0.2690      0.996 0.156 0.000 0.000 0.000 0.844
#> GSM260909     1  0.0162      0.969 0.996 0.000 0.000 0.000 0.004
#> GSM260887     3  0.0000      0.885 0.000 0.000 1.000 0.000 0.000
#> GSM260890     3  0.0000      0.885 0.000 0.000 1.000 0.000 0.000
#> GSM260892     3  0.0000      0.885 0.000 0.000 1.000 0.000 0.000
#> GSM260895     4  0.1768      0.876 0.004 0.000 0.072 0.924 0.000
#> GSM260898     3  0.4197      0.841 0.000 0.000 0.776 0.076 0.148
#> GSM260901     3  0.4197      0.841 0.000 0.000 0.776 0.076 0.148
#> GSM260904     3  0.4017      0.844 0.000 0.000 0.788 0.064 0.148
#> GSM260907     3  0.4197      0.841 0.000 0.000 0.776 0.076 0.148
#> GSM260910     3  0.0000      0.885 0.000 0.000 1.000 0.000 0.000
#> GSM260918     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260921     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260924     2  0.0162      0.998 0.000 0.996 0.000 0.000 0.004
#> GSM260929     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260932     2  0.0162      0.998 0.000 0.996 0.000 0.000 0.004
#> GSM260935     2  0.0162      0.998 0.000 0.996 0.000 0.000 0.004
#> GSM260938     2  0.0162      0.998 0.000 0.996 0.000 0.000 0.004
#> GSM260941     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260944     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260947     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260952     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM260914     1  0.0162      0.969 0.996 0.000 0.000 0.000 0.004
#> GSM260916     1  0.0162      0.966 0.996 0.000 0.000 0.004 0.000
#> GSM260919     1  0.0162      0.969 0.996 0.000 0.000 0.000 0.004
#> GSM260922     1  0.0162      0.966 0.996 0.000 0.000 0.004 0.000
#> GSM260925     1  0.0324      0.967 0.992 0.000 0.000 0.004 0.004
#> GSM260927     1  0.0290      0.967 0.992 0.000 0.000 0.000 0.008
#> GSM260930     5  0.2690      0.996 0.156 0.000 0.000 0.000 0.844
#> GSM260933     5  0.2648      0.998 0.152 0.000 0.000 0.000 0.848
#> GSM260936     5  0.2648      0.998 0.152 0.000 0.000 0.000 0.848
#> GSM260939     5  0.2648      0.998 0.152 0.000 0.000 0.000 0.848
#> GSM260942     5  0.2648      0.998 0.152 0.000 0.000 0.000 0.848
#> GSM260945     5  0.2648      0.998 0.152 0.000 0.000 0.000 0.848
#> GSM260948     1  0.1965      0.875 0.904 0.000 0.000 0.000 0.096
#> GSM260950     1  0.2690      0.794 0.844 0.000 0.000 0.000 0.156
#> GSM260915     3  0.0000      0.885 0.000 0.000 1.000 0.000 0.000
#> GSM260917     3  0.0000      0.885 0.000 0.000 1.000 0.000 0.000
#> GSM260920     3  0.0162      0.884 0.000 0.000 0.996 0.004 0.000
#> GSM260923     3  0.0162      0.884 0.000 0.000 0.996 0.004 0.000
#> GSM260926     3  0.0162      0.884 0.000 0.000 0.996 0.004 0.000
#> GSM260928     4  0.1768      0.876 0.004 0.000 0.072 0.924 0.000
#> GSM260931     3  0.4197      0.841 0.000 0.000 0.776 0.076 0.148
#> GSM260934     3  0.4197      0.841 0.000 0.000 0.776 0.076 0.148
#> GSM260937     4  0.3452      0.753 0.000 0.000 0.032 0.820 0.148
#> GSM260940     3  0.4197      0.841 0.000 0.000 0.776 0.076 0.148
#> GSM260943     3  0.4197      0.841 0.000 0.000 0.776 0.076 0.148
#> GSM260946     3  0.4197      0.841 0.000 0.000 0.776 0.076 0.148
#> GSM260949     3  0.0162      0.884 0.000 0.000 0.996 0.004 0.000
#> GSM260951     3  0.0162      0.885 0.000 0.000 0.996 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
#> GSM260888     2  0.0547      0.973 0.000 0.980 0.000 0.000 0.000 0.020
#> GSM260893     2  0.0790      0.975 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM260896     2  0.0547      0.973 0.000 0.980 0.000 0.000 0.000 0.020
#> GSM260899     6  0.0632      0.957 0.000 0.024 0.000 0.000 0.000 0.976
#> GSM260902     6  0.1007      0.958 0.000 0.044 0.000 0.000 0.000 0.956
#> GSM260905     6  0.2340      0.871 0.000 0.148 0.000 0.000 0.000 0.852
#> GSM260908     6  0.2340      0.884 0.000 0.148 0.000 0.000 0.000 0.852
#> GSM260911     2  0.0713      0.965 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM260912     2  0.0790      0.975 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM260913     4  0.0146      0.928 0.000 0.000 0.004 0.996 0.000 0.000
#> GSM260886     1  0.0260      0.976 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260889     1  0.0260      0.976 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260891     1  0.0260      0.971 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260894     1  0.0260      0.976 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260897     5  0.2631      0.995 0.180 0.000 0.000 0.000 0.820 0.000
#> GSM260900     5  0.2631      0.995 0.180 0.000 0.000 0.000 0.820 0.000
#> GSM260903     5  0.2631      0.995 0.180 0.000 0.000 0.000 0.820 0.000
#> GSM260906     5  0.2631      0.995 0.180 0.000 0.000 0.000 0.820 0.000
#> GSM260909     1  0.0146      0.974 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260887     4  0.0000      0.931 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260890     4  0.0000      0.931 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260892     4  0.0000      0.931 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260895     4  0.5010      0.661 0.004 0.000 0.160 0.672 0.160 0.004
#> GSM260898     3  0.2454      0.952 0.000 0.000 0.840 0.160 0.000 0.000
#> GSM260901     3  0.2527      0.950 0.000 0.000 0.832 0.168 0.000 0.000
#> GSM260904     3  0.3076      0.880 0.000 0.000 0.760 0.240 0.000 0.000
#> GSM260907     3  0.2491      0.954 0.000 0.000 0.836 0.164 0.000 0.000
#> GSM260910     4  0.0000      0.931 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260918     2  0.0790      0.975 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM260921     2  0.0632      0.974 0.000 0.976 0.000 0.000 0.000 0.024
#> GSM260924     2  0.0713      0.965 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM260929     2  0.0790      0.975 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM260932     6  0.0547      0.956 0.000 0.020 0.000 0.000 0.000 0.980
#> GSM260935     6  0.0937      0.959 0.000 0.040 0.000 0.000 0.000 0.960
#> GSM260938     6  0.1053      0.945 0.000 0.012 0.004 0.000 0.020 0.964
#> GSM260941     6  0.0713      0.960 0.000 0.028 0.000 0.000 0.000 0.972
#> GSM260944     6  0.0937      0.958 0.000 0.040 0.000 0.000 0.000 0.960
#> GSM260947     6  0.0937      0.958 0.000 0.040 0.000 0.000 0.000 0.960
#> GSM260952     2  0.0790      0.975 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM260914     1  0.0260      0.976 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260916     1  0.0146      0.973 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260919     1  0.0458      0.973 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM260922     1  0.0260      0.971 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260925     1  0.0260      0.976 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260927     1  0.0363      0.974 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM260930     5  0.2631      0.995 0.180 0.000 0.000 0.000 0.820 0.000
#> GSM260933     5  0.2631      0.995 0.180 0.000 0.000 0.000 0.820 0.000
#> GSM260936     5  0.2527      0.989 0.168 0.000 0.000 0.000 0.832 0.000
#> GSM260939     5  0.2527      0.989 0.168 0.000 0.000 0.000 0.832 0.000
#> GSM260942     5  0.2527      0.989 0.168 0.000 0.000 0.000 0.832 0.000
#> GSM260945     5  0.2631      0.995 0.180 0.000 0.000 0.000 0.820 0.000
#> GSM260948     1  0.1501      0.910 0.924 0.000 0.000 0.000 0.076 0.000
#> GSM260950     1  0.2135      0.842 0.872 0.000 0.000 0.000 0.128 0.000
#> GSM260915     4  0.0000      0.931 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260917     4  0.1075      0.891 0.000 0.000 0.048 0.952 0.000 0.000
#> GSM260920     4  0.0146      0.930 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM260923     4  0.0146      0.930 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM260926     4  0.0146      0.930 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM260928     4  0.5010      0.661 0.004 0.000 0.160 0.672 0.160 0.004
#> GSM260931     3  0.2491      0.954 0.000 0.000 0.836 0.164 0.000 0.000
#> GSM260934     3  0.2491      0.954 0.000 0.000 0.836 0.164 0.000 0.000
#> GSM260937     3  0.2398      0.773 0.000 0.000 0.876 0.104 0.020 0.000
#> GSM260940     3  0.3161      0.904 0.000 0.000 0.776 0.216 0.008 0.000
#> GSM260943     3  0.2491      0.954 0.000 0.000 0.836 0.164 0.000 0.000
#> GSM260946     3  0.2491      0.954 0.000 0.000 0.836 0.164 0.000 0.000
#> GSM260949     4  0.0000      0.931 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM260951     4  0.1957      0.819 0.000 0.000 0.112 0.888 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) cell.type(p) k
#> MAD:mclust 67            0.939     2.75e-14 2
#> MAD:mclust 67            0.927     9.68e-27 3
#> MAD:mclust 67            0.975     3.11e-25 4
#> MAD:mclust 67            0.993     6.72e-24 5
#> MAD:mclust 67            0.996     1.02e-22 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 21168 rows and 67 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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.561           0.746       0.879         0.4681 0.506   0.506
#> 3 3 1.000           0.979       0.993         0.4423 0.750   0.538
#> 4 4 0.912           0.825       0.933         0.0505 0.970   0.910
#> 5 5 0.919           0.859       0.931         0.0175 0.980   0.937
#> 6 6 0.883           0.804       0.909         0.0265 0.970   0.903

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM260888     2   0.000     0.7865 0.000 1.000
#> GSM260893     2   0.000     0.7865 0.000 1.000
#> GSM260896     2   0.000     0.7865 0.000 1.000
#> GSM260899     2   0.000     0.7865 0.000 1.000
#> GSM260902     2   0.000     0.7865 0.000 1.000
#> GSM260905     2   0.000     0.7865 0.000 1.000
#> GSM260908     2   0.000     0.7865 0.000 1.000
#> GSM260911     2   0.000     0.7865 0.000 1.000
#> GSM260912     2   0.000     0.7865 0.000 1.000
#> GSM260913     2   0.966     0.5867 0.392 0.608
#> GSM260886     1   0.000     0.9318 1.000 0.000
#> GSM260889     1   0.000     0.9318 1.000 0.000
#> GSM260891     1   0.000     0.9318 1.000 0.000
#> GSM260894     1   0.000     0.9318 1.000 0.000
#> GSM260897     1   0.000     0.9318 1.000 0.000
#> GSM260900     1   0.000     0.9318 1.000 0.000
#> GSM260903     1   0.000     0.9318 1.000 0.000
#> GSM260906     1   0.000     0.9318 1.000 0.000
#> GSM260909     1   0.000     0.9318 1.000 0.000
#> GSM260887     2   0.939     0.6334 0.356 0.644
#> GSM260890     2   0.900     0.6698 0.316 0.684
#> GSM260892     2   0.932     0.6418 0.348 0.652
#> GSM260895     1   0.000     0.9318 1.000 0.000
#> GSM260898     1   1.000    -0.3586 0.504 0.496
#> GSM260901     2   0.998     0.4144 0.472 0.528
#> GSM260904     2   0.996     0.4358 0.464 0.536
#> GSM260907     2   0.973     0.5667 0.404 0.596
#> GSM260910     2   0.917     0.6571 0.332 0.668
#> GSM260918     2   0.000     0.7865 0.000 1.000
#> GSM260921     2   0.000     0.7865 0.000 1.000
#> GSM260924     2   0.000     0.7865 0.000 1.000
#> GSM260929     2   0.000     0.7865 0.000 1.000
#> GSM260932     2   0.000     0.7865 0.000 1.000
#> GSM260935     2   0.000     0.7865 0.000 1.000
#> GSM260938     2   0.000     0.7865 0.000 1.000
#> GSM260941     2   0.000     0.7865 0.000 1.000
#> GSM260944     2   0.000     0.7865 0.000 1.000
#> GSM260947     2   0.000     0.7865 0.000 1.000
#> GSM260952     2   0.000     0.7865 0.000 1.000
#> GSM260914     1   0.000     0.9318 1.000 0.000
#> GSM260916     1   0.000     0.9318 1.000 0.000
#> GSM260919     1   0.000     0.9318 1.000 0.000
#> GSM260922     1   0.000     0.9318 1.000 0.000
#> GSM260925     1   0.000     0.9318 1.000 0.000
#> GSM260927     1   0.000     0.9318 1.000 0.000
#> GSM260930     1   0.000     0.9318 1.000 0.000
#> GSM260933     1   0.000     0.9318 1.000 0.000
#> GSM260936     1   0.000     0.9318 1.000 0.000
#> GSM260939     1   0.000     0.9318 1.000 0.000
#> GSM260942     1   0.000     0.9318 1.000 0.000
#> GSM260945     1   0.000     0.9318 1.000 0.000
#> GSM260948     1   0.000     0.9318 1.000 0.000
#> GSM260950     1   0.000     0.9318 1.000 0.000
#> GSM260915     2   0.981     0.5364 0.420 0.580
#> GSM260917     2   0.891     0.6754 0.308 0.692
#> GSM260920     2   0.855     0.6923 0.280 0.720
#> GSM260923     1   0.994    -0.2288 0.544 0.456
#> GSM260926     2   0.653     0.7405 0.168 0.832
#> GSM260928     1   0.000     0.9318 1.000 0.000
#> GSM260931     2   0.963     0.5927 0.388 0.612
#> GSM260934     2   0.961     0.5984 0.384 0.616
#> GSM260937     2   0.969     0.5806 0.396 0.604
#> GSM260940     1   0.966     0.0258 0.608 0.392
#> GSM260943     2   0.917     0.6572 0.332 0.668
#> GSM260946     2   0.987     0.5116 0.432 0.568
#> GSM260949     2   0.788     0.7141 0.236 0.764
#> GSM260951     2   0.949     0.6193 0.368 0.632

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM260888     2   0.000      1.000 0.000  1 0.000
#> GSM260893     2   0.000      1.000 0.000  1 0.000
#> GSM260896     2   0.000      1.000 0.000  1 0.000
#> GSM260899     2   0.000      1.000 0.000  1 0.000
#> GSM260902     2   0.000      1.000 0.000  1 0.000
#> GSM260905     2   0.000      1.000 0.000  1 0.000
#> GSM260908     2   0.000      1.000 0.000  1 0.000
#> GSM260911     2   0.000      1.000 0.000  1 0.000
#> GSM260912     2   0.000      1.000 0.000  1 0.000
#> GSM260913     3   0.000      0.999 0.000  0 1.000
#> GSM260886     1   0.000      0.979 1.000  0 0.000
#> GSM260889     1   0.000      0.979 1.000  0 0.000
#> GSM260891     1   0.000      0.979 1.000  0 0.000
#> GSM260894     1   0.000      0.979 1.000  0 0.000
#> GSM260897     1   0.000      0.979 1.000  0 0.000
#> GSM260900     1   0.000      0.979 1.000  0 0.000
#> GSM260903     1   0.000      0.979 1.000  0 0.000
#> GSM260906     1   0.000      0.979 1.000  0 0.000
#> GSM260909     1   0.000      0.979 1.000  0 0.000
#> GSM260887     3   0.000      0.999 0.000  0 1.000
#> GSM260890     3   0.000      0.999 0.000  0 1.000
#> GSM260892     3   0.000      0.999 0.000  0 1.000
#> GSM260895     3   0.103      0.975 0.024  0 0.976
#> GSM260898     3   0.000      0.999 0.000  0 1.000
#> GSM260901     3   0.000      0.999 0.000  0 1.000
#> GSM260904     3   0.000      0.999 0.000  0 1.000
#> GSM260907     3   0.000      0.999 0.000  0 1.000
#> GSM260910     3   0.000      0.999 0.000  0 1.000
#> GSM260918     2   0.000      1.000 0.000  1 0.000
#> GSM260921     2   0.000      1.000 0.000  1 0.000
#> GSM260924     2   0.000      1.000 0.000  1 0.000
#> GSM260929     2   0.000      1.000 0.000  1 0.000
#> GSM260932     2   0.000      1.000 0.000  1 0.000
#> GSM260935     2   0.000      1.000 0.000  1 0.000
#> GSM260938     2   0.000      1.000 0.000  1 0.000
#> GSM260941     2   0.000      1.000 0.000  1 0.000
#> GSM260944     2   0.000      1.000 0.000  1 0.000
#> GSM260947     2   0.000      1.000 0.000  1 0.000
#> GSM260952     2   0.000      1.000 0.000  1 0.000
#> GSM260914     1   0.000      0.979 1.000  0 0.000
#> GSM260916     1   0.000      0.979 1.000  0 0.000
#> GSM260919     1   0.000      0.979 1.000  0 0.000
#> GSM260922     1   0.000      0.979 1.000  0 0.000
#> GSM260925     1   0.000      0.979 1.000  0 0.000
#> GSM260927     1   0.000      0.979 1.000  0 0.000
#> GSM260930     1   0.000      0.979 1.000  0 0.000
#> GSM260933     1   0.000      0.979 1.000  0 0.000
#> GSM260936     1   0.000      0.979 1.000  0 0.000
#> GSM260939     1   0.000      0.979 1.000  0 0.000
#> GSM260942     1   0.000      0.979 1.000  0 0.000
#> GSM260945     1   0.000      0.979 1.000  0 0.000
#> GSM260948     1   0.000      0.979 1.000  0 0.000
#> GSM260950     1   0.000      0.979 1.000  0 0.000
#> GSM260915     3   0.000      0.999 0.000  0 1.000
#> GSM260917     3   0.000      0.999 0.000  0 1.000
#> GSM260920     3   0.000      0.999 0.000  0 1.000
#> GSM260923     3   0.000      0.999 0.000  0 1.000
#> GSM260926     3   0.000      0.999 0.000  0 1.000
#> GSM260928     1   0.630      0.103 0.528  0 0.472
#> GSM260931     3   0.000      0.999 0.000  0 1.000
#> GSM260934     3   0.000      0.999 0.000  0 1.000
#> GSM260937     3   0.000      0.999 0.000  0 1.000
#> GSM260940     3   0.000      0.999 0.000  0 1.000
#> GSM260943     3   0.000      0.999 0.000  0 1.000
#> GSM260946     3   0.000      0.999 0.000  0 1.000
#> GSM260949     3   0.000      0.999 0.000  0 1.000
#> GSM260951     3   0.000      0.999 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM260888     2  0.0188      0.996 0.000 0.996 0.000 0.004
#> GSM260893     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260896     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260899     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260902     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260905     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260908     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260911     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260912     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260913     3  0.0592      0.829 0.000 0.000 0.984 0.016
#> GSM260886     1  0.2011      0.886 0.920 0.000 0.000 0.080
#> GSM260889     1  0.0707      0.905 0.980 0.000 0.000 0.020
#> GSM260891     1  0.3356      0.823 0.824 0.000 0.000 0.176
#> GSM260894     1  0.0817      0.905 0.976 0.000 0.000 0.024
#> GSM260897     1  0.1792      0.893 0.932 0.000 0.000 0.068
#> GSM260900     1  0.1118      0.903 0.964 0.000 0.000 0.036
#> GSM260903     1  0.1211      0.902 0.960 0.000 0.000 0.040
#> GSM260906     1  0.1118      0.903 0.964 0.000 0.000 0.036
#> GSM260909     1  0.2011      0.886 0.920 0.000 0.000 0.080
#> GSM260887     3  0.0188      0.836 0.000 0.000 0.996 0.004
#> GSM260890     3  0.0336      0.835 0.000 0.000 0.992 0.008
#> GSM260892     3  0.3688      0.491 0.000 0.000 0.792 0.208
#> GSM260895     3  0.6055     -0.178 0.044 0.000 0.520 0.436
#> GSM260898     3  0.0469      0.831 0.000 0.000 0.988 0.012
#> GSM260901     3  0.0817      0.821 0.000 0.000 0.976 0.024
#> GSM260904     3  0.0000      0.836 0.000 0.000 1.000 0.000
#> GSM260907     3  0.0188      0.835 0.000 0.000 0.996 0.004
#> GSM260910     3  0.2921      0.637 0.000 0.000 0.860 0.140
#> GSM260918     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260921     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260924     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260929     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260932     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260935     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260938     2  0.0188      0.996 0.000 0.996 0.000 0.004
#> GSM260941     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260944     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260947     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260952     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM260914     1  0.1389      0.899 0.952 0.000 0.000 0.048
#> GSM260916     1  0.4477      0.690 0.688 0.000 0.000 0.312
#> GSM260919     1  0.0707      0.905 0.980 0.000 0.000 0.020
#> GSM260922     1  0.4454      0.695 0.692 0.000 0.000 0.308
#> GSM260925     1  0.1389      0.899 0.952 0.000 0.000 0.048
#> GSM260927     1  0.0188      0.907 0.996 0.000 0.000 0.004
#> GSM260930     1  0.1118      0.903 0.964 0.000 0.000 0.036
#> GSM260933     1  0.1302      0.901 0.956 0.000 0.000 0.044
#> GSM260936     1  0.3528      0.808 0.808 0.000 0.000 0.192
#> GSM260939     1  0.4661      0.629 0.652 0.000 0.000 0.348
#> GSM260942     1  0.4103      0.744 0.744 0.000 0.000 0.256
#> GSM260945     1  0.2011      0.887 0.920 0.000 0.000 0.080
#> GSM260948     1  0.0000      0.907 1.000 0.000 0.000 0.000
#> GSM260950     1  0.0000      0.907 1.000 0.000 0.000 0.000
#> GSM260915     3  0.0188      0.836 0.000 0.000 0.996 0.004
#> GSM260917     3  0.0000      0.836 0.000 0.000 1.000 0.000
#> GSM260920     3  0.0188      0.836 0.000 0.000 0.996 0.004
#> GSM260923     3  0.0707      0.825 0.000 0.000 0.980 0.020
#> GSM260926     3  0.0188      0.836 0.000 0.000 0.996 0.004
#> GSM260928     3  0.5220     -0.164 0.424 0.000 0.568 0.008
#> GSM260931     3  0.0592      0.828 0.000 0.000 0.984 0.016
#> GSM260934     3  0.0469      0.831 0.000 0.000 0.988 0.012
#> GSM260937     4  0.4992      0.000 0.000 0.000 0.476 0.524
#> GSM260940     3  0.4304     -0.129 0.000 0.000 0.716 0.284
#> GSM260943     3  0.1211      0.798 0.000 0.000 0.960 0.040
#> GSM260946     3  0.0707      0.825 0.000 0.000 0.980 0.020
#> GSM260949     3  0.0188      0.836 0.000 0.000 0.996 0.004
#> GSM260951     3  0.0188      0.835 0.000 0.000 0.996 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
#> GSM260888     2  0.0162      0.991 0.000 0.996 0.000 0.004 NA
#> GSM260893     2  0.0162      0.991 0.000 0.996 0.000 0.004 NA
#> GSM260896     2  0.0162      0.991 0.000 0.996 0.000 0.004 NA
#> GSM260899     2  0.1410      0.951 0.000 0.940 0.000 0.000 NA
#> GSM260902     2  0.0609      0.980 0.000 0.980 0.000 0.000 NA
#> GSM260905     2  0.0000      0.991 0.000 1.000 0.000 0.000 NA
#> GSM260908     2  0.0000      0.991 0.000 1.000 0.000 0.000 NA
#> GSM260911     2  0.0162      0.991 0.000 0.996 0.000 0.004 NA
#> GSM260912     2  0.0162      0.991 0.000 0.996 0.000 0.004 NA
#> GSM260913     3  0.0162      0.820 0.000 0.000 0.996 0.000 NA
#> GSM260886     1  0.0703      0.953 0.976 0.000 0.000 0.000 NA
#> GSM260889     1  0.0162      0.958 0.996 0.000 0.000 0.000 NA
#> GSM260891     1  0.1251      0.943 0.956 0.000 0.000 0.008 NA
#> GSM260894     1  0.0290      0.958 0.992 0.000 0.000 0.000 NA
#> GSM260897     1  0.1270      0.946 0.948 0.000 0.000 0.000 NA
#> GSM260900     1  0.0510      0.957 0.984 0.000 0.000 0.000 NA
#> GSM260903     1  0.0609      0.957 0.980 0.000 0.000 0.000 NA
#> GSM260906     1  0.0510      0.957 0.984 0.000 0.000 0.000 NA
#> GSM260909     1  0.0451      0.957 0.988 0.000 0.000 0.004 NA
#> GSM260887     3  0.0290      0.819 0.000 0.000 0.992 0.008 NA
#> GSM260890     3  0.1478      0.791 0.000 0.000 0.936 0.064 NA
#> GSM260892     3  0.5048      0.562 0.000 0.000 0.704 0.144 NA
#> GSM260895     3  0.4674      0.565 0.000 0.000 0.708 0.232 NA
#> GSM260898     3  0.0798      0.812 0.000 0.000 0.976 0.008 NA
#> GSM260901     3  0.1764      0.785 0.000 0.000 0.928 0.008 NA
#> GSM260904     3  0.0162      0.818 0.000 0.000 0.996 0.004 NA
#> GSM260907     3  0.0404      0.815 0.000 0.000 0.988 0.012 NA
#> GSM260910     3  0.3487      0.650 0.000 0.000 0.780 0.212 NA
#> GSM260918     2  0.0162      0.991 0.000 0.996 0.000 0.004 NA
#> GSM260921     2  0.0162      0.991 0.000 0.996 0.000 0.004 NA
#> GSM260924     2  0.0000      0.991 0.000 1.000 0.000 0.000 NA
#> GSM260929     2  0.0162      0.991 0.000 0.996 0.000 0.004 NA
#> GSM260932     2  0.1478      0.948 0.000 0.936 0.000 0.000 NA
#> GSM260935     2  0.0609      0.980 0.000 0.980 0.000 0.000 NA
#> GSM260938     2  0.0000      0.991 0.000 1.000 0.000 0.000 NA
#> GSM260941     2  0.0000      0.991 0.000 1.000 0.000 0.000 NA
#> GSM260944     2  0.0000      0.991 0.000 1.000 0.000 0.000 NA
#> GSM260947     2  0.0000      0.991 0.000 1.000 0.000 0.000 NA
#> GSM260952     2  0.0000      0.991 0.000 1.000 0.000 0.000 NA
#> GSM260914     1  0.0510      0.956 0.984 0.000 0.000 0.000 NA
#> GSM260916     1  0.3561      0.740 0.740 0.000 0.000 0.000 NA
#> GSM260919     1  0.0404      0.957 0.988 0.000 0.000 0.000 NA
#> GSM260922     1  0.4026      0.735 0.736 0.000 0.000 0.020 NA
#> GSM260925     1  0.0609      0.955 0.980 0.000 0.000 0.000 NA
#> GSM260927     1  0.0290      0.958 0.992 0.000 0.000 0.000 NA
#> GSM260930     1  0.0609      0.957 0.980 0.000 0.000 0.000 NA
#> GSM260933     1  0.0703      0.956 0.976 0.000 0.000 0.000 NA
#> GSM260936     1  0.1281      0.950 0.956 0.000 0.000 0.012 NA
#> GSM260939     1  0.2592      0.906 0.892 0.000 0.000 0.056 NA
#> GSM260942     1  0.1774      0.936 0.932 0.000 0.000 0.016 NA
#> GSM260945     1  0.0955      0.954 0.968 0.000 0.000 0.004 NA
#> GSM260948     1  0.0290      0.957 0.992 0.000 0.000 0.000 NA
#> GSM260950     1  0.0162      0.958 0.996 0.000 0.000 0.000 NA
#> GSM260915     3  0.0404      0.818 0.000 0.000 0.988 0.012 NA
#> GSM260917     3  0.0162      0.819 0.000 0.000 0.996 0.004 NA
#> GSM260920     3  0.0000      0.819 0.000 0.000 1.000 0.000 NA
#> GSM260923     3  0.2020      0.767 0.000 0.000 0.900 0.100 NA
#> GSM260926     3  0.0162      0.819 0.000 0.000 0.996 0.004 NA
#> GSM260928     3  0.5787      0.336 0.248 0.000 0.644 0.080 NA
#> GSM260931     3  0.3210      0.519 0.000 0.000 0.788 0.212 NA
#> GSM260934     3  0.0290      0.817 0.000 0.000 0.992 0.008 NA
#> GSM260937     4  0.3480      0.843 0.000 0.000 0.248 0.752 NA
#> GSM260940     4  0.4464      0.724 0.000 0.000 0.408 0.584 NA
#> GSM260943     4  0.3752      0.865 0.000 0.000 0.292 0.708 NA
#> GSM260946     3  0.3752      0.288 0.000 0.000 0.708 0.292 NA
#> GSM260949     3  0.0000      0.819 0.000 0.000 1.000 0.000 NA
#> GSM260951     3  0.4249     -0.329 0.000 0.000 0.568 0.432 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
#> GSM260888     2  0.0405     0.9366 0.000 0.988 0.004 0.000 0.000 NA
#> GSM260893     2  0.0405     0.9366 0.000 0.988 0.004 0.000 0.000 NA
#> GSM260896     2  0.0405     0.9366 0.000 0.988 0.004 0.000 0.000 NA
#> GSM260899     2  0.3747     0.5909 0.000 0.604 0.000 0.000 0.000 NA
#> GSM260902     2  0.2527     0.8435 0.000 0.832 0.000 0.000 0.000 NA
#> GSM260905     2  0.0146     0.9373 0.000 0.996 0.000 0.000 0.000 NA
#> GSM260908     2  0.0865     0.9297 0.000 0.964 0.000 0.000 0.000 NA
#> GSM260911     2  0.0405     0.9366 0.000 0.988 0.004 0.000 0.000 NA
#> GSM260912     2  0.0260     0.9373 0.000 0.992 0.000 0.000 0.000 NA
#> GSM260913     4  0.0993     0.8728 0.024 0.000 0.012 0.964 0.000 NA
#> GSM260886     5  0.1444     0.8739 0.072 0.000 0.000 0.000 0.928 NA
#> GSM260889     5  0.1141     0.8855 0.052 0.000 0.000 0.000 0.948 NA
#> GSM260891     5  0.2875     0.7817 0.052 0.000 0.000 0.000 0.852 NA
#> GSM260894     5  0.0937     0.8879 0.040 0.000 0.000 0.000 0.960 NA
#> GSM260897     5  0.1391     0.8688 0.040 0.000 0.000 0.000 0.944 NA
#> GSM260900     5  0.0260     0.8896 0.008 0.000 0.000 0.000 0.992 NA
#> GSM260903     5  0.0405     0.8893 0.008 0.000 0.000 0.000 0.988 NA
#> GSM260906     5  0.0508     0.8903 0.012 0.000 0.000 0.000 0.984 NA
#> GSM260909     5  0.1367     0.8869 0.044 0.000 0.000 0.000 0.944 NA
#> GSM260887     4  0.0146     0.8720 0.000 0.000 0.000 0.996 0.000 NA
#> GSM260890     4  0.0779     0.8686 0.008 0.000 0.008 0.976 0.000 NA
#> GSM260892     4  0.3487     0.6840 0.224 0.000 0.000 0.756 0.000 NA
#> GSM260895     4  0.3475     0.7688 0.104 0.000 0.008 0.828 0.008 NA
#> GSM260898     4  0.1003     0.8711 0.000 0.000 0.016 0.964 0.000 NA
#> GSM260901     4  0.1398     0.8583 0.000 0.000 0.008 0.940 0.000 NA
#> GSM260904     4  0.0692     0.8706 0.004 0.000 0.020 0.976 0.000 NA
#> GSM260907     4  0.0935     0.8670 0.004 0.000 0.032 0.964 0.000 NA
#> GSM260910     4  0.1149     0.8634 0.024 0.000 0.008 0.960 0.000 NA
#> GSM260918     2  0.0260     0.9373 0.000 0.992 0.000 0.000 0.000 NA
#> GSM260921     2  0.0146     0.9375 0.000 0.996 0.000 0.000 0.000 NA
#> GSM260924     2  0.0291     0.9371 0.000 0.992 0.004 0.000 0.000 NA
#> GSM260929     2  0.0146     0.9375 0.000 0.996 0.000 0.000 0.000 NA
#> GSM260932     2  0.3706     0.6135 0.000 0.620 0.000 0.000 0.000 NA
#> GSM260935     2  0.2482     0.8608 0.000 0.848 0.004 0.000 0.000 NA
#> GSM260938     2  0.1801     0.9133 0.004 0.924 0.016 0.000 0.000 NA
#> GSM260941     2  0.0692     0.9341 0.000 0.976 0.004 0.000 0.000 NA
#> GSM260944     2  0.1152     0.9257 0.000 0.952 0.004 0.000 0.000 NA
#> GSM260947     2  0.0405     0.9365 0.000 0.988 0.004 0.000 0.000 NA
#> GSM260952     2  0.0146     0.9373 0.000 0.996 0.000 0.000 0.000 NA
#> GSM260914     5  0.1556     0.8680 0.080 0.000 0.000 0.000 0.920 NA
#> GSM260916     5  0.3868    -0.6764 0.496 0.000 0.000 0.000 0.504 NA
#> GSM260919     5  0.1501     0.8781 0.076 0.000 0.000 0.000 0.924 NA
#> GSM260922     1  0.3684     0.0000 0.628 0.000 0.000 0.000 0.372 NA
#> GSM260925     5  0.1556     0.8684 0.080 0.000 0.000 0.000 0.920 NA
#> GSM260927     5  0.1333     0.8866 0.048 0.000 0.000 0.000 0.944 NA
#> GSM260930     5  0.0363     0.8894 0.012 0.000 0.000 0.000 0.988 NA
#> GSM260933     5  0.0858     0.8814 0.028 0.000 0.000 0.000 0.968 NA
#> GSM260936     5  0.1536     0.8613 0.020 0.000 0.024 0.000 0.944 NA
#> GSM260939     5  0.1693     0.8579 0.032 0.000 0.020 0.000 0.936 NA
#> GSM260942     5  0.1053     0.8791 0.020 0.000 0.004 0.000 0.964 NA
#> GSM260945     5  0.0622     0.8857 0.012 0.000 0.000 0.000 0.980 NA
#> GSM260948     5  0.1714     0.8604 0.092 0.000 0.000 0.000 0.908 NA
#> GSM260950     5  0.1141     0.8837 0.052 0.000 0.000 0.000 0.948 NA
#> GSM260915     4  0.0291     0.8715 0.004 0.000 0.000 0.992 0.000 NA
#> GSM260917     4  0.0547     0.8716 0.000 0.000 0.020 0.980 0.000 NA
#> GSM260920     4  0.1261     0.8686 0.024 0.000 0.024 0.952 0.000 NA
#> GSM260923     4  0.1010     0.8656 0.036 0.000 0.000 0.960 0.000 NA
#> GSM260926     4  0.0000     0.8720 0.000 0.000 0.000 1.000 0.000 NA
#> GSM260928     4  0.6042     0.2950 0.072 0.000 0.012 0.580 0.276 NA
#> GSM260931     4  0.3371     0.5557 0.000 0.000 0.292 0.708 0.000 NA
#> GSM260934     4  0.0806     0.8705 0.000 0.000 0.020 0.972 0.000 NA
#> GSM260937     3  0.1124     0.7628 0.000 0.000 0.956 0.036 0.000 NA
#> GSM260940     4  0.3971     0.0972 0.004 0.000 0.448 0.548 0.000 NA
#> GSM260943     3  0.2006     0.8181 0.004 0.000 0.892 0.104 0.000 NA
#> GSM260946     4  0.3221     0.6039 0.000 0.000 0.264 0.736 0.000 NA
#> GSM260949     4  0.0508     0.8720 0.012 0.000 0.004 0.984 0.000 NA
#> GSM260951     3  0.3314     0.7058 0.000 0.000 0.740 0.256 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-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) cell.type(p) k
#> MAD:NMF 62            1.000     1.38e-12 2
#> MAD:NMF 66            0.920     2.62e-26 3
#> MAD:NMF 62            0.927     1.47e-24 4
#> MAD:NMF 64            0.312     5.90e-24 5
#> MAD:NMF 63            0.401     1.40e-23 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 21168 rows and 67 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4257 0.575   0.575
#> 3 3 0.623           0.864       0.865         0.4317 0.791   0.637
#> 4 4 0.580           0.858       0.845         0.0759 0.955   0.876
#> 5 5 0.765           0.753       0.844         0.1051 0.972   0.915
#> 6 6 0.843           0.879       0.883         0.1025 0.864   0.575

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
#> GSM260888     2       0          1  0  1
#> GSM260893     2       0          1  0  1
#> GSM260896     2       0          1  0  1
#> GSM260899     2       0          1  0  1
#> GSM260902     2       0          1  0  1
#> GSM260905     2       0          1  0  1
#> GSM260908     2       0          1  0  1
#> GSM260911     2       0          1  0  1
#> GSM260912     2       0          1  0  1
#> GSM260913     1       0          1  1  0
#> GSM260886     1       0          1  1  0
#> GSM260889     1       0          1  1  0
#> GSM260891     1       0          1  1  0
#> GSM260894     1       0          1  1  0
#> GSM260897     1       0          1  1  0
#> GSM260900     1       0          1  1  0
#> GSM260903     1       0          1  1  0
#> GSM260906     1       0          1  1  0
#> GSM260909     1       0          1  1  0
#> GSM260887     1       0          1  1  0
#> GSM260890     1       0          1  1  0
#> GSM260892     1       0          1  1  0
#> GSM260895     1       0          1  1  0
#> GSM260898     1       0          1  1  0
#> GSM260901     1       0          1  1  0
#> GSM260904     1       0          1  1  0
#> GSM260907     1       0          1  1  0
#> GSM260910     1       0          1  1  0
#> GSM260918     2       0          1  0  1
#> GSM260921     2       0          1  0  1
#> GSM260924     2       0          1  0  1
#> GSM260929     2       0          1  0  1
#> GSM260932     2       0          1  0  1
#> GSM260935     2       0          1  0  1
#> GSM260938     2       0          1  0  1
#> GSM260941     2       0          1  0  1
#> GSM260944     2       0          1  0  1
#> GSM260947     2       0          1  0  1
#> GSM260952     2       0          1  0  1
#> GSM260914     1       0          1  1  0
#> GSM260916     1       0          1  1  0
#> GSM260919     1       0          1  1  0
#> GSM260922     1       0          1  1  0
#> GSM260925     1       0          1  1  0
#> GSM260927     1       0          1  1  0
#> GSM260930     1       0          1  1  0
#> GSM260933     1       0          1  1  0
#> GSM260936     1       0          1  1  0
#> GSM260939     1       0          1  1  0
#> GSM260942     1       0          1  1  0
#> GSM260945     1       0          1  1  0
#> GSM260948     1       0          1  1  0
#> GSM260950     1       0          1  1  0
#> GSM260915     1       0          1  1  0
#> GSM260917     1       0          1  1  0
#> GSM260920     1       0          1  1  0
#> GSM260923     1       0          1  1  0
#> GSM260926     1       0          1  1  0
#> GSM260928     1       0          1  1  0
#> GSM260931     1       0          1  1  0
#> GSM260934     1       0          1  1  0
#> GSM260937     1       0          1  1  0
#> GSM260940     1       0          1  1  0
#> GSM260943     1       0          1  1  0
#> GSM260946     1       0          1  1  0
#> GSM260949     1       0          1  1  0
#> GSM260951     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM260888     2   0.000      1.000 0.000  1 0.000
#> GSM260893     2   0.000      1.000 0.000  1 0.000
#> GSM260896     2   0.000      1.000 0.000  1 0.000
#> GSM260899     2   0.000      1.000 0.000  1 0.000
#> GSM260902     2   0.000      1.000 0.000  1 0.000
#> GSM260905     2   0.000      1.000 0.000  1 0.000
#> GSM260908     2   0.000      1.000 0.000  1 0.000
#> GSM260911     2   0.000      1.000 0.000  1 0.000
#> GSM260912     2   0.000      1.000 0.000  1 0.000
#> GSM260913     3   0.429      0.897 0.180  0 0.820
#> GSM260886     1   0.319      0.846 0.888  0 0.112
#> GSM260889     1   0.319      0.846 0.888  0 0.112
#> GSM260891     1   0.319      0.846 0.888  0 0.112
#> GSM260894     1   0.319      0.846 0.888  0 0.112
#> GSM260897     1   0.000      0.839 1.000  0 0.000
#> GSM260900     1   0.000      0.839 1.000  0 0.000
#> GSM260903     1   0.000      0.839 1.000  0 0.000
#> GSM260906     1   0.000      0.839 1.000  0 0.000
#> GSM260909     1   0.319      0.846 0.888  0 0.112
#> GSM260887     3   0.435      0.896 0.184  0 0.816
#> GSM260890     3   0.429      0.897 0.180  0 0.820
#> GSM260892     3   0.000      0.708 0.000  0 1.000
#> GSM260895     1   0.319      0.846 0.888  0 0.112
#> GSM260898     1   0.465      0.637 0.792  0 0.208
#> GSM260901     1   0.465      0.637 0.792  0 0.208
#> GSM260904     1   0.465      0.637 0.792  0 0.208
#> GSM260907     1   0.465      0.637 0.792  0 0.208
#> GSM260910     3   0.429      0.897 0.180  0 0.820
#> GSM260918     2   0.000      1.000 0.000  1 0.000
#> GSM260921     2   0.000      1.000 0.000  1 0.000
#> GSM260924     2   0.000      1.000 0.000  1 0.000
#> GSM260929     2   0.000      1.000 0.000  1 0.000
#> GSM260932     2   0.000      1.000 0.000  1 0.000
#> GSM260935     2   0.000      1.000 0.000  1 0.000
#> GSM260938     2   0.000      1.000 0.000  1 0.000
#> GSM260941     2   0.000      1.000 0.000  1 0.000
#> GSM260944     2   0.000      1.000 0.000  1 0.000
#> GSM260947     2   0.000      1.000 0.000  1 0.000
#> GSM260952     2   0.000      1.000 0.000  1 0.000
#> GSM260914     1   0.319      0.846 0.888  0 0.112
#> GSM260916     1   0.319      0.846 0.888  0 0.112
#> GSM260919     1   0.319      0.846 0.888  0 0.112
#> GSM260922     1   0.319      0.846 0.888  0 0.112
#> GSM260925     1   0.319      0.846 0.888  0 0.112
#> GSM260927     1   0.319      0.846 0.888  0 0.112
#> GSM260930     1   0.000      0.839 1.000  0 0.000
#> GSM260933     1   0.000      0.839 1.000  0 0.000
#> GSM260936     1   0.000      0.839 1.000  0 0.000
#> GSM260939     1   0.000      0.839 1.000  0 0.000
#> GSM260942     1   0.000      0.839 1.000  0 0.000
#> GSM260945     1   0.000      0.839 1.000  0 0.000
#> GSM260948     1   0.319      0.846 0.888  0 0.112
#> GSM260950     1   0.319      0.846 0.888  0 0.112
#> GSM260915     3   0.470      0.879 0.212  0 0.788
#> GSM260917     3   0.435      0.896 0.184  0 0.816
#> GSM260920     3   0.621      0.552 0.428  0 0.572
#> GSM260923     3   0.429      0.897 0.180  0 0.820
#> GSM260926     3   0.470      0.879 0.212  0 0.788
#> GSM260928     1   0.319      0.846 0.888  0 0.112
#> GSM260931     1   0.465      0.637 0.792  0 0.208
#> GSM260934     1   0.465      0.637 0.792  0 0.208
#> GSM260937     3   0.576      0.801 0.328  0 0.672
#> GSM260940     1   0.465      0.637 0.792  0 0.208
#> GSM260943     3   0.576      0.801 0.328  0 0.672
#> GSM260946     1   0.465      0.637 0.792  0 0.208
#> GSM260949     3   0.429      0.897 0.180  0 0.820
#> GSM260951     3   0.576      0.801 0.328  0 0.672

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM260888     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM260893     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM260896     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM260899     2   0.253      1.000 0.000 0.888 0.000 0.112
#> GSM260902     2   0.253      1.000 0.000 0.888 0.000 0.112
#> GSM260905     2   0.253      1.000 0.000 0.888 0.000 0.112
#> GSM260908     2   0.253      1.000 0.000 0.888 0.000 0.112
#> GSM260911     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM260912     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM260913     3   0.340      0.871 0.180 0.000 0.820 0.000
#> GSM260886     1   0.253      0.845 0.888 0.000 0.112 0.000
#> GSM260889     1   0.253      0.845 0.888 0.000 0.112 0.000
#> GSM260891     1   0.253      0.845 0.888 0.000 0.112 0.000
#> GSM260894     1   0.253      0.845 0.888 0.000 0.112 0.000
#> GSM260897     1   0.000      0.843 1.000 0.000 0.000 0.000
#> GSM260900     1   0.000      0.843 1.000 0.000 0.000 0.000
#> GSM260903     1   0.000      0.843 1.000 0.000 0.000 0.000
#> GSM260906     1   0.000      0.843 1.000 0.000 0.000 0.000
#> GSM260909     1   0.253      0.845 0.888 0.000 0.112 0.000
#> GSM260887     3   0.344      0.870 0.184 0.000 0.816 0.000
#> GSM260890     3   0.340      0.871 0.180 0.000 0.820 0.000
#> GSM260892     3   0.000      0.649 0.000 0.000 1.000 0.000
#> GSM260895     1   0.253      0.845 0.888 0.000 0.112 0.000
#> GSM260898     1   0.479      0.665 0.788 0.104 0.108 0.000
#> GSM260901     1   0.479      0.665 0.788 0.104 0.108 0.000
#> GSM260904     1   0.479      0.665 0.788 0.104 0.108 0.000
#> GSM260907     1   0.479      0.665 0.788 0.104 0.108 0.000
#> GSM260910     3   0.340      0.871 0.180 0.000 0.820 0.000
#> GSM260918     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM260921     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM260924     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM260929     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM260932     2   0.253      1.000 0.000 0.888 0.000 0.112
#> GSM260935     2   0.253      1.000 0.000 0.888 0.000 0.112
#> GSM260938     2   0.253      1.000 0.000 0.888 0.000 0.112
#> GSM260941     2   0.253      1.000 0.000 0.888 0.000 0.112
#> GSM260944     2   0.253      1.000 0.000 0.888 0.000 0.112
#> GSM260947     2   0.253      1.000 0.000 0.888 0.000 0.112
#> GSM260952     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM260914     1   0.253      0.845 0.888 0.000 0.112 0.000
#> GSM260916     1   0.253      0.845 0.888 0.000 0.112 0.000
#> GSM260919     1   0.253      0.845 0.888 0.000 0.112 0.000
#> GSM260922     1   0.253      0.845 0.888 0.000 0.112 0.000
#> GSM260925     1   0.253      0.845 0.888 0.000 0.112 0.000
#> GSM260927     1   0.253      0.845 0.888 0.000 0.112 0.000
#> GSM260930     1   0.000      0.843 1.000 0.000 0.000 0.000
#> GSM260933     1   0.000      0.843 1.000 0.000 0.000 0.000
#> GSM260936     1   0.000      0.843 1.000 0.000 0.000 0.000
#> GSM260939     1   0.000      0.843 1.000 0.000 0.000 0.000
#> GSM260942     1   0.000      0.843 1.000 0.000 0.000 0.000
#> GSM260945     1   0.000      0.843 1.000 0.000 0.000 0.000
#> GSM260948     1   0.253      0.845 0.888 0.000 0.112 0.000
#> GSM260950     1   0.253      0.845 0.888 0.000 0.112 0.000
#> GSM260915     3   0.373      0.853 0.212 0.000 0.788 0.000
#> GSM260917     3   0.344      0.870 0.184 0.000 0.816 0.000
#> GSM260920     3   0.688      0.452 0.424 0.104 0.472 0.000
#> GSM260923     3   0.340      0.871 0.180 0.000 0.820 0.000
#> GSM260926     3   0.373      0.853 0.212 0.000 0.788 0.000
#> GSM260928     1   0.253      0.845 0.888 0.000 0.112 0.000
#> GSM260931     1   0.479      0.665 0.788 0.104 0.108 0.000
#> GSM260934     1   0.479      0.665 0.788 0.104 0.108 0.000
#> GSM260937     3   0.673      0.718 0.324 0.112 0.564 0.000
#> GSM260940     1   0.479      0.665 0.788 0.104 0.108 0.000
#> GSM260943     3   0.673      0.718 0.324 0.112 0.564 0.000
#> GSM260946     1   0.479      0.665 0.788 0.104 0.108 0.000
#> GSM260949     3   0.340      0.871 0.180 0.000 0.820 0.000
#> GSM260951     3   0.673      0.718 0.324 0.112 0.564 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
#> GSM260888     4  0.4294      0.774 0.000  0 0.000 0.532 0.468
#> GSM260893     4  0.4294      0.774 0.000  0 0.000 0.532 0.468
#> GSM260896     4  0.4294      0.774 0.000  0 0.000 0.532 0.468
#> GSM260899     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260902     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260905     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260908     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260911     4  0.4294      0.774 0.000  0 0.000 0.532 0.468
#> GSM260912     4  0.4294      0.774 0.000  0 0.000 0.532 0.468
#> GSM260913     3  0.0000      0.916 0.000  0 1.000 0.000 0.000
#> GSM260886     1  0.2179      0.827 0.888  0 0.000 0.000 0.112
#> GSM260889     1  0.2179      0.827 0.888  0 0.000 0.000 0.112
#> GSM260891     1  0.2179      0.827 0.888  0 0.000 0.000 0.112
#> GSM260894     1  0.2179      0.827 0.888  0 0.000 0.000 0.112
#> GSM260897     1  0.0000      0.822 1.000  0 0.000 0.000 0.000
#> GSM260900     1  0.0000      0.822 1.000  0 0.000 0.000 0.000
#> GSM260903     1  0.0000      0.822 1.000  0 0.000 0.000 0.000
#> GSM260906     1  0.0000      0.822 1.000  0 0.000 0.000 0.000
#> GSM260909     1  0.2179      0.827 0.888  0 0.000 0.000 0.112
#> GSM260887     3  0.0162      0.915 0.000  0 0.996 0.000 0.004
#> GSM260890     3  0.0000      0.916 0.000  0 1.000 0.000 0.000
#> GSM260892     3  0.3586      0.634 0.000  0 0.736 0.000 0.264
#> GSM260895     1  0.2286      0.826 0.888  0 0.004 0.000 0.108
#> GSM260898     1  0.5948      0.420 0.580  0 0.264 0.000 0.156
#> GSM260901     1  0.5948      0.420 0.580  0 0.264 0.000 0.156
#> GSM260904     1  0.5948      0.420 0.580  0 0.264 0.000 0.156
#> GSM260907     1  0.5948      0.420 0.580  0 0.264 0.000 0.156
#> GSM260910     3  0.0000      0.916 0.000  0 1.000 0.000 0.000
#> GSM260918     4  0.4294      0.774 0.000  0 0.000 0.532 0.468
#> GSM260921     4  0.4294      0.774 0.000  0 0.000 0.532 0.468
#> GSM260924     4  0.4294      0.774 0.000  0 0.000 0.532 0.468
#> GSM260929     4  0.4294      0.774 0.000  0 0.000 0.532 0.468
#> GSM260932     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260935     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260938     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260941     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260944     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260947     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM260952     4  0.4294      0.774 0.000  0 0.000 0.532 0.468
#> GSM260914     1  0.2179      0.827 0.888  0 0.000 0.000 0.112
#> GSM260916     1  0.2179      0.827 0.888  0 0.000 0.000 0.112
#> GSM260919     1  0.2179      0.827 0.888  0 0.000 0.000 0.112
#> GSM260922     1  0.2179      0.827 0.888  0 0.000 0.000 0.112
#> GSM260925     1  0.2179      0.827 0.888  0 0.000 0.000 0.112
#> GSM260927     1  0.2179      0.827 0.888  0 0.000 0.000 0.112
#> GSM260930     1  0.0000      0.822 1.000  0 0.000 0.000 0.000
#> GSM260933     1  0.0000      0.822 1.000  0 0.000 0.000 0.000
#> GSM260936     1  0.0000      0.822 1.000  0 0.000 0.000 0.000
#> GSM260939     1  0.0000      0.822 1.000  0 0.000 0.000 0.000
#> GSM260942     1  0.0000      0.822 1.000  0 0.000 0.000 0.000
#> GSM260945     1  0.0000      0.822 1.000  0 0.000 0.000 0.000
#> GSM260948     1  0.2179      0.827 0.888  0 0.000 0.000 0.112
#> GSM260950     1  0.2179      0.827 0.888  0 0.000 0.000 0.112
#> GSM260915     3  0.0992      0.901 0.008  0 0.968 0.000 0.024
#> GSM260917     3  0.0324      0.914 0.004  0 0.992 0.004 0.000
#> GSM260920     3  0.5673      0.502 0.216  0 0.628 0.000 0.156
#> GSM260923     3  0.0000      0.916 0.000  0 1.000 0.000 0.000
#> GSM260926     3  0.0992      0.901 0.008  0 0.968 0.000 0.024
#> GSM260928     1  0.2179      0.827 0.888  0 0.000 0.000 0.112
#> GSM260931     1  0.5948      0.420 0.580  0 0.264 0.000 0.156
#> GSM260934     1  0.5948      0.420 0.580  0 0.264 0.000 0.156
#> GSM260937     4  0.7717     -0.212 0.112  0 0.264 0.468 0.156
#> GSM260940     1  0.5948      0.420 0.580  0 0.264 0.000 0.156
#> GSM260943     4  0.7717     -0.212 0.112  0 0.264 0.468 0.156
#> GSM260946     1  0.5948      0.420 0.580  0 0.264 0.000 0.156
#> GSM260949     3  0.0000      0.916 0.000  0 1.000 0.000 0.000
#> GSM260951     4  0.7717     -0.212 0.112  0 0.264 0.468 0.156

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1 p2    p3    p4    p5 p6
#> GSM260888     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260893     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260896     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260899     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260902     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260905     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260908     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260911     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260912     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260913     4  0.0000      0.908 0.000  0 0.000 1.000 0.000  0
#> GSM260886     1  0.3351      0.995 0.712  0 0.000 0.000 0.288  0
#> GSM260889     1  0.3351      0.995 0.712  0 0.000 0.000 0.288  0
#> GSM260891     1  0.3309      0.993 0.720  0 0.000 0.000 0.280  0
#> GSM260894     1  0.3330      0.995 0.716  0 0.000 0.000 0.284  0
#> GSM260897     5  0.0790      0.710 0.032  0 0.000 0.000 0.968  0
#> GSM260900     5  0.0790      0.710 0.032  0 0.000 0.000 0.968  0
#> GSM260903     5  0.0790      0.710 0.032  0 0.000 0.000 0.968  0
#> GSM260906     5  0.0790      0.710 0.032  0 0.000 0.000 0.968  0
#> GSM260909     1  0.3330      0.995 0.716  0 0.000 0.000 0.284  0
#> GSM260887     4  0.0146      0.907 0.000  0 0.000 0.996 0.004  0
#> GSM260890     4  0.0000      0.908 0.000  0 0.000 1.000 0.000  0
#> GSM260892     4  0.3309      0.562 0.280  0 0.000 0.720 0.000  0
#> GSM260895     1  0.3448      0.991 0.716  0 0.000 0.004 0.280  0
#> GSM260898     5  0.5084      0.604 0.000  0 0.124 0.264 0.612  0
#> GSM260901     5  0.5084      0.604 0.000  0 0.124 0.264 0.612  0
#> GSM260904     5  0.5084      0.604 0.000  0 0.124 0.264 0.612  0
#> GSM260907     5  0.5084      0.604 0.000  0 0.124 0.264 0.612  0
#> GSM260910     4  0.0000      0.908 0.000  0 0.000 1.000 0.000  0
#> GSM260918     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260921     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260924     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260929     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260932     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260935     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260938     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260941     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260944     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260947     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260952     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260914     1  0.3351      0.995 0.712  0 0.000 0.000 0.288  0
#> GSM260916     1  0.3309      0.993 0.720  0 0.000 0.000 0.280  0
#> GSM260919     1  0.3351      0.995 0.712  0 0.000 0.000 0.288  0
#> GSM260922     1  0.3309      0.993 0.720  0 0.000 0.000 0.280  0
#> GSM260925     1  0.3351      0.995 0.712  0 0.000 0.000 0.288  0
#> GSM260927     1  0.3330      0.995 0.716  0 0.000 0.000 0.284  0
#> GSM260930     5  0.0790      0.710 0.032  0 0.000 0.000 0.968  0
#> GSM260933     5  0.0790      0.710 0.032  0 0.000 0.000 0.968  0
#> GSM260936     5  0.0790      0.710 0.032  0 0.000 0.000 0.968  0
#> GSM260939     5  0.0790      0.710 0.032  0 0.000 0.000 0.968  0
#> GSM260942     5  0.0790      0.710 0.032  0 0.000 0.000 0.968  0
#> GSM260945     5  0.0790      0.710 0.032  0 0.000 0.000 0.968  0
#> GSM260948     1  0.3351      0.995 0.712  0 0.000 0.000 0.288  0
#> GSM260950     1  0.3351      0.995 0.712  0 0.000 0.000 0.288  0
#> GSM260915     4  0.0790      0.891 0.000  0 0.000 0.968 0.032  0
#> GSM260917     4  0.0458      0.899 0.000  0 0.016 0.984 0.000  0
#> GSM260920     4  0.5005      0.371 0.000  0 0.124 0.628 0.248  0
#> GSM260923     4  0.0000      0.908 0.000  0 0.000 1.000 0.000  0
#> GSM260926     4  0.0790      0.891 0.000  0 0.000 0.968 0.032  0
#> GSM260928     1  0.3309      0.993 0.720  0 0.000 0.000 0.280  0
#> GSM260931     5  0.5084      0.604 0.000  0 0.124 0.264 0.612  0
#> GSM260934     5  0.5084      0.604 0.000  0 0.124 0.264 0.612  0
#> GSM260937     3  0.0000      1.000 0.000  0 1.000 0.000 0.000  0
#> GSM260940     5  0.5084      0.604 0.000  0 0.124 0.264 0.612  0
#> GSM260943     3  0.0000      1.000 0.000  0 1.000 0.000 0.000  0
#> GSM260946     5  0.5084      0.604 0.000  0 0.124 0.264 0.612  0
#> GSM260949     4  0.0000      0.908 0.000  0 0.000 1.000 0.000  0
#> GSM260951     3  0.0000      1.000 0.000  0 1.000 0.000 0.000  0

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

consensus_heatmap(res, k = 2)

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) cell.type(p) k
#> ATC:hclust 67            0.939     2.75e-14 2
#> ATC:hclust 67            0.860     4.00e-18 3
#> ATC:hclust 66            0.952     2.70e-16 4
#> ATC:hclust 56            0.949     1.02e-17 5
#> ATC:hclust 66            0.735     4.86e-15 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 21168 rows and 67 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4257 0.575   0.575
#> 3 3 0.688           0.938       0.869         0.4699 0.751   0.567
#> 4 4 0.790           0.841       0.819         0.1376 1.000   1.000
#> 5 5 0.802           0.885       0.774         0.0753 0.877   0.624
#> 6 6 0.810           0.910       0.796         0.0442 0.955   0.778

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
#> GSM260888     2       0          1  0  1
#> GSM260893     2       0          1  0  1
#> GSM260896     2       0          1  0  1
#> GSM260899     2       0          1  0  1
#> GSM260902     2       0          1  0  1
#> GSM260905     2       0          1  0  1
#> GSM260908     2       0          1  0  1
#> GSM260911     2       0          1  0  1
#> GSM260912     2       0          1  0  1
#> GSM260913     1       0          1  1  0
#> GSM260886     1       0          1  1  0
#> GSM260889     1       0          1  1  0
#> GSM260891     1       0          1  1  0
#> GSM260894     1       0          1  1  0
#> GSM260897     1       0          1  1  0
#> GSM260900     1       0          1  1  0
#> GSM260903     1       0          1  1  0
#> GSM260906     1       0          1  1  0
#> GSM260909     1       0          1  1  0
#> GSM260887     1       0          1  1  0
#> GSM260890     1       0          1  1  0
#> GSM260892     1       0          1  1  0
#> GSM260895     1       0          1  1  0
#> GSM260898     1       0          1  1  0
#> GSM260901     1       0          1  1  0
#> GSM260904     1       0          1  1  0
#> GSM260907     1       0          1  1  0
#> GSM260910     1       0          1  1  0
#> GSM260918     2       0          1  0  1
#> GSM260921     2       0          1  0  1
#> GSM260924     2       0          1  0  1
#> GSM260929     2       0          1  0  1
#> GSM260932     2       0          1  0  1
#> GSM260935     2       0          1  0  1
#> GSM260938     2       0          1  0  1
#> GSM260941     2       0          1  0  1
#> GSM260944     2       0          1  0  1
#> GSM260947     2       0          1  0  1
#> GSM260952     2       0          1  0  1
#> GSM260914     1       0          1  1  0
#> GSM260916     1       0          1  1  0
#> GSM260919     1       0          1  1  0
#> GSM260922     1       0          1  1  0
#> GSM260925     1       0          1  1  0
#> GSM260927     1       0          1  1  0
#> GSM260930     1       0          1  1  0
#> GSM260933     1       0          1  1  0
#> GSM260936     1       0          1  1  0
#> GSM260939     1       0          1  1  0
#> GSM260942     1       0          1  1  0
#> GSM260945     1       0          1  1  0
#> GSM260948     1       0          1  1  0
#> GSM260950     1       0          1  1  0
#> GSM260915     1       0          1  1  0
#> GSM260917     1       0          1  1  0
#> GSM260920     1       0          1  1  0
#> GSM260923     1       0          1  1  0
#> GSM260926     1       0          1  1  0
#> GSM260928     1       0          1  1  0
#> GSM260931     1       0          1  1  0
#> GSM260934     1       0          1  1  0
#> GSM260937     1       0          1  1  0
#> GSM260940     1       0          1  1  0
#> GSM260943     1       0          1  1  0
#> GSM260946     1       0          1  1  0
#> GSM260949     1       0          1  1  0
#> GSM260951     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM260888     2  0.4178      0.930 0.000 0.828 0.172
#> GSM260893     2  0.4178      0.930 0.000 0.828 0.172
#> GSM260896     2  0.4178      0.930 0.000 0.828 0.172
#> GSM260899     2  0.2066      0.908 0.000 0.940 0.060
#> GSM260902     2  0.2066      0.908 0.000 0.940 0.060
#> GSM260905     2  0.0000      0.925 0.000 1.000 0.000
#> GSM260908     2  0.0000      0.925 0.000 1.000 0.000
#> GSM260911     2  0.4178      0.930 0.000 0.828 0.172
#> GSM260912     2  0.4178      0.930 0.000 0.828 0.172
#> GSM260913     3  0.5621      0.942 0.308 0.000 0.692
#> GSM260886     1  0.0237      0.953 0.996 0.000 0.004
#> GSM260889     1  0.0000      0.953 1.000 0.000 0.000
#> GSM260891     1  0.0237      0.953 0.996 0.000 0.004
#> GSM260894     1  0.0237      0.953 0.996 0.000 0.004
#> GSM260897     1  0.2448      0.931 0.924 0.000 0.076
#> GSM260900     1  0.2448      0.931 0.924 0.000 0.076
#> GSM260903     1  0.2448      0.931 0.924 0.000 0.076
#> GSM260906     1  0.2448      0.931 0.924 0.000 0.076
#> GSM260909     1  0.0237      0.953 0.996 0.000 0.004
#> GSM260887     3  0.5591      0.944 0.304 0.000 0.696
#> GSM260890     3  0.5621      0.942 0.308 0.000 0.692
#> GSM260892     3  0.5621      0.942 0.308 0.000 0.692
#> GSM260895     1  0.0237      0.953 0.996 0.000 0.004
#> GSM260898     3  0.4974      0.940 0.236 0.000 0.764
#> GSM260901     3  0.4974      0.940 0.236 0.000 0.764
#> GSM260904     3  0.4974      0.940 0.236 0.000 0.764
#> GSM260907     3  0.4974      0.940 0.236 0.000 0.764
#> GSM260910     3  0.5621      0.942 0.308 0.000 0.692
#> GSM260918     2  0.4178      0.930 0.000 0.828 0.172
#> GSM260921     2  0.4178      0.930 0.000 0.828 0.172
#> GSM260924     2  0.4178      0.930 0.000 0.828 0.172
#> GSM260929     2  0.4178      0.930 0.000 0.828 0.172
#> GSM260932     2  0.2066      0.908 0.000 0.940 0.060
#> GSM260935     2  0.2066      0.908 0.000 0.940 0.060
#> GSM260938     2  0.0592      0.923 0.000 0.988 0.012
#> GSM260941     2  0.0000      0.925 0.000 1.000 0.000
#> GSM260944     2  0.0000      0.925 0.000 1.000 0.000
#> GSM260947     2  0.0000      0.925 0.000 1.000 0.000
#> GSM260952     2  0.4178      0.930 0.000 0.828 0.172
#> GSM260914     1  0.0000      0.953 1.000 0.000 0.000
#> GSM260916     1  0.0237      0.953 0.996 0.000 0.004
#> GSM260919     1  0.0237      0.953 0.996 0.000 0.004
#> GSM260922     1  0.0237      0.953 0.996 0.000 0.004
#> GSM260925     1  0.0000      0.953 1.000 0.000 0.000
#> GSM260927     1  0.0237      0.953 0.996 0.000 0.004
#> GSM260930     1  0.2448      0.931 0.924 0.000 0.076
#> GSM260933     1  0.2448      0.931 0.924 0.000 0.076
#> GSM260936     1  0.2448      0.931 0.924 0.000 0.076
#> GSM260939     1  0.2448      0.931 0.924 0.000 0.076
#> GSM260942     1  0.2448      0.931 0.924 0.000 0.076
#> GSM260945     1  0.2448      0.931 0.924 0.000 0.076
#> GSM260948     1  0.0237      0.953 0.996 0.000 0.004
#> GSM260950     1  0.0000      0.953 1.000 0.000 0.000
#> GSM260915     3  0.5529      0.948 0.296 0.000 0.704
#> GSM260917     3  0.5529      0.948 0.296 0.000 0.704
#> GSM260920     3  0.5529      0.948 0.296 0.000 0.704
#> GSM260923     3  0.5621      0.942 0.308 0.000 0.692
#> GSM260926     3  0.5529      0.948 0.296 0.000 0.704
#> GSM260928     1  0.0237      0.953 0.996 0.000 0.004
#> GSM260931     3  0.4974      0.940 0.236 0.000 0.764
#> GSM260934     3  0.4974      0.940 0.236 0.000 0.764
#> GSM260937     3  0.4974      0.940 0.236 0.000 0.764
#> GSM260940     3  0.4974      0.940 0.236 0.000 0.764
#> GSM260943     3  0.4974      0.940 0.236 0.000 0.764
#> GSM260946     3  0.4974      0.940 0.236 0.000 0.764
#> GSM260949     3  0.5621      0.942 0.308 0.000 0.692
#> GSM260951     3  0.5529      0.948 0.296 0.000 0.704

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3 p4
#> GSM260888     2  0.4500      0.866 0.000 0.684 0.000 NA
#> GSM260893     2  0.4500      0.866 0.000 0.684 0.000 NA
#> GSM260896     2  0.4500      0.866 0.000 0.684 0.000 NA
#> GSM260899     2  0.1975      0.852 0.000 0.936 0.048 NA
#> GSM260902     2  0.1975      0.852 0.000 0.936 0.048 NA
#> GSM260905     2  0.0000      0.859 0.000 1.000 0.000 NA
#> GSM260908     2  0.0000      0.859 0.000 1.000 0.000 NA
#> GSM260911     2  0.4500      0.866 0.000 0.684 0.000 NA
#> GSM260912     2  0.4500      0.866 0.000 0.684 0.000 NA
#> GSM260913     3  0.6500      0.832 0.092 0.000 0.580 NA
#> GSM260886     1  0.4456      0.872 0.716 0.000 0.004 NA
#> GSM260889     1  0.4277      0.872 0.720 0.000 0.000 NA
#> GSM260891     1  0.4456      0.872 0.716 0.000 0.004 NA
#> GSM260894     1  0.4456      0.872 0.716 0.000 0.004 NA
#> GSM260897     1  0.0707      0.812 0.980 0.000 0.020 NA
#> GSM260900     1  0.0707      0.812 0.980 0.000 0.020 NA
#> GSM260903     1  0.0707      0.812 0.980 0.000 0.020 NA
#> GSM260906     1  0.0707      0.812 0.980 0.000 0.020 NA
#> GSM260909     1  0.4456      0.872 0.716 0.000 0.004 NA
#> GSM260887     3  0.6446      0.833 0.088 0.000 0.584 NA
#> GSM260890     3  0.6500      0.832 0.092 0.000 0.580 NA
#> GSM260892     3  0.6547      0.829 0.092 0.000 0.568 NA
#> GSM260895     1  0.5628      0.715 0.556 0.000 0.024 NA
#> GSM260898     3  0.2011      0.818 0.080 0.000 0.920 NA
#> GSM260901     3  0.2011      0.818 0.080 0.000 0.920 NA
#> GSM260904     3  0.1940      0.819 0.076 0.000 0.924 NA
#> GSM260907     3  0.2011      0.818 0.080 0.000 0.920 NA
#> GSM260910     3  0.6500      0.832 0.092 0.000 0.580 NA
#> GSM260918     2  0.4500      0.866 0.000 0.684 0.000 NA
#> GSM260921     2  0.4500      0.866 0.000 0.684 0.000 NA
#> GSM260924     2  0.5113      0.864 0.000 0.684 0.024 NA
#> GSM260929     2  0.4500      0.866 0.000 0.684 0.000 NA
#> GSM260932     2  0.1975      0.852 0.000 0.936 0.048 NA
#> GSM260935     2  0.1975      0.852 0.000 0.936 0.048 NA
#> GSM260938     2  0.0000      0.859 0.000 1.000 0.000 NA
#> GSM260941     2  0.0000      0.859 0.000 1.000 0.000 NA
#> GSM260944     2  0.0000      0.859 0.000 1.000 0.000 NA
#> GSM260947     2  0.0000      0.859 0.000 1.000 0.000 NA
#> GSM260952     2  0.4500      0.866 0.000 0.684 0.000 NA
#> GSM260914     1  0.4277      0.872 0.720 0.000 0.000 NA
#> GSM260916     1  0.4456      0.872 0.716 0.000 0.004 NA
#> GSM260919     1  0.4456      0.872 0.716 0.000 0.004 NA
#> GSM260922     1  0.4456      0.872 0.716 0.000 0.004 NA
#> GSM260925     1  0.4277      0.872 0.720 0.000 0.000 NA
#> GSM260927     1  0.4456      0.872 0.716 0.000 0.004 NA
#> GSM260930     1  0.0707      0.812 0.980 0.000 0.020 NA
#> GSM260933     1  0.0707      0.812 0.980 0.000 0.020 NA
#> GSM260936     1  0.0707      0.812 0.980 0.000 0.020 NA
#> GSM260939     1  0.0707      0.812 0.980 0.000 0.020 NA
#> GSM260942     1  0.0707      0.812 0.980 0.000 0.020 NA
#> GSM260945     1  0.0707      0.812 0.980 0.000 0.020 NA
#> GSM260948     1  0.4456      0.872 0.716 0.000 0.004 NA
#> GSM260950     1  0.4277      0.872 0.720 0.000 0.000 NA
#> GSM260915     3  0.6446      0.833 0.088 0.000 0.584 NA
#> GSM260917     3  0.6446      0.833 0.088 0.000 0.584 NA
#> GSM260920     3  0.6446      0.833 0.088 0.000 0.584 NA
#> GSM260923     3  0.6500      0.832 0.092 0.000 0.580 NA
#> GSM260926     3  0.6446      0.833 0.088 0.000 0.584 NA
#> GSM260928     1  0.4594      0.869 0.712 0.000 0.008 NA
#> GSM260931     3  0.3286      0.804 0.080 0.000 0.876 NA
#> GSM260934     3  0.2011      0.818 0.080 0.000 0.920 NA
#> GSM260937     3  0.3611      0.798 0.080 0.000 0.860 NA
#> GSM260940     3  0.3286      0.804 0.080 0.000 0.876 NA
#> GSM260943     3  0.3611      0.798 0.080 0.000 0.860 NA
#> GSM260946     3  0.3286      0.804 0.080 0.000 0.876 NA
#> GSM260949     3  0.6500      0.832 0.092 0.000 0.580 NA
#> GSM260951     3  0.5417      0.821 0.088 0.000 0.732 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM260888     2  0.0671      0.783 0.000 0.980 0.000 0.004 0.016
#> GSM260893     2  0.0671      0.783 0.000 0.980 0.000 0.004 0.016
#> GSM260896     2  0.0671      0.783 0.000 0.980 0.000 0.004 0.016
#> GSM260899     2  0.6339      0.748 0.000 0.504 0.312 0.000 0.184
#> GSM260902     2  0.6339      0.748 0.000 0.504 0.312 0.000 0.184
#> GSM260905     2  0.6211      0.769 0.000 0.544 0.192 0.000 0.264
#> GSM260908     2  0.6211      0.769 0.000 0.544 0.192 0.000 0.264
#> GSM260911     2  0.0671      0.783 0.000 0.980 0.000 0.004 0.016
#> GSM260912     2  0.0579      0.783 0.000 0.984 0.000 0.008 0.008
#> GSM260913     3  0.5483      0.967 0.048 0.000 0.604 0.332 0.016
#> GSM260886     1  0.0794      0.958 0.972 0.000 0.028 0.000 0.000
#> GSM260889     1  0.0955      0.956 0.968 0.000 0.028 0.004 0.000
#> GSM260891     1  0.0290      0.958 0.992 0.000 0.008 0.000 0.000
#> GSM260894     1  0.0000      0.961 1.000 0.000 0.000 0.000 0.000
#> GSM260897     5  0.4855      0.994 0.424 0.000 0.000 0.024 0.552
#> GSM260900     5  0.4855      0.994 0.424 0.000 0.000 0.024 0.552
#> GSM260903     5  0.4855      0.994 0.424 0.000 0.000 0.024 0.552
#> GSM260906     5  0.4855      0.994 0.424 0.000 0.000 0.024 0.552
#> GSM260909     1  0.0162      0.960 0.996 0.000 0.004 0.000 0.000
#> GSM260887     3  0.5002      0.971 0.044 0.000 0.612 0.344 0.000
#> GSM260890     3  0.5037      0.972 0.048 0.000 0.616 0.336 0.000
#> GSM260892     3  0.5453      0.958 0.048 0.000 0.612 0.324 0.016
#> GSM260895     1  0.2179      0.775 0.888 0.000 0.112 0.000 0.000
#> GSM260898     4  0.2300      0.873 0.024 0.000 0.072 0.904 0.000
#> GSM260901     4  0.2300      0.873 0.024 0.000 0.072 0.904 0.000
#> GSM260904     4  0.2300      0.873 0.024 0.000 0.072 0.904 0.000
#> GSM260907     4  0.2300      0.873 0.024 0.000 0.072 0.904 0.000
#> GSM260910     3  0.5287      0.971 0.048 0.000 0.612 0.332 0.008
#> GSM260918     2  0.0579      0.783 0.000 0.984 0.000 0.008 0.008
#> GSM260921     2  0.0000      0.783 0.000 1.000 0.000 0.000 0.000
#> GSM260924     2  0.1168      0.781 0.000 0.960 0.000 0.008 0.032
#> GSM260929     2  0.0579      0.783 0.000 0.984 0.000 0.008 0.008
#> GSM260932     2  0.6339      0.748 0.000 0.504 0.312 0.000 0.184
#> GSM260935     2  0.6339      0.748 0.000 0.504 0.312 0.000 0.184
#> GSM260938     2  0.6375      0.766 0.000 0.536 0.192 0.004 0.268
#> GSM260941     2  0.6340      0.769 0.000 0.544 0.192 0.004 0.260
#> GSM260944     2  0.6340      0.769 0.000 0.544 0.192 0.004 0.260
#> GSM260947     2  0.6211      0.769 0.000 0.544 0.192 0.000 0.264
#> GSM260952     2  0.0579      0.783 0.000 0.984 0.000 0.008 0.008
#> GSM260914     1  0.0955      0.956 0.968 0.000 0.028 0.004 0.000
#> GSM260916     1  0.0290      0.958 0.992 0.000 0.008 0.000 0.000
#> GSM260919     1  0.0703      0.960 0.976 0.000 0.024 0.000 0.000
#> GSM260922     1  0.0290      0.958 0.992 0.000 0.008 0.000 0.000
#> GSM260925     1  0.1116      0.953 0.964 0.000 0.028 0.004 0.004
#> GSM260927     1  0.0000      0.961 1.000 0.000 0.000 0.000 0.000
#> GSM260930     5  0.4855      0.994 0.424 0.000 0.000 0.024 0.552
#> GSM260933     5  0.4855      0.994 0.424 0.000 0.000 0.024 0.552
#> GSM260936     5  0.5305      0.986 0.424 0.000 0.016 0.024 0.536
#> GSM260939     5  0.5305      0.986 0.424 0.000 0.016 0.024 0.536
#> GSM260942     5  0.5305      0.986 0.424 0.000 0.016 0.024 0.536
#> GSM260945     5  0.4855      0.994 0.424 0.000 0.000 0.024 0.552
#> GSM260948     1  0.0703      0.960 0.976 0.000 0.024 0.000 0.000
#> GSM260950     1  0.0955      0.956 0.968 0.000 0.028 0.004 0.000
#> GSM260915     3  0.5002      0.957 0.040 0.000 0.596 0.364 0.000
#> GSM260917     3  0.4935      0.969 0.040 0.000 0.616 0.344 0.000
#> GSM260920     3  0.5002      0.957 0.040 0.000 0.596 0.364 0.000
#> GSM260923     3  0.5022      0.972 0.048 0.000 0.620 0.332 0.000
#> GSM260926     3  0.5002      0.957 0.040 0.000 0.596 0.364 0.000
#> GSM260928     1  0.0404      0.955 0.988 0.000 0.012 0.000 0.000
#> GSM260931     4  0.0703      0.874 0.024 0.000 0.000 0.976 0.000
#> GSM260934     4  0.2300      0.873 0.024 0.000 0.072 0.904 0.000
#> GSM260937     4  0.3077      0.817 0.024 0.000 0.020 0.872 0.084
#> GSM260940     4  0.0703      0.874 0.024 0.000 0.000 0.976 0.000
#> GSM260943     4  0.3077      0.817 0.024 0.000 0.020 0.872 0.084
#> GSM260946     4  0.0703      0.874 0.024 0.000 0.000 0.976 0.000
#> GSM260949     3  0.5287      0.971 0.048 0.000 0.612 0.332 0.008
#> GSM260951     4  0.5612      0.506 0.040 0.000 0.172 0.696 0.092

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM260888     2  0.4316      0.971 0.004 0.552 0.004 0.008 0.000 0.432
#> GSM260893     2  0.4215      0.972 0.004 0.556 0.004 0.004 0.000 0.432
#> GSM260896     2  0.4215      0.972 0.004 0.556 0.004 0.004 0.000 0.432
#> GSM260899     6  0.4252      0.777 0.164 0.028 0.052 0.000 0.000 0.756
#> GSM260902     6  0.4252      0.777 0.164 0.028 0.052 0.000 0.000 0.756
#> GSM260905     6  0.0665      0.839 0.000 0.008 0.008 0.004 0.000 0.980
#> GSM260908     6  0.0665      0.839 0.000 0.008 0.008 0.004 0.000 0.980
#> GSM260911     2  0.4215      0.972 0.004 0.556 0.004 0.004 0.000 0.432
#> GSM260912     2  0.4285      0.972 0.008 0.552 0.008 0.000 0.000 0.432
#> GSM260913     4  0.2084      0.942 0.044 0.024 0.000 0.916 0.016 0.000
#> GSM260886     1  0.5011      0.933 0.616 0.064 0.004 0.008 0.308 0.000
#> GSM260889     1  0.5011      0.933 0.616 0.064 0.004 0.008 0.308 0.000
#> GSM260891     1  0.3827      0.927 0.680 0.000 0.004 0.008 0.308 0.000
#> GSM260894     1  0.3690      0.928 0.684 0.000 0.000 0.008 0.308 0.000
#> GSM260897     5  0.0405      0.985 0.000 0.004 0.008 0.000 0.988 0.000
#> GSM260900     5  0.0405      0.985 0.000 0.004 0.008 0.000 0.988 0.000
#> GSM260903     5  0.0717      0.983 0.000 0.016 0.008 0.000 0.976 0.000
#> GSM260906     5  0.0717      0.983 0.000 0.016 0.008 0.000 0.976 0.000
#> GSM260909     1  0.3690      0.928 0.684 0.000 0.000 0.008 0.308 0.000
#> GSM260887     4  0.0748      0.966 0.000 0.004 0.004 0.976 0.016 0.000
#> GSM260890     4  0.0458      0.966 0.000 0.000 0.000 0.984 0.016 0.000
#> GSM260892     4  0.2501      0.928 0.056 0.028 0.004 0.896 0.016 0.000
#> GSM260895     1  0.5154      0.765 0.668 0.012 0.004 0.132 0.184 0.000
#> GSM260898     3  0.3518      0.887 0.008 0.000 0.784 0.184 0.024 0.000
#> GSM260901     3  0.3518      0.887 0.008 0.000 0.784 0.184 0.024 0.000
#> GSM260904     3  0.3269      0.887 0.000 0.000 0.792 0.184 0.024 0.000
#> GSM260907     3  0.3269      0.887 0.000 0.000 0.792 0.184 0.024 0.000
#> GSM260910     4  0.1369      0.960 0.016 0.016 0.000 0.952 0.016 0.000
#> GSM260918     2  0.4285      0.972 0.008 0.552 0.008 0.000 0.000 0.432
#> GSM260921     2  0.3950      0.974 0.000 0.564 0.000 0.004 0.000 0.432
#> GSM260924     2  0.5205      0.905 0.020 0.504 0.048 0.000 0.000 0.428
#> GSM260929     2  0.4285      0.972 0.008 0.552 0.008 0.000 0.000 0.432
#> GSM260932     6  0.4319      0.776 0.152 0.028 0.064 0.000 0.000 0.756
#> GSM260935     6  0.4252      0.777 0.164 0.028 0.052 0.000 0.000 0.756
#> GSM260938     6  0.0291      0.840 0.004 0.000 0.004 0.000 0.000 0.992
#> GSM260941     6  0.0260      0.840 0.000 0.008 0.000 0.000 0.000 0.992
#> GSM260944     6  0.0260      0.840 0.000 0.008 0.000 0.000 0.000 0.992
#> GSM260947     6  0.0260      0.840 0.000 0.008 0.000 0.000 0.000 0.992
#> GSM260952     2  0.4316      0.972 0.004 0.552 0.008 0.004 0.000 0.432
#> GSM260914     1  0.5011      0.933 0.616 0.064 0.004 0.008 0.308 0.000
#> GSM260916     1  0.5156      0.881 0.604 0.076 0.004 0.008 0.308 0.000
#> GSM260919     1  0.5011      0.933 0.616 0.064 0.004 0.008 0.308 0.000
#> GSM260922     1  0.5141      0.878 0.608 0.076 0.004 0.008 0.304 0.000
#> GSM260925     1  0.5011      0.933 0.616 0.064 0.004 0.008 0.308 0.000
#> GSM260927     1  0.3690      0.928 0.684 0.000 0.000 0.008 0.308 0.000
#> GSM260930     5  0.0146      0.984 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM260933     5  0.0146      0.984 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM260936     5  0.0622      0.979 0.000 0.008 0.012 0.000 0.980 0.000
#> GSM260939     5  0.0622      0.979 0.000 0.008 0.012 0.000 0.980 0.000
#> GSM260942     5  0.0622      0.979 0.000 0.008 0.012 0.000 0.980 0.000
#> GSM260945     5  0.0717      0.983 0.000 0.016 0.008 0.000 0.976 0.000
#> GSM260948     1  0.5011      0.933 0.616 0.064 0.004 0.008 0.308 0.000
#> GSM260950     1  0.5011      0.933 0.616 0.064 0.004 0.008 0.308 0.000
#> GSM260915     4  0.1390      0.954 0.000 0.004 0.032 0.948 0.016 0.000
#> GSM260917     4  0.0748      0.966 0.000 0.004 0.004 0.976 0.016 0.000
#> GSM260920     4  0.1390      0.954 0.000 0.004 0.032 0.948 0.016 0.000
#> GSM260923     4  0.0603      0.966 0.004 0.000 0.000 0.980 0.016 0.000
#> GSM260926     4  0.1390      0.954 0.000 0.004 0.032 0.948 0.016 0.000
#> GSM260928     1  0.4240      0.921 0.668 0.012 0.004 0.012 0.304 0.000
#> GSM260931     3  0.2950      0.886 0.000 0.000 0.828 0.148 0.024 0.000
#> GSM260934     3  0.3269      0.887 0.000 0.000 0.792 0.184 0.024 0.000
#> GSM260937     3  0.6464      0.752 0.056 0.200 0.584 0.136 0.024 0.000
#> GSM260940     3  0.2950      0.886 0.000 0.000 0.828 0.148 0.024 0.000
#> GSM260943     3  0.6464      0.752 0.056 0.200 0.584 0.136 0.024 0.000
#> GSM260946     3  0.2950      0.886 0.000 0.000 0.828 0.148 0.024 0.000
#> GSM260949     4  0.1369      0.960 0.016 0.016 0.000 0.952 0.016 0.000
#> GSM260951     3  0.7126      0.526 0.056 0.208 0.428 0.292 0.016 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) cell.type(p) k
#> ATC:kmeans 67            0.939     2.75e-14 2
#> ATC:kmeans 67            0.940     1.87e-24 3
#> ATC:kmeans 67            0.940     1.87e-24 4
#> ATC:kmeans 67            0.989     7.25e-22 5
#> ATC:kmeans 67            0.991     1.09e-20 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 21168 rows and 67 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4257 0.575   0.575
#> 3 3 1.000           1.000       1.000         0.5837 0.751   0.567
#> 4 4 1.000           0.989       0.990         0.0829 0.945   0.832
#> 5 5 0.907           0.947       0.898         0.0600 0.932   0.750
#> 6 6 0.860           0.902       0.877         0.0477 0.989   0.947

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM260888     2       0          1  0  1
#> GSM260893     2       0          1  0  1
#> GSM260896     2       0          1  0  1
#> GSM260899     2       0          1  0  1
#> GSM260902     2       0          1  0  1
#> GSM260905     2       0          1  0  1
#> GSM260908     2       0          1  0  1
#> GSM260911     2       0          1  0  1
#> GSM260912     2       0          1  0  1
#> GSM260913     1       0          1  1  0
#> GSM260886     1       0          1  1  0
#> GSM260889     1       0          1  1  0
#> GSM260891     1       0          1  1  0
#> GSM260894     1       0          1  1  0
#> GSM260897     1       0          1  1  0
#> GSM260900     1       0          1  1  0
#> GSM260903     1       0          1  1  0
#> GSM260906     1       0          1  1  0
#> GSM260909     1       0          1  1  0
#> GSM260887     1       0          1  1  0
#> GSM260890     1       0          1  1  0
#> GSM260892     1       0          1  1  0
#> GSM260895     1       0          1  1  0
#> GSM260898     1       0          1  1  0
#> GSM260901     1       0          1  1  0
#> GSM260904     1       0          1  1  0
#> GSM260907     1       0          1  1  0
#> GSM260910     1       0          1  1  0
#> GSM260918     2       0          1  0  1
#> GSM260921     2       0          1  0  1
#> GSM260924     2       0          1  0  1
#> GSM260929     2       0          1  0  1
#> GSM260932     2       0          1  0  1
#> GSM260935     2       0          1  0  1
#> GSM260938     2       0          1  0  1
#> GSM260941     2       0          1  0  1
#> GSM260944     2       0          1  0  1
#> GSM260947     2       0          1  0  1
#> GSM260952     2       0          1  0  1
#> GSM260914     1       0          1  1  0
#> GSM260916     1       0          1  1  0
#> GSM260919     1       0          1  1  0
#> GSM260922     1       0          1  1  0
#> GSM260925     1       0          1  1  0
#> GSM260927     1       0          1  1  0
#> GSM260930     1       0          1  1  0
#> GSM260933     1       0          1  1  0
#> GSM260936     1       0          1  1  0
#> GSM260939     1       0          1  1  0
#> GSM260942     1       0          1  1  0
#> GSM260945     1       0          1  1  0
#> GSM260948     1       0          1  1  0
#> GSM260950     1       0          1  1  0
#> GSM260915     1       0          1  1  0
#> GSM260917     1       0          1  1  0
#> GSM260920     1       0          1  1  0
#> GSM260923     1       0          1  1  0
#> GSM260926     1       0          1  1  0
#> GSM260928     1       0          1  1  0
#> GSM260931     1       0          1  1  0
#> GSM260934     1       0          1  1  0
#> GSM260937     1       0          1  1  0
#> GSM260940     1       0          1  1  0
#> GSM260943     1       0          1  1  0
#> GSM260946     1       0          1  1  0
#> GSM260949     1       0          1  1  0
#> GSM260951     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1 p2 p3
#> GSM260888     2       0          1  0  1  0
#> GSM260893     2       0          1  0  1  0
#> GSM260896     2       0          1  0  1  0
#> GSM260899     2       0          1  0  1  0
#> GSM260902     2       0          1  0  1  0
#> GSM260905     2       0          1  0  1  0
#> GSM260908     2       0          1  0  1  0
#> GSM260911     2       0          1  0  1  0
#> GSM260912     2       0          1  0  1  0
#> GSM260913     3       0          1  0  0  1
#> GSM260886     1       0          1  1  0  0
#> GSM260889     1       0          1  1  0  0
#> GSM260891     1       0          1  1  0  0
#> GSM260894     1       0          1  1  0  0
#> GSM260897     1       0          1  1  0  0
#> GSM260900     1       0          1  1  0  0
#> GSM260903     1       0          1  1  0  0
#> GSM260906     1       0          1  1  0  0
#> GSM260909     1       0          1  1  0  0
#> GSM260887     3       0          1  0  0  1
#> GSM260890     3       0          1  0  0  1
#> GSM260892     3       0          1  0  0  1
#> GSM260895     1       0          1  1  0  0
#> GSM260898     3       0          1  0  0  1
#> GSM260901     3       0          1  0  0  1
#> GSM260904     3       0          1  0  0  1
#> GSM260907     3       0          1  0  0  1
#> GSM260910     3       0          1  0  0  1
#> GSM260918     2       0          1  0  1  0
#> GSM260921     2       0          1  0  1  0
#> GSM260924     2       0          1  0  1  0
#> GSM260929     2       0          1  0  1  0
#> GSM260932     2       0          1  0  1  0
#> GSM260935     2       0          1  0  1  0
#> GSM260938     2       0          1  0  1  0
#> GSM260941     2       0          1  0  1  0
#> GSM260944     2       0          1  0  1  0
#> GSM260947     2       0          1  0  1  0
#> GSM260952     2       0          1  0  1  0
#> GSM260914     1       0          1  1  0  0
#> GSM260916     1       0          1  1  0  0
#> GSM260919     1       0          1  1  0  0
#> GSM260922     1       0          1  1  0  0
#> GSM260925     1       0          1  1  0  0
#> GSM260927     1       0          1  1  0  0
#> GSM260930     1       0          1  1  0  0
#> GSM260933     1       0          1  1  0  0
#> GSM260936     1       0          1  1  0  0
#> GSM260939     1       0          1  1  0  0
#> GSM260942     1       0          1  1  0  0
#> GSM260945     1       0          1  1  0  0
#> GSM260948     1       0          1  1  0  0
#> GSM260950     1       0          1  1  0  0
#> GSM260915     3       0          1  0  0  1
#> GSM260917     3       0          1  0  0  1
#> GSM260920     3       0          1  0  0  1
#> GSM260923     3       0          1  0  0  1
#> GSM260926     3       0          1  0  0  1
#> GSM260928     1       0          1  1  0  0
#> GSM260931     3       0          1  0  0  1
#> GSM260934     3       0          1  0  0  1
#> GSM260937     3       0          1  0  0  1
#> GSM260940     3       0          1  0  0  1
#> GSM260943     3       0          1  0  0  1
#> GSM260946     3       0          1  0  0  1
#> GSM260949     3       0          1  0  0  1
#> GSM260951     3       0          1  0  0  1

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM260888     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260893     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260896     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260899     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260902     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260905     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260908     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260911     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260912     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260913     4  0.0707      0.996 0.000 0.000 0.020 0.980
#> GSM260886     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM260889     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM260891     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM260894     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM260897     1  0.0592      0.984 0.984 0.000 0.000 0.016
#> GSM260900     1  0.0592      0.984 0.984 0.000 0.000 0.016
#> GSM260903     1  0.0592      0.984 0.984 0.000 0.000 0.016
#> GSM260906     1  0.0592      0.984 0.984 0.000 0.000 0.016
#> GSM260909     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM260887     4  0.0707      0.996 0.000 0.000 0.020 0.980
#> GSM260890     4  0.0707      0.996 0.000 0.000 0.020 0.980
#> GSM260892     4  0.0707      0.996 0.000 0.000 0.020 0.980
#> GSM260895     1  0.3528      0.761 0.808 0.000 0.000 0.192
#> GSM260898     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> GSM260901     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> GSM260904     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> GSM260907     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> GSM260910     4  0.0707      0.996 0.000 0.000 0.020 0.980
#> GSM260918     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260921     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260924     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260929     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260932     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260935     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260938     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260941     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260944     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260947     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260952     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260914     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM260916     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM260919     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM260922     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM260925     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM260927     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM260930     1  0.0592      0.984 0.984 0.000 0.000 0.016
#> GSM260933     1  0.0592      0.984 0.984 0.000 0.000 0.016
#> GSM260936     1  0.0592      0.984 0.984 0.000 0.000 0.016
#> GSM260939     1  0.0592      0.984 0.984 0.000 0.000 0.016
#> GSM260942     1  0.0592      0.984 0.984 0.000 0.000 0.016
#> GSM260945     1  0.0592      0.984 0.984 0.000 0.000 0.016
#> GSM260948     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM260950     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM260915     4  0.0817      0.994 0.000 0.000 0.024 0.976
#> GSM260917     4  0.0707      0.996 0.000 0.000 0.020 0.980
#> GSM260920     4  0.1302      0.977 0.000 0.000 0.044 0.956
#> GSM260923     4  0.0707      0.996 0.000 0.000 0.020 0.980
#> GSM260926     4  0.0921      0.992 0.000 0.000 0.028 0.972
#> GSM260928     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM260931     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> GSM260934     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> GSM260937     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> GSM260940     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> GSM260943     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> GSM260946     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> GSM260949     4  0.0707      0.996 0.000 0.000 0.020 0.980
#> GSM260951     3  0.0592      0.984 0.000 0.000 0.984 0.016

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM260888     2  0.0880      0.985 0.000 0.968 0.000 0.032 0.000
#> GSM260893     2  0.0880      0.985 0.000 0.968 0.000 0.032 0.000
#> GSM260896     2  0.0880      0.985 0.000 0.968 0.000 0.032 0.000
#> GSM260899     2  0.0290      0.982 0.000 0.992 0.000 0.008 0.000
#> GSM260902     2  0.0290      0.982 0.000 0.992 0.000 0.008 0.000
#> GSM260905     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000
#> GSM260908     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000
#> GSM260911     2  0.0880      0.985 0.000 0.968 0.000 0.032 0.000
#> GSM260912     2  0.0880      0.985 0.000 0.968 0.000 0.032 0.000
#> GSM260913     3  0.0609      0.913 0.000 0.000 0.980 0.020 0.000
#> GSM260886     1  0.0000      0.992 1.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0162      0.988 0.996 0.000 0.000 0.004 0.000
#> GSM260891     1  0.0000      0.992 1.000 0.000 0.000 0.000 0.000
#> GSM260894     1  0.0000      0.992 1.000 0.000 0.000 0.000 0.000
#> GSM260897     4  0.4375      1.000 0.420 0.000 0.000 0.576 0.004
#> GSM260900     4  0.4375      1.000 0.420 0.000 0.000 0.576 0.004
#> GSM260903     4  0.4375      1.000 0.420 0.000 0.000 0.576 0.004
#> GSM260906     4  0.4375      1.000 0.420 0.000 0.000 0.576 0.004
#> GSM260909     1  0.0000      0.992 1.000 0.000 0.000 0.000 0.000
#> GSM260887     3  0.1043      0.909 0.000 0.000 0.960 0.000 0.040
#> GSM260890     3  0.0162      0.915 0.000 0.000 0.996 0.000 0.004
#> GSM260892     3  0.0703      0.912 0.000 0.000 0.976 0.024 0.000
#> GSM260895     1  0.0794      0.940 0.972 0.000 0.028 0.000 0.000
#> GSM260898     5  0.0000      0.902 0.000 0.000 0.000 0.000 1.000
#> GSM260901     5  0.0000      0.902 0.000 0.000 0.000 0.000 1.000
#> GSM260904     5  0.0000      0.902 0.000 0.000 0.000 0.000 1.000
#> GSM260907     5  0.0000      0.902 0.000 0.000 0.000 0.000 1.000
#> GSM260910     3  0.0404      0.914 0.000 0.000 0.988 0.012 0.000
#> GSM260918     2  0.0880      0.985 0.000 0.968 0.000 0.032 0.000
#> GSM260921     2  0.0880      0.985 0.000 0.968 0.000 0.032 0.000
#> GSM260924     2  0.0880      0.985 0.000 0.968 0.000 0.032 0.000
#> GSM260929     2  0.0880      0.985 0.000 0.968 0.000 0.032 0.000
#> GSM260932     2  0.0290      0.982 0.000 0.992 0.000 0.008 0.000
#> GSM260935     2  0.0290      0.982 0.000 0.992 0.000 0.008 0.000
#> GSM260938     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000
#> GSM260941     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000
#> GSM260944     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000
#> GSM260947     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000
#> GSM260952     2  0.0880      0.985 0.000 0.968 0.000 0.032 0.000
#> GSM260914     1  0.0290      0.984 0.992 0.000 0.000 0.008 0.000
#> GSM260916     1  0.0000      0.992 1.000 0.000 0.000 0.000 0.000
#> GSM260919     1  0.0000      0.992 1.000 0.000 0.000 0.000 0.000
#> GSM260922     1  0.0000      0.992 1.000 0.000 0.000 0.000 0.000
#> GSM260925     1  0.0404      0.979 0.988 0.000 0.000 0.012 0.000
#> GSM260927     1  0.0000      0.992 1.000 0.000 0.000 0.000 0.000
#> GSM260930     4  0.4375      1.000 0.420 0.000 0.000 0.576 0.004
#> GSM260933     4  0.4375      1.000 0.420 0.000 0.000 0.576 0.004
#> GSM260936     4  0.4375      1.000 0.420 0.000 0.000 0.576 0.004
#> GSM260939     4  0.4375      1.000 0.420 0.000 0.000 0.576 0.004
#> GSM260942     4  0.4375      1.000 0.420 0.000 0.000 0.576 0.004
#> GSM260945     4  0.4375      1.000 0.420 0.000 0.000 0.576 0.004
#> GSM260948     1  0.0000      0.992 1.000 0.000 0.000 0.000 0.000
#> GSM260950     1  0.0404      0.979 0.988 0.000 0.000 0.012 0.000
#> GSM260915     3  0.3143      0.807 0.000 0.000 0.796 0.000 0.204
#> GSM260917     3  0.1341      0.904 0.000 0.000 0.944 0.000 0.056
#> GSM260920     3  0.3534      0.751 0.000 0.000 0.744 0.000 0.256
#> GSM260923     3  0.0451      0.915 0.000 0.000 0.988 0.008 0.004
#> GSM260926     3  0.3336      0.784 0.000 0.000 0.772 0.000 0.228
#> GSM260928     1  0.0000      0.992 1.000 0.000 0.000 0.000 0.000
#> GSM260931     5  0.0162      0.901 0.000 0.000 0.000 0.004 0.996
#> GSM260934     5  0.0000      0.902 0.000 0.000 0.000 0.000 1.000
#> GSM260937     5  0.4074      0.728 0.000 0.000 0.000 0.364 0.636
#> GSM260940     5  0.0000      0.902 0.000 0.000 0.000 0.000 1.000
#> GSM260943     5  0.4074      0.728 0.000 0.000 0.000 0.364 0.636
#> GSM260946     5  0.0000      0.902 0.000 0.000 0.000 0.000 1.000
#> GSM260949     3  0.0609      0.913 0.000 0.000 0.980 0.020 0.000
#> GSM260951     5  0.4812      0.700 0.000 0.000 0.028 0.372 0.600

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM260888     2  0.0000      0.810 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260893     2  0.0000      0.810 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260896     2  0.0000      0.810 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260899     2  0.4775      0.791 0.000 0.632 0.000 0.000 0.084 0.284
#> GSM260902     2  0.4775      0.791 0.000 0.632 0.000 0.000 0.084 0.284
#> GSM260905     2  0.4537      0.806 0.000 0.664 0.000 0.000 0.072 0.264
#> GSM260908     2  0.4537      0.806 0.000 0.664 0.000 0.000 0.072 0.264
#> GSM260911     2  0.0000      0.810 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260912     2  0.0000      0.810 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260913     4  0.1267      0.850 0.000 0.000 0.000 0.940 0.060 0.000
#> GSM260886     1  0.0146      0.983 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM260889     1  0.0777      0.971 0.972 0.000 0.000 0.000 0.024 0.004
#> GSM260891     1  0.0146      0.983 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM260894     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260897     5  0.2416      1.000 0.156 0.000 0.000 0.000 0.844 0.000
#> GSM260900     5  0.2416      1.000 0.156 0.000 0.000 0.000 0.844 0.000
#> GSM260903     5  0.2416      1.000 0.156 0.000 0.000 0.000 0.844 0.000
#> GSM260906     5  0.2416      1.000 0.156 0.000 0.000 0.000 0.844 0.000
#> GSM260909     1  0.0146      0.983 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM260887     4  0.1349      0.847 0.000 0.000 0.056 0.940 0.000 0.004
#> GSM260890     4  0.0146      0.854 0.000 0.000 0.004 0.996 0.000 0.000
#> GSM260892     4  0.1387      0.847 0.000 0.000 0.000 0.932 0.068 0.000
#> GSM260895     1  0.0291      0.980 0.992 0.000 0.000 0.004 0.000 0.004
#> GSM260898     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260901     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260904     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260907     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260910     4  0.0937      0.854 0.000 0.000 0.000 0.960 0.040 0.000
#> GSM260918     2  0.0000      0.810 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260921     2  0.0000      0.810 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260924     2  0.0000      0.810 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260929     2  0.0000      0.810 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260932     2  0.4775      0.791 0.000 0.632 0.000 0.000 0.084 0.284
#> GSM260935     2  0.4775      0.791 0.000 0.632 0.000 0.000 0.084 0.284
#> GSM260938     2  0.4537      0.806 0.000 0.664 0.000 0.000 0.072 0.264
#> GSM260941     2  0.4537      0.806 0.000 0.664 0.000 0.000 0.072 0.264
#> GSM260944     2  0.4537      0.806 0.000 0.664 0.000 0.000 0.072 0.264
#> GSM260947     2  0.4537      0.806 0.000 0.664 0.000 0.000 0.072 0.264
#> GSM260952     2  0.0000      0.810 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260914     1  0.0935      0.965 0.964 0.000 0.000 0.000 0.032 0.004
#> GSM260916     1  0.0146      0.983 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM260919     1  0.0146      0.983 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM260922     1  0.0146      0.983 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM260925     1  0.1285      0.946 0.944 0.000 0.000 0.000 0.052 0.004
#> GSM260927     1  0.0146      0.983 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM260930     5  0.2416      1.000 0.156 0.000 0.000 0.000 0.844 0.000
#> GSM260933     5  0.2416      1.000 0.156 0.000 0.000 0.000 0.844 0.000
#> GSM260936     5  0.2416      1.000 0.156 0.000 0.000 0.000 0.844 0.000
#> GSM260939     5  0.2416      1.000 0.156 0.000 0.000 0.000 0.844 0.000
#> GSM260942     5  0.2416      1.000 0.156 0.000 0.000 0.000 0.844 0.000
#> GSM260945     5  0.2416      1.000 0.156 0.000 0.000 0.000 0.844 0.000
#> GSM260948     1  0.0405      0.980 0.988 0.000 0.000 0.000 0.008 0.004
#> GSM260950     1  0.1152      0.954 0.952 0.000 0.000 0.000 0.044 0.004
#> GSM260915     4  0.3405      0.699 0.000 0.000 0.272 0.724 0.000 0.004
#> GSM260917     4  0.1588      0.842 0.000 0.000 0.072 0.924 0.000 0.004
#> GSM260920     4  0.3887      0.563 0.000 0.000 0.360 0.632 0.000 0.008
#> GSM260923     4  0.1151      0.857 0.000 0.000 0.012 0.956 0.032 0.000
#> GSM260926     4  0.3626      0.678 0.000 0.000 0.288 0.704 0.004 0.004
#> GSM260928     1  0.0291      0.982 0.992 0.000 0.000 0.000 0.004 0.004
#> GSM260931     3  0.0363      0.983 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM260934     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM260937     6  0.3409      0.994 0.000 0.000 0.300 0.000 0.000 0.700
#> GSM260940     3  0.0146      0.994 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM260943     6  0.3409      0.994 0.000 0.000 0.300 0.000 0.000 0.700
#> GSM260946     3  0.0146      0.994 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM260949     4  0.1327      0.850 0.000 0.000 0.000 0.936 0.064 0.000
#> GSM260951     6  0.3371      0.988 0.000 0.000 0.292 0.000 0.000 0.708

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) cell.type(p) k
#> ATC:skmeans 67            0.939     2.75e-14 2
#> ATC:skmeans 67            0.940     1.87e-24 3
#> ATC:skmeans 67            0.958     4.88e-23 4
#> ATC:skmeans 67            0.989     7.25e-22 5
#> ATC:skmeans 67            0.768     1.09e-20 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 21168 rows and 67 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4257 0.575   0.575
#> 3 3 1.000           0.998       0.999         0.5836 0.751   0.567
#> 4 4 0.900           0.880       0.844         0.0684 0.955   0.861
#> 5 5 0.968           0.928       0.971         0.0715 0.937   0.778
#> 6 6 0.896           0.910       0.926         0.0749 0.924   0.670

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM260888     2       0          1  0  1
#> GSM260893     2       0          1  0  1
#> GSM260896     2       0          1  0  1
#> GSM260899     2       0          1  0  1
#> GSM260902     2       0          1  0  1
#> GSM260905     2       0          1  0  1
#> GSM260908     2       0          1  0  1
#> GSM260911     2       0          1  0  1
#> GSM260912     2       0          1  0  1
#> GSM260913     1       0          1  1  0
#> GSM260886     1       0          1  1  0
#> GSM260889     1       0          1  1  0
#> GSM260891     1       0          1  1  0
#> GSM260894     1       0          1  1  0
#> GSM260897     1       0          1  1  0
#> GSM260900     1       0          1  1  0
#> GSM260903     1       0          1  1  0
#> GSM260906     1       0          1  1  0
#> GSM260909     1       0          1  1  0
#> GSM260887     1       0          1  1  0
#> GSM260890     1       0          1  1  0
#> GSM260892     1       0          1  1  0
#> GSM260895     1       0          1  1  0
#> GSM260898     1       0          1  1  0
#> GSM260901     1       0          1  1  0
#> GSM260904     1       0          1  1  0
#> GSM260907     1       0          1  1  0
#> GSM260910     1       0          1  1  0
#> GSM260918     2       0          1  0  1
#> GSM260921     2       0          1  0  1
#> GSM260924     2       0          1  0  1
#> GSM260929     2       0          1  0  1
#> GSM260932     2       0          1  0  1
#> GSM260935     2       0          1  0  1
#> GSM260938     2       0          1  0  1
#> GSM260941     2       0          1  0  1
#> GSM260944     2       0          1  0  1
#> GSM260947     2       0          1  0  1
#> GSM260952     2       0          1  0  1
#> GSM260914     1       0          1  1  0
#> GSM260916     1       0          1  1  0
#> GSM260919     1       0          1  1  0
#> GSM260922     1       0          1  1  0
#> GSM260925     1       0          1  1  0
#> GSM260927     1       0          1  1  0
#> GSM260930     1       0          1  1  0
#> GSM260933     1       0          1  1  0
#> GSM260936     1       0          1  1  0
#> GSM260939     1       0          1  1  0
#> GSM260942     1       0          1  1  0
#> GSM260945     1       0          1  1  0
#> GSM260948     1       0          1  1  0
#> GSM260950     1       0          1  1  0
#> GSM260915     1       0          1  1  0
#> GSM260917     1       0          1  1  0
#> GSM260920     1       0          1  1  0
#> GSM260923     1       0          1  1  0
#> GSM260926     1       0          1  1  0
#> GSM260928     1       0          1  1  0
#> GSM260931     1       0          1  1  0
#> GSM260934     1       0          1  1  0
#> GSM260937     1       0          1  1  0
#> GSM260940     1       0          1  1  0
#> GSM260943     1       0          1  1  0
#> GSM260946     1       0          1  1  0
#> GSM260949     1       0          1  1  0
#> GSM260951     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM260888     2   0.000      1.000 0.000  1 0.000
#> GSM260893     2   0.000      1.000 0.000  1 0.000
#> GSM260896     2   0.000      1.000 0.000  1 0.000
#> GSM260899     2   0.000      1.000 0.000  1 0.000
#> GSM260902     2   0.000      1.000 0.000  1 0.000
#> GSM260905     2   0.000      1.000 0.000  1 0.000
#> GSM260908     2   0.000      1.000 0.000  1 0.000
#> GSM260911     2   0.000      1.000 0.000  1 0.000
#> GSM260912     2   0.000      1.000 0.000  1 0.000
#> GSM260913     3   0.000      0.998 0.000  0 1.000
#> GSM260886     1   0.000      0.999 1.000  0 0.000
#> GSM260889     1   0.000      0.999 1.000  0 0.000
#> GSM260891     1   0.000      0.999 1.000  0 0.000
#> GSM260894     1   0.000      0.999 1.000  0 0.000
#> GSM260897     1   0.000      0.999 1.000  0 0.000
#> GSM260900     1   0.000      0.999 1.000  0 0.000
#> GSM260903     1   0.000      0.999 1.000  0 0.000
#> GSM260906     1   0.000      0.999 1.000  0 0.000
#> GSM260909     1   0.000      0.999 1.000  0 0.000
#> GSM260887     3   0.000      0.998 0.000  0 1.000
#> GSM260890     3   0.000      0.998 0.000  0 1.000
#> GSM260892     3   0.000      0.998 0.000  0 1.000
#> GSM260895     1   0.103      0.975 0.976  0 0.024
#> GSM260898     3   0.000      0.998 0.000  0 1.000
#> GSM260901     3   0.000      0.998 0.000  0 1.000
#> GSM260904     3   0.000      0.998 0.000  0 1.000
#> GSM260907     3   0.000      0.998 0.000  0 1.000
#> GSM260910     3   0.000      0.998 0.000  0 1.000
#> GSM260918     2   0.000      1.000 0.000  1 0.000
#> GSM260921     2   0.000      1.000 0.000  1 0.000
#> GSM260924     2   0.000      1.000 0.000  1 0.000
#> GSM260929     2   0.000      1.000 0.000  1 0.000
#> GSM260932     2   0.000      1.000 0.000  1 0.000
#> GSM260935     2   0.000      1.000 0.000  1 0.000
#> GSM260938     2   0.000      1.000 0.000  1 0.000
#> GSM260941     2   0.000      1.000 0.000  1 0.000
#> GSM260944     2   0.000      1.000 0.000  1 0.000
#> GSM260947     2   0.000      1.000 0.000  1 0.000
#> GSM260952     2   0.000      1.000 0.000  1 0.000
#> GSM260914     1   0.000      0.999 1.000  0 0.000
#> GSM260916     1   0.000      0.999 1.000  0 0.000
#> GSM260919     1   0.000      0.999 1.000  0 0.000
#> GSM260922     1   0.000      0.999 1.000  0 0.000
#> GSM260925     1   0.000      0.999 1.000  0 0.000
#> GSM260927     1   0.000      0.999 1.000  0 0.000
#> GSM260930     1   0.000      0.999 1.000  0 0.000
#> GSM260933     1   0.000      0.999 1.000  0 0.000
#> GSM260936     1   0.000      0.999 1.000  0 0.000
#> GSM260939     1   0.000      0.999 1.000  0 0.000
#> GSM260942     1   0.000      0.999 1.000  0 0.000
#> GSM260945     1   0.000      0.999 1.000  0 0.000
#> GSM260948     1   0.000      0.999 1.000  0 0.000
#> GSM260950     1   0.000      0.999 1.000  0 0.000
#> GSM260915     3   0.000      0.998 0.000  0 1.000
#> GSM260917     3   0.000      0.998 0.000  0 1.000
#> GSM260920     3   0.000      0.998 0.000  0 1.000
#> GSM260923     3   0.000      0.998 0.000  0 1.000
#> GSM260926     3   0.000      0.998 0.000  0 1.000
#> GSM260928     1   0.000      0.999 1.000  0 0.000
#> GSM260931     3   0.000      0.998 0.000  0 1.000
#> GSM260934     3   0.000      0.998 0.000  0 1.000
#> GSM260937     3   0.164      0.952 0.044  0 0.956
#> GSM260940     3   0.000      0.998 0.000  0 1.000
#> GSM260943     3   0.000      0.998 0.000  0 1.000
#> GSM260946     3   0.000      0.998 0.000  0 1.000
#> GSM260949     3   0.000      0.998 0.000  0 1.000
#> GSM260951     3   0.000      0.998 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM260888     4   0.470     1.0000 0.000 0.356 0.000 0.644
#> GSM260893     4   0.470     1.0000 0.000 0.356 0.000 0.644
#> GSM260896     4   0.470     1.0000 0.000 0.356 0.000 0.644
#> GSM260899     2   0.000     0.7412 0.000 1.000 0.000 0.000
#> GSM260902     2   0.000     0.7412 0.000 1.000 0.000 0.000
#> GSM260905     2   0.401     0.5795 0.000 0.756 0.000 0.244
#> GSM260908     2   0.376     0.6272 0.000 0.784 0.000 0.216
#> GSM260911     4   0.470     1.0000 0.000 0.356 0.000 0.644
#> GSM260912     4   0.470     1.0000 0.000 0.356 0.000 0.644
#> GSM260913     3   0.470     0.8268 0.000 0.000 0.644 0.356
#> GSM260886     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260889     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260891     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260894     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260897     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260900     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260903     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260906     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260909     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260887     3   0.470     0.8268 0.000 0.000 0.644 0.356
#> GSM260890     3   0.470     0.8268 0.000 0.000 0.644 0.356
#> GSM260892     3   0.470     0.8268 0.000 0.000 0.644 0.356
#> GSM260895     1   0.162     0.9483 0.952 0.000 0.020 0.028
#> GSM260898     3   0.000     0.8268 0.000 0.000 1.000 0.000
#> GSM260901     3   0.000     0.8268 0.000 0.000 1.000 0.000
#> GSM260904     3   0.000     0.8268 0.000 0.000 1.000 0.000
#> GSM260907     3   0.000     0.8268 0.000 0.000 1.000 0.000
#> GSM260910     3   0.470     0.8268 0.000 0.000 0.644 0.356
#> GSM260918     4   0.470     1.0000 0.000 0.356 0.000 0.644
#> GSM260921     4   0.470     1.0000 0.000 0.356 0.000 0.644
#> GSM260924     4   0.470     1.0000 0.000 0.356 0.000 0.644
#> GSM260929     4   0.470     1.0000 0.000 0.356 0.000 0.644
#> GSM260932     2   0.000     0.7412 0.000 1.000 0.000 0.000
#> GSM260935     2   0.000     0.7412 0.000 1.000 0.000 0.000
#> GSM260938     2   0.000     0.7412 0.000 1.000 0.000 0.000
#> GSM260941     2   0.443     0.4130 0.000 0.696 0.000 0.304
#> GSM260944     2   0.376     0.6272 0.000 0.784 0.000 0.216
#> GSM260947     2   0.484    -0.0605 0.000 0.604 0.000 0.396
#> GSM260952     4   0.470     1.0000 0.000 0.356 0.000 0.644
#> GSM260914     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260916     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260919     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260922     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260925     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260927     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260930     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260933     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260936     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260939     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260942     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260945     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260948     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260950     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260915     3   0.470     0.8268 0.000 0.000 0.644 0.356
#> GSM260917     3   0.470     0.8268 0.000 0.000 0.644 0.356
#> GSM260920     3   0.470     0.8268 0.000 0.000 0.644 0.356
#> GSM260923     3   0.470     0.8268 0.000 0.000 0.644 0.356
#> GSM260926     3   0.470     0.8268 0.000 0.000 0.644 0.356
#> GSM260928     1   0.000     0.9979 1.000 0.000 0.000 0.000
#> GSM260931     3   0.000     0.8268 0.000 0.000 1.000 0.000
#> GSM260934     3   0.000     0.8268 0.000 0.000 1.000 0.000
#> GSM260937     3   0.000     0.8268 0.000 0.000 1.000 0.000
#> GSM260940     3   0.000     0.8268 0.000 0.000 1.000 0.000
#> GSM260943     3   0.000     0.8268 0.000 0.000 1.000 0.000
#> GSM260946     3   0.000     0.8268 0.000 0.000 1.000 0.000
#> GSM260949     3   0.470     0.8268 0.000 0.000 0.644 0.356
#> GSM260951     3   0.000     0.8268 0.000 0.000 1.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
#> GSM260888     2   0.000      0.947 0.000 1.000 0.000 0.000  0
#> GSM260893     2   0.000      0.947 0.000 1.000 0.000 0.000  0
#> GSM260896     2   0.000      0.947 0.000 1.000 0.000 0.000  0
#> GSM260899     4   0.000      0.810 0.000 0.000 0.000 1.000  0
#> GSM260902     4   0.000      0.810 0.000 0.000 0.000 1.000  0
#> GSM260905     4   0.416      0.489 0.000 0.392 0.000 0.608  0
#> GSM260908     4   0.342      0.707 0.000 0.240 0.000 0.760  0
#> GSM260911     2   0.000      0.947 0.000 1.000 0.000 0.000  0
#> GSM260912     2   0.000      0.947 0.000 1.000 0.000 0.000  0
#> GSM260913     3   0.000      1.000 0.000 0.000 1.000 0.000  0
#> GSM260886     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260889     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260891     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260894     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260897     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260900     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260903     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260906     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260909     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260887     3   0.000      1.000 0.000 0.000 1.000 0.000  0
#> GSM260890     3   0.000      1.000 0.000 0.000 1.000 0.000  0
#> GSM260892     3   0.000      1.000 0.000 0.000 1.000 0.000  0
#> GSM260895     1   0.318      0.737 0.792 0.000 0.208 0.000  0
#> GSM260898     5   0.000      1.000 0.000 0.000 0.000 0.000  1
#> GSM260901     5   0.000      1.000 0.000 0.000 0.000 0.000  1
#> GSM260904     5   0.000      1.000 0.000 0.000 0.000 0.000  1
#> GSM260907     5   0.000      1.000 0.000 0.000 0.000 0.000  1
#> GSM260910     3   0.000      1.000 0.000 0.000 1.000 0.000  0
#> GSM260918     2   0.000      0.947 0.000 1.000 0.000 0.000  0
#> GSM260921     2   0.000      0.947 0.000 1.000 0.000 0.000  0
#> GSM260924     2   0.000      0.947 0.000 1.000 0.000 0.000  0
#> GSM260929     2   0.000      0.947 0.000 1.000 0.000 0.000  0
#> GSM260932     4   0.000      0.810 0.000 0.000 0.000 1.000  0
#> GSM260935     4   0.000      0.810 0.000 0.000 0.000 1.000  0
#> GSM260938     4   0.000      0.810 0.000 0.000 0.000 1.000  0
#> GSM260941     4   0.430      0.262 0.000 0.480 0.000 0.520  0
#> GSM260944     4   0.342      0.707 0.000 0.240 0.000 0.760  0
#> GSM260947     2   0.421     -0.019 0.000 0.588 0.000 0.412  0
#> GSM260952     2   0.000      0.947 0.000 1.000 0.000 0.000  0
#> GSM260914     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260916     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260919     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260922     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260925     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260927     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260930     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260933     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260936     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260939     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260942     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260945     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260948     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260950     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260915     3   0.000      1.000 0.000 0.000 1.000 0.000  0
#> GSM260917     3   0.000      1.000 0.000 0.000 1.000 0.000  0
#> GSM260920     3   0.000      1.000 0.000 0.000 1.000 0.000  0
#> GSM260923     3   0.000      1.000 0.000 0.000 1.000 0.000  0
#> GSM260926     3   0.000      1.000 0.000 0.000 1.000 0.000  0
#> GSM260928     1   0.000      0.991 1.000 0.000 0.000 0.000  0
#> GSM260931     5   0.000      1.000 0.000 0.000 0.000 0.000  1
#> GSM260934     5   0.000      1.000 0.000 0.000 0.000 0.000  1
#> GSM260937     5   0.000      1.000 0.000 0.000 0.000 0.000  1
#> GSM260940     5   0.000      1.000 0.000 0.000 0.000 0.000  1
#> GSM260943     5   0.000      1.000 0.000 0.000 0.000 0.000  1
#> GSM260946     5   0.000      1.000 0.000 0.000 0.000 0.000  1
#> GSM260949     3   0.000      1.000 0.000 0.000 1.000 0.000  0
#> GSM260951     5   0.000      1.000 0.000 0.000 0.000 0.000  1

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2 p3  p4    p5    p6
#> GSM260888     2   0.000     0.8916 0.000 1.000  0 0.0 0.000 0.000
#> GSM260893     2   0.000     0.8916 0.000 1.000  0 0.0 0.000 0.000
#> GSM260896     2   0.000     0.8916 0.000 1.000  0 0.0 0.000 0.000
#> GSM260899     6   0.000     0.8099 0.000 0.000  0 0.0 0.000 1.000
#> GSM260902     6   0.000     0.8099 0.000 0.000  0 0.0 0.000 1.000
#> GSM260905     6   0.568     0.3927 0.000 0.348  0 0.0 0.168 0.484
#> GSM260908     6   0.506     0.6759 0.000 0.196  0 0.0 0.168 0.636
#> GSM260911     2   0.000     0.8916 0.000 1.000  0 0.0 0.000 0.000
#> GSM260912     2   0.000     0.8916 0.000 1.000  0 0.0 0.000 0.000
#> GSM260913     4   0.000     1.0000 0.000 0.000  0 1.0 0.000 0.000
#> GSM260886     1   0.000     0.9823 1.000 0.000  0 0.0 0.000 0.000
#> GSM260889     1   0.000     0.9823 1.000 0.000  0 0.0 0.000 0.000
#> GSM260891     1   0.000     0.9823 1.000 0.000  0 0.0 0.000 0.000
#> GSM260894     1   0.000     0.9823 1.000 0.000  0 0.0 0.000 0.000
#> GSM260897     5   0.253     1.0000 0.168 0.000  0 0.0 0.832 0.000
#> GSM260900     5   0.253     1.0000 0.168 0.000  0 0.0 0.832 0.000
#> GSM260903     5   0.253     1.0000 0.168 0.000  0 0.0 0.832 0.000
#> GSM260906     5   0.253     1.0000 0.168 0.000  0 0.0 0.832 0.000
#> GSM260909     1   0.000     0.9823 1.000 0.000  0 0.0 0.000 0.000
#> GSM260887     4   0.000     1.0000 0.000 0.000  0 1.0 0.000 0.000
#> GSM260890     4   0.000     1.0000 0.000 0.000  0 1.0 0.000 0.000
#> GSM260892     4   0.000     1.0000 0.000 0.000  0 1.0 0.000 0.000
#> GSM260895     1   0.000     0.9823 1.000 0.000  0 0.0 0.000 0.000
#> GSM260898     3   0.000     1.0000 0.000 0.000  1 0.0 0.000 0.000
#> GSM260901     3   0.000     1.0000 0.000 0.000  1 0.0 0.000 0.000
#> GSM260904     3   0.000     1.0000 0.000 0.000  1 0.0 0.000 0.000
#> GSM260907     3   0.000     1.0000 0.000 0.000  1 0.0 0.000 0.000
#> GSM260910     4   0.000     1.0000 0.000 0.000  0 1.0 0.000 0.000
#> GSM260918     2   0.000     0.8916 0.000 1.000  0 0.0 0.000 0.000
#> GSM260921     2   0.000     0.8916 0.000 1.000  0 0.0 0.000 0.000
#> GSM260924     2   0.000     0.8916 0.000 1.000  0 0.0 0.000 0.000
#> GSM260929     2   0.000     0.8916 0.000 1.000  0 0.0 0.000 0.000
#> GSM260932     6   0.000     0.8099 0.000 0.000  0 0.0 0.000 1.000
#> GSM260935     6   0.000     0.8099 0.000 0.000  0 0.0 0.000 1.000
#> GSM260938     6   0.253     0.7832 0.000 0.000  0 0.0 0.168 0.832
#> GSM260941     2   0.574    -0.2712 0.000 0.436  0 0.0 0.168 0.396
#> GSM260944     6   0.506     0.6759 0.000 0.196  0 0.0 0.168 0.636
#> GSM260947     2   0.552     0.0989 0.000 0.544  0 0.0 0.168 0.288
#> GSM260952     2   0.000     0.8916 0.000 1.000  0 0.0 0.000 0.000
#> GSM260914     1   0.000     0.9823 1.000 0.000  0 0.0 0.000 0.000
#> GSM260916     1   0.000     0.9823 1.000 0.000  0 0.0 0.000 0.000
#> GSM260919     1   0.000     0.9823 1.000 0.000  0 0.0 0.000 0.000
#> GSM260922     1   0.000     0.9823 1.000 0.000  0 0.0 0.000 0.000
#> GSM260925     1   0.000     0.9823 1.000 0.000  0 0.0 0.000 0.000
#> GSM260927     1   0.000     0.9823 1.000 0.000  0 0.0 0.000 0.000
#> GSM260930     5   0.253     1.0000 0.168 0.000  0 0.0 0.832 0.000
#> GSM260933     5   0.253     1.0000 0.168 0.000  0 0.0 0.832 0.000
#> GSM260936     5   0.253     1.0000 0.168 0.000  0 0.0 0.832 0.000
#> GSM260939     5   0.253     1.0000 0.168 0.000  0 0.0 0.832 0.000
#> GSM260942     5   0.253     1.0000 0.168 0.000  0 0.0 0.832 0.000
#> GSM260945     5   0.253     1.0000 0.168 0.000  0 0.0 0.832 0.000
#> GSM260948     1   0.000     0.9823 1.000 0.000  0 0.0 0.000 0.000
#> GSM260950     1   0.000     0.9823 1.000 0.000  0 0.0 0.000 0.000
#> GSM260915     4   0.000     1.0000 0.000 0.000  0 1.0 0.000 0.000
#> GSM260917     4   0.000     1.0000 0.000 0.000  0 1.0 0.000 0.000
#> GSM260920     4   0.000     1.0000 0.000 0.000  0 1.0 0.000 0.000
#> GSM260923     4   0.000     1.0000 0.000 0.000  0 1.0 0.000 0.000
#> GSM260926     4   0.000     1.0000 0.000 0.000  0 1.0 0.000 0.000
#> GSM260928     1   0.279     0.7239 0.800 0.000  0 0.2 0.000 0.000
#> GSM260931     3   0.000     1.0000 0.000 0.000  1 0.0 0.000 0.000
#> GSM260934     3   0.000     1.0000 0.000 0.000  1 0.0 0.000 0.000
#> GSM260937     3   0.000     1.0000 0.000 0.000  1 0.0 0.000 0.000
#> GSM260940     3   0.000     1.0000 0.000 0.000  1 0.0 0.000 0.000
#> GSM260943     3   0.000     1.0000 0.000 0.000  1 0.0 0.000 0.000
#> GSM260946     3   0.000     1.0000 0.000 0.000  1 0.0 0.000 0.000
#> GSM260949     4   0.000     1.0000 0.000 0.000  0 1.0 0.000 0.000
#> GSM260951     3   0.000     1.0000 0.000 0.000  1 0.0 0.000 0.000

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

consensus_heatmap(res, k = 2)

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) cell.type(p) k
#> ATC:pam 67            0.939     2.75e-14 2
#> ATC:pam 67            0.940     1.87e-24 3
#> ATC:pam 65            0.921     3.53e-22 4
#> ATC:pam 64            0.973     1.48e-20 5
#> ATC:pam 64            0.992     1.60e-19 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 21168 rows and 67 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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.775           0.952       0.954          0.440 0.563   0.563
#> 3 3 1.000           1.000       1.000          0.534 0.744   0.553
#> 4 4 1.000           0.994       0.997          0.067 0.955   0.861
#> 5 5 1.000           0.986       0.986          0.033 0.979   0.926
#> 6 6 0.893           0.888       0.899          0.109 0.875   0.541

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM260888     2   0.000      0.988 0.000 1.000
#> GSM260893     2   0.000      0.988 0.000 1.000
#> GSM260896     2   0.000      0.988 0.000 1.000
#> GSM260899     2   0.000      0.988 0.000 1.000
#> GSM260902     2   0.000      0.988 0.000 1.000
#> GSM260905     2   0.000      0.988 0.000 1.000
#> GSM260908     2   0.000      0.988 0.000 1.000
#> GSM260911     2   0.000      0.988 0.000 1.000
#> GSM260912     2   0.000      0.988 0.000 1.000
#> GSM260913     1   0.443      0.936 0.908 0.092
#> GSM260886     1   0.163      0.946 0.976 0.024
#> GSM260889     1   0.163      0.946 0.976 0.024
#> GSM260891     1   0.163      0.946 0.976 0.024
#> GSM260894     1   0.163      0.946 0.976 0.024
#> GSM260897     1   0.163      0.946 0.976 0.024
#> GSM260900     1   0.163      0.946 0.976 0.024
#> GSM260903     1   0.163      0.946 0.976 0.024
#> GSM260906     1   0.163      0.946 0.976 0.024
#> GSM260909     1   0.163      0.946 0.976 0.024
#> GSM260887     1   0.443      0.936 0.908 0.092
#> GSM260890     1   0.443      0.936 0.908 0.092
#> GSM260892     1   0.443      0.936 0.908 0.092
#> GSM260895     1   0.000      0.940 1.000 0.000
#> GSM260898     1   0.443      0.936 0.908 0.092
#> GSM260901     1   0.443      0.936 0.908 0.092
#> GSM260904     1   0.443      0.936 0.908 0.092
#> GSM260907     1   0.443      0.936 0.908 0.092
#> GSM260910     1   0.443      0.936 0.908 0.092
#> GSM260918     2   0.000      0.988 0.000 1.000
#> GSM260921     2   0.000      0.988 0.000 1.000
#> GSM260924     2   0.000      0.988 0.000 1.000
#> GSM260929     2   0.000      0.988 0.000 1.000
#> GSM260932     2   0.000      0.988 0.000 1.000
#> GSM260935     2   0.000      0.988 0.000 1.000
#> GSM260938     2   0.000      0.988 0.000 1.000
#> GSM260941     2   0.000      0.988 0.000 1.000
#> GSM260944     2   0.000      0.988 0.000 1.000
#> GSM260947     2   0.000      0.988 0.000 1.000
#> GSM260952     2   0.000      0.988 0.000 1.000
#> GSM260914     1   0.163      0.946 0.976 0.024
#> GSM260916     1   0.163      0.946 0.976 0.024
#> GSM260919     1   0.163      0.946 0.976 0.024
#> GSM260922     1   0.163      0.946 0.976 0.024
#> GSM260925     1   0.163      0.946 0.976 0.024
#> GSM260927     1   0.163      0.946 0.976 0.024
#> GSM260930     1   0.163      0.946 0.976 0.024
#> GSM260933     1   0.163      0.946 0.976 0.024
#> GSM260936     1   0.163      0.946 0.976 0.024
#> GSM260939     1   0.141      0.945 0.980 0.020
#> GSM260942     1   0.163      0.946 0.976 0.024
#> GSM260945     1   0.163      0.946 0.976 0.024
#> GSM260948     1   0.163      0.946 0.976 0.024
#> GSM260950     1   0.163      0.946 0.976 0.024
#> GSM260915     1   0.443      0.936 0.908 0.092
#> GSM260917     1   0.443      0.936 0.908 0.092
#> GSM260920     1   0.443      0.936 0.908 0.092
#> GSM260923     1   0.443      0.936 0.908 0.092
#> GSM260926     1   0.443      0.936 0.908 0.092
#> GSM260928     1   0.000      0.940 1.000 0.000
#> GSM260931     1   0.443      0.936 0.908 0.092
#> GSM260934     1   0.443      0.936 0.908 0.092
#> GSM260937     2   0.767      0.703 0.224 0.776
#> GSM260940     1   0.443      0.936 0.908 0.092
#> GSM260943     1   0.443      0.936 0.908 0.092
#> GSM260946     1   0.443      0.936 0.908 0.092
#> GSM260949     1   0.443      0.936 0.908 0.092
#> GSM260951     1   0.443      0.936 0.908 0.092

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM260888     2  0.0000      1.000 0.000  1 0.000
#> GSM260893     2  0.0000      1.000 0.000  1 0.000
#> GSM260896     2  0.0000      1.000 0.000  1 0.000
#> GSM260899     2  0.0000      1.000 0.000  1 0.000
#> GSM260902     2  0.0000      1.000 0.000  1 0.000
#> GSM260905     2  0.0000      1.000 0.000  1 0.000
#> GSM260908     2  0.0000      1.000 0.000  1 0.000
#> GSM260911     2  0.0000      1.000 0.000  1 0.000
#> GSM260912     2  0.0000      1.000 0.000  1 0.000
#> GSM260913     3  0.0000      1.000 0.000  0 1.000
#> GSM260886     1  0.0000      1.000 1.000  0 0.000
#> GSM260889     1  0.0000      1.000 1.000  0 0.000
#> GSM260891     1  0.0000      1.000 1.000  0 0.000
#> GSM260894     1  0.0000      1.000 1.000  0 0.000
#> GSM260897     1  0.0000      1.000 1.000  0 0.000
#> GSM260900     1  0.0000      1.000 1.000  0 0.000
#> GSM260903     1  0.0000      1.000 1.000  0 0.000
#> GSM260906     1  0.0000      1.000 1.000  0 0.000
#> GSM260909     1  0.0000      1.000 1.000  0 0.000
#> GSM260887     3  0.0000      1.000 0.000  0 1.000
#> GSM260890     3  0.0000      1.000 0.000  0 1.000
#> GSM260892     3  0.0000      1.000 0.000  0 1.000
#> GSM260895     1  0.0237      0.996 0.996  0 0.004
#> GSM260898     3  0.0000      1.000 0.000  0 1.000
#> GSM260901     3  0.0000      1.000 0.000  0 1.000
#> GSM260904     3  0.0000      1.000 0.000  0 1.000
#> GSM260907     3  0.0000      1.000 0.000  0 1.000
#> GSM260910     3  0.0000      1.000 0.000  0 1.000
#> GSM260918     2  0.0000      1.000 0.000  1 0.000
#> GSM260921     2  0.0000      1.000 0.000  1 0.000
#> GSM260924     2  0.0000      1.000 0.000  1 0.000
#> GSM260929     2  0.0000      1.000 0.000  1 0.000
#> GSM260932     2  0.0000      1.000 0.000  1 0.000
#> GSM260935     2  0.0000      1.000 0.000  1 0.000
#> GSM260938     2  0.0000      1.000 0.000  1 0.000
#> GSM260941     2  0.0000      1.000 0.000  1 0.000
#> GSM260944     2  0.0000      1.000 0.000  1 0.000
#> GSM260947     2  0.0000      1.000 0.000  1 0.000
#> GSM260952     2  0.0000      1.000 0.000  1 0.000
#> GSM260914     1  0.0000      1.000 1.000  0 0.000
#> GSM260916     1  0.0000      1.000 1.000  0 0.000
#> GSM260919     1  0.0000      1.000 1.000  0 0.000
#> GSM260922     1  0.0000      1.000 1.000  0 0.000
#> GSM260925     1  0.0000      1.000 1.000  0 0.000
#> GSM260927     1  0.0000      1.000 1.000  0 0.000
#> GSM260930     1  0.0000      1.000 1.000  0 0.000
#> GSM260933     1  0.0000      1.000 1.000  0 0.000
#> GSM260936     1  0.0000      1.000 1.000  0 0.000
#> GSM260939     1  0.0000      1.000 1.000  0 0.000
#> GSM260942     1  0.0000      1.000 1.000  0 0.000
#> GSM260945     1  0.0000      1.000 1.000  0 0.000
#> GSM260948     1  0.0000      1.000 1.000  0 0.000
#> GSM260950     1  0.0000      1.000 1.000  0 0.000
#> GSM260915     3  0.0000      1.000 0.000  0 1.000
#> GSM260917     3  0.0000      1.000 0.000  0 1.000
#> GSM260920     3  0.0000      1.000 0.000  0 1.000
#> GSM260923     3  0.0000      1.000 0.000  0 1.000
#> GSM260926     3  0.0000      1.000 0.000  0 1.000
#> GSM260928     1  0.0237      0.996 0.996  0 0.004
#> GSM260931     3  0.0000      1.000 0.000  0 1.000
#> GSM260934     3  0.0000      1.000 0.000  0 1.000
#> GSM260937     3  0.0000      1.000 0.000  0 1.000
#> GSM260940     3  0.0000      1.000 0.000  0 1.000
#> GSM260943     3  0.0000      1.000 0.000  0 1.000
#> GSM260946     3  0.0000      1.000 0.000  0 1.000
#> GSM260949     3  0.0000      1.000 0.000  0 1.000
#> GSM260951     3  0.0000      1.000 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2   p3    p4
#> GSM260888     2  0.0000      1.000 0.000 1.000 0.00 0.000
#> GSM260893     2  0.0000      1.000 0.000 1.000 0.00 0.000
#> GSM260896     2  0.0000      1.000 0.000 1.000 0.00 0.000
#> GSM260899     4  0.0188      1.000 0.000 0.004 0.00 0.996
#> GSM260902     4  0.0188      1.000 0.000 0.004 0.00 0.996
#> GSM260905     4  0.0188      1.000 0.000 0.004 0.00 0.996
#> GSM260908     4  0.0188      1.000 0.000 0.004 0.00 0.996
#> GSM260911     2  0.0000      1.000 0.000 1.000 0.00 0.000
#> GSM260912     2  0.0000      1.000 0.000 1.000 0.00 0.000
#> GSM260913     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260886     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260889     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260891     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260894     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260897     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260900     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260903     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260906     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260909     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260887     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260890     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260892     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260895     1  0.2197      0.904 0.916 0.000 0.08 0.004
#> GSM260898     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260901     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260904     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260907     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260910     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260918     2  0.0000      1.000 0.000 1.000 0.00 0.000
#> GSM260921     2  0.0000      1.000 0.000 1.000 0.00 0.000
#> GSM260924     2  0.0000      1.000 0.000 1.000 0.00 0.000
#> GSM260929     2  0.0000      1.000 0.000 1.000 0.00 0.000
#> GSM260932     4  0.0188      1.000 0.000 0.004 0.00 0.996
#> GSM260935     4  0.0188      1.000 0.000 0.004 0.00 0.996
#> GSM260938     4  0.0188      1.000 0.000 0.004 0.00 0.996
#> GSM260941     4  0.0188      1.000 0.000 0.004 0.00 0.996
#> GSM260944     4  0.0188      1.000 0.000 0.004 0.00 0.996
#> GSM260947     4  0.0188      1.000 0.000 0.004 0.00 0.996
#> GSM260952     2  0.0000      1.000 0.000 1.000 0.00 0.000
#> GSM260914     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260916     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260919     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260922     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260925     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260927     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260930     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260933     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260936     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260939     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260942     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260945     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260948     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260950     1  0.0000      0.992 1.000 0.000 0.00 0.000
#> GSM260915     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260917     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260920     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260923     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260926     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260928     1  0.2197      0.904 0.916 0.000 0.08 0.004
#> GSM260931     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260934     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260937     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260940     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260943     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260946     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260949     3  0.0000      1.000 0.000 0.000 1.00 0.000
#> GSM260951     3  0.0000      1.000 0.000 0.000 1.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
#> GSM260888     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM260893     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM260896     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM260899     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000
#> GSM260902     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000
#> GSM260905     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000
#> GSM260908     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000
#> GSM260911     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM260912     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM260913     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM260886     1  0.0000      0.967 1.000 0.000 0.000 0.000 0.000
#> GSM260889     1  0.0000      0.967 1.000 0.000 0.000 0.000 0.000
#> GSM260891     1  0.0000      0.967 1.000 0.000 0.000 0.000 0.000
#> GSM260894     1  0.0000      0.967 1.000 0.000 0.000 0.000 0.000
#> GSM260897     1  0.1608      0.958 0.928 0.000 0.000 0.072 0.000
#> GSM260900     1  0.1608      0.958 0.928 0.000 0.000 0.072 0.000
#> GSM260903     1  0.1608      0.958 0.928 0.000 0.000 0.072 0.000
#> GSM260906     1  0.1608      0.958 0.928 0.000 0.000 0.072 0.000
#> GSM260909     1  0.0000      0.967 1.000 0.000 0.000 0.000 0.000
#> GSM260887     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM260890     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM260892     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM260895     4  0.1671      1.000 0.000 0.000 0.076 0.924 0.000
#> GSM260898     3  0.0162      0.998 0.000 0.000 0.996 0.004 0.000
#> GSM260901     3  0.0162      0.998 0.000 0.000 0.996 0.004 0.000
#> GSM260904     3  0.0162      0.998 0.000 0.000 0.996 0.004 0.000
#> GSM260907     3  0.0162      0.998 0.000 0.000 0.996 0.004 0.000
#> GSM260910     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM260918     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM260921     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM260924     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM260929     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM260932     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000
#> GSM260935     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000
#> GSM260938     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000
#> GSM260941     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000
#> GSM260944     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000
#> GSM260947     5  0.0703      0.969 0.000 0.024 0.000 0.000 0.976
#> GSM260952     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM260914     1  0.0000      0.967 1.000 0.000 0.000 0.000 0.000
#> GSM260916     1  0.0162      0.965 0.996 0.000 0.000 0.004 0.000
#> GSM260919     1  0.0000      0.967 1.000 0.000 0.000 0.000 0.000
#> GSM260922     1  0.0290      0.963 0.992 0.000 0.000 0.008 0.000
#> GSM260925     1  0.0000      0.967 1.000 0.000 0.000 0.000 0.000
#> GSM260927     1  0.0000      0.967 1.000 0.000 0.000 0.000 0.000
#> GSM260930     1  0.1608      0.958 0.928 0.000 0.000 0.072 0.000
#> GSM260933     1  0.1608      0.958 0.928 0.000 0.000 0.072 0.000
#> GSM260936     1  0.1608      0.958 0.928 0.000 0.000 0.072 0.000
#> GSM260939     1  0.1608      0.958 0.928 0.000 0.000 0.072 0.000
#> GSM260942     1  0.1608      0.958 0.928 0.000 0.000 0.072 0.000
#> GSM260945     1  0.1608      0.958 0.928 0.000 0.000 0.072 0.000
#> GSM260948     1  0.0000      0.967 1.000 0.000 0.000 0.000 0.000
#> GSM260950     1  0.0000      0.967 1.000 0.000 0.000 0.000 0.000
#> GSM260915     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM260917     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM260920     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM260923     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM260926     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM260928     4  0.1671      1.000 0.000 0.000 0.076 0.924 0.000
#> GSM260931     3  0.0162      0.998 0.000 0.000 0.996 0.004 0.000
#> GSM260934     3  0.0162      0.998 0.000 0.000 0.996 0.004 0.000
#> GSM260937     3  0.0162      0.998 0.000 0.000 0.996 0.004 0.000
#> GSM260940     3  0.0162      0.998 0.000 0.000 0.996 0.004 0.000
#> GSM260943     3  0.0162      0.998 0.000 0.000 0.996 0.004 0.000
#> GSM260946     3  0.0162      0.998 0.000 0.000 0.996 0.004 0.000
#> GSM260949     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM260951     3  0.0000      0.998 0.000 0.000 1.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
#> GSM260888     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260893     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260896     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260899     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260902     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260905     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260908     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260911     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260912     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260913     4  0.0000      0.996 0.000  0 0.000 1.000 0.000  0
#> GSM260886     1  0.3684      0.784 0.628  0 0.000 0.000 0.372  0
#> GSM260889     1  0.3684      0.784 0.628  0 0.000 0.000 0.372  0
#> GSM260891     1  0.4249      0.741 0.640  0 0.000 0.032 0.328  0
#> GSM260894     1  0.3684      0.784 0.628  0 0.000 0.000 0.372  0
#> GSM260897     5  0.0000      0.998 0.000  0 0.000 0.000 1.000  0
#> GSM260900     5  0.0000      0.998 0.000  0 0.000 0.000 1.000  0
#> GSM260903     5  0.0000      0.998 0.000  0 0.000 0.000 1.000  0
#> GSM260906     5  0.0000      0.998 0.000  0 0.000 0.000 1.000  0
#> GSM260909     1  0.3684      0.784 0.628  0 0.000 0.000 0.372  0
#> GSM260887     4  0.0000      0.996 0.000  0 0.000 1.000 0.000  0
#> GSM260890     4  0.0000      0.996 0.000  0 0.000 1.000 0.000  0
#> GSM260892     4  0.0000      0.996 0.000  0 0.000 1.000 0.000  0
#> GSM260895     1  0.3110      0.365 0.792  0 0.012 0.196 0.000  0
#> GSM260898     3  0.3288      0.723 0.000  0 0.724 0.276 0.000  0
#> GSM260901     3  0.3774      0.589 0.000  0 0.592 0.408 0.000  0
#> GSM260904     3  0.3843      0.508 0.000  0 0.548 0.452 0.000  0
#> GSM260907     3  0.1610      0.791 0.000  0 0.916 0.084 0.000  0
#> GSM260910     4  0.0000      0.996 0.000  0 0.000 1.000 0.000  0
#> GSM260918     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260921     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260924     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260929     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260932     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260935     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260938     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260941     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260944     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260947     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM260952     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM260914     1  0.3684      0.784 0.628  0 0.000 0.000 0.372  0
#> GSM260916     1  0.1194      0.564 0.956  0 0.004 0.032 0.008  0
#> GSM260919     1  0.3684      0.784 0.628  0 0.000 0.000 0.372  0
#> GSM260922     1  0.1307      0.562 0.952  0 0.008 0.032 0.008  0
#> GSM260925     1  0.3695      0.779 0.624  0 0.000 0.000 0.376  0
#> GSM260927     1  0.3684      0.784 0.628  0 0.000 0.000 0.372  0
#> GSM260930     5  0.0000      0.998 0.000  0 0.000 0.000 1.000  0
#> GSM260933     5  0.0000      0.998 0.000  0 0.000 0.000 1.000  0
#> GSM260936     5  0.0000      0.998 0.000  0 0.000 0.000 1.000  0
#> GSM260939     5  0.0405      0.984 0.008  0 0.004 0.000 0.988  0
#> GSM260942     5  0.0000      0.998 0.000  0 0.000 0.000 1.000  0
#> GSM260945     5  0.0000      0.998 0.000  0 0.000 0.000 1.000  0
#> GSM260948     1  0.3684      0.784 0.628  0 0.000 0.000 0.372  0
#> GSM260950     1  0.3684      0.784 0.628  0 0.000 0.000 0.372  0
#> GSM260915     4  0.0260      0.991 0.000  0 0.008 0.992 0.000  0
#> GSM260917     4  0.0146      0.994 0.004  0 0.000 0.996 0.000  0
#> GSM260920     4  0.0260      0.991 0.000  0 0.008 0.992 0.000  0
#> GSM260923     4  0.0146      0.994 0.004  0 0.000 0.996 0.000  0
#> GSM260926     4  0.0260      0.991 0.000  0 0.008 0.992 0.000  0
#> GSM260928     1  0.3110      0.365 0.792  0 0.012 0.196 0.000  0
#> GSM260931     3  0.0363      0.774 0.000  0 0.988 0.012 0.000  0
#> GSM260934     3  0.1141      0.788 0.000  0 0.948 0.052 0.000  0
#> GSM260937     3  0.2854      0.738 0.000  0 0.792 0.208 0.000  0
#> GSM260940     3  0.3288      0.723 0.000  0 0.724 0.276 0.000  0
#> GSM260943     3  0.2762      0.747 0.000  0 0.804 0.196 0.000  0
#> GSM260946     3  0.0363      0.774 0.000  0 0.988 0.012 0.000  0
#> GSM260949     4  0.0000      0.996 0.000  0 0.000 1.000 0.000  0
#> GSM260951     4  0.0146      0.994 0.004  0 0.000 0.996 0.000  0

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

consensus_heatmap(res, k = 2)

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) cell.type(p) k
#> ATC:mclust 67            1.000     2.38e-13 2
#> ATC:mclust 67            0.940     1.87e-24 3
#> ATC:mclust 67            0.954     5.58e-23 4
#> ATC:mclust 67            0.981     6.76e-24 5
#> ATC:mclust 65            0.996     6.69e-22 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 21168 rows and 67 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 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-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           1.000       1.000         0.4257 0.575   0.575
#> 3 3 0.941           0.978       0.976         0.5628 0.751   0.567
#> 4 4 0.940           0.890       0.947         0.0549 0.982   0.945
#> 5 5 0.897           0.837       0.907         0.0387 0.982   0.942
#> 6 6 0.866           0.820       0.905         0.0251 0.960   0.865

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM260888     2       0          1  0  1
#> GSM260893     2       0          1  0  1
#> GSM260896     2       0          1  0  1
#> GSM260899     2       0          1  0  1
#> GSM260902     2       0          1  0  1
#> GSM260905     2       0          1  0  1
#> GSM260908     2       0          1  0  1
#> GSM260911     2       0          1  0  1
#> GSM260912     2       0          1  0  1
#> GSM260913     1       0          1  1  0
#> GSM260886     1       0          1  1  0
#> GSM260889     1       0          1  1  0
#> GSM260891     1       0          1  1  0
#> GSM260894     1       0          1  1  0
#> GSM260897     1       0          1  1  0
#> GSM260900     1       0          1  1  0
#> GSM260903     1       0          1  1  0
#> GSM260906     1       0          1  1  0
#> GSM260909     1       0          1  1  0
#> GSM260887     1       0          1  1  0
#> GSM260890     1       0          1  1  0
#> GSM260892     1       0          1  1  0
#> GSM260895     1       0          1  1  0
#> GSM260898     1       0          1  1  0
#> GSM260901     1       0          1  1  0
#> GSM260904     1       0          1  1  0
#> GSM260907     1       0          1  1  0
#> GSM260910     1       0          1  1  0
#> GSM260918     2       0          1  0  1
#> GSM260921     2       0          1  0  1
#> GSM260924     2       0          1  0  1
#> GSM260929     2       0          1  0  1
#> GSM260932     2       0          1  0  1
#> GSM260935     2       0          1  0  1
#> GSM260938     2       0          1  0  1
#> GSM260941     2       0          1  0  1
#> GSM260944     2       0          1  0  1
#> GSM260947     2       0          1  0  1
#> GSM260952     2       0          1  0  1
#> GSM260914     1       0          1  1  0
#> GSM260916     1       0          1  1  0
#> GSM260919     1       0          1  1  0
#> GSM260922     1       0          1  1  0
#> GSM260925     1       0          1  1  0
#> GSM260927     1       0          1  1  0
#> GSM260930     1       0          1  1  0
#> GSM260933     1       0          1  1  0
#> GSM260936     1       0          1  1  0
#> GSM260939     1       0          1  1  0
#> GSM260942     1       0          1  1  0
#> GSM260945     1       0          1  1  0
#> GSM260948     1       0          1  1  0
#> GSM260950     1       0          1  1  0
#> GSM260915     1       0          1  1  0
#> GSM260917     1       0          1  1  0
#> GSM260920     1       0          1  1  0
#> GSM260923     1       0          1  1  0
#> GSM260926     1       0          1  1  0
#> GSM260928     1       0          1  1  0
#> GSM260931     1       0          1  1  0
#> GSM260934     1       0          1  1  0
#> GSM260937     1       0          1  1  0
#> GSM260940     1       0          1  1  0
#> GSM260943     1       0          1  1  0
#> GSM260946     1       0          1  1  0
#> GSM260949     1       0          1  1  0
#> GSM260951     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM260888     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260893     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260896     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260899     2  0.0237      0.997 0.000 0.996 0.004
#> GSM260902     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260905     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260908     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260911     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260912     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260913     3  0.2878      0.947 0.096 0.000 0.904
#> GSM260886     1  0.0237      0.987 0.996 0.000 0.004
#> GSM260889     1  0.0237      0.987 0.996 0.000 0.004
#> GSM260891     1  0.0424      0.986 0.992 0.000 0.008
#> GSM260894     1  0.0237      0.987 0.996 0.000 0.004
#> GSM260897     1  0.0237      0.988 0.996 0.000 0.004
#> GSM260900     1  0.0237      0.988 0.996 0.000 0.004
#> GSM260903     1  0.0237      0.988 0.996 0.000 0.004
#> GSM260906     1  0.0237      0.988 0.996 0.000 0.004
#> GSM260909     1  0.0237      0.987 0.996 0.000 0.004
#> GSM260887     3  0.2448      0.957 0.076 0.000 0.924
#> GSM260890     3  0.2711      0.952 0.088 0.000 0.912
#> GSM260892     3  0.2959      0.946 0.100 0.000 0.900
#> GSM260895     1  0.3879      0.814 0.848 0.000 0.152
#> GSM260898     3  0.1163      0.959 0.028 0.000 0.972
#> GSM260901     3  0.1753      0.955 0.048 0.000 0.952
#> GSM260904     3  0.1964      0.963 0.056 0.000 0.944
#> GSM260907     3  0.1163      0.959 0.028 0.000 0.972
#> GSM260910     3  0.2878      0.947 0.096 0.000 0.904
#> GSM260918     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260921     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260924     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260929     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260932     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260935     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260938     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260941     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260944     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260947     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260952     2  0.0000      1.000 0.000 1.000 0.000
#> GSM260914     1  0.0000      0.987 1.000 0.000 0.000
#> GSM260916     1  0.0424      0.986 0.992 0.000 0.008
#> GSM260919     1  0.0237      0.987 0.996 0.000 0.004
#> GSM260922     1  0.0424      0.986 0.992 0.000 0.008
#> GSM260925     1  0.0237      0.988 0.996 0.000 0.004
#> GSM260927     1  0.0424      0.987 0.992 0.000 0.008
#> GSM260930     1  0.0237      0.988 0.996 0.000 0.004
#> GSM260933     1  0.0237      0.988 0.996 0.000 0.004
#> GSM260936     1  0.0237      0.988 0.996 0.000 0.004
#> GSM260939     1  0.0424      0.986 0.992 0.000 0.008
#> GSM260942     1  0.0424      0.986 0.992 0.000 0.008
#> GSM260945     1  0.0237      0.988 0.996 0.000 0.004
#> GSM260948     1  0.0000      0.987 1.000 0.000 0.000
#> GSM260950     1  0.0237      0.988 0.996 0.000 0.004
#> GSM260915     3  0.2261      0.960 0.068 0.000 0.932
#> GSM260917     3  0.1643      0.962 0.044 0.000 0.956
#> GSM260920     3  0.2356      0.960 0.072 0.000 0.928
#> GSM260923     3  0.2878      0.947 0.096 0.000 0.904
#> GSM260926     3  0.1860      0.964 0.052 0.000 0.948
#> GSM260928     1  0.1643      0.954 0.956 0.000 0.044
#> GSM260931     3  0.1163      0.959 0.028 0.000 0.972
#> GSM260934     3  0.1163      0.959 0.028 0.000 0.972
#> GSM260937     3  0.1860      0.954 0.052 0.000 0.948
#> GSM260940     3  0.1753      0.955 0.048 0.000 0.952
#> GSM260943     3  0.1163      0.959 0.028 0.000 0.972
#> GSM260946     3  0.1031      0.957 0.024 0.000 0.976
#> GSM260949     3  0.2878      0.947 0.096 0.000 0.904
#> GSM260951     3  0.1289      0.961 0.032 0.000 0.968

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM260888     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260893     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260896     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260899     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260902     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260905     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260908     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260911     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260912     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260913     3  0.1489      0.828 0.004 0.000 0.952 0.044
#> GSM260886     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM260889     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM260891     1  0.1022      0.945 0.968 0.000 0.000 0.032
#> GSM260894     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM260897     1  0.1211      0.955 0.960 0.000 0.000 0.040
#> GSM260900     1  0.1211      0.955 0.960 0.000 0.000 0.040
#> GSM260903     1  0.1211      0.955 0.960 0.000 0.000 0.040
#> GSM260906     1  0.1211      0.955 0.960 0.000 0.000 0.040
#> GSM260909     1  0.0188      0.958 0.996 0.000 0.000 0.004
#> GSM260887     3  0.0524      0.854 0.004 0.000 0.988 0.008
#> GSM260890     3  0.0779      0.851 0.004 0.000 0.980 0.016
#> GSM260892     3  0.3142      0.663 0.008 0.000 0.860 0.132
#> GSM260895     1  0.5977      0.577 0.688 0.000 0.192 0.120
#> GSM260898     3  0.2714      0.786 0.004 0.000 0.884 0.112
#> GSM260901     3  0.5039     -0.380 0.004 0.000 0.592 0.404
#> GSM260904     3  0.1576      0.844 0.004 0.000 0.948 0.048
#> GSM260907     3  0.2053      0.827 0.004 0.000 0.924 0.072
#> GSM260910     3  0.1824      0.809 0.004 0.000 0.936 0.060
#> GSM260918     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260921     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260924     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260929     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260932     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260935     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260938     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260941     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260944     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260947     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM260952     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM260914     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM260916     1  0.1824      0.925 0.936 0.000 0.004 0.060
#> GSM260919     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM260922     1  0.2334      0.903 0.908 0.000 0.004 0.088
#> GSM260925     1  0.0336      0.959 0.992 0.000 0.000 0.008
#> GSM260927     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM260930     1  0.1211      0.955 0.960 0.000 0.000 0.040
#> GSM260933     1  0.1211      0.955 0.960 0.000 0.000 0.040
#> GSM260936     1  0.1302      0.954 0.956 0.000 0.000 0.044
#> GSM260939     1  0.2469      0.915 0.892 0.000 0.000 0.108
#> GSM260942     1  0.2469      0.915 0.892 0.000 0.000 0.108
#> GSM260945     1  0.1557      0.949 0.944 0.000 0.000 0.056
#> GSM260948     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM260950     1  0.0336      0.959 0.992 0.000 0.000 0.008
#> GSM260915     3  0.0376      0.858 0.004 0.000 0.992 0.004
#> GSM260917     3  0.0188      0.857 0.004 0.000 0.996 0.000
#> GSM260920     3  0.1004      0.855 0.004 0.000 0.972 0.024
#> GSM260923     3  0.0779      0.851 0.004 0.000 0.980 0.016
#> GSM260926     3  0.0895      0.856 0.004 0.000 0.976 0.020
#> GSM260928     1  0.0188      0.958 0.996 0.000 0.000 0.004
#> GSM260931     3  0.3583      0.666 0.004 0.000 0.816 0.180
#> GSM260934     3  0.2466      0.806 0.004 0.000 0.900 0.096
#> GSM260937     4  0.4677      0.708 0.004 0.000 0.316 0.680
#> GSM260940     4  0.5158      0.612 0.004 0.000 0.472 0.524
#> GSM260943     3  0.3494      0.684 0.004 0.000 0.824 0.172
#> GSM260946     3  0.2773      0.781 0.004 0.000 0.880 0.116
#> GSM260949     3  0.1109      0.843 0.004 0.000 0.968 0.028
#> GSM260951     3  0.0376      0.858 0.004 0.000 0.992 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
#> GSM260888     2  0.0000      0.938 0.000 1.000 0.000 0.000 NA
#> GSM260893     2  0.0000      0.938 0.000 1.000 0.000 0.000 NA
#> GSM260896     2  0.0000      0.938 0.000 1.000 0.000 0.000 NA
#> GSM260899     2  0.4434      0.532 0.000 0.536 0.000 0.004 NA
#> GSM260902     2  0.3480      0.801 0.000 0.752 0.000 0.000 NA
#> GSM260905     2  0.0510      0.936 0.000 0.984 0.000 0.000 NA
#> GSM260908     2  0.1608      0.920 0.000 0.928 0.000 0.000 NA
#> GSM260911     2  0.0000      0.938 0.000 1.000 0.000 0.000 NA
#> GSM260912     2  0.0000      0.938 0.000 1.000 0.000 0.000 NA
#> GSM260913     3  0.2793      0.752 0.000 0.000 0.876 0.088 NA
#> GSM260886     1  0.0000      0.968 1.000 0.000 0.000 0.000 NA
#> GSM260889     1  0.0000      0.968 1.000 0.000 0.000 0.000 NA
#> GSM260891     1  0.0000      0.968 1.000 0.000 0.000 0.000 NA
#> GSM260894     1  0.0000      0.968 1.000 0.000 0.000 0.000 NA
#> GSM260897     1  0.0162      0.968 0.996 0.000 0.000 0.004 NA
#> GSM260900     1  0.0162      0.968 0.996 0.000 0.000 0.004 NA
#> GSM260903     1  0.0162      0.968 0.996 0.000 0.000 0.004 NA
#> GSM260906     1  0.0162      0.968 0.996 0.000 0.000 0.004 NA
#> GSM260909     1  0.0000      0.968 1.000 0.000 0.000 0.000 NA
#> GSM260887     3  0.0000      0.779 0.000 0.000 1.000 0.000 NA
#> GSM260890     3  0.2136      0.758 0.000 0.000 0.904 0.088 NA
#> GSM260892     3  0.5578      0.489 0.000 0.000 0.644 0.176 NA
#> GSM260895     1  0.6531      0.322 0.564 0.000 0.256 0.156 NA
#> GSM260898     3  0.4360      0.611 0.000 0.000 0.752 0.064 NA
#> GSM260901     3  0.5308      0.161 0.000 0.000 0.532 0.052 NA
#> GSM260904     3  0.2005      0.759 0.004 0.000 0.924 0.056 NA
#> GSM260907     3  0.2775      0.739 0.004 0.000 0.884 0.076 NA
#> GSM260910     3  0.2966      0.717 0.000 0.000 0.848 0.136 NA
#> GSM260918     2  0.0000      0.938 0.000 1.000 0.000 0.000 NA
#> GSM260921     2  0.0000      0.938 0.000 1.000 0.000 0.000 NA
#> GSM260924     2  0.0000      0.938 0.000 1.000 0.000 0.000 NA
#> GSM260929     2  0.0000      0.938 0.000 1.000 0.000 0.000 NA
#> GSM260932     2  0.3550      0.809 0.000 0.760 0.000 0.004 NA
#> GSM260935     2  0.2561      0.882 0.000 0.856 0.000 0.000 NA
#> GSM260938     2  0.1792      0.915 0.000 0.916 0.000 0.000 NA
#> GSM260941     2  0.1270      0.926 0.000 0.948 0.000 0.000 NA
#> GSM260944     2  0.1792      0.915 0.000 0.916 0.000 0.000 NA
#> GSM260947     2  0.0510      0.936 0.000 0.984 0.000 0.000 NA
#> GSM260952     2  0.0000      0.938 0.000 1.000 0.000 0.000 NA
#> GSM260914     1  0.0000      0.968 1.000 0.000 0.000 0.000 NA
#> GSM260916     1  0.0898      0.953 0.972 0.000 0.000 0.020 NA
#> GSM260919     1  0.0000      0.968 1.000 0.000 0.000 0.000 NA
#> GSM260922     1  0.1557      0.929 0.940 0.000 0.000 0.052 NA
#> GSM260925     1  0.0000      0.968 1.000 0.000 0.000 0.000 NA
#> GSM260927     1  0.0000      0.968 1.000 0.000 0.000 0.000 NA
#> GSM260930     1  0.0290      0.966 0.992 0.000 0.000 0.008 NA
#> GSM260933     1  0.0162      0.968 0.996 0.000 0.000 0.004 NA
#> GSM260936     1  0.0566      0.963 0.984 0.000 0.000 0.012 NA
#> GSM260939     1  0.2011      0.902 0.908 0.000 0.000 0.088 NA
#> GSM260942     1  0.1557      0.932 0.940 0.000 0.000 0.052 NA
#> GSM260945     1  0.0566      0.963 0.984 0.000 0.000 0.012 NA
#> GSM260948     1  0.0000      0.968 1.000 0.000 0.000 0.000 NA
#> GSM260950     1  0.0162      0.968 0.996 0.000 0.000 0.004 NA
#> GSM260915     3  0.0451      0.779 0.004 0.000 0.988 0.000 NA
#> GSM260917     3  0.1568      0.774 0.000 0.000 0.944 0.036 NA
#> GSM260920     3  0.1251      0.772 0.000 0.000 0.956 0.036 NA
#> GSM260923     3  0.2351      0.754 0.000 0.000 0.896 0.088 NA
#> GSM260926     3  0.1644      0.772 0.004 0.000 0.940 0.008 NA
#> GSM260928     1  0.1267      0.941 0.960 0.000 0.024 0.004 NA
#> GSM260931     4  0.4504      0.568 0.000 0.000 0.428 0.564 NA
#> GSM260934     3  0.3569      0.700 0.000 0.000 0.828 0.068 NA
#> GSM260937     4  0.3086      0.787 0.000 0.000 0.180 0.816 NA
#> GSM260940     4  0.4380      0.786 0.000 0.000 0.304 0.676 NA
#> GSM260943     4  0.3274      0.812 0.000 0.000 0.220 0.780 NA
#> GSM260946     3  0.3980      0.414 0.000 0.000 0.708 0.284 NA
#> GSM260949     3  0.2448      0.753 0.000 0.000 0.892 0.088 NA
#> GSM260951     3  0.4972      0.341 0.000 0.000 0.672 0.260 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
#> GSM260888     2  0.0692      0.889 0.000 0.976 0.000 0.000 0.020 0.004
#> GSM260893     2  0.0508      0.895 0.000 0.984 0.000 0.000 0.012 0.004
#> GSM260896     2  0.0405      0.896 0.000 0.988 0.000 0.000 0.008 0.004
#> GSM260899     6  0.3354      0.795 0.000 0.240 0.000 0.004 0.004 0.752
#> GSM260902     6  0.3659      0.863 0.000 0.364 0.000 0.000 0.000 0.636
#> GSM260905     2  0.1219      0.882 0.000 0.948 0.004 0.000 0.000 0.048
#> GSM260908     2  0.1858      0.848 0.000 0.904 0.004 0.000 0.000 0.092
#> GSM260911     2  0.0508      0.895 0.000 0.984 0.000 0.000 0.012 0.004
#> GSM260912     2  0.0000      0.898 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM260913     4  0.1802      0.843 0.000 0.000 0.012 0.916 0.072 0.000
#> GSM260886     1  0.0260      0.950 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260889     1  0.0363      0.951 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM260891     1  0.0363      0.949 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM260894     1  0.0260      0.950 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260897     1  0.0547      0.947 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM260900     1  0.0458      0.948 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM260903     1  0.0632      0.946 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM260906     1  0.0260      0.950 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260909     1  0.0603      0.947 0.980 0.000 0.004 0.000 0.016 0.000
#> GSM260887     4  0.0436      0.868 0.000 0.000 0.004 0.988 0.004 0.004
#> GSM260890     4  0.0603      0.864 0.000 0.000 0.000 0.980 0.004 0.016
#> GSM260892     5  0.3725      0.000 0.000 0.000 0.008 0.316 0.676 0.000
#> GSM260895     1  0.5522     -0.056 0.492 0.000 0.004 0.408 0.088 0.008
#> GSM260898     4  0.3199      0.811 0.004 0.000 0.024 0.856 0.048 0.068
#> GSM260901     4  0.4831      0.633 0.008 0.000 0.032 0.728 0.076 0.156
#> GSM260904     4  0.2357      0.858 0.008 0.000 0.036 0.908 0.032 0.016
#> GSM260907     4  0.2910      0.845 0.004 0.000 0.048 0.876 0.044 0.028
#> GSM260910     4  0.1584      0.837 0.000 0.000 0.000 0.928 0.064 0.008
#> GSM260918     2  0.0146      0.897 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM260921     2  0.0405      0.896 0.000 0.988 0.000 0.000 0.008 0.004
#> GSM260924     2  0.0725      0.893 0.000 0.976 0.000 0.000 0.012 0.012
#> GSM260929     2  0.0146      0.897 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM260932     6  0.3620      0.879 0.000 0.352 0.000 0.000 0.000 0.648
#> GSM260935     2  0.3828     -0.362 0.000 0.560 0.000 0.000 0.000 0.440
#> GSM260938     2  0.2520      0.763 0.000 0.844 0.004 0.000 0.000 0.152
#> GSM260941     2  0.1700      0.859 0.000 0.916 0.004 0.000 0.000 0.080
#> GSM260944     2  0.2278      0.802 0.000 0.868 0.004 0.000 0.000 0.128
#> GSM260947     2  0.1285      0.880 0.000 0.944 0.004 0.000 0.000 0.052
#> GSM260952     2  0.0632      0.893 0.000 0.976 0.000 0.000 0.000 0.024
#> GSM260914     1  0.0000      0.951 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM260916     1  0.1082      0.934 0.956 0.000 0.000 0.004 0.040 0.000
#> GSM260919     1  0.0260      0.950 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM260922     1  0.2402      0.843 0.856 0.000 0.000 0.004 0.140 0.000
#> GSM260925     1  0.0146      0.950 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260927     1  0.0146      0.951 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260930     1  0.0146      0.950 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260933     1  0.0146      0.950 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260936     1  0.0405      0.949 0.988 0.000 0.004 0.000 0.008 0.000
#> GSM260939     1  0.1924      0.906 0.920 0.000 0.048 0.000 0.028 0.004
#> GSM260942     1  0.1777      0.914 0.928 0.000 0.024 0.000 0.044 0.004
#> GSM260945     1  0.0692      0.946 0.976 0.000 0.004 0.000 0.020 0.000
#> GSM260948     1  0.0603      0.947 0.980 0.000 0.000 0.000 0.016 0.004
#> GSM260950     1  0.0146      0.950 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM260915     4  0.0520      0.868 0.000 0.000 0.000 0.984 0.008 0.008
#> GSM260917     4  0.1728      0.856 0.000 0.000 0.064 0.924 0.004 0.008
#> GSM260920     4  0.1367      0.865 0.000 0.000 0.044 0.944 0.000 0.012
#> GSM260923     4  0.1844      0.842 0.000 0.000 0.004 0.924 0.048 0.024
#> GSM260926     4  0.1511      0.865 0.004 0.000 0.000 0.940 0.012 0.044
#> GSM260928     1  0.2704      0.852 0.880 0.000 0.008 0.080 0.020 0.012
#> GSM260931     3  0.3789      0.615 0.000 0.000 0.668 0.324 0.004 0.004
#> GSM260934     4  0.2924      0.839 0.004 0.000 0.036 0.876 0.044 0.040
#> GSM260937     3  0.1615      0.672 0.000 0.000 0.928 0.064 0.004 0.004
#> GSM260940     3  0.4405      0.692 0.000 0.000 0.696 0.252 0.024 0.028
#> GSM260943     3  0.1908      0.710 0.000 0.000 0.900 0.096 0.004 0.000
#> GSM260946     4  0.4147      0.425 0.000 0.000 0.316 0.660 0.008 0.016
#> GSM260949     4  0.1265      0.851 0.000 0.000 0.000 0.948 0.044 0.008
#> GSM260951     3  0.4431      0.669 0.000 0.000 0.692 0.228 0.080 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) cell.type(p) k
#> ATC:NMF 67            0.939     2.75e-14 2
#> ATC:NMF 67            0.940     1.87e-24 3
#> ATC:NMF 66            0.672     1.52e-22 4
#> ATC:NMF 62            0.320     7.14e-22 5
#> ATC:NMF 63            0.249     4.57e-21 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