cola Report for GDS2255

Date: 2019-12-25 20:17:18 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 58 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    58

Density distribution

The density distribution for each sample is visualized as in one column in the following heatmap. The clustering is based on the distance which is the Kolmogorov-Smirnov statistic between two distributions.

library(ComplexHeatmap)
densityHeatmap(mat, top_annotation = HeatmapAnnotation(df = get_anno(res_list), 
    col = get_anno_col(res_list)), ylab = "value", cluster_columns = TRUE, show_column_names = FALSE,
    mc.cores = 4)

plot of chunk density-heatmap

Suggest the best k

Folowing table shows the best k (number of partitions) for each combination of top-value methods and partition methods. Clicking on the method name in the table goes to the section for a single combination of methods.

The cola vignette explains the definition of the metrics used for determining the best number of partitions.

suggest_best_k(res_list)
The best k 1-PAC Mean silhouette Concordance Optional k
SD:kmeans 2 1.000 0.999 0.998 **
SD:mclust 2 1.000 1.000 1.000 **
SD:NMF 2 1.000 0.998 0.999 **
CV:kmeans 2 1.000 0.991 0.995 **
MAD:kmeans 2 1.000 1.000 1.000 **
MAD:NMF 2 1.000 0.990 0.995 **
ATC:kmeans 4 1.000 0.965 0.971 ** 2
ATC:skmeans 2 1.000 0.986 0.994 **
ATC:pam 4 1.000 0.962 0.985 ** 3
MAD:pam 6 0.981 0.918 0.965 ** 2,4,5
ATC:mclust 4 0.976 0.929 0.964 **
CV:NMF 6 0.964 0.936 0.966 ** 2,3
CV:pam 5 0.952 0.927 0.969 ** 2,4
CV:skmeans 6 0.947 0.946 0.941 * 2,3,4,5
SD:skmeans 6 0.938 0.933 0.926 * 2,4,5
SD:pam 6 0.933 0.907 0.960 * 2
ATC:NMF 2 0.928 0.938 0.976 *
MAD:skmeans 6 0.927 0.951 0.925 * 2,4,5
MAD:mclust 6 0.919 0.885 0.935 * 2,5
CV:mclust 6 0.919 0.838 0.920 * 2
CV:hclust 4 0.631 0.896 0.879
MAD:hclust 3 0.534 0.832 0.895
ATC:hclust 2 0.496 0.886 0.903
SD:hclust 3 0.461 0.596 0.792

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

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

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

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

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

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

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

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

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

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

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

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

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

Membership heatmap

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

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

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

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

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

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

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

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

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

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

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

Signature heatmap

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

Note in following heatmaps, rows are scaled.

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

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

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

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

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

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

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

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

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

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

Statistics table

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

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 1.000           0.998       0.999          0.422 0.578   0.578
#> CV:NMF      2 1.000           0.969       0.988          0.423 0.578   0.578
#> MAD:NMF     2 1.000           0.990       0.995          0.426 0.578   0.578
#> ATC:NMF     2 0.928           0.938       0.976          0.303 0.710   0.710
#> SD:skmeans  2 1.000           1.000       1.000          0.422 0.578   0.578
#> CV:skmeans  2 1.000           0.991       0.996          0.425 0.578   0.578
#> MAD:skmeans 2 0.900           0.983       0.991          0.428 0.578   0.578
#> ATC:skmeans 2 1.000           0.986       0.994          0.501 0.501   0.501
#> SD:mclust   2 1.000           1.000       1.000          0.422 0.578   0.578
#> CV:mclust   2 1.000           1.000       1.000          0.422 0.578   0.578
#> MAD:mclust  2 1.000           1.000       1.000          0.422 0.578   0.578
#> ATC:mclust  2 0.794           0.901       0.957          0.435 0.552   0.552
#> SD:kmeans   2 1.000           0.999       0.998          0.422 0.578   0.578
#> CV:kmeans   2 1.000           0.991       0.995          0.419 0.578   0.578
#> MAD:kmeans  2 1.000           1.000       1.000          0.422 0.578   0.578
#> ATC:kmeans  2 1.000           1.000       1.000          0.500 0.501   0.501
#> SD:pam      2 1.000           1.000       1.000          0.422 0.578   0.578
#> CV:pam      2 1.000           1.000       1.000          0.422 0.578   0.578
#> MAD:pam     2 1.000           1.000       1.000          0.422 0.578   0.578
#> ATC:pam     2 0.733           0.956       0.972          0.483 0.501   0.501
#> SD:hclust   2 0.805           0.863       0.943          0.356 0.610   0.610
#> CV:hclust   2 0.781           0.875       0.946          0.328 0.733   0.733
#> MAD:hclust  2 0.805           0.949       0.970          0.380 0.593   0.593
#> ATC:hclust  2 0.496           0.886       0.903          0.430 0.501   0.501
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.886           0.904       0.960          0.586 0.724   0.534
#> CV:NMF      3 0.974           0.945       0.978          0.588 0.724   0.534
#> MAD:NMF     3 0.834           0.872       0.938          0.561 0.724   0.534
#> ATC:NMF     3 0.744           0.793       0.922          1.023 0.628   0.494
#> SD:skmeans  3 0.780           0.887       0.924          0.543 0.750   0.567
#> CV:skmeans  3 0.991           0.950       0.966          0.568 0.747   0.563
#> MAD:skmeans 3 0.781           0.930       0.951          0.540 0.750   0.567
#> ATC:skmeans 3 0.849           0.910       0.938          0.261 0.861   0.722
#> SD:mclust   3 0.712           0.819       0.903          0.487 0.789   0.636
#> CV:mclust   3 0.663           0.684       0.855          0.492 0.789   0.636
#> MAD:mclust  3 0.752           0.783       0.891          0.523 0.789   0.636
#> ATC:mclust  3 0.490           0.795       0.860          0.404 0.726   0.531
#> SD:kmeans   3 0.624           0.835       0.830          0.455 0.753   0.573
#> CV:kmeans   3 0.632           0.850       0.866          0.500 0.726   0.537
#> MAD:kmeans  3 0.639           0.894       0.867          0.478 0.758   0.582
#> ATC:kmeans  3 0.557           0.774       0.878          0.267 0.624   0.393
#> SD:pam      3 0.750           0.815       0.845          0.467 0.780   0.619
#> CV:pam      3 0.734           0.933       0.915          0.473 0.789   0.636
#> MAD:pam     3 0.759           0.811       0.848          0.494 0.758   0.582
#> ATC:pam     3 0.916           0.928       0.959          0.352 0.742   0.529
#> SD:hclust   3 0.461           0.596       0.792          0.515 0.950   0.919
#> CV:hclust   3 0.563           0.770       0.789          0.626 0.681   0.564
#> MAD:hclust  3 0.534           0.832       0.895          0.693 0.734   0.551
#> ATC:hclust  3 0.757           0.819       0.926          0.346 0.940   0.879
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.877           0.873       0.929         0.1190 0.869   0.630
#> CV:NMF      4 0.820           0.908       0.925         0.1120 0.889   0.675
#> MAD:NMF     4 0.896           0.882       0.943         0.1344 0.903   0.711
#> ATC:NMF     4 0.633           0.681       0.856         0.1667 0.731   0.421
#> SD:skmeans  4 1.000           0.982       0.989         0.1562 0.903   0.712
#> CV:skmeans  4 1.000           0.946       0.978         0.1315 0.895   0.689
#> MAD:skmeans 4 1.000           0.976       0.987         0.1427 0.903   0.712
#> ATC:skmeans 4 0.792           0.832       0.847         0.1124 0.946   0.849
#> SD:mclust   4 0.720           0.768       0.860         0.1660 0.843   0.594
#> CV:mclust   4 0.823           0.807       0.909         0.1727 0.846   0.599
#> MAD:mclust  4 0.770           0.807       0.902         0.1458 0.858   0.622
#> ATC:mclust  4 0.976           0.929       0.964         0.1605 0.894   0.716
#> SD:kmeans   4 0.632           0.772       0.778         0.1593 0.923   0.766
#> CV:kmeans   4 0.630           0.406       0.625         0.1506 0.757   0.438
#> MAD:kmeans  4 0.683           0.893       0.830         0.1591 0.891   0.685
#> ATC:kmeans  4 1.000           0.965       0.971         0.1616 0.761   0.443
#> SD:pam      4 0.888           0.913       0.959         0.2013 0.891   0.696
#> CV:pam      4 0.970           0.947       0.977         0.1978 0.891   0.704
#> MAD:pam     4 0.982           0.959       0.984         0.1957 0.891   0.685
#> ATC:pam     4 1.000           0.962       0.985         0.1292 0.861   0.623
#> SD:hclust   4 0.635           0.479       0.788         0.2159 0.716   0.506
#> CV:hclust   4 0.631           0.896       0.879         0.2677 0.879   0.708
#> MAD:hclust  4 0.639           0.747       0.874         0.0566 0.989   0.965
#> ATC:hclust  4 0.737           0.714       0.858         0.1994 0.890   0.750
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.853           0.727       0.867         0.0503 0.936   0.755
#> CV:NMF      5 0.884           0.900       0.936         0.0622 0.939   0.761
#> MAD:NMF     5 0.778           0.706       0.826         0.0468 0.974   0.899
#> ATC:NMF     5 0.671           0.741       0.862         0.0652 0.833   0.506
#> SD:skmeans  5 1.000           0.959       0.971         0.0593 0.943   0.775
#> CV:skmeans  5 0.911           0.948       0.958         0.0587 0.946   0.783
#> MAD:skmeans 5 1.000           0.973       0.977         0.0609 0.943   0.775
#> ATC:skmeans 5 0.828           0.889       0.918         0.1002 0.897   0.669
#> SD:mclust   5 0.880           0.863       0.904         0.0807 0.909   0.667
#> CV:mclust   5 0.892           0.872       0.934         0.0727 0.943   0.773
#> MAD:mclust  5 0.932           0.890       0.946         0.0710 0.906   0.655
#> ATC:mclust  5 0.780           0.700       0.844         0.1044 0.849   0.542
#> SD:kmeans   5 0.714           0.623       0.763         0.0837 0.964   0.862
#> CV:kmeans   5 0.774           0.817       0.780         0.0752 0.829   0.485
#> MAD:kmeans  5 0.775           0.688       0.733         0.0756 0.956   0.831
#> ATC:kmeans  5 0.811           0.856       0.876         0.0585 1.000   1.000
#> SD:pam      5 0.857           0.899       0.938         0.0551 0.960   0.840
#> CV:pam      5 0.952           0.927       0.969         0.0502 0.964   0.860
#> MAD:pam     5 0.916           0.883       0.878         0.0534 0.938   0.758
#> ATC:pam     5 0.832           0.770       0.873         0.0448 0.980   0.925
#> SD:hclust   5 0.621           0.590       0.793         0.0690 0.984   0.949
#> CV:hclust   5 0.642           0.809       0.806         0.0920 0.989   0.963
#> MAD:hclust  5 0.603           0.742       0.840         0.0483 0.983   0.946
#> ATC:hclust  5 0.732           0.757       0.827         0.1077 0.791   0.456
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.873           0.882       0.921         0.0423 0.943   0.741
#> CV:NMF      6 0.964           0.936       0.966         0.0484 0.941   0.722
#> MAD:NMF     6 0.859           0.833       0.908         0.0412 0.920   0.676
#> ATC:NMF     6 0.655           0.613       0.754         0.0538 0.944   0.783
#> SD:skmeans  6 0.938           0.933       0.926         0.0460 0.956   0.783
#> CV:skmeans  6 0.947           0.946       0.941         0.0472 0.956   0.783
#> MAD:skmeans 6 0.927           0.951       0.925         0.0462 0.956   0.783
#> ATC:skmeans 6 0.878           0.854       0.898         0.0340 0.968   0.852
#> SD:mclust   6 0.831           0.793       0.887         0.0456 0.964   0.824
#> CV:mclust   6 0.919           0.838       0.920         0.0440 0.950   0.760
#> MAD:mclust  6 0.919           0.885       0.935         0.0361 0.954   0.791
#> ATC:mclust  6 0.727           0.697       0.793         0.0456 0.915   0.642
#> SD:kmeans   6 0.833           0.764       0.783         0.0530 0.907   0.621
#> CV:kmeans   6 0.827           0.851       0.849         0.0554 0.948   0.750
#> MAD:kmeans  6 0.863           0.895       0.854         0.0535 0.912   0.624
#> ATC:kmeans  6 0.787           0.742       0.781         0.0435 1.000   1.000
#> SD:pam      6 0.933           0.907       0.960         0.0533 0.948   0.760
#> CV:pam      6 0.890           0.815       0.895         0.0440 0.909   0.623
#> MAD:pam     6 0.981           0.918       0.965         0.0464 0.930   0.684
#> ATC:pam     6 0.781           0.608       0.831         0.0618 0.929   0.723
#> SD:hclust   6 0.690           0.611       0.754         0.1074 0.839   0.515
#> CV:hclust   6 0.704           0.760       0.835         0.0792 0.889   0.620
#> MAD:hclust  6 0.700           0.719       0.758         0.1018 0.868   0.573
#> ATC:hclust  6 0.857           0.785       0.915         0.0610 0.949   0.779

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 cell.type(p) agent(p) individual(p) k
#> SD:NMF      58     2.54e-13  0.00184       0.99993 2
#> CV:NMF      57     4.19e-13  0.00243       0.99985 2
#> MAD:NMF     58     2.54e-13  0.00184       0.99993 2
#> ATC:NMF     56     3.35e-04  0.51056       0.10865 2
#> SD:skmeans  58     2.54e-13  0.00184       0.99993 2
#> CV:skmeans  58     2.54e-13  0.00184       0.99993 2
#> MAD:skmeans 58     2.54e-13  0.00184       0.99993 2
#> ATC:skmeans 58     5.91e-02  0.33980       0.00642 2
#> SD:mclust   58     2.54e-13  0.00184       0.99993 2
#> CV:mclust   58     2.54e-13  0.00184       0.99993 2
#> MAD:mclust  58     2.54e-13  0.00184       0.99993 2
#> ATC:mclust  56     8.02e-07  0.06509       0.19943 2
#> SD:kmeans   58     2.54e-13  0.00184       0.99993 2
#> CV:kmeans   58     2.54e-13  0.00184       0.99993 2
#> MAD:kmeans  58     2.54e-13  0.00184       0.99993 2
#> ATC:kmeans  58     5.91e-02  0.33980       0.00642 2
#> SD:pam      58     2.54e-13  0.00184       0.99993 2
#> CV:pam      58     2.54e-13  0.00184       0.99993 2
#> MAD:pam     58     2.54e-13  0.00184       0.99993 2
#> ATC:pam     58     5.91e-02  0.33980       0.00642 2
#> SD:hclust   56     6.91e-13  0.00345       0.99856 2
#> CV:hclust   52     1.55e-09  0.03378       0.86209 2
#> MAD:hclust  57     4.70e-12  0.00409       0.99752 2
#> ATC:hclust  58     5.91e-02  0.33980       0.00642 2
test_to_known_factors(res_list, k = 3)
#>              n cell.type(p) agent(p) individual(p) k
#> SD:NMF      55     2.68e-14  0.00255        0.2277 3
#> CV:NMF      56     3.19e-14  0.00495        0.2677 3
#> MAD:NMF     53     7.72e-14  0.00271        0.2899 3
#> ATC:NMF     51     6.23e-04  0.15262        0.0664 3
#> SD:skmeans  57     1.37e-14  0.00234        0.2223 3
#> CV:skmeans  57     1.75e-14  0.00372        0.3072 3
#> MAD:skmeans 57     1.37e-14  0.00234        0.2223 3
#> ATC:skmeans 57     4.38e-02  0.41724        0.0557 3
#> SD:mclust   56     2.73e-23  0.00295        0.9396 3
#> CV:mclust   45     1.32e-18  0.00297        0.8445 3
#> MAD:mclust  47     7.26e-17  0.00603        0.8139 3
#> ATC:mclust  54     1.09e-04  0.13428        0.1806 3
#> SD:kmeans   57     2.67e-14  0.00370        0.1374 3
#> CV:kmeans   55     6.77e-14  0.00411        0.2105 3
#> MAD:kmeans  58     2.30e-14  0.00274        0.1144 3
#> ATC:kmeans  58     2.57e-02  0.23343        0.0134 3
#> SD:pam      57     2.40e-13  0.00357        0.2393 3
#> CV:pam      58     1.80e-13  0.00263        0.3207 3
#> MAD:pam     57     4.94e-14  0.00233        0.1301 3
#> ATC:pam     57     3.34e-02  0.25912        0.0479 3
#> SD:hclust   52     1.38e-10  0.01802        0.8287 3
#> CV:hclust   50     2.48e-12  0.03334        0.0329 3
#> MAD:hclust  57     5.24e-15  0.00507        0.4768 3
#> ATC:hclust  53     6.30e-02  0.72788        0.0949 3
test_to_known_factors(res_list, k = 4)
#>              n cell.type(p) agent(p) individual(p) k
#> SD:NMF      55     2.04e-21  0.00750        0.2875 4
#> CV:NMF      57     2.96e-22  0.01039        0.4111 4
#> MAD:NMF     54     5.34e-21  0.00970        0.2271 4
#> ATC:NMF     49     2.76e-05  0.27571        0.4019 4
#> SD:skmeans  58     1.13e-22  0.00789        0.3966 4
#> CV:skmeans  56     7.77e-22  0.00848        0.4694 4
#> MAD:skmeans 58     1.13e-22  0.00789        0.3966 4
#> ATC:skmeans 56     1.57e-01  0.10805        0.2212 4
#> SD:mclust   52     3.67e-20  0.00382        0.5380 4
#> CV:mclust   52     3.67e-20  0.00980        0.7079 4
#> MAD:mclust  54     1.46e-19  0.00898        0.7409 4
#> ATC:mclust  56     1.35e-06  0.09194        0.5035 4
#> SD:kmeans   55     2.04e-21  0.00458        0.3619 4
#> CV:kmeans   32     4.18e-13  0.00408        0.3553 4
#> MAD:kmeans  57     2.96e-22  0.00688        0.3154 4
#> ATC:kmeans  57     1.01e-02  0.58199        0.0721 4
#> SD:pam      58     1.13e-22  0.00808        0.3426 4
#> CV:pam      57     2.96e-22  0.01024        0.5266 4
#> MAD:pam     57     2.96e-22  0.00689        0.3545 4
#> ATC:pam     57     1.01e-02  0.58199        0.0721 4
#> SD:hclust   28     2.01e-11  0.44224        0.1255 4
#> CV:hclust   58     4.14e-13  0.00812        0.1188 4
#> MAD:hclust  56     7.83e-16  0.00380        0.5580 4
#> ATC:hclust  44     6.42e-02  0.18127        0.2243 4
test_to_known_factors(res_list, k = 5)
#>              n cell.type(p) agent(p) individual(p) k
#> SD:NMF      47     4.46e-18   0.0225       0.17018 5
#> CV:NMF      57     5.72e-21   0.0230       0.40472 5
#> MAD:NMF     53     1.40e-20   0.0281       0.28353 5
#> ATC:NMF     51     1.81e-08   0.0181       0.67272 5
#> SD:skmeans  56     1.48e-20   0.0135       0.08347 5
#> CV:skmeans  58     2.22e-21   0.0173       0.11456 5
#> MAD:skmeans 58     2.22e-21   0.0173       0.11456 5
#> ATC:skmeans 56     3.61e-05   0.0699       0.65266 5
#> SD:mclust   55     3.81e-20   0.0134       0.18580 5
#> CV:mclust   55     3.81e-20   0.0213       0.20129 5
#> MAD:mclust  55     3.81e-20   0.0134       0.18580 5
#> ATC:mclust  45     2.43e-03   0.2226       0.56158 5
#> SD:kmeans   40     2.06e-09   0.9822       0.01974 5
#> CV:kmeans   56     1.48e-20   0.0307       0.34266 5
#> MAD:kmeans  50     4.27e-18   0.1032       0.15893 5
#> ATC:kmeans  57     1.01e-02   0.5820       0.07213 5
#> SD:pam      58     2.22e-21   0.0189       0.29260 5
#> CV:pam      56     1.48e-20   0.0299       0.42907 5
#> MAD:pam     55     3.81e-20   0.0275       0.26823 5
#> ATC:pam     52     2.60e-02   0.5425       0.17726 5
#> SD:hclust   38     3.11e-13   0.2440       0.02242 5
#> CV:hclust   57     5.73e-12   0.0244       0.12480 5
#> MAD:hclust  56     1.55e-14   0.0110       0.45100 5
#> ATC:hclust  53     4.48e-02   0.5947       0.00981 5
test_to_known_factors(res_list, k = 6)
#>              n cell.type(p) agent(p) individual(p) k
#> SD:NMF      56     2.11e-19  0.04069        0.0681 6
#> CV:NMF      57     8.31e-20  0.04734        0.0885 6
#> MAD:NMF     54     1.35e-18  0.04270        0.0824 6
#> ATC:NMF     47     1.10e-06  0.00664        0.5833 6
#> SD:skmeans  57     8.31e-20  0.03200        0.0855 6
#> CV:skmeans  58     3.27e-20  0.03468        0.1104 6
#> MAD:skmeans 58     3.27e-20  0.03468        0.1104 6
#> ATC:skmeans 56     1.91e-06  0.03043        0.5551 6
#> SD:mclust   53     3.41e-18  0.06407        0.1956 6
#> CV:mclust   53     3.41e-18  0.06575        0.1830 6
#> MAD:mclust  58     3.27e-20  0.03077        0.2427 6
#> ATC:mclust  50     1.05e-04  0.25993        0.4595 6
#> SD:kmeans   47     8.59e-16  0.33939        0.0375 6
#> CV:kmeans   57     8.31e-20  0.03753        0.0534 6
#> MAD:kmeans  58     3.27e-20  0.03468        0.1104 6
#> ATC:kmeans  56     9.11e-03  0.67331        0.0861 6
#> SD:pam      56     2.11e-19  0.02434        0.0380 6
#> CV:pam      54     1.35e-18  0.04299        0.0587 6
#> MAD:pam     56     2.11e-19  0.02434        0.0380 6
#> ATC:pam     46     1.36e-03  0.57771        0.2149 6
#> SD:hclust   48     2.80e-17  0.20637        0.1519 6
#> CV:hclust   52     8.60e-18  0.02694        0.1381 6
#> MAD:hclust  53     2.52e-19  0.03434        0.0472 6
#> ATC:hclust  52     4.83e-02  0.10594        0.0699 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 58 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 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-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.805           0.863       0.943          0.356 0.610   0.610
#> 3 3 0.461           0.596       0.792          0.515 0.950   0.919
#> 4 4 0.635           0.479       0.788          0.216 0.716   0.506
#> 5 5 0.621           0.590       0.793          0.069 0.984   0.949
#> 6 6 0.690           0.611       0.754          0.107 0.839   0.515

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
#> GSM78539     1   0.000     0.9722 1.000 0.000
#> GSM78545     1   0.000     0.9722 1.000 0.000
#> GSM78550     1   0.000     0.9722 1.000 0.000
#> GSM78554     1   0.000     0.9722 1.000 0.000
#> GSM78562     1   0.000     0.9722 1.000 0.000
#> GSM78540     1   0.000     0.9722 1.000 0.000
#> GSM78546     1   0.000     0.9722 1.000 0.000
#> GSM78551     1   0.000     0.9722 1.000 0.000
#> GSM78555     1   0.000     0.9722 1.000 0.000
#> GSM78563     1   0.000     0.9722 1.000 0.000
#> GSM43005     1   0.000     0.9722 1.000 0.000
#> GSM43008     1   0.000     0.9722 1.000 0.000
#> GSM43011     1   0.000     0.9722 1.000 0.000
#> GSM78523     1   0.000     0.9722 1.000 0.000
#> GSM78526     1   0.000     0.9722 1.000 0.000
#> GSM78529     1   0.000     0.9722 1.000 0.000
#> GSM78532     1   0.000     0.9722 1.000 0.000
#> GSM78534     1   0.000     0.9722 1.000 0.000
#> GSM78537     1   0.000     0.9722 1.000 0.000
#> GSM78543     1   0.000     0.9722 1.000 0.000
#> GSM78548     1   0.000     0.9722 1.000 0.000
#> GSM78557     1   0.000     0.9722 1.000 0.000
#> GSM78560     1   0.000     0.9722 1.000 0.000
#> GSM78565     1   0.000     0.9722 1.000 0.000
#> GSM43000     1   0.000     0.9722 1.000 0.000
#> GSM43002     1   0.000     0.9722 1.000 0.000
#> GSM43004     1   0.000     0.9722 1.000 0.000
#> GSM43007     1   0.000     0.9722 1.000 0.000
#> GSM43010     1   0.000     0.9722 1.000 0.000
#> GSM78522     1   0.000     0.9722 1.000 0.000
#> GSM78525     1   0.000     0.9722 1.000 0.000
#> GSM78528     1   0.000     0.9722 1.000 0.000
#> GSM78531     1   0.000     0.9722 1.000 0.000
#> GSM78533     1   0.000     0.9722 1.000 0.000
#> GSM78536     1   0.000     0.9722 1.000 0.000
#> GSM78541     1   0.000     0.9722 1.000 0.000
#> GSM78547     1   0.000     0.9722 1.000 0.000
#> GSM78552     1   0.000     0.9722 1.000 0.000
#> GSM78556     1   0.000     0.9722 1.000 0.000
#> GSM78559     1   0.000     0.9722 1.000 0.000
#> GSM78564     1   0.000     0.9722 1.000 0.000
#> GSM42999     2   0.000     0.8119 0.000 1.000
#> GSM43001     2   0.000     0.8119 0.000 1.000
#> GSM43003     2   0.000     0.8119 0.000 1.000
#> GSM43006     2   0.000     0.8119 0.000 1.000
#> GSM43009     2   0.000     0.8119 0.000 1.000
#> GSM43012     2   0.000     0.8119 0.000 1.000
#> GSM78524     1   1.000    -0.3236 0.500 0.500
#> GSM78527     2   0.000     0.8119 0.000 1.000
#> GSM78530     2   0.971     0.5501 0.400 0.600
#> GSM78535     1   0.987    -0.0761 0.568 0.432
#> GSM78538     2   0.971     0.5501 0.400 0.600
#> GSM78542     2   0.971     0.5501 0.400 0.600
#> GSM78544     2   0.971     0.5501 0.400 0.600
#> GSM78549     2   0.000     0.8119 0.000 1.000
#> GSM78553     2   0.971     0.5501 0.400 0.600
#> GSM78558     2   0.971     0.5501 0.400 0.600
#> GSM78561     2   0.000     0.8119 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     1   0.470      0.504 0.788 0.000 0.212
#> GSM78545     1   0.608      0.575 0.612 0.000 0.388
#> GSM78550     1   0.601      0.574 0.628 0.000 0.372
#> GSM78554     1   0.465      0.508 0.792 0.000 0.208
#> GSM78562     1   0.470      0.504 0.788 0.000 0.212
#> GSM78540     1   0.470      0.504 0.788 0.000 0.212
#> GSM78546     1   0.470      0.504 0.788 0.000 0.212
#> GSM78551     1   0.601      0.574 0.628 0.000 0.372
#> GSM78555     1   0.470      0.504 0.788 0.000 0.212
#> GSM78563     1   0.470      0.504 0.788 0.000 0.212
#> GSM43005     1   0.573      0.748 0.676 0.000 0.324
#> GSM43008     1   0.573      0.748 0.676 0.000 0.324
#> GSM43011     1   0.573      0.748 0.676 0.000 0.324
#> GSM78523     1   0.573      0.748 0.676 0.000 0.324
#> GSM78526     1   0.573      0.748 0.676 0.000 0.324
#> GSM78529     1   0.573      0.748 0.676 0.000 0.324
#> GSM78532     1   0.000      0.693 1.000 0.000 0.000
#> GSM78534     1   0.573      0.748 0.676 0.000 0.324
#> GSM78537     1   0.000      0.693 1.000 0.000 0.000
#> GSM78543     1   0.000      0.693 1.000 0.000 0.000
#> GSM78548     1   0.556      0.749 0.700 0.000 0.300
#> GSM78557     1   0.341      0.731 0.876 0.000 0.124
#> GSM78560     1   0.000      0.693 1.000 0.000 0.000
#> GSM78565     1   0.000      0.693 1.000 0.000 0.000
#> GSM43000     1   0.573      0.748 0.676 0.000 0.324
#> GSM43002     1   0.573      0.748 0.676 0.000 0.324
#> GSM43004     1   0.573      0.748 0.676 0.000 0.324
#> GSM43007     1   0.573      0.748 0.676 0.000 0.324
#> GSM43010     1   0.573      0.748 0.676 0.000 0.324
#> GSM78522     1   0.573      0.748 0.676 0.000 0.324
#> GSM78525     1   0.573      0.748 0.676 0.000 0.324
#> GSM78528     1   0.573      0.748 0.676 0.000 0.324
#> GSM78531     1   0.000      0.693 1.000 0.000 0.000
#> GSM78533     1   0.573      0.748 0.676 0.000 0.324
#> GSM78536     1   0.000      0.693 1.000 0.000 0.000
#> GSM78541     1   0.000      0.693 1.000 0.000 0.000
#> GSM78547     1   0.341      0.731 0.876 0.000 0.124
#> GSM78552     1   0.341      0.731 0.876 0.000 0.124
#> GSM78556     1   0.341      0.731 0.876 0.000 0.124
#> GSM78559     1   0.000      0.693 1.000 0.000 0.000
#> GSM78564     1   0.341      0.731 0.876 0.000 0.124
#> GSM42999     2   0.000      0.659 0.000 1.000 0.000
#> GSM43001     2   0.000      0.659 0.000 1.000 0.000
#> GSM43003     2   0.000      0.659 0.000 1.000 0.000
#> GSM43006     2   0.000      0.659 0.000 1.000 0.000
#> GSM43009     2   0.000      0.659 0.000 1.000 0.000
#> GSM43012     2   0.000      0.659 0.000 1.000 0.000
#> GSM78524     3   0.985      0.774 0.292 0.288 0.420
#> GSM78527     2   0.000      0.659 0.000 1.000 0.000
#> GSM78530     2   0.911     -0.138 0.292 0.532 0.176
#> GSM78535     3   0.926      0.807 0.324 0.176 0.500
#> GSM78538     2   0.911     -0.138 0.292 0.532 0.176
#> GSM78542     2   0.911     -0.138 0.292 0.532 0.176
#> GSM78544     2   0.911     -0.138 0.292 0.532 0.176
#> GSM78549     2   0.000      0.659 0.000 1.000 0.000
#> GSM78553     2   0.911     -0.138 0.292 0.532 0.176
#> GSM78558     2   0.911     -0.138 0.292 0.532 0.176
#> GSM78561     2   0.000      0.659 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     4   0.215      0.656 0.000 0.000 0.088 0.912
#> GSM78545     4   0.470      0.422 0.000 0.000 0.356 0.644
#> GSM78550     4   0.436      0.507 0.000 0.000 0.292 0.708
#> GSM78554     4   0.228      0.656 0.000 0.000 0.096 0.904
#> GSM78562     4   0.208      0.656 0.000 0.000 0.084 0.916
#> GSM78540     4   0.208      0.656 0.000 0.000 0.084 0.916
#> GSM78546     4   0.208      0.656 0.000 0.000 0.084 0.916
#> GSM78551     4   0.430      0.508 0.000 0.000 0.284 0.716
#> GSM78555     4   0.208      0.656 0.000 0.000 0.084 0.916
#> GSM78563     4   0.208      0.656 0.000 0.000 0.084 0.916
#> GSM43005     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM43008     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM43011     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM78523     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM78526     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM78529     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM78532     4   0.499      0.462 0.000 0.000 0.480 0.520
#> GSM78534     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM78537     4   0.499      0.462 0.000 0.000 0.480 0.520
#> GSM78543     4   0.499      0.462 0.000 0.000 0.480 0.520
#> GSM78548     3   0.102      0.846 0.000 0.000 0.968 0.032
#> GSM78557     3   0.436      0.419 0.000 0.000 0.708 0.292
#> GSM78560     4   0.499      0.462 0.000 0.000 0.480 0.520
#> GSM78565     4   0.499      0.462 0.000 0.000 0.480 0.520
#> GSM43000     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM43002     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM43004     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM43007     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM43010     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM78522     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM78525     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM78528     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM78531     4   0.499      0.462 0.000 0.000 0.480 0.520
#> GSM78533     3   0.000      0.881 0.000 0.000 1.000 0.000
#> GSM78536     4   0.499      0.462 0.000 0.000 0.480 0.520
#> GSM78541     4   0.499      0.462 0.000 0.000 0.480 0.520
#> GSM78547     3   0.436      0.419 0.000 0.000 0.708 0.292
#> GSM78552     3   0.436      0.419 0.000 0.000 0.708 0.292
#> GSM78556     3   0.436      0.419 0.000 0.000 0.708 0.292
#> GSM78559     4   0.499      0.462 0.000 0.000 0.480 0.520
#> GSM78564     3   0.436      0.419 0.000 0.000 0.708 0.292
#> GSM42999     2   0.499     -0.605 0.468 0.532 0.000 0.000
#> GSM43001     1   0.564      1.000 0.552 0.424 0.000 0.024
#> GSM43003     2   0.499     -0.605 0.468 0.532 0.000 0.000
#> GSM43006     2   0.499     -0.633 0.476 0.524 0.000 0.000
#> GSM43009     2   0.499     -0.605 0.468 0.532 0.000 0.000
#> GSM43012     2   0.499     -0.605 0.468 0.532 0.000 0.000
#> GSM78524     2   0.543      0.247 0.232 0.708 0.000 0.060
#> GSM78527     2   0.499     -0.605 0.468 0.532 0.000 0.000
#> GSM78530     2   0.000      0.405 0.000 1.000 0.000 0.000
#> GSM78535     2   0.683      0.140 0.424 0.476 0.000 0.100
#> GSM78538     2   0.000      0.405 0.000 1.000 0.000 0.000
#> GSM78542     2   0.000      0.405 0.000 1.000 0.000 0.000
#> GSM78544     2   0.000      0.405 0.000 1.000 0.000 0.000
#> GSM78549     2   0.499     -0.605 0.468 0.532 0.000 0.000
#> GSM78553     2   0.000      0.405 0.000 1.000 0.000 0.000
#> GSM78558     2   0.000      0.405 0.000 1.000 0.000 0.000
#> GSM78561     1   0.564      1.000 0.552 0.424 0.000 0.024

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4  0.0162      0.599 0.000 0.000 0.004 0.996 0.000
#> GSM78545     4  0.4883      0.335 0.200 0.000 0.092 0.708 0.000
#> GSM78550     4  0.3388      0.433 0.200 0.000 0.008 0.792 0.000
#> GSM78554     4  0.0404      0.602 0.000 0.000 0.012 0.988 0.000
#> GSM78562     4  0.0000      0.597 0.000 0.000 0.000 1.000 0.000
#> GSM78540     4  0.0000      0.597 0.000 0.000 0.000 1.000 0.000
#> GSM78546     4  0.0000      0.597 0.000 0.000 0.000 1.000 0.000
#> GSM78551     4  0.3109      0.426 0.200 0.000 0.000 0.800 0.000
#> GSM78555     4  0.0000      0.597 0.000 0.000 0.000 1.000 0.000
#> GSM78563     4  0.0000      0.597 0.000 0.000 0.000 1.000 0.000
#> GSM43005     3  0.3109      0.803 0.200 0.000 0.800 0.000 0.000
#> GSM43008     3  0.3109      0.803 0.200 0.000 0.800 0.000 0.000
#> GSM43011     3  0.0000      0.798 0.000 0.000 1.000 0.000 0.000
#> GSM78523     3  0.0000      0.798 0.000 0.000 1.000 0.000 0.000
#> GSM78526     3  0.0000      0.798 0.000 0.000 1.000 0.000 0.000
#> GSM78529     3  0.3109      0.803 0.200 0.000 0.800 0.000 0.000
#> GSM78532     4  0.5173      0.474 0.016 0.000 0.396 0.568 0.020
#> GSM78534     3  0.0000      0.798 0.000 0.000 1.000 0.000 0.000
#> GSM78537     4  0.5173      0.474 0.016 0.000 0.396 0.568 0.020
#> GSM78543     4  0.5173      0.474 0.016 0.000 0.396 0.568 0.020
#> GSM78548     3  0.4021      0.779 0.200 0.000 0.764 0.036 0.000
#> GSM78557     3  0.4009      0.510 0.004 0.000 0.684 0.312 0.000
#> GSM78560     4  0.5173      0.474 0.016 0.000 0.396 0.568 0.020
#> GSM78565     4  0.5173      0.474 0.016 0.000 0.396 0.568 0.020
#> GSM43000     3  0.3109      0.803 0.200 0.000 0.800 0.000 0.000
#> GSM43002     3  0.3109      0.803 0.200 0.000 0.800 0.000 0.000
#> GSM43004     3  0.0000      0.798 0.000 0.000 1.000 0.000 0.000
#> GSM43007     3  0.3109      0.803 0.200 0.000 0.800 0.000 0.000
#> GSM43010     3  0.0000      0.798 0.000 0.000 1.000 0.000 0.000
#> GSM78522     3  0.0000      0.798 0.000 0.000 1.000 0.000 0.000
#> GSM78525     3  0.3109      0.803 0.200 0.000 0.800 0.000 0.000
#> GSM78528     3  0.3109      0.803 0.200 0.000 0.800 0.000 0.000
#> GSM78531     4  0.5173      0.474 0.016 0.000 0.396 0.568 0.020
#> GSM78533     3  0.0000      0.798 0.000 0.000 1.000 0.000 0.000
#> GSM78536     4  0.5173      0.474 0.016 0.000 0.396 0.568 0.020
#> GSM78541     4  0.5173      0.474 0.016 0.000 0.396 0.568 0.020
#> GSM78547     3  0.4009      0.510 0.004 0.000 0.684 0.312 0.000
#> GSM78552     3  0.4009      0.510 0.004 0.000 0.684 0.312 0.000
#> GSM78556     3  0.4009      0.510 0.004 0.000 0.684 0.312 0.000
#> GSM78559     4  0.5173      0.474 0.016 0.000 0.396 0.568 0.020
#> GSM78564     3  0.4009      0.510 0.004 0.000 0.684 0.312 0.000
#> GSM42999     2  0.0000      0.608 0.000 1.000 0.000 0.000 0.000
#> GSM43001     5  0.3274      1.000 0.000 0.220 0.000 0.000 0.780
#> GSM43003     2  0.0000      0.608 0.000 1.000 0.000 0.000 0.000
#> GSM43006     2  0.3177      0.216 0.000 0.792 0.000 0.000 0.208
#> GSM43009     2  0.0000      0.608 0.000 1.000 0.000 0.000 0.000
#> GSM43012     2  0.0000      0.608 0.000 1.000 0.000 0.000 0.000
#> GSM78524     1  0.6357      0.393 0.512 0.288 0.000 0.000 0.200
#> GSM78527     2  0.0000      0.608 0.000 1.000 0.000 0.000 0.000
#> GSM78530     2  0.6279      0.267 0.268 0.532 0.000 0.000 0.200
#> GSM78535     1  0.3109      0.561 0.800 0.000 0.000 0.000 0.200
#> GSM78538     2  0.6279      0.267 0.268 0.532 0.000 0.000 0.200
#> GSM78542     2  0.6279      0.267 0.268 0.532 0.000 0.000 0.200
#> GSM78544     2  0.6279      0.267 0.268 0.532 0.000 0.000 0.200
#> GSM78549     2  0.0000      0.608 0.000 1.000 0.000 0.000 0.000
#> GSM78553     2  0.6279      0.267 0.268 0.532 0.000 0.000 0.200
#> GSM78558     2  0.6279      0.267 0.268 0.532 0.000 0.000 0.200
#> GSM78561     5  0.3274      1.000 0.000 0.220 0.000 0.000 0.780

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM78539     4  0.2969      0.874 0.224 0.000 0.000 0.776 0.000 0.000
#> GSM78545     4  0.1858      0.594 0.012 0.000 0.000 0.912 0.000 0.076
#> GSM78550     4  0.0777      0.695 0.024 0.000 0.000 0.972 0.000 0.004
#> GSM78554     4  0.3136      0.869 0.228 0.000 0.000 0.768 0.000 0.004
#> GSM78562     4  0.2941      0.876 0.220 0.000 0.000 0.780 0.000 0.000
#> GSM78540     4  0.2941      0.876 0.220 0.000 0.000 0.780 0.000 0.000
#> GSM78546     4  0.2941      0.876 0.220 0.000 0.000 0.780 0.000 0.000
#> GSM78551     4  0.0547      0.697 0.020 0.000 0.000 0.980 0.000 0.000
#> GSM78555     4  0.2941      0.876 0.220 0.000 0.000 0.780 0.000 0.000
#> GSM78563     4  0.2941      0.876 0.220 0.000 0.000 0.780 0.000 0.000
#> GSM43005     6  0.5985      0.638 0.272 0.000 0.000 0.220 0.008 0.500
#> GSM43008     6  0.5985      0.638 0.272 0.000 0.000 0.220 0.008 0.500
#> GSM43011     6  0.0790      0.665 0.032 0.000 0.000 0.000 0.000 0.968
#> GSM78523     6  0.0790      0.665 0.032 0.000 0.000 0.000 0.000 0.968
#> GSM78526     6  0.0146      0.652 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM78529     6  0.5985      0.638 0.272 0.000 0.000 0.220 0.008 0.500
#> GSM78532     1  0.1387      0.781 0.932 0.000 0.000 0.068 0.000 0.000
#> GSM78534     6  0.0146      0.652 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM78537     1  0.1531      0.780 0.928 0.000 0.000 0.068 0.000 0.004
#> GSM78543     1  0.1387      0.781 0.932 0.000 0.000 0.068 0.000 0.000
#> GSM78548     1  0.6081     -0.176 0.472 0.000 0.000 0.228 0.008 0.292
#> GSM78557     1  0.3161      0.634 0.776 0.000 0.000 0.000 0.008 0.216
#> GSM78560     1  0.1387      0.781 0.932 0.000 0.000 0.068 0.000 0.000
#> GSM78565     1  0.1531      0.780 0.928 0.000 0.000 0.068 0.000 0.004
#> GSM43000     6  0.5785      0.654 0.224 0.000 0.000 0.220 0.008 0.548
#> GSM43002     6  0.5985      0.638 0.272 0.000 0.000 0.220 0.008 0.500
#> GSM43004     6  0.0146      0.652 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM43007     6  0.5985      0.638 0.272 0.000 0.000 0.220 0.008 0.500
#> GSM43010     6  0.0146      0.652 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM78522     6  0.0146      0.652 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM78525     6  0.5985      0.638 0.272 0.000 0.000 0.220 0.008 0.500
#> GSM78528     6  0.5985      0.638 0.272 0.000 0.000 0.220 0.008 0.500
#> GSM78531     1  0.1387      0.781 0.932 0.000 0.000 0.068 0.000 0.000
#> GSM78533     6  0.1814      0.673 0.100 0.000 0.000 0.000 0.000 0.900
#> GSM78536     1  0.1531      0.780 0.928 0.000 0.000 0.068 0.000 0.004
#> GSM78541     1  0.1531      0.780 0.928 0.000 0.000 0.068 0.000 0.004
#> GSM78547     1  0.3161      0.634 0.776 0.000 0.000 0.000 0.008 0.216
#> GSM78552     1  0.3161      0.634 0.776 0.000 0.000 0.000 0.008 0.216
#> GSM78556     1  0.3161      0.634 0.776 0.000 0.000 0.000 0.008 0.216
#> GSM78559     1  0.1531      0.780 0.928 0.000 0.000 0.068 0.000 0.004
#> GSM78564     1  0.3161      0.634 0.776 0.000 0.000 0.000 0.008 0.216
#> GSM42999     2  0.3857      0.404 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM43001     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM43003     2  0.3857      0.404 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM43006     5  0.5844     -0.403 0.000 0.324 0.208 0.000 0.468 0.000
#> GSM43009     2  0.3857      0.404 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM43012     2  0.3857      0.404 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM78524     2  0.3371     -0.013 0.000 0.708 0.000 0.000 0.292 0.000
#> GSM78527     2  0.3857      0.404 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM78530     2  0.0000      0.509 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78535     5  0.4089     -0.126 0.008 0.468 0.000 0.000 0.524 0.000
#> GSM78538     2  0.0000      0.509 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78542     2  0.0000      0.509 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78544     2  0.0000      0.509 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78549     2  0.3857      0.404 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM78553     2  0.0000      0.509 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78558     2  0.0000      0.509 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78561     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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 cell.type(p) agent(p) individual(p) k
#> SD:hclust 56     6.91e-13  0.00345        0.9986 2
#> SD:hclust 52     1.38e-10  0.01802        0.8287 3
#> SD:hclust 28     2.01e-11  0.44224        0.1255 4
#> SD:hclust 38     3.11e-13  0.24395        0.0224 5
#> SD:hclust 48     2.80e-17  0.20637        0.1519 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 58 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 1.000           0.999       0.998         0.4218 0.578   0.578
#> 3 3 0.624           0.835       0.830         0.4545 0.753   0.573
#> 4 4 0.632           0.772       0.778         0.1593 0.923   0.766
#> 5 5 0.714           0.623       0.763         0.0837 0.964   0.862
#> 6 6 0.833           0.764       0.783         0.0530 0.907   0.621

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
#> GSM78539     1  0.0376      0.997 0.996 0.004
#> GSM78545     1  0.0376      0.997 0.996 0.004
#> GSM78550     1  0.0376      0.997 0.996 0.004
#> GSM78554     1  0.0376      0.997 0.996 0.004
#> GSM78562     1  0.0376      0.997 0.996 0.004
#> GSM78540     1  0.0376      0.997 0.996 0.004
#> GSM78546     1  0.0376      0.997 0.996 0.004
#> GSM78551     1  0.0376      0.997 0.996 0.004
#> GSM78555     1  0.0376      0.997 0.996 0.004
#> GSM78563     1  0.0376      0.997 0.996 0.004
#> GSM43005     1  0.0000      0.999 1.000 0.000
#> GSM43008     1  0.0000      0.999 1.000 0.000
#> GSM43011     1  0.0000      0.999 1.000 0.000
#> GSM78523     1  0.0000      0.999 1.000 0.000
#> GSM78526     1  0.0000      0.999 1.000 0.000
#> GSM78529     1  0.0000      0.999 1.000 0.000
#> GSM78532     1  0.0000      0.999 1.000 0.000
#> GSM78534     1  0.0000      0.999 1.000 0.000
#> GSM78537     1  0.0000      0.999 1.000 0.000
#> GSM78543     1  0.0000      0.999 1.000 0.000
#> GSM78548     1  0.0000      0.999 1.000 0.000
#> GSM78557     1  0.0000      0.999 1.000 0.000
#> GSM78560     1  0.0000      0.999 1.000 0.000
#> GSM78565     1  0.0000      0.999 1.000 0.000
#> GSM43000     1  0.0000      0.999 1.000 0.000
#> GSM43002     1  0.0000      0.999 1.000 0.000
#> GSM43004     1  0.0000      0.999 1.000 0.000
#> GSM43007     1  0.0000      0.999 1.000 0.000
#> GSM43010     1  0.0000      0.999 1.000 0.000
#> GSM78522     1  0.0000      0.999 1.000 0.000
#> GSM78525     1  0.0000      0.999 1.000 0.000
#> GSM78528     1  0.0000      0.999 1.000 0.000
#> GSM78531     1  0.0000      0.999 1.000 0.000
#> GSM78533     1  0.0000      0.999 1.000 0.000
#> GSM78536     1  0.0000      0.999 1.000 0.000
#> GSM78541     1  0.0000      0.999 1.000 0.000
#> GSM78547     1  0.0000      0.999 1.000 0.000
#> GSM78552     1  0.0000      0.999 1.000 0.000
#> GSM78556     1  0.0000      0.999 1.000 0.000
#> GSM78559     1  0.0000      0.999 1.000 0.000
#> GSM78564     1  0.0000      0.999 1.000 0.000
#> GSM42999     2  0.0376      1.000 0.004 0.996
#> GSM43001     2  0.0376      1.000 0.004 0.996
#> GSM43003     2  0.0376      1.000 0.004 0.996
#> GSM43006     2  0.0376      1.000 0.004 0.996
#> GSM43009     2  0.0376      1.000 0.004 0.996
#> GSM43012     2  0.0376      1.000 0.004 0.996
#> GSM78524     2  0.0376      1.000 0.004 0.996
#> GSM78527     2  0.0376      1.000 0.004 0.996
#> GSM78530     2  0.0376      1.000 0.004 0.996
#> GSM78535     2  0.0376      1.000 0.004 0.996
#> GSM78538     2  0.0376      1.000 0.004 0.996
#> GSM78542     2  0.0376      1.000 0.004 0.996
#> GSM78544     2  0.0376      1.000 0.004 0.996
#> GSM78549     2  0.0376      1.000 0.004 0.996
#> GSM78553     2  0.0376      1.000 0.004 0.996
#> GSM78558     2  0.0376      1.000 0.004 0.996
#> GSM78561     2  0.0376      1.000 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     1  0.0237      0.736 0.996 0.000 0.004
#> GSM78545     1  0.0237      0.736 0.996 0.000 0.004
#> GSM78550     1  0.0237      0.736 0.996 0.000 0.004
#> GSM78554     1  0.0237      0.736 0.996 0.000 0.004
#> GSM78562     1  0.0237      0.736 0.996 0.000 0.004
#> GSM78540     1  0.0237      0.736 0.996 0.000 0.004
#> GSM78546     1  0.0237      0.736 0.996 0.000 0.004
#> GSM78551     1  0.0237      0.736 0.996 0.000 0.004
#> GSM78555     1  0.0237      0.736 0.996 0.000 0.004
#> GSM78563     1  0.0237      0.736 0.996 0.000 0.004
#> GSM43005     3  0.4555      0.931 0.200 0.000 0.800
#> GSM43008     3  0.4702      0.922 0.212 0.000 0.788
#> GSM43011     3  0.4062      0.940 0.164 0.000 0.836
#> GSM78523     3  0.4062      0.940 0.164 0.000 0.836
#> GSM78526     3  0.4062      0.940 0.164 0.000 0.836
#> GSM78529     3  0.4654      0.924 0.208 0.000 0.792
#> GSM78532     1  0.5363      0.756 0.724 0.000 0.276
#> GSM78534     3  0.4062      0.940 0.164 0.000 0.836
#> GSM78537     1  0.5363      0.756 0.724 0.000 0.276
#> GSM78543     1  0.5363      0.756 0.724 0.000 0.276
#> GSM78548     3  0.6286      0.160 0.464 0.000 0.536
#> GSM78557     1  0.5363      0.756 0.724 0.000 0.276
#> GSM78560     1  0.5363      0.756 0.724 0.000 0.276
#> GSM78565     1  0.5363      0.756 0.724 0.000 0.276
#> GSM43000     3  0.4062      0.940 0.164 0.000 0.836
#> GSM43002     3  0.4555      0.931 0.200 0.000 0.800
#> GSM43004     3  0.4121      0.938 0.168 0.000 0.832
#> GSM43007     3  0.4654      0.924 0.208 0.000 0.792
#> GSM43010     3  0.4062      0.940 0.164 0.000 0.836
#> GSM78522     3  0.4062      0.940 0.164 0.000 0.836
#> GSM78525     3  0.4399      0.936 0.188 0.000 0.812
#> GSM78528     3  0.4654      0.924 0.208 0.000 0.792
#> GSM78531     1  0.5363      0.756 0.724 0.000 0.276
#> GSM78533     3  0.4062      0.940 0.164 0.000 0.836
#> GSM78536     1  0.5363      0.756 0.724 0.000 0.276
#> GSM78541     1  0.5363      0.756 0.724 0.000 0.276
#> GSM78547     1  0.5363      0.756 0.724 0.000 0.276
#> GSM78552     1  0.5948      0.566 0.640 0.000 0.360
#> GSM78556     1  0.5363      0.756 0.724 0.000 0.276
#> GSM78559     1  0.5363      0.756 0.724 0.000 0.276
#> GSM78564     1  0.5363      0.756 0.724 0.000 0.276
#> GSM42999     2  0.0000      0.936 0.000 1.000 0.000
#> GSM43001     2  0.1964      0.922 0.000 0.944 0.056
#> GSM43003     2  0.0237      0.935 0.000 0.996 0.004
#> GSM43006     2  0.1964      0.922 0.000 0.944 0.056
#> GSM43009     2  0.2356      0.938 0.000 0.928 0.072
#> GSM43012     2  0.1964      0.922 0.000 0.944 0.056
#> GSM78524     2  0.3116      0.937 0.000 0.892 0.108
#> GSM78527     2  0.0237      0.935 0.000 0.996 0.004
#> GSM78530     2  0.3116      0.937 0.000 0.892 0.108
#> GSM78535     2  0.7949      0.632 0.252 0.640 0.108
#> GSM78538     2  0.3116      0.937 0.000 0.892 0.108
#> GSM78542     2  0.3116      0.937 0.000 0.892 0.108
#> GSM78544     2  0.3116      0.937 0.000 0.892 0.108
#> GSM78549     2  0.0000      0.936 0.000 1.000 0.000
#> GSM78553     2  0.3116      0.937 0.000 0.892 0.108
#> GSM78558     2  0.3116      0.937 0.000 0.892 0.108
#> GSM78561     2  0.1964      0.922 0.000 0.944 0.056

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     4  0.4999      0.959 0.492 0.000 0.000 0.508
#> GSM78545     4  0.6130      0.901 0.440 0.000 0.048 0.512
#> GSM78550     4  0.6130      0.901 0.440 0.000 0.048 0.512
#> GSM78554     4  0.4998      0.960 0.488 0.000 0.000 0.512
#> GSM78562     4  0.4999      0.959 0.492 0.000 0.000 0.508
#> GSM78540     4  0.5000      0.957 0.500 0.000 0.000 0.500
#> GSM78546     4  0.5000      0.960 0.496 0.000 0.000 0.504
#> GSM78551     4  0.5000      0.960 0.496 0.000 0.000 0.504
#> GSM78555     1  0.5000     -0.958 0.504 0.000 0.000 0.496
#> GSM78563     1  0.5000     -0.964 0.500 0.000 0.000 0.500
#> GSM43005     3  0.3300      0.818 0.144 0.000 0.848 0.008
#> GSM43008     3  0.3300      0.818 0.144 0.000 0.848 0.008
#> GSM43011     3  0.4105      0.841 0.032 0.000 0.812 0.156
#> GSM78523     3  0.4105      0.841 0.032 0.000 0.812 0.156
#> GSM78526     3  0.4105      0.841 0.032 0.000 0.812 0.156
#> GSM78529     3  0.3300      0.818 0.144 0.000 0.848 0.008
#> GSM78532     1  0.2647      0.837 0.880 0.000 0.120 0.000
#> GSM78534     3  0.4105      0.841 0.032 0.000 0.812 0.156
#> GSM78537     1  0.2647      0.837 0.880 0.000 0.120 0.000
#> GSM78543     1  0.2647      0.837 0.880 0.000 0.120 0.000
#> GSM78548     3  0.4897      0.452 0.332 0.000 0.660 0.008
#> GSM78557     1  0.2647      0.837 0.880 0.000 0.120 0.000
#> GSM78560     1  0.2647      0.837 0.880 0.000 0.120 0.000
#> GSM78565     1  0.2647      0.837 0.880 0.000 0.120 0.000
#> GSM43000     3  0.1022      0.832 0.032 0.000 0.968 0.000
#> GSM43002     3  0.3157      0.818 0.144 0.000 0.852 0.004
#> GSM43004     3  0.4105      0.841 0.032 0.000 0.812 0.156
#> GSM43007     3  0.3300      0.818 0.144 0.000 0.848 0.008
#> GSM43010     3  0.4105      0.841 0.032 0.000 0.812 0.156
#> GSM78522     3  0.4105      0.841 0.032 0.000 0.812 0.156
#> GSM78525     3  0.3157      0.818 0.144 0.000 0.852 0.004
#> GSM78528     3  0.3300      0.818 0.144 0.000 0.848 0.008
#> GSM78531     1  0.2647      0.837 0.880 0.000 0.120 0.000
#> GSM78533     3  0.4105      0.841 0.032 0.000 0.812 0.156
#> GSM78536     1  0.2647      0.837 0.880 0.000 0.120 0.000
#> GSM78541     1  0.2647      0.837 0.880 0.000 0.120 0.000
#> GSM78547     1  0.2647      0.837 0.880 0.000 0.120 0.000
#> GSM78552     1  0.4955      0.505 0.648 0.000 0.344 0.008
#> GSM78556     1  0.2647      0.837 0.880 0.000 0.120 0.000
#> GSM78559     1  0.2647      0.837 0.880 0.000 0.120 0.000
#> GSM78564     1  0.2814      0.820 0.868 0.000 0.132 0.000
#> GSM42999     2  0.0376      0.852 0.000 0.992 0.004 0.004
#> GSM43001     2  0.4234      0.801 0.068 0.844 0.020 0.068
#> GSM43003     2  0.0336      0.850 0.000 0.992 0.000 0.008
#> GSM43006     2  0.4234      0.801 0.068 0.844 0.020 0.068
#> GSM43009     2  0.3157      0.861 0.000 0.852 0.004 0.144
#> GSM43012     2  0.3975      0.809 0.064 0.856 0.016 0.064
#> GSM78524     2  0.4516      0.854 0.000 0.736 0.012 0.252
#> GSM78527     2  0.0336      0.850 0.000 0.992 0.000 0.008
#> GSM78530     2  0.4040      0.856 0.000 0.752 0.000 0.248
#> GSM78535     2  0.7627      0.599 0.240 0.504 0.004 0.252
#> GSM78538     2  0.4040      0.856 0.000 0.752 0.000 0.248
#> GSM78542     2  0.4040      0.856 0.000 0.752 0.000 0.248
#> GSM78544     2  0.4220      0.856 0.000 0.748 0.004 0.248
#> GSM78549     2  0.0000      0.852 0.000 1.000 0.000 0.000
#> GSM78553     2  0.4040      0.856 0.000 0.752 0.000 0.248
#> GSM78558     2  0.4040      0.856 0.000 0.752 0.000 0.248
#> GSM78561     2  0.4339      0.800 0.068 0.840 0.024 0.068

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4  0.3612      0.980 0.184 0.000 0.016 0.796 0.004
#> GSM78545     4  0.4151      0.957 0.156 0.000 0.044 0.788 0.012
#> GSM78550     4  0.4151      0.957 0.156 0.000 0.044 0.788 0.012
#> GSM78554     4  0.3843      0.978 0.184 0.000 0.016 0.788 0.012
#> GSM78562     4  0.3612      0.980 0.184 0.000 0.016 0.796 0.004
#> GSM78540     4  0.2966      0.981 0.184 0.000 0.000 0.816 0.000
#> GSM78546     4  0.2966      0.981 0.184 0.000 0.000 0.816 0.000
#> GSM78551     4  0.3123      0.981 0.184 0.000 0.000 0.812 0.004
#> GSM78555     4  0.3039      0.975 0.192 0.000 0.000 0.808 0.000
#> GSM78563     4  0.2966      0.981 0.184 0.000 0.000 0.816 0.000
#> GSM43005     3  0.3093      0.694 0.168 0.000 0.824 0.008 0.000
#> GSM43008     3  0.3132      0.692 0.172 0.000 0.820 0.008 0.000
#> GSM43011     3  0.6777      0.696 0.076 0.000 0.484 0.064 0.376
#> GSM78523     3  0.6777      0.696 0.076 0.000 0.484 0.064 0.376
#> GSM78526     3  0.6777      0.696 0.076 0.000 0.484 0.064 0.376
#> GSM78529     3  0.3132      0.692 0.172 0.000 0.820 0.008 0.000
#> GSM78532     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000
#> GSM78534     3  0.6869      0.695 0.076 0.000 0.480 0.072 0.372
#> GSM78537     1  0.0290      0.953 0.992 0.000 0.000 0.000 0.008
#> GSM78543     1  0.0290      0.953 0.992 0.000 0.000 0.000 0.008
#> GSM78548     3  0.3737      0.620 0.224 0.000 0.764 0.008 0.004
#> GSM78557     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000
#> GSM78560     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000
#> GSM78565     1  0.0290      0.953 0.992 0.000 0.000 0.000 0.008
#> GSM43000     3  0.1831      0.708 0.076 0.000 0.920 0.000 0.004
#> GSM43002     3  0.2813      0.696 0.168 0.000 0.832 0.000 0.000
#> GSM43004     3  0.6869      0.695 0.076 0.000 0.480 0.072 0.372
#> GSM43007     3  0.3132      0.692 0.172 0.000 0.820 0.008 0.000
#> GSM43010     3  0.6777      0.696 0.076 0.000 0.484 0.064 0.376
#> GSM78522     3  0.6869      0.695 0.076 0.000 0.480 0.072 0.372
#> GSM78525     3  0.2732      0.698 0.160 0.000 0.840 0.000 0.000
#> GSM78528     3  0.3132      0.692 0.172 0.000 0.820 0.008 0.000
#> GSM78531     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000
#> GSM78533     3  0.6777      0.696 0.076 0.000 0.484 0.064 0.376
#> GSM78536     1  0.0290      0.953 0.992 0.000 0.000 0.000 0.008
#> GSM78541     1  0.0290      0.953 0.992 0.000 0.000 0.000 0.008
#> GSM78547     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000
#> GSM78552     1  0.4664      0.149 0.552 0.000 0.436 0.008 0.004
#> GSM78556     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000
#> GSM78559     1  0.0290      0.953 0.992 0.000 0.000 0.000 0.008
#> GSM78564     1  0.0162      0.950 0.996 0.000 0.004 0.000 0.000
#> GSM42999     2  0.1525      0.435 0.000 0.948 0.012 0.004 0.036
#> GSM43001     2  0.4952      0.396 0.000 0.756 0.032 0.100 0.112
#> GSM43003     2  0.0000      0.449 0.000 1.000 0.000 0.000 0.000
#> GSM43006     2  0.4902      0.397 0.000 0.760 0.032 0.096 0.112
#> GSM43009     2  0.4181      0.178 0.000 0.732 0.020 0.004 0.244
#> GSM43012     2  0.4042      0.414 0.000 0.820 0.040 0.040 0.100
#> GSM78524     2  0.5084     -0.270 0.000 0.520 0.016 0.012 0.452
#> GSM78527     2  0.0000      0.449 0.000 1.000 0.000 0.000 0.000
#> GSM78530     2  0.4291     -0.203 0.000 0.536 0.000 0.000 0.464
#> GSM78535     5  0.6562      0.000 0.140 0.368 0.004 0.008 0.480
#> GSM78538     2  0.4262     -0.179 0.000 0.560 0.000 0.000 0.440
#> GSM78542     2  0.4262     -0.179 0.000 0.560 0.000 0.000 0.440
#> GSM78544     2  0.4576     -0.199 0.000 0.536 0.004 0.004 0.456
#> GSM78549     2  0.0771      0.444 0.000 0.976 0.004 0.000 0.020
#> GSM78553     2  0.4291     -0.203 0.000 0.536 0.000 0.000 0.464
#> GSM78558     2  0.4291     -0.203 0.000 0.536 0.000 0.000 0.464
#> GSM78561     2  0.4952      0.396 0.000 0.756 0.032 0.100 0.112

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM78539     4  0.1765     0.9601 0.096 0.000 0.000 0.904 0.000 0.000
#> GSM78545     4  0.3393     0.9435 0.088 0.000 0.012 0.844 0.036 0.020
#> GSM78550     4  0.3485     0.9436 0.088 0.000 0.016 0.840 0.036 0.020
#> GSM78554     4  0.3211     0.9484 0.096 0.000 0.004 0.848 0.032 0.020
#> GSM78562     4  0.1765     0.9601 0.096 0.000 0.000 0.904 0.000 0.000
#> GSM78540     4  0.3099     0.9603 0.096 0.000 0.012 0.848 0.044 0.000
#> GSM78546     4  0.3099     0.9603 0.096 0.000 0.012 0.848 0.044 0.000
#> GSM78551     4  0.3874     0.9582 0.096 0.000 0.020 0.812 0.060 0.012
#> GSM78555     4  0.3147     0.9586 0.100 0.000 0.012 0.844 0.044 0.000
#> GSM78563     4  0.3099     0.9603 0.096 0.000 0.012 0.848 0.044 0.000
#> GSM43005     3  0.1812     0.8840 0.080 0.000 0.912 0.008 0.000 0.000
#> GSM43008     3  0.1956     0.8841 0.080 0.000 0.908 0.004 0.008 0.000
#> GSM43011     6  0.3790     0.9586 0.024 0.000 0.216 0.004 0.004 0.752
#> GSM78523     6  0.3790     0.9586 0.024 0.000 0.216 0.004 0.004 0.752
#> GSM78526     6  0.3483     0.9619 0.024 0.000 0.212 0.000 0.000 0.764
#> GSM78529     3  0.2068     0.8825 0.080 0.000 0.904 0.008 0.008 0.000
#> GSM78532     1  0.0603     0.9526 0.980 0.000 0.000 0.000 0.016 0.004
#> GSM78534     6  0.5107     0.9408 0.024 0.000 0.212 0.008 0.076 0.680
#> GSM78537     1  0.1141     0.9504 0.948 0.000 0.000 0.000 0.052 0.000
#> GSM78543     1  0.1141     0.9504 0.948 0.000 0.000 0.000 0.052 0.000
#> GSM78548     3  0.4694     0.7335 0.184 0.000 0.716 0.004 0.080 0.016
#> GSM78557     1  0.1265     0.9438 0.948 0.000 0.000 0.000 0.044 0.008
#> GSM78560     1  0.1010     0.9484 0.960 0.000 0.000 0.000 0.036 0.004
#> GSM78565     1  0.1204     0.9494 0.944 0.000 0.000 0.000 0.056 0.000
#> GSM43000     3  0.2745     0.7830 0.024 0.000 0.880 0.004 0.020 0.072
#> GSM43002     3  0.2237     0.8797 0.080 0.000 0.896 0.000 0.020 0.004
#> GSM43004     6  0.5203     0.9378 0.024 0.000 0.212 0.008 0.084 0.672
#> GSM43007     3  0.1956     0.8841 0.080 0.000 0.908 0.004 0.008 0.000
#> GSM43010     6  0.3483     0.9619 0.024 0.000 0.212 0.000 0.000 0.764
#> GSM78522     6  0.5155     0.9398 0.024 0.000 0.212 0.008 0.080 0.676
#> GSM78525     3  0.2237     0.8797 0.080 0.000 0.896 0.000 0.020 0.004
#> GSM78528     3  0.1956     0.8834 0.080 0.000 0.908 0.004 0.008 0.000
#> GSM78531     1  0.0603     0.9526 0.980 0.000 0.000 0.000 0.016 0.004
#> GSM78533     6  0.3483     0.9619 0.024 0.000 0.212 0.000 0.000 0.764
#> GSM78536     1  0.1204     0.9494 0.944 0.000 0.000 0.000 0.056 0.000
#> GSM78541     1  0.1204     0.9494 0.944 0.000 0.000 0.000 0.056 0.000
#> GSM78547     1  0.1265     0.9438 0.948 0.000 0.000 0.000 0.044 0.008
#> GSM78552     3  0.5605     0.3467 0.404 0.000 0.496 0.004 0.080 0.016
#> GSM78556     1  0.1265     0.9438 0.948 0.000 0.000 0.000 0.044 0.008
#> GSM78559     1  0.1204     0.9494 0.944 0.000 0.000 0.000 0.056 0.000
#> GSM78564     1  0.0972     0.9485 0.964 0.000 0.000 0.000 0.028 0.008
#> GSM42999     2  0.1296     0.4528 0.000 0.948 0.004 0.004 0.044 0.000
#> GSM43001     2  0.6536     0.4726 0.000 0.584 0.044 0.040 0.136 0.196
#> GSM43003     2  0.0000     0.4957 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43006     2  0.6486     0.4753 0.000 0.592 0.044 0.040 0.136 0.188
#> GSM43009     2  0.3466    -0.0156 0.000 0.760 0.008 0.008 0.224 0.000
#> GSM43012     2  0.4450     0.5018 0.000 0.768 0.036 0.016 0.136 0.044
#> GSM78524     5  0.5086     0.7412 0.000 0.432 0.008 0.040 0.512 0.008
#> GSM78527     2  0.0000     0.4957 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78530     5  0.3866     0.8390 0.000 0.484 0.000 0.000 0.516 0.000
#> GSM78535     5  0.6251     0.5091 0.116 0.280 0.008 0.032 0.556 0.008
#> GSM78538     2  0.3864    -0.8211 0.000 0.520 0.000 0.000 0.480 0.000
#> GSM78542     2  0.3864    -0.8211 0.000 0.520 0.000 0.000 0.480 0.000
#> GSM78544     5  0.3864     0.8372 0.000 0.480 0.000 0.000 0.520 0.000
#> GSM78549     2  0.0865     0.4631 0.000 0.964 0.000 0.000 0.036 0.000
#> GSM78553     5  0.3866     0.8390 0.000 0.484 0.000 0.000 0.516 0.000
#> GSM78558     5  0.3866     0.8390 0.000 0.484 0.000 0.000 0.516 0.000
#> GSM78561     2  0.6536     0.4726 0.000 0.584 0.044 0.040 0.136 0.196

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 cell.type(p) agent(p) individual(p) k
#> SD:kmeans 58     2.54e-13  0.00184        0.9999 2
#> SD:kmeans 57     2.67e-14  0.00370        0.1374 3
#> SD:kmeans 55     2.04e-21  0.00458        0.3619 4
#> SD:kmeans 40     2.06e-09  0.98224        0.0197 5
#> SD:kmeans 47     8.59e-16  0.33939        0.0375 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 58 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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           1.000       1.000         0.4222 0.578   0.578
#> 3 3 0.780           0.887       0.924         0.5434 0.750   0.567
#> 4 4 1.000           0.982       0.989         0.1562 0.903   0.712
#> 5 5 1.000           0.959       0.971         0.0593 0.943   0.775
#> 6 6 0.938           0.933       0.926         0.0460 0.956   0.783

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette p1 p2
#> GSM78539     1       0          1  1  0
#> GSM78545     1       0          1  1  0
#> GSM78550     1       0          1  1  0
#> GSM78554     1       0          1  1  0
#> GSM78562     1       0          1  1  0
#> GSM78540     1       0          1  1  0
#> GSM78546     1       0          1  1  0
#> GSM78551     1       0          1  1  0
#> GSM78555     1       0          1  1  0
#> GSM78563     1       0          1  1  0
#> GSM43005     1       0          1  1  0
#> GSM43008     1       0          1  1  0
#> GSM43011     1       0          1  1  0
#> GSM78523     1       0          1  1  0
#> GSM78526     1       0          1  1  0
#> GSM78529     1       0          1  1  0
#> GSM78532     1       0          1  1  0
#> GSM78534     1       0          1  1  0
#> GSM78537     1       0          1  1  0
#> GSM78543     1       0          1  1  0
#> GSM78548     1       0          1  1  0
#> GSM78557     1       0          1  1  0
#> GSM78560     1       0          1  1  0
#> GSM78565     1       0          1  1  0
#> GSM43000     1       0          1  1  0
#> GSM43002     1       0          1  1  0
#> GSM43004     1       0          1  1  0
#> GSM43007     1       0          1  1  0
#> GSM43010     1       0          1  1  0
#> GSM78522     1       0          1  1  0
#> GSM78525     1       0          1  1  0
#> GSM78528     1       0          1  1  0
#> GSM78531     1       0          1  1  0
#> GSM78533     1       0          1  1  0
#> GSM78536     1       0          1  1  0
#> GSM78541     1       0          1  1  0
#> GSM78547     1       0          1  1  0
#> GSM78552     1       0          1  1  0
#> GSM78556     1       0          1  1  0
#> GSM78559     1       0          1  1  0
#> GSM78564     1       0          1  1  0
#> GSM42999     2       0          1  0  1
#> GSM43001     2       0          1  0  1
#> GSM43003     2       0          1  0  1
#> GSM43006     2       0          1  0  1
#> GSM43009     2       0          1  0  1
#> GSM43012     2       0          1  0  1
#> GSM78524     2       0          1  0  1
#> GSM78527     2       0          1  0  1
#> GSM78530     2       0          1  0  1
#> GSM78535     2       0          1  0  1
#> GSM78538     2       0          1  0  1
#> GSM78542     2       0          1  0  1
#> GSM78544     2       0          1  0  1
#> GSM78549     2       0          1  0  1
#> GSM78553     2       0          1  0  1
#> GSM78558     2       0          1  0  1
#> GSM78561     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1 p2    p3
#> GSM78539     1   0.000     0.7803 1.000  0 0.000
#> GSM78545     1   0.000     0.7803 1.000  0 0.000
#> GSM78550     1   0.000     0.7803 1.000  0 0.000
#> GSM78554     1   0.000     0.7803 1.000  0 0.000
#> GSM78562     1   0.000     0.7803 1.000  0 0.000
#> GSM78540     1   0.000     0.7803 1.000  0 0.000
#> GSM78546     1   0.000     0.7803 1.000  0 0.000
#> GSM78551     1   0.000     0.7803 1.000  0 0.000
#> GSM78555     1   0.000     0.7803 1.000  0 0.000
#> GSM78563     1   0.000     0.7803 1.000  0 0.000
#> GSM43005     3   0.000     0.9654 0.000  0 1.000
#> GSM43008     3   0.000     0.9654 0.000  0 1.000
#> GSM43011     3   0.000     0.9654 0.000  0 1.000
#> GSM78523     3   0.000     0.9654 0.000  0 1.000
#> GSM78526     3   0.000     0.9654 0.000  0 1.000
#> GSM78529     3   0.000     0.9654 0.000  0 1.000
#> GSM78532     1   0.559     0.7910 0.696  0 0.304
#> GSM78534     3   0.000     0.9654 0.000  0 1.000
#> GSM78537     1   0.559     0.7910 0.696  0 0.304
#> GSM78543     1   0.559     0.7910 0.696  0 0.304
#> GSM78548     3   0.196     0.8969 0.056  0 0.944
#> GSM78557     1   0.559     0.7910 0.696  0 0.304
#> GSM78560     1   0.559     0.7910 0.696  0 0.304
#> GSM78565     1   0.559     0.7910 0.696  0 0.304
#> GSM43000     3   0.000     0.9654 0.000  0 1.000
#> GSM43002     3   0.000     0.9654 0.000  0 1.000
#> GSM43004     3   0.000     0.9654 0.000  0 1.000
#> GSM43007     3   0.000     0.9654 0.000  0 1.000
#> GSM43010     3   0.000     0.9654 0.000  0 1.000
#> GSM78522     3   0.000     0.9654 0.000  0 1.000
#> GSM78525     3   0.000     0.9654 0.000  0 1.000
#> GSM78528     3   0.000     0.9654 0.000  0 1.000
#> GSM78531     1   0.559     0.7910 0.696  0 0.304
#> GSM78533     3   0.000     0.9654 0.000  0 1.000
#> GSM78536     1   0.559     0.7910 0.696  0 0.304
#> GSM78541     1   0.559     0.7910 0.696  0 0.304
#> GSM78547     1   0.559     0.7910 0.696  0 0.304
#> GSM78552     3   0.608     0.0291 0.388  0 0.612
#> GSM78556     1   0.559     0.7910 0.696  0 0.304
#> GSM78559     1   0.559     0.7910 0.696  0 0.304
#> GSM78564     1   0.559     0.7910 0.696  0 0.304
#> GSM42999     2   0.000     1.0000 0.000  1 0.000
#> GSM43001     2   0.000     1.0000 0.000  1 0.000
#> GSM43003     2   0.000     1.0000 0.000  1 0.000
#> GSM43006     2   0.000     1.0000 0.000  1 0.000
#> GSM43009     2   0.000     1.0000 0.000  1 0.000
#> GSM43012     2   0.000     1.0000 0.000  1 0.000
#> GSM78524     2   0.000     1.0000 0.000  1 0.000
#> GSM78527     2   0.000     1.0000 0.000  1 0.000
#> GSM78530     2   0.000     1.0000 0.000  1 0.000
#> GSM78535     2   0.000     1.0000 0.000  1 0.000
#> GSM78538     2   0.000     1.0000 0.000  1 0.000
#> GSM78542     2   0.000     1.0000 0.000  1 0.000
#> GSM78544     2   0.000     1.0000 0.000  1 0.000
#> GSM78549     2   0.000     1.0000 0.000  1 0.000
#> GSM78553     2   0.000     1.0000 0.000  1 0.000
#> GSM78558     2   0.000     1.0000 0.000  1 0.000
#> GSM78561     2   0.000     1.0000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1 p2    p3    p4
#> GSM78539     4  0.0336      0.999 0.008  0 0.000 0.992
#> GSM78545     4  0.0188      0.996 0.004  0 0.000 0.996
#> GSM78550     4  0.0188      0.996 0.004  0 0.000 0.996
#> GSM78554     4  0.0336      0.999 0.008  0 0.000 0.992
#> GSM78562     4  0.0336      0.999 0.008  0 0.000 0.992
#> GSM78540     4  0.0336      0.999 0.008  0 0.000 0.992
#> GSM78546     4  0.0336      0.999 0.008  0 0.000 0.992
#> GSM78551     4  0.0336      0.999 0.008  0 0.000 0.992
#> GSM78555     4  0.0336      0.999 0.008  0 0.000 0.992
#> GSM78563     4  0.0336      0.999 0.008  0 0.000 0.992
#> GSM43005     3  0.0376      0.967 0.004  0 0.992 0.004
#> GSM43008     3  0.1743      0.934 0.056  0 0.940 0.004
#> GSM43011     3  0.0188      0.968 0.000  0 0.996 0.004
#> GSM78523     3  0.0188      0.968 0.000  0 0.996 0.004
#> GSM78526     3  0.0188      0.968 0.000  0 0.996 0.004
#> GSM78529     3  0.0524      0.966 0.008  0 0.988 0.004
#> GSM78532     1  0.0000      0.997 1.000  0 0.000 0.000
#> GSM78534     3  0.0188      0.968 0.000  0 0.996 0.004
#> GSM78537     1  0.0000      0.997 1.000  0 0.000 0.000
#> GSM78543     1  0.0000      0.997 1.000  0 0.000 0.000
#> GSM78548     3  0.4088      0.716 0.232  0 0.764 0.004
#> GSM78557     1  0.0000      0.997 1.000  0 0.000 0.000
#> GSM78560     1  0.0000      0.997 1.000  0 0.000 0.000
#> GSM78565     1  0.0000      0.997 1.000  0 0.000 0.000
#> GSM43000     3  0.0000      0.968 0.000  0 1.000 0.000
#> GSM43002     3  0.0376      0.967 0.004  0 0.992 0.004
#> GSM43004     3  0.2197      0.907 0.080  0 0.916 0.004
#> GSM43007     3  0.1743      0.934 0.056  0 0.940 0.004
#> GSM43010     3  0.0188      0.968 0.000  0 0.996 0.004
#> GSM78522     3  0.0188      0.968 0.000  0 0.996 0.004
#> GSM78525     3  0.0188      0.967 0.000  0 0.996 0.004
#> GSM78528     3  0.0524      0.966 0.008  0 0.988 0.004
#> GSM78531     1  0.0000      0.997 1.000  0 0.000 0.000
#> GSM78533     3  0.0188      0.968 0.000  0 0.996 0.004
#> GSM78536     1  0.0000      0.997 1.000  0 0.000 0.000
#> GSM78541     1  0.0000      0.997 1.000  0 0.000 0.000
#> GSM78547     1  0.0000      0.997 1.000  0 0.000 0.000
#> GSM78552     1  0.1305      0.956 0.960  0 0.036 0.004
#> GSM78556     1  0.0000      0.997 1.000  0 0.000 0.000
#> GSM78559     1  0.0000      0.997 1.000  0 0.000 0.000
#> GSM78564     1  0.0000      0.997 1.000  0 0.000 0.000
#> GSM42999     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43001     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43003     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43006     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43009     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43012     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78524     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78527     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78530     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78535     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78538     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78542     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78544     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78549     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78553     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78558     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78561     2  0.0000      1.000 0.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3 p4    p5
#> GSM78539     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78545     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78550     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78554     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78562     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78540     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78546     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78551     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78555     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78563     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM43005     3  0.1341      0.900 0.000 0.000 0.944  0 0.056
#> GSM43008     3  0.1341      0.900 0.000 0.000 0.944  0 0.056
#> GSM43011     5  0.0000      0.999 0.000 0.000 0.000  0 1.000
#> GSM78523     5  0.0000      0.999 0.000 0.000 0.000  0 1.000
#> GSM78526     5  0.0000      0.999 0.000 0.000 0.000  0 1.000
#> GSM78529     3  0.1341      0.900 0.000 0.000 0.944  0 0.056
#> GSM78532     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78534     5  0.0000      0.999 0.000 0.000 0.000  0 1.000
#> GSM78537     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78543     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78548     3  0.3043      0.843 0.080 0.000 0.864  0 0.056
#> GSM78557     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78560     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78565     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM43000     3  0.4150      0.457 0.000 0.000 0.612  0 0.388
#> GSM43002     3  0.1341      0.900 0.000 0.000 0.944  0 0.056
#> GSM43004     5  0.0162      0.994 0.004 0.000 0.000  0 0.996
#> GSM43007     3  0.1341      0.900 0.000 0.000 0.944  0 0.056
#> GSM43010     5  0.0000      0.999 0.000 0.000 0.000  0 1.000
#> GSM78522     5  0.0000      0.999 0.000 0.000 0.000  0 1.000
#> GSM78525     3  0.1341      0.900 0.000 0.000 0.944  0 0.056
#> GSM78528     3  0.1341      0.900 0.000 0.000 0.944  0 0.056
#> GSM78531     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78533     5  0.0000      0.999 0.000 0.000 0.000  0 1.000
#> GSM78536     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78541     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78547     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78552     3  0.4088      0.440 0.368 0.000 0.632  0 0.000
#> GSM78556     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78559     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78564     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM42999     2  0.0000      0.977 0.000 1.000 0.000  0 0.000
#> GSM43001     2  0.0162      0.976 0.000 0.996 0.004  0 0.000
#> GSM43003     2  0.0000      0.977 0.000 1.000 0.000  0 0.000
#> GSM43006     2  0.0162      0.976 0.000 0.996 0.004  0 0.000
#> GSM43009     2  0.0000      0.977 0.000 1.000 0.000  0 0.000
#> GSM43012     2  0.0162      0.976 0.000 0.996 0.004  0 0.000
#> GSM78524     2  0.1270      0.975 0.000 0.948 0.052  0 0.000
#> GSM78527     2  0.0000      0.977 0.000 1.000 0.000  0 0.000
#> GSM78530     2  0.1270      0.975 0.000 0.948 0.052  0 0.000
#> GSM78535     2  0.1270      0.975 0.000 0.948 0.052  0 0.000
#> GSM78538     2  0.1270      0.975 0.000 0.948 0.052  0 0.000
#> GSM78542     2  0.1270      0.975 0.000 0.948 0.052  0 0.000
#> GSM78544     2  0.1270      0.975 0.000 0.948 0.052  0 0.000
#> GSM78549     2  0.0000      0.977 0.000 1.000 0.000  0 0.000
#> GSM78553     2  0.1270      0.975 0.000 0.948 0.052  0 0.000
#> GSM78558     2  0.1270      0.975 0.000 0.948 0.052  0 0.000
#> GSM78561     2  0.0162      0.976 0.000 0.996 0.004  0 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
#> GSM78539     4  0.0547      0.984 0.000 0.000 0.000 0.980 0.020 0.000
#> GSM78545     4  0.1219      0.973 0.000 0.000 0.004 0.948 0.048 0.000
#> GSM78550     4  0.1219      0.973 0.000 0.000 0.004 0.948 0.048 0.000
#> GSM78554     4  0.0865      0.980 0.000 0.000 0.000 0.964 0.036 0.000
#> GSM78562     4  0.0547      0.984 0.000 0.000 0.000 0.980 0.020 0.000
#> GSM78540     4  0.0000      0.986 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78546     4  0.0000      0.986 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78551     4  0.0000      0.986 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78555     4  0.0000      0.986 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78563     4  0.0000      0.986 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM43005     3  0.0603      0.885 0.000 0.000 0.980 0.000 0.016 0.004
#> GSM43008     3  0.0603      0.885 0.000 0.000 0.980 0.000 0.016 0.004
#> GSM43011     6  0.0000      0.992 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78523     6  0.0000      0.992 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78526     6  0.0000      0.992 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78529     3  0.0692      0.884 0.000 0.000 0.976 0.000 0.020 0.004
#> GSM78532     1  0.0547      0.973 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM78534     6  0.0547      0.987 0.000 0.000 0.000 0.000 0.020 0.980
#> GSM78537     1  0.0000      0.975 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78543     1  0.0000      0.975 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78548     3  0.3808      0.780 0.080 0.000 0.784 0.000 0.132 0.004
#> GSM78557     1  0.1501      0.952 0.924 0.000 0.000 0.000 0.076 0.000
#> GSM78560     1  0.0547      0.973 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM78565     1  0.0363      0.970 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM43000     3  0.4064      0.501 0.000 0.000 0.644 0.000 0.020 0.336
#> GSM43002     3  0.0935      0.883 0.000 0.000 0.964 0.000 0.032 0.004
#> GSM43004     6  0.0790      0.980 0.000 0.000 0.000 0.000 0.032 0.968
#> GSM43007     3  0.0603      0.885 0.000 0.000 0.980 0.000 0.016 0.004
#> GSM43010     6  0.0000      0.992 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78522     6  0.0547      0.987 0.000 0.000 0.000 0.000 0.020 0.980
#> GSM78525     3  0.0858      0.882 0.000 0.000 0.968 0.000 0.028 0.004
#> GSM78528     3  0.0692      0.884 0.000 0.000 0.976 0.000 0.020 0.004
#> GSM78531     1  0.0547      0.973 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM78533     6  0.0000      0.992 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78536     1  0.0000      0.975 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0000      0.975 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78547     1  0.1501      0.952 0.924 0.000 0.000 0.000 0.076 0.000
#> GSM78552     3  0.5109      0.455 0.316 0.000 0.580 0.000 0.104 0.000
#> GSM78556     1  0.1501      0.952 0.924 0.000 0.000 0.000 0.076 0.000
#> GSM78559     1  0.0000      0.975 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78564     1  0.1387      0.953 0.932 0.000 0.000 0.000 0.068 0.000
#> GSM42999     2  0.2300      0.877 0.000 0.856 0.000 0.000 0.144 0.000
#> GSM43001     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43003     2  0.2048      0.898 0.000 0.880 0.000 0.000 0.120 0.000
#> GSM43006     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43009     2  0.2378      0.867 0.000 0.848 0.000 0.000 0.152 0.000
#> GSM43012     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78524     5  0.2969      0.983 0.000 0.224 0.000 0.000 0.776 0.000
#> GSM78527     2  0.2048      0.898 0.000 0.880 0.000 0.000 0.120 0.000
#> GSM78530     5  0.2941      0.992 0.000 0.220 0.000 0.000 0.780 0.000
#> GSM78535     5  0.3253      0.955 0.020 0.192 0.000 0.000 0.788 0.000
#> GSM78538     5  0.2941      0.992 0.000 0.220 0.000 0.000 0.780 0.000
#> GSM78542     5  0.2941      0.992 0.000 0.220 0.000 0.000 0.780 0.000
#> GSM78544     5  0.2941      0.992 0.000 0.220 0.000 0.000 0.780 0.000
#> GSM78549     2  0.2048      0.898 0.000 0.880 0.000 0.000 0.120 0.000
#> GSM78553     5  0.2941      0.992 0.000 0.220 0.000 0.000 0.780 0.000
#> GSM78558     5  0.2941      0.992 0.000 0.220 0.000 0.000 0.780 0.000
#> GSM78561     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-skmeans-collect-classes

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

test_to_known_factors(res)
#>             n cell.type(p) agent(p) individual(p) k
#> SD:skmeans 58     2.54e-13  0.00184        0.9999 2
#> SD:skmeans 57     1.37e-14  0.00234        0.2223 3
#> SD:skmeans 58     1.13e-22  0.00789        0.3966 4
#> SD:skmeans 56     1.48e-20  0.01345        0.0835 5
#> SD:skmeans 57     8.31e-20  0.03200        0.0855 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 58 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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.4222 0.578   0.578
#> 3 3 0.750           0.815       0.845         0.4671 0.780   0.619
#> 4 4 0.888           0.913       0.959         0.2013 0.891   0.696
#> 5 5 0.857           0.899       0.938         0.0551 0.960   0.840
#> 6 6 0.933           0.907       0.960         0.0533 0.948   0.760

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette p1 p2
#> GSM78539     1       0          1  1  0
#> GSM78545     1       0          1  1  0
#> GSM78550     1       0          1  1  0
#> GSM78554     1       0          1  1  0
#> GSM78562     1       0          1  1  0
#> GSM78540     1       0          1  1  0
#> GSM78546     1       0          1  1  0
#> GSM78551     1       0          1  1  0
#> GSM78555     1       0          1  1  0
#> GSM78563     1       0          1  1  0
#> GSM43005     1       0          1  1  0
#> GSM43008     1       0          1  1  0
#> GSM43011     1       0          1  1  0
#> GSM78523     1       0          1  1  0
#> GSM78526     1       0          1  1  0
#> GSM78529     1       0          1  1  0
#> GSM78532     1       0          1  1  0
#> GSM78534     1       0          1  1  0
#> GSM78537     1       0          1  1  0
#> GSM78543     1       0          1  1  0
#> GSM78548     1       0          1  1  0
#> GSM78557     1       0          1  1  0
#> GSM78560     1       0          1  1  0
#> GSM78565     1       0          1  1  0
#> GSM43000     1       0          1  1  0
#> GSM43002     1       0          1  1  0
#> GSM43004     1       0          1  1  0
#> GSM43007     1       0          1  1  0
#> GSM43010     1       0          1  1  0
#> GSM78522     1       0          1  1  0
#> GSM78525     1       0          1  1  0
#> GSM78528     1       0          1  1  0
#> GSM78531     1       0          1  1  0
#> GSM78533     1       0          1  1  0
#> GSM78536     1       0          1  1  0
#> GSM78541     1       0          1  1  0
#> GSM78547     1       0          1  1  0
#> GSM78552     1       0          1  1  0
#> GSM78556     1       0          1  1  0
#> GSM78559     1       0          1  1  0
#> GSM78564     1       0          1  1  0
#> GSM42999     2       0          1  0  1
#> GSM43001     2       0          1  0  1
#> GSM43003     2       0          1  0  1
#> GSM43006     2       0          1  0  1
#> GSM43009     2       0          1  0  1
#> GSM43012     2       0          1  0  1
#> GSM78524     2       0          1  0  1
#> GSM78527     2       0          1  0  1
#> GSM78530     2       0          1  0  1
#> GSM78535     2       0          1  0  1
#> GSM78538     2       0          1  0  1
#> GSM78542     2       0          1  0  1
#> GSM78544     2       0          1  0  1
#> GSM78549     2       0          1  0  1
#> GSM78553     2       0          1  0  1
#> GSM78558     2       0          1  0  1
#> GSM78561     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1 p2    p3
#> GSM78539     1  0.0000      0.553 1.000  0 0.000
#> GSM78545     1  0.0000      0.553 1.000  0 0.000
#> GSM78550     1  0.0000      0.553 1.000  0 0.000
#> GSM78554     1  0.6225      0.698 0.568  0 0.432
#> GSM78562     1  0.0237      0.554 0.996  0 0.004
#> GSM78540     1  0.0000      0.553 1.000  0 0.000
#> GSM78546     1  0.0000      0.553 1.000  0 0.000
#> GSM78551     1  0.0000      0.553 1.000  0 0.000
#> GSM78555     1  0.0000      0.553 1.000  0 0.000
#> GSM78563     1  0.0000      0.553 1.000  0 0.000
#> GSM43005     3  0.0000      0.964 0.000  0 1.000
#> GSM43008     1  0.6267      0.707 0.548  0 0.452
#> GSM43011     3  0.0000      0.964 0.000  0 1.000
#> GSM78523     3  0.0000      0.964 0.000  0 1.000
#> GSM78526     3  0.0000      0.964 0.000  0 1.000
#> GSM78529     3  0.0000      0.964 0.000  0 1.000
#> GSM78532     1  0.6267      0.707 0.548  0 0.452
#> GSM78534     3  0.5098      0.351 0.248  0 0.752
#> GSM78537     1  0.6267      0.707 0.548  0 0.452
#> GSM78543     1  0.6267      0.707 0.548  0 0.452
#> GSM78548     1  0.6267      0.707 0.548  0 0.452
#> GSM78557     1  0.6267      0.707 0.548  0 0.452
#> GSM78560     1  0.6267      0.707 0.548  0 0.452
#> GSM78565     1  0.6267      0.707 0.548  0 0.452
#> GSM43000     3  0.0000      0.964 0.000  0 1.000
#> GSM43002     3  0.0237      0.960 0.004  0 0.996
#> GSM43004     1  0.6291      0.680 0.532  0 0.468
#> GSM43007     1  0.6295      0.672 0.528  0 0.472
#> GSM43010     3  0.0000      0.964 0.000  0 1.000
#> GSM78522     3  0.0000      0.964 0.000  0 1.000
#> GSM78525     3  0.0000      0.964 0.000  0 1.000
#> GSM78528     3  0.0237      0.960 0.004  0 0.996
#> GSM78531     1  0.6267      0.707 0.548  0 0.452
#> GSM78533     3  0.0000      0.964 0.000  0 1.000
#> GSM78536     1  0.6267      0.707 0.548  0 0.452
#> GSM78541     1  0.6267      0.707 0.548  0 0.452
#> GSM78547     1  0.6267      0.707 0.548  0 0.452
#> GSM78552     1  0.6267      0.707 0.548  0 0.452
#> GSM78556     1  0.6267      0.707 0.548  0 0.452
#> GSM78559     1  0.6267      0.707 0.548  0 0.452
#> GSM78564     1  0.6267      0.707 0.548  0 0.452
#> GSM42999     2  0.0000      1.000 0.000  1 0.000
#> GSM43001     2  0.0000      1.000 0.000  1 0.000
#> GSM43003     2  0.0000      1.000 0.000  1 0.000
#> GSM43006     2  0.0000      1.000 0.000  1 0.000
#> GSM43009     2  0.0000      1.000 0.000  1 0.000
#> GSM43012     2  0.0000      1.000 0.000  1 0.000
#> GSM78524     2  0.0000      1.000 0.000  1 0.000
#> GSM78527     2  0.0000      1.000 0.000  1 0.000
#> GSM78530     2  0.0000      1.000 0.000  1 0.000
#> GSM78535     2  0.0000      1.000 0.000  1 0.000
#> GSM78538     2  0.0000      1.000 0.000  1 0.000
#> GSM78542     2  0.0000      1.000 0.000  1 0.000
#> GSM78544     2  0.0000      1.000 0.000  1 0.000
#> GSM78549     2  0.0000      1.000 0.000  1 0.000
#> GSM78553     2  0.0000      1.000 0.000  1 0.000
#> GSM78558     2  0.0000      1.000 0.000  1 0.000
#> GSM78561     2  0.0000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1 p2    p3    p4
#> GSM78539     4  0.0000      0.946 0.000  0 0.000 1.000
#> GSM78545     4  0.0000      0.946 0.000  0 0.000 1.000
#> GSM78550     4  0.0336      0.941 0.008  0 0.000 0.992
#> GSM78554     4  0.4477      0.540 0.312  0 0.000 0.688
#> GSM78562     4  0.2081      0.871 0.084  0 0.000 0.916
#> GSM78540     4  0.0000      0.946 0.000  0 0.000 1.000
#> GSM78546     4  0.0000      0.946 0.000  0 0.000 1.000
#> GSM78551     4  0.0000      0.946 0.000  0 0.000 1.000
#> GSM78555     4  0.0000      0.946 0.000  0 0.000 1.000
#> GSM78563     4  0.0000      0.946 0.000  0 0.000 1.000
#> GSM43005     3  0.3528      0.806 0.192  0 0.808 0.000
#> GSM43008     1  0.3311      0.774 0.828  0 0.172 0.000
#> GSM43011     3  0.0000      0.879 0.000  0 1.000 0.000
#> GSM78523     3  0.0000      0.879 0.000  0 1.000 0.000
#> GSM78526     3  0.0000      0.879 0.000  0 1.000 0.000
#> GSM78529     3  0.3610      0.799 0.200  0 0.800 0.000
#> GSM78532     1  0.0000      0.946 1.000  0 0.000 0.000
#> GSM78534     3  0.4164      0.608 0.264  0 0.736 0.000
#> GSM78537     1  0.0000      0.946 1.000  0 0.000 0.000
#> GSM78543     1  0.0000      0.946 1.000  0 0.000 0.000
#> GSM78548     1  0.3486      0.752 0.812  0 0.188 0.000
#> GSM78557     1  0.0000      0.946 1.000  0 0.000 0.000
#> GSM78560     1  0.0000      0.946 1.000  0 0.000 0.000
#> GSM78565     1  0.0000      0.946 1.000  0 0.000 0.000
#> GSM43000     3  0.1022      0.878 0.032  0 0.968 0.000
#> GSM43002     3  0.3649      0.796 0.204  0 0.796 0.000
#> GSM43004     1  0.3726      0.706 0.788  0 0.212 0.000
#> GSM43007     1  0.3649      0.728 0.796  0 0.204 0.000
#> GSM43010     3  0.0000      0.879 0.000  0 1.000 0.000
#> GSM78522     3  0.0000      0.879 0.000  0 1.000 0.000
#> GSM78525     3  0.1792      0.871 0.068  0 0.932 0.000
#> GSM78528     3  0.3801      0.776 0.220  0 0.780 0.000
#> GSM78531     1  0.0000      0.946 1.000  0 0.000 0.000
#> GSM78533     3  0.0000      0.879 0.000  0 1.000 0.000
#> GSM78536     1  0.0000      0.946 1.000  0 0.000 0.000
#> GSM78541     1  0.0000      0.946 1.000  0 0.000 0.000
#> GSM78547     1  0.0000      0.946 1.000  0 0.000 0.000
#> GSM78552     1  0.0000      0.946 1.000  0 0.000 0.000
#> GSM78556     1  0.0000      0.946 1.000  0 0.000 0.000
#> GSM78559     1  0.0000      0.946 1.000  0 0.000 0.000
#> GSM78564     1  0.0000      0.946 1.000  0 0.000 0.000
#> GSM42999     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43001     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43003     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43006     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43009     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43012     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78524     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78527     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78530     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78535     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78538     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78542     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78544     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78549     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78553     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78558     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78561     2  0.0000      1.000 0.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4  0.0000      0.946 0.000 0.000 0.000 1.000 0.000
#> GSM78545     4  0.0000      0.946 0.000 0.000 0.000 1.000 0.000
#> GSM78550     4  0.0290      0.940 0.008 0.000 0.000 0.992 0.000
#> GSM78554     4  0.3837      0.555 0.308 0.000 0.000 0.692 0.000
#> GSM78562     4  0.1197      0.900 0.048 0.000 0.000 0.952 0.000
#> GSM78540     4  0.0000      0.946 0.000 0.000 0.000 1.000 0.000
#> GSM78546     4  0.0000      0.946 0.000 0.000 0.000 1.000 0.000
#> GSM78551     4  0.0000      0.946 0.000 0.000 0.000 1.000 0.000
#> GSM78555     4  0.0000      0.946 0.000 0.000 0.000 1.000 0.000
#> GSM78563     4  0.0000      0.946 0.000 0.000 0.000 1.000 0.000
#> GSM43005     3  0.4255      0.815 0.128 0.000 0.776 0.000 0.096
#> GSM43008     1  0.4509      0.700 0.752 0.000 0.152 0.000 0.096
#> GSM43011     3  0.0000      0.871 0.000 0.000 1.000 0.000 0.000
#> GSM78523     3  0.0000      0.871 0.000 0.000 1.000 0.000 0.000
#> GSM78526     3  0.0000      0.871 0.000 0.000 1.000 0.000 0.000
#> GSM78529     3  0.4300      0.812 0.132 0.000 0.772 0.000 0.096
#> GSM78532     1  0.0000      0.940 1.000 0.000 0.000 0.000 0.000
#> GSM78534     3  0.3586      0.589 0.264 0.000 0.736 0.000 0.000
#> GSM78537     1  0.0000      0.940 1.000 0.000 0.000 0.000 0.000
#> GSM78543     1  0.0000      0.940 1.000 0.000 0.000 0.000 0.000
#> GSM78548     1  0.3359      0.763 0.816 0.000 0.164 0.000 0.020
#> GSM78557     1  0.0000      0.940 1.000 0.000 0.000 0.000 0.000
#> GSM78560     1  0.0000      0.940 1.000 0.000 0.000 0.000 0.000
#> GSM78565     1  0.0000      0.940 1.000 0.000 0.000 0.000 0.000
#> GSM43000     3  0.1800      0.867 0.020 0.000 0.932 0.000 0.048
#> GSM43002     3  0.4386      0.807 0.140 0.000 0.764 0.000 0.096
#> GSM43004     1  0.3551      0.705 0.772 0.000 0.220 0.000 0.008
#> GSM43007     1  0.4768      0.653 0.724 0.000 0.180 0.000 0.096
#> GSM43010     3  0.0000      0.871 0.000 0.000 1.000 0.000 0.000
#> GSM78522     3  0.0000      0.871 0.000 0.000 1.000 0.000 0.000
#> GSM78525     3  0.2520      0.861 0.048 0.000 0.896 0.000 0.056
#> GSM78528     3  0.4469      0.799 0.148 0.000 0.756 0.000 0.096
#> GSM78531     1  0.0000      0.940 1.000 0.000 0.000 0.000 0.000
#> GSM78533     3  0.0000      0.871 0.000 0.000 1.000 0.000 0.000
#> GSM78536     1  0.0000      0.940 1.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0000      0.940 1.000 0.000 0.000 0.000 0.000
#> GSM78547     1  0.0000      0.940 1.000 0.000 0.000 0.000 0.000
#> GSM78552     1  0.0000      0.940 1.000 0.000 0.000 0.000 0.000
#> GSM78556     1  0.0000      0.940 1.000 0.000 0.000 0.000 0.000
#> GSM78559     1  0.0000      0.940 1.000 0.000 0.000 0.000 0.000
#> GSM78564     1  0.0000      0.940 1.000 0.000 0.000 0.000 0.000
#> GSM42999     2  0.0609      0.983 0.000 0.980 0.000 0.000 0.020
#> GSM43001     5  0.1965      0.948 0.000 0.096 0.000 0.000 0.904
#> GSM43003     5  0.3508      0.830 0.000 0.252 0.000 0.000 0.748
#> GSM43006     5  0.1965      0.948 0.000 0.096 0.000 0.000 0.904
#> GSM43009     2  0.0703      0.980 0.000 0.976 0.000 0.000 0.024
#> GSM43012     5  0.1965      0.948 0.000 0.096 0.000 0.000 0.904
#> GSM78524     2  0.0609      0.983 0.000 0.980 0.000 0.000 0.020
#> GSM78527     5  0.3003      0.900 0.000 0.188 0.000 0.000 0.812
#> GSM78530     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000
#> GSM78535     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000
#> GSM78538     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000
#> GSM78542     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000
#> GSM78544     2  0.0609      0.983 0.000 0.980 0.000 0.000 0.020
#> GSM78549     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000
#> GSM78553     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000
#> GSM78558     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000
#> GSM78561     5  0.1965      0.948 0.000 0.096 0.000 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
#> GSM78539     4  0.0000      0.952 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78545     4  0.0000      0.952 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78550     4  0.0146      0.950 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM78554     4  0.3390      0.582 0.296 0.000 0.000 0.704 0.000 0.000
#> GSM78562     4  0.0790      0.924 0.032 0.000 0.000 0.968 0.000 0.000
#> GSM78540     4  0.0000      0.952 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78546     4  0.0000      0.952 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78551     4  0.0000      0.952 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78555     4  0.0000      0.952 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78563     4  0.0000      0.952 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM43005     3  0.0000      0.879 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM43008     3  0.1814      0.821 0.100 0.000 0.900 0.000 0.000 0.000
#> GSM43011     6  0.1814      0.903 0.000 0.000 0.100 0.000 0.000 0.900
#> GSM78523     6  0.1814      0.903 0.000 0.000 0.100 0.000 0.000 0.900
#> GSM78526     6  0.0000      0.964 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78529     3  0.0000      0.879 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM78532     1  0.0000      0.960 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78534     6  0.0000      0.964 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78537     1  0.0000      0.960 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78543     1  0.0000      0.960 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78548     1  0.1387      0.895 0.932 0.000 0.068 0.000 0.000 0.000
#> GSM78557     1  0.0000      0.960 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78560     1  0.0000      0.960 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78565     1  0.0000      0.960 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM43000     3  0.3706      0.360 0.000 0.000 0.620 0.000 0.000 0.380
#> GSM43002     3  0.0000      0.879 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM43004     1  0.5885      0.100 0.476 0.000 0.248 0.000 0.000 0.276
#> GSM43007     3  0.1814      0.821 0.100 0.000 0.900 0.000 0.000 0.000
#> GSM43010     6  0.0000      0.964 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78522     6  0.0000      0.964 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78525     3  0.2257      0.801 0.008 0.000 0.876 0.000 0.000 0.116
#> GSM78528     3  0.0000      0.879 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM78531     1  0.0000      0.960 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78533     6  0.0000      0.964 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78536     1  0.0000      0.960 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0000      0.960 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78547     1  0.0000      0.960 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78552     1  0.0000      0.960 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78556     1  0.0000      0.960 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78559     1  0.0000      0.960 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78564     1  0.0000      0.960 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM42999     2  0.0790      0.974 0.000 0.968 0.000 0.000 0.032 0.000
#> GSM43001     5  0.0000      0.917 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM43003     5  0.2996      0.763 0.000 0.228 0.000 0.000 0.772 0.000
#> GSM43006     5  0.0000      0.917 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM43009     2  0.0865      0.972 0.000 0.964 0.000 0.000 0.036 0.000
#> GSM43012     5  0.0000      0.917 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM78524     2  0.0790      0.974 0.000 0.968 0.000 0.000 0.032 0.000
#> GSM78527     5  0.2340      0.848 0.000 0.148 0.000 0.000 0.852 0.000
#> GSM78530     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78535     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78538     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78542     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78544     2  0.0790      0.974 0.000 0.968 0.000 0.000 0.032 0.000
#> GSM78549     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78553     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78558     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78561     5  0.0000      0.917 0.000 0.000 0.000 0.000 1.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 cell.type(p) agent(p) individual(p) k
#> SD:pam 58     2.54e-13  0.00184         1.000 2
#> SD:pam 57     2.40e-13  0.00357         0.239 3
#> SD:pam 58     1.13e-22  0.00808         0.343 4
#> SD:pam 58     2.22e-21  0.01885         0.293 5
#> SD:pam 56     2.11e-19  0.02434         0.038 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 58 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4222 0.578   0.578
#> 3 3 0.712           0.819       0.903         0.4871 0.789   0.636
#> 4 4 0.720           0.768       0.860         0.1660 0.843   0.594
#> 5 5 0.880           0.863       0.904         0.0807 0.909   0.667
#> 6 6 0.831           0.793       0.887         0.0456 0.964   0.824

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
#> GSM78539     1       0          1  1  0
#> GSM78545     1       0          1  1  0
#> GSM78550     1       0          1  1  0
#> GSM78554     1       0          1  1  0
#> GSM78562     1       0          1  1  0
#> GSM78540     1       0          1  1  0
#> GSM78546     1       0          1  1  0
#> GSM78551     1       0          1  1  0
#> GSM78555     1       0          1  1  0
#> GSM78563     1       0          1  1  0
#> GSM43005     1       0          1  1  0
#> GSM43008     1       0          1  1  0
#> GSM43011     1       0          1  1  0
#> GSM78523     1       0          1  1  0
#> GSM78526     1       0          1  1  0
#> GSM78529     1       0          1  1  0
#> GSM78532     1       0          1  1  0
#> GSM78534     1       0          1  1  0
#> GSM78537     1       0          1  1  0
#> GSM78543     1       0          1  1  0
#> GSM78548     1       0          1  1  0
#> GSM78557     1       0          1  1  0
#> GSM78560     1       0          1  1  0
#> GSM78565     1       0          1  1  0
#> GSM43000     1       0          1  1  0
#> GSM43002     1       0          1  1  0
#> GSM43004     1       0          1  1  0
#> GSM43007     1       0          1  1  0
#> GSM43010     1       0          1  1  0
#> GSM78522     1       0          1  1  0
#> GSM78525     1       0          1  1  0
#> GSM78528     1       0          1  1  0
#> GSM78531     1       0          1  1  0
#> GSM78533     1       0          1  1  0
#> GSM78536     1       0          1  1  0
#> GSM78541     1       0          1  1  0
#> GSM78547     1       0          1  1  0
#> GSM78552     1       0          1  1  0
#> GSM78556     1       0          1  1  0
#> GSM78559     1       0          1  1  0
#> GSM78564     1       0          1  1  0
#> GSM42999     2       0          1  0  1
#> GSM43001     2       0          1  0  1
#> GSM43003     2       0          1  0  1
#> GSM43006     2       0          1  0  1
#> GSM43009     2       0          1  0  1
#> GSM43012     2       0          1  0  1
#> GSM78524     2       0          1  0  1
#> GSM78527     2       0          1  0  1
#> GSM78530     2       0          1  0  1
#> GSM78535     2       0          1  0  1
#> GSM78538     2       0          1  0  1
#> GSM78542     2       0          1  0  1
#> GSM78544     2       0          1  0  1
#> GSM78549     2       0          1  0  1
#> GSM78553     2       0          1  0  1
#> GSM78558     2       0          1  0  1
#> GSM78561     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1 p2    p3
#> GSM78539     1   0.000      0.857 1.000  0 0.000
#> GSM78545     1   0.164      0.836 0.956  0 0.044
#> GSM78550     1   0.164      0.836 0.956  0 0.044
#> GSM78554     1   0.510      0.566 0.752  0 0.248
#> GSM78562     1   0.000      0.857 1.000  0 0.000
#> GSM78540     1   0.000      0.857 1.000  0 0.000
#> GSM78546     1   0.000      0.857 1.000  0 0.000
#> GSM78551     1   0.000      0.857 1.000  0 0.000
#> GSM78555     1   0.000      0.857 1.000  0 0.000
#> GSM78563     1   0.000      0.857 1.000  0 0.000
#> GSM43005     3   0.579      0.672 0.332  0 0.668
#> GSM43008     3   0.550      0.706 0.292  0 0.708
#> GSM43011     3   0.581      0.669 0.336  0 0.664
#> GSM78523     3   0.573      0.685 0.324  0 0.676
#> GSM78526     3   0.394      0.806 0.156  0 0.844
#> GSM78529     1   0.599      0.245 0.632  0 0.368
#> GSM78532     3   0.000      0.809 0.000  0 1.000
#> GSM78534     3   0.394      0.806 0.156  0 0.844
#> GSM78537     3   0.000      0.809 0.000  0 1.000
#> GSM78543     3   0.000      0.809 0.000  0 1.000
#> GSM78548     3   0.553      0.703 0.296  0 0.704
#> GSM78557     3   0.000      0.809 0.000  0 1.000
#> GSM78560     3   0.312      0.812 0.108  0 0.892
#> GSM78565     3   0.000      0.809 0.000  0 1.000
#> GSM43000     3   0.583      0.663 0.340  0 0.660
#> GSM43002     3   0.543      0.718 0.284  0 0.716
#> GSM43004     3   0.394      0.806 0.156  0 0.844
#> GSM43007     3   0.571      0.685 0.320  0 0.680
#> GSM43010     3   0.394      0.806 0.156  0 0.844
#> GSM78522     3   0.394      0.806 0.156  0 0.844
#> GSM78525     3   0.583      0.663 0.340  0 0.660
#> GSM78528     1   0.630     -0.197 0.528  0 0.472
#> GSM78531     3   0.000      0.809 0.000  0 1.000
#> GSM78533     3   0.394      0.806 0.156  0 0.844
#> GSM78536     3   0.000      0.809 0.000  0 1.000
#> GSM78541     3   0.000      0.809 0.000  0 1.000
#> GSM78547     3   0.000      0.809 0.000  0 1.000
#> GSM78552     3   0.559      0.698 0.304  0 0.696
#> GSM78556     3   0.000      0.809 0.000  0 1.000
#> GSM78559     3   0.000      0.809 0.000  0 1.000
#> GSM78564     3   0.000      0.809 0.000  0 1.000
#> GSM42999     2   0.000      1.000 0.000  1 0.000
#> GSM43001     2   0.000      1.000 0.000  1 0.000
#> GSM43003     2   0.000      1.000 0.000  1 0.000
#> GSM43006     2   0.000      1.000 0.000  1 0.000
#> GSM43009     2   0.000      1.000 0.000  1 0.000
#> GSM43012     2   0.000      1.000 0.000  1 0.000
#> GSM78524     2   0.000      1.000 0.000  1 0.000
#> GSM78527     2   0.000      1.000 0.000  1 0.000
#> GSM78530     2   0.000      1.000 0.000  1 0.000
#> GSM78535     2   0.000      1.000 0.000  1 0.000
#> GSM78538     2   0.000      1.000 0.000  1 0.000
#> GSM78542     2   0.000      1.000 0.000  1 0.000
#> GSM78544     2   0.000      1.000 0.000  1 0.000
#> GSM78549     2   0.000      1.000 0.000  1 0.000
#> GSM78553     2   0.000      1.000 0.000  1 0.000
#> GSM78558     2   0.000      1.000 0.000  1 0.000
#> GSM78561     2   0.000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1 p2    p3    p4
#> GSM78539     4  0.0000     0.8882 0.000  0 0.000 1.000
#> GSM78545     4  0.4564     0.5135 0.000  0 0.328 0.672
#> GSM78550     4  0.3610     0.7152 0.000  0 0.200 0.800
#> GSM78554     4  0.4431     0.5746 0.000  0 0.304 0.696
#> GSM78562     4  0.0000     0.8882 0.000  0 0.000 1.000
#> GSM78540     4  0.0000     0.8882 0.000  0 0.000 1.000
#> GSM78546     4  0.0000     0.8882 0.000  0 0.000 1.000
#> GSM78551     4  0.0000     0.8882 0.000  0 0.000 1.000
#> GSM78555     4  0.0000     0.8882 0.000  0 0.000 1.000
#> GSM78563     4  0.0000     0.8882 0.000  0 0.000 1.000
#> GSM43005     3  0.0707     0.7769 0.020  0 0.980 0.000
#> GSM43008     3  0.2408     0.7326 0.104  0 0.896 0.000
#> GSM43011     3  0.0000     0.7719 0.000  0 1.000 0.000
#> GSM78523     3  0.1389     0.7425 0.048  0 0.952 0.000
#> GSM78526     3  0.4304     0.5245 0.284  0 0.716 0.000
#> GSM78529     3  0.3907     0.5720 0.000  0 0.768 0.232
#> GSM78532     1  0.4605     0.5969 0.664  0 0.336 0.000
#> GSM78534     1  0.4888     0.3406 0.588  0 0.412 0.000
#> GSM78537     1  0.3942     0.7285 0.764  0 0.236 0.000
#> GSM78543     1  0.2216     0.7424 0.908  0 0.092 0.000
#> GSM78548     3  0.0921     0.7763 0.028  0 0.972 0.000
#> GSM78557     3  0.4193     0.5126 0.268  0 0.732 0.000
#> GSM78560     1  0.4134     0.7099 0.740  0 0.260 0.000
#> GSM78565     1  0.2216     0.7424 0.908  0 0.092 0.000
#> GSM43000     3  0.0188     0.7705 0.004  0 0.996 0.000
#> GSM43002     3  0.0817     0.7769 0.024  0 0.976 0.000
#> GSM43004     1  0.4830     0.3789 0.608  0 0.392 0.000
#> GSM43007     3  0.1022     0.7751 0.032  0 0.968 0.000
#> GSM43010     3  0.4817     0.2751 0.388  0 0.612 0.000
#> GSM78522     1  0.4888     0.3406 0.588  0 0.412 0.000
#> GSM78525     3  0.0469     0.7757 0.012  0 0.988 0.000
#> GSM78528     3  0.3172     0.6570 0.000  0 0.840 0.160
#> GSM78531     1  0.3801     0.7353 0.780  0 0.220 0.000
#> GSM78533     3  0.4250     0.5319 0.276  0 0.724 0.000
#> GSM78536     1  0.2216     0.7424 0.908  0 0.092 0.000
#> GSM78541     1  0.2216     0.7424 0.908  0 0.092 0.000
#> GSM78547     3  0.4948     0.0684 0.440  0 0.560 0.000
#> GSM78552     3  0.2704     0.7149 0.124  0 0.876 0.000
#> GSM78556     3  0.4277     0.4955 0.280  0 0.720 0.000
#> GSM78559     1  0.2216     0.7424 0.908  0 0.092 0.000
#> GSM78564     1  0.4072     0.7165 0.748  0 0.252 0.000
#> GSM42999     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM43001     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM43003     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM43006     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM43009     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM43012     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM78524     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM78527     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM78530     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM78535     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM78538     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM78542     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM78544     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM78549     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM78553     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM78558     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM78561     2  0.0000     1.0000 0.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4  0.0000      0.989 0.000 0.000 0.000 1.000 0.000
#> GSM78545     4  0.0000      0.989 0.000 0.000 0.000 1.000 0.000
#> GSM78550     4  0.0000      0.989 0.000 0.000 0.000 1.000 0.000
#> GSM78554     4  0.1300      0.957 0.028 0.000 0.016 0.956 0.000
#> GSM78562     4  0.0865      0.971 0.024 0.000 0.004 0.972 0.000
#> GSM78540     4  0.0000      0.989 0.000 0.000 0.000 1.000 0.000
#> GSM78546     4  0.0000      0.989 0.000 0.000 0.000 1.000 0.000
#> GSM78551     4  0.0000      0.989 0.000 0.000 0.000 1.000 0.000
#> GSM78555     4  0.0510      0.979 0.016 0.000 0.000 0.984 0.000
#> GSM78563     4  0.0000      0.989 0.000 0.000 0.000 1.000 0.000
#> GSM43005     3  0.2653      0.846 0.096 0.000 0.880 0.000 0.024
#> GSM43008     3  0.2516      0.805 0.140 0.000 0.860 0.000 0.000
#> GSM43011     3  0.1121      0.816 0.000 0.000 0.956 0.000 0.044
#> GSM78523     3  0.3534      0.523 0.000 0.000 0.744 0.000 0.256
#> GSM78526     5  0.3074      0.976 0.000 0.000 0.196 0.000 0.804
#> GSM78529     3  0.2153      0.808 0.000 0.000 0.916 0.044 0.040
#> GSM78532     1  0.1341      0.831 0.944 0.000 0.056 0.000 0.000
#> GSM78534     5  0.3196      0.976 0.004 0.000 0.192 0.000 0.804
#> GSM78537     1  0.0671      0.836 0.980 0.000 0.016 0.000 0.004
#> GSM78543     1  0.0880      0.834 0.968 0.000 0.000 0.000 0.032
#> GSM78548     3  0.2020      0.839 0.100 0.000 0.900 0.000 0.000
#> GSM78557     1  0.4268      0.250 0.556 0.000 0.444 0.000 0.000
#> GSM78560     1  0.1478      0.828 0.936 0.000 0.064 0.000 0.000
#> GSM78565     1  0.0880      0.834 0.968 0.000 0.000 0.000 0.032
#> GSM43000     3  0.1121      0.816 0.000 0.000 0.956 0.000 0.044
#> GSM43002     3  0.1965      0.841 0.096 0.000 0.904 0.000 0.000
#> GSM43004     5  0.3906      0.898 0.068 0.000 0.132 0.000 0.800
#> GSM43007     3  0.2179      0.830 0.112 0.000 0.888 0.000 0.000
#> GSM43010     5  0.3074      0.976 0.000 0.000 0.196 0.000 0.804
#> GSM78522     5  0.3196      0.976 0.004 0.000 0.192 0.000 0.804
#> GSM78525     3  0.1469      0.830 0.016 0.000 0.948 0.000 0.036
#> GSM78528     3  0.2153      0.808 0.000 0.000 0.916 0.044 0.040
#> GSM78531     1  0.1270      0.833 0.948 0.000 0.052 0.000 0.000
#> GSM78533     5  0.3074      0.976 0.000 0.000 0.196 0.000 0.804
#> GSM78536     1  0.0880      0.834 0.968 0.000 0.000 0.000 0.032
#> GSM78541     1  0.0880      0.834 0.968 0.000 0.000 0.000 0.032
#> GSM78547     1  0.4268      0.250 0.556 0.000 0.444 0.000 0.000
#> GSM78552     3  0.3612      0.607 0.268 0.000 0.732 0.000 0.000
#> GSM78556     1  0.4268      0.250 0.556 0.000 0.444 0.000 0.000
#> GSM78559     1  0.0880      0.834 0.968 0.000 0.000 0.000 0.032
#> GSM78564     1  0.1270      0.833 0.948 0.000 0.052 0.000 0.000
#> GSM42999     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000
#> GSM43001     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000
#> GSM43003     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000
#> GSM43006     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000
#> GSM43009     2  0.0162      0.958 0.000 0.996 0.000 0.000 0.004
#> GSM43012     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000
#> GSM78524     2  0.1544      0.937 0.000 0.932 0.000 0.000 0.068
#> GSM78527     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000
#> GSM78530     2  0.2773      0.891 0.000 0.836 0.000 0.000 0.164
#> GSM78535     2  0.2773      0.891 0.000 0.836 0.000 0.000 0.164
#> GSM78538     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000
#> GSM78542     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000
#> GSM78544     2  0.1544      0.937 0.000 0.932 0.000 0.000 0.068
#> GSM78549     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000
#> GSM78553     2  0.2773      0.891 0.000 0.836 0.000 0.000 0.164
#> GSM78558     2  0.2773      0.891 0.000 0.836 0.000 0.000 0.164
#> GSM78561     2  0.0162      0.958 0.000 0.996 0.000 0.000 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
#> GSM78539     4  0.0000    0.97752 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78545     4  0.0000    0.97752 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78550     4  0.0146    0.97571 0.000 0.000 0.004 0.996 0.000 0.000
#> GSM78554     4  0.2320    0.84116 0.000 0.000 0.132 0.864 0.000 0.004
#> GSM78562     4  0.1010    0.94917 0.000 0.000 0.036 0.960 0.000 0.004
#> GSM78540     4  0.0000    0.97752 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78546     4  0.0000    0.97752 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78551     4  0.0000    0.97752 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78555     4  0.0146    0.97596 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM78563     4  0.0000    0.97752 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM43005     3  0.1492    0.82138 0.036 0.000 0.940 0.000 0.000 0.024
#> GSM43008     3  0.1141    0.81460 0.052 0.000 0.948 0.000 0.000 0.000
#> GSM43011     3  0.2300    0.78642 0.000 0.000 0.856 0.000 0.000 0.144
#> GSM78523     3  0.3647    0.54391 0.000 0.000 0.640 0.000 0.000 0.360
#> GSM78526     6  0.0146    0.98240 0.000 0.000 0.004 0.000 0.000 0.996
#> GSM78529     3  0.2798    0.78929 0.000 0.000 0.852 0.036 0.000 0.112
#> GSM78532     1  0.2003    0.88285 0.884 0.000 0.116 0.000 0.000 0.000
#> GSM78534     6  0.0146    0.98240 0.000 0.000 0.004 0.000 0.000 0.996
#> GSM78537     1  0.0935    0.89100 0.964 0.000 0.032 0.000 0.004 0.000
#> GSM78543     1  0.0146    0.88655 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM78548     3  0.1082    0.81935 0.040 0.000 0.956 0.000 0.000 0.004
#> GSM78557     1  0.3244    0.74481 0.732 0.000 0.268 0.000 0.000 0.000
#> GSM78560     1  0.2340    0.86837 0.852 0.000 0.148 0.000 0.000 0.000
#> GSM78565     1  0.0146    0.88655 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM43000     3  0.3445    0.68974 0.008 0.000 0.732 0.000 0.000 0.260
#> GSM43002     3  0.1196    0.81997 0.040 0.000 0.952 0.000 0.000 0.008
#> GSM43004     6  0.0937    0.94093 0.040 0.000 0.000 0.000 0.000 0.960
#> GSM43007     3  0.0865    0.81639 0.036 0.000 0.964 0.000 0.000 0.000
#> GSM43010     6  0.0146    0.98240 0.000 0.000 0.004 0.000 0.000 0.996
#> GSM78522     6  0.0146    0.98240 0.000 0.000 0.004 0.000 0.000 0.996
#> GSM78525     3  0.2887    0.80838 0.036 0.000 0.844 0.000 0.000 0.120
#> GSM78528     3  0.2798    0.78929 0.000 0.000 0.852 0.036 0.000 0.112
#> GSM78531     1  0.1863    0.88393 0.896 0.000 0.104 0.000 0.000 0.000
#> GSM78533     6  0.0865    0.96063 0.000 0.000 0.036 0.000 0.000 0.964
#> GSM78536     1  0.0146    0.88655 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM78541     1  0.0405    0.88363 0.988 0.000 0.008 0.000 0.004 0.000
#> GSM78547     1  0.3288    0.73861 0.724 0.000 0.276 0.000 0.000 0.000
#> GSM78552     3  0.3804   -0.00803 0.424 0.000 0.576 0.000 0.000 0.000
#> GSM78556     1  0.3266    0.74246 0.728 0.000 0.272 0.000 0.000 0.000
#> GSM78559     1  0.0146    0.88655 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM78564     1  0.1663    0.88844 0.912 0.000 0.088 0.000 0.000 0.000
#> GSM42999     2  0.0000    0.83177 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43001     2  0.0000    0.83177 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43003     2  0.0000    0.83177 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43006     2  0.0000    0.83177 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43009     2  0.1610    0.75389 0.000 0.916 0.000 0.000 0.084 0.000
#> GSM43012     2  0.0260    0.82808 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM78524     5  0.3647    0.30885 0.000 0.360 0.000 0.000 0.640 0.000
#> GSM78527     2  0.0000    0.83177 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78530     5  0.2969    0.77345 0.000 0.224 0.000 0.000 0.776 0.000
#> GSM78535     5  0.0146    0.65148 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM78538     2  0.3737    0.16285 0.000 0.608 0.000 0.000 0.392 0.000
#> GSM78542     2  0.3737    0.16285 0.000 0.608 0.000 0.000 0.392 0.000
#> GSM78544     2  0.3797   -0.00478 0.000 0.580 0.000 0.000 0.420 0.000
#> GSM78549     2  0.0000    0.83177 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78553     5  0.2969    0.77345 0.000 0.224 0.000 0.000 0.776 0.000
#> GSM78558     5  0.2969    0.77345 0.000 0.224 0.000 0.000 0.776 0.000
#> GSM78561     2  0.0363    0.82537 0.000 0.988 0.000 0.000 0.012 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-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 cell.type(p) agent(p) individual(p) k
#> SD:mclust 58     2.54e-13  0.00184         1.000 2
#> SD:mclust 56     2.73e-23  0.00295         0.940 3
#> SD:mclust 52     3.67e-20  0.00382         0.538 4
#> SD:mclust 55     3.81e-20  0.01336         0.186 5
#> SD:mclust 53     3.41e-18  0.06407         0.196 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 58 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 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-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.998       0.999         0.4225 0.578   0.578
#> 3 3 0.886           0.904       0.960         0.5857 0.724   0.534
#> 4 4 0.877           0.873       0.929         0.1190 0.869   0.630
#> 5 5 0.853           0.727       0.867         0.0503 0.936   0.755
#> 6 6 0.873           0.882       0.921         0.0423 0.943   0.741

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
#> GSM78539     1   0.000      0.999 1.00 0.00
#> GSM78545     1   0.000      0.999 1.00 0.00
#> GSM78550     1   0.000      0.999 1.00 0.00
#> GSM78554     1   0.000      0.999 1.00 0.00
#> GSM78562     1   0.000      0.999 1.00 0.00
#> GSM78540     1   0.000      0.999 1.00 0.00
#> GSM78546     1   0.000      0.999 1.00 0.00
#> GSM78551     1   0.000      0.999 1.00 0.00
#> GSM78555     1   0.000      0.999 1.00 0.00
#> GSM78563     1   0.000      0.999 1.00 0.00
#> GSM43005     1   0.000      0.999 1.00 0.00
#> GSM43008     1   0.000      0.999 1.00 0.00
#> GSM43011     1   0.000      0.999 1.00 0.00
#> GSM78523     1   0.000      0.999 1.00 0.00
#> GSM78526     1   0.000      0.999 1.00 0.00
#> GSM78529     1   0.242      0.958 0.96 0.04
#> GSM78532     1   0.000      0.999 1.00 0.00
#> GSM78534     1   0.000      0.999 1.00 0.00
#> GSM78537     1   0.000      0.999 1.00 0.00
#> GSM78543     1   0.000      0.999 1.00 0.00
#> GSM78548     1   0.000      0.999 1.00 0.00
#> GSM78557     1   0.000      0.999 1.00 0.00
#> GSM78560     1   0.000      0.999 1.00 0.00
#> GSM78565     1   0.000      0.999 1.00 0.00
#> GSM43000     1   0.000      0.999 1.00 0.00
#> GSM43002     1   0.000      0.999 1.00 0.00
#> GSM43004     1   0.000      0.999 1.00 0.00
#> GSM43007     1   0.000      0.999 1.00 0.00
#> GSM43010     1   0.000      0.999 1.00 0.00
#> GSM78522     1   0.000      0.999 1.00 0.00
#> GSM78525     1   0.000      0.999 1.00 0.00
#> GSM78528     1   0.000      0.999 1.00 0.00
#> GSM78531     1   0.000      0.999 1.00 0.00
#> GSM78533     1   0.000      0.999 1.00 0.00
#> GSM78536     1   0.000      0.999 1.00 0.00
#> GSM78541     1   0.000      0.999 1.00 0.00
#> GSM78547     1   0.000      0.999 1.00 0.00
#> GSM78552     1   0.000      0.999 1.00 0.00
#> GSM78556     1   0.000      0.999 1.00 0.00
#> GSM78559     1   0.000      0.999 1.00 0.00
#> GSM78564     1   0.000      0.999 1.00 0.00
#> GSM42999     2   0.000      0.999 0.00 1.00
#> GSM43001     2   0.000      0.999 0.00 1.00
#> GSM43003     2   0.000      0.999 0.00 1.00
#> GSM43006     2   0.000      0.999 0.00 1.00
#> GSM43009     2   0.000      0.999 0.00 1.00
#> GSM43012     2   0.000      0.999 0.00 1.00
#> GSM78524     2   0.000      0.999 0.00 1.00
#> GSM78527     2   0.000      0.999 0.00 1.00
#> GSM78530     2   0.000      0.999 0.00 1.00
#> GSM78535     2   0.141      0.980 0.02 0.98
#> GSM78538     2   0.000      0.999 0.00 1.00
#> GSM78542     2   0.000      0.999 0.00 1.00
#> GSM78544     2   0.000      0.999 0.00 1.00
#> GSM78549     2   0.000      0.999 0.00 1.00
#> GSM78553     2   0.000      0.999 0.00 1.00
#> GSM78558     2   0.000      0.999 0.00 1.00
#> GSM78561     2   0.000      0.999 0.00 1.00

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1   p2    p3
#> GSM78539     1  0.0000      0.930 1.000 0.00 0.000
#> GSM78545     1  0.5254      0.618 0.736 0.00 0.264
#> GSM78550     1  0.0592      0.927 0.988 0.00 0.012
#> GSM78554     1  0.0000      0.930 1.000 0.00 0.000
#> GSM78562     1  0.0000      0.930 1.000 0.00 0.000
#> GSM78540     1  0.0000      0.930 1.000 0.00 0.000
#> GSM78546     1  0.0000      0.930 1.000 0.00 0.000
#> GSM78551     1  0.0000      0.930 1.000 0.00 0.000
#> GSM78555     1  0.0000      0.930 1.000 0.00 0.000
#> GSM78563     1  0.0000      0.930 1.000 0.00 0.000
#> GSM43005     3  0.0000      0.947 0.000 0.00 1.000
#> GSM43008     3  0.0237      0.945 0.004 0.00 0.996
#> GSM43011     3  0.0000      0.947 0.000 0.00 1.000
#> GSM78523     3  0.0000      0.947 0.000 0.00 1.000
#> GSM78526     3  0.0000      0.947 0.000 0.00 1.000
#> GSM78529     3  0.0000      0.947 0.000 0.00 1.000
#> GSM78532     1  0.3267      0.865 0.884 0.00 0.116
#> GSM78534     3  0.0000      0.947 0.000 0.00 1.000
#> GSM78537     1  0.0237      0.931 0.996 0.00 0.004
#> GSM78543     1  0.0592      0.929 0.988 0.00 0.012
#> GSM78548     3  0.0237      0.945 0.004 0.00 0.996
#> GSM78557     1  0.0592      0.929 0.988 0.00 0.012
#> GSM78560     1  0.3482      0.854 0.872 0.00 0.128
#> GSM78565     1  0.1031      0.925 0.976 0.00 0.024
#> GSM43000     3  0.0000      0.947 0.000 0.00 1.000
#> GSM43002     3  0.0000      0.947 0.000 0.00 1.000
#> GSM43004     3  0.0000      0.947 0.000 0.00 1.000
#> GSM43007     3  0.0237      0.945 0.004 0.00 0.996
#> GSM43010     3  0.0000      0.947 0.000 0.00 1.000
#> GSM78522     3  0.0000      0.947 0.000 0.00 1.000
#> GSM78525     3  0.0000      0.947 0.000 0.00 1.000
#> GSM78528     3  0.0000      0.947 0.000 0.00 1.000
#> GSM78531     1  0.3340      0.862 0.880 0.00 0.120
#> GSM78533     3  0.0000      0.947 0.000 0.00 1.000
#> GSM78536     1  0.0237      0.931 0.996 0.00 0.004
#> GSM78541     1  0.0237      0.931 0.996 0.00 0.004
#> GSM78547     1  0.2448      0.894 0.924 0.00 0.076
#> GSM78552     3  0.6168      0.253 0.412 0.00 0.588
#> GSM78556     1  0.4555      0.768 0.800 0.00 0.200
#> GSM78559     1  0.1163      0.923 0.972 0.00 0.028
#> GSM78564     3  0.6260      0.112 0.448 0.00 0.552
#> GSM42999     2  0.0000      1.000 0.000 1.00 0.000
#> GSM43001     2  0.0000      1.000 0.000 1.00 0.000
#> GSM43003     2  0.0000      1.000 0.000 1.00 0.000
#> GSM43006     2  0.0000      1.000 0.000 1.00 0.000
#> GSM43009     2  0.0000      1.000 0.000 1.00 0.000
#> GSM43012     2  0.0000      1.000 0.000 1.00 0.000
#> GSM78524     2  0.0000      1.000 0.000 1.00 0.000
#> GSM78527     2  0.0000      1.000 0.000 1.00 0.000
#> GSM78530     2  0.0000      1.000 0.000 1.00 0.000
#> GSM78535     1  0.6244      0.241 0.560 0.44 0.000
#> GSM78538     2  0.0000      1.000 0.000 1.00 0.000
#> GSM78542     2  0.0000      1.000 0.000 1.00 0.000
#> GSM78544     2  0.0000      1.000 0.000 1.00 0.000
#> GSM78549     2  0.0000      1.000 0.000 1.00 0.000
#> GSM78553     2  0.0000      1.000 0.000 1.00 0.000
#> GSM78558     2  0.0000      1.000 0.000 1.00 0.000
#> GSM78561     2  0.0000      1.000 0.000 1.00 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     4  0.2081     0.9677 0.084 0.000 0.000 0.916
#> GSM78545     4  0.0779     0.9272 0.016 0.000 0.004 0.980
#> GSM78550     4  0.1022     0.9432 0.032 0.000 0.000 0.968
#> GSM78554     4  0.2081     0.9677 0.084 0.000 0.000 0.916
#> GSM78562     4  0.2704     0.9404 0.124 0.000 0.000 0.876
#> GSM78540     4  0.2081     0.9677 0.084 0.000 0.000 0.916
#> GSM78546     4  0.1716     0.9636 0.064 0.000 0.000 0.936
#> GSM78551     4  0.1716     0.9636 0.064 0.000 0.000 0.936
#> GSM78555     4  0.2921     0.9248 0.140 0.000 0.000 0.860
#> GSM78563     4  0.2149     0.9659 0.088 0.000 0.000 0.912
#> GSM43005     3  0.2412     0.8378 0.008 0.000 0.908 0.084
#> GSM43008     3  0.4564     0.6009 0.328 0.000 0.672 0.000
#> GSM43011     3  0.0188     0.8772 0.004 0.000 0.996 0.000
#> GSM78523     3  0.0336     0.8787 0.008 0.000 0.992 0.000
#> GSM78526     3  0.0336     0.8787 0.008 0.000 0.992 0.000
#> GSM78529     3  0.3032     0.8121 0.008 0.000 0.868 0.124
#> GSM78532     1  0.0469     0.9370 0.988 0.000 0.012 0.000
#> GSM78534     3  0.0707     0.8766 0.020 0.000 0.980 0.000
#> GSM78537     1  0.0336     0.9367 0.992 0.000 0.000 0.008
#> GSM78543     1  0.0188     0.9400 0.996 0.000 0.004 0.000
#> GSM78548     3  0.5007     0.7702 0.172 0.000 0.760 0.068
#> GSM78557     1  0.0336     0.9367 0.992 0.000 0.000 0.008
#> GSM78560     1  0.0336     0.9393 0.992 0.000 0.008 0.000
#> GSM78565     1  0.0188     0.9400 0.996 0.000 0.004 0.000
#> GSM43000     3  0.0336     0.8787 0.008 0.000 0.992 0.000
#> GSM43002     3  0.2814     0.8290 0.132 0.000 0.868 0.000
#> GSM43004     1  0.5000    -0.0519 0.504 0.000 0.496 0.000
#> GSM43007     3  0.3688     0.7669 0.208 0.000 0.792 0.000
#> GSM43010     3  0.0469     0.8785 0.012 0.000 0.988 0.000
#> GSM78522     3  0.0469     0.8785 0.012 0.000 0.988 0.000
#> GSM78525     3  0.1474     0.8684 0.052 0.000 0.948 0.000
#> GSM78528     3  0.5998     0.7225 0.200 0.000 0.684 0.116
#> GSM78531     1  0.0336     0.9393 0.992 0.000 0.008 0.000
#> GSM78533     3  0.0336     0.8787 0.008 0.000 0.992 0.000
#> GSM78536     1  0.0188     0.9383 0.996 0.000 0.000 0.004
#> GSM78541     1  0.0469     0.9325 0.988 0.000 0.000 0.012
#> GSM78547     1  0.0376     0.9390 0.992 0.000 0.004 0.004
#> GSM78552     3  0.6024     0.3599 0.416 0.000 0.540 0.044
#> GSM78556     1  0.1211     0.9129 0.960 0.000 0.040 0.000
#> GSM78559     1  0.0188     0.9400 0.996 0.000 0.004 0.000
#> GSM78564     1  0.2216     0.8539 0.908 0.000 0.092 0.000
#> GSM42999     2  0.0000     0.9633 0.000 1.000 0.000 0.000
#> GSM43001     2  0.1847     0.9208 0.004 0.940 0.004 0.052
#> GSM43003     2  0.0000     0.9633 0.000 1.000 0.000 0.000
#> GSM43006     2  0.0336     0.9589 0.000 0.992 0.000 0.008
#> GSM43009     2  0.0000     0.9633 0.000 1.000 0.000 0.000
#> GSM43012     2  0.0000     0.9633 0.000 1.000 0.000 0.000
#> GSM78524     2  0.0000     0.9633 0.000 1.000 0.000 0.000
#> GSM78527     2  0.0000     0.9633 0.000 1.000 0.000 0.000
#> GSM78530     2  0.0000     0.9633 0.000 1.000 0.000 0.000
#> GSM78535     2  0.5155     0.1287 0.468 0.528 0.000 0.004
#> GSM78538     2  0.0000     0.9633 0.000 1.000 0.000 0.000
#> GSM78542     2  0.0000     0.9633 0.000 1.000 0.000 0.000
#> GSM78544     2  0.0000     0.9633 0.000 1.000 0.000 0.000
#> GSM78549     2  0.0000     0.9633 0.000 1.000 0.000 0.000
#> GSM78553     2  0.0000     0.9633 0.000 1.000 0.000 0.000
#> GSM78558     2  0.0000     0.9633 0.000 1.000 0.000 0.000
#> GSM78561     2  0.0707     0.9515 0.000 0.980 0.000 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
#> GSM78539     4  0.0290      0.971 0.000 0.000 0.000 0.992 0.008
#> GSM78545     4  0.1478      0.939 0.000 0.000 0.000 0.936 0.064
#> GSM78550     4  0.1792      0.922 0.000 0.000 0.000 0.916 0.084
#> GSM78554     4  0.1121      0.954 0.000 0.000 0.000 0.956 0.044
#> GSM78562     4  0.0290      0.970 0.008 0.000 0.000 0.992 0.000
#> GSM78540     4  0.0162      0.972 0.000 0.004 0.000 0.996 0.000
#> GSM78546     4  0.0000      0.973 0.000 0.000 0.000 1.000 0.000
#> GSM78551     4  0.0000      0.973 0.000 0.000 0.000 1.000 0.000
#> GSM78555     4  0.0451      0.968 0.004 0.008 0.000 0.988 0.000
#> GSM78563     4  0.0162      0.972 0.000 0.004 0.000 0.996 0.000
#> GSM43005     3  0.5411      0.415 0.044 0.000 0.552 0.008 0.396
#> GSM43008     3  0.6877      0.189 0.224 0.000 0.412 0.008 0.356
#> GSM43011     3  0.0290      0.720 0.008 0.000 0.992 0.000 0.000
#> GSM78523     3  0.0404      0.723 0.012 0.000 0.988 0.000 0.000
#> GSM78526     3  0.0404      0.723 0.012 0.000 0.988 0.000 0.000
#> GSM78529     5  0.3525      0.122 0.008 0.000 0.184 0.008 0.800
#> GSM78532     1  0.0579      0.972 0.984 0.000 0.008 0.000 0.008
#> GSM78534     3  0.0703      0.720 0.024 0.000 0.976 0.000 0.000
#> GSM78537     1  0.0865      0.970 0.972 0.000 0.004 0.000 0.024
#> GSM78543     1  0.0290      0.971 0.992 0.000 0.008 0.000 0.000
#> GSM78548     3  0.6441      0.453 0.124 0.000 0.568 0.028 0.280
#> GSM78557     1  0.1894      0.944 0.920 0.000 0.008 0.000 0.072
#> GSM78560     1  0.1331      0.965 0.952 0.000 0.008 0.000 0.040
#> GSM78565     1  0.0579      0.968 0.984 0.000 0.008 0.000 0.008
#> GSM43000     3  0.2305      0.697 0.012 0.000 0.896 0.000 0.092
#> GSM43002     3  0.4728      0.558 0.040 0.000 0.664 0.000 0.296
#> GSM43004     3  0.3752      0.404 0.292 0.000 0.708 0.000 0.000
#> GSM43007     3  0.6644      0.279 0.176 0.000 0.460 0.008 0.356
#> GSM43010     3  0.0510      0.724 0.016 0.000 0.984 0.000 0.000
#> GSM78522     3  0.0609      0.722 0.020 0.000 0.980 0.000 0.000
#> GSM78525     3  0.4352      0.605 0.036 0.000 0.720 0.000 0.244
#> GSM78528     5  0.5633     -0.331 0.056 0.000 0.424 0.008 0.512
#> GSM78531     1  0.0290      0.971 0.992 0.000 0.008 0.000 0.000
#> GSM78533     3  0.0510      0.724 0.016 0.000 0.984 0.000 0.000
#> GSM78536     1  0.0324      0.968 0.992 0.000 0.004 0.000 0.004
#> GSM78541     1  0.0162      0.965 0.996 0.000 0.004 0.000 0.000
#> GSM78547     1  0.1628      0.955 0.936 0.000 0.008 0.000 0.056
#> GSM78552     5  0.7321     -0.284 0.272 0.000 0.340 0.024 0.364
#> GSM78556     1  0.1740      0.953 0.932 0.000 0.012 0.000 0.056
#> GSM78559     1  0.0451      0.970 0.988 0.000 0.008 0.000 0.004
#> GSM78564     1  0.1281      0.966 0.956 0.000 0.012 0.000 0.032
#> GSM42999     2  0.0510      0.899 0.000 0.984 0.000 0.000 0.016
#> GSM43001     5  0.4283     -0.212 0.000 0.456 0.000 0.000 0.544
#> GSM43003     2  0.0609      0.898 0.000 0.980 0.000 0.000 0.020
#> GSM43006     2  0.4210      0.340 0.000 0.588 0.000 0.000 0.412
#> GSM43009     2  0.0290      0.901 0.000 0.992 0.000 0.000 0.008
#> GSM43012     2  0.1410      0.876 0.000 0.940 0.000 0.000 0.060
#> GSM78524     2  0.0963      0.878 0.036 0.964 0.000 0.000 0.000
#> GSM78527     2  0.3424      0.673 0.000 0.760 0.000 0.000 0.240
#> GSM78530     2  0.0290      0.901 0.000 0.992 0.000 0.000 0.008
#> GSM78535     2  0.4392      0.587 0.200 0.748 0.000 0.048 0.004
#> GSM78538     2  0.0162      0.900 0.000 0.996 0.000 0.004 0.000
#> GSM78542     2  0.0000      0.900 0.000 1.000 0.000 0.000 0.000
#> GSM78544     2  0.0000      0.900 0.000 1.000 0.000 0.000 0.000
#> GSM78549     2  0.1341      0.879 0.000 0.944 0.000 0.000 0.056
#> GSM78553     2  0.0510      0.894 0.000 0.984 0.000 0.016 0.000
#> GSM78558     2  0.0703      0.889 0.000 0.976 0.000 0.024 0.000
#> GSM78561     5  0.4304     -0.270 0.000 0.484 0.000 0.000 0.516

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM78539     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78545     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78550     4  0.0146      0.995 0.000 0.000 0.004 0.996 0.000 0.000
#> GSM78554     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78562     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78540     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78546     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78551     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78555     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78563     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM43005     3  0.3259      0.888 0.012 0.000 0.772 0.000 0.000 0.216
#> GSM43008     3  0.3522      0.870 0.072 0.000 0.800 0.000 0.000 0.128
#> GSM43011     6  0.0405      0.908 0.004 0.000 0.008 0.000 0.000 0.988
#> GSM78523     6  0.0405      0.908 0.004 0.000 0.008 0.000 0.000 0.988
#> GSM78526     6  0.0291      0.910 0.004 0.000 0.004 0.000 0.000 0.992
#> GSM78529     3  0.3612      0.839 0.000 0.000 0.796 0.000 0.100 0.104
#> GSM78532     1  0.1462      0.915 0.936 0.000 0.056 0.000 0.008 0.000
#> GSM78534     6  0.0665      0.903 0.008 0.000 0.004 0.000 0.008 0.980
#> GSM78537     1  0.1387      0.910 0.932 0.000 0.068 0.000 0.000 0.000
#> GSM78543     1  0.0260      0.912 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM78548     3  0.3744      0.860 0.016 0.000 0.724 0.000 0.004 0.256
#> GSM78557     1  0.3795      0.529 0.632 0.000 0.364 0.000 0.000 0.004
#> GSM78560     1  0.1462      0.915 0.936 0.000 0.056 0.000 0.008 0.000
#> GSM78565     1  0.0405      0.903 0.988 0.000 0.008 0.000 0.004 0.000
#> GSM43000     6  0.3426      0.435 0.004 0.000 0.276 0.000 0.000 0.720
#> GSM43002     3  0.3373      0.869 0.008 0.000 0.744 0.000 0.000 0.248
#> GSM43004     6  0.2933      0.666 0.200 0.000 0.000 0.000 0.004 0.796
#> GSM43007     3  0.3385      0.893 0.032 0.000 0.788 0.000 0.000 0.180
#> GSM43010     6  0.0146      0.909 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM78522     6  0.0436      0.907 0.004 0.000 0.004 0.000 0.004 0.988
#> GSM78525     3  0.3725      0.782 0.008 0.000 0.676 0.000 0.000 0.316
#> GSM78528     3  0.2308      0.846 0.016 0.000 0.896 0.000 0.012 0.076
#> GSM78531     1  0.1285      0.915 0.944 0.000 0.052 0.000 0.004 0.000
#> GSM78533     6  0.0291      0.910 0.004 0.000 0.004 0.000 0.000 0.992
#> GSM78536     1  0.0000      0.909 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0547      0.913 0.980 0.000 0.020 0.000 0.000 0.000
#> GSM78547     1  0.2632      0.843 0.832 0.000 0.164 0.000 0.000 0.004
#> GSM78552     3  0.3041      0.883 0.040 0.000 0.832 0.000 0.000 0.128
#> GSM78556     1  0.2805      0.823 0.812 0.000 0.184 0.000 0.000 0.004
#> GSM78559     1  0.0146      0.908 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM78564     1  0.0837      0.910 0.972 0.000 0.020 0.000 0.004 0.004
#> GSM42999     2  0.0146      0.927 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM43001     5  0.0547      0.916 0.000 0.020 0.000 0.000 0.980 0.000
#> GSM43003     2  0.0632      0.918 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM43006     5  0.2340      0.822 0.000 0.148 0.000 0.000 0.852 0.000
#> GSM43009     2  0.0146      0.927 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM43012     2  0.3737      0.356 0.000 0.608 0.000 0.000 0.392 0.000
#> GSM78524     2  0.0405      0.925 0.000 0.988 0.008 0.000 0.004 0.000
#> GSM78527     2  0.2793      0.745 0.000 0.800 0.000 0.000 0.200 0.000
#> GSM78530     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78535     2  0.0777      0.906 0.024 0.972 0.000 0.000 0.004 0.000
#> GSM78538     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78542     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78544     2  0.0146      0.927 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM78549     2  0.2762      0.751 0.000 0.804 0.000 0.000 0.196 0.000
#> GSM78553     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78558     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78561     5  0.0458      0.914 0.000 0.016 0.000 0.000 0.984 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-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 cell.type(p) agent(p) individual(p) k
#> SD:NMF 58     2.54e-13  0.00184        0.9999 2
#> SD:NMF 55     2.68e-14  0.00255        0.2277 3
#> SD:NMF 55     2.04e-21  0.00750        0.2875 4
#> SD:NMF 47     4.46e-18  0.02248        0.1702 5
#> SD:NMF 56     2.11e-19  0.04069        0.0681 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 58 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.781           0.875       0.946         0.3283 0.733   0.733
#> 3 3 0.563           0.770       0.789         0.6259 0.681   0.564
#> 4 4 0.631           0.896       0.879         0.2677 0.879   0.708
#> 5 5 0.642           0.809       0.806         0.0920 0.989   0.963
#> 6 6 0.704           0.760       0.835         0.0792 0.889   0.620

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

suggest_best_k(res)
#> [1] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM78539     1   0.000      0.930 1.000 0.000
#> GSM78545     1   0.000      0.930 1.000 0.000
#> GSM78550     1   0.000      0.930 1.000 0.000
#> GSM78554     1   0.000      0.930 1.000 0.000
#> GSM78562     1   0.000      0.930 1.000 0.000
#> GSM78540     1   0.000      0.930 1.000 0.000
#> GSM78546     1   0.000      0.930 1.000 0.000
#> GSM78551     1   0.000      0.930 1.000 0.000
#> GSM78555     1   0.000      0.930 1.000 0.000
#> GSM78563     1   0.000      0.930 1.000 0.000
#> GSM43005     1   0.000      0.930 1.000 0.000
#> GSM43008     1   0.000      0.930 1.000 0.000
#> GSM43011     1   0.000      0.930 1.000 0.000
#> GSM78523     1   0.000      0.930 1.000 0.000
#> GSM78526     1   0.000      0.930 1.000 0.000
#> GSM78529     1   0.000      0.930 1.000 0.000
#> GSM78532     1   0.000      0.930 1.000 0.000
#> GSM78534     1   0.000      0.930 1.000 0.000
#> GSM78537     1   0.000      0.930 1.000 0.000
#> GSM78543     1   0.000      0.930 1.000 0.000
#> GSM78548     1   0.000      0.930 1.000 0.000
#> GSM78557     1   0.000      0.930 1.000 0.000
#> GSM78560     1   0.000      0.930 1.000 0.000
#> GSM78565     1   0.000      0.930 1.000 0.000
#> GSM43000     1   0.000      0.930 1.000 0.000
#> GSM43002     1   0.000      0.930 1.000 0.000
#> GSM43004     1   0.000      0.930 1.000 0.000
#> GSM43007     1   0.000      0.930 1.000 0.000
#> GSM43010     1   0.000      0.930 1.000 0.000
#> GSM78522     1   0.000      0.930 1.000 0.000
#> GSM78525     1   0.000      0.930 1.000 0.000
#> GSM78528     1   0.000      0.930 1.000 0.000
#> GSM78531     1   0.000      0.930 1.000 0.000
#> GSM78533     1   0.000      0.930 1.000 0.000
#> GSM78536     1   0.000      0.930 1.000 0.000
#> GSM78541     1   0.000      0.930 1.000 0.000
#> GSM78547     1   0.000      0.930 1.000 0.000
#> GSM78552     1   0.000      0.930 1.000 0.000
#> GSM78556     1   0.000      0.930 1.000 0.000
#> GSM78559     1   0.000      0.930 1.000 0.000
#> GSM78564     1   0.000      0.930 1.000 0.000
#> GSM42999     2   0.000      1.000 0.000 1.000
#> GSM43001     2   0.000      1.000 0.000 1.000
#> GSM43003     2   0.000      1.000 0.000 1.000
#> GSM43006     2   0.000      1.000 0.000 1.000
#> GSM43009     2   0.000      1.000 0.000 1.000
#> GSM43012     2   0.000      1.000 0.000 1.000
#> GSM78524     1   0.943      0.505 0.640 0.360
#> GSM78527     2   0.000      1.000 0.000 1.000
#> GSM78530     1   0.971      0.431 0.600 0.400
#> GSM78535     1   0.943      0.505 0.640 0.360
#> GSM78538     1   0.971      0.431 0.600 0.400
#> GSM78542     1   0.971      0.431 0.600 0.400
#> GSM78544     1   0.975      0.413 0.592 0.408
#> GSM78549     2   0.000      1.000 0.000 1.000
#> GSM78553     1   0.971      0.431 0.600 0.400
#> GSM78558     1   0.971      0.431 0.600 0.400
#> GSM78561     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     1  0.0000      0.707 1.000 0.000 0.000
#> GSM78545     1  0.3192      0.575 0.888 0.000 0.112
#> GSM78550     1  0.2711      0.622 0.912 0.000 0.088
#> GSM78554     1  0.1753      0.667 0.952 0.000 0.048
#> GSM78562     1  0.0000      0.707 1.000 0.000 0.000
#> GSM78540     1  0.0000      0.707 1.000 0.000 0.000
#> GSM78546     1  0.2537      0.632 0.920 0.000 0.080
#> GSM78551     1  0.2711      0.622 0.912 0.000 0.088
#> GSM78555     1  0.0592      0.712 0.988 0.000 0.012
#> GSM78563     1  0.0000      0.707 1.000 0.000 0.000
#> GSM43005     3  0.6280      0.997 0.460 0.000 0.540
#> GSM43008     3  0.6295      0.979 0.472 0.000 0.528
#> GSM43011     3  0.6280      0.997 0.460 0.000 0.540
#> GSM78523     3  0.6280      0.997 0.460 0.000 0.540
#> GSM78526     3  0.6280      0.997 0.460 0.000 0.540
#> GSM78529     3  0.6280      0.997 0.460 0.000 0.540
#> GSM78532     1  0.0592      0.712 0.988 0.000 0.012
#> GSM78534     3  0.6280      0.997 0.460 0.000 0.540
#> GSM78537     1  0.0592      0.712 0.988 0.000 0.012
#> GSM78543     1  0.0592      0.712 0.988 0.000 0.012
#> GSM78548     1  0.3267      0.565 0.884 0.000 0.116
#> GSM78557     1  0.2796      0.616 0.908 0.000 0.092
#> GSM78560     1  0.0592      0.712 0.988 0.000 0.012
#> GSM78565     1  0.0592      0.712 0.988 0.000 0.012
#> GSM43000     3  0.6280      0.997 0.460 0.000 0.540
#> GSM43002     3  0.6280      0.997 0.460 0.000 0.540
#> GSM43004     3  0.6280      0.997 0.460 0.000 0.540
#> GSM43007     3  0.6295      0.979 0.472 0.000 0.528
#> GSM43010     3  0.6280      0.997 0.460 0.000 0.540
#> GSM78522     3  0.6280      0.997 0.460 0.000 0.540
#> GSM78525     3  0.6280      0.997 0.460 0.000 0.540
#> GSM78528     3  0.6280      0.997 0.460 0.000 0.540
#> GSM78531     1  0.0592      0.712 0.988 0.000 0.012
#> GSM78533     3  0.6280      0.997 0.460 0.000 0.540
#> GSM78536     1  0.0592      0.712 0.988 0.000 0.012
#> GSM78541     1  0.0592      0.712 0.988 0.000 0.012
#> GSM78547     1  0.2878      0.609 0.904 0.000 0.096
#> GSM78552     1  0.2878      0.609 0.904 0.000 0.096
#> GSM78556     1  0.2878      0.609 0.904 0.000 0.096
#> GSM78559     1  0.0592      0.712 0.988 0.000 0.012
#> GSM78564     1  0.2796      0.616 0.908 0.000 0.092
#> GSM42999     2  0.1964      0.978 0.000 0.944 0.056
#> GSM43001     2  0.0000      0.973 0.000 1.000 0.000
#> GSM43003     2  0.2066      0.977 0.000 0.940 0.060
#> GSM43006     2  0.0000      0.973 0.000 1.000 0.000
#> GSM43009     2  0.1964      0.978 0.000 0.944 0.056
#> GSM43012     2  0.0000      0.973 0.000 1.000 0.000
#> GSM78524     1  0.6280      0.420 0.540 0.000 0.460
#> GSM78527     2  0.2066      0.977 0.000 0.940 0.060
#> GSM78530     1  0.8270      0.406 0.540 0.084 0.376
#> GSM78535     1  0.6280      0.420 0.540 0.000 0.460
#> GSM78538     1  0.8270      0.406 0.540 0.084 0.376
#> GSM78542     1  0.8270      0.406 0.540 0.084 0.376
#> GSM78544     1  0.8808      0.378 0.536 0.132 0.332
#> GSM78549     2  0.2066      0.977 0.000 0.940 0.060
#> GSM78553     1  0.8270      0.406 0.540 0.084 0.376
#> GSM78558     1  0.8270      0.406 0.540 0.084 0.376
#> GSM78561     2  0.0000      0.973 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     1  0.0469      0.835 0.988 0.000 0.012 0.000
#> GSM78545     1  0.4543      0.641 0.676 0.000 0.324 0.000
#> GSM78550     1  0.2868      0.842 0.864 0.000 0.136 0.000
#> GSM78554     1  0.2281      0.858 0.904 0.000 0.096 0.000
#> GSM78562     1  0.0469      0.835 0.988 0.000 0.012 0.000
#> GSM78540     1  0.0469      0.835 0.988 0.000 0.012 0.000
#> GSM78546     1  0.2216      0.838 0.908 0.000 0.092 0.000
#> GSM78551     1  0.2408      0.834 0.896 0.000 0.104 0.000
#> GSM78555     1  0.0000      0.829 1.000 0.000 0.000 0.000
#> GSM78563     1  0.0469      0.835 0.988 0.000 0.012 0.000
#> GSM43005     3  0.2216      0.992 0.092 0.000 0.908 0.000
#> GSM43008     3  0.2530      0.976 0.112 0.000 0.888 0.000
#> GSM43011     3  0.2216      0.992 0.092 0.000 0.908 0.000
#> GSM78523     3  0.2216      0.992 0.092 0.000 0.908 0.000
#> GSM78526     3  0.2216      0.992 0.092 0.000 0.908 0.000
#> GSM78529     3  0.2216      0.992 0.092 0.000 0.908 0.000
#> GSM78532     1  0.2530      0.872 0.888 0.000 0.112 0.000
#> GSM78534     3  0.2469      0.981 0.108 0.000 0.892 0.000
#> GSM78537     1  0.2530      0.872 0.888 0.000 0.112 0.000
#> GSM78543     1  0.2530      0.872 0.888 0.000 0.112 0.000
#> GSM78548     1  0.4888      0.523 0.588 0.000 0.412 0.000
#> GSM78557     1  0.3942      0.809 0.764 0.000 0.236 0.000
#> GSM78560     1  0.2647      0.869 0.880 0.000 0.120 0.000
#> GSM78565     1  0.2530      0.872 0.888 0.000 0.112 0.000
#> GSM43000     3  0.2216      0.992 0.092 0.000 0.908 0.000
#> GSM43002     3  0.2216      0.992 0.092 0.000 0.908 0.000
#> GSM43004     3  0.2469      0.981 0.108 0.000 0.892 0.000
#> GSM43007     3  0.2530      0.976 0.112 0.000 0.888 0.000
#> GSM43010     3  0.2216      0.992 0.092 0.000 0.908 0.000
#> GSM78522     3  0.2469      0.981 0.108 0.000 0.892 0.000
#> GSM78525     3  0.2216      0.992 0.092 0.000 0.908 0.000
#> GSM78528     3  0.2216      0.992 0.092 0.000 0.908 0.000
#> GSM78531     1  0.2530      0.872 0.888 0.000 0.112 0.000
#> GSM78533     3  0.2216      0.992 0.092 0.000 0.908 0.000
#> GSM78536     1  0.2530      0.872 0.888 0.000 0.112 0.000
#> GSM78541     1  0.2530      0.872 0.888 0.000 0.112 0.000
#> GSM78547     1  0.4040      0.799 0.752 0.000 0.248 0.000
#> GSM78552     1  0.4746      0.620 0.632 0.000 0.368 0.000
#> GSM78556     1  0.3975      0.806 0.760 0.000 0.240 0.000
#> GSM78559     1  0.2530      0.872 0.888 0.000 0.112 0.000
#> GSM78564     1  0.4454      0.725 0.692 0.000 0.308 0.000
#> GSM42999     2  0.2921      0.934 0.000 0.860 0.000 0.140
#> GSM43001     2  0.0000      0.898 0.000 1.000 0.000 0.000
#> GSM43003     2  0.2973      0.932 0.000 0.856 0.000 0.144
#> GSM43006     2  0.0000      0.898 0.000 1.000 0.000 0.000
#> GSM43009     2  0.2921      0.934 0.000 0.860 0.000 0.140
#> GSM43012     2  0.2081      0.925 0.000 0.916 0.000 0.084
#> GSM78524     4  0.2216      0.916 0.000 0.000 0.092 0.908
#> GSM78527     2  0.2973      0.932 0.000 0.856 0.000 0.144
#> GSM78530     4  0.0000      0.965 0.000 0.000 0.000 1.000
#> GSM78535     4  0.2216      0.916 0.000 0.000 0.092 0.908
#> GSM78538     4  0.0000      0.965 0.000 0.000 0.000 1.000
#> GSM78542     4  0.0000      0.965 0.000 0.000 0.000 1.000
#> GSM78544     4  0.1389      0.922 0.000 0.048 0.000 0.952
#> GSM78549     2  0.2973      0.932 0.000 0.856 0.000 0.144
#> GSM78553     4  0.0000      0.965 0.000 0.000 0.000 1.000
#> GSM78558     4  0.0000      0.965 0.000 0.000 0.000 1.000
#> GSM78561     2  0.0000      0.898 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     1  0.0807      0.654 0.976 0.000 0.012 0.000 0.012
#> GSM78545     1  0.5275      0.528 0.640 0.000 0.276 0.000 0.084
#> GSM78550     1  0.3420      0.660 0.840 0.000 0.076 0.000 0.084
#> GSM78554     1  0.2830      0.676 0.876 0.000 0.080 0.000 0.044
#> GSM78562     1  0.0807      0.654 0.976 0.000 0.012 0.000 0.012
#> GSM78540     1  0.0290      0.646 0.992 0.000 0.008 0.000 0.000
#> GSM78546     1  0.2110      0.641 0.912 0.000 0.016 0.000 0.072
#> GSM78551     1  0.2293      0.637 0.900 0.000 0.016 0.000 0.084
#> GSM78555     1  0.0609      0.645 0.980 0.000 0.000 0.000 0.020
#> GSM78563     1  0.0290      0.646 0.992 0.000 0.008 0.000 0.000
#> GSM43005     3  0.1952      0.894 0.004 0.000 0.912 0.000 0.084
#> GSM43008     3  0.2561      0.880 0.020 0.000 0.884 0.000 0.096
#> GSM43011     3  0.1608      0.894 0.000 0.000 0.928 0.000 0.072
#> GSM78523     3  0.1608      0.894 0.000 0.000 0.928 0.000 0.072
#> GSM78526     3  0.1608      0.894 0.000 0.000 0.928 0.000 0.072
#> GSM78529     3  0.2011      0.894 0.004 0.000 0.908 0.000 0.088
#> GSM78532     1  0.5744      0.738 0.572 0.000 0.108 0.000 0.320
#> GSM78534     3  0.2304      0.878 0.008 0.000 0.892 0.000 0.100
#> GSM78537     1  0.5744      0.738 0.572 0.000 0.108 0.000 0.320
#> GSM78543     1  0.5744      0.738 0.572 0.000 0.108 0.000 0.320
#> GSM78548     1  0.5752      0.399 0.500 0.000 0.412 0.000 0.088
#> GSM78557     1  0.6425      0.688 0.476 0.000 0.188 0.000 0.336
#> GSM78560     1  0.5923      0.736 0.572 0.000 0.140 0.000 0.288
#> GSM78565     1  0.5744      0.738 0.572 0.000 0.108 0.000 0.320
#> GSM43000     3  0.2011      0.894 0.004 0.000 0.908 0.000 0.088
#> GSM43002     3  0.2011      0.894 0.004 0.000 0.908 0.000 0.088
#> GSM43004     3  0.2304      0.878 0.008 0.000 0.892 0.000 0.100
#> GSM43007     3  0.2561      0.880 0.020 0.000 0.884 0.000 0.096
#> GSM43010     3  0.1608      0.894 0.000 0.000 0.928 0.000 0.072
#> GSM78522     3  0.2304      0.878 0.008 0.000 0.892 0.000 0.100
#> GSM78525     3  0.2011      0.894 0.004 0.000 0.908 0.000 0.088
#> GSM78528     3  0.2011      0.894 0.004 0.000 0.908 0.000 0.088
#> GSM78531     1  0.5744      0.738 0.572 0.000 0.108 0.000 0.320
#> GSM78533     3  0.1608      0.894 0.000 0.000 0.928 0.000 0.072
#> GSM78536     1  0.5744      0.738 0.572 0.000 0.108 0.000 0.320
#> GSM78541     1  0.5744      0.738 0.572 0.000 0.108 0.000 0.320
#> GSM78547     1  0.6544      0.669 0.468 0.000 0.224 0.000 0.308
#> GSM78552     1  0.6619      0.513 0.420 0.000 0.360 0.000 0.220
#> GSM78556     1  0.6447      0.685 0.472 0.000 0.192 0.000 0.336
#> GSM78559     1  0.5744      0.738 0.572 0.000 0.108 0.000 0.320
#> GSM78564     1  0.6618      0.630 0.452 0.000 0.244 0.000 0.304
#> GSM42999     4  0.0000      0.970 0.000 0.000 0.000 1.000 0.000
#> GSM43001     5  0.4227      1.000 0.000 0.000 0.000 0.420 0.580
#> GSM43003     4  0.0162      0.970 0.000 0.004 0.000 0.996 0.000
#> GSM43006     5  0.4227      1.000 0.000 0.000 0.000 0.420 0.580
#> GSM43009     4  0.0000      0.970 0.000 0.000 0.000 1.000 0.000
#> GSM43012     4  0.1341      0.859 0.000 0.000 0.000 0.944 0.056
#> GSM78524     2  0.0162      0.857 0.000 0.996 0.000 0.000 0.004
#> GSM78527     4  0.0162      0.970 0.000 0.004 0.000 0.996 0.000
#> GSM78530     2  0.2516      0.946 0.000 0.860 0.000 0.140 0.000
#> GSM78535     2  0.0162      0.857 0.000 0.996 0.000 0.000 0.004
#> GSM78538     2  0.2516      0.946 0.000 0.860 0.000 0.140 0.000
#> GSM78542     2  0.2516      0.946 0.000 0.860 0.000 0.140 0.000
#> GSM78544     2  0.3003      0.903 0.000 0.812 0.000 0.188 0.000
#> GSM78549     4  0.0162      0.970 0.000 0.004 0.000 0.996 0.000
#> GSM78553     2  0.2516      0.946 0.000 0.860 0.000 0.140 0.000
#> GSM78558     2  0.2516      0.946 0.000 0.860 0.000 0.140 0.000
#> GSM78561     5  0.4227      1.000 0.000 0.000 0.000 0.420 0.580

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM78539     4  0.0692      0.795 0.020 0.000 0.004 0.976 0.000 0.000
#> GSM78545     4  0.3620      0.587 0.000 0.000 0.352 0.648 0.000 0.000
#> GSM78550     4  0.2378      0.777 0.000 0.000 0.152 0.848 0.000 0.000
#> GSM78554     4  0.2003      0.799 0.000 0.000 0.116 0.884 0.000 0.000
#> GSM78562     4  0.0692      0.795 0.020 0.000 0.004 0.976 0.000 0.000
#> GSM78540     4  0.0000      0.801 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78546     4  0.1556      0.809 0.000 0.000 0.080 0.920 0.000 0.000
#> GSM78551     4  0.1714      0.805 0.000 0.000 0.092 0.908 0.000 0.000
#> GSM78555     4  0.1714      0.703 0.092 0.000 0.000 0.908 0.000 0.000
#> GSM78563     4  0.0000      0.801 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM43005     3  0.0508      0.713 0.004 0.000 0.984 0.012 0.000 0.000
#> GSM43008     3  0.1528      0.704 0.048 0.000 0.936 0.016 0.000 0.000
#> GSM43011     3  0.4493      0.704 0.344 0.000 0.612 0.000 0.044 0.000
#> GSM78523     3  0.4493      0.704 0.344 0.000 0.612 0.000 0.044 0.000
#> GSM78526     3  0.4493      0.704 0.344 0.000 0.612 0.000 0.044 0.000
#> GSM78529     3  0.0363      0.712 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM78532     1  0.2730      0.819 0.808 0.000 0.000 0.192 0.000 0.000
#> GSM78534     3  0.4627      0.675 0.396 0.000 0.560 0.000 0.044 0.000
#> GSM78537     1  0.2730      0.819 0.808 0.000 0.000 0.192 0.000 0.000
#> GSM78543     1  0.2730      0.819 0.808 0.000 0.000 0.192 0.000 0.000
#> GSM78548     4  0.4467      0.358 0.028 0.000 0.464 0.508 0.000 0.000
#> GSM78557     1  0.5648      0.464 0.512 0.000 0.176 0.312 0.000 0.000
#> GSM78560     1  0.3807      0.782 0.756 0.000 0.052 0.192 0.000 0.000
#> GSM78565     1  0.2730      0.819 0.808 0.000 0.000 0.192 0.000 0.000
#> GSM43000     3  0.0363      0.712 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM43002     3  0.0363      0.712 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM43004     3  0.4634      0.671 0.400 0.000 0.556 0.000 0.044 0.000
#> GSM43007     3  0.1528      0.704 0.048 0.000 0.936 0.016 0.000 0.000
#> GSM43010     3  0.4493      0.704 0.344 0.000 0.612 0.000 0.044 0.000
#> GSM78522     3  0.4627      0.675 0.396 0.000 0.560 0.000 0.044 0.000
#> GSM78525     3  0.0363      0.712 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM78528     3  0.0363      0.712 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM78531     1  0.2730      0.819 0.808 0.000 0.000 0.192 0.000 0.000
#> GSM78533     3  0.4493      0.704 0.344 0.000 0.612 0.000 0.044 0.000
#> GSM78536     1  0.2730      0.819 0.808 0.000 0.000 0.192 0.000 0.000
#> GSM78541     1  0.2730      0.819 0.808 0.000 0.000 0.192 0.000 0.000
#> GSM78547     1  0.5953      0.366 0.448 0.000 0.244 0.308 0.000 0.000
#> GSM78552     3  0.6076     -0.329 0.292 0.000 0.400 0.308 0.000 0.000
#> GSM78556     1  0.5660      0.462 0.512 0.000 0.180 0.308 0.000 0.000
#> GSM78559     1  0.2730      0.819 0.808 0.000 0.000 0.192 0.000 0.000
#> GSM78564     1  0.5925      0.376 0.456 0.000 0.236 0.308 0.000 0.000
#> GSM42999     6  0.0146      0.981 0.000 0.000 0.000 0.000 0.004 0.996
#> GSM43001     5  0.1007      1.000 0.000 0.000 0.000 0.000 0.956 0.044
#> GSM43003     6  0.0000      0.982 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM43006     5  0.1007      1.000 0.000 0.000 0.000 0.000 0.956 0.044
#> GSM43009     6  0.0146      0.981 0.000 0.000 0.000 0.000 0.004 0.996
#> GSM43012     6  0.1267      0.917 0.000 0.000 0.000 0.000 0.060 0.940
#> GSM78524     2  0.0000      0.850 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78527     6  0.0000      0.982 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78530     2  0.2300      0.945 0.000 0.856 0.000 0.000 0.000 0.144
#> GSM78535     2  0.0000      0.850 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78538     2  0.2300      0.945 0.000 0.856 0.000 0.000 0.000 0.144
#> GSM78542     2  0.2300      0.945 0.000 0.856 0.000 0.000 0.000 0.144
#> GSM78544     2  0.2730      0.902 0.000 0.808 0.000 0.000 0.000 0.192
#> GSM78549     6  0.0000      0.982 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78553     2  0.2300      0.945 0.000 0.856 0.000 0.000 0.000 0.144
#> GSM78558     2  0.2300      0.945 0.000 0.856 0.000 0.000 0.000 0.144
#> GSM78561     5  0.1007      1.000 0.000 0.000 0.000 0.000 0.956 0.044

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 cell.type(p) agent(p) individual(p) k
#> CV:hclust 52     1.55e-09  0.03378        0.8621 2
#> CV:hclust 50     2.48e-12  0.03334        0.0329 3
#> CV:hclust 58     4.14e-13  0.00812        0.1188 4
#> CV:hclust 57     5.73e-12  0.02441        0.1248 5
#> CV:hclust 52     8.60e-18  0.02694        0.1381 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 58 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 1.000           0.991       0.995         0.4188 0.578   0.578
#> 3 3 0.632           0.850       0.866         0.5004 0.726   0.537
#> 4 4 0.630           0.406       0.625         0.1506 0.757   0.438
#> 5 5 0.774           0.817       0.780         0.0752 0.829   0.485
#> 6 6 0.827           0.851       0.849         0.0554 0.948   0.750

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
#> GSM78539     1  0.0376      0.997 0.996 0.004
#> GSM78545     1  0.0376      0.997 0.996 0.004
#> GSM78550     1  0.0376      0.997 0.996 0.004
#> GSM78554     1  0.0376      0.997 0.996 0.004
#> GSM78562     1  0.0376      0.997 0.996 0.004
#> GSM78540     1  0.0376      0.997 0.996 0.004
#> GSM78546     1  0.0376      0.997 0.996 0.004
#> GSM78551     1  0.0376      0.997 0.996 0.004
#> GSM78555     1  0.0376      0.997 0.996 0.004
#> GSM78563     1  0.0376      0.997 0.996 0.004
#> GSM43005     1  0.0000      0.999 1.000 0.000
#> GSM43008     1  0.0000      0.999 1.000 0.000
#> GSM43011     1  0.0000      0.999 1.000 0.000
#> GSM78523     1  0.0000      0.999 1.000 0.000
#> GSM78526     1  0.0000      0.999 1.000 0.000
#> GSM78529     1  0.0000      0.999 1.000 0.000
#> GSM78532     1  0.0000      0.999 1.000 0.000
#> GSM78534     1  0.0000      0.999 1.000 0.000
#> GSM78537     1  0.0000      0.999 1.000 0.000
#> GSM78543     1  0.0000      0.999 1.000 0.000
#> GSM78548     1  0.0000      0.999 1.000 0.000
#> GSM78557     1  0.0000      0.999 1.000 0.000
#> GSM78560     1  0.0000      0.999 1.000 0.000
#> GSM78565     1  0.0000      0.999 1.000 0.000
#> GSM43000     1  0.0000      0.999 1.000 0.000
#> GSM43002     1  0.0000      0.999 1.000 0.000
#> GSM43004     1  0.0000      0.999 1.000 0.000
#> GSM43007     1  0.0000      0.999 1.000 0.000
#> GSM43010     1  0.0000      0.999 1.000 0.000
#> GSM78522     1  0.0000      0.999 1.000 0.000
#> GSM78525     1  0.0000      0.999 1.000 0.000
#> GSM78528     1  0.0000      0.999 1.000 0.000
#> GSM78531     1  0.0000      0.999 1.000 0.000
#> GSM78533     1  0.0000      0.999 1.000 0.000
#> GSM78536     1  0.0000      0.999 1.000 0.000
#> GSM78541     1  0.0000      0.999 1.000 0.000
#> GSM78547     1  0.0000      0.999 1.000 0.000
#> GSM78552     1  0.0000      0.999 1.000 0.000
#> GSM78556     1  0.0000      0.999 1.000 0.000
#> GSM78559     1  0.0000      0.999 1.000 0.000
#> GSM78564     1  0.0000      0.999 1.000 0.000
#> GSM42999     2  0.0376      0.987 0.004 0.996
#> GSM43001     2  0.0376      0.987 0.004 0.996
#> GSM43003     2  0.0376      0.987 0.004 0.996
#> GSM43006     2  0.0376      0.987 0.004 0.996
#> GSM43009     2  0.0376      0.987 0.004 0.996
#> GSM43012     2  0.0376      0.987 0.004 0.996
#> GSM78524     2  0.0376      0.987 0.004 0.996
#> GSM78527     2  0.0376      0.987 0.004 0.996
#> GSM78530     2  0.0376      0.987 0.004 0.996
#> GSM78535     2  0.7299      0.749 0.204 0.796
#> GSM78538     2  0.0376      0.987 0.004 0.996
#> GSM78542     2  0.0376      0.987 0.004 0.996
#> GSM78544     2  0.0376      0.987 0.004 0.996
#> GSM78549     2  0.0376      0.987 0.004 0.996
#> GSM78553     2  0.0376      0.987 0.004 0.996
#> GSM78558     2  0.0376      0.987 0.004 0.996
#> GSM78561     2  0.0376      0.987 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     1  0.4062     0.8109 0.836 0.000 0.164
#> GSM78545     3  0.6126     0.2365 0.400 0.000 0.600
#> GSM78550     1  0.4178     0.8103 0.828 0.000 0.172
#> GSM78554     1  0.4178     0.8103 0.828 0.000 0.172
#> GSM78562     1  0.3941     0.8106 0.844 0.000 0.156
#> GSM78540     1  0.4178     0.8103 0.828 0.000 0.172
#> GSM78546     1  0.4178     0.8103 0.828 0.000 0.172
#> GSM78551     1  0.4178     0.8103 0.828 0.000 0.172
#> GSM78555     1  0.3941     0.8106 0.844 0.000 0.156
#> GSM78563     1  0.4178     0.8103 0.828 0.000 0.172
#> GSM43005     3  0.5650     0.9644 0.312 0.000 0.688
#> GSM43008     3  0.5678     0.9636 0.316 0.000 0.684
#> GSM43011     3  0.5650     0.9644 0.312 0.000 0.688
#> GSM78523     3  0.5678     0.9636 0.316 0.000 0.684
#> GSM78526     3  0.5678     0.9636 0.316 0.000 0.684
#> GSM78529     3  0.5650     0.9644 0.312 0.000 0.688
#> GSM78532     1  0.0000     0.8405 1.000 0.000 0.000
#> GSM78534     3  0.5785     0.9489 0.332 0.000 0.668
#> GSM78537     1  0.0000     0.8405 1.000 0.000 0.000
#> GSM78543     1  0.0000     0.8405 1.000 0.000 0.000
#> GSM78548     3  0.5650     0.9644 0.312 0.000 0.688
#> GSM78557     1  0.0000     0.8405 1.000 0.000 0.000
#> GSM78560     1  0.0000     0.8405 1.000 0.000 0.000
#> GSM78565     1  0.0000     0.8405 1.000 0.000 0.000
#> GSM43000     3  0.5650     0.9644 0.312 0.000 0.688
#> GSM43002     3  0.5650     0.9644 0.312 0.000 0.688
#> GSM43004     3  0.5859     0.9366 0.344 0.000 0.656
#> GSM43007     3  0.5650     0.9644 0.312 0.000 0.688
#> GSM43010     3  0.5678     0.9636 0.316 0.000 0.684
#> GSM78522     3  0.5785     0.9489 0.332 0.000 0.668
#> GSM78525     3  0.5650     0.9644 0.312 0.000 0.688
#> GSM78528     3  0.5650     0.9644 0.312 0.000 0.688
#> GSM78531     1  0.0000     0.8405 1.000 0.000 0.000
#> GSM78533     3  0.5678     0.9636 0.316 0.000 0.684
#> GSM78536     1  0.0000     0.8405 1.000 0.000 0.000
#> GSM78541     1  0.0000     0.8405 1.000 0.000 0.000
#> GSM78547     1  0.0000     0.8405 1.000 0.000 0.000
#> GSM78552     1  0.6309    -0.6525 0.500 0.000 0.500
#> GSM78556     1  0.0000     0.8405 1.000 0.000 0.000
#> GSM78559     1  0.0000     0.8405 1.000 0.000 0.000
#> GSM78564     1  0.0000     0.8405 1.000 0.000 0.000
#> GSM42999     2  0.0000     0.9467 0.000 1.000 0.000
#> GSM43001     2  0.0892     0.9434 0.000 0.980 0.020
#> GSM43003     2  0.0000     0.9467 0.000 1.000 0.000
#> GSM43006     2  0.0892     0.9434 0.000 0.980 0.020
#> GSM43009     2  0.2066     0.9466 0.000 0.940 0.060
#> GSM43012     2  0.0892     0.9434 0.000 0.980 0.020
#> GSM78524     2  0.3686     0.9406 0.000 0.860 0.140
#> GSM78527     2  0.0892     0.9434 0.000 0.980 0.020
#> GSM78530     2  0.3686     0.9406 0.000 0.860 0.140
#> GSM78535     1  0.9367     0.0648 0.476 0.344 0.180
#> GSM78538     2  0.3686     0.9406 0.000 0.860 0.140
#> GSM78542     2  0.3686     0.9406 0.000 0.860 0.140
#> GSM78544     2  0.3686     0.9406 0.000 0.860 0.140
#> GSM78549     2  0.0000     0.9467 0.000 1.000 0.000
#> GSM78553     2  0.3686     0.9406 0.000 0.860 0.140
#> GSM78558     2  0.3686     0.9406 0.000 0.860 0.140
#> GSM78561     2  0.0892     0.9434 0.000 0.980 0.020

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     4  0.0921     0.8861 0.028 0.000 0.000 0.972
#> GSM78545     4  0.4605     0.4955 0.336 0.000 0.000 0.664
#> GSM78550     4  0.3764     0.6957 0.216 0.000 0.000 0.784
#> GSM78554     4  0.1557     0.8811 0.056 0.000 0.000 0.944
#> GSM78562     4  0.1557     0.8590 0.056 0.000 0.000 0.944
#> GSM78540     4  0.0921     0.8861 0.028 0.000 0.000 0.972
#> GSM78546     4  0.1389     0.8850 0.048 0.000 0.000 0.952
#> GSM78551     4  0.1389     0.8850 0.048 0.000 0.000 0.952
#> GSM78555     4  0.1557     0.8590 0.056 0.000 0.000 0.944
#> GSM78563     4  0.0921     0.8861 0.028 0.000 0.000 0.972
#> GSM43005     1  0.5671    -0.6995 0.572 0.000 0.400 0.028
#> GSM43008     1  0.5510    -0.6919 0.600 0.000 0.376 0.024
#> GSM43011     3  0.5060     0.9544 0.412 0.000 0.584 0.004
#> GSM78523     3  0.5060     0.9544 0.412 0.000 0.584 0.004
#> GSM78526     3  0.5004     0.9663 0.392 0.000 0.604 0.004
#> GSM78529     1  0.5671    -0.6995 0.572 0.000 0.400 0.028
#> GSM78532     1  0.4989     0.1802 0.528 0.000 0.000 0.472
#> GSM78534     3  0.4985     0.8547 0.468 0.000 0.532 0.000
#> GSM78537     1  0.4989     0.1802 0.528 0.000 0.000 0.472
#> GSM78543     1  0.4989     0.1802 0.528 0.000 0.000 0.472
#> GSM78548     1  0.5649    -0.6955 0.580 0.000 0.392 0.028
#> GSM78557     1  0.4981     0.1816 0.536 0.000 0.000 0.464
#> GSM78560     1  0.4981     0.1816 0.536 0.000 0.000 0.464
#> GSM78565     1  0.4989     0.1802 0.528 0.000 0.000 0.472
#> GSM43000     1  0.5126    -0.7577 0.552 0.000 0.444 0.004
#> GSM43002     1  0.5088    -0.7285 0.572 0.000 0.424 0.004
#> GSM43004     1  0.3881    -0.0861 0.812 0.000 0.172 0.016
#> GSM43007     1  0.5649    -0.6955 0.580 0.000 0.392 0.028
#> GSM43010     3  0.5004     0.9663 0.392 0.000 0.604 0.004
#> GSM78522     3  0.4843     0.9629 0.396 0.000 0.604 0.000
#> GSM78525     1  0.5088    -0.7285 0.572 0.000 0.424 0.004
#> GSM78528     1  0.5671    -0.6995 0.572 0.000 0.400 0.028
#> GSM78531     1  0.4989     0.1802 0.528 0.000 0.000 0.472
#> GSM78533     3  0.5004     0.9663 0.392 0.000 0.604 0.004
#> GSM78536     1  0.4989     0.1802 0.528 0.000 0.000 0.472
#> GSM78541     1  0.4989     0.1802 0.528 0.000 0.000 0.472
#> GSM78547     1  0.4981     0.1816 0.536 0.000 0.000 0.464
#> GSM78552     1  0.6209    -0.3708 0.656 0.000 0.232 0.112
#> GSM78556     1  0.4981     0.1816 0.536 0.000 0.000 0.464
#> GSM78559     1  0.4989     0.1802 0.528 0.000 0.000 0.472
#> GSM78564     1  0.4981     0.1816 0.536 0.000 0.000 0.464
#> GSM42999     2  0.3074     0.8204 0.000 0.848 0.152 0.000
#> GSM43001     2  0.4406     0.8031 0.000 0.780 0.192 0.028
#> GSM43003     2  0.3074     0.8204 0.000 0.848 0.152 0.000
#> GSM43006     2  0.4406     0.8031 0.000 0.780 0.192 0.028
#> GSM43009     2  0.0707     0.8245 0.000 0.980 0.020 0.000
#> GSM43012     2  0.3831     0.8066 0.000 0.792 0.204 0.004
#> GSM78524     2  0.3400     0.8119 0.000 0.820 0.180 0.000
#> GSM78527     2  0.3610     0.8092 0.000 0.800 0.200 0.000
#> GSM78530     2  0.3356     0.8126 0.000 0.824 0.176 0.000
#> GSM78535     2  0.9459     0.2324 0.220 0.424 0.180 0.176
#> GSM78538     2  0.3444     0.8124 0.000 0.816 0.184 0.000
#> GSM78542     2  0.3444     0.8124 0.000 0.816 0.184 0.000
#> GSM78544     2  0.3356     0.8126 0.000 0.824 0.176 0.000
#> GSM78549     2  0.3074     0.8204 0.000 0.848 0.152 0.000
#> GSM78553     2  0.3400     0.8119 0.000 0.820 0.180 0.000
#> GSM78558     2  0.3400     0.8119 0.000 0.820 0.180 0.000
#> GSM78561     2  0.4406     0.8031 0.000 0.780 0.192 0.028

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4  0.3937      0.932 0.252 0.000 0.008 0.736 0.004
#> GSM78545     4  0.5056      0.768 0.084 0.000 0.176 0.724 0.016
#> GSM78550     4  0.5158      0.826 0.124 0.000 0.136 0.724 0.016
#> GSM78554     4  0.4537      0.930 0.236 0.000 0.024 0.724 0.016
#> GSM78562     4  0.3766      0.917 0.268 0.000 0.000 0.728 0.004
#> GSM78540     4  0.3783      0.932 0.252 0.000 0.008 0.740 0.000
#> GSM78546     4  0.4212      0.932 0.236 0.000 0.024 0.736 0.004
#> GSM78551     4  0.4212      0.932 0.236 0.000 0.024 0.736 0.004
#> GSM78555     4  0.3612      0.917 0.268 0.000 0.000 0.732 0.000
#> GSM78563     4  0.3783      0.932 0.252 0.000 0.008 0.740 0.000
#> GSM43005     3  0.0579      0.807 0.008 0.000 0.984 0.008 0.000
#> GSM43008     3  0.1893      0.794 0.024 0.000 0.936 0.012 0.028
#> GSM43011     3  0.5672      0.749 0.008 0.000 0.632 0.104 0.256
#> GSM78523     3  0.5672      0.749 0.008 0.000 0.632 0.104 0.256
#> GSM78526     3  0.5960      0.732 0.008 0.000 0.588 0.116 0.288
#> GSM78529     3  0.0579      0.807 0.008 0.000 0.984 0.008 0.000
#> GSM78532     1  0.0963      0.956 0.964 0.000 0.036 0.000 0.000
#> GSM78534     3  0.7881      0.584 0.140 0.000 0.424 0.132 0.304
#> GSM78537     1  0.0963      0.956 0.964 0.000 0.036 0.000 0.000
#> GSM78543     1  0.0963      0.956 0.964 0.000 0.036 0.000 0.000
#> GSM78548     3  0.1455      0.801 0.008 0.000 0.952 0.008 0.032
#> GSM78557     1  0.1661      0.946 0.940 0.000 0.036 0.000 0.024
#> GSM78560     1  0.1124      0.955 0.960 0.000 0.036 0.000 0.004
#> GSM78565     1  0.0963      0.956 0.964 0.000 0.036 0.000 0.000
#> GSM43000     3  0.1200      0.809 0.008 0.000 0.964 0.016 0.012
#> GSM43002     3  0.0290      0.809 0.008 0.000 0.992 0.000 0.000
#> GSM43004     1  0.6558      0.515 0.632 0.000 0.148 0.128 0.092
#> GSM43007     3  0.1483      0.801 0.008 0.000 0.952 0.012 0.028
#> GSM43010     3  0.5960      0.732 0.008 0.000 0.588 0.116 0.288
#> GSM78522     3  0.6369      0.719 0.016 0.000 0.548 0.132 0.304
#> GSM78525     3  0.0290      0.809 0.008 0.000 0.992 0.000 0.000
#> GSM78528     3  0.0579      0.807 0.008 0.000 0.984 0.008 0.000
#> GSM78531     1  0.0963      0.956 0.964 0.000 0.036 0.000 0.000
#> GSM78533     3  0.5960      0.732 0.008 0.000 0.588 0.116 0.288
#> GSM78536     1  0.0963      0.956 0.964 0.000 0.036 0.000 0.000
#> GSM78541     1  0.0963      0.956 0.964 0.000 0.036 0.000 0.000
#> GSM78547     1  0.1661      0.946 0.940 0.000 0.036 0.000 0.024
#> GSM78552     3  0.4159      0.639 0.172 0.000 0.780 0.012 0.036
#> GSM78556     1  0.1661      0.946 0.940 0.000 0.036 0.000 0.024
#> GSM78559     1  0.0963      0.956 0.964 0.000 0.036 0.000 0.000
#> GSM78564     1  0.1911      0.940 0.932 0.000 0.036 0.004 0.028
#> GSM42999     5  0.4256      0.835 0.000 0.436 0.000 0.000 0.564
#> GSM43001     5  0.6448      0.790 0.028 0.336 0.000 0.104 0.532
#> GSM43003     5  0.4256      0.835 0.000 0.436 0.000 0.000 0.564
#> GSM43006     5  0.6448      0.790 0.028 0.336 0.000 0.104 0.532
#> GSM43009     2  0.4118     -0.238 0.000 0.660 0.004 0.000 0.336
#> GSM43012     5  0.4438      0.843 0.000 0.384 0.004 0.004 0.608
#> GSM78524     2  0.1404      0.807 0.008 0.956 0.004 0.028 0.004
#> GSM78527     5  0.4219      0.844 0.000 0.416 0.000 0.000 0.584
#> GSM78530     2  0.0000      0.835 0.000 1.000 0.000 0.000 0.000
#> GSM78535     2  0.4501      0.447 0.256 0.712 0.004 0.024 0.004
#> GSM78538     2  0.0162      0.834 0.000 0.996 0.000 0.000 0.004
#> GSM78542     2  0.0162      0.834 0.000 0.996 0.000 0.000 0.004
#> GSM78544     2  0.0162      0.833 0.000 0.996 0.004 0.000 0.000
#> GSM78549     5  0.4256      0.835 0.000 0.436 0.000 0.000 0.564
#> GSM78553     2  0.0324      0.834 0.004 0.992 0.000 0.004 0.000
#> GSM78558     2  0.0324      0.834 0.004 0.992 0.000 0.004 0.000
#> GSM78561     5  0.6448      0.790 0.028 0.336 0.000 0.104 0.532

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM78539     4  0.2468     0.9555 0.096 0.000 0.008 0.880 0.016 0.000
#> GSM78545     4  0.3536     0.9005 0.036 0.000 0.104 0.828 0.028 0.004
#> GSM78550     4  0.3463     0.9054 0.040 0.000 0.104 0.828 0.028 0.000
#> GSM78554     4  0.3414     0.9431 0.084 0.000 0.052 0.836 0.028 0.000
#> GSM78562     4  0.2565     0.9515 0.104 0.000 0.008 0.872 0.016 0.000
#> GSM78540     4  0.2020     0.9551 0.096 0.000 0.000 0.896 0.008 0.000
#> GSM78546     4  0.2309     0.9546 0.084 0.000 0.028 0.888 0.000 0.000
#> GSM78551     4  0.2600     0.9529 0.084 0.000 0.036 0.876 0.004 0.000
#> GSM78555     4  0.2118     0.9504 0.104 0.000 0.000 0.888 0.008 0.000
#> GSM78563     4  0.2020     0.9551 0.096 0.000 0.000 0.896 0.008 0.000
#> GSM43005     3  0.3789     0.8851 0.000 0.000 0.660 0.008 0.000 0.332
#> GSM43008     3  0.4554     0.8454 0.008 0.000 0.684 0.008 0.040 0.260
#> GSM43011     6  0.1285     0.8431 0.000 0.000 0.052 0.000 0.004 0.944
#> GSM78523     6  0.1285     0.8431 0.000 0.000 0.052 0.000 0.004 0.944
#> GSM78526     6  0.0000     0.8823 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78529     3  0.4289     0.8843 0.000 0.000 0.640 0.008 0.020 0.332
#> GSM78532     1  0.0146     0.9470 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM78534     6  0.4764     0.6824 0.100 0.000 0.068 0.020 0.052 0.760
#> GSM78537     1  0.0000     0.9472 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78543     1  0.0260     0.9467 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM78548     3  0.4668     0.8549 0.000 0.000 0.652 0.008 0.056 0.284
#> GSM78557     1  0.1720     0.9280 0.928 0.000 0.032 0.000 0.040 0.000
#> GSM78560     1  0.0713     0.9424 0.972 0.000 0.000 0.000 0.028 0.000
#> GSM78565     1  0.0363     0.9464 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM43000     3  0.4123     0.7887 0.000 0.000 0.568 0.000 0.012 0.420
#> GSM43002     3  0.3833     0.8804 0.000 0.000 0.648 0.000 0.008 0.344
#> GSM43004     1  0.5746     0.5940 0.660 0.000 0.068 0.020 0.068 0.184
#> GSM43007     3  0.4354     0.8507 0.000 0.000 0.684 0.008 0.040 0.268
#> GSM43010     6  0.0000     0.8823 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78522     6  0.3039     0.7951 0.000 0.000 0.068 0.020 0.052 0.860
#> GSM78525     3  0.3927     0.8795 0.000 0.000 0.644 0.000 0.012 0.344
#> GSM78528     3  0.4289     0.8843 0.000 0.000 0.640 0.008 0.020 0.332
#> GSM78531     1  0.0000     0.9472 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78533     6  0.0000     0.8823 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78536     1  0.0363     0.9464 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM78541     1  0.0363     0.9464 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM78547     1  0.1720     0.9280 0.928 0.000 0.032 0.000 0.040 0.000
#> GSM78552     3  0.5312     0.7086 0.084 0.000 0.692 0.008 0.052 0.164
#> GSM78556     1  0.1720     0.9280 0.928 0.000 0.032 0.000 0.040 0.000
#> GSM78559     1  0.0260     0.9467 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM78564     1  0.2308     0.9043 0.892 0.000 0.068 0.000 0.040 0.000
#> GSM42999     2  0.2378     0.7635 0.000 0.848 0.000 0.000 0.152 0.000
#> GSM43001     2  0.2907     0.7242 0.000 0.828 0.152 0.020 0.000 0.000
#> GSM43003     2  0.2378     0.7635 0.000 0.848 0.000 0.000 0.152 0.000
#> GSM43006     2  0.2907     0.7242 0.000 0.828 0.152 0.020 0.000 0.000
#> GSM43009     2  0.3961     0.0412 0.000 0.556 0.000 0.004 0.440 0.000
#> GSM43012     2  0.1793     0.7726 0.000 0.928 0.012 0.012 0.048 0.000
#> GSM78524     5  0.4695     0.7912 0.000 0.144 0.068 0.052 0.736 0.000
#> GSM78527     2  0.1910     0.7765 0.000 0.892 0.000 0.000 0.108 0.000
#> GSM78530     5  0.2697     0.9035 0.000 0.188 0.000 0.000 0.812 0.000
#> GSM78535     5  0.5910     0.6084 0.152 0.068 0.068 0.044 0.668 0.000
#> GSM78538     5  0.2697     0.9042 0.000 0.188 0.000 0.000 0.812 0.000
#> GSM78542     5  0.2697     0.9042 0.000 0.188 0.000 0.000 0.812 0.000
#> GSM78544     5  0.2838     0.9016 0.000 0.188 0.000 0.004 0.808 0.000
#> GSM78549     2  0.2520     0.7636 0.000 0.844 0.000 0.004 0.152 0.000
#> GSM78553     5  0.2597     0.9043 0.000 0.176 0.000 0.000 0.824 0.000
#> GSM78558     5  0.2597     0.9043 0.000 0.176 0.000 0.000 0.824 0.000
#> GSM78561     2  0.2907     0.7242 0.000 0.828 0.152 0.020 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-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 cell.type(p) agent(p) individual(p) k
#> CV:kmeans 58     2.54e-13  0.00184        0.9999 2
#> CV:kmeans 55     6.77e-14  0.00411        0.2105 3
#> CV:kmeans 32     4.18e-13  0.00408        0.3553 4
#> CV:kmeans 56     1.48e-20  0.03066        0.3427 5
#> CV:kmeans 57     8.31e-20  0.03753        0.0534 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 58 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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           0.991       0.996         0.4253 0.578   0.578
#> 3 3 0.991           0.950       0.966         0.5678 0.747   0.563
#> 4 4 1.000           0.946       0.978         0.1315 0.895   0.689
#> 5 5 0.911           0.948       0.958         0.0587 0.946   0.783
#> 6 6 0.947           0.946       0.941         0.0472 0.956   0.783

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
#> GSM78539     1    0.00      0.994 1.00 0.00
#> GSM78545     1    0.00      0.994 1.00 0.00
#> GSM78550     1    0.00      0.994 1.00 0.00
#> GSM78554     1    0.00      0.994 1.00 0.00
#> GSM78562     1    0.00      0.994 1.00 0.00
#> GSM78540     1    0.00      0.994 1.00 0.00
#> GSM78546     1    0.00      0.994 1.00 0.00
#> GSM78551     1    0.00      0.994 1.00 0.00
#> GSM78555     1    0.00      0.994 1.00 0.00
#> GSM78563     1    0.00      0.994 1.00 0.00
#> GSM43005     1    0.00      0.994 1.00 0.00
#> GSM43008     1    0.00      0.994 1.00 0.00
#> GSM43011     1    0.00      0.994 1.00 0.00
#> GSM78523     1    0.00      0.994 1.00 0.00
#> GSM78526     1    0.00      0.994 1.00 0.00
#> GSM78529     1    0.76      0.718 0.78 0.22
#> GSM78532     1    0.00      0.994 1.00 0.00
#> GSM78534     1    0.00      0.994 1.00 0.00
#> GSM78537     1    0.00      0.994 1.00 0.00
#> GSM78543     1    0.00      0.994 1.00 0.00
#> GSM78548     1    0.00      0.994 1.00 0.00
#> GSM78557     1    0.00      0.994 1.00 0.00
#> GSM78560     1    0.00      0.994 1.00 0.00
#> GSM78565     1    0.00      0.994 1.00 0.00
#> GSM43000     1    0.00      0.994 1.00 0.00
#> GSM43002     1    0.00      0.994 1.00 0.00
#> GSM43004     1    0.00      0.994 1.00 0.00
#> GSM43007     1    0.00      0.994 1.00 0.00
#> GSM43010     1    0.00      0.994 1.00 0.00
#> GSM78522     1    0.00      0.994 1.00 0.00
#> GSM78525     1    0.00      0.994 1.00 0.00
#> GSM78528     1    0.00      0.994 1.00 0.00
#> GSM78531     1    0.00      0.994 1.00 0.00
#> GSM78533     1    0.00      0.994 1.00 0.00
#> GSM78536     1    0.00      0.994 1.00 0.00
#> GSM78541     1    0.00      0.994 1.00 0.00
#> GSM78547     1    0.00      0.994 1.00 0.00
#> GSM78552     1    0.00      0.994 1.00 0.00
#> GSM78556     1    0.00      0.994 1.00 0.00
#> GSM78559     1    0.00      0.994 1.00 0.00
#> GSM78564     1    0.00      0.994 1.00 0.00
#> GSM42999     2    0.00      1.000 0.00 1.00
#> GSM43001     2    0.00      1.000 0.00 1.00
#> GSM43003     2    0.00      1.000 0.00 1.00
#> GSM43006     2    0.00      1.000 0.00 1.00
#> GSM43009     2    0.00      1.000 0.00 1.00
#> GSM43012     2    0.00      1.000 0.00 1.00
#> GSM78524     2    0.00      1.000 0.00 1.00
#> GSM78527     2    0.00      1.000 0.00 1.00
#> GSM78530     2    0.00      1.000 0.00 1.00
#> GSM78535     2    0.00      1.000 0.00 1.00
#> GSM78538     2    0.00      1.000 0.00 1.00
#> GSM78542     2    0.00      1.000 0.00 1.00
#> GSM78544     2    0.00      1.000 0.00 1.00
#> GSM78549     2    0.00      1.000 0.00 1.00
#> GSM78553     2    0.00      1.000 0.00 1.00
#> GSM78558     2    0.00      1.000 0.00 1.00
#> GSM78561     2    0.00      1.000 0.00 1.00

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     1  0.0000      0.934 1.000 0.000 0.000
#> GSM78545     3  0.6111      0.428 0.396 0.000 0.604
#> GSM78550     1  0.0000      0.934 1.000 0.000 0.000
#> GSM78554     1  0.0000      0.934 1.000 0.000 0.000
#> GSM78562     1  0.0000      0.934 1.000 0.000 0.000
#> GSM78540     1  0.0000      0.934 1.000 0.000 0.000
#> GSM78546     1  0.0000      0.934 1.000 0.000 0.000
#> GSM78551     1  0.0000      0.934 1.000 0.000 0.000
#> GSM78555     1  0.0000      0.934 1.000 0.000 0.000
#> GSM78563     1  0.0000      0.934 1.000 0.000 0.000
#> GSM43005     3  0.0000      0.972 0.000 0.000 1.000
#> GSM43008     3  0.0000      0.972 0.000 0.000 1.000
#> GSM43011     3  0.0000      0.972 0.000 0.000 1.000
#> GSM78523     3  0.0000      0.972 0.000 0.000 1.000
#> GSM78526     3  0.0000      0.972 0.000 0.000 1.000
#> GSM78529     3  0.0000      0.972 0.000 0.000 1.000
#> GSM78532     1  0.2878      0.953 0.904 0.000 0.096
#> GSM78534     3  0.0000      0.972 0.000 0.000 1.000
#> GSM78537     1  0.2878      0.953 0.904 0.000 0.096
#> GSM78543     1  0.2878      0.953 0.904 0.000 0.096
#> GSM78548     3  0.0000      0.972 0.000 0.000 1.000
#> GSM78557     1  0.2878      0.953 0.904 0.000 0.096
#> GSM78560     1  0.2878      0.953 0.904 0.000 0.096
#> GSM78565     1  0.2878      0.953 0.904 0.000 0.096
#> GSM43000     3  0.0000      0.972 0.000 0.000 1.000
#> GSM43002     3  0.0000      0.972 0.000 0.000 1.000
#> GSM43004     3  0.0747      0.959 0.016 0.000 0.984
#> GSM43007     3  0.0000      0.972 0.000 0.000 1.000
#> GSM43010     3  0.0000      0.972 0.000 0.000 1.000
#> GSM78522     3  0.0000      0.972 0.000 0.000 1.000
#> GSM78525     3  0.0000      0.972 0.000 0.000 1.000
#> GSM78528     3  0.0000      0.972 0.000 0.000 1.000
#> GSM78531     1  0.2878      0.953 0.904 0.000 0.096
#> GSM78533     3  0.0000      0.972 0.000 0.000 1.000
#> GSM78536     1  0.2878      0.953 0.904 0.000 0.096
#> GSM78541     1  0.2878      0.953 0.904 0.000 0.096
#> GSM78547     1  0.2878      0.953 0.904 0.000 0.096
#> GSM78552     3  0.2796      0.878 0.092 0.000 0.908
#> GSM78556     1  0.2878      0.953 0.904 0.000 0.096
#> GSM78559     1  0.2878      0.953 0.904 0.000 0.096
#> GSM78564     1  0.2878      0.953 0.904 0.000 0.096
#> GSM42999     2  0.0000      0.986 0.000 1.000 0.000
#> GSM43001     2  0.0000      0.986 0.000 1.000 0.000
#> GSM43003     2  0.0000      0.986 0.000 1.000 0.000
#> GSM43006     2  0.0000      0.986 0.000 1.000 0.000
#> GSM43009     2  0.0000      0.986 0.000 1.000 0.000
#> GSM43012     2  0.0000      0.986 0.000 1.000 0.000
#> GSM78524     2  0.0000      0.986 0.000 1.000 0.000
#> GSM78527     2  0.0000      0.986 0.000 1.000 0.000
#> GSM78530     2  0.0000      0.986 0.000 1.000 0.000
#> GSM78535     2  0.4702      0.724 0.212 0.788 0.000
#> GSM78538     2  0.0000      0.986 0.000 1.000 0.000
#> GSM78542     2  0.0000      0.986 0.000 1.000 0.000
#> GSM78544     2  0.0000      0.986 0.000 1.000 0.000
#> GSM78549     2  0.0000      0.986 0.000 1.000 0.000
#> GSM78553     2  0.0000      0.986 0.000 1.000 0.000
#> GSM78558     2  0.0000      0.986 0.000 1.000 0.000
#> GSM78561     2  0.0000      0.986 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     4  0.0336     0.9979 0.008 0.000 0.000 0.992
#> GSM78545     4  0.0000     0.9918 0.000 0.000 0.000 1.000
#> GSM78550     4  0.0000     0.9918 0.000 0.000 0.000 1.000
#> GSM78554     4  0.0336     0.9979 0.008 0.000 0.000 0.992
#> GSM78562     4  0.0336     0.9979 0.008 0.000 0.000 0.992
#> GSM78540     4  0.0336     0.9979 0.008 0.000 0.000 0.992
#> GSM78546     4  0.0336     0.9979 0.008 0.000 0.000 0.992
#> GSM78551     4  0.0336     0.9979 0.008 0.000 0.000 0.992
#> GSM78555     4  0.0336     0.9979 0.008 0.000 0.000 0.992
#> GSM78563     4  0.0336     0.9979 0.008 0.000 0.000 0.992
#> GSM43005     3  0.0336     0.9339 0.000 0.000 0.992 0.008
#> GSM43008     3  0.1545     0.9035 0.040 0.000 0.952 0.008
#> GSM43011     3  0.0000     0.9339 0.000 0.000 1.000 0.000
#> GSM78523     3  0.0000     0.9339 0.000 0.000 1.000 0.000
#> GSM78526     3  0.0000     0.9339 0.000 0.000 1.000 0.000
#> GSM78529     3  0.0336     0.9339 0.000 0.000 0.992 0.008
#> GSM78532     1  0.0000     0.9993 1.000 0.000 0.000 0.000
#> GSM78534     3  0.5000     0.0245 0.496 0.000 0.504 0.000
#> GSM78537     1  0.0000     0.9993 1.000 0.000 0.000 0.000
#> GSM78543     1  0.0000     0.9993 1.000 0.000 0.000 0.000
#> GSM78548     3  0.0336     0.9339 0.000 0.000 0.992 0.008
#> GSM78557     1  0.0000     0.9993 1.000 0.000 0.000 0.000
#> GSM78560     1  0.0000     0.9993 1.000 0.000 0.000 0.000
#> GSM78565     1  0.0000     0.9993 1.000 0.000 0.000 0.000
#> GSM43000     3  0.0000     0.9339 0.000 0.000 1.000 0.000
#> GSM43002     3  0.0336     0.9339 0.000 0.000 0.992 0.008
#> GSM43004     1  0.0336     0.9911 0.992 0.000 0.008 0.000
#> GSM43007     3  0.0336     0.9339 0.000 0.000 0.992 0.008
#> GSM43010     3  0.0000     0.9339 0.000 0.000 1.000 0.000
#> GSM78522     3  0.0000     0.9339 0.000 0.000 1.000 0.000
#> GSM78525     3  0.0336     0.9339 0.000 0.000 0.992 0.008
#> GSM78528     3  0.0336     0.9339 0.000 0.000 0.992 0.008
#> GSM78531     1  0.0000     0.9993 1.000 0.000 0.000 0.000
#> GSM78533     3  0.0000     0.9339 0.000 0.000 1.000 0.000
#> GSM78536     1  0.0000     0.9993 1.000 0.000 0.000 0.000
#> GSM78541     1  0.0000     0.9993 1.000 0.000 0.000 0.000
#> GSM78547     1  0.0000     0.9993 1.000 0.000 0.000 0.000
#> GSM78552     3  0.5085     0.4101 0.376 0.000 0.616 0.008
#> GSM78556     1  0.0000     0.9993 1.000 0.000 0.000 0.000
#> GSM78559     1  0.0000     0.9993 1.000 0.000 0.000 0.000
#> GSM78564     1  0.0000     0.9993 1.000 0.000 0.000 0.000
#> GSM42999     2  0.0000     0.9855 0.000 1.000 0.000 0.000
#> GSM43001     2  0.0000     0.9855 0.000 1.000 0.000 0.000
#> GSM43003     2  0.0000     0.9855 0.000 1.000 0.000 0.000
#> GSM43006     2  0.0000     0.9855 0.000 1.000 0.000 0.000
#> GSM43009     2  0.0000     0.9855 0.000 1.000 0.000 0.000
#> GSM43012     2  0.0000     0.9855 0.000 1.000 0.000 0.000
#> GSM78524     2  0.0000     0.9855 0.000 1.000 0.000 0.000
#> GSM78527     2  0.0000     0.9855 0.000 1.000 0.000 0.000
#> GSM78530     2  0.0000     0.9855 0.000 1.000 0.000 0.000
#> GSM78535     2  0.3726     0.7281 0.212 0.788 0.000 0.000
#> GSM78538     2  0.0000     0.9855 0.000 1.000 0.000 0.000
#> GSM78542     2  0.0000     0.9855 0.000 1.000 0.000 0.000
#> GSM78544     2  0.0000     0.9855 0.000 1.000 0.000 0.000
#> GSM78549     2  0.0000     0.9855 0.000 1.000 0.000 0.000
#> GSM78553     2  0.0000     0.9855 0.000 1.000 0.000 0.000
#> GSM78558     2  0.0000     0.9855 0.000 1.000 0.000 0.000
#> GSM78561     2  0.0000     0.9855 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3 p4    p5
#> GSM78539     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78545     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78550     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78554     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78562     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78540     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78546     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78551     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78555     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78563     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM43005     3  0.0000      0.962 0.000 0.000 1.000  0 0.000
#> GSM43008     3  0.0000      0.962 0.000 0.000 1.000  0 0.000
#> GSM43011     5  0.2179      0.925 0.000 0.000 0.112  0 0.888
#> GSM78523     5  0.2127      0.928 0.000 0.000 0.108  0 0.892
#> GSM78526     5  0.2074      0.930 0.000 0.000 0.104  0 0.896
#> GSM78529     3  0.0000      0.962 0.000 0.000 1.000  0 0.000
#> GSM78532     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78534     5  0.2520      0.889 0.048 0.000 0.056  0 0.896
#> GSM78537     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78543     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78548     3  0.0000      0.962 0.000 0.000 1.000  0 0.000
#> GSM78557     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78560     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78565     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM43000     3  0.3003      0.745 0.000 0.000 0.812  0 0.188
#> GSM43002     3  0.0000      0.962 0.000 0.000 1.000  0 0.000
#> GSM43004     5  0.3816      0.562 0.304 0.000 0.000  0 0.696
#> GSM43007     3  0.0000      0.962 0.000 0.000 1.000  0 0.000
#> GSM43010     5  0.2074      0.930 0.000 0.000 0.104  0 0.896
#> GSM78522     5  0.2074      0.930 0.000 0.000 0.104  0 0.896
#> GSM78525     3  0.0000      0.962 0.000 0.000 1.000  0 0.000
#> GSM78528     3  0.0000      0.962 0.000 0.000 1.000  0 0.000
#> GSM78531     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78533     5  0.2074      0.930 0.000 0.000 0.104  0 0.896
#> GSM78536     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78541     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78547     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78552     3  0.2020      0.853 0.100 0.000 0.900  0 0.000
#> GSM78556     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78559     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78564     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM42999     2  0.0000      0.941 0.000 1.000 0.000  0 0.000
#> GSM43001     2  0.0162      0.941 0.000 0.996 0.000  0 0.004
#> GSM43003     2  0.0000      0.941 0.000 1.000 0.000  0 0.000
#> GSM43006     2  0.0162      0.941 0.000 0.996 0.000  0 0.004
#> GSM43009     2  0.0000      0.941 0.000 1.000 0.000  0 0.000
#> GSM43012     2  0.0162      0.941 0.000 0.996 0.000  0 0.004
#> GSM78524     2  0.2020      0.932 0.000 0.900 0.000  0 0.100
#> GSM78527     2  0.0000      0.941 0.000 1.000 0.000  0 0.000
#> GSM78530     2  0.2020      0.932 0.000 0.900 0.000  0 0.100
#> GSM78535     2  0.5312      0.642 0.248 0.652 0.000  0 0.100
#> GSM78538     2  0.2020      0.932 0.000 0.900 0.000  0 0.100
#> GSM78542     2  0.2020      0.932 0.000 0.900 0.000  0 0.100
#> GSM78544     2  0.2020      0.932 0.000 0.900 0.000  0 0.100
#> GSM78549     2  0.0000      0.941 0.000 1.000 0.000  0 0.000
#> GSM78553     2  0.2020      0.932 0.000 0.900 0.000  0 0.100
#> GSM78558     2  0.2020      0.932 0.000 0.900 0.000  0 0.100
#> GSM78561     2  0.0162      0.941 0.000 0.996 0.000  0 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
#> GSM78539     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78545     4  0.0937      0.977 0.000 0.000 0.000 0.960 0.040 0.000
#> GSM78550     4  0.0937      0.977 0.000 0.000 0.000 0.960 0.040 0.000
#> GSM78554     4  0.0713      0.982 0.000 0.000 0.000 0.972 0.028 0.000
#> GSM78562     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78540     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78546     4  0.0260      0.989 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM78551     4  0.0260      0.989 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM78555     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78563     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM43005     3  0.0291      0.929 0.000 0.000 0.992 0.000 0.004 0.004
#> GSM43008     3  0.0858      0.927 0.000 0.000 0.968 0.000 0.028 0.004
#> GSM43011     6  0.1265      0.910 0.000 0.000 0.044 0.000 0.008 0.948
#> GSM78523     6  0.1196      0.913 0.000 0.000 0.040 0.000 0.008 0.952
#> GSM78526     6  0.0000      0.934 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78529     3  0.0777      0.929 0.000 0.000 0.972 0.000 0.024 0.004
#> GSM78532     1  0.0260      0.980 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM78534     6  0.0858      0.927 0.004 0.000 0.000 0.000 0.028 0.968
#> GSM78537     1  0.0146      0.980 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM78543     1  0.0260      0.980 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM78548     3  0.1644      0.902 0.000 0.000 0.920 0.000 0.076 0.004
#> GSM78557     1  0.1349      0.961 0.940 0.000 0.004 0.000 0.056 0.000
#> GSM78560     1  0.0000      0.980 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78565     1  0.0363      0.979 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM43000     3  0.3934      0.650 0.000 0.000 0.708 0.000 0.032 0.260
#> GSM43002     3  0.0622      0.929 0.000 0.000 0.980 0.000 0.012 0.008
#> GSM43004     6  0.3909      0.651 0.244 0.000 0.000 0.000 0.036 0.720
#> GSM43007     3  0.0858      0.927 0.000 0.000 0.968 0.000 0.028 0.004
#> GSM43010     6  0.0000      0.934 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78522     6  0.0713      0.929 0.000 0.000 0.000 0.000 0.028 0.972
#> GSM78525     3  0.1049      0.927 0.000 0.000 0.960 0.000 0.032 0.008
#> GSM78528     3  0.0777      0.929 0.000 0.000 0.972 0.000 0.024 0.004
#> GSM78531     1  0.0260      0.980 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM78533     6  0.0000      0.934 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78536     1  0.0260      0.980 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM78541     1  0.0363      0.980 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM78547     1  0.1285      0.963 0.944 0.000 0.004 0.000 0.052 0.000
#> GSM78552     3  0.3361      0.804 0.108 0.000 0.816 0.000 0.076 0.000
#> GSM78556     1  0.1349      0.961 0.940 0.000 0.004 0.000 0.056 0.000
#> GSM78559     1  0.0260      0.980 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM78564     1  0.1285      0.965 0.944 0.000 0.004 0.000 0.052 0.000
#> GSM42999     2  0.0865      0.967 0.000 0.964 0.000 0.000 0.036 0.000
#> GSM43001     2  0.0000      0.975 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43003     2  0.0865      0.967 0.000 0.964 0.000 0.000 0.036 0.000
#> GSM43006     2  0.0000      0.975 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43009     2  0.1075      0.957 0.000 0.952 0.000 0.000 0.048 0.000
#> GSM43012     2  0.0000      0.975 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78524     5  0.2664      0.960 0.000 0.184 0.000 0.000 0.816 0.000
#> GSM78527     2  0.0000      0.975 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78530     5  0.3023      0.947 0.000 0.232 0.000 0.000 0.768 0.000
#> GSM78535     5  0.3293      0.905 0.048 0.140 0.000 0.000 0.812 0.000
#> GSM78538     5  0.2793      0.969 0.000 0.200 0.000 0.000 0.800 0.000
#> GSM78542     5  0.2793      0.969 0.000 0.200 0.000 0.000 0.800 0.000
#> GSM78544     5  0.3101      0.935 0.000 0.244 0.000 0.000 0.756 0.000
#> GSM78549     2  0.0937      0.965 0.000 0.960 0.000 0.000 0.040 0.000
#> GSM78553     5  0.2793      0.969 0.000 0.200 0.000 0.000 0.800 0.000
#> GSM78558     5  0.2762      0.968 0.000 0.196 0.000 0.000 0.804 0.000
#> GSM78561     2  0.0000      0.975 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-skmeans-collect-classes

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

test_to_known_factors(res)
#>             n cell.type(p) agent(p) individual(p) k
#> CV:skmeans 58     2.54e-13  0.00184         1.000 2
#> CV:skmeans 57     1.75e-14  0.00372         0.307 3
#> CV:skmeans 56     7.77e-22  0.00848         0.469 4
#> CV:skmeans 58     2.22e-21  0.01729         0.115 5
#> CV:skmeans 58     3.27e-20  0.03468         0.110 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 58 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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.4222 0.578   0.578
#> 3 3 0.734           0.933       0.915         0.4730 0.789   0.636
#> 4 4 0.970           0.947       0.977         0.1978 0.891   0.704
#> 5 5 0.952           0.927       0.969         0.0502 0.964   0.860
#> 6 6 0.890           0.815       0.895         0.0440 0.909   0.623

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 4

There is also optional best \(k\) = 2 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
#> GSM78539     1       0          1  1  0
#> GSM78545     1       0          1  1  0
#> GSM78550     1       0          1  1  0
#> GSM78554     1       0          1  1  0
#> GSM78562     1       0          1  1  0
#> GSM78540     1       0          1  1  0
#> GSM78546     1       0          1  1  0
#> GSM78551     1       0          1  1  0
#> GSM78555     1       0          1  1  0
#> GSM78563     1       0          1  1  0
#> GSM43005     1       0          1  1  0
#> GSM43008     1       0          1  1  0
#> GSM43011     1       0          1  1  0
#> GSM78523     1       0          1  1  0
#> GSM78526     1       0          1  1  0
#> GSM78529     1       0          1  1  0
#> GSM78532     1       0          1  1  0
#> GSM78534     1       0          1  1  0
#> GSM78537     1       0          1  1  0
#> GSM78543     1       0          1  1  0
#> GSM78548     1       0          1  1  0
#> GSM78557     1       0          1  1  0
#> GSM78560     1       0          1  1  0
#> GSM78565     1       0          1  1  0
#> GSM43000     1       0          1  1  0
#> GSM43002     1       0          1  1  0
#> GSM43004     1       0          1  1  0
#> GSM43007     1       0          1  1  0
#> GSM43010     1       0          1  1  0
#> GSM78522     1       0          1  1  0
#> GSM78525     1       0          1  1  0
#> GSM78528     1       0          1  1  0
#> GSM78531     1       0          1  1  0
#> GSM78533     1       0          1  1  0
#> GSM78536     1       0          1  1  0
#> GSM78541     1       0          1  1  0
#> GSM78547     1       0          1  1  0
#> GSM78552     1       0          1  1  0
#> GSM78556     1       0          1  1  0
#> GSM78559     1       0          1  1  0
#> GSM78564     1       0          1  1  0
#> GSM42999     2       0          1  0  1
#> GSM43001     2       0          1  0  1
#> GSM43003     2       0          1  0  1
#> GSM43006     2       0          1  0  1
#> GSM43009     2       0          1  0  1
#> GSM43012     2       0          1  0  1
#> GSM78524     2       0          1  0  1
#> GSM78527     2       0          1  0  1
#> GSM78530     2       0          1  0  1
#> GSM78535     2       0          1  0  1
#> GSM78538     2       0          1  0  1
#> GSM78542     2       0          1  0  1
#> GSM78544     2       0          1  0  1
#> GSM78549     2       0          1  0  1
#> GSM78553     2       0          1  0  1
#> GSM78558     2       0          1  0  1
#> GSM78561     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1 p2    p3
#> GSM78539     1  0.5058      0.778 0.756  0 0.244
#> GSM78545     1  0.5058      0.778 0.756  0 0.244
#> GSM78550     1  0.5058      0.778 0.756  0 0.244
#> GSM78554     1  0.1031      0.893 0.976  0 0.024
#> GSM78562     1  0.2959      0.854 0.900  0 0.100
#> GSM78540     1  0.5058      0.778 0.756  0 0.244
#> GSM78546     1  0.5058      0.778 0.756  0 0.244
#> GSM78551     1  0.5058      0.778 0.756  0 0.244
#> GSM78555     1  0.5058      0.778 0.756  0 0.244
#> GSM78563     1  0.5058      0.778 0.756  0 0.244
#> GSM43005     3  0.5058      1.000 0.244  0 0.756
#> GSM43008     1  0.0000      0.903 1.000  0 0.000
#> GSM43011     3  0.5058      1.000 0.244  0 0.756
#> GSM78523     3  0.5058      1.000 0.244  0 0.756
#> GSM78526     3  0.5058      1.000 0.244  0 0.756
#> GSM78529     3  0.5058      1.000 0.244  0 0.756
#> GSM78532     1  0.0000      0.903 1.000  0 0.000
#> GSM78534     1  0.0237      0.899 0.996  0 0.004
#> GSM78537     1  0.0000      0.903 1.000  0 0.000
#> GSM78543     1  0.0000      0.903 1.000  0 0.000
#> GSM78548     1  0.0000      0.903 1.000  0 0.000
#> GSM78557     1  0.0000      0.903 1.000  0 0.000
#> GSM78560     1  0.0000      0.903 1.000  0 0.000
#> GSM78565     1  0.0000      0.903 1.000  0 0.000
#> GSM43000     3  0.5058      1.000 0.244  0 0.756
#> GSM43002     3  0.5058      1.000 0.244  0 0.756
#> GSM43004     1  0.0000      0.903 1.000  0 0.000
#> GSM43007     1  0.0000      0.903 1.000  0 0.000
#> GSM43010     3  0.5058      1.000 0.244  0 0.756
#> GSM78522     3  0.5058      1.000 0.244  0 0.756
#> GSM78525     3  0.5058      1.000 0.244  0 0.756
#> GSM78528     3  0.5098      0.995 0.248  0 0.752
#> GSM78531     1  0.0000      0.903 1.000  0 0.000
#> GSM78533     3  0.5058      1.000 0.244  0 0.756
#> GSM78536     1  0.0000      0.903 1.000  0 0.000
#> GSM78541     1  0.0000      0.903 1.000  0 0.000
#> GSM78547     1  0.0000      0.903 1.000  0 0.000
#> GSM78552     1  0.0000      0.903 1.000  0 0.000
#> GSM78556     1  0.0000      0.903 1.000  0 0.000
#> GSM78559     1  0.0000      0.903 1.000  0 0.000
#> GSM78564     1  0.0000      0.903 1.000  0 0.000
#> GSM42999     2  0.0000      1.000 0.000  1 0.000
#> GSM43001     2  0.0000      1.000 0.000  1 0.000
#> GSM43003     2  0.0000      1.000 0.000  1 0.000
#> GSM43006     2  0.0000      1.000 0.000  1 0.000
#> GSM43009     2  0.0000      1.000 0.000  1 0.000
#> GSM43012     2  0.0000      1.000 0.000  1 0.000
#> GSM78524     2  0.0000      1.000 0.000  1 0.000
#> GSM78527     2  0.0000      1.000 0.000  1 0.000
#> GSM78530     2  0.0000      1.000 0.000  1 0.000
#> GSM78535     2  0.0000      1.000 0.000  1 0.000
#> GSM78538     2  0.0000      1.000 0.000  1 0.000
#> GSM78542     2  0.0000      1.000 0.000  1 0.000
#> GSM78544     2  0.0000      1.000 0.000  1 0.000
#> GSM78549     2  0.0000      1.000 0.000  1 0.000
#> GSM78553     2  0.0000      1.000 0.000  1 0.000
#> GSM78558     2  0.0000      1.000 0.000  1 0.000
#> GSM78561     2  0.0000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1   p2    p3    p4
#> GSM78539     4  0.0000      0.987 0.000 0.00 0.000 1.000
#> GSM78545     4  0.0000      0.987 0.000 0.00 0.000 1.000
#> GSM78550     4  0.0000      0.987 0.000 0.00 0.000 1.000
#> GSM78554     4  0.2149      0.895 0.088 0.00 0.000 0.912
#> GSM78562     1  0.4948      0.225 0.560 0.00 0.000 0.440
#> GSM78540     4  0.0000      0.987 0.000 0.00 0.000 1.000
#> GSM78546     4  0.0000      0.987 0.000 0.00 0.000 1.000
#> GSM78551     4  0.0000      0.987 0.000 0.00 0.000 1.000
#> GSM78555     4  0.0000      0.987 0.000 0.00 0.000 1.000
#> GSM78563     4  0.0000      0.987 0.000 0.00 0.000 1.000
#> GSM43005     3  0.0188      0.988 0.004 0.00 0.996 0.000
#> GSM43008     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM43011     3  0.0000      0.988 0.000 0.00 1.000 0.000
#> GSM78523     3  0.0000      0.988 0.000 0.00 1.000 0.000
#> GSM78526     3  0.0000      0.988 0.000 0.00 1.000 0.000
#> GSM78529     3  0.0336      0.986 0.008 0.00 0.992 0.000
#> GSM78532     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM78534     1  0.3219      0.798 0.836 0.00 0.164 0.000
#> GSM78537     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM78543     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM78548     1  0.4406      0.591 0.700 0.00 0.300 0.000
#> GSM78557     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM78560     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM78565     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM43000     3  0.0000      0.988 0.000 0.00 1.000 0.000
#> GSM43002     3  0.0592      0.980 0.016 0.00 0.984 0.000
#> GSM43004     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM43007     1  0.2469      0.857 0.892 0.00 0.108 0.000
#> GSM43010     3  0.0000      0.988 0.000 0.00 1.000 0.000
#> GSM78522     3  0.1211      0.954 0.040 0.00 0.960 0.000
#> GSM78525     3  0.0000      0.988 0.000 0.00 1.000 0.000
#> GSM78528     3  0.1022      0.965 0.032 0.00 0.968 0.000
#> GSM78531     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM78533     3  0.0188      0.987 0.004 0.00 0.996 0.000
#> GSM78536     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM78541     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM78547     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM78552     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM78556     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM78559     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM78564     1  0.0000      0.944 1.000 0.00 0.000 0.000
#> GSM42999     2  0.0000      0.993 0.000 1.00 0.000 0.000
#> GSM43001     2  0.0000      0.993 0.000 1.00 0.000 0.000
#> GSM43003     2  0.0000      0.993 0.000 1.00 0.000 0.000
#> GSM43006     2  0.0000      0.993 0.000 1.00 0.000 0.000
#> GSM43009     2  0.0000      0.993 0.000 1.00 0.000 0.000
#> GSM43012     2  0.0000      0.993 0.000 1.00 0.000 0.000
#> GSM78524     2  0.0000      0.993 0.000 1.00 0.000 0.000
#> GSM78527     2  0.0000      0.993 0.000 1.00 0.000 0.000
#> GSM78530     2  0.0000      0.993 0.000 1.00 0.000 0.000
#> GSM78535     2  0.3247      0.873 0.060 0.88 0.000 0.060
#> GSM78538     2  0.0000      0.993 0.000 1.00 0.000 0.000
#> GSM78542     2  0.0000      0.993 0.000 1.00 0.000 0.000
#> GSM78544     2  0.0000      0.993 0.000 1.00 0.000 0.000
#> GSM78549     2  0.0000      0.993 0.000 1.00 0.000 0.000
#> GSM78553     2  0.0000      0.993 0.000 1.00 0.000 0.000
#> GSM78558     2  0.0000      0.993 0.000 1.00 0.000 0.000
#> GSM78561     2  0.0000      0.993 0.000 1.00 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4  0.0000      0.987 0.000 0.000 0.000 1.000 0.000
#> GSM78545     4  0.0000      0.987 0.000 0.000 0.000 1.000 0.000
#> GSM78550     4  0.0000      0.987 0.000 0.000 0.000 1.000 0.000
#> GSM78554     4  0.1671      0.890 0.076 0.000 0.000 0.924 0.000
#> GSM78562     1  0.4219      0.300 0.584 0.000 0.000 0.416 0.000
#> GSM78540     4  0.0000      0.987 0.000 0.000 0.000 1.000 0.000
#> GSM78546     4  0.0000      0.987 0.000 0.000 0.000 1.000 0.000
#> GSM78551     4  0.0000      0.987 0.000 0.000 0.000 1.000 0.000
#> GSM78555     4  0.0000      0.987 0.000 0.000 0.000 1.000 0.000
#> GSM78563     4  0.0000      0.987 0.000 0.000 0.000 1.000 0.000
#> GSM43005     3  0.0162      0.988 0.004 0.000 0.996 0.000 0.000
#> GSM43008     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM43011     3  0.0000      0.989 0.000 0.000 1.000 0.000 0.000
#> GSM78523     3  0.0000      0.989 0.000 0.000 1.000 0.000 0.000
#> GSM78526     3  0.0000      0.989 0.000 0.000 1.000 0.000 0.000
#> GSM78529     3  0.0290      0.985 0.008 0.000 0.992 0.000 0.000
#> GSM78532     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM78534     1  0.2732      0.795 0.840 0.000 0.160 0.000 0.000
#> GSM78537     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM78543     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM78548     1  0.3837      0.578 0.692 0.000 0.308 0.000 0.000
#> GSM78557     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM78560     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM78565     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM43000     3  0.0000      0.989 0.000 0.000 1.000 0.000 0.000
#> GSM43002     3  0.0404      0.982 0.012 0.000 0.988 0.000 0.000
#> GSM43004     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM43007     1  0.2179      0.845 0.888 0.000 0.112 0.000 0.000
#> GSM43010     3  0.0000      0.989 0.000 0.000 1.000 0.000 0.000
#> GSM78522     3  0.0963      0.954 0.036 0.000 0.964 0.000 0.000
#> GSM78525     3  0.0000      0.989 0.000 0.000 1.000 0.000 0.000
#> GSM78528     3  0.0794      0.966 0.028 0.000 0.972 0.000 0.000
#> GSM78531     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM78533     3  0.0162      0.987 0.004 0.000 0.996 0.000 0.000
#> GSM78536     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM78547     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM78552     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM78556     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM78559     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM78564     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000
#> GSM42999     2  0.4114      0.429 0.000 0.624 0.000 0.000 0.376
#> GSM43001     5  0.0000      0.992 0.000 0.000 0.000 0.000 1.000
#> GSM43003     2  0.2074      0.867 0.000 0.896 0.000 0.000 0.104
#> GSM43006     5  0.0000      0.992 0.000 0.000 0.000 0.000 1.000
#> GSM43009     2  0.0963      0.924 0.000 0.964 0.000 0.000 0.036
#> GSM43012     5  0.0000      0.992 0.000 0.000 0.000 0.000 1.000
#> GSM78524     2  0.0000      0.944 0.000 1.000 0.000 0.000 0.000
#> GSM78527     5  0.0794      0.968 0.000 0.028 0.000 0.000 0.972
#> GSM78530     2  0.0000      0.944 0.000 1.000 0.000 0.000 0.000
#> GSM78535     2  0.1697      0.879 0.060 0.932 0.000 0.008 0.000
#> GSM78538     2  0.0000      0.944 0.000 1.000 0.000 0.000 0.000
#> GSM78542     2  0.0000      0.944 0.000 1.000 0.000 0.000 0.000
#> GSM78544     2  0.0000      0.944 0.000 1.000 0.000 0.000 0.000
#> GSM78549     2  0.0162      0.942 0.000 0.996 0.000 0.000 0.004
#> GSM78553     2  0.0000      0.944 0.000 1.000 0.000 0.000 0.000
#> GSM78558     2  0.0000      0.944 0.000 1.000 0.000 0.000 0.000
#> GSM78561     5  0.0000      0.992 0.000 0.000 0.000 0.000 1.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
#> GSM78539     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78545     4  0.0363      0.915 0.000 0.000 0.012 0.988 0.000 0.000
#> GSM78550     4  0.0363      0.915 0.000 0.000 0.012 0.988 0.000 0.000
#> GSM78554     4  0.1218      0.889 0.028 0.000 0.012 0.956 0.000 0.004
#> GSM78562     4  0.4296      0.145 0.440 0.000 0.008 0.544 0.000 0.008
#> GSM78540     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78546     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78551     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78555     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78563     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM43005     3  0.0260      0.621 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM43008     3  0.4091      0.213 0.472 0.000 0.520 0.000 0.000 0.008
#> GSM43011     6  0.3659      0.745 0.000 0.000 0.364 0.000 0.000 0.636
#> GSM78523     6  0.3817      0.660 0.000 0.000 0.432 0.000 0.000 0.568
#> GSM78526     6  0.2854      0.851 0.000 0.000 0.208 0.000 0.000 0.792
#> GSM78529     3  0.0260      0.621 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM78532     1  0.0146      0.984 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM78534     6  0.2793      0.564 0.200 0.000 0.000 0.000 0.000 0.800
#> GSM78537     1  0.0146      0.984 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM78543     1  0.0146      0.984 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM78548     3  0.4229      0.311 0.436 0.000 0.548 0.000 0.000 0.016
#> GSM78557     1  0.0405      0.981 0.988 0.000 0.008 0.000 0.000 0.004
#> GSM78560     1  0.0146      0.984 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM78565     1  0.0260      0.984 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM43000     3  0.2003      0.505 0.000 0.000 0.884 0.000 0.000 0.116
#> GSM43002     3  0.0260      0.621 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM43004     1  0.0260      0.984 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM43007     3  0.4039      0.334 0.424 0.000 0.568 0.000 0.000 0.008
#> GSM43010     6  0.2854      0.851 0.000 0.000 0.208 0.000 0.000 0.792
#> GSM78522     6  0.3078      0.844 0.012 0.000 0.192 0.000 0.000 0.796
#> GSM78525     3  0.1957      0.512 0.000 0.000 0.888 0.000 0.000 0.112
#> GSM78528     3  0.0000      0.621 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM78531     1  0.0000      0.985 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78533     6  0.2964      0.851 0.004 0.000 0.204 0.000 0.000 0.792
#> GSM78536     1  0.0146      0.984 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM78541     1  0.0405      0.984 0.988 0.000 0.008 0.000 0.000 0.004
#> GSM78547     1  0.0806      0.970 0.972 0.000 0.020 0.000 0.000 0.008
#> GSM78552     1  0.1812      0.896 0.912 0.000 0.080 0.000 0.000 0.008
#> GSM78556     1  0.0520      0.980 0.984 0.000 0.008 0.000 0.000 0.008
#> GSM78559     1  0.0146      0.984 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM78564     1  0.0520      0.980 0.984 0.000 0.008 0.000 0.000 0.008
#> GSM42999     2  0.4653      0.650 0.000 0.684 0.000 0.000 0.120 0.196
#> GSM43001     5  0.0000      0.912 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM43003     2  0.3269      0.779 0.000 0.792 0.000 0.000 0.024 0.184
#> GSM43006     5  0.0000      0.912 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM43009     2  0.2762      0.792 0.000 0.804 0.000 0.000 0.000 0.196
#> GSM43012     5  0.2762      0.863 0.000 0.000 0.000 0.000 0.804 0.196
#> GSM78524     2  0.0000      0.903 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78527     5  0.3345      0.852 0.000 0.028 0.000 0.000 0.788 0.184
#> GSM78530     2  0.0000      0.903 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78535     2  0.3349      0.604 0.244 0.748 0.000 0.008 0.000 0.000
#> GSM78538     2  0.0000      0.903 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78542     2  0.0000      0.903 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78544     2  0.0363      0.900 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM78549     2  0.0260      0.901 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM78553     2  0.0000      0.903 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78558     2  0.0000      0.903 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78561     5  0.0000      0.912 0.000 0.000 0.000 0.000 1.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 cell.type(p) agent(p) individual(p) k
#> CV:pam 58     2.54e-13  0.00184        0.9999 2
#> CV:pam 58     1.80e-13  0.00263        0.3207 3
#> CV:pam 57     2.96e-22  0.01024        0.5266 4
#> CV:pam 56     1.48e-20  0.02988        0.4291 5
#> CV:pam 54     1.35e-18  0.04299        0.0587 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 58 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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.4222 0.578   0.578
#> 3 3 0.663           0.684       0.855         0.4923 0.789   0.636
#> 4 4 0.823           0.807       0.909         0.1727 0.846   0.599
#> 5 5 0.892           0.872       0.934         0.0727 0.943   0.773
#> 6 6 0.919           0.838       0.920         0.0440 0.950   0.760

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette p1 p2
#> GSM78539     1       0          1  1  0
#> GSM78545     1       0          1  1  0
#> GSM78550     1       0          1  1  0
#> GSM78554     1       0          1  1  0
#> GSM78562     1       0          1  1  0
#> GSM78540     1       0          1  1  0
#> GSM78546     1       0          1  1  0
#> GSM78551     1       0          1  1  0
#> GSM78555     1       0          1  1  0
#> GSM78563     1       0          1  1  0
#> GSM43005     1       0          1  1  0
#> GSM43008     1       0          1  1  0
#> GSM43011     1       0          1  1  0
#> GSM78523     1       0          1  1  0
#> GSM78526     1       0          1  1  0
#> GSM78529     1       0          1  1  0
#> GSM78532     1       0          1  1  0
#> GSM78534     1       0          1  1  0
#> GSM78537     1       0          1  1  0
#> GSM78543     1       0          1  1  0
#> GSM78548     1       0          1  1  0
#> GSM78557     1       0          1  1  0
#> GSM78560     1       0          1  1  0
#> GSM78565     1       0          1  1  0
#> GSM43000     1       0          1  1  0
#> GSM43002     1       0          1  1  0
#> GSM43004     1       0          1  1  0
#> GSM43007     1       0          1  1  0
#> GSM43010     1       0          1  1  0
#> GSM78522     1       0          1  1  0
#> GSM78525     1       0          1  1  0
#> GSM78528     1       0          1  1  0
#> GSM78531     1       0          1  1  0
#> GSM78533     1       0          1  1  0
#> GSM78536     1       0          1  1  0
#> GSM78541     1       0          1  1  0
#> GSM78547     1       0          1  1  0
#> GSM78552     1       0          1  1  0
#> GSM78556     1       0          1  1  0
#> GSM78559     1       0          1  1  0
#> GSM78564     1       0          1  1  0
#> GSM42999     2       0          1  0  1
#> GSM43001     2       0          1  0  1
#> GSM43003     2       0          1  0  1
#> GSM43006     2       0          1  0  1
#> GSM43009     2       0          1  0  1
#> GSM43012     2       0          1  0  1
#> GSM78524     2       0          1  0  1
#> GSM78527     2       0          1  0  1
#> GSM78530     2       0          1  0  1
#> GSM78535     2       0          1  0  1
#> GSM78538     2       0          1  0  1
#> GSM78542     2       0          1  0  1
#> GSM78544     2       0          1  0  1
#> GSM78549     2       0          1  0  1
#> GSM78553     2       0          1  0  1
#> GSM78558     2       0          1  0  1
#> GSM78561     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     1  0.3192    0.80755 0.888 0.000 0.112
#> GSM78545     1  0.2448    0.80027 0.924 0.000 0.076
#> GSM78550     1  0.2711    0.80839 0.912 0.000 0.088
#> GSM78554     1  0.4121    0.73047 0.832 0.000 0.168
#> GSM78562     1  0.3340    0.80394 0.880 0.000 0.120
#> GSM78540     1  0.3192    0.80755 0.888 0.000 0.112
#> GSM78546     1  0.2711    0.80839 0.912 0.000 0.088
#> GSM78551     1  0.2711    0.80839 0.912 0.000 0.088
#> GSM78555     1  0.6235    0.23679 0.564 0.000 0.436
#> GSM78563     1  0.3192    0.80755 0.888 0.000 0.112
#> GSM43005     3  0.6291    0.20834 0.468 0.000 0.532
#> GSM43008     3  0.6286    0.20872 0.464 0.000 0.536
#> GSM43011     3  0.6291    0.20834 0.468 0.000 0.532
#> GSM78523     3  0.6291    0.20834 0.468 0.000 0.532
#> GSM78526     3  0.3412    0.66749 0.124 0.000 0.876
#> GSM78529     1  0.6267    0.00866 0.548 0.000 0.452
#> GSM78532     3  0.1643    0.71029 0.044 0.000 0.956
#> GSM78534     3  0.1163    0.70312 0.028 0.000 0.972
#> GSM78537     3  0.1643    0.71029 0.044 0.000 0.956
#> GSM78543     3  0.1643    0.71029 0.044 0.000 0.956
#> GSM78548     3  0.6305    0.19667 0.484 0.000 0.516
#> GSM78557     3  0.2796    0.70845 0.092 0.000 0.908
#> GSM78560     3  0.1964    0.71097 0.056 0.000 0.944
#> GSM78565     3  0.1643    0.71029 0.044 0.000 0.956
#> GSM43000     3  0.6291    0.20834 0.468 0.000 0.532
#> GSM43002     3  0.6291    0.20834 0.468 0.000 0.532
#> GSM43004     3  0.0747    0.70692 0.016 0.000 0.984
#> GSM43007     3  0.6286    0.20872 0.464 0.000 0.536
#> GSM43010     3  0.2537    0.69326 0.080 0.000 0.920
#> GSM78522     3  0.1411    0.69977 0.036 0.000 0.964
#> GSM78525     3  0.6291    0.20834 0.468 0.000 0.532
#> GSM78528     1  0.6267    0.00866 0.548 0.000 0.452
#> GSM78531     3  0.1643    0.71029 0.044 0.000 0.956
#> GSM78533     3  0.2537    0.69326 0.080 0.000 0.920
#> GSM78536     3  0.1643    0.71029 0.044 0.000 0.956
#> GSM78541     3  0.1860    0.71102 0.052 0.000 0.948
#> GSM78547     3  0.2796    0.70845 0.092 0.000 0.908
#> GSM78552     3  0.6309    0.16414 0.496 0.000 0.504
#> GSM78556     3  0.2796    0.70845 0.092 0.000 0.908
#> GSM78559     3  0.1643    0.71029 0.044 0.000 0.956
#> GSM78564     3  0.1643    0.71029 0.044 0.000 0.956
#> GSM42999     2  0.0000    0.99292 0.000 1.000 0.000
#> GSM43001     2  0.0000    0.99292 0.000 1.000 0.000
#> GSM43003     2  0.0000    0.99292 0.000 1.000 0.000
#> GSM43006     2  0.0000    0.99292 0.000 1.000 0.000
#> GSM43009     2  0.0000    0.99292 0.000 1.000 0.000
#> GSM43012     2  0.0000    0.99292 0.000 1.000 0.000
#> GSM78524     2  0.2356    0.94855 0.072 0.928 0.000
#> GSM78527     2  0.0000    0.99292 0.000 1.000 0.000
#> GSM78530     2  0.0000    0.99292 0.000 1.000 0.000
#> GSM78535     2  0.2356    0.94855 0.072 0.928 0.000
#> GSM78538     2  0.0000    0.99292 0.000 1.000 0.000
#> GSM78542     2  0.0000    0.99292 0.000 1.000 0.000
#> GSM78544     2  0.0000    0.99292 0.000 1.000 0.000
#> GSM78549     2  0.0000    0.99292 0.000 1.000 0.000
#> GSM78553     2  0.0424    0.98867 0.008 0.992 0.000
#> GSM78558     2  0.0000    0.99292 0.000 1.000 0.000
#> GSM78561     2  0.0000    0.99292 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     4  0.0188      0.862 0.004 0.000 0.000 0.996
#> GSM78545     4  0.4989      0.195 0.000 0.000 0.472 0.528
#> GSM78550     4  0.3942      0.715 0.000 0.000 0.236 0.764
#> GSM78554     4  0.4867      0.692 0.032 0.000 0.232 0.736
#> GSM78562     4  0.2480      0.827 0.088 0.000 0.008 0.904
#> GSM78540     4  0.0188      0.862 0.004 0.000 0.000 0.996
#> GSM78546     4  0.0779      0.863 0.004 0.000 0.016 0.980
#> GSM78551     4  0.0779      0.863 0.004 0.000 0.016 0.980
#> GSM78555     4  0.2011      0.836 0.080 0.000 0.000 0.920
#> GSM78563     4  0.0188      0.862 0.004 0.000 0.000 0.996
#> GSM43005     3  0.1118      0.871 0.036 0.000 0.964 0.000
#> GSM43008     3  0.1474      0.867 0.052 0.000 0.948 0.000
#> GSM43011     3  0.1118      0.871 0.036 0.000 0.964 0.000
#> GSM78523     3  0.1118      0.871 0.036 0.000 0.964 0.000
#> GSM78526     3  0.4790      0.343 0.380 0.000 0.620 0.000
#> GSM78529     3  0.2281      0.783 0.000 0.000 0.904 0.096
#> GSM78532     1  0.0592      0.831 0.984 0.000 0.016 0.000
#> GSM78534     1  0.4500      0.511 0.684 0.000 0.316 0.000
#> GSM78537     1  0.0469      0.831 0.988 0.000 0.012 0.000
#> GSM78543     1  0.0524      0.831 0.988 0.000 0.008 0.004
#> GSM78548     3  0.1389      0.868 0.048 0.000 0.952 0.000
#> GSM78557     1  0.4898      0.275 0.584 0.000 0.416 0.000
#> GSM78560     1  0.0524      0.831 0.988 0.000 0.008 0.004
#> GSM78565     1  0.0524      0.831 0.988 0.000 0.008 0.004
#> GSM43000     3  0.1151      0.849 0.008 0.000 0.968 0.024
#> GSM43002     3  0.1118      0.871 0.036 0.000 0.964 0.000
#> GSM43004     1  0.4500      0.511 0.684 0.000 0.316 0.000
#> GSM43007     3  0.1474      0.867 0.052 0.000 0.948 0.000
#> GSM43010     3  0.4804      0.332 0.384 0.000 0.616 0.000
#> GSM78522     1  0.4500      0.511 0.684 0.000 0.316 0.000
#> GSM78525     3  0.1118      0.871 0.036 0.000 0.964 0.000
#> GSM78528     3  0.2281      0.783 0.000 0.000 0.904 0.096
#> GSM78531     1  0.0592      0.831 0.984 0.000 0.016 0.000
#> GSM78533     3  0.4804      0.332 0.384 0.000 0.616 0.000
#> GSM78536     1  0.0524      0.831 0.988 0.000 0.008 0.004
#> GSM78541     1  0.0524      0.831 0.988 0.000 0.008 0.004
#> GSM78547     1  0.4454      0.514 0.692 0.000 0.308 0.000
#> GSM78552     3  0.1557      0.865 0.056 0.000 0.944 0.000
#> GSM78556     1  0.4500      0.498 0.684 0.000 0.316 0.000
#> GSM78559     1  0.0524      0.831 0.988 0.000 0.008 0.004
#> GSM78564     1  0.0592      0.831 0.984 0.000 0.016 0.000
#> GSM42999     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> GSM43001     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> GSM43003     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> GSM43006     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> GSM43009     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> GSM43012     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> GSM78524     2  0.1674      0.963 0.012 0.952 0.032 0.004
#> GSM78527     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> GSM78530     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> GSM78535     2  0.1674      0.963 0.012 0.952 0.032 0.004
#> GSM78538     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> GSM78542     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> GSM78544     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> GSM78549     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> GSM78553     2  0.0376      0.990 0.004 0.992 0.000 0.004
#> GSM78558     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> GSM78561     2  0.0000      0.995 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4  0.0404     0.9352 0.000 0.000 0.012 0.988 0.000
#> GSM78545     4  0.2516     0.8565 0.000 0.000 0.140 0.860 0.000
#> GSM78550     4  0.2516     0.8565 0.000 0.000 0.140 0.860 0.000
#> GSM78554     4  0.2929     0.8205 0.000 0.000 0.180 0.820 0.000
#> GSM78562     4  0.0510     0.9333 0.000 0.000 0.016 0.984 0.000
#> GSM78540     4  0.0000     0.9354 0.000 0.000 0.000 1.000 0.000
#> GSM78546     4  0.0000     0.9354 0.000 0.000 0.000 1.000 0.000
#> GSM78551     4  0.0000     0.9354 0.000 0.000 0.000 1.000 0.000
#> GSM78555     4  0.0404     0.9352 0.000 0.000 0.012 0.988 0.000
#> GSM78563     4  0.0000     0.9354 0.000 0.000 0.000 1.000 0.000
#> GSM43005     3  0.0404     0.8610 0.012 0.000 0.988 0.000 0.000
#> GSM43008     3  0.0963     0.8512 0.036 0.000 0.964 0.000 0.000
#> GSM43011     3  0.4268    -0.0117 0.000 0.000 0.556 0.000 0.444
#> GSM78523     5  0.4283     0.1896 0.000 0.000 0.456 0.000 0.544
#> GSM78526     5  0.2890     0.8014 0.004 0.000 0.160 0.000 0.836
#> GSM78529     3  0.1522     0.8351 0.012 0.000 0.944 0.044 0.000
#> GSM78532     1  0.0000     0.9817 1.000 0.000 0.000 0.000 0.000
#> GSM78534     5  0.3238     0.8060 0.136 0.000 0.028 0.000 0.836
#> GSM78537     1  0.0000     0.9817 1.000 0.000 0.000 0.000 0.000
#> GSM78543     1  0.0000     0.9817 1.000 0.000 0.000 0.000 0.000
#> GSM78548     3  0.0510     0.8612 0.016 0.000 0.984 0.000 0.000
#> GSM78557     1  0.1270     0.9460 0.948 0.000 0.052 0.000 0.000
#> GSM78560     1  0.0000     0.9817 1.000 0.000 0.000 0.000 0.000
#> GSM78565     1  0.0000     0.9817 1.000 0.000 0.000 0.000 0.000
#> GSM43000     3  0.4273    -0.0274 0.000 0.000 0.552 0.000 0.448
#> GSM43002     3  0.0404     0.8610 0.012 0.000 0.988 0.000 0.000
#> GSM43004     5  0.2971     0.7856 0.156 0.000 0.008 0.000 0.836
#> GSM43007     3  0.0609     0.8603 0.020 0.000 0.980 0.000 0.000
#> GSM43010     5  0.3151     0.8093 0.020 0.000 0.144 0.000 0.836
#> GSM78522     5  0.3238     0.8060 0.136 0.000 0.028 0.000 0.836
#> GSM78525     3  0.0451     0.8562 0.004 0.000 0.988 0.000 0.008
#> GSM78528     3  0.1522     0.8351 0.012 0.000 0.944 0.044 0.000
#> GSM78531     1  0.0000     0.9817 1.000 0.000 0.000 0.000 0.000
#> GSM78533     5  0.2890     0.8014 0.004 0.000 0.160 0.000 0.836
#> GSM78536     1  0.0000     0.9817 1.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0000     0.9817 1.000 0.000 0.000 0.000 0.000
#> GSM78547     1  0.1478     0.9330 0.936 0.000 0.064 0.000 0.000
#> GSM78552     3  0.0963     0.8510 0.036 0.000 0.964 0.000 0.000
#> GSM78556     1  0.1341     0.9420 0.944 0.000 0.056 0.000 0.000
#> GSM78559     1  0.0000     0.9817 1.000 0.000 0.000 0.000 0.000
#> GSM78564     1  0.0404     0.9750 0.988 0.000 0.012 0.000 0.000
#> GSM42999     2  0.0000     0.9727 0.000 1.000 0.000 0.000 0.000
#> GSM43001     2  0.0000     0.9727 0.000 1.000 0.000 0.000 0.000
#> GSM43003     2  0.0000     0.9727 0.000 1.000 0.000 0.000 0.000
#> GSM43006     2  0.0000     0.9727 0.000 1.000 0.000 0.000 0.000
#> GSM43009     2  0.0404     0.9697 0.000 0.988 0.000 0.000 0.012
#> GSM43012     2  0.0000     0.9727 0.000 1.000 0.000 0.000 0.000
#> GSM78524     2  0.3163     0.8654 0.000 0.824 0.012 0.000 0.164
#> GSM78527     2  0.0000     0.9727 0.000 1.000 0.000 0.000 0.000
#> GSM78530     2  0.0703     0.9656 0.000 0.976 0.000 0.000 0.024
#> GSM78535     2  0.3163     0.8654 0.000 0.824 0.012 0.000 0.164
#> GSM78538     2  0.0000     0.9727 0.000 1.000 0.000 0.000 0.000
#> GSM78542     2  0.0000     0.9727 0.000 1.000 0.000 0.000 0.000
#> GSM78544     2  0.0510     0.9685 0.000 0.984 0.000 0.000 0.016
#> GSM78549     2  0.0000     0.9727 0.000 1.000 0.000 0.000 0.000
#> GSM78553     2  0.2074     0.9192 0.000 0.896 0.000 0.000 0.104
#> GSM78558     2  0.0963     0.9603 0.000 0.964 0.000 0.000 0.036
#> GSM78561     2  0.0000     0.9727 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM78539     4  0.0260      0.991 0.000 0.000 0.008 0.992 0.000 0.000
#> GSM78545     4  0.0260      0.991 0.000 0.000 0.008 0.992 0.000 0.000
#> GSM78550     4  0.0260      0.991 0.000 0.000 0.008 0.992 0.000 0.000
#> GSM78554     4  0.0458      0.987 0.000 0.000 0.016 0.984 0.000 0.000
#> GSM78562     4  0.0291      0.991 0.000 0.000 0.004 0.992 0.000 0.004
#> GSM78540     4  0.0000      0.993 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78546     4  0.0000      0.993 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78551     4  0.0000      0.993 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78555     4  0.0551      0.985 0.008 0.000 0.004 0.984 0.000 0.004
#> GSM78563     4  0.0000      0.993 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM43005     3  0.0260      0.855 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM43008     3  0.1753      0.803 0.084 0.000 0.912 0.000 0.000 0.004
#> GSM43011     3  0.3266      0.623 0.000 0.000 0.728 0.000 0.000 0.272
#> GSM78523     3  0.3804      0.346 0.000 0.000 0.576 0.000 0.000 0.424
#> GSM78526     6  0.1501      0.898 0.000 0.000 0.076 0.000 0.000 0.924
#> GSM78529     3  0.0881      0.850 0.000 0.000 0.972 0.012 0.008 0.008
#> GSM78532     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78534     6  0.2258      0.898 0.060 0.000 0.000 0.000 0.044 0.896
#> GSM78537     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78543     1  0.0146      0.996 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM78548     3  0.0260      0.855 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM78557     1  0.0260      0.992 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM78560     1  0.0146      0.994 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM78565     1  0.0146      0.996 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM43000     3  0.3717      0.437 0.000 0.000 0.616 0.000 0.000 0.384
#> GSM43002     3  0.0260      0.855 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM43004     6  0.2747      0.874 0.096 0.000 0.000 0.000 0.044 0.860
#> GSM43007     3  0.0363      0.854 0.012 0.000 0.988 0.000 0.000 0.000
#> GSM43010     6  0.1411      0.905 0.004 0.000 0.060 0.000 0.000 0.936
#> GSM78522     6  0.2471      0.909 0.040 0.000 0.020 0.000 0.044 0.896
#> GSM78525     3  0.0260      0.853 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM78528     3  0.0881      0.850 0.000 0.000 0.972 0.012 0.008 0.008
#> GSM78531     1  0.0146      0.996 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM78533     6  0.2048      0.857 0.000 0.000 0.120 0.000 0.000 0.880
#> GSM78536     1  0.0146      0.996 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM78541     1  0.0146      0.996 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM78547     1  0.0291      0.991 0.992 0.000 0.004 0.000 0.000 0.004
#> GSM78552     3  0.2454      0.732 0.160 0.000 0.840 0.000 0.000 0.000
#> GSM78556     1  0.0260      0.992 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM78559     1  0.0146      0.996 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM78564     1  0.0260      0.995 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM42999     2  0.0000      0.874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43001     2  0.0000      0.874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43003     2  0.0000      0.874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43006     2  0.0000      0.874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43009     2  0.0146      0.871 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM43012     2  0.0000      0.874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78524     5  0.2451      0.665 0.000 0.060 0.000 0.000 0.884 0.056
#> GSM78527     2  0.0000      0.874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78530     5  0.3592      0.693 0.000 0.344 0.000 0.000 0.656 0.000
#> GSM78535     5  0.2583      0.660 0.000 0.052 0.008 0.000 0.884 0.056
#> GSM78538     2  0.3797     -0.148 0.000 0.580 0.000 0.000 0.420 0.000
#> GSM78542     2  0.3797     -0.148 0.000 0.580 0.000 0.000 0.420 0.000
#> GSM78544     5  0.3847      0.474 0.000 0.456 0.000 0.000 0.544 0.000
#> GSM78549     2  0.0000      0.874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78553     5  0.3266      0.736 0.000 0.272 0.000 0.000 0.728 0.000
#> GSM78558     5  0.3446      0.726 0.000 0.308 0.000 0.000 0.692 0.000
#> GSM78561     2  0.0146      0.871 0.000 0.996 0.000 0.000 0.004 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 cell.type(p) agent(p) individual(p) k
#> CV:mclust 58     2.54e-13  0.00184         1.000 2
#> CV:mclust 45     1.32e-18  0.00297         0.845 3
#> CV:mclust 52     3.67e-20  0.00980         0.708 4
#> CV:mclust 55     3.81e-20  0.02134         0.201 5
#> CV:mclust 53     3.41e-18  0.06575         0.183 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 58 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 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-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           0.969       0.988         0.4230 0.578   0.578
#> 3 3 0.974           0.945       0.978         0.5878 0.724   0.534
#> 4 4 0.820           0.908       0.925         0.1120 0.889   0.675
#> 5 5 0.884           0.900       0.936         0.0622 0.939   0.761
#> 6 6 0.964           0.936       0.966         0.0484 0.941   0.722

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
#> GSM78539     1   0.000      0.990 1.000 0.000
#> GSM78545     1   0.000      0.990 1.000 0.000
#> GSM78550     1   0.000      0.990 1.000 0.000
#> GSM78554     1   0.000      0.990 1.000 0.000
#> GSM78562     1   0.000      0.990 1.000 0.000
#> GSM78540     1   0.000      0.990 1.000 0.000
#> GSM78546     1   0.000      0.990 1.000 0.000
#> GSM78551     1   0.000      0.990 1.000 0.000
#> GSM78555     1   0.000      0.990 1.000 0.000
#> GSM78563     1   0.000      0.990 1.000 0.000
#> GSM43005     1   0.000      0.990 1.000 0.000
#> GSM43008     1   0.000      0.990 1.000 0.000
#> GSM43011     1   0.000      0.990 1.000 0.000
#> GSM78523     1   0.000      0.990 1.000 0.000
#> GSM78526     1   0.000      0.990 1.000 0.000
#> GSM78529     1   0.952      0.394 0.628 0.372
#> GSM78532     1   0.000      0.990 1.000 0.000
#> GSM78534     1   0.000      0.990 1.000 0.000
#> GSM78537     1   0.000      0.990 1.000 0.000
#> GSM78543     1   0.000      0.990 1.000 0.000
#> GSM78548     1   0.000      0.990 1.000 0.000
#> GSM78557     1   0.000      0.990 1.000 0.000
#> GSM78560     1   0.000      0.990 1.000 0.000
#> GSM78565     1   0.000      0.990 1.000 0.000
#> GSM43000     1   0.000      0.990 1.000 0.000
#> GSM43002     1   0.000      0.990 1.000 0.000
#> GSM43004     1   0.000      0.990 1.000 0.000
#> GSM43007     1   0.000      0.990 1.000 0.000
#> GSM43010     1   0.000      0.990 1.000 0.000
#> GSM78522     1   0.000      0.990 1.000 0.000
#> GSM78525     1   0.000      0.990 1.000 0.000
#> GSM78528     1   0.000      0.990 1.000 0.000
#> GSM78531     1   0.000      0.990 1.000 0.000
#> GSM78533     1   0.000      0.990 1.000 0.000
#> GSM78536     1   0.000      0.990 1.000 0.000
#> GSM78541     1   0.000      0.990 1.000 0.000
#> GSM78547     1   0.000      0.990 1.000 0.000
#> GSM78552     1   0.000      0.990 1.000 0.000
#> GSM78556     1   0.000      0.990 1.000 0.000
#> GSM78559     1   0.000      0.990 1.000 0.000
#> GSM78564     1   0.000      0.990 1.000 0.000
#> GSM42999     2   0.000      0.980 0.000 1.000
#> GSM43001     2   0.000      0.980 0.000 1.000
#> GSM43003     2   0.000      0.980 0.000 1.000
#> GSM43006     2   0.000      0.980 0.000 1.000
#> GSM43009     2   0.000      0.980 0.000 1.000
#> GSM43012     2   0.000      0.980 0.000 1.000
#> GSM78524     2   0.000      0.980 0.000 1.000
#> GSM78527     2   0.000      0.980 0.000 1.000
#> GSM78530     2   0.000      0.980 0.000 1.000
#> GSM78535     2   0.900      0.532 0.316 0.684
#> GSM78538     2   0.000      0.980 0.000 1.000
#> GSM78542     2   0.000      0.980 0.000 1.000
#> GSM78544     2   0.000      0.980 0.000 1.000
#> GSM78549     2   0.000      0.980 0.000 1.000
#> GSM78553     2   0.000      0.980 0.000 1.000
#> GSM78558     2   0.000      0.980 0.000 1.000
#> GSM78561     2   0.000      0.980 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78545     3  0.6140      0.327 0.404 0.000 0.596
#> GSM78550     1  0.4702      0.709 0.788 0.000 0.212
#> GSM78554     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78562     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78540     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78546     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78551     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78555     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78563     1  0.0000      0.966 1.000 0.000 0.000
#> GSM43005     3  0.0000      0.967 0.000 0.000 1.000
#> GSM43008     3  0.0424      0.962 0.008 0.000 0.992
#> GSM43011     3  0.0000      0.967 0.000 0.000 1.000
#> GSM78523     3  0.0000      0.967 0.000 0.000 1.000
#> GSM78526     3  0.0000      0.967 0.000 0.000 1.000
#> GSM78529     3  0.0000      0.967 0.000 0.000 1.000
#> GSM78532     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78534     3  0.0000      0.967 0.000 0.000 1.000
#> GSM78537     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78543     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78548     3  0.0000      0.967 0.000 0.000 1.000
#> GSM78557     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78560     1  0.0237      0.963 0.996 0.000 0.004
#> GSM78565     1  0.0000      0.966 1.000 0.000 0.000
#> GSM43000     3  0.0000      0.967 0.000 0.000 1.000
#> GSM43002     3  0.0000      0.967 0.000 0.000 1.000
#> GSM43004     3  0.2165      0.912 0.064 0.000 0.936
#> GSM43007     3  0.0424      0.962 0.008 0.000 0.992
#> GSM43010     3  0.0000      0.967 0.000 0.000 1.000
#> GSM78522     3  0.0000      0.967 0.000 0.000 1.000
#> GSM78525     3  0.0000      0.967 0.000 0.000 1.000
#> GSM78528     3  0.0000      0.967 0.000 0.000 1.000
#> GSM78531     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78533     3  0.0000      0.967 0.000 0.000 1.000
#> GSM78536     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78541     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78547     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78552     3  0.2356      0.906 0.072 0.000 0.928
#> GSM78556     1  0.0237      0.963 0.996 0.000 0.004
#> GSM78559     1  0.0000      0.966 1.000 0.000 0.000
#> GSM78564     1  0.3412      0.841 0.876 0.000 0.124
#> GSM42999     2  0.0000      0.998 0.000 1.000 0.000
#> GSM43001     2  0.0000      0.998 0.000 1.000 0.000
#> GSM43003     2  0.0000      0.998 0.000 1.000 0.000
#> GSM43006     2  0.0000      0.998 0.000 1.000 0.000
#> GSM43009     2  0.0000      0.998 0.000 1.000 0.000
#> GSM43012     2  0.0000      0.998 0.000 1.000 0.000
#> GSM78524     2  0.1163      0.970 0.028 0.972 0.000
#> GSM78527     2  0.0000      0.998 0.000 1.000 0.000
#> GSM78530     2  0.0000      0.998 0.000 1.000 0.000
#> GSM78535     1  0.5988      0.413 0.632 0.368 0.000
#> GSM78538     2  0.0000      0.998 0.000 1.000 0.000
#> GSM78542     2  0.0000      0.998 0.000 1.000 0.000
#> GSM78544     2  0.0000      0.998 0.000 1.000 0.000
#> GSM78549     2  0.0000      0.998 0.000 1.000 0.000
#> GSM78553     2  0.0000      0.998 0.000 1.000 0.000
#> GSM78558     2  0.0000      0.998 0.000 1.000 0.000
#> GSM78561     2  0.0000      0.998 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     4  0.3486    0.96924 0.188 0.000 0.000 0.812
#> GSM78545     4  0.4362    0.86456 0.096 0.000 0.088 0.816
#> GSM78550     4  0.4010    0.94212 0.156 0.000 0.028 0.816
#> GSM78554     4  0.3486    0.96924 0.188 0.000 0.000 0.812
#> GSM78562     4  0.3610    0.96087 0.200 0.000 0.000 0.800
#> GSM78540     4  0.3486    0.96924 0.188 0.000 0.000 0.812
#> GSM78546     4  0.3486    0.96924 0.188 0.000 0.000 0.812
#> GSM78551     4  0.3444    0.96728 0.184 0.000 0.000 0.816
#> GSM78555     4  0.4008    0.91214 0.244 0.000 0.000 0.756
#> GSM78563     4  0.3486    0.96924 0.188 0.000 0.000 0.812
#> GSM43005     3  0.0188    0.95564 0.000 0.000 0.996 0.004
#> GSM43008     3  0.3266    0.81600 0.168 0.000 0.832 0.000
#> GSM43011     3  0.0188    0.95705 0.000 0.000 0.996 0.004
#> GSM78523     3  0.0188    0.95705 0.000 0.000 0.996 0.004
#> GSM78526     3  0.0188    0.95705 0.000 0.000 0.996 0.004
#> GSM78529     3  0.2469    0.88395 0.000 0.000 0.892 0.108
#> GSM78532     1  0.0000    0.93012 1.000 0.000 0.000 0.000
#> GSM78534     3  0.2831    0.85834 0.120 0.000 0.876 0.004
#> GSM78537     1  0.0000    0.93012 1.000 0.000 0.000 0.000
#> GSM78543     1  0.0000    0.93012 1.000 0.000 0.000 0.000
#> GSM78548     3  0.0524    0.95421 0.004 0.000 0.988 0.008
#> GSM78557     1  0.0000    0.93012 1.000 0.000 0.000 0.000
#> GSM78560     1  0.0000    0.93012 1.000 0.000 0.000 0.000
#> GSM78565     1  0.0000    0.93012 1.000 0.000 0.000 0.000
#> GSM43000     3  0.0000    0.95665 0.000 0.000 1.000 0.000
#> GSM43002     3  0.0000    0.95665 0.000 0.000 1.000 0.000
#> GSM43004     1  0.3539    0.70572 0.820 0.000 0.176 0.004
#> GSM43007     3  0.1118    0.93806 0.036 0.000 0.964 0.000
#> GSM43010     3  0.0188    0.95705 0.000 0.000 0.996 0.004
#> GSM78522     3  0.0188    0.95705 0.000 0.000 0.996 0.004
#> GSM78525     3  0.0000    0.95665 0.000 0.000 1.000 0.000
#> GSM78528     3  0.0707    0.94907 0.000 0.000 0.980 0.020
#> GSM78531     1  0.0000    0.93012 1.000 0.000 0.000 0.000
#> GSM78533     3  0.0188    0.95705 0.000 0.000 0.996 0.004
#> GSM78536     1  0.0000    0.93012 1.000 0.000 0.000 0.000
#> GSM78541     1  0.0000    0.93012 1.000 0.000 0.000 0.000
#> GSM78547     1  0.0000    0.93012 1.000 0.000 0.000 0.000
#> GSM78552     3  0.3402    0.81952 0.164 0.000 0.832 0.004
#> GSM78556     1  0.0000    0.93012 1.000 0.000 0.000 0.000
#> GSM78559     1  0.0000    0.93012 1.000 0.000 0.000 0.000
#> GSM78564     1  0.0779    0.90981 0.980 0.000 0.016 0.004
#> GSM42999     2  0.0817    0.93456 0.000 0.976 0.000 0.024
#> GSM43001     2  0.3400    0.88303 0.000 0.820 0.000 0.180
#> GSM43003     2  0.0000    0.93879 0.000 1.000 0.000 0.000
#> GSM43006     2  0.3400    0.88303 0.000 0.820 0.000 0.180
#> GSM43009     2  0.0000    0.93879 0.000 1.000 0.000 0.000
#> GSM43012     2  0.3172    0.89136 0.000 0.840 0.000 0.160
#> GSM78524     2  0.3074    0.78831 0.152 0.848 0.000 0.000
#> GSM78527     2  0.3356    0.88490 0.000 0.824 0.000 0.176
#> GSM78530     2  0.0000    0.93879 0.000 1.000 0.000 0.000
#> GSM78535     1  0.5000    0.00235 0.500 0.500 0.000 0.000
#> GSM78538     2  0.0000    0.93879 0.000 1.000 0.000 0.000
#> GSM78542     2  0.0000    0.93879 0.000 1.000 0.000 0.000
#> GSM78544     2  0.0000    0.93879 0.000 1.000 0.000 0.000
#> GSM78549     2  0.0336    0.93786 0.000 0.992 0.000 0.008
#> GSM78553     2  0.0000    0.93879 0.000 1.000 0.000 0.000
#> GSM78558     2  0.0000    0.93879 0.000 1.000 0.000 0.000
#> GSM78561     2  0.3400    0.88303 0.000 0.820 0.000 0.180

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4  0.0000      0.978 0.000 0.000 0.000 1.000 0.000
#> GSM78545     4  0.0510      0.973 0.000 0.000 0.000 0.984 0.016
#> GSM78550     4  0.0510      0.973 0.000 0.000 0.000 0.984 0.016
#> GSM78554     4  0.0404      0.974 0.000 0.000 0.000 0.988 0.012
#> GSM78562     4  0.0703      0.963 0.024 0.000 0.000 0.976 0.000
#> GSM78540     4  0.0404      0.972 0.000 0.012 0.000 0.988 0.000
#> GSM78546     4  0.0000      0.978 0.000 0.000 0.000 1.000 0.000
#> GSM78551     4  0.0000      0.978 0.000 0.000 0.000 1.000 0.000
#> GSM78555     4  0.1608      0.910 0.072 0.000 0.000 0.928 0.000
#> GSM78563     4  0.0290      0.975 0.000 0.008 0.000 0.992 0.000
#> GSM43005     3  0.2723      0.882 0.000 0.000 0.864 0.012 0.124
#> GSM43008     3  0.5367      0.738 0.168 0.000 0.696 0.012 0.124
#> GSM43011     3  0.0000      0.904 0.000 0.000 1.000 0.000 0.000
#> GSM78523     3  0.0000      0.904 0.000 0.000 1.000 0.000 0.000
#> GSM78526     3  0.0000      0.904 0.000 0.000 1.000 0.000 0.000
#> GSM78529     5  0.4249      0.238 0.000 0.000 0.296 0.016 0.688
#> GSM78532     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> GSM78534     3  0.0703      0.892 0.024 0.000 0.976 0.000 0.000
#> GSM78537     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> GSM78543     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> GSM78548     3  0.3741      0.856 0.000 0.000 0.816 0.076 0.108
#> GSM78557     1  0.0510      0.963 0.984 0.000 0.000 0.000 0.016
#> GSM78560     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> GSM78565     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> GSM43000     3  0.0794      0.905 0.000 0.000 0.972 0.000 0.028
#> GSM43002     3  0.2074      0.893 0.000 0.000 0.896 0.000 0.104
#> GSM43004     1  0.3586      0.641 0.736 0.000 0.264 0.000 0.000
#> GSM43007     3  0.3976      0.860 0.048 0.000 0.812 0.016 0.124
#> GSM43010     3  0.0000      0.904 0.000 0.000 1.000 0.000 0.000
#> GSM78522     3  0.0000      0.904 0.000 0.000 1.000 0.000 0.000
#> GSM78525     3  0.1965      0.895 0.000 0.000 0.904 0.000 0.096
#> GSM78528     3  0.3696      0.831 0.000 0.000 0.772 0.016 0.212
#> GSM78531     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> GSM78533     3  0.0000      0.904 0.000 0.000 1.000 0.000 0.000
#> GSM78536     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> GSM78547     1  0.0510      0.963 0.984 0.000 0.000 0.000 0.016
#> GSM78552     3  0.5650      0.776 0.108 0.000 0.708 0.056 0.128
#> GSM78556     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> GSM78559     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> GSM78564     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> GSM42999     2  0.1544      0.904 0.000 0.932 0.000 0.000 0.068
#> GSM43001     5  0.2648      0.810 0.000 0.152 0.000 0.000 0.848
#> GSM43003     2  0.0703      0.948 0.000 0.976 0.000 0.000 0.024
#> GSM43006     5  0.2852      0.812 0.000 0.172 0.000 0.000 0.828
#> GSM43009     2  0.0404      0.954 0.000 0.988 0.000 0.000 0.012
#> GSM43012     5  0.4015      0.623 0.000 0.348 0.000 0.000 0.652
#> GSM78524     2  0.0771      0.943 0.020 0.976 0.000 0.004 0.000
#> GSM78527     5  0.3508      0.763 0.000 0.252 0.000 0.000 0.748
#> GSM78530     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000
#> GSM78535     2  0.2674      0.791 0.120 0.868 0.000 0.012 0.000
#> GSM78538     2  0.0162      0.958 0.000 0.996 0.000 0.004 0.000
#> GSM78542     2  0.0162      0.958 0.000 0.996 0.000 0.004 0.000
#> GSM78544     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000
#> GSM78549     2  0.1043      0.936 0.000 0.960 0.000 0.000 0.040
#> GSM78553     2  0.0404      0.955 0.000 0.988 0.000 0.012 0.000
#> GSM78558     2  0.0404      0.955 0.000 0.988 0.000 0.012 0.000
#> GSM78561     5  0.2732      0.812 0.000 0.160 0.000 0.000 0.840

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM78539     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78545     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78550     4  0.0363      0.986 0.000 0.000 0.012 0.988 0.000 0.000
#> GSM78554     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78562     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78540     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78546     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78551     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78555     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78563     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM43005     3  0.1663      0.931 0.000 0.000 0.912 0.000 0.000 0.088
#> GSM43008     3  0.0937      0.934 0.000 0.000 0.960 0.000 0.000 0.040
#> GSM43011     6  0.0000      0.942 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78523     6  0.0000      0.942 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78526     6  0.0000      0.942 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78529     3  0.1074      0.926 0.000 0.000 0.960 0.000 0.012 0.028
#> GSM78532     1  0.0363      0.977 0.988 0.000 0.012 0.000 0.000 0.000
#> GSM78534     6  0.0000      0.942 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78537     1  0.0458      0.976 0.984 0.000 0.016 0.000 0.000 0.000
#> GSM78543     1  0.0146      0.978 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM78548     3  0.2527      0.880 0.000 0.000 0.832 0.000 0.000 0.168
#> GSM78557     1  0.1765      0.911 0.904 0.000 0.096 0.000 0.000 0.000
#> GSM78560     1  0.0260      0.978 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM78565     1  0.0000      0.977 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM43000     6  0.1663      0.855 0.000 0.000 0.088 0.000 0.000 0.912
#> GSM43002     3  0.2048      0.918 0.000 0.000 0.880 0.000 0.000 0.120
#> GSM43004     6  0.3288      0.599 0.276 0.000 0.000 0.000 0.000 0.724
#> GSM43007     3  0.1141      0.936 0.000 0.000 0.948 0.000 0.000 0.052
#> GSM43010     6  0.0000      0.942 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78522     6  0.0000      0.942 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78525     3  0.2854      0.834 0.000 0.000 0.792 0.000 0.000 0.208
#> GSM78528     3  0.0603      0.919 0.000 0.000 0.980 0.000 0.004 0.016
#> GSM78531     1  0.0146      0.978 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM78533     6  0.0000      0.942 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78536     1  0.0000      0.977 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0146      0.978 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM78547     1  0.1714      0.915 0.908 0.000 0.092 0.000 0.000 0.000
#> GSM78552     3  0.1082      0.934 0.004 0.000 0.956 0.000 0.000 0.040
#> GSM78556     1  0.0790      0.966 0.968 0.000 0.032 0.000 0.000 0.000
#> GSM78559     1  0.0000      0.977 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78564     1  0.0146      0.978 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM42999     2  0.1141      0.931 0.000 0.948 0.000 0.000 0.052 0.000
#> GSM43001     5  0.0000      0.879 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM43003     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43006     5  0.0146      0.880 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM43009     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43012     5  0.0713      0.872 0.000 0.028 0.000 0.000 0.972 0.000
#> GSM78524     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78527     5  0.3717      0.377 0.000 0.384 0.000 0.000 0.616 0.000
#> GSM78530     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78535     2  0.1910      0.843 0.108 0.892 0.000 0.000 0.000 0.000
#> GSM78538     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78542     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78544     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78549     2  0.0146      0.978 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM78553     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78558     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78561     5  0.0000      0.879 0.000 0.000 0.000 0.000 1.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 cell.type(p) agent(p) individual(p) k
#> CV:NMF 57     4.19e-13  0.00243        0.9999 2
#> CV:NMF 56     3.19e-14  0.00495        0.2677 3
#> CV:NMF 57     2.96e-22  0.01039        0.4111 4
#> CV:NMF 57     5.72e-21  0.02302        0.4047 5
#> CV:NMF 57     8.31e-20  0.04734        0.0885 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 58 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.805           0.949       0.970         0.3798 0.593   0.593
#> 3 3 0.534           0.832       0.895         0.6926 0.734   0.551
#> 4 4 0.639           0.747       0.874         0.0566 0.989   0.965
#> 5 5 0.603           0.742       0.840         0.0483 0.983   0.946
#> 6 6 0.700           0.719       0.758         0.1018 0.868   0.573

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
#> GSM78539     1   0.000      0.995 1.000 0.000
#> GSM78545     1   0.000      0.995 1.000 0.000
#> GSM78550     1   0.000      0.995 1.000 0.000
#> GSM78554     1   0.000      0.995 1.000 0.000
#> GSM78562     1   0.000      0.995 1.000 0.000
#> GSM78540     1   0.000      0.995 1.000 0.000
#> GSM78546     1   0.000      0.995 1.000 0.000
#> GSM78551     1   0.000      0.995 1.000 0.000
#> GSM78555     1   0.000      0.995 1.000 0.000
#> GSM78563     1   0.000      0.995 1.000 0.000
#> GSM43005     1   0.000      0.995 1.000 0.000
#> GSM43008     1   0.000      0.995 1.000 0.000
#> GSM43011     1   0.000      0.995 1.000 0.000
#> GSM78523     1   0.000      0.995 1.000 0.000
#> GSM78526     1   0.000      0.995 1.000 0.000
#> GSM78529     1   0.000      0.995 1.000 0.000
#> GSM78532     1   0.000      0.995 1.000 0.000
#> GSM78534     1   0.000      0.995 1.000 0.000
#> GSM78537     1   0.000      0.995 1.000 0.000
#> GSM78543     1   0.000      0.995 1.000 0.000
#> GSM78548     1   0.000      0.995 1.000 0.000
#> GSM78557     1   0.000      0.995 1.000 0.000
#> GSM78560     1   0.000      0.995 1.000 0.000
#> GSM78565     1   0.000      0.995 1.000 0.000
#> GSM43000     1   0.000      0.995 1.000 0.000
#> GSM43002     1   0.000      0.995 1.000 0.000
#> GSM43004     1   0.000      0.995 1.000 0.000
#> GSM43007     1   0.000      0.995 1.000 0.000
#> GSM43010     1   0.000      0.995 1.000 0.000
#> GSM78522     1   0.000      0.995 1.000 0.000
#> GSM78525     1   0.000      0.995 1.000 0.000
#> GSM78528     1   0.000      0.995 1.000 0.000
#> GSM78531     1   0.000      0.995 1.000 0.000
#> GSM78533     1   0.000      0.995 1.000 0.000
#> GSM78536     1   0.000      0.995 1.000 0.000
#> GSM78541     1   0.000      0.995 1.000 0.000
#> GSM78547     1   0.000      0.995 1.000 0.000
#> GSM78552     1   0.000      0.995 1.000 0.000
#> GSM78556     1   0.000      0.995 1.000 0.000
#> GSM78559     1   0.000      0.995 1.000 0.000
#> GSM78564     1   0.000      0.995 1.000 0.000
#> GSM42999     2   0.000      0.893 0.000 1.000
#> GSM43001     2   0.000      0.893 0.000 1.000
#> GSM43003     2   0.000      0.893 0.000 1.000
#> GSM43006     2   0.000      0.893 0.000 1.000
#> GSM43009     2   0.000      0.893 0.000 1.000
#> GSM43012     2   0.000      0.893 0.000 1.000
#> GSM78524     2   0.981      0.420 0.420 0.580
#> GSM78527     2   0.000      0.893 0.000 1.000
#> GSM78530     2   0.697      0.839 0.188 0.812
#> GSM78535     1   0.671      0.750 0.824 0.176
#> GSM78538     2   0.697      0.839 0.188 0.812
#> GSM78542     2   0.697      0.839 0.188 0.812
#> GSM78544     2   0.697      0.839 0.188 0.812
#> GSM78549     2   0.000      0.893 0.000 1.000
#> GSM78553     2   0.697      0.839 0.188 0.812
#> GSM78558     2   0.697      0.839 0.188 0.812
#> GSM78561     2   0.000      0.893 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     1  0.0892      0.820 0.980 0.000 0.020
#> GSM78545     1  0.4654      0.743 0.792 0.000 0.208
#> GSM78550     1  0.3551      0.809 0.868 0.000 0.132
#> GSM78554     1  0.3340      0.816 0.880 0.000 0.120
#> GSM78562     1  0.0892      0.820 0.980 0.000 0.020
#> GSM78540     1  0.0892      0.820 0.980 0.000 0.020
#> GSM78546     1  0.3116      0.820 0.892 0.000 0.108
#> GSM78551     1  0.3551      0.809 0.868 0.000 0.132
#> GSM78555     1  0.0892      0.820 0.980 0.000 0.020
#> GSM78563     1  0.0892      0.820 0.980 0.000 0.020
#> GSM43005     3  0.0000      0.913 0.000 0.000 1.000
#> GSM43008     3  0.0000      0.913 0.000 0.000 1.000
#> GSM43011     3  0.0000      0.913 0.000 0.000 1.000
#> GSM78523     3  0.0000      0.913 0.000 0.000 1.000
#> GSM78526     3  0.0000      0.913 0.000 0.000 1.000
#> GSM78529     3  0.0000      0.913 0.000 0.000 1.000
#> GSM78532     1  0.4796      0.819 0.780 0.000 0.220
#> GSM78534     3  0.0000      0.913 0.000 0.000 1.000
#> GSM78537     1  0.4750      0.822 0.784 0.000 0.216
#> GSM78543     1  0.5098      0.796 0.752 0.000 0.248
#> GSM78548     3  0.4178      0.760 0.172 0.000 0.828
#> GSM78557     3  0.5016      0.679 0.240 0.000 0.760
#> GSM78560     1  0.5529      0.736 0.704 0.000 0.296
#> GSM78565     1  0.4750      0.822 0.784 0.000 0.216
#> GSM43000     3  0.0000      0.913 0.000 0.000 1.000
#> GSM43002     3  0.0000      0.913 0.000 0.000 1.000
#> GSM43004     3  0.0000      0.913 0.000 0.000 1.000
#> GSM43007     3  0.0000      0.913 0.000 0.000 1.000
#> GSM43010     3  0.0000      0.913 0.000 0.000 1.000
#> GSM78522     3  0.0000      0.913 0.000 0.000 1.000
#> GSM78525     3  0.0000      0.913 0.000 0.000 1.000
#> GSM78528     3  0.0000      0.913 0.000 0.000 1.000
#> GSM78531     1  0.4796      0.819 0.780 0.000 0.220
#> GSM78533     3  0.0000      0.913 0.000 0.000 1.000
#> GSM78536     1  0.4750      0.822 0.784 0.000 0.216
#> GSM78541     1  0.4750      0.822 0.784 0.000 0.216
#> GSM78547     3  0.5016      0.679 0.240 0.000 0.760
#> GSM78552     3  0.5016      0.679 0.240 0.000 0.760
#> GSM78556     3  0.5016      0.679 0.240 0.000 0.760
#> GSM78559     1  0.4750      0.822 0.784 0.000 0.216
#> GSM78564     3  0.5178      0.648 0.256 0.000 0.744
#> GSM42999     2  0.0000      0.888 0.000 1.000 0.000
#> GSM43001     2  0.0000      0.888 0.000 1.000 0.000
#> GSM43003     2  0.0000      0.888 0.000 1.000 0.000
#> GSM43006     2  0.0000      0.888 0.000 1.000 0.000
#> GSM43009     2  0.0000      0.888 0.000 1.000 0.000
#> GSM43012     2  0.0000      0.888 0.000 1.000 0.000
#> GSM78524     2  0.6244      0.408 0.440 0.560 0.000
#> GSM78527     2  0.0000      0.888 0.000 1.000 0.000
#> GSM78530     2  0.4452      0.837 0.192 0.808 0.000
#> GSM78535     1  0.3941      0.694 0.844 0.156 0.000
#> GSM78538     2  0.4452      0.837 0.192 0.808 0.000
#> GSM78542     2  0.4452      0.837 0.192 0.808 0.000
#> GSM78544     2  0.4452      0.837 0.192 0.808 0.000
#> GSM78549     2  0.0237      0.887 0.004 0.996 0.000
#> GSM78553     2  0.4452      0.837 0.192 0.808 0.000
#> GSM78558     2  0.4452      0.837 0.192 0.808 0.000
#> GSM78561     2  0.0000      0.888 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     4  0.0000      0.685 0.000 0.000 0.000 1.000
#> GSM78545     4  0.3528      0.586 0.000 0.000 0.192 0.808
#> GSM78550     4  0.2530      0.683 0.000 0.000 0.112 0.888
#> GSM78554     4  0.2408      0.688 0.000 0.000 0.104 0.896
#> GSM78562     4  0.0188      0.683 0.004 0.000 0.000 0.996
#> GSM78540     4  0.0000      0.685 0.000 0.000 0.000 1.000
#> GSM78546     4  0.2149      0.691 0.000 0.000 0.088 0.912
#> GSM78551     4  0.2530      0.683 0.000 0.000 0.112 0.888
#> GSM78555     4  0.0188      0.683 0.004 0.000 0.000 0.996
#> GSM78563     4  0.0188      0.683 0.004 0.000 0.000 0.996
#> GSM43005     3  0.0000      0.871 0.000 0.000 1.000 0.000
#> GSM43008     3  0.0000      0.871 0.000 0.000 1.000 0.000
#> GSM43011     3  0.1792      0.860 0.068 0.000 0.932 0.000
#> GSM78523     3  0.1792      0.860 0.068 0.000 0.932 0.000
#> GSM78526     3  0.1792      0.860 0.068 0.000 0.932 0.000
#> GSM78529     3  0.0000      0.871 0.000 0.000 1.000 0.000
#> GSM78532     4  0.3791      0.736 0.004 0.000 0.200 0.796
#> GSM78534     3  0.1792      0.860 0.068 0.000 0.932 0.000
#> GSM78537     4  0.4019      0.737 0.012 0.000 0.196 0.792
#> GSM78543     4  0.4194      0.719 0.008 0.000 0.228 0.764
#> GSM78548     3  0.3444      0.722 0.000 0.000 0.816 0.184
#> GSM78557     3  0.4103      0.633 0.000 0.000 0.744 0.256
#> GSM78560     4  0.4428      0.676 0.004 0.000 0.276 0.720
#> GSM78565     4  0.4019      0.737 0.012 0.000 0.196 0.792
#> GSM43000     3  0.0000      0.871 0.000 0.000 1.000 0.000
#> GSM43002     3  0.0000      0.871 0.000 0.000 1.000 0.000
#> GSM43004     3  0.1792      0.860 0.068 0.000 0.932 0.000
#> GSM43007     3  0.0000      0.871 0.000 0.000 1.000 0.000
#> GSM43010     3  0.1792      0.860 0.068 0.000 0.932 0.000
#> GSM78522     3  0.1792      0.860 0.068 0.000 0.932 0.000
#> GSM78525     3  0.0000      0.871 0.000 0.000 1.000 0.000
#> GSM78528     3  0.0000      0.871 0.000 0.000 1.000 0.000
#> GSM78531     4  0.3791      0.736 0.004 0.000 0.200 0.796
#> GSM78533     3  0.1792      0.860 0.068 0.000 0.932 0.000
#> GSM78536     4  0.4019      0.737 0.012 0.000 0.196 0.792
#> GSM78541     4  0.4019      0.737 0.012 0.000 0.196 0.792
#> GSM78547     3  0.4103      0.633 0.000 0.000 0.744 0.256
#> GSM78552     3  0.4103      0.633 0.000 0.000 0.744 0.256
#> GSM78556     3  0.4103      0.633 0.000 0.000 0.744 0.256
#> GSM78559     4  0.4019      0.737 0.012 0.000 0.196 0.792
#> GSM78564     3  0.4222      0.605 0.000 0.000 0.728 0.272
#> GSM42999     2  0.0000      0.839 0.000 1.000 0.000 0.000
#> GSM43001     2  0.4103      0.630 0.256 0.744 0.000 0.000
#> GSM43003     2  0.0000      0.839 0.000 1.000 0.000 0.000
#> GSM43006     2  0.0000      0.839 0.000 1.000 0.000 0.000
#> GSM43009     2  0.0000      0.839 0.000 1.000 0.000 0.000
#> GSM43012     2  0.0000      0.839 0.000 1.000 0.000 0.000
#> GSM78524     2  0.6757      0.385 0.376 0.524 0.000 0.100
#> GSM78527     2  0.0000      0.839 0.000 1.000 0.000 0.000
#> GSM78530     2  0.4482      0.802 0.128 0.804 0.000 0.068
#> GSM78535     1  0.4543      0.000 0.676 0.000 0.000 0.324
#> GSM78538     2  0.4482      0.802 0.128 0.804 0.000 0.068
#> GSM78542     2  0.4482      0.802 0.128 0.804 0.000 0.068
#> GSM78544     2  0.4482      0.802 0.128 0.804 0.000 0.068
#> GSM78549     2  0.0188      0.839 0.004 0.996 0.000 0.000
#> GSM78553     2  0.4482      0.802 0.128 0.804 0.000 0.068
#> GSM78558     2  0.4482      0.802 0.128 0.804 0.000 0.068
#> GSM78561     2  0.4103      0.630 0.256 0.744 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4  0.0162      0.708 0.000 0.000 0.000 0.996 0.004
#> GSM78545     4  0.3282      0.619 0.000 0.000 0.188 0.804 0.008
#> GSM78550     4  0.2338      0.689 0.000 0.000 0.112 0.884 0.004
#> GSM78554     4  0.2233      0.693 0.000 0.000 0.104 0.892 0.004
#> GSM78562     4  0.0162      0.708 0.000 0.000 0.000 0.996 0.004
#> GSM78540     4  0.0162      0.708 0.000 0.000 0.000 0.996 0.004
#> GSM78546     4  0.2011      0.698 0.000 0.000 0.088 0.908 0.004
#> GSM78551     4  0.2338      0.689 0.000 0.000 0.112 0.884 0.004
#> GSM78555     4  0.0162      0.708 0.000 0.000 0.000 0.996 0.004
#> GSM78563     4  0.0162      0.708 0.000 0.000 0.000 0.996 0.004
#> GSM43005     3  0.0162      0.823 0.000 0.000 0.996 0.000 0.004
#> GSM43008     3  0.0000      0.824 0.000 0.000 1.000 0.000 0.000
#> GSM43011     3  0.2813      0.792 0.000 0.000 0.832 0.000 0.168
#> GSM78523     3  0.2813      0.792 0.000 0.000 0.832 0.000 0.168
#> GSM78526     3  0.2813      0.792 0.000 0.000 0.832 0.000 0.168
#> GSM78529     3  0.0162      0.823 0.000 0.000 0.996 0.000 0.004
#> GSM78532     4  0.5399      0.721 0.000 0.000 0.188 0.664 0.148
#> GSM78534     3  0.2813      0.792 0.000 0.000 0.832 0.000 0.168
#> GSM78537     4  0.5440      0.722 0.000 0.000 0.184 0.660 0.156
#> GSM78543     4  0.5638      0.710 0.000 0.000 0.216 0.632 0.152
#> GSM78548     3  0.3513      0.669 0.000 0.000 0.800 0.180 0.020
#> GSM78557     3  0.4114      0.577 0.000 0.000 0.732 0.244 0.024
#> GSM78560     4  0.5882      0.679 0.000 0.000 0.264 0.588 0.148
#> GSM78565     4  0.5440      0.722 0.000 0.000 0.184 0.660 0.156
#> GSM43000     3  0.0000      0.824 0.000 0.000 1.000 0.000 0.000
#> GSM43002     3  0.0000      0.824 0.000 0.000 1.000 0.000 0.000
#> GSM43004     3  0.2773      0.792 0.000 0.000 0.836 0.000 0.164
#> GSM43007     3  0.0000      0.824 0.000 0.000 1.000 0.000 0.000
#> GSM43010     3  0.2813      0.792 0.000 0.000 0.832 0.000 0.168
#> GSM78522     3  0.2813      0.792 0.000 0.000 0.832 0.000 0.168
#> GSM78525     3  0.0000      0.824 0.000 0.000 1.000 0.000 0.000
#> GSM78528     3  0.0162      0.823 0.000 0.000 0.996 0.000 0.004
#> GSM78531     4  0.5399      0.721 0.000 0.000 0.188 0.664 0.148
#> GSM78533     3  0.2813      0.792 0.000 0.000 0.832 0.000 0.168
#> GSM78536     4  0.5440      0.722 0.000 0.000 0.184 0.660 0.156
#> GSM78541     4  0.5440      0.722 0.000 0.000 0.184 0.660 0.156
#> GSM78547     3  0.4114      0.577 0.000 0.000 0.732 0.244 0.024
#> GSM78552     3  0.4114      0.577 0.000 0.000 0.732 0.244 0.024
#> GSM78556     3  0.4114      0.577 0.000 0.000 0.732 0.244 0.024
#> GSM78559     4  0.5440      0.722 0.000 0.000 0.184 0.660 0.156
#> GSM78564     3  0.4276      0.551 0.000 0.000 0.716 0.256 0.028
#> GSM42999     2  0.3074      0.840 0.196 0.804 0.000 0.000 0.000
#> GSM43001     1  0.0404      1.000 0.988 0.012 0.000 0.000 0.000
#> GSM43003     2  0.3074      0.840 0.196 0.804 0.000 0.000 0.000
#> GSM43006     2  0.3336      0.812 0.228 0.772 0.000 0.000 0.000
#> GSM43009     2  0.3074      0.840 0.196 0.804 0.000 0.000 0.000
#> GSM43012     2  0.3074      0.840 0.196 0.804 0.000 0.000 0.000
#> GSM78524     2  0.4121      0.370 0.004 0.720 0.000 0.012 0.264
#> GSM78527     2  0.3074      0.840 0.196 0.804 0.000 0.000 0.000
#> GSM78530     2  0.0000      0.828 0.000 1.000 0.000 0.000 0.000
#> GSM78535     5  0.4042      0.000 0.012 0.196 0.000 0.020 0.772
#> GSM78538     2  0.0000      0.828 0.000 1.000 0.000 0.000 0.000
#> GSM78542     2  0.0000      0.828 0.000 1.000 0.000 0.000 0.000
#> GSM78544     2  0.0000      0.828 0.000 1.000 0.000 0.000 0.000
#> GSM78549     2  0.3039      0.840 0.192 0.808 0.000 0.000 0.000
#> GSM78553     2  0.0000      0.828 0.000 1.000 0.000 0.000 0.000
#> GSM78558     2  0.0000      0.828 0.000 1.000 0.000 0.000 0.000
#> GSM78561     1  0.0404      1.000 0.988 0.012 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM78539     4  0.3620      0.876 0.352 0.000 0.000 0.648 0.000 0.000
#> GSM78545     4  0.5392      0.777 0.224 0.000 0.192 0.584 0.000 0.000
#> GSM78550     4  0.4849      0.862 0.240 0.000 0.112 0.648 0.000 0.000
#> GSM78554     4  0.5019      0.838 0.292 0.000 0.104 0.604 0.000 0.000
#> GSM78562     4  0.3647      0.873 0.360 0.000 0.000 0.640 0.000 0.000
#> GSM78540     4  0.3620      0.876 0.352 0.000 0.000 0.648 0.000 0.000
#> GSM78546     4  0.4725      0.871 0.264 0.000 0.088 0.648 0.000 0.000
#> GSM78551     4  0.4849      0.862 0.240 0.000 0.112 0.648 0.000 0.000
#> GSM78555     4  0.3647      0.873 0.360 0.000 0.000 0.640 0.000 0.000
#> GSM78563     4  0.3647      0.873 0.360 0.000 0.000 0.640 0.000 0.000
#> GSM43005     3  0.0000      0.626 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM43008     3  0.0146      0.630 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM43011     6  0.3838      0.734 0.000 0.000 0.448 0.000 0.000 0.552
#> GSM78523     6  0.3838      0.734 0.000 0.000 0.448 0.000 0.000 0.552
#> GSM78526     6  0.3838      0.734 0.000 0.000 0.448 0.000 0.000 0.552
#> GSM78529     3  0.0000      0.626 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM78532     1  0.0291      0.966 0.992 0.000 0.004 0.004 0.000 0.000
#> GSM78534     6  0.3966      0.732 0.004 0.000 0.444 0.000 0.000 0.552
#> GSM78537     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78543     1  0.0935      0.931 0.964 0.000 0.032 0.004 0.000 0.000
#> GSM78548     3  0.3728      0.583 0.344 0.000 0.652 0.004 0.000 0.000
#> GSM78557     3  0.3930      0.511 0.420 0.000 0.576 0.004 0.000 0.000
#> GSM78560     1  0.1700      0.852 0.916 0.000 0.080 0.004 0.000 0.000
#> GSM78565     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM43000     3  0.0858      0.643 0.028 0.000 0.968 0.000 0.000 0.004
#> GSM43002     3  0.0713      0.645 0.028 0.000 0.972 0.000 0.000 0.000
#> GSM43004     6  0.4482      0.694 0.032 0.000 0.416 0.000 0.000 0.552
#> GSM43007     3  0.0146      0.630 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM43010     6  0.3838      0.734 0.000 0.000 0.448 0.000 0.000 0.552
#> GSM78522     6  0.3966      0.732 0.004 0.000 0.444 0.000 0.000 0.552
#> GSM78525     3  0.0713      0.645 0.028 0.000 0.972 0.000 0.000 0.000
#> GSM78528     3  0.0000      0.626 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM78531     1  0.0291      0.966 0.992 0.000 0.004 0.004 0.000 0.000
#> GSM78533     6  0.3838      0.734 0.000 0.000 0.448 0.000 0.000 0.552
#> GSM78536     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78547     3  0.3930      0.511 0.420 0.000 0.576 0.004 0.000 0.000
#> GSM78552     3  0.3930      0.511 0.420 0.000 0.576 0.004 0.000 0.000
#> GSM78556     3  0.3930      0.511 0.420 0.000 0.576 0.004 0.000 0.000
#> GSM78559     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78564     3  0.3955      0.478 0.436 0.000 0.560 0.004 0.000 0.000
#> GSM42999     2  0.0000      0.851 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43001     6  0.6628     -0.371 0.000 0.104 0.000 0.352 0.096 0.448
#> GSM43003     2  0.0000      0.851 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43006     2  0.0790      0.827 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM43009     2  0.0000      0.851 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43012     2  0.0000      0.851 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78524     2  0.3862      0.375 0.000 0.524 0.000 0.000 0.476 0.000
#> GSM78527     2  0.0000      0.851 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78530     2  0.2762      0.835 0.000 0.804 0.000 0.000 0.196 0.000
#> GSM78535     5  0.1765      0.000 0.096 0.000 0.000 0.000 0.904 0.000
#> GSM78538     2  0.2762      0.835 0.000 0.804 0.000 0.000 0.196 0.000
#> GSM78542     2  0.2762      0.835 0.000 0.804 0.000 0.000 0.196 0.000
#> GSM78544     2  0.2762      0.835 0.000 0.804 0.000 0.000 0.196 0.000
#> GSM78549     2  0.0146      0.851 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM78553     2  0.2762      0.835 0.000 0.804 0.000 0.000 0.196 0.000
#> GSM78558     2  0.2762      0.835 0.000 0.804 0.000 0.000 0.196 0.000
#> GSM78561     6  0.6628     -0.371 0.000 0.104 0.000 0.352 0.096 0.448

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 cell.type(p) agent(p) individual(p) k
#> MAD:hclust 57     4.70e-12  0.00409        0.9975 2
#> MAD:hclust 57     5.24e-15  0.00507        0.4768 3
#> MAD:hclust 56     7.83e-16  0.00380        0.5580 4
#> MAD:hclust 56     1.55e-14  0.01096        0.4510 5
#> MAD:hclust 53     2.52e-19  0.03434        0.0472 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 58 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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 1.000           1.000       1.000         0.4222 0.578   0.578
#> 3 3 0.639           0.894       0.867         0.4783 0.758   0.582
#> 4 4 0.683           0.893       0.830         0.1591 0.891   0.685
#> 5 5 0.775           0.688       0.733         0.0756 0.956   0.831
#> 6 6 0.863           0.895       0.854         0.0535 0.912   0.624

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
#> GSM78539     1       0          1  1  0
#> GSM78545     1       0          1  1  0
#> GSM78550     1       0          1  1  0
#> GSM78554     1       0          1  1  0
#> GSM78562     1       0          1  1  0
#> GSM78540     1       0          1  1  0
#> GSM78546     1       0          1  1  0
#> GSM78551     1       0          1  1  0
#> GSM78555     1       0          1  1  0
#> GSM78563     1       0          1  1  0
#> GSM43005     1       0          1  1  0
#> GSM43008     1       0          1  1  0
#> GSM43011     1       0          1  1  0
#> GSM78523     1       0          1  1  0
#> GSM78526     1       0          1  1  0
#> GSM78529     1       0          1  1  0
#> GSM78532     1       0          1  1  0
#> GSM78534     1       0          1  1  0
#> GSM78537     1       0          1  1  0
#> GSM78543     1       0          1  1  0
#> GSM78548     1       0          1  1  0
#> GSM78557     1       0          1  1  0
#> GSM78560     1       0          1  1  0
#> GSM78565     1       0          1  1  0
#> GSM43000     1       0          1  1  0
#> GSM43002     1       0          1  1  0
#> GSM43004     1       0          1  1  0
#> GSM43007     1       0          1  1  0
#> GSM43010     1       0          1  1  0
#> GSM78522     1       0          1  1  0
#> GSM78525     1       0          1  1  0
#> GSM78528     1       0          1  1  0
#> GSM78531     1       0          1  1  0
#> GSM78533     1       0          1  1  0
#> GSM78536     1       0          1  1  0
#> GSM78541     1       0          1  1  0
#> GSM78547     1       0          1  1  0
#> GSM78552     1       0          1  1  0
#> GSM78556     1       0          1  1  0
#> GSM78559     1       0          1  1  0
#> GSM78564     1       0          1  1  0
#> GSM42999     2       0          1  0  1
#> GSM43001     2       0          1  0  1
#> GSM43003     2       0          1  0  1
#> GSM43006     2       0          1  0  1
#> GSM43009     2       0          1  0  1
#> GSM43012     2       0          1  0  1
#> GSM78524     2       0          1  0  1
#> GSM78527     2       0          1  0  1
#> GSM78530     2       0          1  0  1
#> GSM78535     2       0          1  0  1
#> GSM78538     2       0          1  0  1
#> GSM78542     2       0          1  0  1
#> GSM78544     2       0          1  0  1
#> GSM78549     2       0          1  0  1
#> GSM78553     2       0          1  0  1
#> GSM78558     2       0          1  0  1
#> GSM78561     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     1  0.4842      0.801 0.776 0.000 0.224
#> GSM78545     1  0.4842      0.801 0.776 0.000 0.224
#> GSM78550     1  0.4842      0.801 0.776 0.000 0.224
#> GSM78554     1  0.4842      0.801 0.776 0.000 0.224
#> GSM78562     1  0.4842      0.801 0.776 0.000 0.224
#> GSM78540     1  0.4842      0.801 0.776 0.000 0.224
#> GSM78546     1  0.4842      0.801 0.776 0.000 0.224
#> GSM78551     1  0.4842      0.801 0.776 0.000 0.224
#> GSM78555     1  0.4842      0.801 0.776 0.000 0.224
#> GSM78563     1  0.4842      0.801 0.776 0.000 0.224
#> GSM43005     3  0.5926      0.995 0.356 0.000 0.644
#> GSM43008     3  0.5926      0.995 0.356 0.000 0.644
#> GSM43011     3  0.5926      0.995 0.356 0.000 0.644
#> GSM78523     3  0.5926      0.995 0.356 0.000 0.644
#> GSM78526     3  0.5968      0.992 0.364 0.000 0.636
#> GSM78529     3  0.5926      0.995 0.356 0.000 0.644
#> GSM78532     1  0.0000      0.836 1.000 0.000 0.000
#> GSM78534     3  0.5968      0.992 0.364 0.000 0.636
#> GSM78537     1  0.0000      0.836 1.000 0.000 0.000
#> GSM78543     1  0.0000      0.836 1.000 0.000 0.000
#> GSM78548     1  0.4235      0.518 0.824 0.000 0.176
#> GSM78557     1  0.0000      0.836 1.000 0.000 0.000
#> GSM78560     1  0.0000      0.836 1.000 0.000 0.000
#> GSM78565     1  0.0000      0.836 1.000 0.000 0.000
#> GSM43000     3  0.5926      0.995 0.356 0.000 0.644
#> GSM43002     3  0.5926      0.995 0.356 0.000 0.644
#> GSM43004     3  0.5968      0.992 0.364 0.000 0.636
#> GSM43007     3  0.5926      0.995 0.356 0.000 0.644
#> GSM43010     3  0.5968      0.992 0.364 0.000 0.636
#> GSM78522     3  0.5968      0.992 0.364 0.000 0.636
#> GSM78525     3  0.5926      0.995 0.356 0.000 0.644
#> GSM78528     3  0.5926      0.995 0.356 0.000 0.644
#> GSM78531     1  0.0000      0.836 1.000 0.000 0.000
#> GSM78533     3  0.5968      0.992 0.364 0.000 0.636
#> GSM78536     1  0.0000      0.836 1.000 0.000 0.000
#> GSM78541     1  0.0000      0.836 1.000 0.000 0.000
#> GSM78547     1  0.0000      0.836 1.000 0.000 0.000
#> GSM78552     1  0.3267      0.662 0.884 0.000 0.116
#> GSM78556     1  0.0000      0.836 1.000 0.000 0.000
#> GSM78559     1  0.0000      0.836 1.000 0.000 0.000
#> GSM78564     1  0.0000      0.836 1.000 0.000 0.000
#> GSM42999     2  0.2878      0.950 0.000 0.904 0.096
#> GSM43001     2  0.3619      0.940 0.000 0.864 0.136
#> GSM43003     2  0.2878      0.950 0.000 0.904 0.096
#> GSM43006     2  0.3619      0.940 0.000 0.864 0.136
#> GSM43009     2  0.2878      0.950 0.000 0.904 0.096
#> GSM43012     2  0.3267      0.945 0.000 0.884 0.116
#> GSM78524     2  0.0237      0.944 0.000 0.996 0.004
#> GSM78527     2  0.2878      0.950 0.000 0.904 0.096
#> GSM78530     2  0.0000      0.945 0.000 1.000 0.000
#> GSM78535     2  0.4575      0.747 0.184 0.812 0.004
#> GSM78538     2  0.0000      0.945 0.000 1.000 0.000
#> GSM78542     2  0.0000      0.945 0.000 1.000 0.000
#> GSM78544     2  0.0000      0.945 0.000 1.000 0.000
#> GSM78549     2  0.2878      0.950 0.000 0.904 0.096
#> GSM78553     2  0.0000      0.945 0.000 1.000 0.000
#> GSM78558     2  0.0237      0.944 0.000 0.996 0.004
#> GSM78561     2  0.3619      0.940 0.000 0.864 0.136

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     4  0.5510      0.971 0.376 0.000 0.024 0.600
#> GSM78545     4  0.5384      0.906 0.324 0.000 0.028 0.648
#> GSM78550     4  0.5311      0.912 0.328 0.000 0.024 0.648
#> GSM78554     4  0.5510      0.970 0.376 0.000 0.024 0.600
#> GSM78562     4  0.5510      0.971 0.376 0.000 0.024 0.600
#> GSM78540     4  0.5510      0.971 0.376 0.000 0.024 0.600
#> GSM78546     4  0.5496      0.971 0.372 0.000 0.024 0.604
#> GSM78551     4  0.5510      0.970 0.376 0.000 0.024 0.600
#> GSM78555     4  0.5548      0.953 0.388 0.000 0.024 0.588
#> GSM78563     4  0.5510      0.971 0.376 0.000 0.024 0.600
#> GSM43005     3  0.2053      0.913 0.004 0.000 0.924 0.072
#> GSM43008     3  0.2053      0.913 0.004 0.000 0.924 0.072
#> GSM43011     3  0.1743      0.913 0.004 0.000 0.940 0.056
#> GSM78523     3  0.1743      0.913 0.004 0.000 0.940 0.056
#> GSM78526     3  0.1890      0.913 0.008 0.000 0.936 0.056
#> GSM78529     3  0.2053      0.913 0.004 0.000 0.924 0.072
#> GSM78532     1  0.2469      0.955 0.892 0.000 0.108 0.000
#> GSM78534     3  0.1890      0.913 0.008 0.000 0.936 0.056
#> GSM78537     1  0.2593      0.953 0.892 0.000 0.104 0.004
#> GSM78543     1  0.2593      0.953 0.892 0.000 0.104 0.004
#> GSM78548     3  0.5464      0.552 0.228 0.000 0.708 0.064
#> GSM78557     1  0.2469      0.955 0.892 0.000 0.108 0.000
#> GSM78560     1  0.2469      0.955 0.892 0.000 0.108 0.000
#> GSM78565     1  0.2593      0.953 0.892 0.000 0.104 0.004
#> GSM43000     3  0.1576      0.917 0.004 0.000 0.948 0.048
#> GSM43002     3  0.1824      0.915 0.004 0.000 0.936 0.060
#> GSM43004     3  0.3533      0.856 0.080 0.000 0.864 0.056
#> GSM43007     3  0.2053      0.913 0.004 0.000 0.924 0.072
#> GSM43010     3  0.1890      0.913 0.008 0.000 0.936 0.056
#> GSM78522     3  0.1890      0.913 0.008 0.000 0.936 0.056
#> GSM78525     3  0.1824      0.915 0.004 0.000 0.936 0.060
#> GSM78528     3  0.2053      0.913 0.004 0.000 0.924 0.072
#> GSM78531     1  0.2469      0.955 0.892 0.000 0.108 0.000
#> GSM78533     3  0.1890      0.913 0.008 0.000 0.936 0.056
#> GSM78536     1  0.2593      0.953 0.892 0.000 0.104 0.004
#> GSM78541     1  0.2593      0.953 0.892 0.000 0.104 0.004
#> GSM78547     1  0.2469      0.955 0.892 0.000 0.108 0.000
#> GSM78552     1  0.6089      0.490 0.608 0.000 0.328 0.064
#> GSM78556     1  0.2469      0.955 0.892 0.000 0.108 0.000
#> GSM78559     1  0.2593      0.953 0.892 0.000 0.104 0.004
#> GSM78564     1  0.2469      0.955 0.892 0.000 0.108 0.000
#> GSM42999     2  0.5184      0.863 0.060 0.736 0.000 0.204
#> GSM43001     2  0.6248      0.833 0.100 0.640 0.000 0.260
#> GSM43003     2  0.5429      0.860 0.072 0.720 0.000 0.208
#> GSM43006     2  0.6124      0.834 0.084 0.640 0.000 0.276
#> GSM43009     2  0.5184      0.863 0.060 0.736 0.000 0.204
#> GSM43012     2  0.5820      0.850 0.084 0.684 0.000 0.232
#> GSM78524     2  0.0469      0.847 0.000 0.988 0.000 0.012
#> GSM78527     2  0.5429      0.860 0.072 0.720 0.000 0.208
#> GSM78530     2  0.0000      0.849 0.000 1.000 0.000 0.000
#> GSM78535     2  0.3933      0.648 0.200 0.792 0.000 0.008
#> GSM78538     2  0.0000      0.849 0.000 1.000 0.000 0.000
#> GSM78542     2  0.0000      0.849 0.000 1.000 0.000 0.000
#> GSM78544     2  0.0000      0.849 0.000 1.000 0.000 0.000
#> GSM78549     2  0.5325      0.862 0.068 0.728 0.000 0.204
#> GSM78553     2  0.0000      0.849 0.000 1.000 0.000 0.000
#> GSM78558     2  0.0336      0.846 0.000 0.992 0.000 0.008
#> GSM78561     2  0.6248      0.833 0.100 0.640 0.000 0.260

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4  0.3336      0.983 0.228 0.000 0.000 0.772 0.000
#> GSM78545     4  0.4338      0.943 0.192 0.000 0.036 0.760 0.012
#> GSM78550     4  0.4295      0.949 0.196 0.000 0.032 0.760 0.012
#> GSM78554     4  0.3720      0.978 0.228 0.000 0.000 0.760 0.012
#> GSM78562     4  0.3366      0.980 0.232 0.000 0.000 0.768 0.000
#> GSM78540     4  0.3336      0.983 0.228 0.000 0.000 0.772 0.000
#> GSM78546     4  0.3336      0.983 0.228 0.000 0.000 0.772 0.000
#> GSM78551     4  0.3336      0.983 0.228 0.000 0.000 0.772 0.000
#> GSM78555     4  0.3424      0.971 0.240 0.000 0.000 0.760 0.000
#> GSM78563     4  0.3336      0.983 0.228 0.000 0.000 0.772 0.000
#> GSM43005     3  0.1597      0.730 0.048 0.000 0.940 0.012 0.000
#> GSM43008     3  0.1597      0.730 0.048 0.000 0.940 0.012 0.000
#> GSM43011     3  0.6021      0.688 0.024 0.000 0.504 0.060 0.412
#> GSM78523     3  0.6021      0.688 0.024 0.000 0.504 0.060 0.412
#> GSM78526     3  0.6021      0.688 0.024 0.000 0.504 0.060 0.412
#> GSM78529     3  0.1597      0.730 0.048 0.000 0.940 0.012 0.000
#> GSM78532     1  0.0671      0.971 0.980 0.000 0.004 0.000 0.016
#> GSM78534     3  0.6118      0.687 0.024 0.000 0.500 0.068 0.408
#> GSM78537     1  0.0898      0.970 0.972 0.000 0.000 0.008 0.020
#> GSM78543     1  0.0898      0.970 0.972 0.000 0.000 0.008 0.020
#> GSM78548     3  0.3711      0.638 0.136 0.000 0.820 0.012 0.032
#> GSM78557     1  0.0671      0.971 0.980 0.000 0.004 0.000 0.016
#> GSM78560     1  0.0771      0.969 0.976 0.000 0.004 0.000 0.020
#> GSM78565     1  0.0992      0.969 0.968 0.000 0.000 0.008 0.024
#> GSM43000     3  0.0703      0.730 0.024 0.000 0.976 0.000 0.000
#> GSM43002     3  0.1197      0.731 0.048 0.000 0.952 0.000 0.000
#> GSM43004     3  0.6860      0.654 0.076 0.000 0.448 0.068 0.408
#> GSM43007     3  0.1597      0.730 0.048 0.000 0.940 0.012 0.000
#> GSM43010     3  0.6021      0.688 0.024 0.000 0.504 0.060 0.412
#> GSM78522     3  0.6118      0.687 0.024 0.000 0.500 0.068 0.408
#> GSM78525     3  0.1043      0.731 0.040 0.000 0.960 0.000 0.000
#> GSM78528     3  0.1597      0.730 0.048 0.000 0.940 0.012 0.000
#> GSM78531     1  0.0671      0.971 0.980 0.000 0.004 0.000 0.016
#> GSM78533     3  0.6021      0.688 0.024 0.000 0.504 0.060 0.412
#> GSM78536     1  0.0992      0.969 0.968 0.000 0.000 0.008 0.024
#> GSM78541     1  0.0992      0.969 0.968 0.000 0.000 0.008 0.024
#> GSM78547     1  0.0671      0.971 0.980 0.000 0.004 0.000 0.016
#> GSM78552     3  0.4985      0.178 0.392 0.000 0.580 0.012 0.016
#> GSM78556     1  0.0671      0.971 0.980 0.000 0.004 0.000 0.016
#> GSM78559     1  0.0992      0.969 0.968 0.000 0.000 0.008 0.024
#> GSM78564     1  0.0451      0.972 0.988 0.000 0.004 0.000 0.008
#> GSM42999     2  0.4264     -0.140 0.000 0.620 0.000 0.004 0.376
#> GSM43001     5  0.6474      0.921 0.000 0.424 0.012 0.128 0.436
#> GSM43003     2  0.4321     -0.215 0.000 0.600 0.000 0.004 0.396
#> GSM43006     5  0.5483      0.838 0.000 0.424 0.000 0.064 0.512
#> GSM43009     2  0.4264     -0.140 0.000 0.620 0.000 0.004 0.376
#> GSM43012     2  0.5436     -0.664 0.000 0.492 0.004 0.048 0.456
#> GSM78524     2  0.1682      0.544 0.000 0.944 0.012 0.032 0.012
#> GSM78527     2  0.4321     -0.215 0.000 0.600 0.000 0.004 0.396
#> GSM78530     2  0.0000      0.577 0.000 1.000 0.000 0.000 0.000
#> GSM78535     2  0.4059      0.324 0.148 0.804 0.008 0.020 0.020
#> GSM78538     2  0.0000      0.577 0.000 1.000 0.000 0.000 0.000
#> GSM78542     2  0.0000      0.577 0.000 1.000 0.000 0.000 0.000
#> GSM78544     2  0.0000      0.577 0.000 1.000 0.000 0.000 0.000
#> GSM78549     2  0.4150     -0.176 0.000 0.612 0.000 0.000 0.388
#> GSM78553     2  0.0000      0.577 0.000 1.000 0.000 0.000 0.000
#> GSM78558     2  0.0000      0.577 0.000 1.000 0.000 0.000 0.000
#> GSM78561     5  0.6474      0.921 0.000 0.424 0.012 0.128 0.436

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM78539     4  0.2121      0.980 0.096 0.012 0.000 0.892 0.000 0.000
#> GSM78545     4  0.3370      0.948 0.072 0.032 0.024 0.852 0.000 0.020
#> GSM78550     4  0.3343      0.952 0.076 0.032 0.020 0.852 0.000 0.020
#> GSM78554     4  0.2994      0.967 0.096 0.028 0.000 0.856 0.000 0.020
#> GSM78562     4  0.2121      0.980 0.096 0.012 0.000 0.892 0.000 0.000
#> GSM78540     4  0.1765      0.981 0.096 0.000 0.000 0.904 0.000 0.000
#> GSM78546     4  0.1765      0.981 0.096 0.000 0.000 0.904 0.000 0.000
#> GSM78551     4  0.1908      0.980 0.096 0.000 0.000 0.900 0.000 0.004
#> GSM78555     4  0.1765      0.981 0.096 0.000 0.000 0.904 0.000 0.000
#> GSM78563     4  0.1765      0.981 0.096 0.000 0.000 0.904 0.000 0.000
#> GSM43005     3  0.0291      0.908 0.004 0.004 0.992 0.000 0.000 0.000
#> GSM43008     3  0.0405      0.906 0.004 0.008 0.988 0.000 0.000 0.000
#> GSM43011     6  0.3567      0.966 0.004 0.004 0.252 0.004 0.000 0.736
#> GSM78523     6  0.3567      0.966 0.004 0.004 0.252 0.004 0.000 0.736
#> GSM78526     6  0.3429      0.967 0.004 0.000 0.252 0.004 0.000 0.740
#> GSM78529     3  0.0291      0.908 0.004 0.004 0.992 0.000 0.000 0.000
#> GSM78532     1  0.0458      0.950 0.984 0.016 0.000 0.000 0.000 0.000
#> GSM78534     6  0.4420      0.951 0.004 0.048 0.252 0.004 0.000 0.692
#> GSM78537     1  0.1225      0.950 0.952 0.036 0.000 0.000 0.000 0.012
#> GSM78543     1  0.1225      0.950 0.952 0.036 0.000 0.000 0.000 0.012
#> GSM78548     3  0.4041      0.736 0.108 0.076 0.788 0.000 0.000 0.028
#> GSM78557     1  0.1297      0.941 0.948 0.040 0.000 0.000 0.000 0.012
#> GSM78560     1  0.1010      0.946 0.960 0.036 0.000 0.000 0.000 0.004
#> GSM78565     1  0.1686      0.942 0.924 0.064 0.000 0.000 0.000 0.012
#> GSM43000     3  0.1363      0.882 0.004 0.012 0.952 0.004 0.000 0.028
#> GSM43002     3  0.0508      0.906 0.004 0.012 0.984 0.000 0.000 0.000
#> GSM43004     6  0.5217      0.892 0.048 0.060 0.216 0.004 0.000 0.672
#> GSM43007     3  0.0405      0.906 0.004 0.008 0.988 0.000 0.000 0.000
#> GSM43010     6  0.3290      0.968 0.004 0.000 0.252 0.000 0.000 0.744
#> GSM78522     6  0.4360      0.953 0.004 0.044 0.252 0.004 0.000 0.696
#> GSM78525     3  0.0508      0.906 0.004 0.012 0.984 0.000 0.000 0.000
#> GSM78528     3  0.0291      0.908 0.004 0.004 0.992 0.000 0.000 0.000
#> GSM78531     1  0.0458      0.950 0.984 0.016 0.000 0.000 0.000 0.000
#> GSM78533     6  0.3290      0.968 0.004 0.000 0.252 0.000 0.000 0.744
#> GSM78536     1  0.1625      0.943 0.928 0.060 0.000 0.000 0.000 0.012
#> GSM78541     1  0.1625      0.943 0.928 0.060 0.000 0.000 0.000 0.012
#> GSM78547     1  0.1297      0.941 0.948 0.040 0.000 0.000 0.000 0.012
#> GSM78552     3  0.5080      0.572 0.244 0.072 0.656 0.000 0.000 0.028
#> GSM78556     1  0.1297      0.941 0.948 0.040 0.000 0.000 0.000 0.012
#> GSM78559     1  0.1625      0.943 0.928 0.060 0.000 0.000 0.000 0.012
#> GSM78564     1  0.1528      0.939 0.936 0.048 0.000 0.000 0.000 0.016
#> GSM42999     2  0.4504      0.769 0.000 0.536 0.000 0.000 0.432 0.032
#> GSM43001     2  0.5463      0.687 0.000 0.652 0.004 0.064 0.220 0.060
#> GSM43003     2  0.4123      0.787 0.000 0.568 0.000 0.000 0.420 0.012
#> GSM43006     2  0.3426      0.739 0.000 0.764 0.000 0.004 0.220 0.012
#> GSM43009     2  0.4513      0.761 0.000 0.528 0.000 0.000 0.440 0.032
#> GSM43012     2  0.4522      0.771 0.000 0.648 0.000 0.004 0.300 0.048
#> GSM78524     5  0.3222      0.805 0.000 0.012 0.000 0.024 0.824 0.140
#> GSM78527     2  0.4123      0.787 0.000 0.568 0.000 0.000 0.420 0.012
#> GSM78530     5  0.0000      0.910 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM78535     5  0.4351      0.714 0.060 0.044 0.000 0.016 0.788 0.092
#> GSM78538     5  0.0748      0.901 0.000 0.004 0.000 0.004 0.976 0.016
#> GSM78542     5  0.0748      0.901 0.000 0.004 0.000 0.004 0.976 0.016
#> GSM78544     5  0.0935      0.902 0.000 0.000 0.000 0.004 0.964 0.032
#> GSM78549     2  0.4229      0.774 0.000 0.548 0.000 0.000 0.436 0.016
#> GSM78553     5  0.0405      0.911 0.000 0.000 0.000 0.004 0.988 0.008
#> GSM78558     5  0.0405      0.911 0.000 0.000 0.000 0.004 0.988 0.008
#> GSM78561     2  0.5463      0.687 0.000 0.652 0.004 0.064 0.220 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-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 cell.type(p) agent(p) individual(p) k
#> MAD:kmeans 58     2.54e-13  0.00184         1.000 2
#> MAD:kmeans 58     2.30e-14  0.00274         0.114 3
#> MAD:kmeans 57     2.96e-22  0.00688         0.315 4
#> MAD:kmeans 50     4.27e-18  0.10324         0.159 5
#> MAD:kmeans 58     3.27e-20  0.03468         0.110 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 58 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.900           0.983       0.991         0.4281 0.578   0.578
#> 3 3 0.781           0.930       0.951         0.5398 0.750   0.567
#> 4 4 1.000           0.976       0.987         0.1427 0.903   0.712
#> 5 5 1.000           0.973       0.977         0.0609 0.943   0.775
#> 6 6 0.927           0.951       0.925         0.0462 0.956   0.783

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM78539     1   0.000      0.987 1.000 0.000
#> GSM78545     1   0.000      0.987 1.000 0.000
#> GSM78550     1   0.000      0.987 1.000 0.000
#> GSM78554     1   0.000      0.987 1.000 0.000
#> GSM78562     1   0.000      0.987 1.000 0.000
#> GSM78540     1   0.494      0.891 0.892 0.108
#> GSM78546     1   0.482      0.895 0.896 0.104
#> GSM78551     1   0.482      0.895 0.896 0.104
#> GSM78555     1   0.456      0.903 0.904 0.096
#> GSM78563     1   0.482      0.895 0.896 0.104
#> GSM43005     1   0.000      0.987 1.000 0.000
#> GSM43008     1   0.000      0.987 1.000 0.000
#> GSM43011     1   0.000      0.987 1.000 0.000
#> GSM78523     1   0.000      0.987 1.000 0.000
#> GSM78526     1   0.000      0.987 1.000 0.000
#> GSM78529     1   0.000      0.987 1.000 0.000
#> GSM78532     1   0.000      0.987 1.000 0.000
#> GSM78534     1   0.000      0.987 1.000 0.000
#> GSM78537     1   0.000      0.987 1.000 0.000
#> GSM78543     1   0.000      0.987 1.000 0.000
#> GSM78548     1   0.000      0.987 1.000 0.000
#> GSM78557     1   0.000      0.987 1.000 0.000
#> GSM78560     1   0.000      0.987 1.000 0.000
#> GSM78565     1   0.000      0.987 1.000 0.000
#> GSM43000     1   0.000      0.987 1.000 0.000
#> GSM43002     1   0.000      0.987 1.000 0.000
#> GSM43004     1   0.000      0.987 1.000 0.000
#> GSM43007     1   0.000      0.987 1.000 0.000
#> GSM43010     1   0.000      0.987 1.000 0.000
#> GSM78522     1   0.000      0.987 1.000 0.000
#> GSM78525     1   0.000      0.987 1.000 0.000
#> GSM78528     1   0.000      0.987 1.000 0.000
#> GSM78531     1   0.000      0.987 1.000 0.000
#> GSM78533     1   0.000      0.987 1.000 0.000
#> GSM78536     1   0.000      0.987 1.000 0.000
#> GSM78541     1   0.000      0.987 1.000 0.000
#> GSM78547     1   0.000      0.987 1.000 0.000
#> GSM78552     1   0.000      0.987 1.000 0.000
#> GSM78556     1   0.000      0.987 1.000 0.000
#> GSM78559     1   0.000      0.987 1.000 0.000
#> GSM78564     1   0.000      0.987 1.000 0.000
#> GSM42999     2   0.000      1.000 0.000 1.000
#> GSM43001     2   0.000      1.000 0.000 1.000
#> GSM43003     2   0.000      1.000 0.000 1.000
#> GSM43006     2   0.000      1.000 0.000 1.000
#> GSM43009     2   0.000      1.000 0.000 1.000
#> GSM43012     2   0.000      1.000 0.000 1.000
#> GSM78524     2   0.000      1.000 0.000 1.000
#> GSM78527     2   0.000      1.000 0.000 1.000
#> GSM78530     2   0.000      1.000 0.000 1.000
#> GSM78535     2   0.000      1.000 0.000 1.000
#> GSM78538     2   0.000      1.000 0.000 1.000
#> GSM78542     2   0.000      1.000 0.000 1.000
#> GSM78544     2   0.000      1.000 0.000 1.000
#> GSM78549     2   0.000      1.000 0.000 1.000
#> GSM78553     2   0.000      1.000 0.000 1.000
#> GSM78558     2   0.000      1.000 0.000 1.000
#> GSM78561     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1 p2    p3
#> GSM78539     1   0.000      0.876 1.000  0 0.000
#> GSM78545     1   0.000      0.876 1.000  0 0.000
#> GSM78550     1   0.000      0.876 1.000  0 0.000
#> GSM78554     1   0.000      0.876 1.000  0 0.000
#> GSM78562     1   0.000      0.876 1.000  0 0.000
#> GSM78540     1   0.000      0.876 1.000  0 0.000
#> GSM78546     1   0.000      0.876 1.000  0 0.000
#> GSM78551     1   0.000      0.876 1.000  0 0.000
#> GSM78555     1   0.000      0.876 1.000  0 0.000
#> GSM78563     1   0.000      0.876 1.000  0 0.000
#> GSM43005     3   0.000      0.966 0.000  0 1.000
#> GSM43008     3   0.000      0.966 0.000  0 1.000
#> GSM43011     3   0.000      0.966 0.000  0 1.000
#> GSM78523     3   0.000      0.966 0.000  0 1.000
#> GSM78526     3   0.000      0.966 0.000  0 1.000
#> GSM78529     3   0.000      0.966 0.000  0 1.000
#> GSM78532     1   0.429      0.895 0.820  0 0.180
#> GSM78534     3   0.000      0.966 0.000  0 1.000
#> GSM78537     1   0.429      0.895 0.820  0 0.180
#> GSM78543     1   0.429      0.895 0.820  0 0.180
#> GSM78548     3   0.319      0.836 0.112  0 0.888
#> GSM78557     1   0.429      0.895 0.820  0 0.180
#> GSM78560     1   0.429      0.895 0.820  0 0.180
#> GSM78565     1   0.429      0.895 0.820  0 0.180
#> GSM43000     3   0.000      0.966 0.000  0 1.000
#> GSM43002     3   0.000      0.966 0.000  0 1.000
#> GSM43004     3   0.000      0.966 0.000  0 1.000
#> GSM43007     3   0.000      0.966 0.000  0 1.000
#> GSM43010     3   0.000      0.966 0.000  0 1.000
#> GSM78522     3   0.000      0.966 0.000  0 1.000
#> GSM78525     3   0.000      0.966 0.000  0 1.000
#> GSM78528     3   0.000      0.966 0.000  0 1.000
#> GSM78531     1   0.429      0.895 0.820  0 0.180
#> GSM78533     3   0.000      0.966 0.000  0 1.000
#> GSM78536     1   0.429      0.895 0.820  0 0.180
#> GSM78541     1   0.429      0.895 0.820  0 0.180
#> GSM78547     1   0.429      0.895 0.820  0 0.180
#> GSM78552     3   0.603      0.245 0.376  0 0.624
#> GSM78556     1   0.429      0.895 0.820  0 0.180
#> GSM78559     1   0.429      0.895 0.820  0 0.180
#> GSM78564     1   0.429      0.895 0.820  0 0.180
#> GSM42999     2   0.000      1.000 0.000  1 0.000
#> GSM43001     2   0.000      1.000 0.000  1 0.000
#> GSM43003     2   0.000      1.000 0.000  1 0.000
#> GSM43006     2   0.000      1.000 0.000  1 0.000
#> GSM43009     2   0.000      1.000 0.000  1 0.000
#> GSM43012     2   0.000      1.000 0.000  1 0.000
#> GSM78524     2   0.000      1.000 0.000  1 0.000
#> GSM78527     2   0.000      1.000 0.000  1 0.000
#> GSM78530     2   0.000      1.000 0.000  1 0.000
#> GSM78535     2   0.000      1.000 0.000  1 0.000
#> GSM78538     2   0.000      1.000 0.000  1 0.000
#> GSM78542     2   0.000      1.000 0.000  1 0.000
#> GSM78544     2   0.000      1.000 0.000  1 0.000
#> GSM78549     2   0.000      1.000 0.000  1 0.000
#> GSM78553     2   0.000      1.000 0.000  1 0.000
#> GSM78558     2   0.000      1.000 0.000  1 0.000
#> GSM78561     2   0.000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1 p2    p3    p4
#> GSM78539     4  0.0469      0.997 0.012  0 0.000 0.988
#> GSM78545     4  0.0000      0.987 0.000  0 0.000 1.000
#> GSM78550     4  0.0000      0.987 0.000  0 0.000 1.000
#> GSM78554     4  0.0469      0.997 0.012  0 0.000 0.988
#> GSM78562     4  0.0469      0.997 0.012  0 0.000 0.988
#> GSM78540     4  0.0469      0.997 0.012  0 0.000 0.988
#> GSM78546     4  0.0469      0.997 0.012  0 0.000 0.988
#> GSM78551     4  0.0469      0.997 0.012  0 0.000 0.988
#> GSM78555     4  0.0469      0.997 0.012  0 0.000 0.988
#> GSM78563     4  0.0469      0.997 0.012  0 0.000 0.988
#> GSM43005     3  0.0469      0.968 0.000  0 0.988 0.012
#> GSM43008     3  0.0469      0.968 0.000  0 0.988 0.012
#> GSM43011     3  0.0000      0.969 0.000  0 1.000 0.000
#> GSM78523     3  0.0000      0.969 0.000  0 1.000 0.000
#> GSM78526     3  0.0000      0.969 0.000  0 1.000 0.000
#> GSM78529     3  0.0469      0.968 0.000  0 0.988 0.012
#> GSM78532     1  0.0000      0.985 1.000  0 0.000 0.000
#> GSM78534     3  0.0000      0.969 0.000  0 1.000 0.000
#> GSM78537     1  0.0000      0.985 1.000  0 0.000 0.000
#> GSM78543     1  0.0000      0.985 1.000  0 0.000 0.000
#> GSM78548     3  0.4019      0.752 0.196  0 0.792 0.012
#> GSM78557     1  0.0000      0.985 1.000  0 0.000 0.000
#> GSM78560     1  0.0000      0.985 1.000  0 0.000 0.000
#> GSM78565     1  0.0000      0.985 1.000  0 0.000 0.000
#> GSM43000     3  0.0000      0.969 0.000  0 1.000 0.000
#> GSM43002     3  0.0469      0.968 0.000  0 0.988 0.012
#> GSM43004     3  0.3528      0.760 0.192  0 0.808 0.000
#> GSM43007     3  0.0469      0.968 0.000  0 0.988 0.012
#> GSM43010     3  0.0000      0.969 0.000  0 1.000 0.000
#> GSM78522     3  0.0000      0.969 0.000  0 1.000 0.000
#> GSM78525     3  0.0469      0.968 0.000  0 0.988 0.012
#> GSM78528     3  0.0469      0.968 0.000  0 0.988 0.012
#> GSM78531     1  0.0000      0.985 1.000  0 0.000 0.000
#> GSM78533     3  0.0000      0.969 0.000  0 1.000 0.000
#> GSM78536     1  0.0000      0.985 1.000  0 0.000 0.000
#> GSM78541     1  0.0000      0.985 1.000  0 0.000 0.000
#> GSM78547     1  0.0000      0.985 1.000  0 0.000 0.000
#> GSM78552     1  0.3625      0.786 0.828  0 0.160 0.012
#> GSM78556     1  0.0000      0.985 1.000  0 0.000 0.000
#> GSM78559     1  0.0000      0.985 1.000  0 0.000 0.000
#> GSM78564     1  0.0000      0.985 1.000  0 0.000 0.000
#> GSM42999     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43001     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43003     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43006     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43009     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43012     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78524     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78527     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78530     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78535     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78538     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78542     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78544     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78549     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78553     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78558     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78561     2  0.0000      1.000 0.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3 p4    p5
#> GSM78539     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78545     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78550     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78554     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78562     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78540     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78546     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78551     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78555     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78563     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM43005     3  0.1121      0.943 0.000 0.000 0.956  0 0.044
#> GSM43008     3  0.1121      0.943 0.000 0.000 0.956  0 0.044
#> GSM43011     5  0.0404      0.999 0.000 0.000 0.012  0 0.988
#> GSM78523     5  0.0404      0.999 0.000 0.000 0.012  0 0.988
#> GSM78526     5  0.0404      0.999 0.000 0.000 0.012  0 0.988
#> GSM78529     3  0.1121      0.943 0.000 0.000 0.956  0 0.044
#> GSM78532     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78534     5  0.0404      0.999 0.000 0.000 0.012  0 0.988
#> GSM78537     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78543     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78548     3  0.1281      0.933 0.012 0.000 0.956  0 0.032
#> GSM78557     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78560     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78565     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM43000     3  0.4060      0.501 0.000 0.000 0.640  0 0.360
#> GSM43002     3  0.1121      0.943 0.000 0.000 0.956  0 0.044
#> GSM43004     5  0.0451      0.994 0.004 0.000 0.008  0 0.988
#> GSM43007     3  0.1121      0.943 0.000 0.000 0.956  0 0.044
#> GSM43010     5  0.0404      0.999 0.000 0.000 0.012  0 0.988
#> GSM78522     5  0.0404      0.999 0.000 0.000 0.012  0 0.988
#> GSM78525     3  0.1121      0.943 0.000 0.000 0.956  0 0.044
#> GSM78528     3  0.1121      0.943 0.000 0.000 0.956  0 0.044
#> GSM78531     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78533     5  0.0404      0.999 0.000 0.000 0.012  0 0.988
#> GSM78536     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78541     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78547     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78552     3  0.2329      0.824 0.124 0.000 0.876  0 0.000
#> GSM78556     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78559     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM78564     1  0.0000      1.000 1.000 0.000 0.000  0 0.000
#> GSM42999     2  0.0000      0.977 0.000 1.000 0.000  0 0.000
#> GSM43001     2  0.0000      0.977 0.000 1.000 0.000  0 0.000
#> GSM43003     2  0.0000      0.977 0.000 1.000 0.000  0 0.000
#> GSM43006     2  0.0000      0.977 0.000 1.000 0.000  0 0.000
#> GSM43009     2  0.0000      0.977 0.000 1.000 0.000  0 0.000
#> GSM43012     2  0.0000      0.977 0.000 1.000 0.000  0 0.000
#> GSM78524     2  0.1522      0.974 0.000 0.944 0.044  0 0.012
#> GSM78527     2  0.0000      0.977 0.000 1.000 0.000  0 0.000
#> GSM78530     2  0.1522      0.974 0.000 0.944 0.044  0 0.012
#> GSM78535     2  0.1522      0.974 0.000 0.944 0.044  0 0.012
#> GSM78538     2  0.1522      0.974 0.000 0.944 0.044  0 0.012
#> GSM78542     2  0.1522      0.974 0.000 0.944 0.044  0 0.012
#> GSM78544     2  0.1522      0.974 0.000 0.944 0.044  0 0.012
#> GSM78549     2  0.0000      0.977 0.000 1.000 0.000  0 0.000
#> GSM78553     2  0.1522      0.974 0.000 0.944 0.044  0 0.012
#> GSM78558     2  0.1522      0.974 0.000 0.944 0.044  0 0.012
#> GSM78561     2  0.0000      0.977 0.000 1.000 0.000  0 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
#> GSM78539     4  0.0000      0.989 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78545     4  0.1075      0.969 0.000 0.000 0.000 0.952 0.048 0.000
#> GSM78550     4  0.1075      0.969 0.000 0.000 0.000 0.952 0.048 0.000
#> GSM78554     4  0.0790      0.977 0.000 0.000 0.000 0.968 0.032 0.000
#> GSM78562     4  0.0000      0.989 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78540     4  0.0000      0.989 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78546     4  0.0000      0.989 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78551     4  0.0000      0.989 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78555     4  0.0000      0.989 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78563     4  0.0000      0.989 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM43005     3  0.0547      0.906 0.000 0.000 0.980 0.000 0.020 0.000
#> GSM43008     3  0.0146      0.906 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM43011     6  0.0363      0.990 0.000 0.000 0.000 0.000 0.012 0.988
#> GSM78523     6  0.0363      0.990 0.000 0.000 0.000 0.000 0.012 0.988
#> GSM78526     6  0.0000      0.995 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78529     3  0.0547      0.906 0.000 0.000 0.980 0.000 0.020 0.000
#> GSM78532     1  0.0632      0.959 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM78534     6  0.0000      0.995 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78537     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78543     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78548     3  0.3298      0.814 0.008 0.000 0.756 0.000 0.236 0.000
#> GSM78557     1  0.2003      0.922 0.884 0.000 0.000 0.000 0.116 0.000
#> GSM78560     1  0.0632      0.959 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM78565     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM43000     3  0.4453      0.507 0.000 0.000 0.624 0.000 0.044 0.332
#> GSM43002     3  0.0937      0.902 0.000 0.000 0.960 0.000 0.040 0.000
#> GSM43004     6  0.0405      0.987 0.008 0.000 0.000 0.000 0.004 0.988
#> GSM43007     3  0.0146      0.906 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM43010     6  0.0000      0.995 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78522     6  0.0000      0.995 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78525     3  0.0937      0.902 0.000 0.000 0.960 0.000 0.040 0.000
#> GSM78528     3  0.0363      0.906 0.000 0.000 0.988 0.000 0.012 0.000
#> GSM78531     1  0.0632      0.959 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM78533     6  0.0000      0.995 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78536     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78547     1  0.2003      0.922 0.884 0.000 0.000 0.000 0.116 0.000
#> GSM78552     3  0.4205      0.774 0.084 0.000 0.728 0.000 0.188 0.000
#> GSM78556     1  0.2003      0.922 0.884 0.000 0.000 0.000 0.116 0.000
#> GSM78559     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78564     1  0.1863      0.926 0.896 0.000 0.000 0.000 0.104 0.000
#> GSM42999     2  0.1075      0.965 0.000 0.952 0.000 0.000 0.048 0.000
#> GSM43001     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43003     2  0.0865      0.973 0.000 0.964 0.000 0.000 0.036 0.000
#> GSM43006     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43009     2  0.1075      0.965 0.000 0.952 0.000 0.000 0.048 0.000
#> GSM43012     2  0.0458      0.970 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM78524     5  0.3309      0.965 0.000 0.280 0.000 0.000 0.720 0.000
#> GSM78527     2  0.0865      0.973 0.000 0.964 0.000 0.000 0.036 0.000
#> GSM78530     5  0.3198      0.992 0.000 0.260 0.000 0.000 0.740 0.000
#> GSM78535     5  0.3265      0.981 0.004 0.248 0.000 0.000 0.748 0.000
#> GSM78538     5  0.3198      0.992 0.000 0.260 0.000 0.000 0.740 0.000
#> GSM78542     5  0.3198      0.992 0.000 0.260 0.000 0.000 0.740 0.000
#> GSM78544     5  0.3198      0.992 0.000 0.260 0.000 0.000 0.740 0.000
#> GSM78549     2  0.0937      0.971 0.000 0.960 0.000 0.000 0.040 0.000
#> GSM78553     5  0.3198      0.992 0.000 0.260 0.000 0.000 0.740 0.000
#> GSM78558     5  0.3175      0.989 0.000 0.256 0.000 0.000 0.744 0.000
#> GSM78561     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-skmeans-collect-classes

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

test_to_known_factors(res)
#>              n cell.type(p) agent(p) individual(p) k
#> MAD:skmeans 58     2.54e-13  0.00184         1.000 2
#> MAD:skmeans 57     1.37e-14  0.00234         0.222 3
#> MAD:skmeans 58     1.13e-22  0.00789         0.397 4
#> MAD:skmeans 58     2.22e-21  0.01729         0.115 5
#> MAD:skmeans 58     3.27e-20  0.03468         0.110 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 58 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 1.000           1.000       1.000         0.4222 0.578   0.578
#> 3 3 0.759           0.811       0.848         0.4938 0.758   0.582
#> 4 4 0.982           0.959       0.984         0.1957 0.891   0.685
#> 5 5 0.916           0.883       0.878         0.0534 0.938   0.758
#> 6 6 0.981           0.918       0.965         0.0464 0.930   0.684

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette p1 p2
#> GSM78539     1       0          1  1  0
#> GSM78545     1       0          1  1  0
#> GSM78550     1       0          1  1  0
#> GSM78554     1       0          1  1  0
#> GSM78562     1       0          1  1  0
#> GSM78540     1       0          1  1  0
#> GSM78546     1       0          1  1  0
#> GSM78551     1       0          1  1  0
#> GSM78555     1       0          1  1  0
#> GSM78563     1       0          1  1  0
#> GSM43005     1       0          1  1  0
#> GSM43008     1       0          1  1  0
#> GSM43011     1       0          1  1  0
#> GSM78523     1       0          1  1  0
#> GSM78526     1       0          1  1  0
#> GSM78529     1       0          1  1  0
#> GSM78532     1       0          1  1  0
#> GSM78534     1       0          1  1  0
#> GSM78537     1       0          1  1  0
#> GSM78543     1       0          1  1  0
#> GSM78548     1       0          1  1  0
#> GSM78557     1       0          1  1  0
#> GSM78560     1       0          1  1  0
#> GSM78565     1       0          1  1  0
#> GSM43000     1       0          1  1  0
#> GSM43002     1       0          1  1  0
#> GSM43004     1       0          1  1  0
#> GSM43007     1       0          1  1  0
#> GSM43010     1       0          1  1  0
#> GSM78522     1       0          1  1  0
#> GSM78525     1       0          1  1  0
#> GSM78528     1       0          1  1  0
#> GSM78531     1       0          1  1  0
#> GSM78533     1       0          1  1  0
#> GSM78536     1       0          1  1  0
#> GSM78541     1       0          1  1  0
#> GSM78547     1       0          1  1  0
#> GSM78552     1       0          1  1  0
#> GSM78556     1       0          1  1  0
#> GSM78559     1       0          1  1  0
#> GSM78564     1       0          1  1  0
#> GSM42999     2       0          1  0  1
#> GSM43001     2       0          1  0  1
#> GSM43003     2       0          1  0  1
#> GSM43006     2       0          1  0  1
#> GSM43009     2       0          1  0  1
#> GSM43012     2       0          1  0  1
#> GSM78524     2       0          1  0  1
#> GSM78527     2       0          1  0  1
#> GSM78530     2       0          1  0  1
#> GSM78535     2       0          1  0  1
#> GSM78538     2       0          1  0  1
#> GSM78542     2       0          1  0  1
#> GSM78544     2       0          1  0  1
#> GSM78549     2       0          1  0  1
#> GSM78553     2       0          1  0  1
#> GSM78558     2       0          1  0  1
#> GSM78561     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1 p2    p3
#> GSM78539     1  0.0000      0.585 1.000  0 0.000
#> GSM78545     1  0.0000      0.585 1.000  0 0.000
#> GSM78550     1  0.0000      0.585 1.000  0 0.000
#> GSM78554     1  0.6062      0.616 0.616  0 0.384
#> GSM78562     1  0.0237      0.585 0.996  0 0.004
#> GSM78540     1  0.0000      0.585 1.000  0 0.000
#> GSM78546     1  0.0000      0.585 1.000  0 0.000
#> GSM78551     1  0.0000      0.585 1.000  0 0.000
#> GSM78555     1  0.0000      0.585 1.000  0 0.000
#> GSM78563     1  0.0000      0.585 1.000  0 0.000
#> GSM43005     3  0.0000      0.962 0.000  0 1.000
#> GSM43008     3  0.0424      0.955 0.008  0 0.992
#> GSM43011     3  0.0000      0.962 0.000  0 1.000
#> GSM78523     3  0.0000      0.962 0.000  0 1.000
#> GSM78526     3  0.0000      0.962 0.000  0 1.000
#> GSM78529     3  0.0000      0.962 0.000  0 1.000
#> GSM78532     1  0.6299      0.634 0.524  0 0.476
#> GSM78534     3  0.2066      0.876 0.060  0 0.940
#> GSM78537     1  0.6299      0.634 0.524  0 0.476
#> GSM78543     1  0.6299      0.634 0.524  0 0.476
#> GSM78548     1  0.6299      0.634 0.524  0 0.476
#> GSM78557     1  0.6299      0.634 0.524  0 0.476
#> GSM78560     1  0.6299      0.634 0.524  0 0.476
#> GSM78565     1  0.6299      0.634 0.524  0 0.476
#> GSM43000     3  0.0000      0.962 0.000  0 1.000
#> GSM43002     3  0.0000      0.962 0.000  0 1.000
#> GSM43004     3  0.5291      0.309 0.268  0 0.732
#> GSM43007     3  0.0424      0.955 0.008  0 0.992
#> GSM43010     3  0.0000      0.962 0.000  0 1.000
#> GSM78522     3  0.0000      0.962 0.000  0 1.000
#> GSM78525     3  0.0000      0.962 0.000  0 1.000
#> GSM78528     3  0.0000      0.962 0.000  0 1.000
#> GSM78531     1  0.6299      0.634 0.524  0 0.476
#> GSM78533     3  0.0000      0.962 0.000  0 1.000
#> GSM78536     1  0.6299      0.634 0.524  0 0.476
#> GSM78541     1  0.6299      0.634 0.524  0 0.476
#> GSM78547     1  0.6299      0.634 0.524  0 0.476
#> GSM78552     1  0.6299      0.634 0.524  0 0.476
#> GSM78556     1  0.6299      0.634 0.524  0 0.476
#> GSM78559     1  0.6299      0.634 0.524  0 0.476
#> GSM78564     1  0.6299      0.634 0.524  0 0.476
#> GSM42999     2  0.0000      1.000 0.000  1 0.000
#> GSM43001     2  0.0000      1.000 0.000  1 0.000
#> GSM43003     2  0.0000      1.000 0.000  1 0.000
#> GSM43006     2  0.0000      1.000 0.000  1 0.000
#> GSM43009     2  0.0000      1.000 0.000  1 0.000
#> GSM43012     2  0.0000      1.000 0.000  1 0.000
#> GSM78524     2  0.0000      1.000 0.000  1 0.000
#> GSM78527     2  0.0000      1.000 0.000  1 0.000
#> GSM78530     2  0.0000      1.000 0.000  1 0.000
#> GSM78535     2  0.0000      1.000 0.000  1 0.000
#> GSM78538     2  0.0000      1.000 0.000  1 0.000
#> GSM78542     2  0.0000      1.000 0.000  1 0.000
#> GSM78544     2  0.0000      1.000 0.000  1 0.000
#> GSM78549     2  0.0000      1.000 0.000  1 0.000
#> GSM78553     2  0.0000      1.000 0.000  1 0.000
#> GSM78558     2  0.0000      1.000 0.000  1 0.000
#> GSM78561     2  0.0000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1 p2    p3 p4
#> GSM78539     4   0.000      1.000 0.000  0 0.000  1
#> GSM78545     4   0.000      1.000 0.000  0 0.000  1
#> GSM78550     4   0.000      1.000 0.000  0 0.000  1
#> GSM78554     4   0.000      1.000 0.000  0 0.000  1
#> GSM78562     4   0.000      1.000 0.000  0 0.000  1
#> GSM78540     4   0.000      1.000 0.000  0 0.000  1
#> GSM78546     4   0.000      1.000 0.000  0 0.000  1
#> GSM78551     4   0.000      1.000 0.000  0 0.000  1
#> GSM78555     4   0.000      1.000 0.000  0 0.000  1
#> GSM78563     4   0.000      1.000 0.000  0 0.000  1
#> GSM43005     3   0.000      0.977 0.000  0 1.000  0
#> GSM43008     3   0.259      0.873 0.116  0 0.884  0
#> GSM43011     3   0.000      0.977 0.000  0 1.000  0
#> GSM78523     3   0.000      0.977 0.000  0 1.000  0
#> GSM78526     3   0.000      0.977 0.000  0 1.000  0
#> GSM78529     3   0.000      0.977 0.000  0 1.000  0
#> GSM78532     1   0.000      0.954 1.000  0 0.000  0
#> GSM78534     3   0.164      0.928 0.060  0 0.940  0
#> GSM78537     1   0.000      0.954 1.000  0 0.000  0
#> GSM78543     1   0.000      0.954 1.000  0 0.000  0
#> GSM78548     1   0.317      0.787 0.840  0 0.160  0
#> GSM78557     1   0.000      0.954 1.000  0 0.000  0
#> GSM78560     1   0.000      0.954 1.000  0 0.000  0
#> GSM78565     1   0.000      0.954 1.000  0 0.000  0
#> GSM43000     3   0.000      0.977 0.000  0 1.000  0
#> GSM43002     3   0.000      0.977 0.000  0 1.000  0
#> GSM43004     1   0.498      0.105 0.540  0 0.460  0
#> GSM43007     3   0.259      0.873 0.116  0 0.884  0
#> GSM43010     3   0.000      0.977 0.000  0 1.000  0
#> GSM78522     3   0.000      0.977 0.000  0 1.000  0
#> GSM78525     3   0.000      0.977 0.000  0 1.000  0
#> GSM78528     3   0.000      0.977 0.000  0 1.000  0
#> GSM78531     1   0.000      0.954 1.000  0 0.000  0
#> GSM78533     3   0.000      0.977 0.000  0 1.000  0
#> GSM78536     1   0.000      0.954 1.000  0 0.000  0
#> GSM78541     1   0.000      0.954 1.000  0 0.000  0
#> GSM78547     1   0.000      0.954 1.000  0 0.000  0
#> GSM78552     1   0.000      0.954 1.000  0 0.000  0
#> GSM78556     1   0.000      0.954 1.000  0 0.000  0
#> GSM78559     1   0.000      0.954 1.000  0 0.000  0
#> GSM78564     1   0.000      0.954 1.000  0 0.000  0
#> GSM42999     2   0.000      1.000 0.000  1 0.000  0
#> GSM43001     2   0.000      1.000 0.000  1 0.000  0
#> GSM43003     2   0.000      1.000 0.000  1 0.000  0
#> GSM43006     2   0.000      1.000 0.000  1 0.000  0
#> GSM43009     2   0.000      1.000 0.000  1 0.000  0
#> GSM43012     2   0.000      1.000 0.000  1 0.000  0
#> GSM78524     2   0.000      1.000 0.000  1 0.000  0
#> GSM78527     2   0.000      1.000 0.000  1 0.000  0
#> GSM78530     2   0.000      1.000 0.000  1 0.000  0
#> GSM78535     2   0.000      1.000 0.000  1 0.000  0
#> GSM78538     2   0.000      1.000 0.000  1 0.000  0
#> GSM78542     2   0.000      1.000 0.000  1 0.000  0
#> GSM78544     2   0.000      1.000 0.000  1 0.000  0
#> GSM78549     2   0.000      1.000 0.000  1 0.000  0
#> GSM78553     2   0.000      1.000 0.000  1 0.000  0
#> GSM78558     2   0.000      1.000 0.000  1 0.000  0
#> GSM78561     2   0.000      1.000 0.000  1 0.000  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3 p4    p5
#> GSM78539     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78545     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78550     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78554     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78562     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78540     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78546     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78551     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78555     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> GSM78563     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> GSM43005     3   0.411      0.788 0.000 0.376 0.624  0 0.000
#> GSM43008     3   0.459      0.781 0.016 0.380 0.604  0 0.000
#> GSM43011     3   0.000      0.812 0.000 0.000 1.000  0 0.000
#> GSM78523     3   0.000      0.812 0.000 0.000 1.000  0 0.000
#> GSM78526     3   0.000      0.812 0.000 0.000 1.000  0 0.000
#> GSM78529     3   0.413      0.787 0.000 0.380 0.620  0 0.000
#> GSM78532     1   0.000      0.995 1.000 0.000 0.000  0 0.000
#> GSM78534     3   0.141      0.776 0.060 0.000 0.940  0 0.000
#> GSM78537     1   0.000      0.995 1.000 0.000 0.000  0 0.000
#> GSM78543     1   0.000      0.995 1.000 0.000 0.000  0 0.000
#> GSM78548     1   0.201      0.918 0.920 0.020 0.060  0 0.000
#> GSM78557     1   0.000      0.995 1.000 0.000 0.000  0 0.000
#> GSM78560     1   0.000      0.995 1.000 0.000 0.000  0 0.000
#> GSM78565     1   0.000      0.995 1.000 0.000 0.000  0 0.000
#> GSM43000     3   0.247      0.816 0.000 0.136 0.864  0 0.000
#> GSM43002     3   0.413      0.787 0.000 0.380 0.620  0 0.000
#> GSM43004     3   0.539      0.272 0.400 0.060 0.540  0 0.000
#> GSM43007     3   0.468      0.779 0.020 0.380 0.600  0 0.000
#> GSM43010     3   0.000      0.812 0.000 0.000 1.000  0 0.000
#> GSM78522     3   0.000      0.812 0.000 0.000 1.000  0 0.000
#> GSM78525     3   0.356      0.808 0.000 0.260 0.740  0 0.000
#> GSM78528     3   0.413      0.787 0.000 0.380 0.620  0 0.000
#> GSM78531     1   0.000      0.995 1.000 0.000 0.000  0 0.000
#> GSM78533     3   0.000      0.812 0.000 0.000 1.000  0 0.000
#> GSM78536     1   0.000      0.995 1.000 0.000 0.000  0 0.000
#> GSM78541     1   0.000      0.995 1.000 0.000 0.000  0 0.000
#> GSM78547     1   0.000      0.995 1.000 0.000 0.000  0 0.000
#> GSM78552     1   0.000      0.995 1.000 0.000 0.000  0 0.000
#> GSM78556     1   0.000      0.995 1.000 0.000 0.000  0 0.000
#> GSM78559     1   0.000      0.995 1.000 0.000 0.000  0 0.000
#> GSM78564     1   0.000      0.995 1.000 0.000 0.000  0 0.000
#> GSM42999     5   0.386      0.115 0.000 0.312 0.000  0 0.688
#> GSM43001     5   0.000      0.832 0.000 0.000 0.000  0 1.000
#> GSM43003     5   0.120      0.789 0.000 0.048 0.000  0 0.952
#> GSM43006     5   0.000      0.832 0.000 0.000 0.000  0 1.000
#> GSM43009     5   0.384      0.136 0.000 0.308 0.000  0 0.692
#> GSM43012     5   0.000      0.832 0.000 0.000 0.000  0 1.000
#> GSM78524     2   0.416      0.980 0.000 0.608 0.000  0 0.392
#> GSM78527     5   0.029      0.827 0.000 0.008 0.000  0 0.992
#> GSM78530     2   0.413      0.994 0.000 0.620 0.000  0 0.380
#> GSM78535     2   0.413      0.994 0.000 0.620 0.000  0 0.380
#> GSM78538     2   0.413      0.994 0.000 0.620 0.000  0 0.380
#> GSM78542     2   0.413      0.994 0.000 0.620 0.000  0 0.380
#> GSM78544     2   0.416      0.980 0.000 0.608 0.000  0 0.392
#> GSM78549     2   0.413      0.994 0.000 0.620 0.000  0 0.380
#> GSM78553     2   0.413      0.994 0.000 0.620 0.000  0 0.380
#> GSM78558     2   0.413      0.994 0.000 0.620 0.000  0 0.380
#> GSM78561     5   0.000      0.832 0.000 0.000 0.000  0 1.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
#> GSM78539     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM78545     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM78550     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM78554     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM78562     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM78540     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM78546     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM78551     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM78555     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM78563     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM43005     3  0.0146      0.971 0.000 0.000 0.996  0 0.000 0.004
#> GSM43008     3  0.0000      0.974 0.000 0.000 1.000  0 0.000 0.000
#> GSM43011     6  0.0937      0.906 0.000 0.000 0.040  0 0.000 0.960
#> GSM78523     6  0.0937      0.906 0.000 0.000 0.040  0 0.000 0.960
#> GSM78526     6  0.0000      0.922 0.000 0.000 0.000  0 0.000 1.000
#> GSM78529     3  0.0000      0.974 0.000 0.000 1.000  0 0.000 0.000
#> GSM78532     1  0.0000      0.969 1.000 0.000 0.000  0 0.000 0.000
#> GSM78534     6  0.0000      0.922 0.000 0.000 0.000  0 0.000 1.000
#> GSM78537     1  0.0000      0.969 1.000 0.000 0.000  0 0.000 0.000
#> GSM78543     1  0.0000      0.969 1.000 0.000 0.000  0 0.000 0.000
#> GSM78548     1  0.1549      0.915 0.936 0.000 0.020  0 0.000 0.044
#> GSM78557     1  0.0000      0.969 1.000 0.000 0.000  0 0.000 0.000
#> GSM78560     1  0.0000      0.969 1.000 0.000 0.000  0 0.000 0.000
#> GSM78565     1  0.0000      0.969 1.000 0.000 0.000  0 0.000 0.000
#> GSM43000     6  0.3817      0.228 0.000 0.000 0.432  0 0.000 0.568
#> GSM43002     3  0.0000      0.974 0.000 0.000 1.000  0 0.000 0.000
#> GSM43004     1  0.4900      0.375 0.592 0.000 0.080  0 0.000 0.328
#> GSM43007     3  0.0000      0.974 0.000 0.000 1.000  0 0.000 0.000
#> GSM43010     6  0.0000      0.922 0.000 0.000 0.000  0 0.000 1.000
#> GSM78522     6  0.0000      0.922 0.000 0.000 0.000  0 0.000 1.000
#> GSM78525     3  0.2178      0.828 0.000 0.000 0.868  0 0.000 0.132
#> GSM78528     3  0.0000      0.974 0.000 0.000 1.000  0 0.000 0.000
#> GSM78531     1  0.0000      0.969 1.000 0.000 0.000  0 0.000 0.000
#> GSM78533     6  0.0000      0.922 0.000 0.000 0.000  0 0.000 1.000
#> GSM78536     1  0.0000      0.969 1.000 0.000 0.000  0 0.000 0.000
#> GSM78541     1  0.0000      0.969 1.000 0.000 0.000  0 0.000 0.000
#> GSM78547     1  0.0000      0.969 1.000 0.000 0.000  0 0.000 0.000
#> GSM78552     1  0.0000      0.969 1.000 0.000 0.000  0 0.000 0.000
#> GSM78556     1  0.0000      0.969 1.000 0.000 0.000  0 0.000 0.000
#> GSM78559     1  0.0000      0.969 1.000 0.000 0.000  0 0.000 0.000
#> GSM78564     1  0.0000      0.969 1.000 0.000 0.000  0 0.000 0.000
#> GSM42999     2  0.3620      0.543 0.000 0.648 0.000  0 0.352 0.000
#> GSM43001     5  0.0000      0.980 0.000 0.000 0.000  0 1.000 0.000
#> GSM43003     5  0.1267      0.937 0.000 0.060 0.000  0 0.940 0.000
#> GSM43006     5  0.0000      0.980 0.000 0.000 0.000  0 1.000 0.000
#> GSM43009     2  0.3659      0.520 0.000 0.636 0.000  0 0.364 0.000
#> GSM43012     5  0.0000      0.980 0.000 0.000 0.000  0 1.000 0.000
#> GSM78524     2  0.1141      0.893 0.000 0.948 0.000  0 0.052 0.000
#> GSM78527     5  0.0790      0.962 0.000 0.032 0.000  0 0.968 0.000
#> GSM78530     2  0.0000      0.915 0.000 1.000 0.000  0 0.000 0.000
#> GSM78535     2  0.0000      0.915 0.000 1.000 0.000  0 0.000 0.000
#> GSM78538     2  0.0000      0.915 0.000 1.000 0.000  0 0.000 0.000
#> GSM78542     2  0.0000      0.915 0.000 1.000 0.000  0 0.000 0.000
#> GSM78544     2  0.1141      0.893 0.000 0.948 0.000  0 0.052 0.000
#> GSM78549     2  0.0000      0.915 0.000 1.000 0.000  0 0.000 0.000
#> GSM78553     2  0.0000      0.915 0.000 1.000 0.000  0 0.000 0.000
#> GSM78558     2  0.0000      0.915 0.000 1.000 0.000  0 0.000 0.000
#> GSM78561     5  0.0000      0.980 0.000 0.000 0.000  0 1.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 cell.type(p) agent(p) individual(p) k
#> MAD:pam 58     2.54e-13  0.00184         1.000 2
#> MAD:pam 57     4.94e-14  0.00233         0.130 3
#> MAD:pam 57     2.96e-22  0.00689         0.354 4
#> MAD:pam 55     3.81e-20  0.02745         0.268 5
#> MAD:pam 56     2.11e-19  0.02434         0.038 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 58 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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           1.000       1.000         0.4222 0.578   0.578
#> 3 3 0.752           0.783       0.891         0.5234 0.789   0.636
#> 4 4 0.770           0.807       0.902         0.1458 0.858   0.622
#> 5 5 0.932           0.890       0.946         0.0710 0.906   0.655
#> 6 6 0.919           0.885       0.935         0.0361 0.954   0.791

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette p1 p2
#> GSM78539     1       0          1  1  0
#> GSM78545     1       0          1  1  0
#> GSM78550     1       0          1  1  0
#> GSM78554     1       0          1  1  0
#> GSM78562     1       0          1  1  0
#> GSM78540     1       0          1  1  0
#> GSM78546     1       0          1  1  0
#> GSM78551     1       0          1  1  0
#> GSM78555     1       0          1  1  0
#> GSM78563     1       0          1  1  0
#> GSM43005     1       0          1  1  0
#> GSM43008     1       0          1  1  0
#> GSM43011     1       0          1  1  0
#> GSM78523     1       0          1  1  0
#> GSM78526     1       0          1  1  0
#> GSM78529     1       0          1  1  0
#> GSM78532     1       0          1  1  0
#> GSM78534     1       0          1  1  0
#> GSM78537     1       0          1  1  0
#> GSM78543     1       0          1  1  0
#> GSM78548     1       0          1  1  0
#> GSM78557     1       0          1  1  0
#> GSM78560     1       0          1  1  0
#> GSM78565     1       0          1  1  0
#> GSM43000     1       0          1  1  0
#> GSM43002     1       0          1  1  0
#> GSM43004     1       0          1  1  0
#> GSM43007     1       0          1  1  0
#> GSM43010     1       0          1  1  0
#> GSM78522     1       0          1  1  0
#> GSM78525     1       0          1  1  0
#> GSM78528     1       0          1  1  0
#> GSM78531     1       0          1  1  0
#> GSM78533     1       0          1  1  0
#> GSM78536     1       0          1  1  0
#> GSM78541     1       0          1  1  0
#> GSM78547     1       0          1  1  0
#> GSM78552     1       0          1  1  0
#> GSM78556     1       0          1  1  0
#> GSM78559     1       0          1  1  0
#> GSM78564     1       0          1  1  0
#> GSM42999     2       0          1  0  1
#> GSM43001     2       0          1  0  1
#> GSM43003     2       0          1  0  1
#> GSM43006     2       0          1  0  1
#> GSM43009     2       0          1  0  1
#> GSM43012     2       0          1  0  1
#> GSM78524     2       0          1  0  1
#> GSM78527     2       0          1  0  1
#> GSM78530     2       0          1  0  1
#> GSM78535     2       0          1  0  1
#> GSM78538     2       0          1  0  1
#> GSM78542     2       0          1  0  1
#> GSM78544     2       0          1  0  1
#> GSM78549     2       0          1  0  1
#> GSM78553     2       0          1  0  1
#> GSM78558     2       0          1  0  1
#> GSM78561     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1 p2    p3
#> GSM78539     1  0.0424      0.899 0.992  0 0.008
#> GSM78545     1  0.2959      0.854 0.900  0 0.100
#> GSM78550     1  0.2165      0.871 0.936  0 0.064
#> GSM78554     1  0.5810      0.289 0.664  0 0.336
#> GSM78562     1  0.0424      0.899 0.992  0 0.008
#> GSM78540     1  0.0424      0.899 0.992  0 0.008
#> GSM78546     1  0.0424      0.899 0.992  0 0.008
#> GSM78551     1  0.0237      0.898 0.996  0 0.004
#> GSM78555     1  0.0424      0.899 0.992  0 0.008
#> GSM78563     1  0.0424      0.899 0.992  0 0.008
#> GSM43005     3  0.6215      0.426 0.428  0 0.572
#> GSM43008     3  0.6192      0.434 0.420  0 0.580
#> GSM43011     3  0.6204      0.434 0.424  0 0.576
#> GSM78523     3  0.6204      0.434 0.424  0 0.576
#> GSM78526     3  0.1529      0.760 0.040  0 0.960
#> GSM78529     1  0.4178      0.787 0.828  0 0.172
#> GSM78532     3  0.1529      0.758 0.040  0 0.960
#> GSM78534     3  0.1289      0.762 0.032  0 0.968
#> GSM78537     3  0.1529      0.758 0.040  0 0.960
#> GSM78543     3  0.2448      0.740 0.076  0 0.924
#> GSM78548     3  0.6192      0.434 0.420  0 0.580
#> GSM78557     3  0.2356      0.761 0.072  0 0.928
#> GSM78560     3  0.5016      0.663 0.240  0 0.760
#> GSM78565     3  0.2448      0.740 0.076  0 0.924
#> GSM43000     3  0.6204      0.434 0.424  0 0.576
#> GSM43002     3  0.6192      0.434 0.420  0 0.580
#> GSM43004     3  0.1289      0.762 0.032  0 0.968
#> GSM43007     3  0.6204      0.426 0.424  0 0.576
#> GSM43010     3  0.1529      0.760 0.040  0 0.960
#> GSM78522     3  0.1289      0.762 0.032  0 0.968
#> GSM78525     3  0.6204      0.434 0.424  0 0.576
#> GSM78528     1  0.4235      0.781 0.824  0 0.176
#> GSM78531     3  0.1411      0.757 0.036  0 0.964
#> GSM78533     3  0.1529      0.760 0.040  0 0.960
#> GSM78536     3  0.2448      0.740 0.076  0 0.924
#> GSM78541     3  0.2448      0.740 0.076  0 0.924
#> GSM78547     3  0.2356      0.761 0.072  0 0.928
#> GSM78552     3  0.6260      0.421 0.448  0 0.552
#> GSM78556     3  0.2356      0.761 0.072  0 0.928
#> GSM78559     3  0.2448      0.740 0.076  0 0.924
#> GSM78564     3  0.1411      0.759 0.036  0 0.964
#> GSM42999     2  0.0000      1.000 0.000  1 0.000
#> GSM43001     2  0.0000      1.000 0.000  1 0.000
#> GSM43003     2  0.0000      1.000 0.000  1 0.000
#> GSM43006     2  0.0000      1.000 0.000  1 0.000
#> GSM43009     2  0.0000      1.000 0.000  1 0.000
#> GSM43012     2  0.0000      1.000 0.000  1 0.000
#> GSM78524     2  0.0000      1.000 0.000  1 0.000
#> GSM78527     2  0.0000      1.000 0.000  1 0.000
#> GSM78530     2  0.0000      1.000 0.000  1 0.000
#> GSM78535     2  0.0000      1.000 0.000  1 0.000
#> GSM78538     2  0.0000      1.000 0.000  1 0.000
#> GSM78542     2  0.0000      1.000 0.000  1 0.000
#> GSM78544     2  0.0000      1.000 0.000  1 0.000
#> GSM78549     2  0.0000      1.000 0.000  1 0.000
#> GSM78553     2  0.0000      1.000 0.000  1 0.000
#> GSM78558     2  0.0000      1.000 0.000  1 0.000
#> GSM78561     2  0.0000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1 p2    p3    p4
#> GSM78539     4  0.0000      0.835 0.000  0 0.000 1.000
#> GSM78545     4  0.4072      0.655 0.000  0 0.252 0.748
#> GSM78550     4  0.4072      0.655 0.000  0 0.252 0.748
#> GSM78554     3  0.3837      0.615 0.000  0 0.776 0.224
#> GSM78562     4  0.0000      0.835 0.000  0 0.000 1.000
#> GSM78540     4  0.0000      0.835 0.000  0 0.000 1.000
#> GSM78546     4  0.0000      0.835 0.000  0 0.000 1.000
#> GSM78551     4  0.0000      0.835 0.000  0 0.000 1.000
#> GSM78555     4  0.0000      0.835 0.000  0 0.000 1.000
#> GSM78563     4  0.0000      0.835 0.000  0 0.000 1.000
#> GSM43005     3  0.0336      0.861 0.008  0 0.992 0.000
#> GSM43008     3  0.0336      0.861 0.008  0 0.992 0.000
#> GSM43011     3  0.0000      0.859 0.000  0 1.000 0.000
#> GSM78523     3  0.0188      0.856 0.004  0 0.996 0.000
#> GSM78526     3  0.4277      0.430 0.280  0 0.720 0.000
#> GSM78529     4  0.5285      0.298 0.008  0 0.468 0.524
#> GSM78532     1  0.3569      0.778 0.804  0 0.196 0.000
#> GSM78534     1  0.4817      0.597 0.612  0 0.388 0.000
#> GSM78537     1  0.3400      0.788 0.820  0 0.180 0.000
#> GSM78543     1  0.0188      0.759 0.996  0 0.004 0.000
#> GSM78548     3  0.0336      0.861 0.008  0 0.992 0.000
#> GSM78557     3  0.4331      0.580 0.288  0 0.712 0.000
#> GSM78560     1  0.3444      0.786 0.816  0 0.184 0.000
#> GSM78565     1  0.0188      0.759 0.996  0 0.004 0.000
#> GSM43000     3  0.0000      0.859 0.000  0 1.000 0.000
#> GSM43002     3  0.0336      0.861 0.008  0 0.992 0.000
#> GSM43004     1  0.3569      0.783 0.804  0 0.196 0.000
#> GSM43007     3  0.0336      0.861 0.008  0 0.992 0.000
#> GSM43010     1  0.4941      0.516 0.564  0 0.436 0.000
#> GSM78522     1  0.4817      0.597 0.612  0 0.388 0.000
#> GSM78525     3  0.0000      0.859 0.000  0 1.000 0.000
#> GSM78528     4  0.5285      0.298 0.008  0 0.468 0.524
#> GSM78531     1  0.2868      0.789 0.864  0 0.136 0.000
#> GSM78533     1  0.4967      0.481 0.548  0 0.452 0.000
#> GSM78536     1  0.0188      0.759 0.996  0 0.004 0.000
#> GSM78541     1  0.0188      0.759 0.996  0 0.004 0.000
#> GSM78547     3  0.4331      0.580 0.288  0 0.712 0.000
#> GSM78552     3  0.1557      0.834 0.056  0 0.944 0.000
#> GSM78556     3  0.4331      0.580 0.288  0 0.712 0.000
#> GSM78559     1  0.0188      0.759 0.996  0 0.004 0.000
#> GSM78564     1  0.3400      0.788 0.820  0 0.180 0.000
#> GSM42999     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43001     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43003     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43006     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43009     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM43012     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78524     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78527     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78530     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78535     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78538     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78542     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78544     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78549     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78553     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78558     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM78561     2  0.0000      1.000 0.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4  0.0000     0.9981 0.000 0.000 0.000 1.000 0.000
#> GSM78545     4  0.0162     0.9966 0.000 0.000 0.000 0.996 0.004
#> GSM78550     4  0.0162     0.9966 0.000 0.000 0.000 0.996 0.004
#> GSM78554     4  0.0451     0.9899 0.000 0.000 0.004 0.988 0.008
#> GSM78562     4  0.0000     0.9981 0.000 0.000 0.000 1.000 0.000
#> GSM78540     4  0.0000     0.9981 0.000 0.000 0.000 1.000 0.000
#> GSM78546     4  0.0000     0.9981 0.000 0.000 0.000 1.000 0.000
#> GSM78551     4  0.0000     0.9981 0.000 0.000 0.000 1.000 0.000
#> GSM78555     4  0.0000     0.9981 0.000 0.000 0.000 1.000 0.000
#> GSM78563     4  0.0000     0.9981 0.000 0.000 0.000 1.000 0.000
#> GSM43005     3  0.0000     0.8817 0.000 0.000 1.000 0.000 0.000
#> GSM43008     3  0.0000     0.8817 0.000 0.000 1.000 0.000 0.000
#> GSM43011     3  0.0000     0.8817 0.000 0.000 1.000 0.000 0.000
#> GSM78523     3  0.0290     0.8771 0.000 0.000 0.992 0.000 0.008
#> GSM78526     5  0.2852     0.9476 0.000 0.000 0.172 0.000 0.828
#> GSM78529     3  0.1041     0.8596 0.000 0.000 0.964 0.032 0.004
#> GSM78532     1  0.0000     0.9226 1.000 0.000 0.000 0.000 0.000
#> GSM78534     5  0.2890     0.9474 0.004 0.000 0.160 0.000 0.836
#> GSM78537     1  0.0000     0.9226 1.000 0.000 0.000 0.000 0.000
#> GSM78543     1  0.0794     0.9222 0.972 0.000 0.000 0.000 0.028
#> GSM78548     3  0.0290     0.8800 0.000 0.000 0.992 0.000 0.008
#> GSM78557     3  0.4562     0.0143 0.496 0.000 0.496 0.000 0.008
#> GSM78560     1  0.0000     0.9226 1.000 0.000 0.000 0.000 0.000
#> GSM78565     1  0.0794     0.9222 0.972 0.000 0.000 0.000 0.028
#> GSM43000     3  0.0000     0.8817 0.000 0.000 1.000 0.000 0.000
#> GSM43002     3  0.0290     0.8800 0.000 0.000 0.992 0.000 0.008
#> GSM43004     5  0.3284     0.7728 0.148 0.000 0.024 0.000 0.828
#> GSM43007     3  0.0000     0.8817 0.000 0.000 1.000 0.000 0.000
#> GSM43010     5  0.2852     0.9476 0.000 0.000 0.172 0.000 0.828
#> GSM78522     5  0.2890     0.9474 0.004 0.000 0.160 0.000 0.836
#> GSM78525     3  0.0000     0.8817 0.000 0.000 1.000 0.000 0.000
#> GSM78528     3  0.1041     0.8596 0.000 0.000 0.964 0.032 0.004
#> GSM78531     1  0.0000     0.9226 1.000 0.000 0.000 0.000 0.000
#> GSM78533     5  0.2966     0.9379 0.000 0.000 0.184 0.000 0.816
#> GSM78536     1  0.0794     0.9222 0.972 0.000 0.000 0.000 0.028
#> GSM78541     1  0.0794     0.9222 0.972 0.000 0.000 0.000 0.028
#> GSM78547     1  0.4562    -0.1679 0.496 0.000 0.496 0.000 0.008
#> GSM78552     3  0.1251     0.8541 0.036 0.000 0.956 0.000 0.008
#> GSM78556     3  0.4562     0.0143 0.496 0.000 0.496 0.000 0.008
#> GSM78559     1  0.0794     0.9222 0.972 0.000 0.000 0.000 0.028
#> GSM78564     1  0.0162     0.9204 0.996 0.000 0.004 0.000 0.000
#> GSM42999     2  0.0000     0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM43001     2  0.0000     0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM43003     2  0.0000     0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM43006     2  0.0000     0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM43009     2  0.0000     0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM43012     2  0.0000     0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM78524     2  0.2020     0.9183 0.000 0.900 0.000 0.000 0.100
#> GSM78527     2  0.0000     0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM78530     2  0.0404     0.9821 0.000 0.988 0.000 0.000 0.012
#> GSM78535     2  0.2280     0.9015 0.000 0.880 0.000 0.000 0.120
#> GSM78538     2  0.0000     0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM78542     2  0.0000     0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM78544     2  0.0404     0.9821 0.000 0.988 0.000 0.000 0.012
#> GSM78549     2  0.0000     0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM78553     2  0.0404     0.9821 0.000 0.988 0.000 0.000 0.012
#> GSM78558     2  0.0404     0.9821 0.000 0.988 0.000 0.000 0.012
#> GSM78561     2  0.0000     0.9860 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM78539     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78545     4  0.0146      0.992 0.000 0.000 0.004 0.996 0.000 0.000
#> GSM78550     4  0.0146      0.992 0.000 0.000 0.004 0.996 0.000 0.000
#> GSM78554     4  0.0777      0.968 0.000 0.000 0.024 0.972 0.000 0.004
#> GSM78562     4  0.0260      0.988 0.000 0.000 0.008 0.992 0.000 0.000
#> GSM78540     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78546     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78551     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78555     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78563     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM43005     3  0.0000      0.914 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM43008     3  0.0146      0.915 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM43011     3  0.1327      0.886 0.000 0.000 0.936 0.000 0.000 0.064
#> GSM78523     3  0.2823      0.748 0.000 0.000 0.796 0.000 0.000 0.204
#> GSM78526     6  0.1910      0.928 0.000 0.000 0.108 0.000 0.000 0.892
#> GSM78529     3  0.0777      0.905 0.000 0.000 0.972 0.024 0.000 0.004
#> GSM78532     1  0.0000      0.952 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78534     6  0.1890      0.940 0.024 0.000 0.060 0.000 0.000 0.916
#> GSM78537     1  0.0000      0.952 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78543     1  0.1225      0.946 0.952 0.000 0.000 0.000 0.012 0.036
#> GSM78548     3  0.0653      0.907 0.012 0.000 0.980 0.000 0.004 0.004
#> GSM78557     1  0.1426      0.934 0.948 0.000 0.028 0.000 0.016 0.008
#> GSM78560     1  0.0458      0.948 0.984 0.000 0.016 0.000 0.000 0.000
#> GSM78565     1  0.1951      0.933 0.908 0.000 0.000 0.000 0.016 0.076
#> GSM43000     3  0.2491      0.798 0.000 0.000 0.836 0.000 0.000 0.164
#> GSM43002     3  0.0146      0.913 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM43004     6  0.1531      0.853 0.068 0.000 0.004 0.000 0.000 0.928
#> GSM43007     3  0.0146      0.915 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM43010     6  0.1700      0.940 0.004 0.000 0.080 0.000 0.000 0.916
#> GSM78522     6  0.1890      0.940 0.024 0.000 0.060 0.000 0.000 0.916
#> GSM78525     3  0.0146      0.915 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM78528     3  0.0777      0.905 0.000 0.000 0.972 0.024 0.000 0.004
#> GSM78531     1  0.0363      0.952 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM78533     6  0.2048      0.917 0.000 0.000 0.120 0.000 0.000 0.880
#> GSM78536     1  0.1951      0.933 0.908 0.000 0.000 0.000 0.016 0.076
#> GSM78541     1  0.1951      0.933 0.908 0.000 0.000 0.000 0.016 0.076
#> GSM78547     1  0.1390      0.933 0.948 0.000 0.032 0.000 0.016 0.004
#> GSM78552     3  0.3448      0.595 0.280 0.000 0.716 0.000 0.004 0.000
#> GSM78556     1  0.1426      0.934 0.948 0.000 0.028 0.000 0.016 0.008
#> GSM78559     1  0.1951      0.933 0.908 0.000 0.000 0.000 0.016 0.076
#> GSM78564     1  0.0000      0.952 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM42999     2  0.0000      0.865 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43001     2  0.0000      0.865 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43003     2  0.0000      0.865 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43006     2  0.0000      0.865 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43009     2  0.0000      0.865 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43012     2  0.0632      0.846 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM78524     5  0.3446      0.604 0.000 0.308 0.000 0.000 0.692 0.000
#> GSM78527     2  0.0000      0.865 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78530     2  0.3330      0.700 0.000 0.716 0.000 0.000 0.284 0.000
#> GSM78535     5  0.0790      0.617 0.000 0.032 0.000 0.000 0.968 0.000
#> GSM78538     2  0.3221      0.718 0.000 0.736 0.000 0.000 0.264 0.000
#> GSM78542     2  0.3221      0.718 0.000 0.736 0.000 0.000 0.264 0.000
#> GSM78544     2  0.0865      0.850 0.000 0.964 0.000 0.000 0.036 0.000
#> GSM78549     2  0.0000      0.865 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78553     2  0.3330      0.700 0.000 0.716 0.000 0.000 0.284 0.000
#> GSM78558     2  0.3330      0.700 0.000 0.716 0.000 0.000 0.284 0.000
#> GSM78561     2  0.0000      0.865 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-mclust-collect-classes

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

test_to_known_factors(res)
#>             n cell.type(p) agent(p) individual(p) k
#> MAD:mclust 58     2.54e-13  0.00184         1.000 2
#> MAD:mclust 47     7.26e-17  0.00603         0.814 3
#> MAD:mclust 54     1.46e-19  0.00898         0.741 4
#> MAD:mclust 55     3.81e-20  0.01336         0.186 5
#> MAD:mclust 58     3.27e-20  0.03077         0.243 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 58 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.990       0.995         0.4262 0.578   0.578
#> 3 3 0.834           0.872       0.938         0.5612 0.724   0.534
#> 4 4 0.896           0.882       0.943         0.1344 0.903   0.711
#> 5 5 0.778           0.706       0.826         0.0468 0.974   0.899
#> 6 6 0.859           0.833       0.908         0.0412 0.920   0.676

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
#> GSM78539     1  0.0000      0.993 1.000 0.000
#> GSM78545     1  0.0000      0.993 1.000 0.000
#> GSM78550     1  0.0000      0.993 1.000 0.000
#> GSM78554     1  0.0000      0.993 1.000 0.000
#> GSM78562     1  0.0000      0.993 1.000 0.000
#> GSM78540     1  0.5946      0.836 0.856 0.144
#> GSM78546     1  0.1843      0.968 0.972 0.028
#> GSM78551     1  0.0672      0.986 0.992 0.008
#> GSM78555     1  0.0000      0.993 1.000 0.000
#> GSM78563     1  0.0672      0.986 0.992 0.008
#> GSM43005     1  0.0000      0.993 1.000 0.000
#> GSM43008     1  0.0000      0.993 1.000 0.000
#> GSM43011     1  0.0000      0.993 1.000 0.000
#> GSM78523     1  0.0000      0.993 1.000 0.000
#> GSM78526     1  0.0000      0.993 1.000 0.000
#> GSM78529     1  0.4815      0.885 0.896 0.104
#> GSM78532     1  0.0000      0.993 1.000 0.000
#> GSM78534     1  0.0000      0.993 1.000 0.000
#> GSM78537     1  0.0000      0.993 1.000 0.000
#> GSM78543     1  0.0000      0.993 1.000 0.000
#> GSM78548     1  0.0000      0.993 1.000 0.000
#> GSM78557     1  0.0000      0.993 1.000 0.000
#> GSM78560     1  0.0000      0.993 1.000 0.000
#> GSM78565     1  0.0000      0.993 1.000 0.000
#> GSM43000     1  0.0000      0.993 1.000 0.000
#> GSM43002     1  0.0000      0.993 1.000 0.000
#> GSM43004     1  0.0000      0.993 1.000 0.000
#> GSM43007     1  0.0000      0.993 1.000 0.000
#> GSM43010     1  0.0000      0.993 1.000 0.000
#> GSM78522     1  0.0000      0.993 1.000 0.000
#> GSM78525     1  0.0000      0.993 1.000 0.000
#> GSM78528     1  0.0000      0.993 1.000 0.000
#> GSM78531     1  0.0000      0.993 1.000 0.000
#> GSM78533     1  0.0000      0.993 1.000 0.000
#> GSM78536     1  0.0000      0.993 1.000 0.000
#> GSM78541     1  0.0000      0.993 1.000 0.000
#> GSM78547     1  0.0000      0.993 1.000 0.000
#> GSM78552     1  0.0000      0.993 1.000 0.000
#> GSM78556     1  0.0000      0.993 1.000 0.000
#> GSM78559     1  0.0000      0.993 1.000 0.000
#> GSM78564     1  0.0000      0.993 1.000 0.000
#> GSM42999     2  0.0000      1.000 0.000 1.000
#> GSM43001     2  0.0000      1.000 0.000 1.000
#> GSM43003     2  0.0000      1.000 0.000 1.000
#> GSM43006     2  0.0000      1.000 0.000 1.000
#> GSM43009     2  0.0000      1.000 0.000 1.000
#> GSM43012     2  0.0000      1.000 0.000 1.000
#> GSM78524     2  0.0000      1.000 0.000 1.000
#> GSM78527     2  0.0000      1.000 0.000 1.000
#> GSM78530     2  0.0000      1.000 0.000 1.000
#> GSM78535     2  0.0000      1.000 0.000 1.000
#> GSM78538     2  0.0000      1.000 0.000 1.000
#> GSM78542     2  0.0000      1.000 0.000 1.000
#> GSM78544     2  0.0000      1.000 0.000 1.000
#> GSM78549     2  0.0000      1.000 0.000 1.000
#> GSM78553     2  0.0000      1.000 0.000 1.000
#> GSM78558     2  0.0000      1.000 0.000 1.000
#> GSM78561     2  0.0000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     1  0.0237      0.888 0.996 0.000 0.004
#> GSM78545     1  0.6180      0.334 0.584 0.000 0.416
#> GSM78550     1  0.3038      0.860 0.896 0.000 0.104
#> GSM78554     1  0.0892      0.892 0.980 0.000 0.020
#> GSM78562     1  0.0424      0.889 0.992 0.000 0.008
#> GSM78540     1  0.1031      0.875 0.976 0.024 0.000
#> GSM78546     1  0.0592      0.882 0.988 0.012 0.000
#> GSM78551     1  0.0592      0.882 0.988 0.012 0.000
#> GSM78555     1  0.0424      0.884 0.992 0.008 0.000
#> GSM78563     1  0.0592      0.882 0.988 0.012 0.000
#> GSM43005     3  0.1163      0.932 0.028 0.000 0.972
#> GSM43008     3  0.1163      0.932 0.028 0.000 0.972
#> GSM43011     3  0.0424      0.932 0.008 0.000 0.992
#> GSM78523     3  0.0000      0.930 0.000 0.000 1.000
#> GSM78526     3  0.0000      0.930 0.000 0.000 1.000
#> GSM78529     3  0.0237      0.927 0.000 0.004 0.996
#> GSM78532     1  0.4654      0.762 0.792 0.000 0.208
#> GSM78534     3  0.0237      0.931 0.004 0.000 0.996
#> GSM78537     1  0.1411      0.891 0.964 0.000 0.036
#> GSM78543     1  0.1289      0.892 0.968 0.000 0.032
#> GSM78548     3  0.2066      0.905 0.060 0.000 0.940
#> GSM78557     1  0.3116      0.858 0.892 0.000 0.108
#> GSM78560     1  0.4062      0.812 0.836 0.000 0.164
#> GSM78565     1  0.1163      0.892 0.972 0.000 0.028
#> GSM43000     3  0.0000      0.930 0.000 0.000 1.000
#> GSM43002     3  0.1163      0.932 0.028 0.000 0.972
#> GSM43004     3  0.1163      0.932 0.028 0.000 0.972
#> GSM43007     3  0.1289      0.930 0.032 0.000 0.968
#> GSM43010     3  0.0000      0.930 0.000 0.000 1.000
#> GSM78522     3  0.0000      0.930 0.000 0.000 1.000
#> GSM78525     3  0.1163      0.932 0.028 0.000 0.972
#> GSM78528     3  0.0892      0.933 0.020 0.000 0.980
#> GSM78531     1  0.3482      0.845 0.872 0.000 0.128
#> GSM78533     3  0.1031      0.933 0.024 0.000 0.976
#> GSM78536     1  0.1031      0.892 0.976 0.000 0.024
#> GSM78541     1  0.0892      0.892 0.980 0.000 0.020
#> GSM78547     1  0.3686      0.835 0.860 0.000 0.140
#> GSM78552     3  0.6140      0.253 0.404 0.000 0.596
#> GSM78556     1  0.6026      0.452 0.624 0.000 0.376
#> GSM78559     1  0.1289      0.892 0.968 0.000 0.032
#> GSM78564     3  0.6154      0.239 0.408 0.000 0.592
#> GSM42999     2  0.0237      0.988 0.000 0.996 0.004
#> GSM43001     2  0.1163      0.979 0.000 0.972 0.028
#> GSM43003     2  0.0000      0.989 0.000 1.000 0.000
#> GSM43006     2  0.0747      0.985 0.000 0.984 0.016
#> GSM43009     2  0.0747      0.985 0.000 0.984 0.016
#> GSM43012     2  0.1163      0.979 0.000 0.972 0.028
#> GSM78524     2  0.0237      0.989 0.004 0.996 0.000
#> GSM78527     2  0.0000      0.989 0.000 1.000 0.000
#> GSM78530     2  0.0592      0.988 0.012 0.988 0.000
#> GSM78535     1  0.5988      0.357 0.632 0.368 0.000
#> GSM78538     2  0.0592      0.988 0.012 0.988 0.000
#> GSM78542     2  0.0592      0.988 0.012 0.988 0.000
#> GSM78544     2  0.0237      0.989 0.004 0.996 0.000
#> GSM78549     2  0.0424      0.988 0.008 0.992 0.000
#> GSM78553     2  0.0747      0.986 0.016 0.984 0.000
#> GSM78558     2  0.1031      0.981 0.024 0.976 0.000
#> GSM78561     2  0.1031      0.981 0.000 0.976 0.024

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     4  0.0707      0.960 0.020 0.000 0.000 0.980
#> GSM78545     4  0.1584      0.933 0.012 0.000 0.036 0.952
#> GSM78550     4  0.1297      0.952 0.020 0.000 0.016 0.964
#> GSM78554     4  0.0895      0.959 0.020 0.000 0.004 0.976
#> GSM78562     4  0.2921      0.866 0.140 0.000 0.000 0.860
#> GSM78540     4  0.0707      0.960 0.020 0.000 0.000 0.980
#> GSM78546     4  0.0707      0.960 0.020 0.000 0.000 0.980
#> GSM78551     4  0.0707      0.960 0.020 0.000 0.000 0.980
#> GSM78555     4  0.3311      0.821 0.172 0.000 0.000 0.828
#> GSM78563     4  0.0707      0.960 0.020 0.000 0.000 0.980
#> GSM43005     3  0.1389      0.875 0.000 0.000 0.952 0.048
#> GSM43008     3  0.0921      0.887 0.028 0.000 0.972 0.000
#> GSM43011     3  0.0188      0.896 0.004 0.000 0.996 0.000
#> GSM78523     3  0.0188      0.896 0.004 0.000 0.996 0.000
#> GSM78526     3  0.0336      0.896 0.008 0.000 0.992 0.000
#> GSM78529     3  0.2760      0.815 0.000 0.000 0.872 0.128
#> GSM78532     1  0.0188      0.925 0.996 0.000 0.000 0.004
#> GSM78534     3  0.0592      0.894 0.016 0.000 0.984 0.000
#> GSM78537     1  0.0336      0.925 0.992 0.000 0.000 0.008
#> GSM78543     1  0.0188      0.926 0.996 0.000 0.000 0.004
#> GSM78548     3  0.5161      0.135 0.004 0.000 0.520 0.476
#> GSM78557     1  0.2773      0.839 0.880 0.000 0.004 0.116
#> GSM78560     1  0.0592      0.921 0.984 0.000 0.000 0.016
#> GSM78565     1  0.0188      0.926 0.996 0.000 0.000 0.004
#> GSM43000     3  0.0188      0.896 0.004 0.000 0.996 0.000
#> GSM43002     3  0.0336      0.896 0.008 0.000 0.992 0.000
#> GSM43004     3  0.4697      0.429 0.356 0.000 0.644 0.000
#> GSM43007     3  0.0779      0.893 0.016 0.000 0.980 0.004
#> GSM43010     3  0.0336      0.896 0.008 0.000 0.992 0.000
#> GSM78522     3  0.0524      0.895 0.008 0.004 0.988 0.000
#> GSM78525     3  0.0188      0.896 0.004 0.000 0.996 0.000
#> GSM78528     3  0.2408      0.835 0.000 0.000 0.896 0.104
#> GSM78531     1  0.0000      0.924 1.000 0.000 0.000 0.000
#> GSM78533     3  0.0469      0.896 0.012 0.000 0.988 0.000
#> GSM78536     1  0.0188      0.926 0.996 0.000 0.000 0.004
#> GSM78541     1  0.0188      0.926 0.996 0.000 0.000 0.004
#> GSM78547     1  0.1867      0.885 0.928 0.000 0.000 0.072
#> GSM78552     3  0.7220      0.138 0.144 0.000 0.472 0.384
#> GSM78556     1  0.3239      0.860 0.880 0.000 0.068 0.052
#> GSM78559     1  0.0188      0.926 0.996 0.000 0.000 0.004
#> GSM78564     1  0.3052      0.811 0.860 0.000 0.136 0.004
#> GSM42999     2  0.0188      0.990 0.000 0.996 0.000 0.004
#> GSM43001     2  0.0927      0.977 0.000 0.976 0.008 0.016
#> GSM43003     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM43006     2  0.0188      0.990 0.000 0.996 0.000 0.004
#> GSM43009     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM43012     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM78524     2  0.2053      0.922 0.072 0.924 0.000 0.004
#> GSM78527     2  0.0188      0.990 0.000 0.996 0.000 0.004
#> GSM78530     2  0.0188      0.990 0.000 0.996 0.000 0.004
#> GSM78535     1  0.5355      0.396 0.620 0.360 0.000 0.020
#> GSM78538     2  0.0336      0.989 0.000 0.992 0.000 0.008
#> GSM78542     2  0.0336      0.989 0.000 0.992 0.000 0.008
#> GSM78544     2  0.0188      0.990 0.000 0.996 0.000 0.004
#> GSM78549     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM78553     2  0.0336      0.989 0.000 0.992 0.000 0.008
#> GSM78558     2  0.0336      0.989 0.000 0.992 0.000 0.008
#> GSM78561     2  0.0336      0.988 0.000 0.992 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4  0.1410      0.922 0.000 0.000 0.060 0.940 0.000
#> GSM78545     4  0.2471      0.887 0.000 0.000 0.136 0.864 0.000
#> GSM78550     4  0.2732      0.869 0.000 0.000 0.160 0.840 0.000
#> GSM78554     4  0.2648      0.875 0.000 0.000 0.152 0.848 0.000
#> GSM78562     4  0.1205      0.910 0.040 0.000 0.004 0.956 0.000
#> GSM78540     4  0.0000      0.926 0.000 0.000 0.000 1.000 0.000
#> GSM78546     4  0.0404      0.930 0.000 0.000 0.012 0.988 0.000
#> GSM78551     4  0.0510      0.930 0.000 0.000 0.016 0.984 0.000
#> GSM78555     4  0.0794      0.916 0.028 0.000 0.000 0.972 0.000
#> GSM78563     4  0.0000      0.926 0.000 0.000 0.000 1.000 0.000
#> GSM43005     3  0.1498      0.700 0.016 0.000 0.952 0.008 0.024
#> GSM43008     3  0.1818      0.682 0.044 0.000 0.932 0.000 0.024
#> GSM43011     3  0.4242      0.730 0.000 0.000 0.572 0.000 0.428
#> GSM78523     3  0.4242      0.730 0.000 0.000 0.572 0.000 0.428
#> GSM78526     3  0.4504      0.729 0.008 0.000 0.564 0.000 0.428
#> GSM78529     3  0.5025      0.412 0.016 0.000 0.680 0.040 0.264
#> GSM78532     1  0.1121      0.910 0.956 0.000 0.044 0.000 0.000
#> GSM78534     3  0.5538      0.697 0.068 0.000 0.504 0.000 0.428
#> GSM78537     1  0.1662      0.907 0.936 0.000 0.056 0.004 0.004
#> GSM78543     1  0.0324      0.909 0.992 0.000 0.004 0.004 0.000
#> GSM78548     3  0.4462      0.532 0.000 0.000 0.740 0.196 0.064
#> GSM78557     1  0.5489      0.688 0.656 0.000 0.248 0.084 0.012
#> GSM78560     1  0.1952      0.900 0.912 0.000 0.084 0.004 0.000
#> GSM78565     1  0.0510      0.899 0.984 0.000 0.000 0.000 0.016
#> GSM43000     3  0.3774      0.739 0.000 0.000 0.704 0.000 0.296
#> GSM43002     3  0.1386      0.712 0.016 0.000 0.952 0.000 0.032
#> GSM43004     3  0.6420      0.629 0.176 0.000 0.448 0.000 0.376
#> GSM43007     3  0.1469      0.690 0.036 0.000 0.948 0.000 0.016
#> GSM43010     3  0.4604      0.728 0.012 0.000 0.560 0.000 0.428
#> GSM78522     3  0.4696      0.726 0.016 0.000 0.556 0.000 0.428
#> GSM78525     3  0.2806      0.733 0.004 0.000 0.844 0.000 0.152
#> GSM78528     3  0.2131      0.675 0.016 0.000 0.920 0.008 0.056
#> GSM78531     1  0.0510      0.910 0.984 0.000 0.016 0.000 0.000
#> GSM78533     3  0.4504      0.729 0.008 0.000 0.564 0.000 0.428
#> GSM78536     1  0.0162      0.906 0.996 0.000 0.000 0.000 0.004
#> GSM78541     1  0.0324      0.908 0.992 0.000 0.004 0.004 0.000
#> GSM78547     1  0.3111      0.864 0.840 0.000 0.144 0.012 0.004
#> GSM78552     3  0.2765      0.672 0.044 0.000 0.896 0.036 0.024
#> GSM78556     1  0.3883      0.763 0.744 0.000 0.244 0.008 0.004
#> GSM78559     1  0.0404      0.902 0.988 0.000 0.000 0.000 0.012
#> GSM78564     1  0.2471      0.869 0.864 0.000 0.136 0.000 0.000
#> GSM42999     2  0.0162      0.754 0.000 0.996 0.000 0.000 0.004
#> GSM43001     5  0.4307      0.000 0.000 0.500 0.000 0.000 0.500
#> GSM43003     2  0.0290      0.752 0.000 0.992 0.000 0.000 0.008
#> GSM43006     2  0.3895     -0.406 0.000 0.680 0.000 0.000 0.320
#> GSM43009     2  0.0000      0.755 0.000 1.000 0.000 0.000 0.000
#> GSM43012     2  0.1197      0.717 0.000 0.952 0.000 0.000 0.048
#> GSM78524     2  0.2522      0.685 0.056 0.904 0.000 0.028 0.012
#> GSM78527     2  0.0963      0.729 0.000 0.964 0.000 0.000 0.036
#> GSM78530     2  0.0290      0.758 0.000 0.992 0.000 0.008 0.000
#> GSM78535     2  0.6287      0.135 0.244 0.592 0.000 0.144 0.020
#> GSM78538     2  0.1341      0.743 0.000 0.944 0.000 0.056 0.000
#> GSM78542     2  0.0963      0.757 0.000 0.964 0.000 0.036 0.000
#> GSM78544     2  0.0963      0.757 0.000 0.964 0.000 0.036 0.000
#> GSM78549     2  0.1544      0.683 0.000 0.932 0.000 0.000 0.068
#> GSM78553     2  0.1121      0.752 0.000 0.956 0.000 0.044 0.000
#> GSM78558     2  0.2020      0.683 0.000 0.900 0.000 0.100 0.000
#> GSM78561     2  0.4306     -0.980 0.000 0.508 0.000 0.000 0.492

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM78539     4  0.0603      0.967 0.016 0.000 0.004 0.980 0.000 0.000
#> GSM78545     4  0.1296      0.955 0.000 0.000 0.032 0.952 0.004 0.012
#> GSM78550     4  0.1327      0.939 0.000 0.000 0.064 0.936 0.000 0.000
#> GSM78554     4  0.1327      0.940 0.000 0.000 0.064 0.936 0.000 0.000
#> GSM78562     4  0.0363      0.969 0.012 0.000 0.000 0.988 0.000 0.000
#> GSM78540     4  0.0146      0.972 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM78546     4  0.0000      0.972 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78551     4  0.0291      0.973 0.000 0.000 0.004 0.992 0.004 0.000
#> GSM78555     4  0.0260      0.972 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM78563     4  0.0260      0.972 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM43005     3  0.2773      0.824 0.004 0.000 0.828 0.000 0.004 0.164
#> GSM43008     3  0.2257      0.828 0.008 0.000 0.876 0.000 0.000 0.116
#> GSM43011     6  0.0363      0.951 0.000 0.000 0.012 0.000 0.000 0.988
#> GSM78523     6  0.0260      0.953 0.000 0.000 0.008 0.000 0.000 0.992
#> GSM78526     6  0.0000      0.956 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78529     3  0.1845      0.786 0.000 0.000 0.920 0.000 0.028 0.052
#> GSM78532     1  0.1349      0.896 0.940 0.000 0.056 0.004 0.000 0.000
#> GSM78534     6  0.0508      0.949 0.000 0.000 0.004 0.000 0.012 0.984
#> GSM78537     1  0.1644      0.891 0.920 0.004 0.076 0.000 0.000 0.000
#> GSM78543     1  0.0508      0.895 0.984 0.000 0.012 0.004 0.000 0.000
#> GSM78548     3  0.3728      0.782 0.004 0.000 0.748 0.012 0.008 0.228
#> GSM78557     3  0.3737      0.155 0.392 0.000 0.608 0.000 0.000 0.000
#> GSM78560     1  0.1908      0.880 0.900 0.000 0.096 0.004 0.000 0.000
#> GSM78565     1  0.0291      0.888 0.992 0.000 0.004 0.000 0.004 0.000
#> GSM43000     6  0.2838      0.696 0.000 0.000 0.188 0.000 0.004 0.808
#> GSM43002     3  0.3489      0.712 0.000 0.000 0.708 0.000 0.004 0.288
#> GSM43004     6  0.1152      0.911 0.044 0.000 0.000 0.000 0.004 0.952
#> GSM43007     3  0.2362      0.831 0.004 0.000 0.860 0.000 0.000 0.136
#> GSM43010     6  0.0000      0.956 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78522     6  0.0000      0.956 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78525     3  0.3955      0.431 0.000 0.000 0.560 0.000 0.004 0.436
#> GSM78528     3  0.0858      0.772 0.004 0.000 0.968 0.000 0.000 0.028
#> GSM78531     1  0.1010      0.897 0.960 0.000 0.036 0.004 0.000 0.000
#> GSM78533     6  0.0000      0.956 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78536     1  0.0146      0.890 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM78541     1  0.0508      0.893 0.984 0.000 0.012 0.000 0.004 0.000
#> GSM78547     1  0.3189      0.745 0.760 0.000 0.236 0.004 0.000 0.000
#> GSM78552     3  0.2442      0.830 0.004 0.000 0.852 0.000 0.000 0.144
#> GSM78556     1  0.3976      0.463 0.612 0.000 0.380 0.004 0.000 0.004
#> GSM78559     1  0.0291      0.888 0.992 0.000 0.004 0.000 0.004 0.000
#> GSM78564     1  0.2876      0.824 0.836 0.000 0.148 0.004 0.004 0.008
#> GSM42999     2  0.1010      0.881 0.000 0.960 0.004 0.000 0.036 0.000
#> GSM43001     5  0.1387      0.823 0.000 0.068 0.000 0.000 0.932 0.000
#> GSM43003     2  0.1444      0.862 0.000 0.928 0.000 0.000 0.072 0.000
#> GSM43006     5  0.3531      0.518 0.000 0.328 0.000 0.000 0.672 0.000
#> GSM43009     2  0.0508      0.890 0.000 0.984 0.000 0.000 0.012 0.004
#> GSM43012     2  0.3281      0.704 0.000 0.784 0.004 0.000 0.200 0.012
#> GSM78524     2  0.1223      0.882 0.012 0.960 0.008 0.004 0.016 0.000
#> GSM78527     2  0.2092      0.818 0.000 0.876 0.000 0.000 0.124 0.000
#> GSM78530     2  0.0146      0.891 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM78535     2  0.3316      0.723 0.124 0.828 0.000 0.024 0.024 0.000
#> GSM78538     2  0.0260      0.891 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM78542     2  0.0260      0.891 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM78544     2  0.0551      0.888 0.000 0.984 0.004 0.000 0.008 0.004
#> GSM78549     2  0.3804      0.139 0.000 0.576 0.000 0.000 0.424 0.000
#> GSM78553     2  0.0405      0.889 0.000 0.988 0.000 0.004 0.008 0.000
#> GSM78558     2  0.1088      0.872 0.000 0.960 0.000 0.024 0.016 0.000
#> GSM78561     5  0.1141      0.817 0.000 0.052 0.000 0.000 0.948 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-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 cell.type(p) agent(p) individual(p) k
#> MAD:NMF 58     2.54e-13  0.00184        0.9999 2
#> MAD:NMF 53     7.72e-14  0.00271        0.2899 3
#> MAD:NMF 54     5.34e-21  0.00970        0.2271 4
#> MAD:NMF 53     1.40e-20  0.02814        0.2835 5
#> MAD:NMF 54     1.35e-18  0.04270        0.0824 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 58 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 0.496           0.886       0.903          0.430 0.501   0.501
#> 3 3 0.757           0.819       0.926          0.346 0.940   0.879
#> 4 4 0.737           0.714       0.858          0.199 0.890   0.750
#> 5 5 0.732           0.757       0.827          0.108 0.791   0.456
#> 6 6 0.857           0.785       0.915          0.061 0.949   0.779

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
#> GSM78539     1  0.4562      0.871 0.904 0.096
#> GSM78545     2  0.8608      0.853 0.284 0.716
#> GSM78550     1  0.0000      0.962 1.000 0.000
#> GSM78554     1  0.4562      0.871 0.904 0.096
#> GSM78562     1  0.0000      0.962 1.000 0.000
#> GSM78540     1  0.0000      0.962 1.000 0.000
#> GSM78546     2  0.8608      0.853 0.284 0.716
#> GSM78551     1  0.0000      0.962 1.000 0.000
#> GSM78555     1  0.0000      0.962 1.000 0.000
#> GSM78563     1  0.0000      0.962 1.000 0.000
#> GSM43005     2  0.8608      0.853 0.284 0.716
#> GSM43008     2  0.8608      0.853 0.284 0.716
#> GSM43011     2  0.8608      0.853 0.284 0.716
#> GSM78523     2  0.8144      0.851 0.252 0.748
#> GSM78526     1  0.0000      0.962 1.000 0.000
#> GSM78529     2  0.0000      0.763 0.000 1.000
#> GSM78532     1  0.0000      0.962 1.000 0.000
#> GSM78534     1  0.0000      0.962 1.000 0.000
#> GSM78537     1  0.0000      0.962 1.000 0.000
#> GSM78543     1  0.6343      0.783 0.840 0.160
#> GSM78548     1  0.0000      0.962 1.000 0.000
#> GSM78557     1  0.6343      0.783 0.840 0.160
#> GSM78560     1  0.6343      0.783 0.840 0.160
#> GSM78565     1  0.0000      0.962 1.000 0.000
#> GSM43000     2  0.8144      0.851 0.252 0.748
#> GSM43002     2  0.8608      0.853 0.284 0.716
#> GSM43004     1  0.0000      0.962 1.000 0.000
#> GSM43007     2  0.8608      0.853 0.284 0.716
#> GSM43010     1  0.0000      0.962 1.000 0.000
#> GSM78522     2  0.8608      0.853 0.284 0.716
#> GSM78525     2  0.8608      0.853 0.284 0.716
#> GSM78528     2  0.8327      0.854 0.264 0.736
#> GSM78531     1  0.0000      0.962 1.000 0.000
#> GSM78533     1  0.3879      0.893 0.924 0.076
#> GSM78536     1  0.0000      0.962 1.000 0.000
#> GSM78541     1  0.0000      0.962 1.000 0.000
#> GSM78547     1  0.0000      0.962 1.000 0.000
#> GSM78552     2  0.8608      0.853 0.284 0.716
#> GSM78556     1  0.0000      0.962 1.000 0.000
#> GSM78559     1  0.0000      0.962 1.000 0.000
#> GSM78564     1  0.6343      0.783 0.840 0.160
#> GSM42999     2  0.0000      0.763 0.000 1.000
#> GSM43001     2  0.0000      0.763 0.000 1.000
#> GSM43003     2  0.0000      0.763 0.000 1.000
#> GSM43006     2  0.0000      0.763 0.000 1.000
#> GSM43009     2  0.8443      0.854 0.272 0.728
#> GSM43012     2  0.0000      0.763 0.000 1.000
#> GSM78524     1  0.0000      0.962 1.000 0.000
#> GSM78527     2  0.0000      0.763 0.000 1.000
#> GSM78530     2  0.8608      0.853 0.284 0.716
#> GSM78535     1  0.0000      0.962 1.000 0.000
#> GSM78538     1  0.0000      0.962 1.000 0.000
#> GSM78542     1  0.0000      0.962 1.000 0.000
#> GSM78544     2  0.8608      0.853 0.284 0.716
#> GSM78549     2  0.8443      0.854 0.272 0.728
#> GSM78553     1  0.0000      0.962 1.000 0.000
#> GSM78558     1  0.0376      0.959 0.996 0.004
#> GSM78561     2  0.0000      0.763 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     1  0.5859      0.554 0.656 0.000 0.344
#> GSM78545     3  0.0000      0.927 0.000 0.000 1.000
#> GSM78550     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78554     1  0.5859      0.554 0.656 0.000 0.344
#> GSM78562     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78540     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78546     3  0.0000      0.927 0.000 0.000 1.000
#> GSM78551     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78555     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78563     1  0.0000      0.896 1.000 0.000 0.000
#> GSM43005     3  0.0000      0.927 0.000 0.000 1.000
#> GSM43008     3  0.0000      0.927 0.000 0.000 1.000
#> GSM43011     3  0.0000      0.927 0.000 0.000 1.000
#> GSM78523     3  0.1411      0.907 0.000 0.036 0.964
#> GSM78526     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78529     2  0.5650      0.508 0.000 0.688 0.312
#> GSM78532     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78534     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78537     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78543     1  0.6252      0.365 0.556 0.000 0.444
#> GSM78548     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78557     1  0.6252      0.365 0.556 0.000 0.444
#> GSM78560     1  0.6252      0.365 0.556 0.000 0.444
#> GSM78565     1  0.0000      0.896 1.000 0.000 0.000
#> GSM43000     3  0.1289      0.910 0.000 0.032 0.968
#> GSM43002     3  0.0000      0.927 0.000 0.000 1.000
#> GSM43004     1  0.0000      0.896 1.000 0.000 0.000
#> GSM43007     3  0.0000      0.927 0.000 0.000 1.000
#> GSM43010     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78522     3  0.0000      0.927 0.000 0.000 1.000
#> GSM78525     3  0.0000      0.927 0.000 0.000 1.000
#> GSM78528     3  0.0892      0.918 0.000 0.020 0.980
#> GSM78531     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78533     1  0.5560      0.616 0.700 0.000 0.300
#> GSM78536     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78541     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78547     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78552     3  0.0000      0.927 0.000 0.000 1.000
#> GSM78556     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78559     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78564     1  0.6244      0.373 0.560 0.000 0.440
#> GSM42999     2  0.1643      0.882 0.000 0.956 0.044
#> GSM43001     2  0.0000      0.901 0.000 1.000 0.000
#> GSM43003     3  0.5591      0.514 0.000 0.304 0.696
#> GSM43006     2  0.0000      0.901 0.000 1.000 0.000
#> GSM43009     3  0.0592      0.922 0.000 0.012 0.988
#> GSM43012     3  0.5591      0.514 0.000 0.304 0.696
#> GSM78524     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78527     3  0.6244      0.183 0.000 0.440 0.560
#> GSM78530     3  0.0000      0.927 0.000 0.000 1.000
#> GSM78535     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78538     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78542     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78544     3  0.0000      0.927 0.000 0.000 1.000
#> GSM78549     3  0.0592      0.922 0.000 0.012 0.988
#> GSM78553     1  0.0000      0.896 1.000 0.000 0.000
#> GSM78558     1  0.0592      0.887 0.988 0.000 0.012
#> GSM78561     2  0.0000      0.901 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     4  0.2921      0.866 0.140 0.000 0.000 0.860
#> GSM78545     3  0.0336      0.896 0.000 0.000 0.992 0.008
#> GSM78550     1  0.4888      0.493 0.588 0.000 0.000 0.412
#> GSM78554     4  0.2921      0.866 0.140 0.000 0.000 0.860
#> GSM78562     1  0.0000      0.718 1.000 0.000 0.000 0.000
#> GSM78540     1  0.5000      0.287 0.504 0.000 0.000 0.496
#> GSM78546     3  0.0336      0.896 0.000 0.000 0.992 0.008
#> GSM78551     1  0.4888      0.493 0.588 0.000 0.000 0.412
#> GSM78555     1  0.0000      0.718 1.000 0.000 0.000 0.000
#> GSM78563     1  0.5000      0.287 0.504 0.000 0.000 0.496
#> GSM43005     3  0.0336      0.896 0.000 0.000 0.992 0.008
#> GSM43008     3  0.0336      0.896 0.000 0.000 0.992 0.008
#> GSM43011     3  0.0336      0.896 0.000 0.000 0.992 0.008
#> GSM78523     3  0.1867      0.856 0.000 0.072 0.928 0.000
#> GSM78526     1  0.4888      0.493 0.588 0.000 0.000 0.412
#> GSM78529     2  0.4250      0.524 0.000 0.724 0.276 0.000
#> GSM78532     1  0.0000      0.718 1.000 0.000 0.000 0.000
#> GSM78534     1  0.0000      0.718 1.000 0.000 0.000 0.000
#> GSM78537     1  0.0000      0.718 1.000 0.000 0.000 0.000
#> GSM78543     4  0.2111      0.907 0.044 0.000 0.024 0.932
#> GSM78548     1  0.4888      0.493 0.588 0.000 0.000 0.412
#> GSM78557     4  0.2111      0.907 0.044 0.000 0.024 0.932
#> GSM78560     4  0.2111      0.907 0.044 0.000 0.024 0.932
#> GSM78565     1  0.0000      0.718 1.000 0.000 0.000 0.000
#> GSM43000     3  0.1792      0.858 0.000 0.068 0.932 0.000
#> GSM43002     3  0.0336      0.896 0.000 0.000 0.992 0.008
#> GSM43004     1  0.0000      0.718 1.000 0.000 0.000 0.000
#> GSM43007     3  0.0336      0.896 0.000 0.000 0.992 0.008
#> GSM43010     1  0.4888      0.493 0.588 0.000 0.000 0.412
#> GSM78522     3  0.4907      0.394 0.000 0.000 0.580 0.420
#> GSM78525     3  0.0336      0.896 0.000 0.000 0.992 0.008
#> GSM78528     3  0.0921      0.881 0.000 0.028 0.972 0.000
#> GSM78531     1  0.0000      0.718 1.000 0.000 0.000 0.000
#> GSM78533     4  0.3528      0.777 0.192 0.000 0.000 0.808
#> GSM78536     1  0.0000      0.718 1.000 0.000 0.000 0.000
#> GSM78541     1  0.0000      0.718 1.000 0.000 0.000 0.000
#> GSM78547     1  0.0000      0.718 1.000 0.000 0.000 0.000
#> GSM78552     3  0.0336      0.896 0.000 0.000 0.992 0.008
#> GSM78556     1  0.5000      0.287 0.504 0.000 0.000 0.496
#> GSM78559     1  0.0000      0.718 1.000 0.000 0.000 0.000
#> GSM78564     4  0.2089      0.907 0.048 0.000 0.020 0.932
#> GSM42999     2  0.0000      0.873 0.000 1.000 0.000 0.000
#> GSM43001     2  0.1716      0.892 0.000 0.936 0.000 0.064
#> GSM43003     3  0.4624      0.522 0.000 0.340 0.660 0.000
#> GSM43006     2  0.1716      0.892 0.000 0.936 0.000 0.064
#> GSM43009     3  0.0188      0.891 0.000 0.004 0.996 0.000
#> GSM43012     3  0.4624      0.522 0.000 0.340 0.660 0.000
#> GSM78524     1  0.0000      0.718 1.000 0.000 0.000 0.000
#> GSM78527     3  0.4992      0.196 0.000 0.476 0.524 0.000
#> GSM78530     3  0.0336      0.896 0.000 0.000 0.992 0.008
#> GSM78535     1  0.0000      0.718 1.000 0.000 0.000 0.000
#> GSM78538     1  0.4888      0.493 0.588 0.000 0.000 0.412
#> GSM78542     1  0.4888      0.493 0.588 0.000 0.000 0.412
#> GSM78544     3  0.0336      0.896 0.000 0.000 0.992 0.008
#> GSM78549     3  0.1545      0.878 0.000 0.040 0.952 0.008
#> GSM78553     1  0.4888      0.493 0.588 0.000 0.000 0.412
#> GSM78558     1  0.4916      0.472 0.576 0.000 0.000 0.424
#> GSM78561     2  0.1716      0.892 0.000 0.936 0.000 0.064

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4   0.483      0.627 0.028 0.308 0.008 0.656 0.000
#> GSM78545     3   0.000      0.883 0.000 0.000 1.000 0.000 0.000
#> GSM78550     4   0.314      0.745 0.204 0.000 0.000 0.796 0.000
#> GSM78554     4   0.483      0.627 0.028 0.308 0.008 0.656 0.000
#> GSM78562     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM78540     4   0.321      0.701 0.212 0.000 0.000 0.788 0.000
#> GSM78546     3   0.000      0.883 0.000 0.000 1.000 0.000 0.000
#> GSM78551     4   0.314      0.745 0.204 0.000 0.000 0.796 0.000
#> GSM78555     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM78563     4   0.321      0.701 0.212 0.000 0.000 0.788 0.000
#> GSM43005     3   0.000      0.883 0.000 0.000 1.000 0.000 0.000
#> GSM43008     3   0.000      0.883 0.000 0.000 1.000 0.000 0.000
#> GSM43011     3   0.000      0.883 0.000 0.000 1.000 0.000 0.000
#> GSM78523     5   0.424      0.511 0.000 0.000 0.428 0.000 0.572
#> GSM78526     4   0.314      0.745 0.204 0.000 0.000 0.796 0.000
#> GSM78529     5   0.591     -0.318 0.000 0.348 0.116 0.000 0.536
#> GSM78532     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM78534     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM78537     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM78543     4   0.448      0.562 0.000 0.376 0.012 0.612 0.000
#> GSM78548     4   0.314      0.745 0.204 0.000 0.000 0.796 0.000
#> GSM78557     4   0.448      0.562 0.000 0.376 0.012 0.612 0.000
#> GSM78560     4   0.448      0.562 0.000 0.376 0.012 0.612 0.000
#> GSM78565     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM43000     5   0.425      0.505 0.000 0.000 0.432 0.000 0.568
#> GSM43002     3   0.000      0.883 0.000 0.000 1.000 0.000 0.000
#> GSM43004     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM43007     3   0.000      0.883 0.000 0.000 1.000 0.000 0.000
#> GSM43010     4   0.314      0.745 0.204 0.000 0.000 0.796 0.000
#> GSM78522     3   0.528      0.262 0.000 0.376 0.568 0.056 0.000
#> GSM78525     3   0.000      0.883 0.000 0.000 1.000 0.000 0.000
#> GSM78528     5   0.430      0.423 0.000 0.000 0.472 0.000 0.528
#> GSM78531     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM78533     4   0.482      0.650 0.040 0.264 0.008 0.688 0.000
#> GSM78536     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM78541     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM78547     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM78552     3   0.000      0.883 0.000 0.000 1.000 0.000 0.000
#> GSM78556     4   0.321      0.701 0.212 0.000 0.000 0.788 0.000
#> GSM78559     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM78564     4   0.463      0.565 0.004 0.376 0.012 0.608 0.000
#> GSM42999     2   0.430      0.868 0.000 0.520 0.000 0.000 0.480
#> GSM43001     2   0.411      0.959 0.000 0.624 0.000 0.000 0.376
#> GSM43003     5   0.265      0.579 0.000 0.000 0.152 0.000 0.848
#> GSM43006     2   0.411      0.959 0.000 0.624 0.000 0.000 0.376
#> GSM43009     3   0.415     -0.127 0.000 0.000 0.612 0.000 0.388
#> GSM43012     5   0.265      0.579 0.000 0.000 0.152 0.000 0.848
#> GSM78524     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM78527     5   0.445      0.414 0.000 0.112 0.128 0.000 0.760
#> GSM78530     3   0.029      0.875 0.000 0.000 0.992 0.000 0.008
#> GSM78535     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM78538     4   0.314      0.745 0.204 0.000 0.000 0.796 0.000
#> GSM78542     4   0.314      0.745 0.204 0.000 0.000 0.796 0.000
#> GSM78544     3   0.000      0.883 0.000 0.000 1.000 0.000 0.000
#> GSM78549     3   0.269      0.660 0.000 0.000 0.844 0.000 0.156
#> GSM78553     4   0.314      0.745 0.204 0.000 0.000 0.796 0.000
#> GSM78558     4   0.353      0.744 0.204 0.012 0.000 0.784 0.000
#> GSM78561     2   0.411      0.959 0.000 0.624 0.000 0.000 0.376

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM78539     6  0.2631   0.771386 0.000 0.000 0.000 0.180 0.000 0.820
#> GSM78545     3  0.0000   0.893041 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM78550     4  0.0000   0.859700 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78554     6  0.2631   0.771386 0.000 0.000 0.000 0.180 0.000 0.820
#> GSM78562     1  0.0000   0.999198 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78540     4  0.4693   0.614833 0.176 0.000 0.000 0.684 0.000 0.140
#> GSM78546     3  0.0000   0.893041 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM78551     4  0.0146   0.858214 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM78555     1  0.0000   0.999198 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78563     4  0.4693   0.614833 0.176 0.000 0.000 0.684 0.000 0.140
#> GSM43005     3  0.0000   0.893041 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM43008     3  0.0000   0.893041 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM43011     3  0.0000   0.893041 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM78523     5  0.3592   0.534062 0.000 0.000 0.344 0.000 0.656 0.000
#> GSM78526     4  0.0000   0.859700 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78529     5  0.3717  -0.131603 0.000 0.384 0.000 0.000 0.616 0.000
#> GSM78532     1  0.0000   0.999198 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78534     1  0.0146   0.995180 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM78537     1  0.0000   0.999198 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78543     6  0.0000   0.830668 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78548     4  0.0000   0.859700 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78557     6  0.0000   0.830668 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78560     6  0.0000   0.830668 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM78565     1  0.0000   0.999198 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM43000     5  0.3607   0.528814 0.000 0.000 0.348 0.000 0.652 0.000
#> GSM43002     3  0.0000   0.893041 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM43004     1  0.0000   0.999198 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM43007     3  0.0000   0.893041 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM43010     4  0.0000   0.859700 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78522     3  0.3833   0.186681 0.000 0.000 0.556 0.000 0.000 0.444
#> GSM78525     3  0.0000   0.893041 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM78528     5  0.3737   0.448739 0.000 0.000 0.392 0.000 0.608 0.000
#> GSM78531     1  0.0000   0.999198 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78533     6  0.3737   0.395323 0.000 0.000 0.000 0.392 0.000 0.608
#> GSM78536     1  0.0000   0.999198 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0000   0.999198 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78547     1  0.0000   0.999198 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78552     3  0.0000   0.893041 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM78556     4  0.4693   0.614833 0.176 0.000 0.000 0.684 0.000 0.140
#> GSM78559     1  0.0000   0.999198 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78564     6  0.0146   0.831182 0.000 0.000 0.000 0.004 0.000 0.996
#> GSM42999     2  0.3288   0.642742 0.000 0.724 0.000 0.000 0.276 0.000
#> GSM43001     2  0.0000   0.901514 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43003     5  0.0000   0.570401 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM43006     2  0.0000   0.901514 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43009     3  0.3782  -0.000383 0.000 0.000 0.588 0.000 0.412 0.000
#> GSM43012     5  0.0000   0.570401 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM78524     1  0.0146   0.995180 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM78527     5  0.2219   0.453728 0.000 0.136 0.000 0.000 0.864 0.000
#> GSM78530     3  0.0260   0.886183 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM78535     1  0.0000   0.999198 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78538     4  0.0000   0.859700 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78542     4  0.0000   0.859700 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78544     3  0.0000   0.893041 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM78549     3  0.2631   0.669852 0.000 0.000 0.820 0.000 0.180 0.000
#> GSM78553     4  0.1204   0.820208 0.000 0.000 0.000 0.944 0.000 0.056
#> GSM78558     4  0.3050   0.586517 0.000 0.000 0.000 0.764 0.000 0.236
#> GSM78561     2  0.0000   0.901514 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

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

test_to_known_factors(res)
#>             n cell.type(p) agent(p) individual(p) k
#> ATC:hclust 58       0.0591    0.340       0.00642 2
#> ATC:hclust 53       0.0630    0.728       0.09488 3
#> ATC:hclust 44       0.0642    0.181       0.22427 4
#> ATC:hclust 53       0.0448    0.595       0.00981 5
#> ATC:hclust 52       0.0483    0.106       0.06992 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 58 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 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-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.4996 0.501   0.501
#> 3 3 0.557           0.774       0.878         0.2670 0.624   0.393
#> 4 4 1.000           0.965       0.971         0.1616 0.761   0.443
#> 5 5 0.811           0.856       0.876         0.0585 1.000   1.000
#> 6 6 0.787           0.742       0.781         0.0435 1.000   1.000

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

suggest_best_k(res)
#> [1] 4
#> 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
#> GSM78539     1       0          1  1  0
#> GSM78545     2       0          1  0  1
#> GSM78550     1       0          1  1  0
#> GSM78554     1       0          1  1  0
#> GSM78562     1       0          1  1  0
#> GSM78540     1       0          1  1  0
#> GSM78546     2       0          1  0  1
#> GSM78551     1       0          1  1  0
#> GSM78555     1       0          1  1  0
#> GSM78563     1       0          1  1  0
#> GSM43005     2       0          1  0  1
#> GSM43008     2       0          1  0  1
#> GSM43011     2       0          1  0  1
#> GSM78523     2       0          1  0  1
#> GSM78526     1       0          1  1  0
#> GSM78529     2       0          1  0  1
#> GSM78532     1       0          1  1  0
#> GSM78534     1       0          1  1  0
#> GSM78537     1       0          1  1  0
#> GSM78543     1       0          1  1  0
#> GSM78548     1       0          1  1  0
#> GSM78557     1       0          1  1  0
#> GSM78560     1       0          1  1  0
#> GSM78565     1       0          1  1  0
#> GSM43000     2       0          1  0  1
#> GSM43002     2       0          1  0  1
#> GSM43004     1       0          1  1  0
#> GSM43007     2       0          1  0  1
#> GSM43010     1       0          1  1  0
#> GSM78522     2       0          1  0  1
#> GSM78525     2       0          1  0  1
#> GSM78528     2       0          1  0  1
#> GSM78531     1       0          1  1  0
#> GSM78533     1       0          1  1  0
#> GSM78536     1       0          1  1  0
#> GSM78541     1       0          1  1  0
#> GSM78547     1       0          1  1  0
#> GSM78552     2       0          1  0  1
#> GSM78556     1       0          1  1  0
#> GSM78559     1       0          1  1  0
#> GSM78564     1       0          1  1  0
#> GSM42999     2       0          1  0  1
#> GSM43001     2       0          1  0  1
#> GSM43003     2       0          1  0  1
#> GSM43006     2       0          1  0  1
#> GSM43009     2       0          1  0  1
#> GSM43012     2       0          1  0  1
#> GSM78524     1       0          1  1  0
#> GSM78527     2       0          1  0  1
#> GSM78530     2       0          1  0  1
#> GSM78535     1       0          1  1  0
#> GSM78538     1       0          1  1  0
#> GSM78542     1       0          1  1  0
#> GSM78544     2       0          1  0  1
#> GSM78549     2       0          1  0  1
#> GSM78553     1       0          1  1  0
#> GSM78558     1       0          1  1  0
#> GSM78561     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     3  0.4555      0.720 0.200 0.000 0.800
#> GSM78545     3  0.4842      0.637 0.000 0.224 0.776
#> GSM78550     3  0.4555      0.720 0.200 0.000 0.800
#> GSM78554     3  0.4555      0.720 0.200 0.000 0.800
#> GSM78562     1  0.0000      0.941 1.000 0.000 0.000
#> GSM78540     1  0.4842      0.763 0.776 0.000 0.224
#> GSM78546     3  0.2711      0.707 0.000 0.088 0.912
#> GSM78551     3  0.4654      0.710 0.208 0.000 0.792
#> GSM78555     1  0.0000      0.941 1.000 0.000 0.000
#> GSM78563     1  0.4842      0.763 0.776 0.000 0.224
#> GSM43005     3  0.0592      0.727 0.000 0.012 0.988
#> GSM43008     3  0.4605      0.653 0.000 0.204 0.796
#> GSM43011     3  0.4842      0.637 0.000 0.224 0.776
#> GSM78523     2  0.5591      0.643 0.000 0.696 0.304
#> GSM78526     3  0.4555      0.720 0.200 0.000 0.800
#> GSM78529     2  0.0000      0.872 0.000 1.000 0.000
#> GSM78532     1  0.0000      0.941 1.000 0.000 0.000
#> GSM78534     1  0.0000      0.941 1.000 0.000 0.000
#> GSM78537     1  0.0000      0.941 1.000 0.000 0.000
#> GSM78543     3  0.4555      0.720 0.200 0.000 0.800
#> GSM78548     3  0.0000      0.729 0.000 0.000 1.000
#> GSM78557     3  0.4555      0.720 0.200 0.000 0.800
#> GSM78560     3  0.0000      0.729 0.000 0.000 1.000
#> GSM78565     1  0.0000      0.941 1.000 0.000 0.000
#> GSM43000     2  0.6008      0.524 0.000 0.628 0.372
#> GSM43002     3  0.4842      0.637 0.000 0.224 0.776
#> GSM43004     1  0.0000      0.941 1.000 0.000 0.000
#> GSM43007     3  0.4605      0.653 0.000 0.204 0.796
#> GSM43010     3  0.4605      0.715 0.204 0.000 0.796
#> GSM78522     3  0.4842      0.637 0.000 0.224 0.776
#> GSM78525     3  0.4842      0.637 0.000 0.224 0.776
#> GSM78528     2  0.6008      0.524 0.000 0.628 0.372
#> GSM78531     1  0.0000      0.941 1.000 0.000 0.000
#> GSM78533     3  0.4555      0.720 0.200 0.000 0.800
#> GSM78536     1  0.0000      0.941 1.000 0.000 0.000
#> GSM78541     1  0.0000      0.941 1.000 0.000 0.000
#> GSM78547     1  0.0000      0.941 1.000 0.000 0.000
#> GSM78552     3  0.4842      0.637 0.000 0.224 0.776
#> GSM78556     1  0.4842      0.763 0.776 0.000 0.224
#> GSM78559     1  0.0000      0.941 1.000 0.000 0.000
#> GSM78564     3  0.4555      0.720 0.200 0.000 0.800
#> GSM42999     2  0.0000      0.872 0.000 1.000 0.000
#> GSM43001     2  0.0000      0.872 0.000 1.000 0.000
#> GSM43003     2  0.0000      0.872 0.000 1.000 0.000
#> GSM43006     2  0.0000      0.872 0.000 1.000 0.000
#> GSM43009     2  0.4702      0.746 0.000 0.788 0.212
#> GSM43012     2  0.0000      0.872 0.000 1.000 0.000
#> GSM78524     1  0.0000      0.941 1.000 0.000 0.000
#> GSM78527     2  0.0000      0.872 0.000 1.000 0.000
#> GSM78530     3  0.4842      0.637 0.000 0.224 0.776
#> GSM78535     1  0.0000      0.941 1.000 0.000 0.000
#> GSM78538     1  0.4842      0.763 0.776 0.000 0.224
#> GSM78542     3  0.4654      0.710 0.208 0.000 0.792
#> GSM78544     3  0.4605      0.653 0.000 0.204 0.796
#> GSM78549     3  0.4887      0.631 0.000 0.228 0.772
#> GSM78553     3  0.4555      0.720 0.200 0.000 0.800
#> GSM78558     3  0.0000      0.729 0.000 0.000 1.000
#> GSM78561     2  0.0000      0.872 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     4  0.0376      0.990 0.000 0.004 0.004 0.992
#> GSM78545     3  0.0000      0.989 0.000 0.000 1.000 0.000
#> GSM78550     4  0.0188      0.991 0.000 0.000 0.004 0.996
#> GSM78554     4  0.0188      0.991 0.000 0.000 0.004 0.996
#> GSM78562     1  0.1837      0.987 0.944 0.028 0.000 0.028
#> GSM78540     4  0.0376      0.989 0.004 0.004 0.000 0.992
#> GSM78546     3  0.0817      0.965 0.000 0.000 0.976 0.024
#> GSM78551     4  0.0188      0.991 0.000 0.000 0.004 0.996
#> GSM78555     1  0.1256      0.989 0.964 0.008 0.000 0.028
#> GSM78563     4  0.0376      0.989 0.004 0.004 0.000 0.992
#> GSM43005     3  0.1118      0.950 0.000 0.000 0.964 0.036
#> GSM43008     3  0.0188      0.987 0.000 0.000 0.996 0.004
#> GSM43011     3  0.0000      0.989 0.000 0.000 1.000 0.000
#> GSM78523     3  0.0000      0.989 0.000 0.000 1.000 0.000
#> GSM78526     4  0.0188      0.991 0.000 0.000 0.004 0.996
#> GSM78529     2  0.1118      0.928 0.000 0.964 0.036 0.000
#> GSM78532     1  0.1510      0.989 0.956 0.016 0.000 0.028
#> GSM78534     1  0.1837      0.987 0.944 0.028 0.000 0.028
#> GSM78537     1  0.1388      0.990 0.960 0.012 0.000 0.028
#> GSM78543     4  0.0376      0.990 0.000 0.004 0.004 0.992
#> GSM78548     4  0.1022      0.964 0.000 0.000 0.032 0.968
#> GSM78557     4  0.0376      0.990 0.000 0.004 0.004 0.992
#> GSM78560     4  0.1209      0.964 0.000 0.004 0.032 0.964
#> GSM78565     1  0.1109      0.989 0.968 0.004 0.000 0.028
#> GSM43000     3  0.0000      0.989 0.000 0.000 1.000 0.000
#> GSM43002     3  0.0000      0.989 0.000 0.000 1.000 0.000
#> GSM43004     1  0.1837      0.987 0.944 0.028 0.000 0.028
#> GSM43007     3  0.0188      0.987 0.000 0.000 0.996 0.004
#> GSM43010     4  0.0188      0.991 0.000 0.000 0.004 0.996
#> GSM78522     3  0.0000      0.989 0.000 0.000 1.000 0.000
#> GSM78525     3  0.0000      0.989 0.000 0.000 1.000 0.000
#> GSM78528     3  0.0000      0.989 0.000 0.000 1.000 0.000
#> GSM78531     1  0.1510      0.989 0.956 0.016 0.000 0.028
#> GSM78533     4  0.0188      0.991 0.000 0.000 0.004 0.996
#> GSM78536     1  0.0921      0.990 0.972 0.000 0.000 0.028
#> GSM78541     1  0.0921      0.990 0.972 0.000 0.000 0.028
#> GSM78547     1  0.1837      0.987 0.944 0.028 0.000 0.028
#> GSM78552     3  0.0000      0.989 0.000 0.000 1.000 0.000
#> GSM78556     4  0.0376      0.989 0.004 0.004 0.000 0.992
#> GSM78559     1  0.1109      0.989 0.968 0.004 0.000 0.028
#> GSM78564     4  0.0376      0.990 0.000 0.004 0.004 0.992
#> GSM42999     2  0.1118      0.928 0.000 0.964 0.036 0.000
#> GSM43001     2  0.1452      0.928 0.008 0.956 0.036 0.000
#> GSM43003     2  0.5581      0.230 0.020 0.532 0.448 0.000
#> GSM43006     2  0.1452      0.928 0.008 0.956 0.036 0.000
#> GSM43009     3  0.1229      0.966 0.020 0.008 0.968 0.004
#> GSM43012     2  0.1913      0.922 0.020 0.940 0.040 0.000
#> GSM78524     1  0.1510      0.988 0.956 0.016 0.000 0.028
#> GSM78527     2  0.1820      0.923 0.020 0.944 0.036 0.000
#> GSM78530     3  0.0188      0.986 0.000 0.000 0.996 0.004
#> GSM78535     1  0.1109      0.989 0.968 0.004 0.000 0.028
#> GSM78538     4  0.0336      0.985 0.000 0.008 0.000 0.992
#> GSM78542     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> GSM78544     3  0.0336      0.986 0.000 0.000 0.992 0.008
#> GSM78549     3  0.1229      0.966 0.020 0.008 0.968 0.004
#> GSM78553     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> GSM78558     4  0.0921      0.965 0.000 0.000 0.028 0.972
#> GSM78561     2  0.1452      0.928 0.008 0.956 0.036 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
#> GSM78539     4  0.3741      0.839 0.000 0.000 0.004 0.732 0.264
#> GSM78545     3  0.0162      0.903 0.000 0.000 0.996 0.000 0.004
#> GSM78550     4  0.0162      0.875 0.000 0.000 0.004 0.996 0.000
#> GSM78554     4  0.3366      0.859 0.000 0.000 0.004 0.784 0.212
#> GSM78562     1  0.3561      0.877 0.740 0.000 0.000 0.000 0.260
#> GSM78540     4  0.2536      0.875 0.004 0.000 0.000 0.868 0.128
#> GSM78546     3  0.2519      0.868 0.000 0.000 0.884 0.016 0.100
#> GSM78551     4  0.0162      0.875 0.000 0.000 0.004 0.996 0.000
#> GSM78555     1  0.1670      0.901 0.936 0.012 0.000 0.000 0.052
#> GSM78563     4  0.2536      0.875 0.004 0.000 0.000 0.868 0.128
#> GSM43005     3  0.0671      0.900 0.000 0.000 0.980 0.016 0.004
#> GSM43008     3  0.1851      0.883 0.000 0.000 0.912 0.000 0.088
#> GSM43011     3  0.0404      0.903 0.000 0.000 0.988 0.000 0.012
#> GSM78523     3  0.2806      0.853 0.000 0.004 0.844 0.000 0.152
#> GSM78526     4  0.0162      0.875 0.000 0.000 0.004 0.996 0.000
#> GSM78529     2  0.0912      0.880 0.000 0.972 0.016 0.000 0.012
#> GSM78532     1  0.2230      0.905 0.884 0.000 0.000 0.000 0.116
#> GSM78534     1  0.3715      0.874 0.736 0.004 0.000 0.000 0.260
#> GSM78537     1  0.2230      0.907 0.884 0.000 0.000 0.000 0.116
#> GSM78543     4  0.4359      0.740 0.000 0.000 0.004 0.584 0.412
#> GSM78548     4  0.1571      0.878 0.000 0.000 0.004 0.936 0.060
#> GSM78557     4  0.4066      0.808 0.000 0.000 0.004 0.672 0.324
#> GSM78560     4  0.4367      0.736 0.000 0.000 0.004 0.580 0.416
#> GSM78565     1  0.1364      0.902 0.952 0.012 0.000 0.000 0.036
#> GSM43000     3  0.2806      0.853 0.000 0.004 0.844 0.000 0.152
#> GSM43002     3  0.0609      0.903 0.000 0.000 0.980 0.000 0.020
#> GSM43004     1  0.3715      0.874 0.736 0.004 0.000 0.000 0.260
#> GSM43007     3  0.1851      0.883 0.000 0.000 0.912 0.000 0.088
#> GSM43010     4  0.0162      0.875 0.000 0.000 0.004 0.996 0.000
#> GSM78522     3  0.2690      0.840 0.000 0.000 0.844 0.000 0.156
#> GSM78525     3  0.0404      0.903 0.000 0.000 0.988 0.000 0.012
#> GSM78528     3  0.2806      0.853 0.000 0.004 0.844 0.000 0.152
#> GSM78531     1  0.2230      0.905 0.884 0.000 0.000 0.000 0.116
#> GSM78533     4  0.2719      0.877 0.000 0.000 0.004 0.852 0.144
#> GSM78536     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000
#> GSM78547     1  0.3561      0.877 0.740 0.000 0.000 0.000 0.260
#> GSM78552     3  0.1851      0.883 0.000 0.000 0.912 0.000 0.088
#> GSM78556     4  0.2389      0.876 0.004 0.000 0.000 0.880 0.116
#> GSM78559     1  0.0290      0.900 0.992 0.000 0.000 0.000 0.008
#> GSM78564     4  0.4066      0.808 0.000 0.000 0.004 0.672 0.324
#> GSM42999     2  0.0912      0.880 0.000 0.972 0.016 0.000 0.012
#> GSM43001     2  0.0798      0.880 0.000 0.976 0.016 0.000 0.008
#> GSM43003     2  0.6676      0.191 0.000 0.416 0.344 0.000 0.240
#> GSM43006     2  0.0798      0.880 0.000 0.976 0.016 0.000 0.008
#> GSM43009     3  0.3662      0.771 0.000 0.004 0.744 0.000 0.252
#> GSM43012     2  0.3999      0.795 0.000 0.740 0.020 0.000 0.240
#> GSM78524     1  0.3343      0.883 0.812 0.016 0.000 0.000 0.172
#> GSM78527     2  0.3183      0.841 0.000 0.828 0.016 0.000 0.156
#> GSM78530     3  0.1768      0.891 0.000 0.000 0.924 0.004 0.072
#> GSM78535     1  0.0290      0.900 0.992 0.000 0.000 0.000 0.008
#> GSM78538     4  0.1410      0.852 0.000 0.000 0.000 0.940 0.060
#> GSM78542     4  0.0963      0.861 0.000 0.000 0.000 0.964 0.036
#> GSM78544     3  0.1430      0.896 0.000 0.000 0.944 0.004 0.052
#> GSM78549     3  0.3010      0.835 0.000 0.000 0.824 0.004 0.172
#> GSM78553     4  0.0963      0.861 0.000 0.000 0.000 0.964 0.036
#> GSM78558     4  0.2471      0.864 0.000 0.000 0.000 0.864 0.136
#> GSM78561     2  0.0798      0.880 0.000 0.976 0.016 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
#> GSM78539     4  0.2048      0.697 0.000 0.000 0.000 0.880 NA 0.120
#> GSM78545     3  0.0146      0.824 0.000 0.000 0.996 0.000 NA 0.000
#> GSM78550     4  0.3774      0.755 0.000 0.000 0.000 0.664 NA 0.328
#> GSM78554     4  0.1075      0.727 0.000 0.000 0.000 0.952 NA 0.048
#> GSM78562     1  0.0622      0.744 0.980 0.000 0.000 0.000 NA 0.012
#> GSM78540     4  0.2709      0.755 0.000 0.000 0.000 0.848 NA 0.132
#> GSM78546     3  0.4299      0.742 0.000 0.000 0.720 0.000 NA 0.188
#> GSM78551     4  0.3578      0.755 0.000 0.000 0.000 0.660 NA 0.340
#> GSM78555     1  0.4488      0.785 0.548 0.000 0.000 0.000 NA 0.032
#> GSM78563     4  0.2709      0.755 0.000 0.000 0.000 0.848 NA 0.132
#> GSM43005     3  0.1257      0.822 0.000 0.000 0.952 0.000 NA 0.020
#> GSM43008     3  0.3978      0.765 0.000 0.000 0.756 0.000 NA 0.160
#> GSM43011     3  0.0291      0.824 0.000 0.000 0.992 0.000 NA 0.004
#> GSM78523     3  0.3412      0.763 0.000 0.000 0.808 0.000 NA 0.064
#> GSM78526     4  0.3804      0.754 0.000 0.000 0.000 0.656 NA 0.336
#> GSM78529     2  0.1082      0.830 0.000 0.956 0.000 0.000 NA 0.004
#> GSM78532     1  0.3512      0.799 0.772 0.000 0.000 0.000 NA 0.032
#> GSM78534     1  0.0717      0.747 0.976 0.000 0.000 0.000 NA 0.016
#> GSM78537     1  0.3511      0.802 0.760 0.000 0.000 0.000 NA 0.024
#> GSM78543     4  0.4580      0.502 0.000 0.000 0.000 0.612 NA 0.336
#> GSM78548     4  0.3217      0.757 0.000 0.000 0.000 0.768 NA 0.224
#> GSM78557     4  0.3457      0.622 0.000 0.000 0.000 0.752 NA 0.232
#> GSM78560     4  0.4575      0.484 0.000 0.000 0.000 0.600 NA 0.352
#> GSM78565     1  0.4499      0.784 0.540 0.000 0.000 0.000 NA 0.032
#> GSM43000     3  0.3370      0.764 0.000 0.000 0.812 0.000 NA 0.064
#> GSM43002     3  0.1757      0.816 0.000 0.000 0.916 0.000 NA 0.008
#> GSM43004     1  0.0717      0.747 0.976 0.000 0.000 0.000 NA 0.016
#> GSM43007     3  0.3978      0.765 0.000 0.000 0.756 0.000 NA 0.160
#> GSM43010     4  0.3592      0.754 0.000 0.000 0.000 0.656 NA 0.344
#> GSM78522     3  0.4871      0.696 0.000 0.000 0.660 0.000 NA 0.196
#> GSM78525     3  0.0146      0.824 0.000 0.000 0.996 0.000 NA 0.000
#> GSM78528     3  0.3370      0.764 0.000 0.000 0.812 0.000 NA 0.064
#> GSM78531     1  0.3512      0.799 0.772 0.000 0.000 0.000 NA 0.032
#> GSM78533     4  0.1007      0.753 0.000 0.000 0.000 0.956 NA 0.044
#> GSM78536     1  0.4509      0.792 0.532 0.000 0.000 0.000 NA 0.032
#> GSM78541     1  0.4509      0.792 0.532 0.000 0.000 0.000 NA 0.032
#> GSM78547     1  0.0622      0.744 0.980 0.000 0.000 0.000 NA 0.012
#> GSM78552     3  0.3978      0.765 0.000 0.000 0.756 0.000 NA 0.160
#> GSM78556     4  0.2581      0.757 0.000 0.000 0.000 0.860 NA 0.120
#> GSM78559     1  0.3867      0.785 0.512 0.000 0.000 0.000 NA 0.000
#> GSM78564     4  0.3457      0.622 0.000 0.000 0.000 0.752 NA 0.232
#> GSM42999     2  0.1082      0.830 0.000 0.956 0.000 0.000 NA 0.004
#> GSM43001     2  0.0713      0.826 0.000 0.972 0.000 0.000 NA 0.028
#> GSM43003     2  0.7187      0.177 0.000 0.332 0.288 0.000 NA 0.080
#> GSM43006     2  0.0713      0.826 0.000 0.972 0.000 0.000 NA 0.028
#> GSM43009     3  0.5201      0.594 0.000 0.012 0.616 0.000 NA 0.096
#> GSM43012     2  0.4916      0.706 0.000 0.620 0.004 0.000 NA 0.080
#> GSM78524     1  0.3651      0.763 0.772 0.000 0.000 0.000 NA 0.048
#> GSM78527     2  0.3920      0.769 0.000 0.736 0.000 0.000 NA 0.048
#> GSM78530     3  0.2499      0.803 0.000 0.000 0.880 0.000 NA 0.048
#> GSM78535     1  0.3867      0.785 0.512 0.000 0.000 0.000 NA 0.000
#> GSM78538     4  0.4586      0.724 0.004 0.000 0.000 0.564 NA 0.400
#> GSM78542     4  0.4076      0.732 0.000 0.000 0.000 0.592 NA 0.396
#> GSM78544     3  0.2070      0.815 0.000 0.000 0.908 0.000 NA 0.044
#> GSM78549     3  0.4841      0.672 0.000 0.012 0.684 0.000 NA 0.100
#> GSM78553     4  0.4121      0.733 0.000 0.000 0.000 0.604 NA 0.380
#> GSM78558     4  0.3725      0.731 0.000 0.000 0.000 0.676 NA 0.316
#> GSM78561     2  0.0713      0.826 0.000 0.972 0.000 0.000 NA 0.028

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 cell.type(p) agent(p) individual(p) k
#> ATC:kmeans 58      0.05915    0.340       0.00642 2
#> ATC:kmeans 58      0.02569    0.233       0.01335 3
#> ATC:kmeans 57      0.01011    0.582       0.07213 4
#> ATC:kmeans 57      0.01011    0.582       0.07213 5
#> ATC:kmeans 56      0.00911    0.673       0.08608 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 58 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 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-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.986       0.994          0.501 0.501   0.501
#> 3 3 0.849           0.910       0.938          0.261 0.861   0.722
#> 4 4 0.792           0.832       0.847          0.112 0.946   0.849
#> 5 5 0.828           0.889       0.918          0.100 0.897   0.669
#> 6 6 0.878           0.854       0.898          0.034 0.968   0.852

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

suggest_best_k(res)
#> [1] 2

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM78539     1   0.000      0.988 1.000 0.000
#> GSM78545     2   0.000      1.000 0.000 1.000
#> GSM78550     1   0.000      0.988 1.000 0.000
#> GSM78554     1   0.000      0.988 1.000 0.000
#> GSM78562     1   0.000      0.988 1.000 0.000
#> GSM78540     1   0.000      0.988 1.000 0.000
#> GSM78546     2   0.000      1.000 0.000 1.000
#> GSM78551     1   0.000      0.988 1.000 0.000
#> GSM78555     1   0.000      0.988 1.000 0.000
#> GSM78563     1   0.000      0.988 1.000 0.000
#> GSM43005     2   0.000      1.000 0.000 1.000
#> GSM43008     2   0.000      1.000 0.000 1.000
#> GSM43011     2   0.000      1.000 0.000 1.000
#> GSM78523     2   0.000      1.000 0.000 1.000
#> GSM78526     1   0.000      0.988 1.000 0.000
#> GSM78529     2   0.000      1.000 0.000 1.000
#> GSM78532     1   0.000      0.988 1.000 0.000
#> GSM78534     1   0.000      0.988 1.000 0.000
#> GSM78537     1   0.000      0.988 1.000 0.000
#> GSM78543     1   0.000      0.988 1.000 0.000
#> GSM78548     1   0.653      0.803 0.832 0.168
#> GSM78557     1   0.000      0.988 1.000 0.000
#> GSM78560     1   0.722      0.758 0.800 0.200
#> GSM78565     1   0.000      0.988 1.000 0.000
#> GSM43000     2   0.000      1.000 0.000 1.000
#> GSM43002     2   0.000      1.000 0.000 1.000
#> GSM43004     1   0.000      0.988 1.000 0.000
#> GSM43007     2   0.000      1.000 0.000 1.000
#> GSM43010     1   0.000      0.988 1.000 0.000
#> GSM78522     2   0.000      1.000 0.000 1.000
#> GSM78525     2   0.000      1.000 0.000 1.000
#> GSM78528     2   0.000      1.000 0.000 1.000
#> GSM78531     1   0.000      0.988 1.000 0.000
#> GSM78533     1   0.000      0.988 1.000 0.000
#> GSM78536     1   0.000      0.988 1.000 0.000
#> GSM78541     1   0.000      0.988 1.000 0.000
#> GSM78547     1   0.000      0.988 1.000 0.000
#> GSM78552     2   0.000      1.000 0.000 1.000
#> GSM78556     1   0.000      0.988 1.000 0.000
#> GSM78559     1   0.000      0.988 1.000 0.000
#> GSM78564     1   0.000      0.988 1.000 0.000
#> GSM42999     2   0.000      1.000 0.000 1.000
#> GSM43001     2   0.000      1.000 0.000 1.000
#> GSM43003     2   0.000      1.000 0.000 1.000
#> GSM43006     2   0.000      1.000 0.000 1.000
#> GSM43009     2   0.000      1.000 0.000 1.000
#> GSM43012     2   0.000      1.000 0.000 1.000
#> GSM78524     1   0.000      0.988 1.000 0.000
#> GSM78527     2   0.000      1.000 0.000 1.000
#> GSM78530     2   0.000      1.000 0.000 1.000
#> GSM78535     1   0.000      0.988 1.000 0.000
#> GSM78538     1   0.000      0.988 1.000 0.000
#> GSM78542     1   0.000      0.988 1.000 0.000
#> GSM78544     2   0.000      1.000 0.000 1.000
#> GSM78549     2   0.000      1.000 0.000 1.000
#> GSM78553     1   0.000      0.988 1.000 0.000
#> GSM78558     1   0.000      0.988 1.000 0.000
#> GSM78561     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     1  0.4796    0.73733 0.780 0.220 0.000
#> GSM78545     3  0.0000    0.99209 0.000 0.000 1.000
#> GSM78550     2  0.4887    0.89728 0.228 0.772 0.000
#> GSM78554     2  0.3619    0.70568 0.136 0.864 0.000
#> GSM78562     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM78540     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM78546     3  0.0237    0.99098 0.000 0.004 0.996
#> GSM78551     2  0.5016    0.89839 0.240 0.760 0.000
#> GSM78555     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM78563     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM43005     3  0.0000    0.99209 0.000 0.000 1.000
#> GSM43008     3  0.0237    0.99098 0.000 0.004 0.996
#> GSM43011     3  0.0000    0.99209 0.000 0.000 1.000
#> GSM78523     3  0.0000    0.99209 0.000 0.000 1.000
#> GSM78526     2  0.4974    0.89898 0.236 0.764 0.000
#> GSM78529     3  0.0747    0.99194 0.000 0.016 0.984
#> GSM78532     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM78534     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM78537     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM78543     1  0.4702    0.74551 0.788 0.212 0.000
#> GSM78548     2  0.5911    0.74683 0.060 0.784 0.156
#> GSM78557     1  0.4702    0.74495 0.788 0.212 0.000
#> GSM78560     1  0.5024    0.73342 0.776 0.220 0.004
#> GSM78565     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM43000     3  0.0000    0.99209 0.000 0.000 1.000
#> GSM43002     3  0.0237    0.99098 0.000 0.004 0.996
#> GSM43004     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM43007     3  0.0237    0.99098 0.000 0.004 0.996
#> GSM43010     2  0.5016    0.89839 0.240 0.760 0.000
#> GSM78522     3  0.0237    0.99098 0.000 0.004 0.996
#> GSM78525     3  0.0000    0.99209 0.000 0.000 1.000
#> GSM78528     3  0.0000    0.99209 0.000 0.000 1.000
#> GSM78531     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM78533     1  0.6095   -0.00779 0.608 0.392 0.000
#> GSM78536     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM78541     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM78547     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM78552     3  0.0237    0.99098 0.000 0.004 0.996
#> GSM78556     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM78559     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM78564     1  0.2537    0.86153 0.920 0.080 0.000
#> GSM42999     3  0.0747    0.99194 0.000 0.016 0.984
#> GSM43001     3  0.0747    0.99194 0.000 0.016 0.984
#> GSM43003     3  0.0747    0.99194 0.000 0.016 0.984
#> GSM43006     3  0.0747    0.99194 0.000 0.016 0.984
#> GSM43009     3  0.0747    0.99194 0.000 0.016 0.984
#> GSM43012     3  0.0747    0.99194 0.000 0.016 0.984
#> GSM78524     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM78527     3  0.0747    0.99194 0.000 0.016 0.984
#> GSM78530     3  0.0747    0.99194 0.000 0.016 0.984
#> GSM78535     1  0.0000    0.92188 1.000 0.000 0.000
#> GSM78538     2  0.5016    0.89839 0.240 0.760 0.000
#> GSM78542     2  0.5016    0.89839 0.240 0.760 0.000
#> GSM78544     3  0.0747    0.99194 0.000 0.016 0.984
#> GSM78549     3  0.0747    0.99194 0.000 0.016 0.984
#> GSM78553     2  0.4931    0.89856 0.232 0.768 0.000
#> GSM78558     2  0.0892    0.75640 0.020 0.980 0.000
#> GSM78561     3  0.0747    0.99194 0.000 0.016 0.984

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     4  0.5453      0.925 0.388 0.020 0.000 0.592
#> GSM78545     3  0.4624      0.814 0.000 0.000 0.660 0.340
#> GSM78550     2  0.0707      0.813 0.020 0.980 0.000 0.000
#> GSM78554     2  0.7286     -0.074 0.156 0.480 0.000 0.364
#> GSM78562     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM78540     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM78546     3  0.4866      0.788 0.000 0.000 0.596 0.404
#> GSM78551     2  0.3266      0.780 0.168 0.832 0.000 0.000
#> GSM78555     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM78563     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM43005     3  0.4624      0.814 0.000 0.000 0.660 0.340
#> GSM43008     3  0.4855      0.790 0.000 0.000 0.600 0.400
#> GSM43011     3  0.4605      0.815 0.000 0.000 0.664 0.336
#> GSM78523     3  0.4585      0.815 0.000 0.000 0.668 0.332
#> GSM78526     2  0.0707      0.813 0.020 0.980 0.000 0.000
#> GSM78529     3  0.0000      0.809 0.000 0.000 1.000 0.000
#> GSM78532     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM78534     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM78537     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM78543     4  0.5386      0.920 0.368 0.020 0.000 0.612
#> GSM78548     2  0.0779      0.811 0.016 0.980 0.000 0.004
#> GSM78557     4  0.5453      0.925 0.388 0.020 0.000 0.592
#> GSM78560     4  0.5193      0.872 0.324 0.020 0.000 0.656
#> GSM78565     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM43000     3  0.4585      0.815 0.000 0.000 0.668 0.332
#> GSM43002     3  0.4843      0.792 0.000 0.000 0.604 0.396
#> GSM43004     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM43007     3  0.4855      0.790 0.000 0.000 0.600 0.400
#> GSM43010     2  0.3837      0.733 0.224 0.776 0.000 0.000
#> GSM78522     3  0.4843      0.792 0.000 0.000 0.604 0.396
#> GSM78525     3  0.4624      0.814 0.000 0.000 0.660 0.340
#> GSM78528     3  0.4585      0.815 0.000 0.000 0.668 0.332
#> GSM78531     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM78533     1  0.4477      0.356 0.688 0.312 0.000 0.000
#> GSM78536     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM78541     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM78547     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM78552     3  0.4855      0.790 0.000 0.000 0.600 0.400
#> GSM78556     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM78559     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM78564     4  0.5506      0.798 0.472 0.016 0.000 0.512
#> GSM42999     3  0.0000      0.809 0.000 0.000 1.000 0.000
#> GSM43001     3  0.0000      0.809 0.000 0.000 1.000 0.000
#> GSM43003     3  0.0000      0.809 0.000 0.000 1.000 0.000
#> GSM43006     3  0.0000      0.809 0.000 0.000 1.000 0.000
#> GSM43009     3  0.0000      0.809 0.000 0.000 1.000 0.000
#> GSM43012     3  0.0000      0.809 0.000 0.000 1.000 0.000
#> GSM78524     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM78527     3  0.0000      0.809 0.000 0.000 1.000 0.000
#> GSM78530     3  0.0000      0.809 0.000 0.000 1.000 0.000
#> GSM78535     1  0.0000      0.966 1.000 0.000 0.000 0.000
#> GSM78538     2  0.4621      0.657 0.284 0.708 0.000 0.008
#> GSM78542     2  0.3591      0.780 0.168 0.824 0.000 0.008
#> GSM78544     3  0.0000      0.809 0.000 0.000 1.000 0.000
#> GSM78549     3  0.0000      0.809 0.000 0.000 1.000 0.000
#> GSM78553     2  0.1042      0.812 0.020 0.972 0.000 0.008
#> GSM78558     2  0.2125      0.774 0.004 0.920 0.000 0.076
#> GSM78561     3  0.0000      0.809 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
#> GSM78539     4  0.2824      0.861 0.116 0.000 0.020 0.864 0.000
#> GSM78545     3  0.2813      0.903 0.000 0.168 0.832 0.000 0.000
#> GSM78550     5  0.0510      0.795 0.000 0.000 0.016 0.000 0.984
#> GSM78554     4  0.5265      0.301 0.004 0.000 0.040 0.544 0.412
#> GSM78562     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM78540     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM78546     3  0.1845      0.890 0.000 0.056 0.928 0.016 0.000
#> GSM78551     5  0.2690      0.768 0.156 0.000 0.000 0.000 0.844
#> GSM78555     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM78563     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM43005     3  0.2732      0.905 0.000 0.160 0.840 0.000 0.000
#> GSM43008     3  0.1809      0.894 0.000 0.060 0.928 0.012 0.000
#> GSM43011     3  0.2813      0.903 0.000 0.168 0.832 0.000 0.000
#> GSM78523     3  0.3452      0.848 0.000 0.244 0.756 0.000 0.000
#> GSM78526     5  0.0000      0.797 0.000 0.000 0.000 0.000 1.000
#> GSM78529     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM78532     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM78534     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM78537     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM78543     4  0.2305      0.862 0.092 0.000 0.012 0.896 0.000
#> GSM78548     5  0.0609      0.794 0.000 0.000 0.020 0.000 0.980
#> GSM78557     4  0.2179      0.864 0.112 0.000 0.000 0.888 0.000
#> GSM78560     4  0.2331      0.853 0.080 0.000 0.020 0.900 0.000
#> GSM78565     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM43000     3  0.3561      0.832 0.000 0.260 0.740 0.000 0.000
#> GSM43002     3  0.1478      0.896 0.000 0.064 0.936 0.000 0.000
#> GSM43004     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM43007     3  0.1809      0.894 0.000 0.060 0.928 0.012 0.000
#> GSM43010     5  0.3109      0.732 0.200 0.000 0.000 0.000 0.800
#> GSM78522     3  0.2006      0.895 0.000 0.072 0.916 0.012 0.000
#> GSM78525     3  0.2732      0.905 0.000 0.160 0.840 0.000 0.000
#> GSM78528     3  0.3561      0.832 0.000 0.260 0.740 0.000 0.000
#> GSM78531     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM78533     1  0.4415      0.236 0.604 0.000 0.000 0.008 0.388
#> GSM78536     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM78547     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM78552     3  0.1809      0.894 0.000 0.060 0.928 0.012 0.000
#> GSM78556     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM78559     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM78564     4  0.3074      0.786 0.196 0.000 0.000 0.804 0.000
#> GSM42999     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM43001     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM43003     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM43006     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM43009     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM43012     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM78524     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM78527     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM78530     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM78535     1  0.0000      0.973 1.000 0.000 0.000 0.000 0.000
#> GSM78538     5  0.6036      0.615 0.280 0.000 0.020 0.100 0.600
#> GSM78542     5  0.5012      0.767 0.140 0.000 0.020 0.100 0.740
#> GSM78544     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM78549     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM78553     5  0.2616      0.780 0.000 0.000 0.020 0.100 0.880
#> GSM78558     5  0.3995      0.746 0.000 0.000 0.060 0.152 0.788
#> GSM78561     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM78539     4  0.2510      0.866 0.028 0.000 0.000 0.872 0.100 0.000
#> GSM78545     3  0.1814      0.820 0.000 0.100 0.900 0.000 0.000 0.000
#> GSM78550     6  0.2060      0.599 0.000 0.000 0.016 0.000 0.084 0.900
#> GSM78554     6  0.5486      0.360 0.000 0.000 0.000 0.208 0.224 0.568
#> GSM78562     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78540     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78546     3  0.4050      0.757 0.000 0.016 0.728 0.024 0.232 0.000
#> GSM78551     6  0.1788      0.584 0.076 0.000 0.000 0.004 0.004 0.916
#> GSM78555     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78563     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM43005     3  0.1556      0.821 0.000 0.080 0.920 0.000 0.000 0.000
#> GSM43008     3  0.3810      0.769 0.000 0.016 0.748 0.016 0.220 0.000
#> GSM43011     3  0.1863      0.818 0.000 0.104 0.896 0.000 0.000 0.000
#> GSM78523     3  0.2823      0.767 0.000 0.204 0.796 0.000 0.000 0.000
#> GSM78526     6  0.0146      0.581 0.000 0.000 0.000 0.000 0.004 0.996
#> GSM78529     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78532     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78534     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78537     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78543     4  0.0603      0.899 0.004 0.000 0.000 0.980 0.016 0.000
#> GSM78548     6  0.2581      0.587 0.000 0.000 0.020 0.000 0.120 0.860
#> GSM78557     4  0.1092      0.902 0.020 0.000 0.000 0.960 0.020 0.000
#> GSM78560     4  0.0458      0.897 0.000 0.000 0.000 0.984 0.016 0.000
#> GSM78565     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM43000     3  0.2883      0.757 0.000 0.212 0.788 0.000 0.000 0.000
#> GSM43002     3  0.0820      0.805 0.000 0.016 0.972 0.000 0.012 0.000
#> GSM43004     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM43007     3  0.3810      0.769 0.000 0.016 0.748 0.016 0.220 0.000
#> GSM43010     6  0.2006      0.559 0.104 0.000 0.000 0.000 0.004 0.892
#> GSM78522     3  0.4563      0.749 0.000 0.040 0.700 0.028 0.232 0.000
#> GSM78525     3  0.1663      0.821 0.000 0.088 0.912 0.000 0.000 0.000
#> GSM78528     3  0.2854      0.761 0.000 0.208 0.792 0.000 0.000 0.000
#> GSM78531     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78533     6  0.4266      0.267 0.348 0.000 0.000 0.008 0.016 0.628
#> GSM78536     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78547     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78552     3  0.3810      0.769 0.000 0.016 0.748 0.016 0.220 0.000
#> GSM78556     1  0.0146      0.995 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM78559     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78564     4  0.2260      0.774 0.140 0.000 0.000 0.860 0.000 0.000
#> GSM42999     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43001     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43003     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43006     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43009     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM43012     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78524     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78527     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78530     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM78535     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78538     5  0.5659      0.618 0.168 0.000 0.000 0.000 0.496 0.336
#> GSM78542     5  0.5162      0.700 0.088 0.000 0.000 0.000 0.504 0.408
#> GSM78544     2  0.0405      0.990 0.000 0.988 0.004 0.000 0.008 0.000
#> GSM78549     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM78553     5  0.3868      0.645 0.000 0.000 0.000 0.000 0.504 0.496
#> GSM78558     5  0.3670      0.563 0.000 0.000 0.000 0.024 0.736 0.240
#> GSM78561     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-skmeans-collect-classes

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

test_to_known_factors(res)
#>              n cell.type(p) agent(p) individual(p) k
#> ATC:skmeans 58     5.91e-02   0.3398       0.00642 2
#> ATC:skmeans 57     4.38e-02   0.4172       0.05569 3
#> ATC:skmeans 56     1.57e-01   0.1081       0.22123 4
#> ATC:skmeans 56     3.61e-05   0.0699       0.65266 5
#> ATC:skmeans 56     1.91e-06   0.0304       0.55514 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 58 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 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-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.733           0.956       0.972         0.4833 0.501   0.501
#> 3 3 0.916           0.928       0.959         0.3516 0.742   0.529
#> 4 4 1.000           0.962       0.985         0.1292 0.861   0.623
#> 5 5 0.832           0.770       0.873         0.0448 0.980   0.925
#> 6 6 0.781           0.608       0.831         0.0618 0.929   0.723

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] 3

There is also optional best \(k\) = 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
#> GSM78539     1   0.000      1.000 1.000 0.000
#> GSM78545     2   0.706      0.838 0.192 0.808
#> GSM78550     1   0.000      1.000 1.000 0.000
#> GSM78554     1   0.000      1.000 1.000 0.000
#> GSM78562     1   0.000      1.000 1.000 0.000
#> GSM78540     1   0.000      1.000 1.000 0.000
#> GSM78546     2   0.706      0.838 0.192 0.808
#> GSM78551     1   0.000      1.000 1.000 0.000
#> GSM78555     1   0.000      1.000 1.000 0.000
#> GSM78563     1   0.000      1.000 1.000 0.000
#> GSM43005     2   0.706      0.838 0.192 0.808
#> GSM43008     2   0.706      0.838 0.192 0.808
#> GSM43011     2   0.000      0.929 0.000 1.000
#> GSM78523     2   0.000      0.929 0.000 1.000
#> GSM78526     1   0.000      1.000 1.000 0.000
#> GSM78529     2   0.000      0.929 0.000 1.000
#> GSM78532     1   0.000      1.000 1.000 0.000
#> GSM78534     1   0.000      1.000 1.000 0.000
#> GSM78537     1   0.000      1.000 1.000 0.000
#> GSM78543     1   0.000      1.000 1.000 0.000
#> GSM78548     1   0.000      1.000 1.000 0.000
#> GSM78557     1   0.000      1.000 1.000 0.000
#> GSM78560     1   0.000      1.000 1.000 0.000
#> GSM78565     1   0.000      1.000 1.000 0.000
#> GSM43000     2   0.000      0.929 0.000 1.000
#> GSM43002     2   0.706      0.838 0.192 0.808
#> GSM43004     1   0.000      1.000 1.000 0.000
#> GSM43007     2   0.706      0.838 0.192 0.808
#> GSM43010     1   0.000      1.000 1.000 0.000
#> GSM78522     2   0.469      0.889 0.100 0.900
#> GSM78525     2   0.706      0.838 0.192 0.808
#> GSM78528     2   0.000      0.929 0.000 1.000
#> GSM78531     1   0.000      1.000 1.000 0.000
#> GSM78533     1   0.000      1.000 1.000 0.000
#> GSM78536     1   0.000      1.000 1.000 0.000
#> GSM78541     1   0.000      1.000 1.000 0.000
#> GSM78547     1   0.000      1.000 1.000 0.000
#> GSM78552     2   0.706      0.838 0.192 0.808
#> GSM78556     1   0.000      1.000 1.000 0.000
#> GSM78559     1   0.000      1.000 1.000 0.000
#> GSM78564     1   0.000      1.000 1.000 0.000
#> GSM42999     2   0.000      0.929 0.000 1.000
#> GSM43001     2   0.000      0.929 0.000 1.000
#> GSM43003     2   0.000      0.929 0.000 1.000
#> GSM43006     2   0.000      0.929 0.000 1.000
#> GSM43009     2   0.000      0.929 0.000 1.000
#> GSM43012     2   0.000      0.929 0.000 1.000
#> GSM78524     1   0.000      1.000 1.000 0.000
#> GSM78527     2   0.000      0.929 0.000 1.000
#> GSM78530     2   0.000      0.929 0.000 1.000
#> GSM78535     1   0.000      1.000 1.000 0.000
#> GSM78538     1   0.000      1.000 1.000 0.000
#> GSM78542     1   0.000      1.000 1.000 0.000
#> GSM78544     2   0.000      0.929 0.000 1.000
#> GSM78549     2   0.000      0.929 0.000 1.000
#> GSM78553     1   0.000      1.000 1.000 0.000
#> GSM78558     1   0.000      1.000 1.000 0.000
#> GSM78561     2   0.000      0.929 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78545     2  0.5098      0.767 0.000 0.752 0.248
#> GSM78550     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78554     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78562     1  0.0000      0.999 1.000 0.000 0.000
#> GSM78540     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78546     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78551     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78555     1  0.0000      0.999 1.000 0.000 0.000
#> GSM78563     3  0.0000      0.994 0.000 0.000 1.000
#> GSM43005     3  0.0000      0.994 0.000 0.000 1.000
#> GSM43008     3  0.2711      0.887 0.000 0.088 0.912
#> GSM43011     2  0.2878      0.876 0.000 0.904 0.096
#> GSM78523     2  0.0592      0.878 0.000 0.988 0.012
#> GSM78526     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78529     2  0.0000      0.876 0.000 1.000 0.000
#> GSM78532     1  0.0000      0.999 1.000 0.000 0.000
#> GSM78534     1  0.0000      0.999 1.000 0.000 0.000
#> GSM78537     1  0.0000      0.999 1.000 0.000 0.000
#> GSM78543     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78548     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78557     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78560     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78565     1  0.0000      0.999 1.000 0.000 0.000
#> GSM43000     2  0.2796      0.877 0.000 0.908 0.092
#> GSM43002     2  0.5098      0.767 0.000 0.752 0.248
#> GSM43004     1  0.0000      0.999 1.000 0.000 0.000
#> GSM43007     3  0.1289      0.960 0.000 0.032 0.968
#> GSM43010     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78522     2  0.5431      0.719 0.000 0.716 0.284
#> GSM78525     2  0.4750      0.797 0.000 0.784 0.216
#> GSM78528     2  0.2796      0.877 0.000 0.908 0.092
#> GSM78531     1  0.0000      0.999 1.000 0.000 0.000
#> GSM78533     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78536     1  0.0000      0.999 1.000 0.000 0.000
#> GSM78541     1  0.0000      0.999 1.000 0.000 0.000
#> GSM78547     1  0.0424      0.991 0.992 0.000 0.008
#> GSM78552     2  0.5178      0.757 0.000 0.744 0.256
#> GSM78556     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78559     1  0.0000      0.999 1.000 0.000 0.000
#> GSM78564     3  0.0000      0.994 0.000 0.000 1.000
#> GSM42999     2  0.0000      0.876 0.000 1.000 0.000
#> GSM43001     2  0.0000      0.876 0.000 1.000 0.000
#> GSM43003     2  0.0000      0.876 0.000 1.000 0.000
#> GSM43006     2  0.0000      0.876 0.000 1.000 0.000
#> GSM43009     2  0.0000      0.876 0.000 1.000 0.000
#> GSM43012     2  0.0000      0.876 0.000 1.000 0.000
#> GSM78524     1  0.0000      0.999 1.000 0.000 0.000
#> GSM78527     2  0.0000      0.876 0.000 1.000 0.000
#> GSM78530     2  0.2878      0.876 0.000 0.904 0.096
#> GSM78535     1  0.0000      0.999 1.000 0.000 0.000
#> GSM78538     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78542     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78544     2  0.6308      0.172 0.000 0.508 0.492
#> GSM78549     2  0.2878      0.876 0.000 0.904 0.096
#> GSM78553     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78558     3  0.0000      0.994 0.000 0.000 1.000
#> GSM78561     2  0.0000      0.876 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78545     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> GSM78550     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78554     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78562     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM78540     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78546     3  0.4304      0.601 0.000 0.000 0.716 0.284
#> GSM78551     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78555     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM78563     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM43005     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> GSM43008     3  0.1474      0.903 0.000 0.000 0.948 0.052
#> GSM43011     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> GSM78523     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> GSM78526     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78529     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM78532     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM78534     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM78537     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM78543     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78548     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78557     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78560     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78565     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM43000     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> GSM43002     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> GSM43004     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM43007     3  0.0921      0.926 0.000 0.000 0.972 0.028
#> GSM43010     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78522     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> GSM78525     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> GSM78528     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> GSM78531     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM78533     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78536     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM78541     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM78547     1  0.1474      0.932 0.948 0.000 0.000 0.052
#> GSM78552     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> GSM78556     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78559     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM78564     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM42999     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM43001     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM43003     3  0.4855      0.340 0.000 0.400 0.600 0.000
#> GSM43006     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM43009     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> GSM43012     2  0.1474      0.941 0.000 0.948 0.052 0.000
#> GSM78524     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM78527     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM78530     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> GSM78535     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM78538     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78542     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78544     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> GSM78549     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> GSM78553     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78558     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM78561     2  0.0000      0.991 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000
#> GSM78545     3  0.0000      0.855 0.000 0.000 1.000 0.000 0.000
#> GSM78550     4  0.2233      0.925 0.000 0.000 0.004 0.892 0.104
#> GSM78554     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000
#> GSM78562     1  0.3586      0.787 0.736 0.000 0.000 0.000 0.264
#> GSM78540     4  0.0703      0.935 0.000 0.000 0.000 0.976 0.024
#> GSM78546     3  0.3895      0.471 0.000 0.000 0.680 0.320 0.000
#> GSM78551     4  0.1908      0.929 0.000 0.000 0.000 0.908 0.092
#> GSM78555     1  0.0000      0.920 1.000 0.000 0.000 0.000 0.000
#> GSM78563     4  0.0703      0.935 0.000 0.000 0.000 0.976 0.024
#> GSM43005     3  0.0000      0.855 0.000 0.000 1.000 0.000 0.000
#> GSM43008     3  0.1270      0.828 0.000 0.000 0.948 0.052 0.000
#> GSM43011     3  0.0162      0.854 0.000 0.004 0.996 0.000 0.000
#> GSM78523     3  0.3857      0.634 0.000 0.312 0.688 0.000 0.000
#> GSM78526     4  0.2439      0.921 0.000 0.000 0.004 0.876 0.120
#> GSM78529     2  0.3895     -0.308 0.000 0.680 0.000 0.000 0.320
#> GSM78532     1  0.0000      0.920 1.000 0.000 0.000 0.000 0.000
#> GSM78534     1  0.3508      0.795 0.748 0.000 0.000 0.000 0.252
#> GSM78537     1  0.0000      0.920 1.000 0.000 0.000 0.000 0.000
#> GSM78543     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000
#> GSM78548     4  0.2423      0.921 0.000 0.000 0.024 0.896 0.080
#> GSM78557     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000
#> GSM78560     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000
#> GSM78565     1  0.0000      0.920 1.000 0.000 0.000 0.000 0.000
#> GSM43000     3  0.3857      0.634 0.000 0.312 0.688 0.000 0.000
#> GSM43002     3  0.0000      0.855 0.000 0.000 1.000 0.000 0.000
#> GSM43004     1  0.3508      0.795 0.748 0.000 0.000 0.000 0.252
#> GSM43007     3  0.0794      0.844 0.000 0.000 0.972 0.028 0.000
#> GSM43010     4  0.2280      0.922 0.000 0.000 0.000 0.880 0.120
#> GSM78522     3  0.0000      0.855 0.000 0.000 1.000 0.000 0.000
#> GSM78525     3  0.0000      0.855 0.000 0.000 1.000 0.000 0.000
#> GSM78528     3  0.3837      0.637 0.000 0.308 0.692 0.000 0.000
#> GSM78531     1  0.0000      0.920 1.000 0.000 0.000 0.000 0.000
#> GSM78533     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000
#> GSM78536     1  0.0000      0.920 1.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0000      0.920 1.000 0.000 0.000 0.000 0.000
#> GSM78547     1  0.4777      0.731 0.680 0.000 0.000 0.052 0.268
#> GSM78552     3  0.0000      0.855 0.000 0.000 1.000 0.000 0.000
#> GSM78556     4  0.0703      0.935 0.000 0.000 0.000 0.976 0.024
#> GSM78559     1  0.0000      0.920 1.000 0.000 0.000 0.000 0.000
#> GSM78564     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000
#> GSM42999     2  0.4126     -0.467 0.000 0.620 0.000 0.000 0.380
#> GSM43001     5  0.4227      1.000 0.000 0.420 0.000 0.000 0.580
#> GSM43003     2  0.4639     -0.113 0.000 0.632 0.344 0.000 0.024
#> GSM43006     5  0.4227      1.000 0.000 0.420 0.000 0.000 0.580
#> GSM43009     3  0.4654      0.592 0.000 0.348 0.628 0.000 0.024
#> GSM43012     2  0.0693      0.148 0.000 0.980 0.008 0.000 0.012
#> GSM78524     1  0.1121      0.898 0.956 0.000 0.000 0.000 0.044
#> GSM78527     2  0.3857     -0.301 0.000 0.688 0.000 0.000 0.312
#> GSM78530     3  0.2036      0.833 0.000 0.056 0.920 0.000 0.024
#> GSM78535     1  0.0000      0.920 1.000 0.000 0.000 0.000 0.000
#> GSM78538     4  0.4161      0.637 0.000 0.000 0.000 0.608 0.392
#> GSM78542     4  0.2561      0.910 0.000 0.000 0.000 0.856 0.144
#> GSM78544     3  0.2291      0.823 0.000 0.036 0.908 0.000 0.056
#> GSM78549     3  0.3055      0.796 0.000 0.072 0.864 0.000 0.064
#> GSM78553     4  0.2280      0.915 0.000 0.000 0.000 0.880 0.120
#> GSM78558     4  0.2280      0.915 0.000 0.000 0.000 0.880 0.120
#> GSM78561     5  0.4227      1.000 0.000 0.420 0.000 0.000 0.580

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM78539     4  0.0000    0.75815 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78545     3  0.0000    0.73846 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM78550     6  0.3866    0.32646 0.000 0.000 0.000 0.484 0.000 0.516
#> GSM78554     4  0.0000    0.75815 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78562     1  0.4942    0.72315 0.652 0.000 0.000 0.000 0.156 0.192
#> GSM78540     4  0.3351    0.53677 0.000 0.000 0.000 0.712 0.000 0.288
#> GSM78546     3  0.3857    0.09148 0.000 0.000 0.532 0.468 0.000 0.000
#> GSM78551     4  0.3867   -0.00612 0.000 0.000 0.000 0.512 0.000 0.488
#> GSM78555     1  0.0632    0.88404 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM78563     4  0.3351    0.53677 0.000 0.000 0.000 0.712 0.000 0.288
#> GSM43005     3  0.0000    0.73846 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM43008     3  0.1141    0.70731 0.000 0.000 0.948 0.052 0.000 0.000
#> GSM43011     3  0.0146    0.73679 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM78523     3  0.3828   -0.15702 0.000 0.000 0.560 0.000 0.440 0.000
#> GSM78526     6  0.3198    0.59766 0.000 0.000 0.000 0.260 0.000 0.740
#> GSM78529     2  0.3563    0.71029 0.000 0.664 0.000 0.000 0.336 0.000
#> GSM78532     1  0.0000    0.88790 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78534     1  0.4302    0.77946 0.728 0.000 0.000 0.000 0.156 0.116
#> GSM78537     1  0.0547    0.88447 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM78543     4  0.0000    0.75815 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78548     4  0.4972    0.07630 0.000 0.000 0.116 0.628 0.000 0.256
#> GSM78557     4  0.0000    0.75815 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78560     4  0.0000    0.75815 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78565     1  0.0000    0.88790 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM43000     3  0.3828   -0.15702 0.000 0.000 0.560 0.000 0.440 0.000
#> GSM43002     3  0.0000    0.73846 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM43004     1  0.4302    0.77946 0.728 0.000 0.000 0.000 0.156 0.116
#> GSM43007     3  0.0632    0.72836 0.000 0.000 0.976 0.024 0.000 0.000
#> GSM43010     6  0.3266    0.58239 0.000 0.000 0.000 0.272 0.000 0.728
#> GSM78522     3  0.0458    0.73364 0.000 0.000 0.984 0.000 0.016 0.000
#> GSM78525     3  0.0000    0.73846 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM78528     3  0.3828   -0.15702 0.000 0.000 0.560 0.000 0.440 0.000
#> GSM78531     1  0.0000    0.88790 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78533     4  0.0000    0.75815 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM78536     1  0.0000    0.88790 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78541     1  0.0000    0.88790 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78547     1  0.5997    0.64904 0.588 0.000 0.000 0.048 0.156 0.208
#> GSM78552     3  0.0000    0.73846 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM78556     4  0.3351    0.53677 0.000 0.000 0.000 0.712 0.000 0.288
#> GSM78559     1  0.0000    0.88790 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78564     4  0.0000    0.75815 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM42999     2  0.3050    0.77871 0.000 0.764 0.000 0.000 0.236 0.000
#> GSM43001     2  0.0000    0.81185 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43003     5  0.2416    0.49854 0.000 0.000 0.156 0.000 0.844 0.000
#> GSM43006     2  0.0000    0.81185 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM43009     5  0.3864   -0.04823 0.000 0.000 0.480 0.000 0.520 0.000
#> GSM43012     5  0.3151    0.01003 0.000 0.252 0.000 0.000 0.748 0.000
#> GSM78524     1  0.4539    0.69289 0.688 0.000 0.000 0.000 0.096 0.216
#> GSM78527     2  0.3634    0.69797 0.000 0.644 0.000 0.000 0.356 0.000
#> GSM78530     3  0.1501    0.69597 0.000 0.000 0.924 0.000 0.076 0.000
#> GSM78535     1  0.0000    0.88790 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM78538     6  0.0458    0.58739 0.000 0.000 0.000 0.016 0.000 0.984
#> GSM78542     6  0.2048    0.64265 0.000 0.000 0.000 0.120 0.000 0.880
#> GSM78544     3  0.4305    0.48639 0.000 0.000 0.708 0.000 0.076 0.216
#> GSM78549     3  0.4855    0.42673 0.000 0.000 0.660 0.000 0.136 0.204
#> GSM78553     6  0.3765    0.52133 0.000 0.000 0.000 0.404 0.000 0.596
#> GSM78558     6  0.3774    0.51728 0.000 0.000 0.000 0.408 0.000 0.592
#> GSM78561     2  0.0000    0.81185 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-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 cell.type(p) agent(p) individual(p) k
#> ATC:pam 58      0.05915    0.340       0.00642 2
#> ATC:pam 57      0.03338    0.259       0.04791 3
#> ATC:pam 57      0.01011    0.582       0.07213 4
#> ATC:pam 52      0.02597    0.543       0.17726 5
#> ATC:pam 46      0.00136    0.578       0.21493 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 58 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.794           0.901       0.957         0.4353 0.552   0.552
#> 3 3 0.490           0.795       0.860         0.4037 0.726   0.531
#> 4 4 0.976           0.929       0.964         0.1605 0.894   0.716
#> 5 5 0.780           0.700       0.844         0.1044 0.849   0.542
#> 6 6 0.727           0.697       0.793         0.0456 0.915   0.642

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

suggest_best_k(res)
#> [1] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM78539     1  0.0000      0.978 1.000 0.000
#> GSM78545     1  0.8813      0.519 0.700 0.300
#> GSM78550     1  0.0000      0.978 1.000 0.000
#> GSM78554     1  0.0000      0.978 1.000 0.000
#> GSM78562     1  0.0000      0.978 1.000 0.000
#> GSM78540     1  0.0000      0.978 1.000 0.000
#> GSM78546     1  0.0000      0.978 1.000 0.000
#> GSM78551     1  0.0000      0.978 1.000 0.000
#> GSM78555     1  0.0000      0.978 1.000 0.000
#> GSM78563     1  0.0000      0.978 1.000 0.000
#> GSM43005     1  0.0376      0.974 0.996 0.004
#> GSM43008     1  0.0000      0.978 1.000 0.000
#> GSM43011     2  0.9850      0.306 0.428 0.572
#> GSM78523     2  0.7674      0.710 0.224 0.776
#> GSM78526     1  0.0000      0.978 1.000 0.000
#> GSM78529     2  0.0000      0.896 0.000 1.000
#> GSM78532     1  0.0000      0.978 1.000 0.000
#> GSM78534     1  0.0000      0.978 1.000 0.000
#> GSM78537     1  0.0000      0.978 1.000 0.000
#> GSM78543     1  0.0000      0.978 1.000 0.000
#> GSM78548     1  0.0000      0.978 1.000 0.000
#> GSM78557     1  0.0000      0.978 1.000 0.000
#> GSM78560     1  0.0000      0.978 1.000 0.000
#> GSM78565     1  0.0000      0.978 1.000 0.000
#> GSM43000     2  0.5946      0.797 0.144 0.856
#> GSM43002     1  0.0000      0.978 1.000 0.000
#> GSM43004     1  0.0000      0.978 1.000 0.000
#> GSM43007     1  0.0000      0.978 1.000 0.000
#> GSM43010     1  0.0000      0.978 1.000 0.000
#> GSM78522     1  0.0000      0.978 1.000 0.000
#> GSM78525     1  0.6623      0.759 0.828 0.172
#> GSM78528     2  0.0672      0.893 0.008 0.992
#> GSM78531     1  0.0000      0.978 1.000 0.000
#> GSM78533     1  0.0000      0.978 1.000 0.000
#> GSM78536     1  0.0000      0.978 1.000 0.000
#> GSM78541     1  0.0000      0.978 1.000 0.000
#> GSM78547     1  0.0000      0.978 1.000 0.000
#> GSM78552     1  0.0000      0.978 1.000 0.000
#> GSM78556     1  0.0000      0.978 1.000 0.000
#> GSM78559     1  0.0000      0.978 1.000 0.000
#> GSM78564     1  0.0000      0.978 1.000 0.000
#> GSM42999     2  0.0000      0.896 0.000 1.000
#> GSM43001     2  0.0000      0.896 0.000 1.000
#> GSM43003     2  0.0000      0.896 0.000 1.000
#> GSM43006     2  0.0000      0.896 0.000 1.000
#> GSM43009     2  0.0000      0.896 0.000 1.000
#> GSM43012     2  0.0000      0.896 0.000 1.000
#> GSM78524     1  0.0000      0.978 1.000 0.000
#> GSM78527     2  0.0000      0.896 0.000 1.000
#> GSM78530     2  0.0000      0.896 0.000 1.000
#> GSM78535     1  0.0000      0.978 1.000 0.000
#> GSM78538     2  0.8443      0.655 0.272 0.728
#> GSM78542     2  0.8443      0.655 0.272 0.728
#> GSM78544     2  0.0000      0.896 0.000 1.000
#> GSM78549     2  0.0000      0.896 0.000 1.000
#> GSM78553     2  0.9732      0.395 0.404 0.596
#> GSM78558     1  0.8016      0.630 0.756 0.244
#> GSM78561     2  0.0000      0.896 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     3  0.0892      0.912 0.020 0.000 0.980
#> GSM78545     3  0.6393      0.549 0.048 0.216 0.736
#> GSM78550     3  0.1411      0.910 0.036 0.000 0.964
#> GSM78554     3  0.0892      0.912 0.020 0.000 0.980
#> GSM78562     1  0.5431      0.772 0.716 0.000 0.284
#> GSM78540     3  0.5497      0.380 0.292 0.000 0.708
#> GSM78546     3  0.0000      0.910 0.000 0.000 1.000
#> GSM78551     3  0.1289      0.909 0.032 0.000 0.968
#> GSM78555     1  0.5216      0.797 0.740 0.000 0.260
#> GSM78563     3  0.1411      0.907 0.036 0.000 0.964
#> GSM43005     3  0.3456      0.849 0.036 0.060 0.904
#> GSM43008     3  0.0000      0.910 0.000 0.000 1.000
#> GSM43011     2  0.7755      0.384 0.048 0.492 0.460
#> GSM78523     2  0.7065      0.734 0.048 0.664 0.288
#> GSM78526     3  0.1529      0.909 0.040 0.000 0.960
#> GSM78529     2  0.6252      0.748 0.024 0.708 0.268
#> GSM78532     1  0.3752      0.866 0.856 0.000 0.144
#> GSM78534     1  0.3482      0.859 0.872 0.000 0.128
#> GSM78537     1  0.5016      0.812 0.760 0.000 0.240
#> GSM78543     3  0.3038      0.796 0.104 0.000 0.896
#> GSM78548     3  0.1411      0.910 0.036 0.000 0.964
#> GSM78557     3  0.0592      0.912 0.012 0.000 0.988
#> GSM78560     3  0.0237      0.910 0.004 0.000 0.996
#> GSM78565     1  0.3752      0.866 0.856 0.000 0.144
#> GSM43000     2  0.7034      0.738 0.048 0.668 0.284
#> GSM43002     3  0.0983      0.906 0.004 0.016 0.980
#> GSM43004     1  0.3879      0.864 0.848 0.000 0.152
#> GSM43007     3  0.0000      0.910 0.000 0.000 1.000
#> GSM43010     3  0.1289      0.909 0.032 0.000 0.968
#> GSM78522     3  0.0000      0.910 0.000 0.000 1.000
#> GSM78525     3  0.5268      0.635 0.012 0.212 0.776
#> GSM78528     2  0.7002      0.742 0.048 0.672 0.280
#> GSM78531     1  0.3752      0.866 0.856 0.000 0.144
#> GSM78533     3  0.1289      0.909 0.032 0.000 0.968
#> GSM78536     1  0.3412      0.858 0.876 0.000 0.124
#> GSM78541     1  0.3752      0.866 0.856 0.000 0.144
#> GSM78547     1  0.6168      0.554 0.588 0.000 0.412
#> GSM78552     3  0.0000      0.910 0.000 0.000 1.000
#> GSM78556     3  0.1289      0.909 0.032 0.000 0.968
#> GSM78559     1  0.3752      0.866 0.856 0.000 0.144
#> GSM78564     3  0.0747      0.912 0.016 0.000 0.984
#> GSM42999     2  0.0424      0.779 0.008 0.992 0.000
#> GSM43001     2  0.0747      0.778 0.016 0.984 0.000
#> GSM43003     2  0.0892      0.779 0.020 0.980 0.000
#> GSM43006     2  0.0747      0.778 0.016 0.984 0.000
#> GSM43009     2  0.6904      0.748 0.048 0.684 0.268
#> GSM43012     2  0.0592      0.779 0.012 0.988 0.000
#> GSM78524     1  0.4555      0.739 0.800 0.000 0.200
#> GSM78527     2  0.0592      0.778 0.012 0.988 0.000
#> GSM78530     2  0.6904      0.748 0.048 0.684 0.268
#> GSM78535     1  0.2796      0.835 0.908 0.000 0.092
#> GSM78538     1  0.7478      0.497 0.632 0.060 0.308
#> GSM78542     1  0.7801      0.487 0.616 0.076 0.308
#> GSM78544     2  0.6904      0.748 0.048 0.684 0.268
#> GSM78549     2  0.1529      0.776 0.040 0.960 0.000
#> GSM78553     3  0.7501      0.586 0.212 0.104 0.684
#> GSM78558     3  0.4339      0.810 0.048 0.084 0.868
#> GSM78561     2  0.0747      0.778 0.016 0.984 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     3  0.0469      0.940 0.012 0.000 0.988 0.000
#> GSM78545     3  0.4679      0.502 0.000 0.352 0.648 0.000
#> GSM78550     3  0.0376      0.940 0.004 0.000 0.992 0.004
#> GSM78554     3  0.0469      0.940 0.012 0.000 0.988 0.000
#> GSM78562     1  0.0469      0.992 0.988 0.000 0.012 0.000
#> GSM78540     3  0.0657      0.940 0.012 0.000 0.984 0.004
#> GSM78546     3  0.0000      0.940 0.000 0.000 1.000 0.000
#> GSM78551     3  0.0657      0.940 0.012 0.000 0.984 0.004
#> GSM78555     1  0.0592      0.988 0.984 0.000 0.016 0.000
#> GSM78563     3  0.0657      0.940 0.012 0.000 0.984 0.004
#> GSM43005     3  0.4730      0.459 0.000 0.364 0.636 0.000
#> GSM43008     3  0.0000      0.940 0.000 0.000 1.000 0.000
#> GSM43011     3  0.1557      0.908 0.000 0.056 0.944 0.000
#> GSM78523     2  0.0524      0.955 0.000 0.988 0.008 0.004
#> GSM78526     3  0.0376      0.940 0.004 0.000 0.992 0.004
#> GSM78529     2  0.1557      0.922 0.000 0.944 0.000 0.056
#> GSM78532     1  0.0336      0.995 0.992 0.000 0.008 0.000
#> GSM78534     1  0.0336      0.995 0.992 0.000 0.008 0.000
#> GSM78537     1  0.0336      0.995 0.992 0.000 0.008 0.000
#> GSM78543     3  0.0524      0.940 0.008 0.000 0.988 0.004
#> GSM78548     3  0.0188      0.940 0.004 0.000 0.996 0.000
#> GSM78557     3  0.0336      0.940 0.008 0.000 0.992 0.000
#> GSM78560     3  0.0336      0.940 0.008 0.000 0.992 0.000
#> GSM78565     1  0.0524      0.993 0.988 0.000 0.008 0.004
#> GSM43000     2  0.0336      0.957 0.000 0.992 0.008 0.000
#> GSM43002     3  0.0707      0.932 0.000 0.020 0.980 0.000
#> GSM43004     1  0.0336      0.995 0.992 0.000 0.008 0.000
#> GSM43007     3  0.0188      0.939 0.000 0.000 0.996 0.004
#> GSM43010     3  0.2311      0.882 0.004 0.076 0.916 0.004
#> GSM78522     3  0.0188      0.939 0.000 0.000 0.996 0.004
#> GSM78525     3  0.0469      0.937 0.000 0.012 0.988 0.000
#> GSM78528     2  0.0336      0.957 0.000 0.992 0.008 0.000
#> GSM78531     1  0.0336      0.995 0.992 0.000 0.008 0.000
#> GSM78533     3  0.0469      0.940 0.012 0.000 0.988 0.000
#> GSM78536     1  0.0336      0.995 0.992 0.000 0.008 0.000
#> GSM78541     1  0.0336      0.995 0.992 0.000 0.008 0.000
#> GSM78547     1  0.0707      0.984 0.980 0.000 0.020 0.000
#> GSM78552     3  0.0000      0.940 0.000 0.000 1.000 0.000
#> GSM78556     3  0.0657      0.940 0.012 0.000 0.984 0.004
#> GSM78559     1  0.0336      0.995 0.992 0.000 0.008 0.000
#> GSM78564     3  0.0336      0.940 0.008 0.000 0.992 0.000
#> GSM42999     4  0.0592      0.994 0.000 0.016 0.000 0.984
#> GSM43001     4  0.0469      0.994 0.000 0.012 0.000 0.988
#> GSM43003     4  0.0707      0.993 0.000 0.020 0.000 0.980
#> GSM43006     4  0.0707      0.993 0.000 0.020 0.000 0.980
#> GSM43009     2  0.0336      0.957 0.000 0.992 0.000 0.008
#> GSM43012     4  0.0707      0.994 0.000 0.020 0.000 0.980
#> GSM78524     1  0.0524      0.980 0.988 0.008 0.000 0.004
#> GSM78527     4  0.0707      0.994 0.000 0.020 0.000 0.980
#> GSM78530     2  0.0188      0.957 0.000 0.996 0.000 0.004
#> GSM78535     1  0.0376      0.989 0.992 0.000 0.004 0.004
#> GSM78538     2  0.0927      0.951 0.016 0.976 0.008 0.000
#> GSM78542     2  0.0804      0.953 0.008 0.980 0.012 0.000
#> GSM78544     2  0.0000      0.957 0.000 1.000 0.000 0.000
#> GSM78549     2  0.0592      0.955 0.000 0.984 0.000 0.016
#> GSM78553     2  0.3710      0.724 0.004 0.804 0.192 0.000
#> GSM78558     3  0.5070      0.311 0.004 0.416 0.580 0.000
#> GSM78561     4  0.0469      0.994 0.000 0.012 0.000 0.988

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4  0.4173      0.568 0.012 0.000 0.000 0.688 0.300
#> GSM78545     3  0.3449      0.616 0.000 0.000 0.812 0.164 0.024
#> GSM78550     5  0.6672     -0.227 0.016 0.000 0.144 0.416 0.424
#> GSM78554     4  0.4367      0.489 0.008 0.000 0.000 0.620 0.372
#> GSM78562     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000
#> GSM78540     4  0.5077      0.450 0.016 0.000 0.016 0.576 0.392
#> GSM78546     4  0.1697      0.699 0.000 0.000 0.060 0.932 0.008
#> GSM78551     4  0.6326      0.150 0.016 0.000 0.100 0.444 0.440
#> GSM78555     1  0.1697      0.917 0.932 0.000 0.000 0.060 0.008
#> GSM78563     4  0.4994      0.450 0.016 0.000 0.012 0.576 0.396
#> GSM43005     3  0.4768      0.244 0.000 0.000 0.592 0.384 0.024
#> GSM43008     4  0.1410      0.699 0.000 0.000 0.060 0.940 0.000
#> GSM43011     3  0.3821      0.581 0.000 0.000 0.764 0.216 0.020
#> GSM78523     3  0.0162      0.679 0.000 0.000 0.996 0.004 0.000
#> GSM78526     5  0.4806      0.650 0.016 0.000 0.144 0.088 0.752
#> GSM78529     3  0.5628      0.486 0.000 0.220 0.632 0.000 0.148
#> GSM78532     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000
#> GSM78534     1  0.0162      0.983 0.996 0.000 0.000 0.000 0.004
#> GSM78537     1  0.0162      0.982 0.996 0.000 0.000 0.004 0.000
#> GSM78543     4  0.0290      0.694 0.000 0.000 0.000 0.992 0.008
#> GSM78548     4  0.6897      0.199 0.016 0.000 0.360 0.436 0.188
#> GSM78557     4  0.1331      0.697 0.008 0.000 0.000 0.952 0.040
#> GSM78560     4  0.0290      0.695 0.000 0.000 0.000 0.992 0.008
#> GSM78565     1  0.0404      0.980 0.988 0.000 0.000 0.000 0.012
#> GSM43000     3  0.0000      0.679 0.000 0.000 1.000 0.000 0.000
#> GSM43002     3  0.4718      0.317 0.008 0.000 0.580 0.404 0.008
#> GSM43004     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000
#> GSM43007     4  0.1410      0.699 0.000 0.000 0.060 0.940 0.000
#> GSM43010     5  0.3547      0.689 0.016 0.000 0.144 0.016 0.824
#> GSM78522     4  0.1430      0.700 0.000 0.000 0.052 0.944 0.004
#> GSM78525     3  0.4726      0.262 0.000 0.000 0.580 0.400 0.020
#> GSM78528     3  0.0510      0.680 0.000 0.000 0.984 0.000 0.016
#> GSM78531     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000
#> GSM78533     4  0.5077      0.451 0.016 0.000 0.016 0.576 0.392
#> GSM78536     1  0.0162      0.984 0.996 0.000 0.000 0.000 0.004
#> GSM78541     1  0.0162      0.984 0.996 0.000 0.000 0.000 0.004
#> GSM78547     1  0.1282      0.940 0.952 0.000 0.000 0.044 0.004
#> GSM78552     4  0.1697      0.699 0.000 0.000 0.060 0.932 0.008
#> GSM78556     4  0.4640      0.460 0.016 0.000 0.000 0.584 0.400
#> GSM78559     1  0.0162      0.984 0.996 0.000 0.000 0.000 0.004
#> GSM78564     4  0.1597      0.698 0.012 0.000 0.000 0.940 0.048
#> GSM42999     2  0.0324      0.987 0.000 0.992 0.004 0.000 0.004
#> GSM43001     2  0.0162      0.988 0.000 0.996 0.000 0.000 0.004
#> GSM43003     2  0.0880      0.964 0.000 0.968 0.032 0.000 0.000
#> GSM43006     2  0.0162      0.988 0.000 0.996 0.004 0.000 0.000
#> GSM43009     3  0.2605      0.657 0.000 0.000 0.852 0.000 0.148
#> GSM43012     2  0.0693      0.980 0.000 0.980 0.008 0.000 0.012
#> GSM78524     1  0.0794      0.970 0.972 0.000 0.000 0.000 0.028
#> GSM78527     2  0.0162      0.988 0.000 0.996 0.000 0.000 0.004
#> GSM78530     3  0.2561      0.656 0.000 0.000 0.856 0.000 0.144
#> GSM78535     1  0.0404      0.980 0.988 0.000 0.000 0.000 0.012
#> GSM78538     5  0.1731      0.712 0.004 0.004 0.060 0.000 0.932
#> GSM78542     5  0.1798      0.712 0.004 0.004 0.064 0.000 0.928
#> GSM78544     3  0.2605      0.655 0.000 0.000 0.852 0.000 0.148
#> GSM78549     3  0.6166      0.221 0.000 0.340 0.512 0.000 0.148
#> GSM78553     5  0.1341      0.718 0.000 0.000 0.056 0.000 0.944
#> GSM78558     5  0.4571      0.588 0.000 0.000 0.076 0.188 0.736
#> GSM78561     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM78539     4  0.2830      0.757 0.000 0.000 0.000 0.836 0.020 0.144
#> GSM78545     3  0.2182      0.718 0.000 0.000 0.904 0.020 0.008 0.068
#> GSM78550     4  0.1116      0.829 0.000 0.000 0.004 0.960 0.028 0.008
#> GSM78554     4  0.4454      0.382 0.004 0.000 0.000 0.616 0.032 0.348
#> GSM78562     1  0.3986      0.779 0.664 0.000 0.000 0.020 0.316 0.000
#> GSM78540     4  0.0777      0.828 0.000 0.000 0.000 0.972 0.024 0.004
#> GSM78546     6  0.5081      0.617 0.000 0.000 0.316 0.088 0.004 0.592
#> GSM78551     4  0.1010      0.828 0.000 0.000 0.004 0.960 0.036 0.000
#> GSM78555     1  0.2151      0.757 0.904 0.000 0.000 0.072 0.008 0.016
#> GSM78563     4  0.0603      0.828 0.000 0.000 0.000 0.980 0.016 0.004
#> GSM43005     3  0.3792      0.619 0.000 0.000 0.780 0.160 0.008 0.052
#> GSM43008     6  0.5317      0.623 0.000 0.000 0.316 0.112 0.004 0.568
#> GSM43011     3  0.2877      0.678 0.000 0.000 0.848 0.020 0.008 0.124
#> GSM78523     3  0.0260      0.734 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM78526     4  0.2234      0.775 0.000 0.000 0.004 0.872 0.124 0.000
#> GSM78529     3  0.4585      0.471 0.000 0.192 0.692 0.000 0.116 0.000
#> GSM78532     1  0.3758      0.798 0.700 0.000 0.000 0.016 0.284 0.000
#> GSM78534     1  0.4018      0.774 0.656 0.000 0.000 0.020 0.324 0.000
#> GSM78537     1  0.2892      0.817 0.840 0.000 0.000 0.020 0.136 0.004
#> GSM78543     6  0.2730      0.612 0.000 0.000 0.000 0.192 0.000 0.808
#> GSM78548     4  0.1346      0.827 0.000 0.000 0.016 0.952 0.024 0.008
#> GSM78557     6  0.3512      0.523 0.000 0.000 0.000 0.272 0.008 0.720
#> GSM78560     6  0.3244      0.576 0.000 0.000 0.000 0.268 0.000 0.732
#> GSM78565     1  0.1500      0.784 0.936 0.000 0.000 0.012 0.000 0.052
#> GSM43000     3  0.0000      0.735 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM43002     3  0.5705      0.449 0.000 0.000 0.608 0.028 0.172 0.192
#> GSM43004     1  0.3819      0.799 0.700 0.000 0.000 0.020 0.280 0.000
#> GSM43007     6  0.5454      0.618 0.000 0.000 0.316 0.128 0.004 0.552
#> GSM43010     4  0.2743      0.721 0.000 0.000 0.008 0.828 0.164 0.000
#> GSM78522     6  0.3822      0.665 0.000 0.000 0.096 0.128 0.000 0.776
#> GSM78525     3  0.4886      0.222 0.000 0.000 0.620 0.076 0.004 0.300
#> GSM78528     3  0.0000      0.735 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM78531     1  0.3738      0.800 0.704 0.000 0.000 0.016 0.280 0.000
#> GSM78533     4  0.0777      0.831 0.000 0.000 0.000 0.972 0.024 0.004
#> GSM78536     1  0.1364      0.792 0.944 0.000 0.000 0.004 0.004 0.048
#> GSM78541     1  0.0820      0.808 0.972 0.000 0.000 0.012 0.016 0.000
#> GSM78547     1  0.5058      0.752 0.604 0.000 0.004 0.056 0.324 0.012
#> GSM78552     6  0.4993      0.612 0.000 0.000 0.316 0.080 0.004 0.600
#> GSM78556     4  0.1757      0.820 0.012 0.000 0.000 0.928 0.008 0.052
#> GSM78559     1  0.1219      0.791 0.948 0.000 0.000 0.004 0.000 0.048
#> GSM78564     4  0.3953      0.402 0.000 0.000 0.000 0.656 0.016 0.328
#> GSM42999     2  0.1204      0.899 0.000 0.944 0.000 0.000 0.056 0.000
#> GSM43001     2  0.1556      0.917 0.000 0.920 0.000 0.000 0.080 0.000
#> GSM43003     2  0.1204      0.889 0.000 0.944 0.056 0.000 0.000 0.000
#> GSM43006     2  0.0790      0.910 0.000 0.968 0.032 0.000 0.000 0.000
#> GSM43009     3  0.2609      0.679 0.000 0.000 0.868 0.036 0.096 0.000
#> GSM43012     2  0.1814      0.905 0.000 0.900 0.000 0.000 0.100 0.000
#> GSM78524     1  0.3753      0.788 0.748 0.000 0.000 0.028 0.220 0.004
#> GSM78527     2  0.1556      0.917 0.000 0.920 0.000 0.000 0.080 0.000
#> GSM78530     3  0.3834      0.547 0.000 0.000 0.732 0.036 0.232 0.000
#> GSM78535     1  0.1075      0.790 0.952 0.000 0.000 0.000 0.000 0.048
#> GSM78538     5  0.2536      0.676 0.000 0.000 0.020 0.116 0.864 0.000
#> GSM78542     5  0.2830      0.664 0.000 0.000 0.020 0.144 0.836 0.000
#> GSM78544     3  0.4810      0.350 0.000 0.000 0.660 0.220 0.120 0.000
#> GSM78549     5  0.6071      0.154 0.000 0.276 0.328 0.000 0.396 0.000
#> GSM78553     4  0.4399      0.124 0.000 0.000 0.024 0.516 0.460 0.000
#> GSM78558     4  0.2094      0.817 0.000 0.000 0.008 0.908 0.068 0.016
#> GSM78561     2  0.0000      0.914 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-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 cell.type(p) agent(p) individual(p) k
#> ATC:mclust 56     8.02e-07   0.0651         0.199 2
#> ATC:mclust 54     1.09e-04   0.1343         0.181 3
#> ATC:mclust 56     1.35e-06   0.0919         0.504 4
#> ATC:mclust 45     2.43e-03   0.2226         0.562 5
#> ATC:mclust 50     1.05e-04   0.2599         0.460 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 58 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

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 0.928           0.938       0.976         0.3035 0.710   0.710
#> 3 3 0.744           0.793       0.922         1.0230 0.628   0.494
#> 4 4 0.633           0.681       0.856         0.1667 0.731   0.421
#> 5 5 0.671           0.741       0.862         0.0652 0.833   0.506
#> 6 6 0.655           0.613       0.754         0.0538 0.944   0.783

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
#> GSM78539     1  0.0000     0.9773 1.000 0.000
#> GSM78545     1  0.0000     0.9773 1.000 0.000
#> GSM78550     1  0.0000     0.9773 1.000 0.000
#> GSM78554     1  0.0000     0.9773 1.000 0.000
#> GSM78562     1  0.0000     0.9773 1.000 0.000
#> GSM78540     1  0.0000     0.9773 1.000 0.000
#> GSM78546     1  0.0000     0.9773 1.000 0.000
#> GSM78551     1  0.0000     0.9773 1.000 0.000
#> GSM78555     1  0.0000     0.9773 1.000 0.000
#> GSM78563     1  0.0000     0.9773 1.000 0.000
#> GSM43005     1  0.0000     0.9773 1.000 0.000
#> GSM43008     1  0.0000     0.9773 1.000 0.000
#> GSM43011     1  0.0000     0.9773 1.000 0.000
#> GSM78523     2  0.6887     0.7892 0.184 0.816
#> GSM78526     1  0.0000     0.9773 1.000 0.000
#> GSM78529     2  0.0000     0.9553 0.000 1.000
#> GSM78532     1  0.0000     0.9773 1.000 0.000
#> GSM78534     1  0.0000     0.9773 1.000 0.000
#> GSM78537     1  0.0000     0.9773 1.000 0.000
#> GSM78543     1  0.0000     0.9773 1.000 0.000
#> GSM78548     1  0.0000     0.9773 1.000 0.000
#> GSM78557     1  0.0000     0.9773 1.000 0.000
#> GSM78560     1  0.0000     0.9773 1.000 0.000
#> GSM78565     1  0.0000     0.9773 1.000 0.000
#> GSM43000     1  0.9608     0.3448 0.616 0.384
#> GSM43002     1  0.0000     0.9773 1.000 0.000
#> GSM43004     1  0.0000     0.9773 1.000 0.000
#> GSM43007     1  0.0000     0.9773 1.000 0.000
#> GSM43010     1  0.0000     0.9773 1.000 0.000
#> GSM78522     1  0.0000     0.9773 1.000 0.000
#> GSM78525     1  0.0000     0.9773 1.000 0.000
#> GSM78528     1  0.5408     0.8394 0.876 0.124
#> GSM78531     1  0.0000     0.9773 1.000 0.000
#> GSM78533     1  0.0000     0.9773 1.000 0.000
#> GSM78536     1  0.0000     0.9773 1.000 0.000
#> GSM78541     1  0.0000     0.9773 1.000 0.000
#> GSM78547     1  0.0000     0.9773 1.000 0.000
#> GSM78552     1  0.0000     0.9773 1.000 0.000
#> GSM78556     1  0.0000     0.9773 1.000 0.000
#> GSM78559     1  0.0000     0.9773 1.000 0.000
#> GSM78564     1  0.0000     0.9773 1.000 0.000
#> GSM42999     2  0.0000     0.9553 0.000 1.000
#> GSM43001     2  0.0000     0.9553 0.000 1.000
#> GSM43003     2  0.0672     0.9511 0.008 0.992
#> GSM43006     2  0.0000     0.9553 0.000 1.000
#> GSM43009     2  0.7056     0.7780 0.192 0.808
#> GSM43012     2  0.0000     0.9553 0.000 1.000
#> GSM78524     1  0.0000     0.9773 1.000 0.000
#> GSM78527     2  0.0000     0.9553 0.000 1.000
#> GSM78530     1  0.1184     0.9621 0.984 0.016
#> GSM78535     1  0.0000     0.9773 1.000 0.000
#> GSM78538     1  0.0000     0.9773 1.000 0.000
#> GSM78542     1  0.0000     0.9773 1.000 0.000
#> GSM78544     1  0.0000     0.9773 1.000 0.000
#> GSM78549     1  0.9988     0.0247 0.520 0.480
#> GSM78553     1  0.0000     0.9773 1.000 0.000
#> GSM78558     1  0.0000     0.9773 1.000 0.000
#> GSM78561     2  0.0000     0.9553 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM78539     1  0.0237     0.8968 0.996 0.000 0.004
#> GSM78545     3  0.0000     0.8704 0.000 0.000 1.000
#> GSM78550     3  0.0000     0.8704 0.000 0.000 1.000
#> GSM78554     1  0.5733     0.5280 0.676 0.000 0.324
#> GSM78562     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78540     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78546     1  0.6126     0.2448 0.600 0.000 0.400
#> GSM78551     1  0.6215     0.2764 0.572 0.000 0.428
#> GSM78555     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78563     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM43005     3  0.0000     0.8704 0.000 0.000 1.000
#> GSM43008     3  0.5465     0.5668 0.288 0.000 0.712
#> GSM43011     3  0.0000     0.8704 0.000 0.000 1.000
#> GSM78523     3  0.0000     0.8704 0.000 0.000 1.000
#> GSM78526     3  0.0000     0.8704 0.000 0.000 1.000
#> GSM78529     2  0.0237     0.9632 0.000 0.996 0.004
#> GSM78532     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78534     1  0.0237     0.8968 0.996 0.000 0.004
#> GSM78537     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78543     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78548     3  0.0000     0.8704 0.000 0.000 1.000
#> GSM78557     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78560     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78565     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM43000     3  0.0000     0.8704 0.000 0.000 1.000
#> GSM43002     3  0.0000     0.8704 0.000 0.000 1.000
#> GSM43004     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM43007     1  0.6302    -0.0227 0.520 0.000 0.480
#> GSM43010     3  0.0592     0.8631 0.012 0.000 0.988
#> GSM78522     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78525     3  0.0000     0.8704 0.000 0.000 1.000
#> GSM78528     3  0.0000     0.8704 0.000 0.000 1.000
#> GSM78531     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78533     3  0.6215     0.2436 0.428 0.000 0.572
#> GSM78536     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78541     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78547     1  0.2537     0.8372 0.920 0.000 0.080
#> GSM78552     3  0.5988     0.4117 0.368 0.000 0.632
#> GSM78556     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78559     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78564     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM42999     2  0.0000     0.9663 0.000 1.000 0.000
#> GSM43001     2  0.0000     0.9663 0.000 1.000 0.000
#> GSM43003     2  0.0000     0.9663 0.000 1.000 0.000
#> GSM43006     2  0.0000     0.9663 0.000 1.000 0.000
#> GSM43009     3  0.4399     0.6752 0.000 0.188 0.812
#> GSM43012     2  0.0000     0.9663 0.000 1.000 0.000
#> GSM78524     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78527     2  0.0000     0.9663 0.000 1.000 0.000
#> GSM78530     3  0.1163     0.8508 0.000 0.028 0.972
#> GSM78535     1  0.0000     0.8992 1.000 0.000 0.000
#> GSM78538     1  0.4605     0.7070 0.796 0.000 0.204
#> GSM78542     1  0.5810     0.4972 0.664 0.000 0.336
#> GSM78544     3  0.0237     0.8684 0.004 0.000 0.996
#> GSM78549     2  0.5058     0.6578 0.000 0.756 0.244
#> GSM78553     3  0.6274     0.0561 0.456 0.000 0.544
#> GSM78558     1  0.5178     0.6388 0.744 0.000 0.256
#> GSM78561     2  0.0000     0.9663 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM78539     4  0.5938    -0.0254 0.476 0.000 0.036 0.488
#> GSM78545     3  0.0188     0.8741 0.000 0.000 0.996 0.004
#> GSM78550     4  0.4431     0.5254 0.000 0.000 0.304 0.696
#> GSM78554     4  0.4019     0.6433 0.012 0.000 0.196 0.792
#> GSM78562     4  0.1557     0.7580 0.056 0.000 0.000 0.944
#> GSM78540     4  0.1637     0.7573 0.060 0.000 0.000 0.940
#> GSM78546     3  0.2814     0.7991 0.132 0.000 0.868 0.000
#> GSM78551     4  0.0469     0.7578 0.000 0.000 0.012 0.988
#> GSM78555     1  0.4948     0.5144 0.560 0.000 0.000 0.440
#> GSM78563     4  0.1474     0.7590 0.052 0.000 0.000 0.948
#> GSM43005     3  0.1022     0.8601 0.000 0.000 0.968 0.032
#> GSM43008     3  0.1211     0.8615 0.040 0.000 0.960 0.000
#> GSM43011     3  0.0000     0.8747 0.000 0.000 1.000 0.000
#> GSM78523     3  0.0336     0.8738 0.008 0.000 0.992 0.000
#> GSM78526     4  0.4981     0.1117 0.000 0.000 0.464 0.536
#> GSM78529     2  0.2760     0.8002 0.000 0.872 0.128 0.000
#> GSM78532     4  0.1716     0.7548 0.064 0.000 0.000 0.936
#> GSM78534     4  0.0817     0.7622 0.024 0.000 0.000 0.976
#> GSM78537     4  0.3123     0.6611 0.156 0.000 0.000 0.844
#> GSM78543     1  0.0469     0.6631 0.988 0.000 0.000 0.012
#> GSM78548     3  0.3726     0.6879 0.000 0.000 0.788 0.212
#> GSM78557     1  0.1867     0.7011 0.928 0.000 0.000 0.072
#> GSM78560     1  0.0000     0.6530 1.000 0.000 0.000 0.000
#> GSM78565     1  0.3688     0.7042 0.792 0.000 0.000 0.208
#> GSM43000     3  0.0000     0.8747 0.000 0.000 1.000 0.000
#> GSM43002     3  0.0336     0.8738 0.008 0.000 0.992 0.000
#> GSM43004     4  0.2081     0.7412 0.084 0.000 0.000 0.916
#> GSM43007     3  0.2149     0.8345 0.088 0.000 0.912 0.000
#> GSM43010     4  0.2704     0.7064 0.000 0.000 0.124 0.876
#> GSM78522     1  0.2530     0.5497 0.888 0.000 0.112 0.000
#> GSM78525     3  0.0336     0.8728 0.000 0.000 0.992 0.008
#> GSM78528     3  0.0000     0.8747 0.000 0.000 1.000 0.000
#> GSM78531     4  0.1716     0.7548 0.064 0.000 0.000 0.936
#> GSM78533     4  0.4456     0.5330 0.004 0.000 0.280 0.716
#> GSM78536     1  0.4955     0.5085 0.556 0.000 0.000 0.444
#> GSM78541     4  0.4585     0.2239 0.332 0.000 0.000 0.668
#> GSM78547     4  0.0188     0.7614 0.004 0.000 0.000 0.996
#> GSM78552     3  0.2081     0.8380 0.084 0.000 0.916 0.000
#> GSM78556     4  0.2081     0.7436 0.084 0.000 0.000 0.916
#> GSM78559     1  0.4977     0.4728 0.540 0.000 0.000 0.460
#> GSM78564     1  0.3801     0.7007 0.780 0.000 0.000 0.220
#> GSM42999     2  0.0000     0.8855 0.000 1.000 0.000 0.000
#> GSM43001     2  0.0000     0.8855 0.000 1.000 0.000 0.000
#> GSM43003     2  0.2919     0.8447 0.044 0.896 0.060 0.000
#> GSM43006     2  0.0000     0.8855 0.000 1.000 0.000 0.000
#> GSM43009     2  0.4985     0.1160 0.000 0.532 0.468 0.000
#> GSM43012     2  0.0000     0.8855 0.000 1.000 0.000 0.000
#> GSM78524     4  0.3311     0.6378 0.172 0.000 0.000 0.828
#> GSM78527     2  0.0000     0.8855 0.000 1.000 0.000 0.000
#> GSM78530     3  0.6650     0.4288 0.004 0.272 0.612 0.112
#> GSM78535     1  0.4948     0.4951 0.560 0.000 0.000 0.440
#> GSM78538     4  0.0000     0.7607 0.000 0.000 0.000 1.000
#> GSM78542     4  0.0188     0.7603 0.000 0.000 0.004 0.996
#> GSM78544     3  0.4994     0.0329 0.000 0.000 0.520 0.480
#> GSM78549     2  0.4050     0.7447 0.000 0.808 0.168 0.024
#> GSM78553     4  0.3123     0.6753 0.000 0.000 0.156 0.844
#> GSM78558     4  0.4699     0.4885 0.004 0.000 0.320 0.676
#> GSM78561     2  0.0000     0.8855 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM78539     4  0.6004      0.352 0.328 0.068 0.028 0.576 0.000
#> GSM78545     3  0.1410      0.882 0.000 0.060 0.940 0.000 0.000
#> GSM78550     4  0.6129      0.386 0.004 0.160 0.264 0.572 0.000
#> GSM78554     4  0.4733      0.642 0.008 0.116 0.124 0.752 0.000
#> GSM78562     4  0.0162      0.798 0.000 0.004 0.000 0.996 0.000
#> GSM78540     4  0.0703      0.798 0.000 0.024 0.000 0.976 0.000
#> GSM78546     3  0.4444      0.775 0.156 0.088 0.756 0.000 0.000
#> GSM78551     4  0.2177      0.769 0.004 0.080 0.008 0.908 0.000
#> GSM78555     4  0.3728      0.599 0.244 0.008 0.000 0.748 0.000
#> GSM78563     4  0.0404      0.799 0.000 0.012 0.000 0.988 0.000
#> GSM43005     3  0.1671      0.877 0.000 0.076 0.924 0.000 0.000
#> GSM43008     3  0.3586      0.827 0.096 0.076 0.828 0.000 0.000
#> GSM43011     3  0.0609      0.892 0.000 0.020 0.980 0.000 0.000
#> GSM78523     3  0.0324      0.889 0.004 0.000 0.992 0.000 0.004
#> GSM78526     3  0.5834      0.303 0.004 0.092 0.548 0.356 0.000
#> GSM78529     5  0.1043      0.890 0.000 0.000 0.040 0.000 0.960
#> GSM78532     4  0.0162      0.798 0.000 0.004 0.000 0.996 0.000
#> GSM78534     4  0.1205      0.792 0.004 0.040 0.000 0.956 0.000
#> GSM78537     4  0.1211      0.793 0.024 0.016 0.000 0.960 0.000
#> GSM78543     1  0.1331      0.718 0.952 0.008 0.000 0.040 0.000
#> GSM78548     3  0.3617      0.797 0.004 0.128 0.824 0.044 0.000
#> GSM78557     1  0.3304      0.716 0.816 0.016 0.000 0.168 0.000
#> GSM78560     1  0.1369      0.693 0.956 0.028 0.008 0.008 0.000
#> GSM78565     1  0.4235      0.531 0.656 0.008 0.000 0.336 0.000
#> GSM43000     3  0.0609      0.892 0.000 0.020 0.980 0.000 0.000
#> GSM43002     3  0.0324      0.889 0.004 0.004 0.992 0.000 0.000
#> GSM43004     4  0.0451      0.799 0.008 0.004 0.000 0.988 0.000
#> GSM43007     3  0.2208      0.867 0.072 0.020 0.908 0.000 0.000
#> GSM43010     4  0.3827      0.690 0.004 0.068 0.112 0.816 0.000
#> GSM78522     1  0.2300      0.657 0.904 0.024 0.072 0.000 0.000
#> GSM78525     3  0.0963      0.891 0.000 0.036 0.964 0.000 0.000
#> GSM78528     3  0.0880      0.892 0.000 0.032 0.968 0.000 0.000
#> GSM78531     4  0.0000      0.798 0.000 0.000 0.000 1.000 0.000
#> GSM78533     4  0.5245      0.461 0.016 0.044 0.292 0.648 0.000
#> GSM78536     4  0.3231      0.657 0.196 0.004 0.000 0.800 0.000
#> GSM78541     4  0.1478      0.776 0.064 0.000 0.000 0.936 0.000
#> GSM78547     4  0.0451      0.798 0.004 0.008 0.000 0.988 0.000
#> GSM78552     3  0.1557      0.871 0.052 0.008 0.940 0.000 0.000
#> GSM78556     4  0.0451      0.798 0.008 0.004 0.000 0.988 0.000
#> GSM78559     4  0.3003      0.668 0.188 0.000 0.000 0.812 0.000
#> GSM78564     1  0.4510      0.292 0.560 0.008 0.000 0.432 0.000
#> GSM42999     5  0.0000      0.913 0.000 0.000 0.000 0.000 1.000
#> GSM43001     5  0.0000      0.913 0.000 0.000 0.000 0.000 1.000
#> GSM43003     2  0.5433      0.560 0.060 0.676 0.028 0.000 0.236
#> GSM43006     5  0.0000      0.913 0.000 0.000 0.000 0.000 1.000
#> GSM43009     2  0.3650      0.819 0.000 0.796 0.176 0.000 0.028
#> GSM43012     5  0.3003      0.768 0.000 0.188 0.000 0.000 0.812
#> GSM78524     4  0.5816      0.366 0.132 0.280 0.000 0.588 0.000
#> GSM78527     5  0.3242      0.727 0.000 0.216 0.000 0.000 0.784
#> GSM78530     2  0.3283      0.838 0.028 0.832 0.140 0.000 0.000
#> GSM78535     4  0.4511      0.319 0.356 0.016 0.000 0.628 0.000
#> GSM78538     2  0.3128      0.740 0.004 0.824 0.004 0.168 0.000
#> GSM78542     2  0.2624      0.797 0.000 0.872 0.012 0.116 0.000
#> GSM78544     2  0.2439      0.852 0.004 0.876 0.120 0.000 0.000
#> GSM78549     2  0.3073      0.846 0.004 0.868 0.076 0.000 0.052
#> GSM78553     2  0.2843      0.851 0.000 0.876 0.076 0.048 0.000
#> GSM78558     2  0.2707      0.857 0.024 0.888 0.080 0.008 0.000
#> GSM78561     5  0.0510      0.909 0.000 0.016 0.000 0.000 0.984

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4 p5    p6
#> GSM78539     1  0.8752    -0.0202 0.268 0.124 0.220 0.144 NA 0.000
#> GSM78545     3  0.4131     0.6361 0.004 0.072 0.744 0.000 NA 0.000
#> GSM78550     3  0.7462     0.2825 0.000 0.156 0.360 0.200 NA 0.000
#> GSM78554     3  0.8227     0.1166 0.048 0.136 0.308 0.232 NA 0.000
#> GSM78562     4  0.1692     0.7322 0.012 0.008 0.000 0.932 NA 0.000
#> GSM78540     4  0.4146     0.6403 0.028 0.024 0.004 0.752 NA 0.000
#> GSM78546     3  0.7012     0.4008 0.192 0.088 0.464 0.004 NA 0.000
#> GSM78551     4  0.6945     0.1309 0.000 0.104 0.156 0.448 NA 0.000
#> GSM78555     4  0.4111     0.5780 0.244 0.012 0.000 0.716 NA 0.000
#> GSM78563     4  0.4478     0.6535 0.040 0.040 0.004 0.744 NA 0.000
#> GSM43005     3  0.3260     0.6692 0.000 0.072 0.832 0.004 NA 0.000
#> GSM43008     3  0.5060     0.5644 0.168 0.056 0.700 0.000 NA 0.000
#> GSM43011     3  0.3110     0.5944 0.000 0.012 0.792 0.000 NA 0.000
#> GSM78523     3  0.3240     0.5604 0.000 0.004 0.752 0.000 NA 0.000
#> GSM78526     3  0.7364     0.1279 0.000 0.112 0.336 0.304 NA 0.000
#> GSM78529     6  0.1327     0.8418 0.000 0.000 0.064 0.000 NA 0.936
#> GSM78532     4  0.1116     0.7339 0.008 0.004 0.000 0.960 NA 0.000
#> GSM78534     4  0.3840     0.6541 0.020 0.052 0.000 0.792 NA 0.000
#> GSM78537     4  0.2402     0.7226 0.060 0.012 0.000 0.896 NA 0.000
#> GSM78543     1  0.2510     0.5939 0.884 0.008 0.000 0.080 NA 0.000
#> GSM78548     3  0.5967     0.5479 0.000 0.124 0.584 0.052 NA 0.000
#> GSM78557     1  0.4010     0.5735 0.780 0.016 0.004 0.148 NA 0.000
#> GSM78560     1  0.2517     0.5399 0.888 0.016 0.008 0.008 NA 0.000
#> GSM78565     1  0.4387     0.1923 0.572 0.004 0.000 0.404 NA 0.000
#> GSM43000     3  0.3046     0.5993 0.000 0.012 0.800 0.000 NA 0.000
#> GSM43002     3  0.0458     0.6640 0.000 0.000 0.984 0.000 NA 0.000
#> GSM43004     4  0.2741     0.7005 0.032 0.008 0.000 0.868 NA 0.000
#> GSM43007     3  0.4868     0.6158 0.124 0.028 0.712 0.000 NA 0.000
#> GSM43010     4  0.5253     0.5601 0.000 0.076 0.068 0.684 NA 0.000
#> GSM78522     1  0.5592     0.2641 0.516 0.000 0.136 0.004 NA 0.000
#> GSM78525     3  0.2624     0.6462 0.000 0.020 0.856 0.000 NA 0.000
#> GSM78528     3  0.2795     0.6684 0.000 0.044 0.856 0.000 NA 0.000
#> GSM78531     4  0.0405     0.7325 0.000 0.004 0.000 0.988 NA 0.000
#> GSM78533     4  0.6165     0.4764 0.004 0.088 0.188 0.604 NA 0.000
#> GSM78536     4  0.2920     0.6680 0.168 0.004 0.000 0.820 NA 0.000
#> GSM78541     4  0.1812     0.7179 0.080 0.000 0.000 0.912 NA 0.000
#> GSM78547     4  0.2230     0.7199 0.000 0.024 0.000 0.892 NA 0.000
#> GSM78552     3  0.2866     0.6496 0.084 0.004 0.860 0.000 NA 0.000
#> GSM78556     4  0.3308     0.7067 0.064 0.012 0.000 0.836 NA 0.000
#> GSM78559     4  0.3359     0.6392 0.196 0.012 0.000 0.784 NA 0.000
#> GSM78564     1  0.4189     0.1533 0.552 0.008 0.000 0.436 NA 0.000
#> GSM42999     6  0.0000     0.8799 0.000 0.000 0.000 0.000 NA 1.000
#> GSM43001     6  0.0000     0.8799 0.000 0.000 0.000 0.000 NA 1.000
#> GSM43003     2  0.4538     0.6788 0.048 0.740 0.004 0.000 NA 0.172
#> GSM43006     6  0.0000     0.8799 0.000 0.000 0.000 0.000 NA 1.000
#> GSM43009     2  0.2865     0.8234 0.000 0.840 0.140 0.000 NA 0.012
#> GSM43012     6  0.3109     0.7046 0.000 0.224 0.000 0.000 NA 0.772
#> GSM78524     4  0.6775     0.3082 0.148 0.128 0.000 0.516 NA 0.000
#> GSM78527     6  0.3489     0.5954 0.000 0.288 0.000 0.000 NA 0.708
#> GSM78530     2  0.2375     0.8772 0.008 0.896 0.060 0.000 NA 0.000
#> GSM78535     4  0.4029     0.5064 0.288 0.012 0.000 0.688 NA 0.000
#> GSM78538     2  0.2727     0.8293 0.004 0.876 0.004 0.068 NA 0.000
#> GSM78542     2  0.1708     0.8738 0.004 0.932 0.000 0.024 NA 0.000
#> GSM78544     2  0.1480     0.8948 0.000 0.940 0.040 0.000 NA 0.000
#> GSM78549     2  0.1679     0.8938 0.000 0.936 0.036 0.000 NA 0.012
#> GSM78553     2  0.1542     0.8862 0.000 0.944 0.016 0.016 NA 0.000
#> GSM78558     2  0.1078     0.8941 0.012 0.964 0.016 0.000 NA 0.000
#> GSM78561     6  0.0820     0.8731 0.000 0.012 0.000 0.000 NA 0.972

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 cell.type(p) agent(p) individual(p) k
#> ATC:NMF 56     3.35e-04  0.51056        0.1086 2
#> ATC:NMF 51     6.23e-04  0.15262        0.0664 3
#> ATC:NMF 49     2.76e-05  0.27571        0.4019 4
#> ATC:NMF 51     1.81e-08  0.01808        0.6727 5
#> ATC:NMF 47     1.10e-06  0.00664        0.5833 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