cola Report for recount2:SRP028594

Date: 2019-12-25 23:48:32 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 16816 rows and 54 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)

Dimension of the input matrix:

mat = get_matrix(res_list)
dim(mat)
#> [1] 16816    54

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, 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
ATC:kmeans 2 1.000 0.955 0.981 **
ATC:skmeans 3 1.000 0.989 0.994 ** 2
MAD:pam 5 0.999 0.962 0.984 ** 2,4
MAD:NMF 2 0.994 0.944 0.977 **
CV:pam 4 0.954 0.933 0.977 **
SD:skmeans 4 0.948 0.869 0.947 *
CV:skmeans 4 0.947 0.905 0.961 * 2
ATC:NMF 3 0.947 0.922 0.970 * 2
CV:NMF 4 0.926 0.894 0.956 *
ATC:mclust 2 0.923 0.910 0.944 *
SD:pam 5 0.904 0.816 0.931 * 4
CV:mclust 2 0.885 0.954 0.969
SD:NMF 4 0.870 0.840 0.930
ATC:pam 5 0.824 0.798 0.916
SD:mclust 4 0.820 0.756 0.902
ATC:hclust 4 0.774 0.914 0.947
SD:hclust 5 0.727 0.759 0.847
SD:kmeans 5 0.701 0.715 0.804
MAD:skmeans 2 0.698 0.871 0.941
MAD:hclust 5 0.606 0.615 0.758
MAD:kmeans 5 0.594 0.627 0.727
CV:kmeans 4 0.581 0.803 0.810
CV:hclust 3 0.560 0.775 0.814
MAD:mclust 2 0.354 0.766 0.860

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

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

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

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

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

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

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

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

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

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

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

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

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

Membership heatmap

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

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

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

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

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

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

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

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

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

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

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

Signature heatmap

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

Note in following heatmaps, rows are scaled.

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

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

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

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

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

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

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

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

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

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

Statistics table

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

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 0.854           0.921       0.966          0.434 0.560   0.560
#> CV:NMF      2 0.812           0.869       0.948          0.481 0.516   0.516
#> MAD:NMF     2 0.994           0.944       0.977          0.427 0.575   0.575
#> ATC:NMF     2 1.000           0.969       0.988          0.371 0.628   0.628
#> SD:skmeans  2 0.726           0.833       0.935          0.484 0.502   0.502
#> CV:skmeans  2 1.000           0.987       0.994          0.506 0.493   0.493
#> MAD:skmeans 2 0.698           0.871       0.941          0.481 0.547   0.547
#> ATC:skmeans 2 1.000           0.963       0.986          0.497 0.508   0.508
#> SD:mclust   2 0.448           0.689       0.863          0.474 0.508   0.508
#> CV:mclust   2 0.885           0.954       0.969          0.507 0.493   0.493
#> MAD:mclust  2 0.354           0.766       0.860          0.434 0.547   0.547
#> ATC:mclust  2 0.923           0.910       0.944          0.298 0.693   0.693
#> SD:kmeans   2 0.693           0.896       0.940          0.401 0.609   0.609
#> CV:kmeans   2 0.341           0.685       0.811          0.394 0.591   0.591
#> MAD:kmeans  2 0.666           0.877       0.932          0.431 0.575   0.575
#> ATC:kmeans  2 1.000           0.955       0.981          0.466 0.535   0.535
#> SD:pam      2 0.885           0.885       0.921          0.389 0.575   0.575
#> CV:pam      2 0.456           0.912       0.852          0.432 0.547   0.547
#> MAD:pam     2 0.923           0.928       0.971          0.433 0.575   0.575
#> ATC:pam     2 0.779           0.826       0.937          0.363 0.628   0.628
#> SD:hclust   2 0.545           0.756       0.903          0.353 0.717   0.717
#> CV:hclust   2 0.858           0.954       0.980          0.262 0.743   0.743
#> MAD:hclust  2 0.592           0.781       0.909          0.355 0.628   0.628
#> ATC:hclust  2 0.621           0.877       0.942          0.428 0.547   0.547
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.587           0.670       0.847          0.521 0.739   0.547
#> CV:NMF      3 0.706           0.821       0.906          0.387 0.676   0.442
#> MAD:NMF     3 0.641           0.810       0.903          0.564 0.679   0.475
#> ATC:NMF     3 0.947           0.922       0.970          0.765 0.690   0.515
#> SD:skmeans  3 0.754           0.809       0.892          0.385 0.704   0.471
#> CV:skmeans  3 0.849           0.835       0.929          0.329 0.792   0.598
#> MAD:skmeans 3 0.710           0.693       0.885          0.398 0.751   0.554
#> ATC:skmeans 3 1.000           0.989       0.994          0.311 0.815   0.644
#> SD:mclust   3 0.430           0.682       0.827          0.320 0.765   0.570
#> CV:mclust   3 0.470           0.680       0.855          0.288 0.734   0.512
#> MAD:mclust  3 0.394           0.548       0.758          0.406 0.682   0.470
#> ATC:mclust  3 0.780           0.811       0.906          1.058 0.499   0.360
#> SD:kmeans   3 0.478           0.595       0.782          0.527 0.760   0.632
#> CV:kmeans   3 0.346           0.555       0.693          0.500 0.678   0.499
#> MAD:kmeans  3 0.459           0.547       0.773          0.461 0.735   0.568
#> ATC:kmeans  3 0.561           0.717       0.825          0.377 0.776   0.600
#> SD:pam      3 0.802           0.888       0.944          0.661 0.759   0.581
#> CV:pam      3 0.752           0.767       0.874          0.288 0.942   0.894
#> MAD:pam     3 0.827           0.902       0.951          0.533 0.732   0.544
#> ATC:pam     3 0.456           0.523       0.753          0.750 0.686   0.507
#> SD:hclust   3 0.387           0.516       0.762          0.491 0.697   0.604
#> CV:hclust   3 0.560           0.775       0.814          1.122 0.655   0.536
#> MAD:hclust  3 0.355           0.580       0.801          0.585 0.677   0.524
#> ATC:hclust  3 0.614           0.663       0.847          0.295 0.843   0.722
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.870           0.840       0.930         0.1335 0.770   0.438
#> CV:NMF      4 0.926           0.894       0.956         0.1349 0.853   0.587
#> MAD:NMF     4 0.712           0.749       0.885         0.1281 0.787   0.457
#> ATC:NMF     4 0.809           0.844       0.926         0.1294 0.846   0.590
#> SD:skmeans  4 0.948           0.869       0.947         0.1260 0.887   0.667
#> CV:skmeans  4 0.947           0.905       0.961         0.1232 0.882   0.661
#> MAD:skmeans 4 0.857           0.851       0.928         0.1206 0.880   0.649
#> ATC:skmeans 4 0.856           0.874       0.928         0.1185 0.912   0.751
#> SD:mclust   4 0.820           0.756       0.902         0.1282 0.820   0.571
#> CV:mclust   4 0.691           0.717       0.848         0.0884 0.923   0.787
#> MAD:mclust  4 0.580           0.679       0.825         0.1760 0.860   0.619
#> ATC:mclust  4 0.623           0.705       0.805         0.1325 0.895   0.731
#> SD:kmeans   4 0.500           0.658       0.766         0.1756 0.790   0.553
#> CV:kmeans   4 0.581           0.803       0.810         0.1881 0.826   0.559
#> MAD:kmeans  4 0.536           0.582       0.729         0.1585 0.834   0.585
#> ATC:kmeans  4 0.686           0.792       0.857         0.1260 0.899   0.729
#> SD:pam      4 0.938           0.912       0.964         0.1124 0.908   0.738
#> CV:pam      4 0.954           0.933       0.977         0.2273 0.816   0.626
#> MAD:pam     4 0.902           0.933       0.971         0.1008 0.870   0.644
#> ATC:pam     4 0.766           0.848       0.873         0.0755 0.695   0.385
#> SD:hclust   4 0.454           0.498       0.675         0.2817 0.700   0.458
#> CV:hclust   4 0.539           0.651       0.775         0.1090 0.980   0.951
#> MAD:hclust  4 0.397           0.443       0.664         0.2328 0.736   0.451
#> ATC:hclust  4 0.774           0.914       0.947         0.2397 0.841   0.643
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.770           0.601       0.821         0.0561 0.985   0.941
#> CV:NMF      5 0.847           0.767       0.870         0.0438 0.931   0.734
#> MAD:NMF     5 0.689           0.570       0.774         0.0550 0.984   0.935
#> ATC:NMF     5 0.715           0.584       0.804         0.0712 0.924   0.722
#> SD:skmeans  5 0.844           0.805       0.878         0.0481 0.973   0.892
#> CV:skmeans  5 0.842           0.782       0.867         0.0513 0.908   0.668
#> MAD:skmeans 5 0.785           0.710       0.826         0.0550 0.958   0.831
#> ATC:skmeans 5 0.843           0.889       0.883         0.0948 0.877   0.577
#> SD:mclust   5 0.761           0.715       0.820         0.1147 0.892   0.656
#> CV:mclust   5 0.820           0.844       0.921         0.0941 0.843   0.543
#> MAD:mclust  5 0.614           0.560       0.731         0.0833 0.867   0.571
#> ATC:mclust  5 0.744           0.667       0.840         0.1148 0.814   0.467
#> SD:kmeans   5 0.701           0.715       0.804         0.0861 0.911   0.686
#> CV:kmeans   5 0.801           0.748       0.808         0.0980 0.964   0.857
#> MAD:kmeans  5 0.594           0.627       0.727         0.0779 0.943   0.778
#> ATC:kmeans  5 0.729           0.746       0.798         0.0855 0.887   0.612
#> SD:pam      5 0.904           0.816       0.931         0.0844 0.900   0.664
#> CV:pam      5 0.762           0.763       0.759         0.1052 0.900   0.676
#> MAD:pam     5 0.999           0.962       0.984         0.0666 0.934   0.764
#> ATC:pam     5 0.824           0.798       0.916         0.1509 0.817   0.510
#> SD:hclust   5 0.727           0.759       0.847         0.1611 0.829   0.497
#> CV:hclust   5 0.590           0.820       0.786         0.1159 0.869   0.655
#> MAD:hclust  5 0.606           0.615       0.758         0.1041 0.836   0.509
#> ATC:hclust  5 0.897           0.898       0.929         0.0316 0.994   0.982
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.775           0.660       0.803         0.0414 0.899   0.608
#> CV:NMF      6 0.860           0.779       0.876         0.0365 0.932   0.703
#> MAD:NMF     6 0.737           0.602       0.750         0.0400 0.879   0.537
#> ATC:NMF     6 0.664           0.618       0.789         0.0485 0.843   0.411
#> SD:skmeans  6 0.823           0.743       0.856         0.0376 0.966   0.850
#> CV:skmeans  6 0.833           0.767       0.837         0.0393 0.954   0.788
#> MAD:skmeans 6 0.759           0.673       0.800         0.0369 0.996   0.980
#> ATC:skmeans 6 0.847           0.790       0.861         0.0363 0.977   0.881
#> SD:mclust   6 0.729           0.719       0.780         0.0403 0.941   0.735
#> CV:mclust   6 0.878           0.837       0.890         0.0393 0.975   0.882
#> MAD:mclust  6 0.593           0.533       0.677         0.0349 0.930   0.714
#> ATC:mclust  6 0.876           0.841       0.929         0.0532 0.939   0.731
#> SD:kmeans   6 0.737           0.646       0.751         0.0437 0.979   0.902
#> CV:kmeans   6 0.781           0.641       0.792         0.0440 0.981   0.914
#> MAD:kmeans  6 0.716           0.536       0.712         0.0435 0.983   0.919
#> ATC:kmeans  6 0.729           0.745       0.799         0.0457 0.970   0.847
#> SD:pam      6 0.859           0.782       0.895         0.0484 0.945   0.755
#> CV:pam      6 0.758           0.512       0.764         0.0564 0.864   0.492
#> MAD:pam     6 0.885           0.831       0.893         0.0451 0.956   0.801
#> ATC:pam     6 0.859           0.793       0.911         0.0214 0.958   0.814
#> SD:hclust   6 0.769           0.755       0.834         0.0316 0.987   0.941
#> CV:hclust   6 0.896           0.899       0.945         0.1317 0.964   0.854
#> MAD:hclust  6 0.682           0.605       0.762         0.0478 0.987   0.940
#> ATC:hclust  6 0.898           0.886       0.909         0.0338 0.978   0.925

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

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

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

collect_plots(res)

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.545           0.756       0.903         0.3526 0.717   0.717
#> 3 3 0.387           0.516       0.762         0.4908 0.697   0.604
#> 4 4 0.454           0.498       0.675         0.2817 0.700   0.458
#> 5 5 0.727           0.759       0.847         0.1611 0.829   0.497
#> 6 6 0.769           0.755       0.834         0.0316 0.987   0.941

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

suggest_best_k(res)
#> [1] 5

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
#> SRR949076     1  0.0000     0.8747 1.000 0.000
#> SRR949078     2  0.9286     0.4425 0.344 0.656
#> SRR949077     1  0.0000     0.8747 1.000 0.000
#> SRR949079     1  0.0000     0.8747 1.000 0.000
#> SRR949080     1  0.0000     0.8747 1.000 0.000
#> SRR949081     1  0.0938     0.8681 0.988 0.012
#> SRR949082     2  0.9286     0.4425 0.344 0.656
#> SRR949083     1  0.0000     0.8747 1.000 0.000
#> SRR949084     1  0.0000     0.8747 1.000 0.000
#> SRR949085     2  0.0000     0.8778 0.000 1.000
#> SRR949087     1  0.8555     0.5465 0.720 0.280
#> SRR949088     1  0.8555     0.5465 0.720 0.280
#> SRR949086     1  0.7602     0.6911 0.780 0.220
#> SRR949089     2  0.0000     0.8778 0.000 1.000
#> SRR949090     1  0.0938     0.8688 0.988 0.012
#> SRR949092     1  0.0000     0.8747 1.000 0.000
#> SRR949093     1  0.0000     0.8747 1.000 0.000
#> SRR949091     1  0.7674     0.6869 0.776 0.224
#> SRR949095     1  0.8955     0.4830 0.688 0.312
#> SRR949094     1  0.0000     0.8747 1.000 0.000
#> SRR949096     1  0.0000     0.8747 1.000 0.000
#> SRR949097     1  0.0000     0.8747 1.000 0.000
#> SRR949098     2  0.0000     0.8778 0.000 1.000
#> SRR949099     1  0.0000     0.8747 1.000 0.000
#> SRR949101     1  0.7674     0.6869 0.776 0.224
#> SRR949100     1  0.8861     0.4999 0.696 0.304
#> SRR949102     1  0.0938     0.8681 0.988 0.012
#> SRR949103     1  0.0000     0.8747 1.000 0.000
#> SRR949104     2  0.0000     0.8778 0.000 1.000
#> SRR949105     1  0.7674     0.6869 0.776 0.224
#> SRR949106     1  0.7674     0.6869 0.776 0.224
#> SRR949107     1  0.7674     0.6869 0.776 0.224
#> SRR949108     1  0.0000     0.8747 1.000 0.000
#> SRR949109     1  0.0000     0.8747 1.000 0.000
#> SRR949110     1  0.0000     0.8747 1.000 0.000
#> SRR949111     1  0.0000     0.8747 1.000 0.000
#> SRR949112     1  0.0000     0.8747 1.000 0.000
#> SRR949113     2  0.4431     0.8224 0.092 0.908
#> SRR949114     1  0.0672     0.8714 0.992 0.008
#> SRR949115     1  0.0672     0.8714 0.992 0.008
#> SRR949116     1  0.0672     0.8714 0.992 0.008
#> SRR949117     1  0.7602     0.6911 0.780 0.220
#> SRR949118     1  0.7674     0.6869 0.776 0.224
#> SRR949119     1  0.0000     0.8747 1.000 0.000
#> SRR949120     1  0.0000     0.8747 1.000 0.000
#> SRR949121     1  0.0000     0.8747 1.000 0.000
#> SRR949122     1  0.0000     0.8747 1.000 0.000
#> SRR949123     2  0.1184     0.8725 0.016 0.984
#> SRR949124     2  0.0000     0.8778 0.000 1.000
#> SRR949125     1  0.0000     0.8747 1.000 0.000
#> SRR949126     1  0.0000     0.8747 1.000 0.000
#> SRR949127     1  0.9977     0.0156 0.528 0.472
#> SRR949128     1  0.9977     0.0156 0.528 0.472
#> SRR949129     1  0.9977     0.0156 0.528 0.472

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR949076     1  0.6295      0.382 0.528 0.000 0.472
#> SRR949078     1  0.6079     -0.238 0.612 0.388 0.000
#> SRR949077     1  0.6295      0.382 0.528 0.000 0.472
#> SRR949079     1  0.6305      0.383 0.516 0.000 0.484
#> SRR949080     1  0.6305      0.383 0.516 0.000 0.484
#> SRR949081     1  0.6111      0.508 0.604 0.000 0.396
#> SRR949082     1  0.6244     -0.284 0.560 0.440 0.000
#> SRR949083     1  0.5529      0.586 0.704 0.000 0.296
#> SRR949084     1  0.5529      0.586 0.704 0.000 0.296
#> SRR949085     2  0.0000      0.954 0.000 1.000 0.000
#> SRR949087     1  0.4683      0.387 0.836 0.024 0.140
#> SRR949088     1  0.4683      0.387 0.836 0.024 0.140
#> SRR949086     3  0.0237      0.796 0.004 0.000 0.996
#> SRR949089     2  0.0000      0.954 0.000 1.000 0.000
#> SRR949090     3  0.6291     -0.358 0.468 0.000 0.532
#> SRR949092     1  0.5760      0.587 0.672 0.000 0.328
#> SRR949093     1  0.5760      0.587 0.672 0.000 0.328
#> SRR949091     3  0.2796      0.688 0.092 0.000 0.908
#> SRR949095     1  0.0892      0.409 0.980 0.020 0.000
#> SRR949094     1  0.6305      0.383 0.516 0.000 0.484
#> SRR949096     1  0.5529      0.586 0.704 0.000 0.296
#> SRR949097     1  0.6180      0.555 0.584 0.000 0.416
#> SRR949098     2  0.0000      0.954 0.000 1.000 0.000
#> SRR949099     3  0.6302     -0.491 0.480 0.000 0.520
#> SRR949101     3  0.0000      0.798 0.000 0.000 1.000
#> SRR949100     1  0.3832      0.388 0.880 0.020 0.100
#> SRR949102     1  0.6126      0.508 0.600 0.000 0.400
#> SRR949103     1  0.6180      0.555 0.584 0.000 0.416
#> SRR949104     2  0.0000      0.954 0.000 1.000 0.000
#> SRR949105     3  0.0000      0.798 0.000 0.000 1.000
#> SRR949106     3  0.0000      0.798 0.000 0.000 1.000
#> SRR949107     3  0.0000      0.798 0.000 0.000 1.000
#> SRR949108     1  0.6180      0.555 0.584 0.000 0.416
#> SRR949109     1  0.6305      0.383 0.516 0.000 0.484
#> SRR949110     1  0.6180      0.555 0.584 0.000 0.416
#> SRR949111     1  0.6305      0.383 0.516 0.000 0.484
#> SRR949112     1  0.6180      0.555 0.584 0.000 0.416
#> SRR949113     2  0.3038      0.871 0.104 0.896 0.000
#> SRR949114     1  0.6244      0.526 0.560 0.000 0.440
#> SRR949115     1  0.6244      0.526 0.560 0.000 0.440
#> SRR949116     1  0.6244      0.526 0.560 0.000 0.440
#> SRR949117     3  0.0237      0.796 0.004 0.000 0.996
#> SRR949118     3  0.0000      0.798 0.000 0.000 1.000
#> SRR949119     1  0.5926      0.582 0.644 0.000 0.356
#> SRR949120     1  0.5926      0.582 0.644 0.000 0.356
#> SRR949121     1  0.6180      0.555 0.584 0.000 0.416
#> SRR949122     1  0.6180      0.555 0.584 0.000 0.416
#> SRR949123     2  0.5219      0.839 0.196 0.788 0.016
#> SRR949124     2  0.0000      0.954 0.000 1.000 0.000
#> SRR949125     1  0.6305      0.383 0.516 0.000 0.484
#> SRR949126     1  0.6305      0.383 0.516 0.000 0.484
#> SRR949127     1  0.4605      0.303 0.796 0.204 0.000
#> SRR949128     1  0.4605      0.303 0.796 0.204 0.000
#> SRR949129     1  0.4605      0.303 0.796 0.204 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR949076     4  0.0707     0.5518 0.020 0.000 0.000 0.980
#> SRR949078     1  0.4746    -0.1026 0.632 0.368 0.000 0.000
#> SRR949077     4  0.0707     0.5518 0.020 0.000 0.000 0.980
#> SRR949079     4  0.3688     0.6701 0.208 0.000 0.000 0.792
#> SRR949080     4  0.3688     0.6701 0.208 0.000 0.000 0.792
#> SRR949081     3  0.7908     0.0658 0.336 0.000 0.360 0.304
#> SRR949082     1  0.4907    -0.1651 0.580 0.420 0.000 0.000
#> SRR949083     4  0.6621    -0.1844 0.408 0.000 0.084 0.508
#> SRR949084     4  0.6621    -0.1844 0.408 0.000 0.084 0.508
#> SRR949085     2  0.0000     0.9438 0.000 1.000 0.000 0.000
#> SRR949087     1  0.3060     0.3825 0.888 0.008 0.088 0.016
#> SRR949088     1  0.3060     0.3825 0.888 0.008 0.088 0.016
#> SRR949086     3  0.0707     0.8137 0.020 0.000 0.980 0.000
#> SRR949089     2  0.0000     0.9438 0.000 1.000 0.000 0.000
#> SRR949090     4  0.4881     0.6397 0.196 0.000 0.048 0.756
#> SRR949092     1  0.6500     0.3959 0.580 0.000 0.092 0.328
#> SRR949093     1  0.6500     0.3959 0.580 0.000 0.092 0.328
#> SRR949091     4  0.4948     0.1367 0.000 0.000 0.440 0.560
#> SRR949095     1  0.4040     0.2418 0.752 0.000 0.000 0.248
#> SRR949094     4  0.3688     0.6701 0.208 0.000 0.000 0.792
#> SRR949096     4  0.6621    -0.1844 0.408 0.000 0.084 0.508
#> SRR949097     1  0.6993     0.4680 0.556 0.000 0.148 0.296
#> SRR949098     2  0.0000     0.9438 0.000 1.000 0.000 0.000
#> SRR949099     1  0.7003     0.2783 0.460 0.000 0.424 0.116
#> SRR949101     3  0.0000     0.8191 0.000 0.000 1.000 0.000
#> SRR949100     1  0.1798     0.3888 0.944 0.000 0.040 0.016
#> SRR949102     3  0.7913     0.0611 0.324 0.000 0.360 0.316
#> SRR949103     1  0.6993     0.4680 0.556 0.000 0.148 0.296
#> SRR949104     2  0.0000     0.9438 0.000 1.000 0.000 0.000
#> SRR949105     3  0.0000     0.8191 0.000 0.000 1.000 0.000
#> SRR949106     3  0.0000     0.8191 0.000 0.000 1.000 0.000
#> SRR949107     3  0.0000     0.8191 0.000 0.000 1.000 0.000
#> SRR949108     1  0.7028     0.4664 0.548 0.000 0.148 0.304
#> SRR949109     4  0.3688     0.6701 0.208 0.000 0.000 0.792
#> SRR949110     1  0.6993     0.4680 0.556 0.000 0.148 0.296
#> SRR949111     4  0.3688     0.6701 0.208 0.000 0.000 0.792
#> SRR949112     1  0.7028     0.4664 0.548 0.000 0.148 0.304
#> SRR949113     2  0.2530     0.8565 0.112 0.888 0.000 0.000
#> SRR949114     1  0.7170     0.4587 0.540 0.000 0.172 0.288
#> SRR949115     1  0.7170     0.4587 0.540 0.000 0.172 0.288
#> SRR949116     1  0.7170     0.4587 0.540 0.000 0.172 0.288
#> SRR949117     3  0.0707     0.8137 0.020 0.000 0.980 0.000
#> SRR949118     3  0.0188     0.8186 0.004 0.000 0.996 0.000
#> SRR949119     1  0.6903     0.3907 0.508 0.000 0.112 0.380
#> SRR949120     1  0.6903     0.3907 0.508 0.000 0.112 0.380
#> SRR949121     1  0.7028     0.4664 0.548 0.000 0.148 0.304
#> SRR949122     1  0.7028     0.4664 0.548 0.000 0.148 0.304
#> SRR949123     2  0.4253     0.7894 0.208 0.776 0.000 0.016
#> SRR949124     2  0.0000     0.9438 0.000 1.000 0.000 0.000
#> SRR949125     4  0.3688     0.6701 0.208 0.000 0.000 0.792
#> SRR949126     4  0.3688     0.6701 0.208 0.000 0.000 0.792
#> SRR949127     1  0.3444     0.3450 0.816 0.184 0.000 0.000
#> SRR949128     1  0.3444     0.3450 0.816 0.184 0.000 0.000
#> SRR949129     1  0.3444     0.3450 0.816 0.184 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
#> SRR949076     4  0.3203      0.769 0.012 0.000 0.000 0.820 0.168
#> SRR949078     5  0.4551      0.390 0.016 0.368 0.000 0.000 0.616
#> SRR949077     4  0.3203      0.769 0.012 0.000 0.000 0.820 0.168
#> SRR949079     4  0.0963      0.907 0.036 0.000 0.000 0.964 0.000
#> SRR949080     4  0.0963      0.907 0.036 0.000 0.000 0.964 0.000
#> SRR949081     5  0.6462      0.191 0.124 0.000 0.304 0.024 0.548
#> SRR949082     5  0.4682      0.306 0.016 0.420 0.000 0.000 0.564
#> SRR949083     1  0.4313      0.581 0.636 0.000 0.000 0.008 0.356
#> SRR949084     1  0.4313      0.581 0.636 0.000 0.000 0.008 0.356
#> SRR949085     2  0.0000      0.931 0.000 1.000 0.000 0.000 0.000
#> SRR949087     5  0.4916      0.653 0.268 0.008 0.044 0.000 0.680
#> SRR949088     5  0.4916      0.653 0.268 0.008 0.044 0.000 0.680
#> SRR949086     3  0.1862      0.949 0.016 0.000 0.932 0.004 0.048
#> SRR949089     2  0.0000      0.931 0.000 1.000 0.000 0.000 0.000
#> SRR949090     4  0.2149      0.878 0.036 0.000 0.048 0.916 0.000
#> SRR949092     1  0.3622      0.782 0.816 0.000 0.000 0.048 0.136
#> SRR949093     1  0.3622      0.782 0.816 0.000 0.000 0.048 0.136
#> SRR949091     4  0.4410      0.286 0.004 0.000 0.440 0.556 0.000
#> SRR949095     5  0.1956      0.563 0.076 0.000 0.000 0.008 0.916
#> SRR949094     4  0.0963      0.907 0.036 0.000 0.000 0.964 0.000
#> SRR949096     1  0.4313      0.581 0.636 0.000 0.000 0.008 0.356
#> SRR949097     1  0.0510      0.820 0.984 0.000 0.000 0.000 0.016
#> SRR949098     2  0.0000      0.931 0.000 1.000 0.000 0.000 0.000
#> SRR949099     1  0.5333      0.294 0.628 0.000 0.300 0.004 0.068
#> SRR949101     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR949100     5  0.3949      0.630 0.300 0.000 0.004 0.000 0.696
#> SRR949102     5  0.6744      0.176 0.124 0.000 0.304 0.040 0.532
#> SRR949103     1  0.0510      0.820 0.984 0.000 0.000 0.000 0.016
#> SRR949104     2  0.0000      0.931 0.000 1.000 0.000 0.000 0.000
#> SRR949105     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR949106     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR949107     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR949108     1  0.1197      0.840 0.952 0.000 0.000 0.048 0.000
#> SRR949109     4  0.0963      0.907 0.036 0.000 0.000 0.964 0.000
#> SRR949110     1  0.0324      0.827 0.992 0.000 0.000 0.004 0.004
#> SRR949111     4  0.0963      0.907 0.036 0.000 0.000 0.964 0.000
#> SRR949112     1  0.1197      0.840 0.952 0.000 0.000 0.048 0.000
#> SRR949113     2  0.2179      0.813 0.000 0.888 0.000 0.000 0.112
#> SRR949114     1  0.1893      0.835 0.928 0.000 0.024 0.048 0.000
#> SRR949115     1  0.1893      0.835 0.928 0.000 0.024 0.048 0.000
#> SRR949116     1  0.1893      0.835 0.928 0.000 0.024 0.048 0.000
#> SRR949117     3  0.1862      0.949 0.016 0.000 0.932 0.004 0.048
#> SRR949118     3  0.1430      0.954 0.000 0.000 0.944 0.004 0.052
#> SRR949119     1  0.3226      0.806 0.852 0.000 0.000 0.060 0.088
#> SRR949120     1  0.3226      0.806 0.852 0.000 0.000 0.060 0.088
#> SRR949121     1  0.1197      0.840 0.952 0.000 0.000 0.048 0.000
#> SRR949122     1  0.1197      0.840 0.952 0.000 0.000 0.048 0.000
#> SRR949123     2  0.3305      0.699 0.000 0.776 0.000 0.000 0.224
#> SRR949124     2  0.0000      0.931 0.000 1.000 0.000 0.000 0.000
#> SRR949125     4  0.0963      0.907 0.036 0.000 0.000 0.964 0.000
#> SRR949126     4  0.0963      0.907 0.036 0.000 0.000 0.964 0.000
#> SRR949127     5  0.5673      0.640 0.184 0.184 0.000 0.000 0.632
#> SRR949128     5  0.5673      0.640 0.184 0.184 0.000 0.000 0.632
#> SRR949129     5  0.5673      0.640 0.184 0.184 0.000 0.000 0.632

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR949076     4   0.304      0.744 0.008 0.000 0.000 0.792 0.000 0.200
#> SRR949078     5   0.365      0.495 0.000 0.360 0.000 0.000 0.640 0.000
#> SRR949077     4   0.304      0.744 0.008 0.000 0.000 0.792 0.000 0.200
#> SRR949079     4   0.026      0.899 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR949080     4   0.026      0.899 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR949081     6   0.301      0.974 0.028 0.000 0.044 0.000 0.064 0.864
#> SRR949082     5   0.378      0.408 0.000 0.412 0.000 0.000 0.588 0.000
#> SRR949083     1   0.495      0.589 0.656 0.000 0.000 0.008 0.236 0.100
#> SRR949084     1   0.495      0.589 0.656 0.000 0.000 0.008 0.236 0.100
#> SRR949085     2   0.026      0.928 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR949087     5   0.485      0.623 0.188 0.000 0.000 0.000 0.664 0.148
#> SRR949088     5   0.485      0.623 0.188 0.000 0.000 0.000 0.664 0.148
#> SRR949086     3   0.385      0.648 0.012 0.000 0.664 0.000 0.000 0.324
#> SRR949089     2   0.000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949090     4   0.133      0.865 0.008 0.000 0.048 0.944 0.000 0.000
#> SRR949092     1   0.400      0.787 0.800 0.000 0.000 0.048 0.076 0.076
#> SRR949093     1   0.400      0.787 0.800 0.000 0.000 0.048 0.076 0.076
#> SRR949091     4   0.383      0.234 0.000 0.000 0.440 0.560 0.000 0.000
#> SRR949095     5   0.346      0.360 0.048 0.000 0.000 0.008 0.812 0.132
#> SRR949094     4   0.026      0.899 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR949096     1   0.495      0.589 0.656 0.000 0.000 0.008 0.236 0.100
#> SRR949097     1   0.141      0.816 0.936 0.000 0.000 0.000 0.060 0.004
#> SRR949098     2   0.000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949099     1   0.564      0.186 0.564 0.000 0.052 0.000 0.060 0.324
#> SRR949101     3   0.000      0.795 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949100     5   0.418      0.639 0.212 0.000 0.000 0.000 0.720 0.068
#> SRR949102     6   0.297      0.974 0.028 0.000 0.044 0.004 0.052 0.872
#> SRR949103     1   0.141      0.816 0.936 0.000 0.000 0.000 0.060 0.004
#> SRR949104     2   0.000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949105     3   0.000      0.795 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949106     3   0.000      0.795 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949107     3   0.000      0.795 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949108     1   0.133      0.836 0.944 0.000 0.000 0.048 0.000 0.008
#> SRR949109     4   0.026      0.899 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR949110     1   0.122      0.824 0.948 0.000 0.000 0.004 0.048 0.000
#> SRR949111     4   0.026      0.899 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR949112     1   0.107      0.836 0.952 0.000 0.000 0.048 0.000 0.000
#> SRR949113     2   0.196      0.828 0.000 0.888 0.000 0.000 0.112 0.000
#> SRR949114     1   0.176      0.832 0.928 0.000 0.020 0.048 0.000 0.004
#> SRR949115     1   0.176      0.832 0.928 0.000 0.020 0.048 0.000 0.004
#> SRR949116     1   0.176      0.832 0.928 0.000 0.020 0.048 0.000 0.004
#> SRR949117     3   0.385      0.648 0.012 0.000 0.664 0.000 0.000 0.324
#> SRR949118     3   0.355      0.646 0.000 0.000 0.668 0.000 0.000 0.332
#> SRR949119     1   0.352      0.734 0.776 0.000 0.000 0.036 0.000 0.188
#> SRR949120     1   0.352      0.734 0.776 0.000 0.000 0.036 0.000 0.188
#> SRR949121     1   0.107      0.836 0.952 0.000 0.000 0.048 0.000 0.000
#> SRR949122     1   0.107      0.836 0.952 0.000 0.000 0.048 0.000 0.000
#> SRR949123     2   0.359      0.693 0.000 0.776 0.000 0.000 0.180 0.044
#> SRR949124     2   0.000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949125     4   0.026      0.899 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR949126     4   0.026      0.899 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR949127     5   0.454      0.739 0.124 0.176 0.000 0.000 0.700 0.000
#> SRR949128     5   0.454      0.739 0.124 0.176 0.000 0.000 0.700 0.000
#> SRR949129     5   0.454      0.739 0.124 0.176 0.000 0.000 0.700 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

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

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

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.693           0.896       0.940         0.4012 0.609   0.609
#> 3 3 0.478           0.595       0.782         0.5272 0.760   0.632
#> 4 4 0.500           0.658       0.766         0.1756 0.790   0.553
#> 5 5 0.701           0.715       0.804         0.0861 0.911   0.686
#> 6 6 0.737           0.646       0.751         0.0437 0.979   0.902

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

suggest_best_k(res)
#> [1] 5

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
#> SRR949076     1  0.0376      0.943 0.996 0.004
#> SRR949078     2  0.2423      0.953 0.040 0.960
#> SRR949077     1  0.0376      0.943 0.996 0.004
#> SRR949079     1  0.0376      0.943 0.996 0.004
#> SRR949080     1  0.0376      0.943 0.996 0.004
#> SRR949081     1  0.9850      0.235 0.572 0.428
#> SRR949082     2  0.2423      0.953 0.040 0.960
#> SRR949083     1  0.0376      0.944 0.996 0.004
#> SRR949084     1  0.0376      0.944 0.996 0.004
#> SRR949085     2  0.2423      0.953 0.040 0.960
#> SRR949087     2  0.8861      0.603 0.304 0.696
#> SRR949088     2  0.8861      0.603 0.304 0.696
#> SRR949086     1  0.5946      0.858 0.856 0.144
#> SRR949089     2  0.2423      0.953 0.040 0.960
#> SRR949090     1  0.0376      0.943 0.996 0.004
#> SRR949092     1  0.0376      0.944 0.996 0.004
#> SRR949093     1  0.0376      0.944 0.996 0.004
#> SRR949091     1  0.2236      0.924 0.964 0.036
#> SRR949095     1  0.9286      0.440 0.656 0.344
#> SRR949094     1  0.0376      0.943 0.996 0.004
#> SRR949096     1  0.0376      0.944 0.996 0.004
#> SRR949097     1  0.0376      0.944 0.996 0.004
#> SRR949098     2  0.2423      0.953 0.040 0.960
#> SRR949099     1  0.2043      0.930 0.968 0.032
#> SRR949101     1  0.4690      0.892 0.900 0.100
#> SRR949100     1  0.5059      0.859 0.888 0.112
#> SRR949102     1  0.2603      0.922 0.956 0.044
#> SRR949103     1  0.0376      0.944 0.996 0.004
#> SRR949104     2  0.2423      0.953 0.040 0.960
#> SRR949105     1  0.6712      0.823 0.824 0.176
#> SRR949106     1  0.6712      0.823 0.824 0.176
#> SRR949107     1  0.6712      0.823 0.824 0.176
#> SRR949108     1  0.0376      0.944 0.996 0.004
#> SRR949109     1  0.0376      0.943 0.996 0.004
#> SRR949110     1  0.0376      0.944 0.996 0.004
#> SRR949111     1  0.0376      0.943 0.996 0.004
#> SRR949112     1  0.0376      0.944 0.996 0.004
#> SRR949113     2  0.2423      0.953 0.040 0.960
#> SRR949114     1  0.0938      0.942 0.988 0.012
#> SRR949115     1  0.0938      0.942 0.988 0.012
#> SRR949116     1  0.0938      0.942 0.988 0.012
#> SRR949117     1  0.5946      0.858 0.856 0.144
#> SRR949118     1  0.4815      0.893 0.896 0.104
#> SRR949119     1  0.0376      0.944 0.996 0.004
#> SRR949120     1  0.0376      0.944 0.996 0.004
#> SRR949121     1  0.0376      0.944 0.996 0.004
#> SRR949122     1  0.0376      0.944 0.996 0.004
#> SRR949123     2  0.2423      0.953 0.040 0.960
#> SRR949124     2  0.2423      0.953 0.040 0.960
#> SRR949125     1  0.0376      0.943 0.996 0.004
#> SRR949126     1  0.0376      0.943 0.996 0.004
#> SRR949127     2  0.2423      0.953 0.040 0.960
#> SRR949128     2  0.2423      0.953 0.040 0.960
#> SRR949129     2  0.2423      0.953 0.040 0.960

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR949076     1  0.5926     0.4806 0.644 0.000 0.356
#> SRR949078     2  0.1878     0.9722 0.004 0.952 0.044
#> SRR949077     1  0.5926     0.4806 0.644 0.000 0.356
#> SRR949079     1  0.5926     0.4802 0.644 0.000 0.356
#> SRR949080     1  0.5926     0.4802 0.644 0.000 0.356
#> SRR949081     1  0.9026     0.0832 0.556 0.196 0.248
#> SRR949082     2  0.1878     0.9722 0.004 0.952 0.044
#> SRR949083     1  0.0661     0.6111 0.988 0.004 0.008
#> SRR949084     1  0.0661     0.6121 0.988 0.004 0.008
#> SRR949085     2  0.0000     0.9802 0.000 1.000 0.000
#> SRR949087     1  0.9649    -0.0291 0.404 0.388 0.208
#> SRR949088     1  0.9649    -0.0291 0.404 0.388 0.208
#> SRR949086     3  0.6422     0.7746 0.324 0.016 0.660
#> SRR949089     2  0.0000     0.9802 0.000 1.000 0.000
#> SRR949090     1  0.6309     0.3874 0.504 0.000 0.496
#> SRR949092     1  0.1647     0.6122 0.960 0.004 0.036
#> SRR949093     1  0.1647     0.6122 0.960 0.004 0.036
#> SRR949091     3  0.4178     0.4214 0.172 0.000 0.828
#> SRR949095     1  0.6506     0.4049 0.720 0.236 0.044
#> SRR949094     1  0.5926     0.4802 0.644 0.000 0.356
#> SRR949096     1  0.0983     0.6131 0.980 0.004 0.016
#> SRR949097     1  0.3425     0.5720 0.884 0.004 0.112
#> SRR949098     2  0.0000     0.9802 0.000 1.000 0.000
#> SRR949099     1  0.6286    -0.2407 0.536 0.000 0.464
#> SRR949101     3  0.5414     0.8054 0.212 0.016 0.772
#> SRR949100     1  0.7777     0.4274 0.676 0.164 0.160
#> SRR949102     1  0.5775     0.3757 0.728 0.012 0.260
#> SRR949103     1  0.3482     0.5587 0.872 0.000 0.128
#> SRR949104     2  0.0000     0.9802 0.000 1.000 0.000
#> SRR949105     3  0.6495     0.8252 0.200 0.060 0.740
#> SRR949106     3  0.6495     0.8252 0.200 0.060 0.740
#> SRR949107     3  0.6495     0.8252 0.200 0.060 0.740
#> SRR949108     1  0.1525     0.6129 0.964 0.004 0.032
#> SRR949109     1  0.6308     0.3939 0.508 0.000 0.492
#> SRR949110     1  0.3425     0.5720 0.884 0.004 0.112
#> SRR949111     1  0.6252     0.4370 0.556 0.000 0.444
#> SRR949112     1  0.2496     0.5971 0.928 0.004 0.068
#> SRR949113     2  0.0000     0.9802 0.000 1.000 0.000
#> SRR949114     1  0.6282     0.1737 0.664 0.012 0.324
#> SRR949115     1  0.6282     0.1737 0.664 0.012 0.324
#> SRR949116     1  0.6282     0.1737 0.664 0.012 0.324
#> SRR949117     3  0.6473     0.7617 0.332 0.016 0.652
#> SRR949118     3  0.6422     0.7746 0.324 0.016 0.660
#> SRR949119     1  0.1525     0.6138 0.964 0.004 0.032
#> SRR949120     1  0.1525     0.6138 0.964 0.004 0.032
#> SRR949121     1  0.2400     0.5988 0.932 0.004 0.064
#> SRR949122     1  0.1647     0.6122 0.960 0.004 0.036
#> SRR949123     2  0.0000     0.9802 0.000 1.000 0.000
#> SRR949124     2  0.0000     0.9802 0.000 1.000 0.000
#> SRR949125     1  0.6280     0.4181 0.540 0.000 0.460
#> SRR949126     1  0.6280     0.4181 0.540 0.000 0.460
#> SRR949127     2  0.1878     0.9722 0.004 0.952 0.044
#> SRR949128     2  0.1878     0.9722 0.004 0.952 0.044
#> SRR949129     2  0.1878     0.9722 0.004 0.952 0.044

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR949076     4  0.3801     0.8572 0.220 0.000 0.000 0.780
#> SRR949078     2  0.4300     0.8835 0.000 0.820 0.092 0.088
#> SRR949077     4  0.3801     0.8572 0.220 0.000 0.000 0.780
#> SRR949079     4  0.3801     0.8896 0.220 0.000 0.000 0.780
#> SRR949080     4  0.3801     0.8896 0.220 0.000 0.000 0.780
#> SRR949081     3  0.9440     0.0485 0.260 0.108 0.372 0.260
#> SRR949082     2  0.4300     0.8835 0.000 0.820 0.092 0.088
#> SRR949083     1  0.3048     0.6663 0.876 0.000 0.016 0.108
#> SRR949084     1  0.2730     0.6693 0.896 0.000 0.016 0.088
#> SRR949085     2  0.0336     0.9220 0.000 0.992 0.000 0.008
#> SRR949087     1  0.9698     0.0329 0.352 0.232 0.264 0.152
#> SRR949088     1  0.9698     0.0329 0.352 0.232 0.264 0.152
#> SRR949086     3  0.4874     0.6657 0.180 0.000 0.764 0.056
#> SRR949089     2  0.0336     0.9220 0.000 0.992 0.000 0.008
#> SRR949090     4  0.5785     0.8762 0.272 0.000 0.064 0.664
#> SRR949092     1  0.0188     0.7081 0.996 0.000 0.000 0.004
#> SRR949093     1  0.0188     0.7081 0.996 0.000 0.000 0.004
#> SRR949091     3  0.6557    -0.0611 0.076 0.000 0.476 0.448
#> SRR949095     1  0.8623     0.3572 0.508 0.144 0.096 0.252
#> SRR949094     4  0.3801     0.8896 0.220 0.000 0.000 0.780
#> SRR949096     1  0.2805     0.6624 0.888 0.000 0.012 0.100
#> SRR949097     1  0.1209     0.6957 0.964 0.000 0.004 0.032
#> SRR949098     2  0.0336     0.9220 0.000 0.992 0.000 0.008
#> SRR949099     1  0.6727    -0.0911 0.496 0.000 0.412 0.092
#> SRR949101     3  0.3471     0.7096 0.072 0.000 0.868 0.060
#> SRR949100     1  0.8918     0.2346 0.484 0.108 0.232 0.176
#> SRR949102     3  0.7925     0.0533 0.332 0.000 0.336 0.332
#> SRR949103     1  0.1209     0.6957 0.964 0.000 0.004 0.032
#> SRR949104     2  0.0000     0.9220 0.000 1.000 0.000 0.000
#> SRR949105     3  0.4149     0.7115 0.072 0.004 0.836 0.088
#> SRR949106     3  0.4149     0.7115 0.072 0.004 0.836 0.088
#> SRR949107     3  0.4149     0.7115 0.072 0.004 0.836 0.088
#> SRR949108     1  0.0188     0.7081 0.996 0.000 0.000 0.004
#> SRR949109     4  0.5785     0.8762 0.272 0.000 0.064 0.664
#> SRR949110     1  0.1209     0.6957 0.964 0.000 0.004 0.032
#> SRR949111     4  0.5537     0.8895 0.256 0.000 0.056 0.688
#> SRR949112     1  0.0672     0.7090 0.984 0.000 0.008 0.008
#> SRR949113     2  0.0000     0.9220 0.000 1.000 0.000 0.000
#> SRR949114     1  0.5460     0.3111 0.632 0.000 0.340 0.028
#> SRR949115     1  0.5460     0.3111 0.632 0.000 0.340 0.028
#> SRR949116     1  0.5460     0.3111 0.632 0.000 0.340 0.028
#> SRR949117     3  0.4880     0.6584 0.188 0.000 0.760 0.052
#> SRR949118     3  0.4562     0.6827 0.152 0.000 0.792 0.056
#> SRR949119     1  0.3569     0.5617 0.804 0.000 0.000 0.196
#> SRR949120     1  0.3569     0.5617 0.804 0.000 0.000 0.196
#> SRR949121     1  0.0376     0.7084 0.992 0.000 0.004 0.004
#> SRR949122     1  0.0336     0.7091 0.992 0.000 0.000 0.008
#> SRR949123     2  0.0336     0.9193 0.000 0.992 0.000 0.008
#> SRR949124     2  0.0000     0.9220 0.000 1.000 0.000 0.000
#> SRR949125     4  0.5772     0.8848 0.260 0.000 0.068 0.672
#> SRR949126     4  0.5772     0.8848 0.260 0.000 0.068 0.672
#> SRR949127     2  0.4104     0.8906 0.000 0.832 0.088 0.080
#> SRR949128     2  0.4104     0.8906 0.000 0.832 0.088 0.080
#> SRR949129     2  0.4104     0.8906 0.000 0.832 0.088 0.080

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR949076     4  0.3269     0.8360 0.056 0.000 0.000 0.848 0.096
#> SRR949078     2  0.4773     0.6956 0.000 0.656 0.008 0.024 0.312
#> SRR949077     4  0.3269     0.8360 0.056 0.000 0.000 0.848 0.096
#> SRR949079     4  0.2914     0.8716 0.076 0.000 0.000 0.872 0.052
#> SRR949080     4  0.2914     0.8716 0.076 0.000 0.000 0.872 0.052
#> SRR949081     5  0.6256     0.5568 0.080 0.024 0.140 0.068 0.688
#> SRR949082     2  0.4773     0.6956 0.000 0.656 0.008 0.024 0.312
#> SRR949083     1  0.3322     0.7604 0.848 0.000 0.004 0.044 0.104
#> SRR949084     1  0.2694     0.7853 0.888 0.000 0.004 0.032 0.076
#> SRR949085     2  0.0898     0.8152 0.000 0.972 0.008 0.020 0.000
#> SRR949087     5  0.5922     0.6385 0.176 0.088 0.060 0.000 0.676
#> SRR949088     5  0.5922     0.6385 0.176 0.088 0.060 0.000 0.676
#> SRR949086     3  0.6109     0.5600 0.084 0.000 0.548 0.020 0.348
#> SRR949089     2  0.0693     0.8150 0.000 0.980 0.008 0.012 0.000
#> SRR949090     4  0.3539     0.8698 0.092 0.000 0.028 0.848 0.032
#> SRR949092     1  0.0290     0.8285 0.992 0.000 0.000 0.008 0.000
#> SRR949093     1  0.0290     0.8285 0.992 0.000 0.000 0.008 0.000
#> SRR949091     4  0.5802     0.3003 0.016 0.000 0.380 0.544 0.060
#> SRR949095     5  0.6163     0.5556 0.220 0.044 0.012 0.072 0.652
#> SRR949094     4  0.2770     0.8729 0.076 0.000 0.000 0.880 0.044
#> SRR949096     1  0.2775     0.7827 0.884 0.000 0.004 0.036 0.076
#> SRR949097     1  0.2124     0.8048 0.916 0.000 0.000 0.028 0.056
#> SRR949098     2  0.0693     0.8150 0.000 0.980 0.008 0.012 0.000
#> SRR949099     5  0.7578    -0.0414 0.252 0.000 0.296 0.048 0.404
#> SRR949101     3  0.3070     0.6993 0.012 0.000 0.860 0.016 0.112
#> SRR949100     5  0.4976     0.6130 0.128 0.040 0.024 0.036 0.772
#> SRR949102     5  0.7476     0.3746 0.116 0.004 0.196 0.144 0.540
#> SRR949103     1  0.2209     0.8031 0.912 0.000 0.000 0.032 0.056
#> SRR949104     2  0.0000     0.8155 0.000 1.000 0.000 0.000 0.000
#> SRR949105     3  0.1815     0.7107 0.016 0.000 0.940 0.024 0.020
#> SRR949106     3  0.1815     0.7107 0.016 0.000 0.940 0.024 0.020
#> SRR949107     3  0.1815     0.7107 0.016 0.000 0.940 0.024 0.020
#> SRR949108     1  0.0566     0.8273 0.984 0.000 0.000 0.012 0.004
#> SRR949109     4  0.3369     0.8718 0.092 0.000 0.028 0.856 0.024
#> SRR949110     1  0.2036     0.8067 0.920 0.000 0.000 0.024 0.056
#> SRR949111     4  0.2540     0.8783 0.088 0.000 0.024 0.888 0.000
#> SRR949112     1  0.0510     0.8260 0.984 0.000 0.000 0.000 0.016
#> SRR949113     2  0.0000     0.8155 0.000 1.000 0.000 0.000 0.000
#> SRR949114     1  0.5884     0.4987 0.640 0.000 0.168 0.012 0.180
#> SRR949115     1  0.5884     0.4987 0.640 0.000 0.168 0.012 0.180
#> SRR949116     1  0.5884     0.4987 0.640 0.000 0.168 0.012 0.180
#> SRR949117     3  0.6155     0.5548 0.088 0.000 0.544 0.020 0.348
#> SRR949118     3  0.5803     0.5842 0.060 0.000 0.572 0.020 0.348
#> SRR949119     1  0.4471     0.6903 0.768 0.000 0.004 0.108 0.120
#> SRR949120     1  0.4471     0.6903 0.768 0.000 0.004 0.108 0.120
#> SRR949121     1  0.0404     0.8261 0.988 0.000 0.000 0.000 0.012
#> SRR949122     1  0.0000     0.8278 1.000 0.000 0.000 0.000 0.000
#> SRR949123     2  0.0932     0.8055 0.000 0.972 0.004 0.004 0.020
#> SRR949124     2  0.0000     0.8155 0.000 1.000 0.000 0.000 0.000
#> SRR949125     4  0.3386     0.8752 0.088 0.000 0.036 0.856 0.020
#> SRR949126     4  0.3386     0.8752 0.088 0.000 0.036 0.856 0.020
#> SRR949127     2  0.4401     0.6981 0.000 0.656 0.000 0.016 0.328
#> SRR949128     2  0.4401     0.6981 0.000 0.656 0.000 0.016 0.328
#> SRR949129     2  0.4401     0.6981 0.000 0.656 0.000 0.016 0.328

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR949076     4  0.4378     0.7416 0.028 0.000 0.000 0.760 0.108 0.104
#> SRR949078     2  0.4261     0.5641 0.000 0.572 0.000 0.000 0.408 0.020
#> SRR949077     4  0.4450     0.7435 0.032 0.000 0.000 0.756 0.108 0.104
#> SRR949079     4  0.2271     0.8419 0.024 0.000 0.000 0.908 0.036 0.032
#> SRR949080     4  0.2271     0.8419 0.024 0.000 0.000 0.908 0.036 0.032
#> SRR949081     5  0.6837     0.3687 0.044 0.000 0.340 0.020 0.448 0.148
#> SRR949082     2  0.4261     0.5641 0.000 0.572 0.000 0.000 0.408 0.020
#> SRR949083     1  0.3956     0.6799 0.788 0.000 0.000 0.016 0.104 0.092
#> SRR949084     1  0.3014     0.7274 0.860 0.000 0.000 0.016 0.068 0.056
#> SRR949085     2  0.0632     0.7688 0.000 0.976 0.000 0.000 0.000 0.024
#> SRR949087     5  0.6134     0.6432 0.080 0.044 0.272 0.000 0.580 0.024
#> SRR949088     5  0.6134     0.6432 0.080 0.044 0.272 0.000 0.580 0.024
#> SRR949086     3  0.0862     0.5171 0.008 0.000 0.972 0.000 0.016 0.004
#> SRR949089     2  0.0632     0.7688 0.000 0.976 0.000 0.000 0.000 0.024
#> SRR949090     4  0.2494     0.8414 0.036 0.000 0.004 0.900 0.028 0.032
#> SRR949092     1  0.0291     0.7815 0.992 0.000 0.000 0.000 0.004 0.004
#> SRR949093     1  0.0291     0.7815 0.992 0.000 0.000 0.000 0.004 0.004
#> SRR949091     4  0.6345     0.1608 0.008 0.000 0.380 0.468 0.056 0.088
#> SRR949095     5  0.6087     0.5083 0.100 0.004 0.060 0.032 0.656 0.148
#> SRR949094     4  0.2201     0.8440 0.028 0.000 0.000 0.912 0.032 0.028
#> SRR949096     1  0.3130     0.7244 0.852 0.000 0.000 0.016 0.072 0.060
#> SRR949097     1  0.2998     0.7464 0.876 0.000 0.012 0.036 0.040 0.036
#> SRR949098     2  0.0632     0.7688 0.000 0.976 0.000 0.000 0.000 0.024
#> SRR949099     3  0.6148     0.2798 0.176 0.000 0.632 0.036 0.108 0.048
#> SRR949101     3  0.4229    -0.0414 0.000 0.000 0.732 0.008 0.060 0.200
#> SRR949100     5  0.6156     0.5592 0.044 0.008 0.208 0.028 0.628 0.084
#> SRR949102     3  0.7671    -0.2573 0.060 0.000 0.408 0.056 0.272 0.204
#> SRR949103     1  0.2998     0.7464 0.876 0.000 0.012 0.036 0.040 0.036
#> SRR949104     2  0.0000     0.7686 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949105     6  0.3828     1.0000 0.000 0.000 0.440 0.000 0.000 0.560
#> SRR949106     6  0.3828     1.0000 0.000 0.000 0.440 0.000 0.000 0.560
#> SRR949107     6  0.3828     1.0000 0.000 0.000 0.440 0.000 0.000 0.560
#> SRR949108     1  0.0520     0.7795 0.984 0.000 0.000 0.000 0.008 0.008
#> SRR949109     4  0.2176     0.8450 0.036 0.000 0.004 0.916 0.024 0.020
#> SRR949110     1  0.2884     0.7533 0.880 0.000 0.008 0.028 0.048 0.036
#> SRR949111     4  0.1010     0.8495 0.036 0.000 0.000 0.960 0.000 0.004
#> SRR949112     1  0.1340     0.7723 0.948 0.000 0.008 0.000 0.040 0.004
#> SRR949113     2  0.0146     0.7691 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR949114     1  0.6578     0.2945 0.500 0.000 0.320 0.012 0.096 0.072
#> SRR949115     1  0.6578     0.2945 0.500 0.000 0.320 0.012 0.096 0.072
#> SRR949116     1  0.6578     0.2945 0.500 0.000 0.320 0.012 0.096 0.072
#> SRR949117     3  0.1059     0.5216 0.016 0.000 0.964 0.000 0.016 0.004
#> SRR949118     3  0.0717     0.5172 0.008 0.000 0.976 0.000 0.016 0.000
#> SRR949119     1  0.6291     0.5366 0.624 0.000 0.020 0.096 0.140 0.120
#> SRR949120     1  0.6291     0.5366 0.624 0.000 0.020 0.096 0.140 0.120
#> SRR949121     1  0.0260     0.7809 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR949122     1  0.0260     0.7811 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR949123     2  0.1503     0.7462 0.000 0.944 0.000 0.008 0.032 0.016
#> SRR949124     2  0.0000     0.7686 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949125     4  0.2494     0.8430 0.036 0.000 0.004 0.900 0.028 0.032
#> SRR949126     4  0.2494     0.8430 0.036 0.000 0.004 0.900 0.028 0.032
#> SRR949127     2  0.4379     0.5846 0.000 0.576 0.000 0.000 0.396 0.028
#> SRR949128     2  0.4379     0.5846 0.000 0.576 0.000 0.000 0.396 0.028
#> SRR949129     2  0.4379     0.5846 0.000 0.576 0.000 0.000 0.396 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-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

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

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.726           0.833       0.935         0.4837 0.502   0.502
#> 3 3 0.754           0.809       0.892         0.3848 0.704   0.471
#> 4 4 0.948           0.869       0.947         0.1260 0.887   0.667
#> 5 5 0.844           0.805       0.878         0.0481 0.973   0.892
#> 6 6 0.823           0.743       0.856         0.0376 0.966   0.850

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
#> SRR949076     1  0.3114     0.9002 0.944 0.056
#> SRR949078     2  0.0000     0.8754 0.000 1.000
#> SRR949077     1  0.0000     0.9588 1.000 0.000
#> SRR949079     1  0.0000     0.9588 1.000 0.000
#> SRR949080     1  0.0000     0.9588 1.000 0.000
#> SRR949081     2  0.0000     0.8754 0.000 1.000
#> SRR949082     2  0.0000     0.8754 0.000 1.000
#> SRR949083     1  0.7219     0.6964 0.800 0.200
#> SRR949084     1  0.0000     0.9588 1.000 0.000
#> SRR949085     2  0.0000     0.8754 0.000 1.000
#> SRR949087     2  0.0000     0.8754 0.000 1.000
#> SRR949088     2  0.0000     0.8754 0.000 1.000
#> SRR949086     2  0.9896     0.3273 0.440 0.560
#> SRR949089     2  0.0000     0.8754 0.000 1.000
#> SRR949090     1  0.0000     0.9588 1.000 0.000
#> SRR949092     1  0.0000     0.9588 1.000 0.000
#> SRR949093     1  0.0000     0.9588 1.000 0.000
#> SRR949091     1  0.0000     0.9588 1.000 0.000
#> SRR949095     2  0.0000     0.8754 0.000 1.000
#> SRR949094     1  0.0000     0.9588 1.000 0.000
#> SRR949096     1  0.0000     0.9588 1.000 0.000
#> SRR949097     1  0.0000     0.9588 1.000 0.000
#> SRR949098     2  0.0000     0.8754 0.000 1.000
#> SRR949099     1  0.0000     0.9588 1.000 0.000
#> SRR949101     1  0.8763     0.4858 0.704 0.296
#> SRR949100     2  0.0000     0.8754 0.000 1.000
#> SRR949102     2  0.8499     0.5722 0.276 0.724
#> SRR949103     1  0.0000     0.9588 1.000 0.000
#> SRR949104     2  0.0000     0.8754 0.000 1.000
#> SRR949105     2  0.9896     0.3273 0.440 0.560
#> SRR949106     2  0.9896     0.3273 0.440 0.560
#> SRR949107     2  0.9896     0.3273 0.440 0.560
#> SRR949108     1  0.0000     0.9588 1.000 0.000
#> SRR949109     1  0.0000     0.9588 1.000 0.000
#> SRR949110     1  0.0000     0.9588 1.000 0.000
#> SRR949111     1  0.0000     0.9588 1.000 0.000
#> SRR949112     1  0.0672     0.9514 0.992 0.008
#> SRR949113     2  0.0000     0.8754 0.000 1.000
#> SRR949114     1  0.0000     0.9588 1.000 0.000
#> SRR949115     1  0.0000     0.9588 1.000 0.000
#> SRR949116     1  0.0000     0.9588 1.000 0.000
#> SRR949117     2  0.9896     0.3273 0.440 0.560
#> SRR949118     1  0.9977    -0.0962 0.528 0.472
#> SRR949119     1  0.0000     0.9588 1.000 0.000
#> SRR949120     1  0.0000     0.9588 1.000 0.000
#> SRR949121     1  0.0000     0.9588 1.000 0.000
#> SRR949122     1  0.0000     0.9588 1.000 0.000
#> SRR949123     2  0.0000     0.8754 0.000 1.000
#> SRR949124     2  0.0000     0.8754 0.000 1.000
#> SRR949125     1  0.0000     0.9588 1.000 0.000
#> SRR949126     1  0.0000     0.9588 1.000 0.000
#> SRR949127     2  0.0000     0.8754 0.000 1.000
#> SRR949128     2  0.0000     0.8754 0.000 1.000
#> SRR949129     2  0.0000     0.8754 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
#> SRR949076     3  0.6111      0.635 0.396 0.000 0.604
#> SRR949078     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949077     3  0.6111      0.635 0.396 0.000 0.604
#> SRR949079     3  0.6111      0.635 0.396 0.000 0.604
#> SRR949080     3  0.6111      0.635 0.396 0.000 0.604
#> SRR949081     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949082     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949083     1  0.0000      0.887 1.000 0.000 0.000
#> SRR949084     1  0.0000      0.887 1.000 0.000 0.000
#> SRR949085     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949087     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949088     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949086     3  0.4555      0.566 0.000 0.200 0.800
#> SRR949089     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949090     3  0.5835      0.667 0.340 0.000 0.660
#> SRR949092     1  0.0000      0.887 1.000 0.000 0.000
#> SRR949093     1  0.0000      0.887 1.000 0.000 0.000
#> SRR949091     3  0.0000      0.694 0.000 0.000 1.000
#> SRR949095     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949094     3  0.6111      0.635 0.396 0.000 0.604
#> SRR949096     1  0.0000      0.887 1.000 0.000 0.000
#> SRR949097     1  0.1411      0.864 0.964 0.000 0.036
#> SRR949098     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949099     3  0.0000      0.694 0.000 0.000 1.000
#> SRR949101     3  0.0000      0.694 0.000 0.000 1.000
#> SRR949100     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949102     3  0.6984      0.511 0.040 0.304 0.656
#> SRR949103     1  0.1643      0.858 0.956 0.000 0.044
#> SRR949104     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949105     3  0.1031      0.690 0.000 0.024 0.976
#> SRR949106     3  0.1031      0.690 0.000 0.024 0.976
#> SRR949107     3  0.1031      0.690 0.000 0.024 0.976
#> SRR949108     1  0.0000      0.887 1.000 0.000 0.000
#> SRR949109     3  0.5835      0.667 0.340 0.000 0.660
#> SRR949110     1  0.1411      0.864 0.964 0.000 0.036
#> SRR949111     3  0.5926      0.660 0.356 0.000 0.644
#> SRR949112     1  0.0000      0.887 1.000 0.000 0.000
#> SRR949113     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949114     1  0.6111      0.455 0.604 0.000 0.396
#> SRR949115     1  0.6111      0.455 0.604 0.000 0.396
#> SRR949116     1  0.6111      0.455 0.604 0.000 0.396
#> SRR949117     3  0.4555      0.566 0.000 0.200 0.800
#> SRR949118     3  0.0000      0.694 0.000 0.000 1.000
#> SRR949119     1  0.0237      0.884 0.996 0.000 0.004
#> SRR949120     1  0.0237      0.884 0.996 0.000 0.004
#> SRR949121     1  0.0000      0.887 1.000 0.000 0.000
#> SRR949122     1  0.0000      0.887 1.000 0.000 0.000
#> SRR949123     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949124     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949125     3  0.5926      0.660 0.356 0.000 0.644
#> SRR949126     3  0.5926      0.660 0.356 0.000 0.644
#> SRR949127     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949128     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949129     2  0.0000      1.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR949076     4  0.0188      0.902 0.004 0.000 0.000 0.996
#> SRR949078     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR949077     4  0.0188      0.902 0.004 0.000 0.000 0.996
#> SRR949079     4  0.0000      0.903 0.000 0.000 0.000 1.000
#> SRR949080     4  0.0000      0.903 0.000 0.000 0.000 1.000
#> SRR949081     2  0.5138      0.389 0.000 0.600 0.392 0.008
#> SRR949082     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR949083     1  0.0188      0.986 0.996 0.000 0.000 0.004
#> SRR949084     1  0.0188      0.986 0.996 0.000 0.000 0.004
#> SRR949085     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR949087     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR949088     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR949086     3  0.0000      0.836 0.000 0.000 1.000 0.000
#> SRR949089     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR949090     4  0.0336      0.904 0.000 0.000 0.008 0.992
#> SRR949092     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR949093     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR949091     4  0.4948      0.211 0.000 0.000 0.440 0.560
#> SRR949095     2  0.0336      0.967 0.000 0.992 0.000 0.008
#> SRR949094     4  0.0000      0.903 0.000 0.000 0.000 1.000
#> SRR949096     1  0.0188      0.986 0.996 0.000 0.000 0.004
#> SRR949097     1  0.0336      0.984 0.992 0.000 0.000 0.008
#> SRR949098     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR949099     3  0.0469      0.827 0.000 0.000 0.988 0.012
#> SRR949101     3  0.0000      0.836 0.000 0.000 1.000 0.000
#> SRR949100     2  0.0188      0.971 0.000 0.996 0.000 0.004
#> SRR949102     4  0.7241      0.159 0.004 0.124 0.416 0.456
#> SRR949103     1  0.0336      0.984 0.992 0.000 0.000 0.008
#> SRR949104     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR949105     3  0.0000      0.836 0.000 0.000 1.000 0.000
#> SRR949106     3  0.0000      0.836 0.000 0.000 1.000 0.000
#> SRR949107     3  0.0000      0.836 0.000 0.000 1.000 0.000
#> SRR949108     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR949109     4  0.0336      0.904 0.000 0.000 0.008 0.992
#> SRR949110     1  0.0188      0.986 0.996 0.000 0.000 0.004
#> SRR949111     4  0.0336      0.904 0.000 0.000 0.008 0.992
#> SRR949112     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR949113     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR949114     3  0.4916      0.393 0.424 0.000 0.576 0.000
#> SRR949115     3  0.4916      0.393 0.424 0.000 0.576 0.000
#> SRR949116     3  0.4916      0.393 0.424 0.000 0.576 0.000
#> SRR949117     3  0.0000      0.836 0.000 0.000 1.000 0.000
#> SRR949118     3  0.0000      0.836 0.000 0.000 1.000 0.000
#> SRR949119     1  0.1557      0.941 0.944 0.000 0.000 0.056
#> SRR949120     1  0.1557      0.941 0.944 0.000 0.000 0.056
#> SRR949121     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR949122     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR949123     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR949124     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR949125     4  0.0336      0.904 0.000 0.000 0.008 0.992
#> SRR949126     4  0.0336      0.904 0.000 0.000 0.008 0.992
#> SRR949127     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR949128     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR949129     2  0.0000      0.974 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
#> SRR949076     4  0.1043     0.8849 0.000 0.000 0.000 0.960 0.040
#> SRR949078     2  0.0290     0.9089 0.000 0.992 0.000 0.000 0.008
#> SRR949077     4  0.1410     0.8701 0.000 0.000 0.000 0.940 0.060
#> SRR949079     4  0.0162     0.9017 0.000 0.000 0.000 0.996 0.004
#> SRR949080     4  0.0162     0.9017 0.000 0.000 0.000 0.996 0.004
#> SRR949081     2  0.7490     0.0562 0.000 0.396 0.248 0.040 0.316
#> SRR949082     2  0.0000     0.9101 0.000 1.000 0.000 0.000 0.000
#> SRR949083     1  0.2074     0.8329 0.896 0.000 0.000 0.000 0.104
#> SRR949084     1  0.1792     0.8419 0.916 0.000 0.000 0.000 0.084
#> SRR949085     2  0.0000     0.9101 0.000 1.000 0.000 0.000 0.000
#> SRR949087     2  0.3109     0.8211 0.000 0.800 0.000 0.000 0.200
#> SRR949088     2  0.3109     0.8211 0.000 0.800 0.000 0.000 0.200
#> SRR949086     3  0.1544     0.9108 0.000 0.000 0.932 0.000 0.068
#> SRR949089     2  0.0000     0.9101 0.000 1.000 0.000 0.000 0.000
#> SRR949090     4  0.1671     0.8847 0.000 0.000 0.000 0.924 0.076
#> SRR949092     1  0.0162     0.8605 0.996 0.000 0.000 0.000 0.004
#> SRR949093     1  0.0162     0.8605 0.996 0.000 0.000 0.000 0.004
#> SRR949091     4  0.4283     0.1848 0.000 0.000 0.456 0.544 0.000
#> SRR949095     2  0.3478     0.7922 0.004 0.828 0.000 0.032 0.136
#> SRR949094     4  0.0162     0.9017 0.000 0.000 0.000 0.996 0.004
#> SRR949096     1  0.1851     0.8403 0.912 0.000 0.000 0.000 0.088
#> SRR949097     1  0.2020     0.8249 0.900 0.000 0.000 0.000 0.100
#> SRR949098     2  0.0000     0.9101 0.000 1.000 0.000 0.000 0.000
#> SRR949099     3  0.3880     0.7102 0.020 0.000 0.772 0.004 0.204
#> SRR949101     3  0.0000     0.9225 0.000 0.000 1.000 0.000 0.000
#> SRR949100     2  0.3074     0.8087 0.000 0.804 0.000 0.000 0.196
#> SRR949102     5  0.7513    -0.0378 0.000 0.048 0.304 0.228 0.420
#> SRR949103     1  0.2020     0.8249 0.900 0.000 0.000 0.000 0.100
#> SRR949104     2  0.0000     0.9101 0.000 1.000 0.000 0.000 0.000
#> SRR949105     3  0.0000     0.9225 0.000 0.000 1.000 0.000 0.000
#> SRR949106     3  0.0000     0.9225 0.000 0.000 1.000 0.000 0.000
#> SRR949107     3  0.0000     0.9225 0.000 0.000 1.000 0.000 0.000
#> SRR949108     1  0.0404     0.8606 0.988 0.000 0.000 0.000 0.012
#> SRR949109     4  0.1732     0.8819 0.000 0.000 0.000 0.920 0.080
#> SRR949110     1  0.1908     0.8282 0.908 0.000 0.000 0.000 0.092
#> SRR949111     4  0.1043     0.9030 0.000 0.000 0.000 0.960 0.040
#> SRR949112     1  0.4045     0.3306 0.644 0.000 0.000 0.000 0.356
#> SRR949113     2  0.0000     0.9101 0.000 1.000 0.000 0.000 0.000
#> SRR949114     5  0.6319     0.6984 0.196 0.000 0.284 0.000 0.520
#> SRR949115     5  0.6319     0.6984 0.196 0.000 0.284 0.000 0.520
#> SRR949116     5  0.6319     0.6984 0.196 0.000 0.284 0.000 0.520
#> SRR949117     3  0.1478     0.9115 0.000 0.000 0.936 0.000 0.064
#> SRR949118     3  0.1732     0.9020 0.000 0.000 0.920 0.000 0.080
#> SRR949119     1  0.4736     0.6781 0.712 0.000 0.000 0.072 0.216
#> SRR949120     1  0.4736     0.6781 0.712 0.000 0.000 0.072 0.216
#> SRR949121     1  0.0290     0.8597 0.992 0.000 0.000 0.000 0.008
#> SRR949122     1  0.0404     0.8598 0.988 0.000 0.000 0.000 0.012
#> SRR949123     2  0.0000     0.9101 0.000 1.000 0.000 0.000 0.000
#> SRR949124     2  0.0000     0.9101 0.000 1.000 0.000 0.000 0.000
#> SRR949125     4  0.1043     0.9030 0.000 0.000 0.000 0.960 0.040
#> SRR949126     4  0.1043     0.9030 0.000 0.000 0.000 0.960 0.040
#> SRR949127     2  0.1478     0.8935 0.000 0.936 0.000 0.000 0.064
#> SRR949128     2  0.1478     0.8935 0.000 0.936 0.000 0.000 0.064
#> SRR949129     2  0.1478     0.8935 0.000 0.936 0.000 0.000 0.064

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR949076     4  0.1806    0.87668 0.000 0.000 0.000 0.908 0.088 0.004
#> SRR949078     2  0.1563    0.79333 0.000 0.932 0.000 0.000 0.056 0.012
#> SRR949077     4  0.1908    0.87007 0.000 0.000 0.000 0.900 0.096 0.004
#> SRR949079     4  0.0405    0.91939 0.000 0.000 0.000 0.988 0.008 0.004
#> SRR949080     4  0.0405    0.91939 0.000 0.000 0.000 0.988 0.008 0.004
#> SRR949081     5  0.3700    0.43167 0.000 0.152 0.068 0.000 0.780 0.000
#> SRR949082     2  0.0146    0.82747 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR949083     1  0.1812    0.81577 0.912 0.000 0.000 0.000 0.080 0.008
#> SRR949084     1  0.1524    0.82275 0.932 0.000 0.000 0.000 0.060 0.008
#> SRR949085     2  0.0000    0.83007 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949087     5  0.5051    0.25748 0.000 0.388 0.004 0.000 0.540 0.068
#> SRR949088     5  0.5051    0.25748 0.000 0.388 0.004 0.000 0.540 0.068
#> SRR949086     3  0.3493    0.82225 0.000 0.000 0.800 0.000 0.136 0.064
#> SRR949089     2  0.0000    0.83007 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949090     4  0.1088    0.90148 0.000 0.000 0.000 0.960 0.016 0.024
#> SRR949092     1  0.0146    0.83379 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR949093     1  0.0146    0.83379 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR949091     4  0.3950    0.23826 0.000 0.000 0.432 0.564 0.000 0.004
#> SRR949095     2  0.3420    0.47799 0.000 0.748 0.000 0.000 0.240 0.012
#> SRR949094     4  0.0405    0.91939 0.000 0.000 0.000 0.988 0.008 0.004
#> SRR949096     1  0.1524    0.82275 0.932 0.000 0.000 0.000 0.060 0.008
#> SRR949097     1  0.2917    0.78341 0.852 0.000 0.000 0.004 0.040 0.104
#> SRR949098     2  0.0000    0.83007 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949099     3  0.5702    0.62742 0.012 0.000 0.596 0.008 0.240 0.144
#> SRR949101     3  0.0405    0.84849 0.000 0.000 0.988 0.004 0.000 0.008
#> SRR949100     2  0.5451    0.30505 0.000 0.564 0.000 0.004 0.296 0.136
#> SRR949102     5  0.5957    0.31218 0.000 0.116 0.128 0.052 0.664 0.040
#> SRR949103     1  0.2917    0.78341 0.852 0.000 0.000 0.004 0.040 0.104
#> SRR949104     2  0.0000    0.83007 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949105     3  0.0291    0.85104 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR949106     3  0.0291    0.85104 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR949107     3  0.0291    0.85104 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR949108     1  0.0000    0.83386 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949109     4  0.1176    0.89911 0.000 0.000 0.000 0.956 0.020 0.024
#> SRR949110     1  0.2870    0.78402 0.856 0.000 0.000 0.004 0.040 0.100
#> SRR949111     4  0.0000    0.91959 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949112     1  0.3860   -0.00422 0.528 0.000 0.000 0.000 0.000 0.472
#> SRR949113     2  0.0000    0.83007 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949114     6  0.3183    1.00000 0.060 0.000 0.112 0.000 0.000 0.828
#> SRR949115     6  0.3183    1.00000 0.060 0.000 0.112 0.000 0.000 0.828
#> SRR949116     6  0.3183    1.00000 0.060 0.000 0.112 0.000 0.000 0.828
#> SRR949117     3  0.3341    0.82795 0.000 0.000 0.816 0.000 0.116 0.068
#> SRR949118     3  0.3530    0.81575 0.000 0.000 0.792 0.000 0.152 0.056
#> SRR949119     1  0.5635    0.52442 0.584 0.000 0.000 0.048 0.296 0.072
#> SRR949120     1  0.5635    0.52442 0.584 0.000 0.000 0.048 0.296 0.072
#> SRR949121     1  0.0547    0.83141 0.980 0.000 0.000 0.000 0.000 0.020
#> SRR949122     1  0.0547    0.83110 0.980 0.000 0.000 0.000 0.000 0.020
#> SRR949123     2  0.0000    0.83007 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949124     2  0.0000    0.83007 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949125     4  0.0000    0.91959 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949126     4  0.0000    0.91959 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949127     2  0.4011    0.60953 0.000 0.732 0.000 0.000 0.212 0.056
#> SRR949128     2  0.4011    0.60953 0.000 0.732 0.000 0.000 0.212 0.056
#> SRR949129     2  0.4011    0.60953 0.000 0.732 0.000 0.000 0.212 0.056

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

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

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

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.885           0.885       0.921         0.3894 0.575   0.575
#> 3 3 0.802           0.888       0.944         0.6613 0.759   0.581
#> 4 4 0.938           0.912       0.964         0.1124 0.908   0.738
#> 5 5 0.904           0.816       0.931         0.0844 0.900   0.664
#> 6 6 0.859           0.782       0.895         0.0484 0.945   0.755

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

There is also optional best \(k\) = 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
#> SRR949076     1   0.000      0.915 1.000 0.000
#> SRR949078     2   0.000      0.870 0.000 1.000
#> SRR949077     1   0.000      0.915 1.000 0.000
#> SRR949079     1   0.000      0.915 1.000 0.000
#> SRR949080     1   0.000      0.915 1.000 0.000
#> SRR949081     2   0.963      0.404 0.388 0.612
#> SRR949082     2   0.000      0.870 0.000 1.000
#> SRR949083     1   0.443      0.959 0.908 0.092
#> SRR949084     1   0.443      0.959 0.908 0.092
#> SRR949085     2   0.000      0.870 0.000 1.000
#> SRR949087     2   0.936      0.493 0.352 0.648
#> SRR949088     2   0.900      0.563 0.316 0.684
#> SRR949086     1   0.443      0.959 0.908 0.092
#> SRR949089     2   0.000      0.870 0.000 1.000
#> SRR949090     1   0.000      0.915 1.000 0.000
#> SRR949092     1   0.443      0.959 0.908 0.092
#> SRR949093     1   0.443      0.959 0.908 0.092
#> SRR949091     1   0.000      0.915 1.000 0.000
#> SRR949095     1   0.714      0.826 0.804 0.196
#> SRR949094     1   0.000      0.915 1.000 0.000
#> SRR949096     1   0.443      0.959 0.908 0.092
#> SRR949097     1   0.443      0.959 0.908 0.092
#> SRR949098     2   0.000      0.870 0.000 1.000
#> SRR949099     1   0.443      0.959 0.908 0.092
#> SRR949101     1   0.443      0.959 0.908 0.092
#> SRR949100     2   0.833      0.629 0.264 0.736
#> SRR949102     1   0.443      0.959 0.908 0.092
#> SRR949103     1   0.443      0.959 0.908 0.092
#> SRR949104     2   0.000      0.870 0.000 1.000
#> SRR949105     1   0.443      0.959 0.908 0.092
#> SRR949106     1   0.443      0.959 0.908 0.092
#> SRR949107     1   0.443      0.959 0.908 0.092
#> SRR949108     1   0.443      0.959 0.908 0.092
#> SRR949109     1   0.000      0.915 1.000 0.000
#> SRR949110     1   0.443      0.959 0.908 0.092
#> SRR949111     1   0.000      0.915 1.000 0.000
#> SRR949112     1   0.443      0.959 0.908 0.092
#> SRR949113     2   0.000      0.870 0.000 1.000
#> SRR949114     1   0.443      0.959 0.908 0.092
#> SRR949115     1   0.443      0.959 0.908 0.092
#> SRR949116     1   0.443      0.959 0.908 0.092
#> SRR949117     1   0.443      0.959 0.908 0.092
#> SRR949118     1   0.443      0.959 0.908 0.092
#> SRR949119     1   0.311      0.944 0.944 0.056
#> SRR949120     1   0.311      0.944 0.944 0.056
#> SRR949121     1   0.443      0.959 0.908 0.092
#> SRR949122     1   0.443      0.959 0.908 0.092
#> SRR949123     2   0.973      0.356 0.404 0.596
#> SRR949124     2   0.000      0.870 0.000 1.000
#> SRR949125     1   0.000      0.915 1.000 0.000
#> SRR949126     1   0.000      0.915 1.000 0.000
#> SRR949127     2   0.000      0.870 0.000 1.000
#> SRR949128     2   0.000      0.870 0.000 1.000
#> SRR949129     2   0.000      0.870 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
#> SRR949076     3  0.1529      0.877 0.040 0.000 0.960
#> SRR949078     2  0.0000      0.942 0.000 1.000 0.000
#> SRR949077     3  0.3340      0.829 0.120 0.000 0.880
#> SRR949079     3  0.1529      0.877 0.040 0.000 0.960
#> SRR949080     3  0.1529      0.877 0.040 0.000 0.960
#> SRR949081     2  0.5291      0.659 0.268 0.732 0.000
#> SRR949082     2  0.0000      0.942 0.000 1.000 0.000
#> SRR949083     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949084     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949085     2  0.0000      0.942 0.000 1.000 0.000
#> SRR949087     2  0.3412      0.863 0.124 0.876 0.000
#> SRR949088     2  0.3192      0.873 0.112 0.888 0.000
#> SRR949086     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949089     2  0.0000      0.942 0.000 1.000 0.000
#> SRR949090     3  0.1529      0.877 0.040 0.000 0.960
#> SRR949092     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949093     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949091     3  0.0000      0.845 0.000 0.000 1.000
#> SRR949095     1  0.7279      0.271 0.588 0.376 0.036
#> SRR949094     3  0.1529      0.877 0.040 0.000 0.960
#> SRR949096     1  0.0424      0.968 0.992 0.000 0.008
#> SRR949097     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949098     2  0.0000      0.942 0.000 1.000 0.000
#> SRR949099     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949101     3  0.6204      0.371 0.424 0.000 0.576
#> SRR949100     2  0.2448      0.894 0.076 0.924 0.000
#> SRR949102     1  0.0237      0.971 0.996 0.000 0.004
#> SRR949103     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949104     2  0.0000      0.942 0.000 1.000 0.000
#> SRR949105     3  0.5845      0.624 0.308 0.004 0.688
#> SRR949106     3  0.5845      0.624 0.308 0.004 0.688
#> SRR949107     3  0.5845      0.624 0.308 0.004 0.688
#> SRR949108     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949109     3  0.1529      0.877 0.040 0.000 0.960
#> SRR949110     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949111     3  0.1529      0.877 0.040 0.000 0.960
#> SRR949112     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949113     2  0.0000      0.942 0.000 1.000 0.000
#> SRR949114     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949115     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949116     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949117     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949118     1  0.1529      0.932 0.960 0.000 0.040
#> SRR949119     1  0.0424      0.968 0.992 0.000 0.008
#> SRR949120     1  0.0237      0.971 0.996 0.000 0.004
#> SRR949121     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949122     1  0.0000      0.974 1.000 0.000 0.000
#> SRR949123     2  0.3686      0.847 0.140 0.860 0.000
#> SRR949124     2  0.0000      0.942 0.000 1.000 0.000
#> SRR949125     3  0.1529      0.877 0.040 0.000 0.960
#> SRR949126     3  0.1529      0.877 0.040 0.000 0.960
#> SRR949127     2  0.0000      0.942 0.000 1.000 0.000
#> SRR949128     2  0.0000      0.942 0.000 1.000 0.000
#> SRR949129     2  0.0000      0.942 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
#> SRR949076     4  0.0000      0.879 0.000 0.000 0.000 1.000
#> SRR949078     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR949077     4  0.3569      0.695 0.196 0.000 0.000 0.804
#> SRR949079     4  0.0000      0.879 0.000 0.000 0.000 1.000
#> SRR949080     4  0.0000      0.879 0.000 0.000 0.000 1.000
#> SRR949081     2  0.0592      0.982 0.016 0.984 0.000 0.000
#> SRR949082     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR949083     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949084     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949085     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR949087     2  0.0336      0.991 0.008 0.992 0.000 0.000
#> SRR949088     2  0.0336      0.991 0.008 0.992 0.000 0.000
#> SRR949086     1  0.2760      0.832 0.872 0.000 0.128 0.000
#> SRR949089     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR949090     4  0.0000      0.879 0.000 0.000 0.000 1.000
#> SRR949092     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949093     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949091     4  0.1716      0.825 0.000 0.000 0.064 0.936
#> SRR949095     4  0.7784      0.190 0.244 0.364 0.000 0.392
#> SRR949094     4  0.0000      0.879 0.000 0.000 0.000 1.000
#> SRR949096     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949097     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949098     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR949099     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949101     3  0.0188      0.995 0.004 0.000 0.996 0.000
#> SRR949100     2  0.0188      0.993 0.004 0.996 0.000 0.000
#> SRR949102     4  0.4431      0.550 0.304 0.000 0.000 0.696
#> SRR949103     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949104     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR949105     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> SRR949106     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> SRR949107     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> SRR949108     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949109     4  0.0000      0.879 0.000 0.000 0.000 1.000
#> SRR949110     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949111     4  0.0000      0.879 0.000 0.000 0.000 1.000
#> SRR949112     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949113     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR949114     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949115     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949116     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949117     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949118     3  0.0336      0.991 0.008 0.000 0.992 0.000
#> SRR949119     1  0.4564      0.485 0.672 0.000 0.000 0.328
#> SRR949120     1  0.4193      0.608 0.732 0.000 0.000 0.268
#> SRR949121     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949122     1  0.0000      0.957 1.000 0.000 0.000 0.000
#> SRR949123     2  0.0469      0.987 0.012 0.988 0.000 0.000
#> SRR949124     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR949125     4  0.0000      0.879 0.000 0.000 0.000 1.000
#> SRR949126     4  0.0000      0.879 0.000 0.000 0.000 1.000
#> SRR949127     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR949128     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR949129     2  0.0000      0.996 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
#> SRR949076     4  0.0000     0.8632 0.000 0.000 0.000 1.000 0.000
#> SRR949078     2  0.0000     0.9893 0.000 1.000 0.000 0.000 0.000
#> SRR949077     4  0.1792     0.7791 0.084 0.000 0.000 0.916 0.000
#> SRR949079     4  0.0000     0.8632 0.000 0.000 0.000 1.000 0.000
#> SRR949080     4  0.0000     0.8632 0.000 0.000 0.000 1.000 0.000
#> SRR949081     2  0.2471     0.8232 0.000 0.864 0.136 0.000 0.000
#> SRR949082     2  0.0000     0.9893 0.000 1.000 0.000 0.000 0.000
#> SRR949083     1  0.0000     0.8957 1.000 0.000 0.000 0.000 0.000
#> SRR949084     1  0.0000     0.8957 1.000 0.000 0.000 0.000 0.000
#> SRR949085     2  0.0000     0.9893 0.000 1.000 0.000 0.000 0.000
#> SRR949087     2  0.0000     0.9893 0.000 1.000 0.000 0.000 0.000
#> SRR949088     2  0.0000     0.9893 0.000 1.000 0.000 0.000 0.000
#> SRR949086     3  0.0000     0.8051 0.000 0.000 1.000 0.000 0.000
#> SRR949089     2  0.0000     0.9893 0.000 1.000 0.000 0.000 0.000
#> SRR949090     4  0.0000     0.8632 0.000 0.000 0.000 1.000 0.000
#> SRR949092     1  0.0000     0.8957 1.000 0.000 0.000 0.000 0.000
#> SRR949093     1  0.0000     0.8957 1.000 0.000 0.000 0.000 0.000
#> SRR949091     3  0.4304     0.0758 0.000 0.000 0.516 0.484 0.000
#> SRR949095     4  0.7797     0.1312 0.092 0.288 0.188 0.432 0.000
#> SRR949094     4  0.0000     0.8632 0.000 0.000 0.000 1.000 0.000
#> SRR949096     1  0.0000     0.8957 1.000 0.000 0.000 0.000 0.000
#> SRR949097     1  0.0000     0.8957 1.000 0.000 0.000 0.000 0.000
#> SRR949098     2  0.0000     0.9893 0.000 1.000 0.000 0.000 0.000
#> SRR949099     1  0.3837     0.5667 0.692 0.000 0.308 0.000 0.000
#> SRR949101     5  0.1851     0.8838 0.000 0.000 0.088 0.000 0.912
#> SRR949100     2  0.0000     0.9893 0.000 1.000 0.000 0.000 0.000
#> SRR949102     3  0.5731     0.0439 0.084 0.000 0.480 0.436 0.000
#> SRR949103     1  0.0000     0.8957 1.000 0.000 0.000 0.000 0.000
#> SRR949104     2  0.0000     0.9893 0.000 1.000 0.000 0.000 0.000
#> SRR949105     5  0.0000     0.9642 0.000 0.000 0.000 0.000 1.000
#> SRR949106     5  0.0000     0.9642 0.000 0.000 0.000 0.000 1.000
#> SRR949107     5  0.0000     0.9642 0.000 0.000 0.000 0.000 1.000
#> SRR949108     1  0.0000     0.8957 1.000 0.000 0.000 0.000 0.000
#> SRR949109     4  0.0000     0.8632 0.000 0.000 0.000 1.000 0.000
#> SRR949110     1  0.0000     0.8957 1.000 0.000 0.000 0.000 0.000
#> SRR949111     4  0.0000     0.8632 0.000 0.000 0.000 1.000 0.000
#> SRR949112     1  0.4060     0.4738 0.640 0.000 0.360 0.000 0.000
#> SRR949113     2  0.0000     0.9893 0.000 1.000 0.000 0.000 0.000
#> SRR949114     3  0.0000     0.8051 0.000 0.000 1.000 0.000 0.000
#> SRR949115     3  0.0000     0.8051 0.000 0.000 1.000 0.000 0.000
#> SRR949116     3  0.0000     0.8051 0.000 0.000 1.000 0.000 0.000
#> SRR949117     3  0.0609     0.7899 0.020 0.000 0.980 0.000 0.000
#> SRR949118     3  0.0162     0.8024 0.000 0.000 0.996 0.000 0.004
#> SRR949119     4  0.6756    -0.0131 0.344 0.000 0.268 0.388 0.000
#> SRR949120     1  0.6685     0.1109 0.436 0.000 0.284 0.280 0.000
#> SRR949121     1  0.0000     0.8957 1.000 0.000 0.000 0.000 0.000
#> SRR949122     1  0.0000     0.8957 1.000 0.000 0.000 0.000 0.000
#> SRR949123     2  0.0000     0.9893 0.000 1.000 0.000 0.000 0.000
#> SRR949124     2  0.0000     0.9893 0.000 1.000 0.000 0.000 0.000
#> SRR949125     4  0.0000     0.8632 0.000 0.000 0.000 1.000 0.000
#> SRR949126     4  0.0000     0.8632 0.000 0.000 0.000 1.000 0.000
#> SRR949127     2  0.0000     0.9893 0.000 1.000 0.000 0.000 0.000
#> SRR949128     2  0.0000     0.9893 0.000 1.000 0.000 0.000 0.000
#> SRR949129     2  0.0000     0.9893 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
#> SRR949076     4  0.0000     0.8297 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949078     5  0.2491     0.9529 0.000 0.164 0.000 0.000 0.836 0.000
#> SRR949077     4  0.1610     0.7622 0.084 0.000 0.000 0.916 0.000 0.000
#> SRR949079     4  0.0000     0.8297 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949080     4  0.0000     0.8297 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949081     5  0.2219     0.5530 0.000 0.000 0.000 0.000 0.864 0.136
#> SRR949082     5  0.2491     0.9529 0.000 0.164 0.000 0.000 0.836 0.000
#> SRR949083     1  0.0000     0.8928 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949084     1  0.0000     0.8928 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949085     5  0.2491     0.9529 0.000 0.164 0.000 0.000 0.836 0.000
#> SRR949087     5  0.2491     0.9529 0.000 0.164 0.000 0.000 0.836 0.000
#> SRR949088     5  0.2491     0.9529 0.000 0.164 0.000 0.000 0.836 0.000
#> SRR949086     6  0.0000     0.8843 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR949089     2  0.0632     0.8906 0.000 0.976 0.000 0.000 0.024 0.000
#> SRR949090     4  0.0000     0.8297 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949092     1  0.0000     0.8928 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949093     1  0.0000     0.8928 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949091     6  0.3866     0.0470 0.000 0.000 0.000 0.484 0.000 0.516
#> SRR949095     4  0.7948     0.2493 0.096 0.092 0.000 0.448 0.176 0.188
#> SRR949094     4  0.0000     0.8297 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949096     1  0.0000     0.8928 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949097     1  0.0000     0.8928 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949098     2  0.0632     0.8906 0.000 0.976 0.000 0.000 0.024 0.000
#> SRR949099     1  0.3464     0.5684 0.688 0.000 0.000 0.000 0.000 0.312
#> SRR949101     3  0.1663     0.8857 0.000 0.000 0.912 0.000 0.000 0.088
#> SRR949100     5  0.2491     0.9529 0.000 0.164 0.000 0.000 0.836 0.000
#> SRR949102     4  0.7402     0.1000 0.084 0.024 0.000 0.400 0.164 0.328
#> SRR949103     1  0.0000     0.8928 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949104     2  0.0632     0.8906 0.000 0.976 0.000 0.000 0.024 0.000
#> SRR949105     3  0.0000     0.9638 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949106     3  0.0000     0.9638 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949107     3  0.0000     0.9638 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949108     1  0.0000     0.8928 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949109     4  0.0000     0.8297 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949110     1  0.0146     0.8905 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR949111     4  0.0000     0.8297 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949112     1  0.3672     0.4698 0.632 0.000 0.000 0.000 0.000 0.368
#> SRR949113     2  0.3833    -0.0758 0.000 0.556 0.000 0.000 0.444 0.000
#> SRR949114     6  0.0000     0.8843 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR949115     6  0.0000     0.8843 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR949116     6  0.0000     0.8843 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR949117     6  0.0547     0.8645 0.020 0.000 0.000 0.000 0.000 0.980
#> SRR949118     6  0.0146     0.8815 0.000 0.000 0.004 0.000 0.000 0.996
#> SRR949119     4  0.8031     0.0654 0.280 0.024 0.000 0.312 0.164 0.220
#> SRR949120     1  0.7898     0.1132 0.380 0.024 0.000 0.204 0.164 0.228
#> SRR949121     1  0.0000     0.8928 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949122     1  0.0000     0.8928 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949123     2  0.0632     0.8906 0.000 0.976 0.000 0.000 0.024 0.000
#> SRR949124     2  0.0632     0.8906 0.000 0.976 0.000 0.000 0.024 0.000
#> SRR949125     4  0.0000     0.8297 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949126     4  0.0000     0.8297 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949127     5  0.2491     0.9529 0.000 0.164 0.000 0.000 0.836 0.000
#> SRR949128     5  0.2491     0.9529 0.000 0.164 0.000 0.000 0.836 0.000
#> SRR949129     5  0.2491     0.9529 0.000 0.164 0.000 0.000 0.836 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

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

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.448           0.689       0.863         0.4737 0.508   0.508
#> 3 3 0.430           0.682       0.827         0.3203 0.765   0.570
#> 4 4 0.820           0.756       0.902         0.1282 0.820   0.571
#> 5 5 0.761           0.715       0.820         0.1147 0.892   0.656
#> 6 6 0.729           0.719       0.780         0.0403 0.941   0.735

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
#> SRR949076     2  0.9815     0.3259 0.420 0.580
#> SRR949078     2  0.0000     0.8503 0.000 1.000
#> SRR949077     2  0.9815     0.3259 0.420 0.580
#> SRR949079     2  0.9815     0.3259 0.420 0.580
#> SRR949080     2  0.9815     0.3259 0.420 0.580
#> SRR949081     2  0.6712     0.7513 0.176 0.824
#> SRR949082     2  0.0000     0.8503 0.000 1.000
#> SRR949083     1  0.2778     0.8318 0.952 0.048
#> SRR949084     1  0.4298     0.8180 0.912 0.088
#> SRR949085     2  0.0000     0.8503 0.000 1.000
#> SRR949087     2  0.6343     0.7685 0.160 0.840
#> SRR949088     2  0.6623     0.7562 0.172 0.828
#> SRR949086     1  0.0000     0.8221 1.000 0.000
#> SRR949089     2  0.0000     0.8503 0.000 1.000
#> SRR949090     1  0.9983     0.0234 0.524 0.476
#> SRR949092     1  0.2603     0.8327 0.956 0.044
#> SRR949093     1  0.2603     0.8327 0.956 0.044
#> SRR949091     1  0.9393     0.3691 0.644 0.356
#> SRR949095     2  0.4431     0.8111 0.092 0.908
#> SRR949094     1  0.9983     0.0234 0.524 0.476
#> SRR949096     1  0.4690     0.8112 0.900 0.100
#> SRR949097     1  0.2603     0.8327 0.956 0.044
#> SRR949098     2  0.0000     0.8503 0.000 1.000
#> SRR949099     1  0.0672     0.8252 0.992 0.008
#> SRR949101     1  0.3114     0.8056 0.944 0.056
#> SRR949100     2  0.4562     0.8089 0.096 0.904
#> SRR949102     2  0.7883     0.7228 0.236 0.764
#> SRR949103     1  0.2603     0.8327 0.956 0.044
#> SRR949104     2  0.0000     0.8503 0.000 1.000
#> SRR949105     1  0.0000     0.8221 1.000 0.000
#> SRR949106     1  0.0000     0.8221 1.000 0.000
#> SRR949107     1  0.0000     0.8221 1.000 0.000
#> SRR949108     1  0.2948     0.8323 0.948 0.052
#> SRR949109     1  0.9983     0.0234 0.524 0.476
#> SRR949110     1  0.2603     0.8327 0.956 0.044
#> SRR949111     1  0.9983     0.0234 0.524 0.476
#> SRR949112     1  0.6623     0.7371 0.828 0.172
#> SRR949113     2  0.0000     0.8503 0.000 1.000
#> SRR949114     1  0.2603     0.8327 0.956 0.044
#> SRR949115     1  0.2603     0.8327 0.956 0.044
#> SRR949116     1  0.2603     0.8327 0.956 0.044
#> SRR949117     1  0.0376     0.8238 0.996 0.004
#> SRR949118     1  0.0000     0.8221 1.000 0.000
#> SRR949119     1  0.4690     0.8112 0.900 0.100
#> SRR949120     1  0.4690     0.8112 0.900 0.100
#> SRR949121     1  0.2778     0.8328 0.952 0.048
#> SRR949122     1  0.2948     0.8323 0.948 0.052
#> SRR949123     2  0.0000     0.8503 0.000 1.000
#> SRR949124     2  0.0000     0.8503 0.000 1.000
#> SRR949125     1  0.9983     0.0234 0.524 0.476
#> SRR949126     1  0.9983     0.0234 0.524 0.476
#> SRR949127     2  0.0000     0.8503 0.000 1.000
#> SRR949128     2  0.0000     0.8503 0.000 1.000
#> SRR949129     2  0.0000     0.8503 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
#> SRR949076     1  0.4915     0.9360 0.804 0.012 0.184
#> SRR949078     2  0.0237     0.8195 0.000 0.996 0.004
#> SRR949077     1  0.4915     0.9360 0.804 0.012 0.184
#> SRR949079     1  0.4915     0.9360 0.804 0.012 0.184
#> SRR949080     1  0.4915     0.9360 0.804 0.012 0.184
#> SRR949081     3  0.7295    -0.0831 0.028 0.484 0.488
#> SRR949082     2  0.0237     0.8195 0.000 0.996 0.004
#> SRR949083     3  0.4277     0.7460 0.016 0.132 0.852
#> SRR949084     3  0.3686     0.7429 0.000 0.140 0.860
#> SRR949085     2  0.0000     0.8204 0.000 1.000 0.000
#> SRR949087     2  0.8579     0.1625 0.096 0.464 0.440
#> SRR949088     2  0.8579     0.1625 0.096 0.464 0.440
#> SRR949086     3  0.1453     0.7823 0.024 0.008 0.968
#> SRR949089     2  0.0000     0.8204 0.000 1.000 0.000
#> SRR949090     1  0.4346     0.9398 0.816 0.000 0.184
#> SRR949092     3  0.0747     0.7840 0.016 0.000 0.984
#> SRR949093     3  0.0747     0.7840 0.016 0.000 0.984
#> SRR949091     1  0.2537     0.8158 0.920 0.000 0.080
#> SRR949095     2  0.6473     0.4726 0.020 0.668 0.312
#> SRR949094     1  0.4346     0.9398 0.816 0.000 0.184
#> SRR949096     3  0.4744     0.7401 0.028 0.136 0.836
#> SRR949097     3  0.0892     0.7837 0.020 0.000 0.980
#> SRR949098     2  0.0000     0.8204 0.000 1.000 0.000
#> SRR949099     3  0.0661     0.7847 0.004 0.008 0.988
#> SRR949101     1  0.6155     0.4721 0.664 0.008 0.328
#> SRR949100     2  0.8308     0.4092 0.096 0.568 0.336
#> SRR949102     2  0.9940    -0.0439 0.280 0.360 0.360
#> SRR949103     3  0.0747     0.7840 0.016 0.000 0.984
#> SRR949104     2  0.0000     0.8204 0.000 1.000 0.000
#> SRR949105     3  0.6683     0.0159 0.492 0.008 0.500
#> SRR949106     3  0.6682     0.0300 0.488 0.008 0.504
#> SRR949107     3  0.6683     0.0159 0.492 0.008 0.500
#> SRR949108     3  0.3713     0.7702 0.032 0.076 0.892
#> SRR949109     1  0.4346     0.9398 0.816 0.000 0.184
#> SRR949110     3  0.0747     0.7840 0.016 0.000 0.984
#> SRR949111     1  0.4346     0.9398 0.816 0.000 0.184
#> SRR949112     3  0.6192     0.6482 0.060 0.176 0.764
#> SRR949113     2  0.0000     0.8204 0.000 1.000 0.000
#> SRR949114     3  0.0747     0.7837 0.016 0.000 0.984
#> SRR949115     3  0.0747     0.7837 0.016 0.000 0.984
#> SRR949116     3  0.0747     0.7837 0.016 0.000 0.984
#> SRR949117     3  0.1453     0.7823 0.024 0.008 0.968
#> SRR949118     3  0.5156     0.6088 0.216 0.008 0.776
#> SRR949119     3  0.8716     0.4340 0.240 0.172 0.588
#> SRR949120     3  0.8716     0.4340 0.240 0.172 0.588
#> SRR949121     3  0.2796     0.7423 0.092 0.000 0.908
#> SRR949122     3  0.3551     0.7461 0.000 0.132 0.868
#> SRR949123     2  0.0000     0.8204 0.000 1.000 0.000
#> SRR949124     2  0.0000     0.8204 0.000 1.000 0.000
#> SRR949125     1  0.4346     0.9398 0.816 0.000 0.184
#> SRR949126     1  0.4346     0.9398 0.816 0.000 0.184
#> SRR949127     2  0.2537     0.7989 0.080 0.920 0.000
#> SRR949128     2  0.2537     0.7989 0.080 0.920 0.000
#> SRR949129     2  0.2537     0.7989 0.080 0.920 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR949076     4  0.0336     0.9136 0.008 0.000 0.000 0.992
#> SRR949078     2  0.0000     0.9989 0.000 1.000 0.000 0.000
#> SRR949077     4  0.0336     0.9136 0.008 0.000 0.000 0.992
#> SRR949079     4  0.0336     0.9136 0.008 0.000 0.000 0.992
#> SRR949080     4  0.0336     0.9136 0.008 0.000 0.000 0.992
#> SRR949081     1  0.9254     0.0128 0.388 0.100 0.200 0.312
#> SRR949082     2  0.0000     0.9989 0.000 1.000 0.000 0.000
#> SRR949083     1  0.0188     0.8162 0.996 0.000 0.000 0.004
#> SRR949084     1  0.0188     0.8162 0.996 0.000 0.000 0.004
#> SRR949085     2  0.0000     0.9989 0.000 1.000 0.000 0.000
#> SRR949087     1  0.4839     0.6318 0.756 0.044 0.200 0.000
#> SRR949088     1  0.4839     0.6318 0.756 0.044 0.200 0.000
#> SRR949086     1  0.5229     0.2252 0.564 0.000 0.428 0.008
#> SRR949089     2  0.0000     0.9989 0.000 1.000 0.000 0.000
#> SRR949090     4  0.1118     0.8907 0.036 0.000 0.000 0.964
#> SRR949092     1  0.0188     0.8162 0.996 0.000 0.000 0.004
#> SRR949093     1  0.0188     0.8162 0.996 0.000 0.000 0.004
#> SRR949091     4  0.1211     0.8803 0.000 0.000 0.040 0.960
#> SRR949095     1  0.9235    -0.0118 0.376 0.096 0.200 0.328
#> SRR949094     4  0.0336     0.9136 0.008 0.000 0.000 0.992
#> SRR949096     1  0.0188     0.8162 0.996 0.000 0.000 0.004
#> SRR949097     1  0.0188     0.8162 0.996 0.000 0.000 0.004
#> SRR949098     2  0.0000     0.9989 0.000 1.000 0.000 0.000
#> SRR949099     1  0.3402     0.7016 0.832 0.000 0.164 0.004
#> SRR949101     3  0.6277     0.2928 0.068 0.000 0.572 0.360
#> SRR949100     1  0.4839     0.6318 0.756 0.044 0.200 0.000
#> SRR949102     4  0.8615    -0.1551 0.364 0.044 0.200 0.392
#> SRR949103     1  0.0188     0.8162 0.996 0.000 0.000 0.004
#> SRR949104     2  0.0000     0.9989 0.000 1.000 0.000 0.000
#> SRR949105     3  0.0000     0.7454 0.000 0.000 1.000 0.000
#> SRR949106     3  0.0000     0.7454 0.000 0.000 1.000 0.000
#> SRR949107     3  0.0000     0.7454 0.000 0.000 1.000 0.000
#> SRR949108     1  0.0188     0.8162 0.996 0.000 0.000 0.004
#> SRR949109     4  0.1211     0.8867 0.040 0.000 0.000 0.960
#> SRR949110     1  0.0188     0.8162 0.996 0.000 0.000 0.004
#> SRR949111     4  0.0336     0.9136 0.008 0.000 0.000 0.992
#> SRR949112     1  0.0000     0.8146 1.000 0.000 0.000 0.000
#> SRR949113     2  0.0000     0.9989 0.000 1.000 0.000 0.000
#> SRR949114     1  0.0927     0.8050 0.976 0.000 0.016 0.008
#> SRR949115     1  0.0927     0.8050 0.976 0.000 0.016 0.008
#> SRR949116     1  0.0804     0.8071 0.980 0.000 0.012 0.008
#> SRR949117     1  0.5279     0.2952 0.588 0.000 0.400 0.012
#> SRR949118     3  0.4898     0.0862 0.416 0.000 0.584 0.000
#> SRR949119     1  0.4304     0.5177 0.716 0.000 0.000 0.284
#> SRR949120     1  0.3975     0.5811 0.760 0.000 0.000 0.240
#> SRR949121     1  0.0000     0.8146 1.000 0.000 0.000 0.000
#> SRR949122     1  0.0188     0.8162 0.996 0.000 0.000 0.004
#> SRR949123     2  0.0000     0.9989 0.000 1.000 0.000 0.000
#> SRR949124     2  0.0000     0.9989 0.000 1.000 0.000 0.000
#> SRR949125     4  0.0336     0.9136 0.008 0.000 0.000 0.992
#> SRR949126     4  0.0336     0.9136 0.008 0.000 0.000 0.992
#> SRR949127     2  0.0188     0.9965 0.004 0.996 0.000 0.000
#> SRR949128     2  0.0188     0.9965 0.004 0.996 0.000 0.000
#> SRR949129     2  0.0188     0.9965 0.004 0.996 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
#> SRR949076     4  0.0703     0.9005 0.000 0.000 0.000 0.976 0.024
#> SRR949078     2  0.0703     0.9705 0.024 0.976 0.000 0.000 0.000
#> SRR949077     4  0.0703     0.9005 0.000 0.000 0.000 0.976 0.024
#> SRR949079     4  0.0703     0.9005 0.000 0.000 0.000 0.976 0.024
#> SRR949080     4  0.0703     0.9005 0.000 0.000 0.000 0.976 0.024
#> SRR949081     5  0.4811     0.5062 0.204 0.036 0.008 0.016 0.736
#> SRR949082     2  0.0771     0.9741 0.004 0.976 0.000 0.000 0.020
#> SRR949083     1  0.2798     0.6580 0.852 0.000 0.008 0.000 0.140
#> SRR949084     1  0.3203     0.6406 0.820 0.000 0.000 0.012 0.168
#> SRR949085     2  0.0290     0.9835 0.000 0.992 0.000 0.000 0.008
#> SRR949087     5  0.4416     0.6073 0.356 0.012 0.000 0.000 0.632
#> SRR949088     5  0.4416     0.6073 0.356 0.012 0.000 0.000 0.632
#> SRR949086     5  0.6232     0.2706 0.164 0.004 0.280 0.000 0.552
#> SRR949089     2  0.0000     0.9837 0.000 1.000 0.000 0.000 0.000
#> SRR949090     4  0.2864     0.7713 0.136 0.000 0.000 0.852 0.012
#> SRR949092     1  0.1410     0.6907 0.940 0.000 0.000 0.000 0.060
#> SRR949093     1  0.1792     0.6850 0.916 0.000 0.000 0.000 0.084
#> SRR949091     4  0.4658     0.3024 0.000 0.000 0.408 0.576 0.016
#> SRR949095     5  0.4956     0.5059 0.204 0.044 0.008 0.016 0.728
#> SRR949094     4  0.0000     0.9019 0.000 0.000 0.000 1.000 0.000
#> SRR949096     1  0.3527     0.6337 0.804 0.000 0.000 0.024 0.172
#> SRR949097     1  0.3242     0.6500 0.784 0.000 0.000 0.000 0.216
#> SRR949098     2  0.0290     0.9835 0.000 0.992 0.000 0.000 0.008
#> SRR949099     5  0.4807    -0.0101 0.448 0.000 0.020 0.000 0.532
#> SRR949101     3  0.4227     0.6081 0.000 0.000 0.692 0.016 0.292
#> SRR949100     5  0.4974     0.6054 0.364 0.024 0.008 0.000 0.604
#> SRR949102     5  0.6075     0.3186 0.056 0.020 0.016 0.312 0.596
#> SRR949103     1  0.3242     0.6500 0.784 0.000 0.000 0.000 0.216
#> SRR949104     2  0.0000     0.9837 0.000 1.000 0.000 0.000 0.000
#> SRR949105     3  0.0000     0.8036 0.000 0.000 1.000 0.000 0.000
#> SRR949106     3  0.0000     0.8036 0.000 0.000 1.000 0.000 0.000
#> SRR949107     3  0.0000     0.8036 0.000 0.000 1.000 0.000 0.000
#> SRR949108     1  0.0693     0.6906 0.980 0.000 0.000 0.008 0.012
#> SRR949109     4  0.3197     0.7504 0.140 0.000 0.000 0.836 0.024
#> SRR949110     1  0.3242     0.6500 0.784 0.000 0.000 0.000 0.216
#> SRR949111     4  0.0000     0.9019 0.000 0.000 0.000 1.000 0.000
#> SRR949112     1  0.3242     0.4745 0.784 0.000 0.000 0.000 0.216
#> SRR949113     2  0.0771     0.9741 0.004 0.976 0.000 0.000 0.020
#> SRR949114     1  0.4880     0.4913 0.616 0.000 0.036 0.000 0.348
#> SRR949115     1  0.4866     0.4984 0.620 0.000 0.036 0.000 0.344
#> SRR949116     1  0.4866     0.4984 0.620 0.000 0.036 0.000 0.344
#> SRR949117     5  0.6211     0.3172 0.204 0.000 0.248 0.000 0.548
#> SRR949118     3  0.4201     0.5671 0.008 0.000 0.664 0.000 0.328
#> SRR949119     1  0.3847     0.6232 0.784 0.000 0.000 0.036 0.180
#> SRR949120     1  0.3847     0.6232 0.784 0.000 0.000 0.036 0.180
#> SRR949121     1  0.3039     0.6591 0.808 0.000 0.000 0.000 0.192
#> SRR949122     1  0.1043     0.6802 0.960 0.000 0.000 0.000 0.040
#> SRR949123     2  0.0162     0.9832 0.000 0.996 0.000 0.000 0.004
#> SRR949124     2  0.0000     0.9837 0.000 1.000 0.000 0.000 0.000
#> SRR949125     4  0.0000     0.9019 0.000 0.000 0.000 1.000 0.000
#> SRR949126     4  0.0000     0.9019 0.000 0.000 0.000 1.000 0.000
#> SRR949127     2  0.0703     0.9774 0.000 0.976 0.000 0.000 0.024
#> SRR949128     2  0.0703     0.9774 0.000 0.976 0.000 0.000 0.024
#> SRR949129     2  0.0703     0.9774 0.000 0.976 0.000 0.000 0.024

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR949076     4  0.1578     0.9051 0.012 0.000 0.000 0.936 0.048 0.004
#> SRR949078     2  0.3507     0.7489 0.012 0.752 0.000 0.004 0.232 0.000
#> SRR949077     4  0.2110     0.8939 0.012 0.000 0.000 0.900 0.084 0.004
#> SRR949079     4  0.1888     0.9035 0.012 0.000 0.000 0.916 0.068 0.004
#> SRR949080     4  0.1888     0.9035 0.012 0.000 0.000 0.916 0.068 0.004
#> SRR949081     5  0.3945     0.7413 0.032 0.044 0.000 0.112 0.804 0.008
#> SRR949082     2  0.4173     0.7486 0.012 0.732 0.000 0.044 0.212 0.000
#> SRR949083     1  0.0964     0.7892 0.968 0.004 0.000 0.000 0.016 0.012
#> SRR949084     1  0.0893     0.7864 0.972 0.004 0.000 0.004 0.016 0.004
#> SRR949085     2  0.2597     0.7827 0.000 0.824 0.000 0.000 0.176 0.000
#> SRR949087     5  0.3112     0.7429 0.096 0.000 0.000 0.000 0.836 0.068
#> SRR949088     5  0.3112     0.7429 0.096 0.000 0.000 0.000 0.836 0.068
#> SRR949086     6  0.5304     0.5461 0.008 0.000 0.152 0.000 0.216 0.624
#> SRR949089     2  0.2631     0.7191 0.000 0.820 0.000 0.000 0.000 0.180
#> SRR949090     4  0.1204     0.9261 0.000 0.000 0.000 0.944 0.000 0.056
#> SRR949092     1  0.2006     0.8038 0.904 0.000 0.000 0.000 0.080 0.016
#> SRR949093     1  0.2006     0.8038 0.904 0.000 0.000 0.000 0.080 0.016
#> SRR949091     3  0.4057     0.1499 0.000 0.000 0.556 0.436 0.000 0.008
#> SRR949095     5  0.4381     0.7203 0.036 0.084 0.000 0.104 0.772 0.004
#> SRR949094     4  0.2364     0.8929 0.072 0.000 0.000 0.892 0.032 0.004
#> SRR949096     1  0.0972     0.7799 0.964 0.000 0.000 0.008 0.028 0.000
#> SRR949097     1  0.4281     0.6906 0.708 0.000 0.000 0.000 0.072 0.220
#> SRR949098     2  0.2913     0.7168 0.004 0.812 0.000 0.000 0.004 0.180
#> SRR949099     6  0.5748     0.5080 0.060 0.000 0.072 0.000 0.284 0.584
#> SRR949101     3  0.4633     0.5421 0.000 0.000 0.716 0.056 0.196 0.032
#> SRR949100     5  0.2863     0.7524 0.096 0.008 0.000 0.000 0.860 0.036
#> SRR949102     5  0.4970     0.4910 0.008 0.012 0.012 0.316 0.628 0.024
#> SRR949103     1  0.4809     0.4978 0.600 0.000 0.000 0.000 0.072 0.328
#> SRR949104     2  0.2631     0.7191 0.000 0.820 0.000 0.000 0.000 0.180
#> SRR949105     3  0.0000     0.6999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949106     3  0.0000     0.6999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949107     3  0.0000     0.6999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949108     1  0.2452     0.8051 0.884 0.000 0.000 0.004 0.084 0.028
#> SRR949109     4  0.1267     0.9238 0.000 0.000 0.000 0.940 0.000 0.060
#> SRR949110     1  0.4332     0.6832 0.700 0.000 0.000 0.000 0.072 0.228
#> SRR949111     4  0.1204     0.9261 0.000 0.000 0.000 0.944 0.000 0.056
#> SRR949112     1  0.4465     0.6658 0.704 0.000 0.004 0.000 0.212 0.080
#> SRR949113     2  0.4182     0.7671 0.008 0.756 0.000 0.044 0.180 0.012
#> SRR949114     6  0.4770     0.6193 0.284 0.000 0.040 0.000 0.024 0.652
#> SRR949115     6  0.4788     0.6152 0.288 0.000 0.040 0.000 0.024 0.648
#> SRR949116     6  0.4788     0.6152 0.288 0.000 0.040 0.000 0.024 0.648
#> SRR949117     6  0.5304     0.5461 0.008 0.000 0.152 0.000 0.216 0.624
#> SRR949118     3  0.5964     0.0557 0.004 0.000 0.468 0.000 0.208 0.320
#> SRR949119     1  0.3108     0.7106 0.860 0.000 0.000 0.052 0.036 0.052
#> SRR949120     1  0.3108     0.7106 0.860 0.000 0.000 0.052 0.036 0.052
#> SRR949121     1  0.4012     0.7185 0.748 0.000 0.000 0.000 0.076 0.176
#> SRR949122     1  0.3375     0.7802 0.816 0.000 0.000 0.000 0.096 0.088
#> SRR949123     2  0.1851     0.7586 0.000 0.928 0.000 0.012 0.036 0.024
#> SRR949124     2  0.2772     0.7177 0.000 0.816 0.000 0.000 0.004 0.180
#> SRR949125     4  0.1204     0.9261 0.000 0.000 0.000 0.944 0.000 0.056
#> SRR949126     4  0.1204     0.9261 0.000 0.000 0.000 0.944 0.000 0.056
#> SRR949127     2  0.3175     0.7653 0.000 0.744 0.000 0.000 0.256 0.000
#> SRR949128     2  0.3175     0.7653 0.000 0.744 0.000 0.000 0.256 0.000
#> SRR949129     2  0.3175     0.7653 0.000 0.744 0.000 0.000 0.256 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

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

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.854           0.921       0.966         0.4337 0.560   0.560
#> 3 3 0.587           0.670       0.847         0.5214 0.739   0.547
#> 4 4 0.870           0.840       0.930         0.1335 0.770   0.438
#> 5 5 0.770           0.601       0.821         0.0561 0.985   0.941
#> 6 6 0.775           0.660       0.803         0.0414 0.899   0.608

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
#> SRR949076     1   0.000      0.975 1.000 0.000
#> SRR949078     2   0.000      0.934 0.000 1.000
#> SRR949077     1   0.000      0.975 1.000 0.000
#> SRR949079     1   0.000      0.975 1.000 0.000
#> SRR949080     1   0.000      0.975 1.000 0.000
#> SRR949081     2   0.242      0.911 0.040 0.960
#> SRR949082     2   0.000      0.934 0.000 1.000
#> SRR949083     1   0.000      0.975 1.000 0.000
#> SRR949084     1   0.000      0.975 1.000 0.000
#> SRR949085     2   0.000      0.934 0.000 1.000
#> SRR949087     2   0.358      0.891 0.068 0.932
#> SRR949088     2   0.373      0.887 0.072 0.928
#> SRR949086     1   0.327      0.921 0.940 0.060
#> SRR949089     2   0.000      0.934 0.000 1.000
#> SRR949090     1   0.000      0.975 1.000 0.000
#> SRR949092     1   0.000      0.975 1.000 0.000
#> SRR949093     1   0.000      0.975 1.000 0.000
#> SRR949091     1   0.000      0.975 1.000 0.000
#> SRR949095     2   0.966      0.384 0.392 0.608
#> SRR949094     1   0.000      0.975 1.000 0.000
#> SRR949096     1   0.000      0.975 1.000 0.000
#> SRR949097     1   0.000      0.975 1.000 0.000
#> SRR949098     2   0.000      0.934 0.000 1.000
#> SRR949099     1   0.000      0.975 1.000 0.000
#> SRR949101     1   0.000      0.975 1.000 0.000
#> SRR949100     2   0.990      0.224 0.440 0.560
#> SRR949102     1   0.000      0.975 1.000 0.000
#> SRR949103     1   0.000      0.975 1.000 0.000
#> SRR949104     2   0.000      0.934 0.000 1.000
#> SRR949105     1   0.722      0.753 0.800 0.200
#> SRR949106     1   0.722      0.753 0.800 0.200
#> SRR949107     1   0.722      0.753 0.800 0.200
#> SRR949108     1   0.000      0.975 1.000 0.000
#> SRR949109     1   0.000      0.975 1.000 0.000
#> SRR949110     1   0.000      0.975 1.000 0.000
#> SRR949111     1   0.000      0.975 1.000 0.000
#> SRR949112     1   0.000      0.975 1.000 0.000
#> SRR949113     2   0.000      0.934 0.000 1.000
#> SRR949114     1   0.000      0.975 1.000 0.000
#> SRR949115     1   0.000      0.975 1.000 0.000
#> SRR949116     1   0.000      0.975 1.000 0.000
#> SRR949117     1   0.605      0.823 0.852 0.148
#> SRR949118     1   0.000      0.975 1.000 0.000
#> SRR949119     1   0.000      0.975 1.000 0.000
#> SRR949120     1   0.000      0.975 1.000 0.000
#> SRR949121     1   0.000      0.975 1.000 0.000
#> SRR949122     1   0.000      0.975 1.000 0.000
#> SRR949123     2   0.000      0.934 0.000 1.000
#> SRR949124     2   0.000      0.934 0.000 1.000
#> SRR949125     1   0.000      0.975 1.000 0.000
#> SRR949126     1   0.000      0.975 1.000 0.000
#> SRR949127     2   0.000      0.934 0.000 1.000
#> SRR949128     2   0.000      0.934 0.000 1.000
#> SRR949129     2   0.000      0.934 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
#> SRR949076     1  0.5706      0.521 0.680 0.000 0.320
#> SRR949078     2  0.0000      0.927 0.000 1.000 0.000
#> SRR949077     1  0.5327      0.578 0.728 0.000 0.272
#> SRR949079     1  0.5760      0.510 0.672 0.000 0.328
#> SRR949080     1  0.5760      0.510 0.672 0.000 0.328
#> SRR949081     2  0.7141      0.369 0.368 0.600 0.032
#> SRR949082     2  0.0000      0.927 0.000 1.000 0.000
#> SRR949083     1  0.1753      0.763 0.952 0.000 0.048
#> SRR949084     1  0.0000      0.771 1.000 0.000 0.000
#> SRR949085     2  0.0000      0.927 0.000 1.000 0.000
#> SRR949087     2  0.2636      0.878 0.048 0.932 0.020
#> SRR949088     2  0.2636      0.878 0.048 0.932 0.020
#> SRR949086     3  0.5355      0.650 0.036 0.160 0.804
#> SRR949089     2  0.0000      0.927 0.000 1.000 0.000
#> SRR949090     3  0.4399      0.615 0.188 0.000 0.812
#> SRR949092     1  0.1753      0.763 0.952 0.000 0.048
#> SRR949093     1  0.1753      0.763 0.952 0.000 0.048
#> SRR949091     3  0.2066      0.671 0.060 0.000 0.940
#> SRR949095     1  0.6102      0.454 0.672 0.320 0.008
#> SRR949094     1  0.5591      0.543 0.696 0.000 0.304
#> SRR949096     1  0.0000      0.771 1.000 0.000 0.000
#> SRR949097     1  0.1860      0.761 0.948 0.000 0.052
#> SRR949098     2  0.0000      0.927 0.000 1.000 0.000
#> SRR949099     3  0.5621      0.518 0.308 0.000 0.692
#> SRR949101     3  0.0237      0.687 0.004 0.000 0.996
#> SRR949100     2  0.6062      0.369 0.384 0.616 0.000
#> SRR949102     1  0.5678      0.533 0.684 0.000 0.316
#> SRR949103     1  0.4931      0.497 0.768 0.000 0.232
#> SRR949104     2  0.0000      0.927 0.000 1.000 0.000
#> SRR949105     3  0.3276      0.699 0.024 0.068 0.908
#> SRR949106     3  0.3499      0.699 0.028 0.072 0.900
#> SRR949107     3  0.3550      0.697 0.024 0.080 0.896
#> SRR949108     1  0.0424      0.772 0.992 0.000 0.008
#> SRR949109     3  0.4887      0.578 0.228 0.000 0.772
#> SRR949110     1  0.2711      0.731 0.912 0.000 0.088
#> SRR949111     3  0.6079      0.266 0.388 0.000 0.612
#> SRR949112     1  0.1411      0.767 0.964 0.000 0.036
#> SRR949113     2  0.0000      0.927 0.000 1.000 0.000
#> SRR949114     3  0.6291      0.278 0.468 0.000 0.532
#> SRR949115     3  0.6308      0.223 0.492 0.000 0.508
#> SRR949116     1  0.6309     -0.279 0.504 0.000 0.496
#> SRR949117     3  0.7026      0.614 0.120 0.152 0.728
#> SRR949118     3  0.3941      0.662 0.156 0.000 0.844
#> SRR949119     1  0.0237      0.770 0.996 0.000 0.004
#> SRR949120     1  0.0237      0.770 0.996 0.000 0.004
#> SRR949121     1  0.1753      0.763 0.952 0.000 0.048
#> SRR949122     1  0.0424      0.772 0.992 0.000 0.008
#> SRR949123     2  0.0000      0.927 0.000 1.000 0.000
#> SRR949124     2  0.0000      0.927 0.000 1.000 0.000
#> SRR949125     3  0.5650      0.455 0.312 0.000 0.688
#> SRR949126     3  0.5650      0.455 0.312 0.000 0.688
#> SRR949127     2  0.0000      0.927 0.000 1.000 0.000
#> SRR949128     2  0.0000      0.927 0.000 1.000 0.000
#> SRR949129     2  0.0000      0.927 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
#> SRR949076     4  0.0336      0.914 0.000 0.000 0.008 0.992
#> SRR949078     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> SRR949077     4  0.0000      0.918 0.000 0.000 0.000 1.000
#> SRR949079     4  0.0000      0.918 0.000 0.000 0.000 1.000
#> SRR949080     4  0.0000      0.918 0.000 0.000 0.000 1.000
#> SRR949081     2  0.5486      0.643 0.000 0.720 0.200 0.080
#> SRR949082     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> SRR949083     1  0.1302      0.874 0.956 0.000 0.000 0.044
#> SRR949084     1  0.1302      0.874 0.956 0.000 0.000 0.044
#> SRR949085     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> SRR949087     1  0.5594      0.137 0.520 0.460 0.020 0.000
#> SRR949088     1  0.5594      0.137 0.520 0.460 0.020 0.000
#> SRR949086     3  0.0524      0.941 0.004 0.008 0.988 0.000
#> SRR949089     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> SRR949090     4  0.1302      0.919 0.000 0.000 0.044 0.956
#> SRR949092     1  0.0000      0.887 1.000 0.000 0.000 0.000
#> SRR949093     1  0.0000      0.887 1.000 0.000 0.000 0.000
#> SRR949091     4  0.4843      0.375 0.000 0.000 0.396 0.604
#> SRR949095     2  0.5268      0.217 0.000 0.540 0.008 0.452
#> SRR949094     4  0.0000      0.918 0.000 0.000 0.000 1.000
#> SRR949096     1  0.1302      0.874 0.956 0.000 0.000 0.044
#> SRR949097     1  0.0000      0.887 1.000 0.000 0.000 0.000
#> SRR949098     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> SRR949099     3  0.3837      0.714 0.224 0.000 0.776 0.000
#> SRR949101     3  0.0336      0.944 0.000 0.000 0.992 0.008
#> SRR949100     2  0.2965      0.848 0.072 0.892 0.000 0.036
#> SRR949102     4  0.3569      0.730 0.000 0.000 0.196 0.804
#> SRR949103     1  0.0000      0.887 1.000 0.000 0.000 0.000
#> SRR949104     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> SRR949105     3  0.0336      0.944 0.000 0.000 0.992 0.008
#> SRR949106     3  0.0336      0.944 0.000 0.000 0.992 0.008
#> SRR949107     3  0.0336      0.944 0.000 0.000 0.992 0.008
#> SRR949108     1  0.0000      0.887 1.000 0.000 0.000 0.000
#> SRR949109     4  0.1302      0.919 0.000 0.000 0.044 0.956
#> SRR949110     1  0.0000      0.887 1.000 0.000 0.000 0.000
#> SRR949111     4  0.1302      0.919 0.000 0.000 0.044 0.956
#> SRR949112     1  0.0000      0.887 1.000 0.000 0.000 0.000
#> SRR949113     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> SRR949114     1  0.3801      0.670 0.780 0.000 0.220 0.000
#> SRR949115     1  0.3074      0.762 0.848 0.000 0.152 0.000
#> SRR949116     1  0.3074      0.762 0.848 0.000 0.152 0.000
#> SRR949117     3  0.1722      0.919 0.048 0.008 0.944 0.000
#> SRR949118     3  0.1256      0.936 0.028 0.000 0.964 0.008
#> SRR949119     1  0.1637      0.867 0.940 0.000 0.000 0.060
#> SRR949120     1  0.1637      0.867 0.940 0.000 0.000 0.060
#> SRR949121     1  0.0000      0.887 1.000 0.000 0.000 0.000
#> SRR949122     1  0.0000      0.887 1.000 0.000 0.000 0.000
#> SRR949123     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> SRR949124     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> SRR949125     4  0.1302      0.919 0.000 0.000 0.044 0.956
#> SRR949126     4  0.1302      0.919 0.000 0.000 0.044 0.956
#> SRR949127     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> SRR949128     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> SRR949129     2  0.0000      0.938 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR949076     4  0.1571      0.859 0.000 0.000 0.004 0.936 0.060
#> SRR949078     2  0.0609      0.903 0.000 0.980 0.000 0.000 0.020
#> SRR949077     4  0.2648      0.773 0.000 0.000 0.000 0.848 0.152
#> SRR949079     4  0.0000      0.895 0.000 0.000 0.000 1.000 0.000
#> SRR949080     4  0.0000      0.895 0.000 0.000 0.000 1.000 0.000
#> SRR949081     5  0.7759      0.135 0.280 0.080 0.128 0.020 0.492
#> SRR949082     2  0.0404      0.905 0.000 0.988 0.000 0.000 0.012
#> SRR949083     1  0.1851      0.638 0.912 0.000 0.000 0.000 0.088
#> SRR949084     1  0.2074      0.628 0.896 0.000 0.000 0.000 0.104
#> SRR949085     2  0.0000      0.907 0.000 1.000 0.000 0.000 0.000
#> SRR949087     1  0.8136     -0.261 0.348 0.328 0.116 0.000 0.208
#> SRR949088     1  0.8136     -0.259 0.348 0.328 0.116 0.000 0.208
#> SRR949086     3  0.3366      0.509 0.000 0.000 0.768 0.000 0.232
#> SRR949089     2  0.0000      0.907 0.000 1.000 0.000 0.000 0.000
#> SRR949090     4  0.0404      0.892 0.000 0.000 0.012 0.988 0.000
#> SRR949092     1  0.0000      0.671 1.000 0.000 0.000 0.000 0.000
#> SRR949093     1  0.0000      0.671 1.000 0.000 0.000 0.000 0.000
#> SRR949091     4  0.4980      0.539 0.000 0.000 0.072 0.676 0.252
#> SRR949095     2  0.7843     -0.025 0.060 0.400 0.004 0.252 0.284
#> SRR949094     4  0.0000      0.895 0.000 0.000 0.000 1.000 0.000
#> SRR949096     1  0.2230      0.619 0.884 0.000 0.000 0.000 0.116
#> SRR949097     1  0.0794      0.669 0.972 0.000 0.000 0.000 0.028
#> SRR949098     2  0.0000      0.907 0.000 1.000 0.000 0.000 0.000
#> SRR949099     3  0.6243      0.129 0.184 0.000 0.532 0.000 0.284
#> SRR949101     3  0.3590      0.555 0.000 0.000 0.828 0.092 0.080
#> SRR949100     2  0.6294      0.267 0.100 0.552 0.024 0.000 0.324
#> SRR949102     4  0.5880      0.176 0.000 0.000 0.100 0.484 0.416
#> SRR949103     1  0.2732      0.599 0.840 0.000 0.000 0.000 0.160
#> SRR949104     2  0.0000      0.907 0.000 1.000 0.000 0.000 0.000
#> SRR949105     3  0.0162      0.681 0.000 0.000 0.996 0.004 0.000
#> SRR949106     3  0.0162      0.681 0.000 0.000 0.996 0.004 0.000
#> SRR949107     3  0.0162      0.681 0.000 0.000 0.996 0.004 0.000
#> SRR949108     1  0.0510      0.672 0.984 0.000 0.000 0.000 0.016
#> SRR949109     4  0.0451      0.892 0.000 0.000 0.008 0.988 0.004
#> SRR949110     1  0.1043      0.672 0.960 0.000 0.000 0.000 0.040
#> SRR949111     4  0.0162      0.895 0.000 0.000 0.004 0.996 0.000
#> SRR949112     1  0.3586      0.539 0.736 0.000 0.000 0.000 0.264
#> SRR949113     2  0.0000      0.907 0.000 1.000 0.000 0.000 0.000
#> SRR949114     1  0.5059      0.357 0.548 0.000 0.036 0.000 0.416
#> SRR949115     1  0.5059      0.357 0.548 0.000 0.036 0.000 0.416
#> SRR949116     1  0.4989      0.362 0.552 0.000 0.032 0.000 0.416
#> SRR949117     3  0.5771      0.211 0.112 0.000 0.572 0.000 0.316
#> SRR949118     5  0.4304     -0.431 0.000 0.000 0.484 0.000 0.516
#> SRR949119     1  0.5226      0.224 0.572 0.000 0.000 0.052 0.376
#> SRR949120     1  0.5226      0.224 0.572 0.000 0.000 0.052 0.376
#> SRR949121     1  0.2471      0.631 0.864 0.000 0.000 0.000 0.136
#> SRR949122     1  0.1121      0.669 0.956 0.000 0.000 0.000 0.044
#> SRR949123     2  0.0162      0.904 0.000 0.996 0.000 0.000 0.004
#> SRR949124     2  0.0000      0.907 0.000 1.000 0.000 0.000 0.000
#> SRR949125     4  0.0162      0.895 0.000 0.000 0.004 0.996 0.000
#> SRR949126     4  0.0162      0.895 0.000 0.000 0.004 0.996 0.000
#> SRR949127     2  0.0609      0.903 0.000 0.980 0.000 0.000 0.020
#> SRR949128     2  0.0609      0.903 0.000 0.980 0.000 0.000 0.020
#> SRR949129     2  0.0609      0.903 0.000 0.980 0.000 0.000 0.020

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR949076     4  0.3482     0.5187 0.000 0.000 0.000 0.684 0.316 0.000
#> SRR949078     2  0.1528     0.9012 0.000 0.936 0.000 0.000 0.016 0.048
#> SRR949077     4  0.3672     0.4095 0.000 0.000 0.000 0.632 0.368 0.000
#> SRR949079     4  0.0146     0.8998 0.000 0.000 0.000 0.996 0.004 0.000
#> SRR949080     4  0.0146     0.8998 0.000 0.000 0.000 0.996 0.004 0.000
#> SRR949081     5  0.5964     0.4528 0.068 0.004 0.084 0.004 0.616 0.224
#> SRR949082     2  0.1124     0.9061 0.000 0.956 0.000 0.000 0.008 0.036
#> SRR949083     1  0.2331     0.7731 0.888 0.000 0.000 0.000 0.080 0.032
#> SRR949084     1  0.1753     0.7772 0.912 0.000 0.000 0.004 0.084 0.000
#> SRR949085     2  0.0000     0.9106 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949087     6  0.8678     0.1806 0.256 0.200 0.152 0.000 0.108 0.284
#> SRR949088     6  0.8678     0.1806 0.256 0.200 0.152 0.000 0.108 0.284
#> SRR949086     3  0.4947     0.5259 0.000 0.000 0.636 0.000 0.120 0.244
#> SRR949089     2  0.0000     0.9106 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949090     4  0.0520     0.8966 0.000 0.000 0.008 0.984 0.008 0.000
#> SRR949092     1  0.0260     0.8000 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR949093     1  0.0260     0.8000 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR949091     4  0.2269     0.8279 0.000 0.000 0.012 0.896 0.012 0.080
#> SRR949095     5  0.5637     0.4830 0.040 0.292 0.000 0.072 0.592 0.004
#> SRR949094     4  0.0000     0.9005 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949096     1  0.2362     0.7356 0.860 0.000 0.000 0.004 0.136 0.000
#> SRR949097     1  0.3103     0.7301 0.836 0.000 0.000 0.000 0.064 0.100
#> SRR949098     2  0.0000     0.9106 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949099     6  0.7327     0.1397 0.312 0.000 0.132 0.000 0.188 0.368
#> SRR949101     3  0.2833     0.6790 0.000 0.000 0.836 0.012 0.004 0.148
#> SRR949100     2  0.7169     0.0189 0.084 0.416 0.004 0.004 0.172 0.320
#> SRR949102     5  0.5683     0.5236 0.004 0.000 0.036 0.100 0.612 0.248
#> SRR949103     1  0.4148     0.6192 0.744 0.000 0.000 0.000 0.108 0.148
#> SRR949104     2  0.0000     0.9106 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949105     3  0.0000     0.7584 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949106     3  0.0000     0.7584 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949107     3  0.0000     0.7584 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949108     1  0.2191     0.7465 0.876 0.000 0.000 0.000 0.004 0.120
#> SRR949109     4  0.1049     0.8833 0.000 0.000 0.008 0.960 0.032 0.000
#> SRR949110     1  0.2837     0.7553 0.856 0.000 0.000 0.000 0.056 0.088
#> SRR949111     4  0.0291     0.9003 0.000 0.000 0.004 0.992 0.000 0.004
#> SRR949112     1  0.3684     0.4462 0.664 0.000 0.000 0.000 0.004 0.332
#> SRR949113     2  0.0000     0.9106 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949114     6  0.3898     0.2253 0.336 0.000 0.012 0.000 0.000 0.652
#> SRR949115     6  0.3898     0.2253 0.336 0.000 0.012 0.000 0.000 0.652
#> SRR949116     6  0.3898     0.2253 0.336 0.000 0.012 0.000 0.000 0.652
#> SRR949117     3  0.6255     0.2391 0.036 0.000 0.428 0.000 0.136 0.400
#> SRR949118     6  0.5517    -0.3986 0.000 0.000 0.396 0.000 0.132 0.472
#> SRR949119     5  0.3089     0.6408 0.188 0.000 0.000 0.008 0.800 0.004
#> SRR949120     5  0.3089     0.6408 0.188 0.000 0.000 0.008 0.800 0.004
#> SRR949121     1  0.1814     0.7701 0.900 0.000 0.000 0.000 0.000 0.100
#> SRR949122     1  0.2527     0.7016 0.832 0.000 0.000 0.000 0.000 0.168
#> SRR949123     2  0.2199     0.8243 0.000 0.892 0.000 0.000 0.020 0.088
#> SRR949124     2  0.0363     0.9051 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR949125     4  0.0146     0.9007 0.000 0.000 0.004 0.996 0.000 0.000
#> SRR949126     4  0.0146     0.9007 0.000 0.000 0.004 0.996 0.000 0.000
#> SRR949127     2  0.1682     0.8978 0.000 0.928 0.000 0.000 0.020 0.052
#> SRR949128     2  0.1682     0.8978 0.000 0.928 0.000 0.000 0.020 0.052
#> SRR949129     2  0.1594     0.8992 0.000 0.932 0.000 0.000 0.016 0.052

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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

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

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.858           0.954       0.980          0.262 0.743   0.743
#> 3 3 0.560           0.775       0.814          1.122 0.655   0.536
#> 4 4 0.539           0.651       0.775          0.109 0.980   0.951
#> 5 5 0.590           0.820       0.786          0.116 0.869   0.655
#> 6 6 0.896           0.899       0.945          0.132 0.964   0.854

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
#> SRR949076     1  0.0000      0.984 1.000 0.000
#> SRR949078     1  0.5737      0.849 0.864 0.136
#> SRR949077     1  0.0000      0.984 1.000 0.000
#> SRR949079     1  0.0000      0.984 1.000 0.000
#> SRR949080     1  0.0000      0.984 1.000 0.000
#> SRR949081     1  0.0000      0.984 1.000 0.000
#> SRR949082     2  0.9732      0.286 0.404 0.596
#> SRR949083     1  0.0000      0.984 1.000 0.000
#> SRR949084     1  0.0000      0.984 1.000 0.000
#> SRR949085     2  0.0000      0.939 0.000 1.000
#> SRR949087     1  0.1843      0.962 0.972 0.028
#> SRR949088     1  0.1843      0.962 0.972 0.028
#> SRR949086     1  0.0000      0.984 1.000 0.000
#> SRR949089     2  0.0000      0.939 0.000 1.000
#> SRR949090     1  0.0000      0.984 1.000 0.000
#> SRR949092     1  0.0000      0.984 1.000 0.000
#> SRR949093     1  0.0000      0.984 1.000 0.000
#> SRR949091     1  0.0000      0.984 1.000 0.000
#> SRR949095     1  0.3274      0.933 0.940 0.060
#> SRR949094     1  0.0000      0.984 1.000 0.000
#> SRR949096     1  0.0000      0.984 1.000 0.000
#> SRR949097     1  0.0000      0.984 1.000 0.000
#> SRR949098     2  0.0000      0.939 0.000 1.000
#> SRR949099     1  0.0000      0.984 1.000 0.000
#> SRR949101     1  0.0000      0.984 1.000 0.000
#> SRR949100     1  0.0376      0.981 0.996 0.004
#> SRR949102     1  0.0000      0.984 1.000 0.000
#> SRR949103     1  0.0000      0.984 1.000 0.000
#> SRR949104     2  0.0000      0.939 0.000 1.000
#> SRR949105     1  0.0000      0.984 1.000 0.000
#> SRR949106     1  0.0000      0.984 1.000 0.000
#> SRR949107     1  0.0000      0.984 1.000 0.000
#> SRR949108     1  0.0000      0.984 1.000 0.000
#> SRR949109     1  0.0000      0.984 1.000 0.000
#> SRR949110     1  0.0000      0.984 1.000 0.000
#> SRR949111     1  0.0000      0.984 1.000 0.000
#> SRR949112     1  0.0000      0.984 1.000 0.000
#> SRR949113     2  0.0000      0.939 0.000 1.000
#> SRR949114     1  0.0000      0.984 1.000 0.000
#> SRR949115     1  0.0000      0.984 1.000 0.000
#> SRR949116     1  0.0000      0.984 1.000 0.000
#> SRR949117     1  0.0000      0.984 1.000 0.000
#> SRR949118     1  0.0000      0.984 1.000 0.000
#> SRR949119     1  0.0000      0.984 1.000 0.000
#> SRR949120     1  0.0000      0.984 1.000 0.000
#> SRR949121     1  0.0000      0.984 1.000 0.000
#> SRR949122     1  0.0000      0.984 1.000 0.000
#> SRR949123     2  0.0376      0.937 0.004 0.996
#> SRR949124     2  0.0000      0.939 0.000 1.000
#> SRR949125     1  0.0000      0.984 1.000 0.000
#> SRR949126     1  0.0000      0.984 1.000 0.000
#> SRR949127     1  0.5737      0.849 0.864 0.136
#> SRR949128     1  0.5737      0.849 0.864 0.136
#> SRR949129     1  0.5737      0.849 0.864 0.136

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR949076     1  0.1031      0.666 0.976 0.000 0.024
#> SRR949078     3  0.4277      0.858 0.016 0.132 0.852
#> SRR949077     1  0.1031      0.666 0.976 0.000 0.024
#> SRR949079     1  0.1031      0.666 0.976 0.000 0.024
#> SRR949080     1  0.1031      0.666 0.976 0.000 0.024
#> SRR949081     3  0.1860      0.938 0.052 0.000 0.948
#> SRR949082     2  0.6359      0.199 0.004 0.592 0.404
#> SRR949083     1  0.6180      0.689 0.584 0.000 0.416
#> SRR949084     1  0.6180      0.689 0.584 0.000 0.416
#> SRR949085     2  0.0000      0.934 0.000 1.000 0.000
#> SRR949087     3  0.2773      0.933 0.048 0.024 0.928
#> SRR949088     3  0.2773      0.933 0.048 0.024 0.928
#> SRR949086     3  0.1860      0.938 0.052 0.000 0.948
#> SRR949089     2  0.0000      0.934 0.000 1.000 0.000
#> SRR949090     1  0.1031      0.666 0.976 0.000 0.024
#> SRR949092     1  0.6180      0.689 0.584 0.000 0.416
#> SRR949093     1  0.6180      0.689 0.584 0.000 0.416
#> SRR949091     1  0.1031      0.666 0.976 0.000 0.024
#> SRR949095     1  0.2448      0.631 0.924 0.000 0.076
#> SRR949094     1  0.3038      0.671 0.896 0.000 0.104
#> SRR949096     1  0.6180      0.689 0.584 0.000 0.416
#> SRR949097     1  0.6180      0.689 0.584 0.000 0.416
#> SRR949098     2  0.0000      0.934 0.000 1.000 0.000
#> SRR949099     3  0.1860      0.938 0.052 0.000 0.948
#> SRR949101     3  0.1529      0.934 0.040 0.000 0.960
#> SRR949100     3  0.1753      0.939 0.048 0.000 0.952
#> SRR949102     3  0.2796      0.886 0.092 0.000 0.908
#> SRR949103     1  0.6180      0.689 0.584 0.000 0.416
#> SRR949104     2  0.0000      0.934 0.000 1.000 0.000
#> SRR949105     3  0.1411      0.936 0.036 0.000 0.964
#> SRR949106     3  0.1411      0.936 0.036 0.000 0.964
#> SRR949107     3  0.1411      0.936 0.036 0.000 0.964
#> SRR949108     1  0.6180      0.689 0.584 0.000 0.416
#> SRR949109     1  0.1031      0.666 0.976 0.000 0.024
#> SRR949110     1  0.6180      0.689 0.584 0.000 0.416
#> SRR949111     1  0.1031      0.666 0.976 0.000 0.024
#> SRR949112     1  0.6215      0.672 0.572 0.000 0.428
#> SRR949113     2  0.0237      0.932 0.000 0.996 0.004
#> SRR949114     1  0.6225      0.666 0.568 0.000 0.432
#> SRR949115     1  0.6225      0.666 0.568 0.000 0.432
#> SRR949116     1  0.6225      0.666 0.568 0.000 0.432
#> SRR949117     3  0.1860      0.938 0.052 0.000 0.948
#> SRR949118     3  0.1860      0.938 0.052 0.000 0.948
#> SRR949119     1  0.6180      0.689 0.584 0.000 0.416
#> SRR949120     1  0.6180      0.689 0.584 0.000 0.416
#> SRR949121     1  0.6180      0.689 0.584 0.000 0.416
#> SRR949122     1  0.6215      0.672 0.572 0.000 0.428
#> SRR949123     2  0.0237      0.931 0.000 0.996 0.004
#> SRR949124     2  0.0000      0.934 0.000 1.000 0.000
#> SRR949125     1  0.1031      0.666 0.976 0.000 0.024
#> SRR949126     1  0.1031      0.666 0.976 0.000 0.024
#> SRR949127     3  0.4277      0.858 0.016 0.132 0.852
#> SRR949128     3  0.4277      0.858 0.016 0.132 0.852
#> SRR949129     3  0.4277      0.858 0.016 0.132 0.852

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR949076     1  0.4999      0.364 0.508 0.000 0.000 0.492
#> SRR949078     3  0.7182      0.802 0.356 0.128 0.512 0.004
#> SRR949077     1  0.4999      0.364 0.508 0.000 0.000 0.492
#> SRR949079     1  0.4999      0.364 0.508 0.000 0.000 0.492
#> SRR949080     1  0.4999      0.364 0.508 0.000 0.000 0.492
#> SRR949081     3  0.4925      0.837 0.428 0.000 0.572 0.000
#> SRR949082     2  0.7088      0.159 0.196 0.588 0.212 0.004
#> SRR949083     1  0.0000      0.690 1.000 0.000 0.000 0.000
#> SRR949084     1  0.0000      0.690 1.000 0.000 0.000 0.000
#> SRR949085     2  0.0188      0.894 0.000 0.996 0.004 0.000
#> SRR949087     3  0.5706      0.837 0.420 0.020 0.556 0.004
#> SRR949088     3  0.5706      0.837 0.420 0.020 0.556 0.004
#> SRR949086     3  0.4916      0.839 0.424 0.000 0.576 0.000
#> SRR949089     2  0.0188      0.894 0.000 0.996 0.004 0.000
#> SRR949090     1  0.4999      0.364 0.508 0.000 0.000 0.492
#> SRR949092     1  0.0000      0.690 1.000 0.000 0.000 0.000
#> SRR949093     1  0.0000      0.690 1.000 0.000 0.000 0.000
#> SRR949091     1  0.4999      0.364 0.508 0.000 0.000 0.492
#> SRR949095     4  0.5119      0.000 0.112 0.000 0.124 0.764
#> SRR949094     1  0.4817      0.430 0.612 0.000 0.000 0.388
#> SRR949096     1  0.0000      0.690 1.000 0.000 0.000 0.000
#> SRR949097     1  0.0000      0.690 1.000 0.000 0.000 0.000
#> SRR949098     2  0.0188      0.894 0.000 0.996 0.004 0.000
#> SRR949099     3  0.4916      0.839 0.424 0.000 0.576 0.000
#> SRR949101     3  0.3392      0.580 0.124 0.000 0.856 0.020
#> SRR949100     3  0.5088      0.839 0.424 0.000 0.572 0.004
#> SRR949102     3  0.5158      0.776 0.472 0.000 0.524 0.004
#> SRR949103     1  0.0000      0.690 1.000 0.000 0.000 0.000
#> SRR949104     2  0.0336      0.891 0.000 0.992 0.000 0.008
#> SRR949105     3  0.3280      0.585 0.124 0.000 0.860 0.016
#> SRR949106     3  0.3280      0.585 0.124 0.000 0.860 0.016
#> SRR949107     3  0.3280      0.585 0.124 0.000 0.860 0.016
#> SRR949108     1  0.0000      0.690 1.000 0.000 0.000 0.000
#> SRR949109     1  0.4999      0.364 0.508 0.000 0.000 0.492
#> SRR949110     1  0.0000      0.690 1.000 0.000 0.000 0.000
#> SRR949111     1  0.4999      0.364 0.508 0.000 0.000 0.492
#> SRR949112     1  0.0592      0.677 0.984 0.000 0.016 0.000
#> SRR949113     2  0.0376      0.891 0.000 0.992 0.004 0.004
#> SRR949114     1  0.0707      0.672 0.980 0.000 0.020 0.000
#> SRR949115     1  0.0707      0.672 0.980 0.000 0.020 0.000
#> SRR949116     1  0.0707      0.672 0.980 0.000 0.020 0.000
#> SRR949117     3  0.4916      0.839 0.424 0.000 0.576 0.000
#> SRR949118     3  0.4916      0.839 0.424 0.000 0.576 0.000
#> SRR949119     1  0.0188      0.690 0.996 0.000 0.000 0.004
#> SRR949120     1  0.0188      0.690 0.996 0.000 0.000 0.004
#> SRR949121     1  0.0000      0.690 1.000 0.000 0.000 0.000
#> SRR949122     1  0.0592      0.677 0.984 0.000 0.016 0.000
#> SRR949123     2  0.0524      0.888 0.004 0.988 0.000 0.008
#> SRR949124     2  0.0336      0.891 0.000 0.992 0.000 0.008
#> SRR949125     1  0.4999      0.364 0.508 0.000 0.000 0.492
#> SRR949126     1  0.4999      0.364 0.508 0.000 0.000 0.492
#> SRR949127     3  0.7182      0.802 0.356 0.128 0.512 0.004
#> SRR949128     3  0.7182      0.802 0.356 0.128 0.512 0.004
#> SRR949129     3  0.7182      0.802 0.356 0.128 0.512 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR949076     4  0.3752      0.984 0.292 0.000 0.000 0.708 0.000
#> SRR949078     3  0.5731      0.733 0.236 0.132 0.628 0.000 0.004
#> SRR949077     4  0.3752      0.984 0.292 0.000 0.000 0.708 0.000
#> SRR949079     4  0.3752      0.984 0.292 0.000 0.000 0.708 0.000
#> SRR949080     4  0.3752      0.984 0.292 0.000 0.000 0.708 0.000
#> SRR949081     3  0.3876      0.771 0.316 0.000 0.684 0.000 0.000
#> SRR949082     2  0.5624      0.194 0.084 0.592 0.320 0.000 0.004
#> SRR949083     1  0.0000      0.980 1.000 0.000 0.000 0.000 0.000
#> SRR949084     1  0.0000      0.980 1.000 0.000 0.000 0.000 0.000
#> SRR949085     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000
#> SRR949087     3  0.4597      0.774 0.300 0.024 0.672 0.000 0.004
#> SRR949088     3  0.4597      0.774 0.300 0.024 0.672 0.000 0.004
#> SRR949086     3  0.3837      0.776 0.308 0.000 0.692 0.000 0.000
#> SRR949089     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000
#> SRR949090     4  0.3752      0.984 0.292 0.000 0.000 0.708 0.000
#> SRR949092     1  0.0000      0.980 1.000 0.000 0.000 0.000 0.000
#> SRR949093     1  0.0000      0.980 1.000 0.000 0.000 0.000 0.000
#> SRR949091     4  0.3752      0.984 0.292 0.000 0.000 0.708 0.000
#> SRR949095     5  0.0486      0.000 0.004 0.000 0.004 0.004 0.988
#> SRR949094     4  0.4331      0.825 0.400 0.000 0.004 0.596 0.000
#> SRR949096     1  0.0000      0.980 1.000 0.000 0.000 0.000 0.000
#> SRR949097     1  0.0000      0.980 1.000 0.000 0.000 0.000 0.000
#> SRR949098     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000
#> SRR949099     3  0.3837      0.776 0.308 0.000 0.692 0.000 0.000
#> SRR949101     3  0.4111      0.211 0.008 0.000 0.708 0.280 0.004
#> SRR949100     3  0.3990      0.776 0.308 0.000 0.688 0.000 0.004
#> SRR949102     3  0.4482      0.713 0.348 0.000 0.636 0.016 0.000
#> SRR949103     1  0.0000      0.980 1.000 0.000 0.000 0.000 0.000
#> SRR949104     2  0.0798      0.881 0.000 0.976 0.000 0.016 0.008
#> SRR949105     3  0.3968      0.217 0.004 0.000 0.716 0.276 0.004
#> SRR949106     3  0.3968      0.217 0.004 0.000 0.716 0.276 0.004
#> SRR949107     3  0.3968      0.217 0.004 0.000 0.716 0.276 0.004
#> SRR949108     1  0.0000      0.980 1.000 0.000 0.000 0.000 0.000
#> SRR949109     4  0.3752      0.984 0.292 0.000 0.000 0.708 0.000
#> SRR949110     1  0.0000      0.980 1.000 0.000 0.000 0.000 0.000
#> SRR949111     4  0.3752      0.984 0.292 0.000 0.000 0.708 0.000
#> SRR949112     1  0.0794      0.962 0.972 0.000 0.028 0.000 0.000
#> SRR949113     2  0.0162      0.885 0.000 0.996 0.000 0.000 0.004
#> SRR949114     1  0.0963      0.955 0.964 0.000 0.036 0.000 0.000
#> SRR949115     1  0.0963      0.955 0.964 0.000 0.036 0.000 0.000
#> SRR949116     1  0.0963      0.955 0.964 0.000 0.036 0.000 0.000
#> SRR949117     3  0.3837      0.776 0.308 0.000 0.692 0.000 0.000
#> SRR949118     3  0.3837      0.776 0.308 0.000 0.692 0.000 0.000
#> SRR949119     1  0.0671      0.958 0.980 0.000 0.004 0.016 0.000
#> SRR949120     1  0.0671      0.958 0.980 0.000 0.004 0.016 0.000
#> SRR949121     1  0.0000      0.980 1.000 0.000 0.000 0.000 0.000
#> SRR949122     1  0.0794      0.962 0.972 0.000 0.028 0.000 0.000
#> SRR949123     2  0.0912      0.879 0.000 0.972 0.000 0.016 0.012
#> SRR949124     2  0.0798      0.881 0.000 0.976 0.000 0.016 0.008
#> SRR949125     4  0.3752      0.984 0.292 0.000 0.000 0.708 0.000
#> SRR949126     4  0.3752      0.984 0.292 0.000 0.000 0.708 0.000
#> SRR949127     3  0.5731      0.733 0.236 0.132 0.628 0.000 0.004
#> SRR949128     3  0.5731      0.733 0.236 0.132 0.628 0.000 0.004
#> SRR949129     3  0.5731      0.733 0.236 0.132 0.628 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
#> SRR949076     4  0.0000      0.982 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR949078     5  0.4090      0.852 0.064 0.108 0.040 0.00 0.788 0.000
#> SRR949077     4  0.0000      0.982 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR949079     4  0.0000      0.982 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR949080     4  0.0000      0.982 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR949081     5  0.2361      0.887 0.088 0.000 0.028 0.00 0.884 0.000
#> SRR949082     2  0.5282      0.231 0.040 0.568 0.040 0.00 0.352 0.000
#> SRR949083     1  0.0000      0.977 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR949084     1  0.0000      0.977 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR949085     2  0.0632      0.890 0.000 0.976 0.000 0.00 0.024 0.000
#> SRR949087     5  0.2250      0.893 0.064 0.000 0.040 0.00 0.896 0.000
#> SRR949088     5  0.2250      0.893 0.064 0.000 0.040 0.00 0.896 0.000
#> SRR949086     5  0.2088      0.898 0.068 0.000 0.028 0.00 0.904 0.000
#> SRR949089     2  0.0632      0.890 0.000 0.976 0.000 0.00 0.024 0.000
#> SRR949090     4  0.0000      0.982 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR949092     1  0.0000      0.977 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR949093     1  0.0000      0.977 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR949091     4  0.0000      0.982 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR949095     6  0.0000      0.000 0.000 0.000 0.000 0.00 0.000 1.000
#> SRR949094     4  0.2146      0.805 0.116 0.000 0.000 0.88 0.004 0.000
#> SRR949096     1  0.0000      0.977 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR949097     1  0.0000      0.977 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR949098     2  0.0632      0.890 0.000 0.976 0.000 0.00 0.024 0.000
#> SRR949099     5  0.2088      0.898 0.068 0.000 0.028 0.00 0.904 0.000
#> SRR949101     3  0.1327      0.912 0.000 0.000 0.936 0.00 0.064 0.000
#> SRR949100     5  0.1926      0.899 0.068 0.000 0.020 0.00 0.912 0.000
#> SRR949102     5  0.3293      0.710 0.140 0.000 0.048 0.00 0.812 0.000
#> SRR949103     1  0.0000      0.977 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR949104     2  0.0547      0.880 0.000 0.980 0.020 0.00 0.000 0.000
#> SRR949105     3  0.0713      0.971 0.000 0.000 0.972 0.00 0.028 0.000
#> SRR949106     3  0.0713      0.971 0.000 0.000 0.972 0.00 0.028 0.000
#> SRR949107     3  0.0713      0.971 0.000 0.000 0.972 0.00 0.028 0.000
#> SRR949108     1  0.0000      0.977 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR949109     4  0.0000      0.982 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR949110     1  0.0000      0.977 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR949111     4  0.0000      0.982 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR949112     1  0.0713      0.962 0.972 0.000 0.000 0.00 0.028 0.000
#> SRR949113     2  0.0713      0.887 0.000 0.972 0.000 0.00 0.028 0.000
#> SRR949114     1  0.0865      0.957 0.964 0.000 0.000 0.00 0.036 0.000
#> SRR949115     1  0.0865      0.957 0.964 0.000 0.000 0.00 0.036 0.000
#> SRR949116     1  0.0865      0.957 0.964 0.000 0.000 0.00 0.036 0.000
#> SRR949117     5  0.2009      0.899 0.068 0.000 0.024 0.00 0.908 0.000
#> SRR949118     5  0.2088      0.898 0.068 0.000 0.028 0.00 0.904 0.000
#> SRR949119     1  0.1327      0.911 0.936 0.000 0.000 0.00 0.064 0.000
#> SRR949120     1  0.1327      0.911 0.936 0.000 0.000 0.00 0.064 0.000
#> SRR949121     1  0.0000      0.977 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR949122     1  0.0713      0.962 0.972 0.000 0.000 0.00 0.028 0.000
#> SRR949123     2  0.0692      0.879 0.000 0.976 0.020 0.00 0.000 0.004
#> SRR949124     2  0.0547      0.880 0.000 0.980 0.020 0.00 0.000 0.000
#> SRR949125     4  0.0000      0.982 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR949126     4  0.0000      0.982 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR949127     5  0.4090      0.852 0.064 0.108 0.040 0.00 0.788 0.000
#> SRR949128     5  0.4090      0.852 0.064 0.108 0.040 0.00 0.788 0.000
#> SRR949129     5  0.4090      0.852 0.064 0.108 0.040 0.00 0.788 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-hclust-collect-classes

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 16816 rows and 54 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 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-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.341           0.685       0.811          0.394 0.591   0.591
#> 3 3 0.346           0.555       0.693          0.500 0.678   0.499
#> 4 4 0.581           0.803       0.810          0.188 0.826   0.559
#> 5 5 0.801           0.748       0.808          0.098 0.964   0.857
#> 6 6 0.781           0.641       0.792          0.044 0.981   0.914

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
#> SRR949076     1  0.7674      0.705 0.776 0.224
#> SRR949078     2  0.8661      0.871 0.288 0.712
#> SRR949077     1  0.7602      0.704 0.780 0.220
#> SRR949079     1  0.7674      0.705 0.776 0.224
#> SRR949080     1  0.7674      0.705 0.776 0.224
#> SRR949081     1  0.7950      0.478 0.760 0.240
#> SRR949082     2  0.8661      0.871 0.288 0.712
#> SRR949083     1  0.0672      0.793 0.992 0.008
#> SRR949084     1  0.0672      0.793 0.992 0.008
#> SRR949085     2  0.8386      0.872 0.268 0.732
#> SRR949087     1  0.9993     -0.483 0.516 0.484
#> SRR949088     1  0.9993     -0.483 0.516 0.484
#> SRR949086     1  0.7674      0.510 0.776 0.224
#> SRR949089     2  0.8267      0.874 0.260 0.740
#> SRR949090     1  0.7674      0.705 0.776 0.224
#> SRR949092     1  0.0672      0.793 0.992 0.008
#> SRR949093     1  0.0672      0.793 0.992 0.008
#> SRR949091     1  0.7745      0.702 0.772 0.228
#> SRR949095     1  0.3879      0.759 0.924 0.076
#> SRR949094     1  0.7528      0.703 0.784 0.216
#> SRR949096     1  0.1184      0.792 0.984 0.016
#> SRR949097     1  0.0672      0.793 0.992 0.008
#> SRR949098     2  0.8267      0.874 0.260 0.740
#> SRR949099     1  0.2603      0.780 0.956 0.044
#> SRR949101     1  0.8955      0.487 0.688 0.312
#> SRR949100     1  0.3584      0.758 0.932 0.068
#> SRR949102     1  0.6148      0.667 0.848 0.152
#> SRR949103     1  0.0000      0.793 1.000 0.000
#> SRR949104     2  0.8267      0.874 0.260 0.740
#> SRR949105     2  0.9993      0.283 0.484 0.516
#> SRR949106     2  0.9993      0.283 0.484 0.516
#> SRR949107     2  0.9993      0.283 0.484 0.516
#> SRR949108     1  0.0672      0.793 0.992 0.008
#> SRR949109     1  0.7674      0.705 0.776 0.224
#> SRR949110     1  0.0672      0.793 0.992 0.008
#> SRR949111     1  0.7674      0.705 0.776 0.224
#> SRR949112     1  0.1633      0.785 0.976 0.024
#> SRR949113     2  0.8267      0.874 0.260 0.740
#> SRR949114     1  0.2236      0.781 0.964 0.036
#> SRR949115     1  0.2236      0.781 0.964 0.036
#> SRR949116     1  0.2236      0.781 0.964 0.036
#> SRR949117     1  0.7815      0.503 0.768 0.232
#> SRR949118     1  0.7674      0.510 0.776 0.224
#> SRR949119     1  0.1633      0.788 0.976 0.024
#> SRR949120     1  0.1633      0.788 0.976 0.024
#> SRR949121     1  0.0672      0.793 0.992 0.008
#> SRR949122     1  0.0672      0.793 0.992 0.008
#> SRR949123     2  0.8267      0.874 0.260 0.740
#> SRR949124     2  0.8267      0.874 0.260 0.740
#> SRR949125     1  0.7674      0.705 0.776 0.224
#> SRR949126     1  0.7674      0.705 0.776 0.224
#> SRR949127     2  0.8713      0.870 0.292 0.708
#> SRR949128     2  0.8713      0.870 0.292 0.708
#> SRR949129     2  0.8713      0.870 0.292 0.708

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR949076     1  0.0237      0.821 0.996 0.004 0.000
#> SRR949078     2  0.4261      0.922 0.012 0.848 0.140
#> SRR949077     1  0.0237      0.821 0.996 0.004 0.000
#> SRR949079     1  0.0237      0.821 0.996 0.004 0.000
#> SRR949080     1  0.0237      0.821 0.996 0.004 0.000
#> SRR949081     3  0.7256      0.455 0.164 0.124 0.712
#> SRR949082     2  0.4326      0.917 0.012 0.844 0.144
#> SRR949083     3  0.7665      0.392 0.456 0.044 0.500
#> SRR949084     3  0.7665      0.392 0.456 0.044 0.500
#> SRR949085     2  0.2261      0.940 0.000 0.932 0.068
#> SRR949087     3  0.8037      0.152 0.076 0.352 0.572
#> SRR949088     3  0.8037      0.152 0.076 0.352 0.572
#> SRR949086     3  0.6757      0.468 0.180 0.084 0.736
#> SRR949089     2  0.1647      0.943 0.004 0.960 0.036
#> SRR949090     1  0.0237      0.821 0.996 0.004 0.000
#> SRR949092     3  0.7665      0.392 0.456 0.044 0.500
#> SRR949093     3  0.7665      0.392 0.456 0.044 0.500
#> SRR949091     1  0.1267      0.787 0.972 0.004 0.024
#> SRR949095     1  0.8849     -0.217 0.556 0.152 0.292
#> SRR949094     1  0.0237      0.814 0.996 0.000 0.004
#> SRR949096     3  0.7665      0.392 0.456 0.044 0.500
#> SRR949097     3  0.7665      0.392 0.456 0.044 0.500
#> SRR949098     2  0.1647      0.943 0.004 0.960 0.036
#> SRR949099     3  0.4399      0.464 0.188 0.000 0.812
#> SRR949101     3  0.8668      0.310 0.304 0.132 0.564
#> SRR949100     3  0.8464      0.457 0.280 0.128 0.592
#> SRR949102     3  0.7180      0.448 0.196 0.096 0.708
#> SRR949103     3  0.7665      0.392 0.456 0.044 0.500
#> SRR949104     2  0.1647      0.943 0.004 0.960 0.036
#> SRR949105     3  0.8322      0.219 0.124 0.268 0.608
#> SRR949106     3  0.8322      0.219 0.124 0.268 0.608
#> SRR949107     3  0.8322      0.219 0.124 0.268 0.608
#> SRR949108     3  0.7665      0.392 0.456 0.044 0.500
#> SRR949109     1  0.0237      0.821 0.996 0.004 0.000
#> SRR949110     3  0.7665      0.392 0.456 0.044 0.500
#> SRR949111     1  0.0237      0.821 0.996 0.004 0.000
#> SRR949112     3  0.7634      0.405 0.432 0.044 0.524
#> SRR949113     2  0.1647      0.943 0.004 0.960 0.036
#> SRR949114     3  0.7395      0.434 0.380 0.040 0.580
#> SRR949115     3  0.7395      0.434 0.380 0.040 0.580
#> SRR949116     3  0.7395      0.434 0.380 0.040 0.580
#> SRR949117     3  0.6783      0.471 0.176 0.088 0.736
#> SRR949118     3  0.6728      0.469 0.184 0.080 0.736
#> SRR949119     1  0.7466     -0.260 0.520 0.036 0.444
#> SRR949120     1  0.7466     -0.260 0.520 0.036 0.444
#> SRR949121     3  0.7665      0.392 0.456 0.044 0.500
#> SRR949122     3  0.7665      0.392 0.456 0.044 0.500
#> SRR949123     2  0.1765      0.942 0.004 0.956 0.040
#> SRR949124     2  0.1647      0.943 0.004 0.960 0.036
#> SRR949125     1  0.0424      0.819 0.992 0.008 0.000
#> SRR949126     1  0.0424      0.819 0.992 0.008 0.000
#> SRR949127     2  0.4261      0.922 0.012 0.848 0.140
#> SRR949128     2  0.4261      0.922 0.012 0.848 0.140
#> SRR949129     2  0.4261      0.922 0.012 0.848 0.140

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR949076     4  0.0804      0.921 0.012 0.000 0.008 0.980
#> SRR949078     2  0.5186      0.841 0.084 0.752 0.164 0.000
#> SRR949077     4  0.0804      0.921 0.012 0.000 0.008 0.980
#> SRR949079     4  0.1174      0.920 0.012 0.000 0.020 0.968
#> SRR949080     4  0.1174      0.920 0.012 0.000 0.020 0.968
#> SRR949081     3  0.5926      0.734 0.304 0.020 0.648 0.028
#> SRR949082     2  0.5186      0.841 0.084 0.752 0.164 0.000
#> SRR949083     1  0.3356      0.918 0.824 0.000 0.000 0.176
#> SRR949084     1  0.3356      0.918 0.824 0.000 0.000 0.176
#> SRR949085     2  0.3009      0.874 0.056 0.892 0.052 0.000
#> SRR949087     3  0.7382      0.570 0.248 0.204 0.544 0.004
#> SRR949088     3  0.7382      0.570 0.248 0.204 0.544 0.004
#> SRR949086     3  0.5944      0.735 0.328 0.016 0.628 0.028
#> SRR949089     2  0.0469      0.881 0.012 0.988 0.000 0.000
#> SRR949090     4  0.1042      0.920 0.008 0.000 0.020 0.972
#> SRR949092     1  0.3356      0.918 0.824 0.000 0.000 0.176
#> SRR949093     1  0.3356      0.918 0.824 0.000 0.000 0.176
#> SRR949091     4  0.1174      0.910 0.012 0.000 0.020 0.968
#> SRR949095     4  0.8607     -0.344 0.308 0.028 0.308 0.356
#> SRR949094     4  0.0469      0.921 0.012 0.000 0.000 0.988
#> SRR949096     1  0.3356      0.918 0.824 0.000 0.000 0.176
#> SRR949097     1  0.3356      0.918 0.824 0.000 0.000 0.176
#> SRR949098     2  0.0469      0.881 0.012 0.988 0.000 0.000
#> SRR949099     3  0.5495      0.715 0.348 0.000 0.624 0.028
#> SRR949101     3  0.6777      0.628 0.140 0.024 0.664 0.172
#> SRR949100     3  0.6849      0.661 0.344 0.020 0.568 0.068
#> SRR949102     3  0.6017      0.734 0.308 0.016 0.640 0.036
#> SRR949103     1  0.3356      0.918 0.824 0.000 0.000 0.176
#> SRR949104     2  0.1124      0.878 0.012 0.972 0.012 0.004
#> SRR949105     3  0.7129      0.618 0.160 0.108 0.664 0.068
#> SRR949106     3  0.7129      0.618 0.160 0.108 0.664 0.068
#> SRR949107     3  0.7129      0.618 0.160 0.108 0.664 0.068
#> SRR949108     1  0.3356      0.918 0.824 0.000 0.000 0.176
#> SRR949109     4  0.0804      0.919 0.008 0.000 0.012 0.980
#> SRR949110     1  0.3356      0.918 0.824 0.000 0.000 0.176
#> SRR949111     4  0.0469      0.921 0.012 0.000 0.000 0.988
#> SRR949112     1  0.3208      0.894 0.848 0.000 0.004 0.148
#> SRR949113     2  0.0469      0.881 0.012 0.988 0.000 0.000
#> SRR949114     1  0.5897      0.678 0.700 0.000 0.164 0.136
#> SRR949115     1  0.5897      0.678 0.700 0.000 0.164 0.136
#> SRR949116     1  0.5897      0.678 0.700 0.000 0.164 0.136
#> SRR949117     3  0.5889      0.727 0.340 0.012 0.620 0.028
#> SRR949118     3  0.5944      0.735 0.328 0.016 0.628 0.028
#> SRR949119     1  0.5727      0.784 0.704 0.000 0.096 0.200
#> SRR949120     1  0.5727      0.784 0.704 0.000 0.096 0.200
#> SRR949121     1  0.3356      0.918 0.824 0.000 0.000 0.176
#> SRR949122     1  0.3356      0.918 0.824 0.000 0.000 0.176
#> SRR949123     2  0.1362      0.876 0.020 0.964 0.012 0.004
#> SRR949124     2  0.1124      0.878 0.012 0.972 0.012 0.004
#> SRR949125     4  0.1545      0.912 0.008 0.000 0.040 0.952
#> SRR949126     4  0.1545      0.912 0.008 0.000 0.040 0.952
#> SRR949127     2  0.5229      0.839 0.084 0.748 0.168 0.000
#> SRR949128     2  0.5229      0.839 0.084 0.748 0.168 0.000
#> SRR949129     2  0.5229      0.839 0.084 0.748 0.168 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
#> SRR949076     4  0.1732      0.982 0.080 0.000 0.000 0.920 0.000
#> SRR949078     2  0.6240      0.700 0.024 0.580 0.288 0.000 0.108
#> SRR949077     4  0.1892      0.981 0.080 0.000 0.000 0.916 0.004
#> SRR949079     4  0.2490      0.975 0.080 0.000 0.020 0.896 0.004
#> SRR949080     4  0.2490      0.975 0.080 0.000 0.020 0.896 0.004
#> SRR949081     5  0.2400      0.596 0.020 0.000 0.048 0.020 0.912
#> SRR949082     2  0.6240      0.700 0.024 0.580 0.288 0.000 0.108
#> SRR949083     1  0.0955      0.860 0.968 0.000 0.028 0.000 0.004
#> SRR949084     1  0.0290      0.857 0.992 0.000 0.008 0.000 0.000
#> SRR949085     2  0.3742      0.751 0.004 0.788 0.188 0.000 0.020
#> SRR949087     5  0.6365      0.230 0.052 0.080 0.280 0.000 0.588
#> SRR949088     5  0.6365      0.230 0.052 0.080 0.280 0.000 0.588
#> SRR949086     5  0.1830      0.617 0.052 0.000 0.004 0.012 0.932
#> SRR949089     2  0.0162      0.765 0.004 0.996 0.000 0.000 0.000
#> SRR949090     4  0.2052      0.981 0.080 0.000 0.004 0.912 0.004
#> SRR949092     1  0.0955      0.860 0.968 0.000 0.028 0.000 0.004
#> SRR949093     1  0.0955      0.860 0.968 0.000 0.028 0.000 0.004
#> SRR949091     4  0.2166      0.976 0.072 0.000 0.012 0.912 0.004
#> SRR949095     5  0.7858      0.146 0.140 0.004 0.144 0.228 0.484
#> SRR949094     4  0.1732      0.982 0.080 0.000 0.000 0.920 0.000
#> SRR949096     1  0.0963      0.857 0.964 0.000 0.036 0.000 0.000
#> SRR949097     1  0.0955      0.860 0.968 0.000 0.028 0.000 0.004
#> SRR949098     2  0.0162      0.765 0.004 0.996 0.000 0.000 0.000
#> SRR949099     5  0.1809      0.619 0.060 0.000 0.000 0.012 0.928
#> SRR949101     5  0.4883      0.252 0.020 0.000 0.128 0.100 0.752
#> SRR949100     5  0.3920      0.544 0.052 0.008 0.108 0.008 0.824
#> SRR949102     5  0.2581      0.589 0.020 0.000 0.048 0.028 0.904
#> SRR949103     1  0.0955      0.860 0.968 0.000 0.028 0.000 0.004
#> SRR949104     2  0.1356      0.756 0.004 0.956 0.028 0.012 0.000
#> SRR949105     3  0.6990      1.000 0.036 0.020 0.440 0.080 0.424
#> SRR949106     3  0.6990      1.000 0.036 0.020 0.440 0.080 0.424
#> SRR949107     3  0.6990      1.000 0.036 0.020 0.440 0.080 0.424
#> SRR949108     1  0.0290      0.857 0.992 0.000 0.008 0.000 0.000
#> SRR949109     4  0.2130      0.980 0.080 0.000 0.012 0.908 0.000
#> SRR949110     1  0.0162      0.860 0.996 0.000 0.000 0.000 0.004
#> SRR949111     4  0.2017      0.980 0.080 0.000 0.008 0.912 0.000
#> SRR949112     1  0.0798      0.853 0.976 0.000 0.016 0.000 0.008
#> SRR949113     2  0.0162      0.765 0.004 0.996 0.000 0.000 0.000
#> SRR949114     1  0.5933      0.427 0.584 0.000 0.096 0.012 0.308
#> SRR949115     1  0.5933      0.427 0.584 0.000 0.096 0.012 0.308
#> SRR949116     1  0.5933      0.427 0.584 0.000 0.096 0.012 0.308
#> SRR949117     5  0.2115      0.611 0.068 0.000 0.008 0.008 0.916
#> SRR949118     5  0.1901      0.616 0.056 0.000 0.004 0.012 0.928
#> SRR949119     1  0.6216      0.618 0.672 0.004 0.132 0.072 0.120
#> SRR949120     1  0.6216      0.618 0.672 0.004 0.132 0.072 0.120
#> SRR949121     1  0.0162      0.860 0.996 0.000 0.000 0.000 0.004
#> SRR949122     1  0.0290      0.859 0.992 0.000 0.000 0.000 0.008
#> SRR949123     2  0.2061      0.747 0.004 0.928 0.040 0.024 0.004
#> SRR949124     2  0.1356      0.756 0.004 0.956 0.028 0.012 0.000
#> SRR949125     4  0.3268      0.953 0.080 0.000 0.060 0.856 0.004
#> SRR949126     4  0.3268      0.953 0.080 0.000 0.060 0.856 0.004
#> SRR949127     2  0.6274      0.695 0.024 0.572 0.296 0.000 0.108
#> SRR949128     2  0.6274      0.695 0.024 0.572 0.296 0.000 0.108
#> SRR949129     2  0.6274      0.695 0.024 0.572 0.296 0.000 0.108

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR949076     4  0.0806      0.957 0.020 0.000 0.000 0.972 0.000 0.008
#> SRR949078     2  0.1461      0.566 0.016 0.940 0.000 0.000 0.044 0.000
#> SRR949077     4  0.0806      0.957 0.020 0.000 0.000 0.972 0.000 0.008
#> SRR949079     4  0.2183      0.941 0.020 0.000 0.028 0.912 0.000 0.040
#> SRR949080     4  0.2183      0.941 0.020 0.000 0.028 0.912 0.000 0.040
#> SRR949081     5  0.2815      0.663 0.020 0.004 0.048 0.000 0.880 0.048
#> SRR949082     2  0.1461      0.566 0.016 0.940 0.000 0.000 0.044 0.000
#> SRR949083     1  0.1036      0.835 0.964 0.000 0.008 0.000 0.004 0.024
#> SRR949084     1  0.0260      0.834 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR949085     2  0.2703      0.198 0.004 0.824 0.000 0.000 0.000 0.172
#> SRR949087     5  0.5387      0.254 0.032 0.444 0.020 0.000 0.488 0.016
#> SRR949088     5  0.5387      0.254 0.032 0.444 0.020 0.000 0.488 0.016
#> SRR949086     5  0.1520      0.682 0.020 0.016 0.008 0.000 0.948 0.008
#> SRR949089     2  0.3993     -0.813 0.004 0.520 0.000 0.000 0.000 0.476
#> SRR949090     4  0.1334      0.955 0.020 0.000 0.000 0.948 0.000 0.032
#> SRR949092     1  0.1138      0.835 0.960 0.000 0.012 0.000 0.004 0.024
#> SRR949093     1  0.1138      0.835 0.960 0.000 0.012 0.000 0.004 0.024
#> SRR949091     4  0.1515      0.954 0.020 0.000 0.008 0.944 0.000 0.028
#> SRR949095     5  0.8000      0.282 0.040 0.020 0.164 0.112 0.456 0.208
#> SRR949094     4  0.0806      0.957 0.020 0.000 0.000 0.972 0.000 0.008
#> SRR949096     1  0.0806      0.834 0.972 0.000 0.008 0.000 0.000 0.020
#> SRR949097     1  0.1232      0.835 0.956 0.000 0.016 0.000 0.004 0.024
#> SRR949098     2  0.3993     -0.813 0.004 0.520 0.000 0.000 0.000 0.476
#> SRR949099     5  0.1313      0.682 0.028 0.016 0.004 0.000 0.952 0.000
#> SRR949101     5  0.5692      0.385 0.016 0.000 0.156 0.068 0.672 0.088
#> SRR949100     5  0.3638      0.612 0.036 0.156 0.000 0.004 0.796 0.008
#> SRR949102     5  0.2706      0.661 0.016 0.000 0.040 0.008 0.888 0.048
#> SRR949103     1  0.1232      0.835 0.956 0.000 0.016 0.000 0.004 0.024
#> SRR949104     6  0.4672      0.911 0.004 0.480 0.008 0.012 0.004 0.492
#> SRR949105     3  0.5593      1.000 0.028 0.096 0.624 0.008 0.244 0.000
#> SRR949106     3  0.5593      1.000 0.028 0.096 0.624 0.008 0.244 0.000
#> SRR949107     3  0.5593      1.000 0.028 0.096 0.624 0.008 0.244 0.000
#> SRR949108     1  0.0260      0.834 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR949109     4  0.1515      0.954 0.020 0.000 0.008 0.944 0.000 0.028
#> SRR949110     1  0.0436      0.836 0.988 0.000 0.004 0.000 0.004 0.004
#> SRR949111     4  0.1065      0.957 0.020 0.000 0.008 0.964 0.000 0.008
#> SRR949112     1  0.1026      0.831 0.968 0.008 0.008 0.000 0.012 0.004
#> SRR949113     2  0.3993     -0.813 0.004 0.520 0.000 0.000 0.000 0.476
#> SRR949114     1  0.7018      0.420 0.524 0.040 0.140 0.000 0.232 0.064
#> SRR949115     1  0.7018      0.420 0.524 0.040 0.140 0.000 0.232 0.064
#> SRR949116     1  0.7018      0.420 0.524 0.040 0.140 0.000 0.232 0.064
#> SRR949117     5  0.1168      0.683 0.028 0.016 0.000 0.000 0.956 0.000
#> SRR949118     5  0.1262      0.682 0.020 0.016 0.008 0.000 0.956 0.000
#> SRR949119     1  0.7179      0.428 0.528 0.000 0.128 0.040 0.104 0.200
#> SRR949120     1  0.7179      0.428 0.528 0.000 0.128 0.040 0.104 0.200
#> SRR949121     1  0.0436      0.836 0.988 0.000 0.004 0.000 0.004 0.004
#> SRR949122     1  0.0291      0.836 0.992 0.000 0.000 0.000 0.004 0.004
#> SRR949123     6  0.5451      0.826 0.004 0.456 0.044 0.008 0.016 0.472
#> SRR949124     6  0.4672      0.911 0.004 0.480 0.008 0.012 0.004 0.492
#> SRR949125     4  0.3264      0.911 0.020 0.000 0.056 0.844 0.000 0.080
#> SRR949126     4  0.3264      0.911 0.020 0.000 0.056 0.844 0.000 0.080
#> SRR949127     2  0.1844      0.569 0.016 0.928 0.016 0.000 0.040 0.000
#> SRR949128     2  0.1844      0.569 0.016 0.928 0.016 0.000 0.040 0.000
#> SRR949129     2  0.1844      0.569 0.016 0.928 0.016 0.000 0.040 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

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 16816 rows and 54 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 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-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.987       0.994         0.5065 0.493   0.493
#> 3 3 0.849           0.835       0.929         0.3292 0.792   0.598
#> 4 4 0.947           0.905       0.961         0.1232 0.882   0.661
#> 5 5 0.842           0.782       0.867         0.0513 0.908   0.668
#> 6 6 0.833           0.767       0.837         0.0393 0.954   0.788

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
#> SRR949076     1   0.000      0.998 1.000 0.000
#> SRR949078     2   0.000      0.989 0.000 1.000
#> SRR949077     1   0.000      0.998 1.000 0.000
#> SRR949079     1   0.000      0.998 1.000 0.000
#> SRR949080     1   0.000      0.998 1.000 0.000
#> SRR949081     2   0.000      0.989 0.000 1.000
#> SRR949082     2   0.000      0.989 0.000 1.000
#> SRR949083     1   0.000      0.998 1.000 0.000
#> SRR949084     1   0.000      0.998 1.000 0.000
#> SRR949085     2   0.000      0.989 0.000 1.000
#> SRR949087     2   0.000      0.989 0.000 1.000
#> SRR949088     2   0.000      0.989 0.000 1.000
#> SRR949086     2   0.000      0.989 0.000 1.000
#> SRR949089     2   0.000      0.989 0.000 1.000
#> SRR949090     1   0.000      0.998 1.000 0.000
#> SRR949092     1   0.000      0.998 1.000 0.000
#> SRR949093     1   0.000      0.998 1.000 0.000
#> SRR949091     1   0.000      0.998 1.000 0.000
#> SRR949095     2   0.311      0.936 0.056 0.944
#> SRR949094     1   0.000      0.998 1.000 0.000
#> SRR949096     1   0.000      0.998 1.000 0.000
#> SRR949097     1   0.000      0.998 1.000 0.000
#> SRR949098     2   0.000      0.989 0.000 1.000
#> SRR949099     1   0.343      0.930 0.936 0.064
#> SRR949101     2   0.722      0.753 0.200 0.800
#> SRR949100     2   0.000      0.989 0.000 1.000
#> SRR949102     2   0.000      0.989 0.000 1.000
#> SRR949103     1   0.000      0.998 1.000 0.000
#> SRR949104     2   0.000      0.989 0.000 1.000
#> SRR949105     2   0.000      0.989 0.000 1.000
#> SRR949106     2   0.000      0.989 0.000 1.000
#> SRR949107     2   0.000      0.989 0.000 1.000
#> SRR949108     1   0.000      0.998 1.000 0.000
#> SRR949109     1   0.000      0.998 1.000 0.000
#> SRR949110     1   0.000      0.998 1.000 0.000
#> SRR949111     1   0.000      0.998 1.000 0.000
#> SRR949112     1   0.000      0.998 1.000 0.000
#> SRR949113     2   0.000      0.989 0.000 1.000
#> SRR949114     1   0.000      0.998 1.000 0.000
#> SRR949115     1   0.000      0.998 1.000 0.000
#> SRR949116     1   0.000      0.998 1.000 0.000
#> SRR949117     2   0.000      0.989 0.000 1.000
#> SRR949118     2   0.000      0.989 0.000 1.000
#> SRR949119     1   0.000      0.998 1.000 0.000
#> SRR949120     1   0.000      0.998 1.000 0.000
#> SRR949121     1   0.000      0.998 1.000 0.000
#> SRR949122     1   0.000      0.998 1.000 0.000
#> SRR949123     2   0.000      0.989 0.000 1.000
#> SRR949124     2   0.000      0.989 0.000 1.000
#> SRR949125     1   0.000      0.998 1.000 0.000
#> SRR949126     1   0.000      0.998 1.000 0.000
#> SRR949127     2   0.000      0.989 0.000 1.000
#> SRR949128     2   0.000      0.989 0.000 1.000
#> SRR949129     2   0.000      0.989 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
#> SRR949076     1  0.0424      0.952 0.992 0.000 0.008
#> SRR949078     2  0.0000      0.857 0.000 1.000 0.000
#> SRR949077     1  0.0424      0.952 0.992 0.000 0.008
#> SRR949079     1  0.0424      0.952 0.992 0.000 0.008
#> SRR949080     1  0.0424      0.952 0.992 0.000 0.008
#> SRR949081     2  0.0424      0.853 0.008 0.992 0.000
#> SRR949082     2  0.0000      0.857 0.000 1.000 0.000
#> SRR949083     3  0.0000      0.970 0.000 0.000 1.000
#> SRR949084     3  0.0000      0.970 0.000 0.000 1.000
#> SRR949085     2  0.0000      0.857 0.000 1.000 0.000
#> SRR949087     2  0.0000      0.857 0.000 1.000 0.000
#> SRR949088     2  0.0000      0.857 0.000 1.000 0.000
#> SRR949086     2  0.6095      0.448 0.392 0.608 0.000
#> SRR949089     2  0.0000      0.857 0.000 1.000 0.000
#> SRR949090     1  0.0424      0.952 0.992 0.000 0.008
#> SRR949092     3  0.0000      0.970 0.000 0.000 1.000
#> SRR949093     3  0.0000      0.970 0.000 0.000 1.000
#> SRR949091     1  0.0000      0.946 1.000 0.000 0.000
#> SRR949095     1  0.6244      0.155 0.560 0.440 0.000
#> SRR949094     1  0.0424      0.952 0.992 0.000 0.008
#> SRR949096     3  0.0000      0.970 0.000 0.000 1.000
#> SRR949097     3  0.0000      0.970 0.000 0.000 1.000
#> SRR949098     2  0.0000      0.857 0.000 1.000 0.000
#> SRR949099     3  0.6180      0.259 0.416 0.000 0.584
#> SRR949101     1  0.0424      0.941 0.992 0.008 0.000
#> SRR949100     2  0.6243      0.675 0.124 0.776 0.100
#> SRR949102     1  0.2280      0.896 0.940 0.052 0.008
#> SRR949103     3  0.0000      0.970 0.000 0.000 1.000
#> SRR949104     2  0.0000      0.857 0.000 1.000 0.000
#> SRR949105     2  0.6215      0.385 0.428 0.572 0.000
#> SRR949106     2  0.6215      0.385 0.428 0.572 0.000
#> SRR949107     2  0.6215      0.385 0.428 0.572 0.000
#> SRR949108     3  0.0000      0.970 0.000 0.000 1.000
#> SRR949109     1  0.0424      0.952 0.992 0.000 0.008
#> SRR949110     3  0.0000      0.970 0.000 0.000 1.000
#> SRR949111     1  0.0424      0.952 0.992 0.000 0.008
#> SRR949112     3  0.0000      0.970 0.000 0.000 1.000
#> SRR949113     2  0.0000      0.857 0.000 1.000 0.000
#> SRR949114     3  0.0424      0.965 0.008 0.000 0.992
#> SRR949115     3  0.0424      0.965 0.008 0.000 0.992
#> SRR949116     3  0.0424      0.965 0.008 0.000 0.992
#> SRR949117     2  0.6968      0.647 0.204 0.716 0.080
#> SRR949118     2  0.9625      0.150 0.388 0.408 0.204
#> SRR949119     3  0.0892      0.955 0.020 0.000 0.980
#> SRR949120     3  0.0892      0.955 0.020 0.000 0.980
#> SRR949121     3  0.0000      0.970 0.000 0.000 1.000
#> SRR949122     3  0.0000      0.970 0.000 0.000 1.000
#> SRR949123     2  0.0000      0.857 0.000 1.000 0.000
#> SRR949124     2  0.0000      0.857 0.000 1.000 0.000
#> SRR949125     1  0.0424      0.952 0.992 0.000 0.008
#> SRR949126     1  0.0424      0.952 0.992 0.000 0.008
#> SRR949127     2  0.0000      0.857 0.000 1.000 0.000
#> SRR949128     2  0.0000      0.857 0.000 1.000 0.000
#> SRR949129     2  0.0000      0.857 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
#> SRR949076     4  0.0000     0.9495 0.000 0.000 0.000 1.000
#> SRR949078     2  0.0000     0.9234 0.000 1.000 0.000 0.000
#> SRR949077     4  0.0000     0.9495 0.000 0.000 0.000 1.000
#> SRR949079     4  0.0000     0.9495 0.000 0.000 0.000 1.000
#> SRR949080     4  0.0000     0.9495 0.000 0.000 0.000 1.000
#> SRR949081     3  0.1302     0.9240 0.000 0.044 0.956 0.000
#> SRR949082     2  0.0000     0.9234 0.000 1.000 0.000 0.000
#> SRR949083     1  0.0000     0.9806 1.000 0.000 0.000 0.000
#> SRR949084     1  0.0000     0.9806 1.000 0.000 0.000 0.000
#> SRR949085     2  0.0000     0.9234 0.000 1.000 0.000 0.000
#> SRR949087     2  0.4382     0.6196 0.000 0.704 0.296 0.000
#> SRR949088     2  0.4382     0.6196 0.000 0.704 0.296 0.000
#> SRR949086     3  0.0000     0.9668 0.000 0.000 1.000 0.000
#> SRR949089     2  0.0000     0.9234 0.000 1.000 0.000 0.000
#> SRR949090     4  0.0000     0.9495 0.000 0.000 0.000 1.000
#> SRR949092     1  0.0000     0.9806 1.000 0.000 0.000 0.000
#> SRR949093     1  0.0000     0.9806 1.000 0.000 0.000 0.000
#> SRR949091     4  0.0000     0.9495 0.000 0.000 0.000 1.000
#> SRR949095     4  0.5000     0.0252 0.000 0.496 0.000 0.504
#> SRR949094     4  0.0000     0.9495 0.000 0.000 0.000 1.000
#> SRR949096     1  0.0000     0.9806 1.000 0.000 0.000 0.000
#> SRR949097     1  0.0000     0.9806 1.000 0.000 0.000 0.000
#> SRR949098     2  0.0000     0.9234 0.000 1.000 0.000 0.000
#> SRR949099     3  0.0000     0.9668 0.000 0.000 1.000 0.000
#> SRR949101     3  0.3801     0.7032 0.000 0.000 0.780 0.220
#> SRR949100     2  0.5459     0.2882 0.000 0.552 0.432 0.016
#> SRR949102     3  0.0188     0.9644 0.000 0.000 0.996 0.004
#> SRR949103     1  0.0000     0.9806 1.000 0.000 0.000 0.000
#> SRR949104     2  0.0000     0.9234 0.000 1.000 0.000 0.000
#> SRR949105     3  0.0000     0.9668 0.000 0.000 1.000 0.000
#> SRR949106     3  0.0000     0.9668 0.000 0.000 1.000 0.000
#> SRR949107     3  0.0000     0.9668 0.000 0.000 1.000 0.000
#> SRR949108     1  0.0000     0.9806 1.000 0.000 0.000 0.000
#> SRR949109     4  0.0000     0.9495 0.000 0.000 0.000 1.000
#> SRR949110     1  0.0000     0.9806 1.000 0.000 0.000 0.000
#> SRR949111     4  0.0000     0.9495 0.000 0.000 0.000 1.000
#> SRR949112     1  0.0000     0.9806 1.000 0.000 0.000 0.000
#> SRR949113     2  0.0000     0.9234 0.000 1.000 0.000 0.000
#> SRR949114     1  0.2281     0.9078 0.904 0.000 0.096 0.000
#> SRR949115     1  0.2281     0.9078 0.904 0.000 0.096 0.000
#> SRR949116     1  0.2281     0.9078 0.904 0.000 0.096 0.000
#> SRR949117     3  0.0000     0.9668 0.000 0.000 1.000 0.000
#> SRR949118     3  0.0000     0.9668 0.000 0.000 1.000 0.000
#> SRR949119     1  0.0336     0.9756 0.992 0.000 0.000 0.008
#> SRR949120     1  0.0336     0.9756 0.992 0.000 0.000 0.008
#> SRR949121     1  0.0000     0.9806 1.000 0.000 0.000 0.000
#> SRR949122     1  0.0000     0.9806 1.000 0.000 0.000 0.000
#> SRR949123     2  0.0000     0.9234 0.000 1.000 0.000 0.000
#> SRR949124     2  0.0000     0.9234 0.000 1.000 0.000 0.000
#> SRR949125     4  0.0000     0.9495 0.000 0.000 0.000 1.000
#> SRR949126     4  0.0000     0.9495 0.000 0.000 0.000 1.000
#> SRR949127     2  0.0000     0.9234 0.000 1.000 0.000 0.000
#> SRR949128     2  0.0000     0.9234 0.000 1.000 0.000 0.000
#> SRR949129     2  0.0000     0.9234 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
#> SRR949076     4  0.0000    1.00000 0.000 0.000 0.000 1.000 0.000
#> SRR949078     2  0.2516    0.86295 0.000 0.860 0.000 0.000 0.140
#> SRR949077     4  0.0000    1.00000 0.000 0.000 0.000 1.000 0.000
#> SRR949079     4  0.0000    1.00000 0.000 0.000 0.000 1.000 0.000
#> SRR949080     4  0.0000    1.00000 0.000 0.000 0.000 1.000 0.000
#> SRR949081     3  0.3276    0.62935 0.000 0.032 0.836 0.000 0.132
#> SRR949082     2  0.2329    0.86842 0.000 0.876 0.000 0.000 0.124
#> SRR949083     1  0.0162    0.90147 0.996 0.000 0.000 0.000 0.004
#> SRR949084     1  0.0000    0.90086 1.000 0.000 0.000 0.000 0.000
#> SRR949085     2  0.0290    0.89366 0.000 0.992 0.000 0.000 0.008
#> SRR949087     3  0.6418    0.00305 0.000 0.412 0.416 0.000 0.172
#> SRR949088     3  0.6418    0.00305 0.000 0.412 0.416 0.000 0.172
#> SRR949086     3  0.0404    0.63363 0.000 0.000 0.988 0.000 0.012
#> SRR949089     2  0.0000    0.89431 0.000 1.000 0.000 0.000 0.000
#> SRR949090     4  0.0000    1.00000 0.000 0.000 0.000 1.000 0.000
#> SRR949092     1  0.0162    0.90147 0.996 0.000 0.000 0.000 0.004
#> SRR949093     1  0.0162    0.90147 0.996 0.000 0.000 0.000 0.004
#> SRR949091     4  0.0000    1.00000 0.000 0.000 0.000 1.000 0.000
#> SRR949095     2  0.5997    0.27274 0.004 0.556 0.016 0.356 0.068
#> SRR949094     4  0.0000    1.00000 0.000 0.000 0.000 1.000 0.000
#> SRR949096     1  0.0162    0.90147 0.996 0.000 0.000 0.000 0.004
#> SRR949097     1  0.0162    0.90147 0.996 0.000 0.000 0.000 0.004
#> SRR949098     2  0.0000    0.89431 0.000 1.000 0.000 0.000 0.000
#> SRR949099     3  0.1341    0.61735 0.000 0.000 0.944 0.000 0.056
#> SRR949101     3  0.6422    0.41585 0.000 0.000 0.460 0.180 0.360
#> SRR949100     3  0.7055    0.26148 0.000 0.160 0.488 0.040 0.312
#> SRR949102     3  0.2877    0.60091 0.000 0.004 0.848 0.004 0.144
#> SRR949103     1  0.0162    0.90147 0.996 0.000 0.000 0.000 0.004
#> SRR949104     2  0.0000    0.89431 0.000 1.000 0.000 0.000 0.000
#> SRR949105     3  0.4126    0.56209 0.000 0.000 0.620 0.000 0.380
#> SRR949106     3  0.4126    0.56209 0.000 0.000 0.620 0.000 0.380
#> SRR949107     3  0.4126    0.56209 0.000 0.000 0.620 0.000 0.380
#> SRR949108     1  0.0000    0.90086 1.000 0.000 0.000 0.000 0.000
#> SRR949109     4  0.0000    1.00000 0.000 0.000 0.000 1.000 0.000
#> SRR949110     1  0.0162    0.89858 0.996 0.000 0.000 0.000 0.004
#> SRR949111     4  0.0000    1.00000 0.000 0.000 0.000 1.000 0.000
#> SRR949112     1  0.3074    0.56588 0.804 0.000 0.000 0.000 0.196
#> SRR949113     2  0.0000    0.89431 0.000 1.000 0.000 0.000 0.000
#> SRR949114     5  0.6335    1.00000 0.352 0.000 0.168 0.000 0.480
#> SRR949115     5  0.6335    1.00000 0.352 0.000 0.168 0.000 0.480
#> SRR949116     5  0.6335    1.00000 0.352 0.000 0.168 0.000 0.480
#> SRR949117     3  0.1197    0.63450 0.000 0.000 0.952 0.000 0.048
#> SRR949118     3  0.1121    0.62257 0.000 0.000 0.956 0.000 0.044
#> SRR949119     1  0.5038    0.38404 0.692 0.000 0.032 0.028 0.248
#> SRR949120     1  0.5038    0.38404 0.692 0.000 0.032 0.028 0.248
#> SRR949121     1  0.0162    0.89858 0.996 0.000 0.000 0.000 0.004
#> SRR949122     1  0.0000    0.90086 1.000 0.000 0.000 0.000 0.000
#> SRR949123     2  0.0000    0.89431 0.000 1.000 0.000 0.000 0.000
#> SRR949124     2  0.0000    0.89431 0.000 1.000 0.000 0.000 0.000
#> SRR949125     4  0.0000    1.00000 0.000 0.000 0.000 1.000 0.000
#> SRR949126     4  0.0000    1.00000 0.000 0.000 0.000 1.000 0.000
#> SRR949127     2  0.2516    0.86295 0.000 0.860 0.000 0.000 0.140
#> SRR949128     2  0.2516    0.86295 0.000 0.860 0.000 0.000 0.140
#> SRR949129     2  0.2516    0.86295 0.000 0.860 0.000 0.000 0.140

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR949076     4  0.0146      0.996 0.000 0.000 0.000 0.996 0.004 0.000
#> SRR949078     2  0.3742      0.677 0.000 0.648 0.004 0.000 0.348 0.000
#> SRR949077     4  0.0146      0.996 0.000 0.000 0.000 0.996 0.004 0.000
#> SRR949079     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949080     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949081     5  0.5701      0.432 0.000 0.004 0.256 0.000 0.544 0.196
#> SRR949082     2  0.3547      0.700 0.000 0.696 0.004 0.000 0.300 0.000
#> SRR949083     1  0.0146      0.946 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR949084     1  0.0725      0.940 0.976 0.000 0.000 0.000 0.012 0.012
#> SRR949085     2  0.0547      0.791 0.000 0.980 0.000 0.000 0.020 0.000
#> SRR949087     5  0.4111      0.378 0.000 0.144 0.108 0.000 0.748 0.000
#> SRR949088     5  0.4111      0.378 0.000 0.144 0.108 0.000 0.748 0.000
#> SRR949086     5  0.5887      0.488 0.000 0.000 0.392 0.000 0.408 0.200
#> SRR949089     2  0.0000      0.794 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949090     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949092     1  0.0146      0.946 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR949093     1  0.0146      0.946 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR949091     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949095     2  0.6887      0.295 0.012 0.568 0.048 0.228 0.084 0.060
#> SRR949094     4  0.0405      0.989 0.000 0.000 0.000 0.988 0.008 0.004
#> SRR949096     1  0.0520      0.941 0.984 0.000 0.000 0.000 0.008 0.008
#> SRR949097     1  0.0291      0.945 0.992 0.000 0.000 0.000 0.004 0.004
#> SRR949098     2  0.0000      0.794 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949099     5  0.5987      0.533 0.000 0.000 0.300 0.000 0.440 0.260
#> SRR949101     3  0.3906      0.713 0.000 0.000 0.796 0.120 0.052 0.032
#> SRR949100     5  0.5472      0.452 0.000 0.064 0.048 0.008 0.648 0.232
#> SRR949102     5  0.5999      0.369 0.000 0.008 0.212 0.000 0.492 0.288
#> SRR949103     1  0.0291      0.945 0.992 0.000 0.000 0.000 0.004 0.004
#> SRR949104     2  0.0000      0.794 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949105     3  0.0000      0.903 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949106     3  0.0000      0.903 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949107     3  0.0000      0.903 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949108     1  0.0725      0.940 0.976 0.000 0.000 0.000 0.012 0.012
#> SRR949109     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949110     1  0.0622      0.942 0.980 0.000 0.000 0.000 0.008 0.012
#> SRR949111     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949112     1  0.3684      0.389 0.664 0.000 0.000 0.000 0.004 0.332
#> SRR949113     2  0.0000      0.794 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949114     6  0.3275      0.671 0.140 0.000 0.032 0.000 0.008 0.820
#> SRR949115     6  0.3275      0.671 0.140 0.000 0.032 0.000 0.008 0.820
#> SRR949116     6  0.3275      0.671 0.140 0.000 0.032 0.000 0.008 0.820
#> SRR949117     5  0.5809      0.507 0.000 0.000 0.360 0.000 0.452 0.188
#> SRR949118     5  0.6016      0.518 0.000 0.000 0.340 0.000 0.412 0.248
#> SRR949119     6  0.6663      0.499 0.312 0.000 0.008 0.032 0.200 0.448
#> SRR949120     6  0.6663      0.499 0.312 0.000 0.008 0.032 0.200 0.448
#> SRR949121     1  0.0622      0.942 0.980 0.000 0.000 0.000 0.008 0.012
#> SRR949122     1  0.1049      0.927 0.960 0.000 0.000 0.000 0.008 0.032
#> SRR949123     2  0.0000      0.794 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949124     2  0.0000      0.794 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949125     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949126     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949127     2  0.3830      0.660 0.000 0.620 0.004 0.000 0.376 0.000
#> SRR949128     2  0.3830      0.660 0.000 0.620 0.004 0.000 0.376 0.000
#> SRR949129     2  0.3830      0.660 0.000 0.620 0.004 0.000 0.376 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

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 16816 rows and 54 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 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-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.456           0.912       0.852         0.4324 0.547   0.547
#> 3 3 0.752           0.767       0.874         0.2879 0.942   0.894
#> 4 4 0.954           0.933       0.977         0.2273 0.816   0.626
#> 5 5 0.762           0.763       0.759         0.1052 0.900   0.676
#> 6 6 0.758           0.512       0.764         0.0564 0.864   0.492

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
#> SRR949076     1  0.5842      0.874 0.860 0.140
#> SRR949078     2  0.5842      0.961 0.140 0.860
#> SRR949077     1  0.5842      0.874 0.860 0.140
#> SRR949079     1  0.5842      0.874 0.860 0.140
#> SRR949080     1  0.5842      0.874 0.860 0.140
#> SRR949081     2  0.6801      0.932 0.180 0.820
#> SRR949082     2  0.5842      0.961 0.140 0.860
#> SRR949083     1  0.0000      0.933 1.000 0.000
#> SRR949084     1  0.0000      0.933 1.000 0.000
#> SRR949085     2  0.5842      0.961 0.140 0.860
#> SRR949087     2  0.5842      0.961 0.140 0.860
#> SRR949088     2  0.5842      0.961 0.140 0.860
#> SRR949086     1  0.0376      0.931 0.996 0.004
#> SRR949089     2  0.5842      0.961 0.140 0.860
#> SRR949090     1  0.5842      0.874 0.860 0.140
#> SRR949092     1  0.0000      0.933 1.000 0.000
#> SRR949093     1  0.0000      0.933 1.000 0.000
#> SRR949091     1  0.5842      0.874 0.860 0.140
#> SRR949095     1  0.4815      0.827 0.896 0.104
#> SRR949094     1  0.5842      0.874 0.860 0.140
#> SRR949096     1  0.0000      0.933 1.000 0.000
#> SRR949097     1  0.0000      0.933 1.000 0.000
#> SRR949098     2  0.5842      0.961 0.140 0.860
#> SRR949099     1  0.0000      0.933 1.000 0.000
#> SRR949101     1  0.6712      0.763 0.824 0.176
#> SRR949100     1  0.3879      0.863 0.924 0.076
#> SRR949102     1  0.2423      0.900 0.960 0.040
#> SRR949103     1  0.0000      0.933 1.000 0.000
#> SRR949104     2  0.5842      0.961 0.140 0.860
#> SRR949105     2  0.9580      0.643 0.380 0.620
#> SRR949106     2  0.8327      0.843 0.264 0.736
#> SRR949107     2  0.8443      0.832 0.272 0.728
#> SRR949108     1  0.0000      0.933 1.000 0.000
#> SRR949109     1  0.5294      0.883 0.880 0.120
#> SRR949110     1  0.0000      0.933 1.000 0.000
#> SRR949111     1  0.5842      0.874 0.860 0.140
#> SRR949112     1  0.0000      0.933 1.000 0.000
#> SRR949113     2  0.5842      0.961 0.140 0.860
#> SRR949114     1  0.0000      0.933 1.000 0.000
#> SRR949115     1  0.0000      0.933 1.000 0.000
#> SRR949116     1  0.0000      0.933 1.000 0.000
#> SRR949117     1  0.0376      0.931 0.996 0.004
#> SRR949118     1  0.0376      0.931 0.996 0.004
#> SRR949119     1  0.0000      0.933 1.000 0.000
#> SRR949120     1  0.0000      0.933 1.000 0.000
#> SRR949121     1  0.0000      0.933 1.000 0.000
#> SRR949122     1  0.0000      0.933 1.000 0.000
#> SRR949123     2  0.6247      0.951 0.156 0.844
#> SRR949124     2  0.5842      0.961 0.140 0.860
#> SRR949125     1  0.5842      0.874 0.860 0.140
#> SRR949126     1  0.5842      0.874 0.860 0.140
#> SRR949127     2  0.5842      0.961 0.140 0.860
#> SRR949128     2  0.5842      0.961 0.140 0.860
#> SRR949129     2  0.5842      0.961 0.140 0.860

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR949076     1  0.0892     0.5772 0.980 0.000 0.020
#> SRR949078     2  0.6126     0.9537 0.000 0.600 0.400
#> SRR949077     1  0.0892     0.5772 0.980 0.000 0.020
#> SRR949079     1  0.0892     0.5772 0.980 0.000 0.020
#> SRR949080     1  0.0892     0.5772 0.980 0.000 0.020
#> SRR949081     2  0.6968     0.3211 0.080 0.716 0.204
#> SRR949082     2  0.5926     0.8887 0.000 0.644 0.356
#> SRR949083     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949084     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949085     2  0.6126     0.9537 0.000 0.600 0.400
#> SRR949087     2  0.6126     0.9537 0.000 0.600 0.400
#> SRR949088     2  0.6126     0.9537 0.000 0.600 0.400
#> SRR949086     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949089     2  0.6126     0.9537 0.000 0.600 0.400
#> SRR949090     1  0.0892     0.5772 0.980 0.000 0.020
#> SRR949092     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949093     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949091     1  0.0892     0.5772 0.980 0.000 0.020
#> SRR949095     1  0.5926     0.7939 0.644 0.356 0.000
#> SRR949094     1  0.0000     0.5889 1.000 0.000 0.000
#> SRR949096     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949097     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949098     2  0.6126     0.9537 0.000 0.600 0.400
#> SRR949099     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949101     3  0.9512     0.0186 0.188 0.384 0.428
#> SRR949100     1  0.6111     0.8197 0.604 0.396 0.000
#> SRR949102     1  0.6095     0.8178 0.608 0.392 0.000
#> SRR949103     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949104     2  0.6126     0.9537 0.000 0.600 0.400
#> SRR949105     3  0.4551     0.6185 0.020 0.140 0.840
#> SRR949106     3  0.2846     0.5789 0.020 0.056 0.924
#> SRR949107     3  0.2636     0.5625 0.020 0.048 0.932
#> SRR949108     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949109     1  0.0424     0.5933 0.992 0.008 0.000
#> SRR949110     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949111     1  0.0892     0.5772 0.980 0.000 0.020
#> SRR949112     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949113     2  0.6126     0.9537 0.000 0.600 0.400
#> SRR949114     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949115     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949116     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949117     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949118     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949119     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949120     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949121     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949122     1  0.6126     0.8215 0.600 0.400 0.000
#> SRR949123     2  0.6617     0.9209 0.012 0.600 0.388
#> SRR949124     2  0.6126     0.9537 0.000 0.600 0.400
#> SRR949125     1  0.0892     0.5772 0.980 0.000 0.020
#> SRR949126     1  0.0892     0.5772 0.980 0.000 0.020
#> SRR949127     2  0.6126     0.9537 0.000 0.600 0.400
#> SRR949128     2  0.6126     0.9537 0.000 0.600 0.400
#> SRR949129     2  0.6126     0.9537 0.000 0.600 0.400

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2  p3    p4
#> SRR949076     4  0.0188      0.919 0.004 0.000 0.0 0.996
#> SRR949078     2  0.0000      0.968 0.000 1.000 0.0 0.000
#> SRR949077     4  0.0000      0.922 0.000 0.000 0.0 1.000
#> SRR949079     4  0.0000      0.922 0.000 0.000 0.0 1.000
#> SRR949080     4  0.0000      0.922 0.000 0.000 0.0 1.000
#> SRR949081     2  0.4072      0.577 0.252 0.748 0.0 0.000
#> SRR949082     2  0.1022      0.934 0.032 0.968 0.0 0.000
#> SRR949083     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949084     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949085     2  0.0000      0.968 0.000 1.000 0.0 0.000
#> SRR949087     2  0.0000      0.968 0.000 1.000 0.0 0.000
#> SRR949088     2  0.0000      0.968 0.000 1.000 0.0 0.000
#> SRR949086     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949089     2  0.0000      0.968 0.000 1.000 0.0 0.000
#> SRR949090     4  0.0000      0.922 0.000 0.000 0.0 1.000
#> SRR949092     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949093     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949091     4  0.0000      0.922 0.000 0.000 0.0 1.000
#> SRR949095     1  0.3764      0.699 0.784 0.000 0.0 0.216
#> SRR949094     4  0.2921      0.754 0.140 0.000 0.0 0.860
#> SRR949096     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949097     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949098     2  0.0000      0.968 0.000 1.000 0.0 0.000
#> SRR949099     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949101     3  0.4290      0.722 0.164 0.000 0.8 0.036
#> SRR949100     1  0.0524      0.977 0.988 0.004 0.0 0.008
#> SRR949102     1  0.1004      0.960 0.972 0.004 0.0 0.024
#> SRR949103     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949104     2  0.0000      0.968 0.000 1.000 0.0 0.000
#> SRR949105     3  0.0000      0.913 0.000 0.000 1.0 0.000
#> SRR949106     3  0.0000      0.913 0.000 0.000 1.0 0.000
#> SRR949107     3  0.0000      0.913 0.000 0.000 1.0 0.000
#> SRR949108     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949109     4  0.4522      0.464 0.320 0.000 0.0 0.680
#> SRR949110     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949111     4  0.0817      0.902 0.024 0.000 0.0 0.976
#> SRR949112     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949113     2  0.0000      0.968 0.000 1.000 0.0 0.000
#> SRR949114     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949115     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949116     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949117     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949118     1  0.0188      0.983 0.996 0.004 0.0 0.000
#> SRR949119     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949120     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949121     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949122     1  0.0000      0.987 1.000 0.000 0.0 0.000
#> SRR949123     2  0.0817      0.944 0.024 0.976 0.0 0.000
#> SRR949124     2  0.0000      0.968 0.000 1.000 0.0 0.000
#> SRR949125     4  0.0000      0.922 0.000 0.000 0.0 1.000
#> SRR949126     4  0.0000      0.922 0.000 0.000 0.0 1.000
#> SRR949127     2  0.0000      0.968 0.000 1.000 0.0 0.000
#> SRR949128     2  0.0000      0.968 0.000 1.000 0.0 0.000
#> SRR949129     2  0.0000      0.968 0.000 1.000 0.0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR949076     4  0.0162     0.9329 0.000 0.000 0.004 0.996 0.000
#> SRR949078     2  0.0000     0.8348 0.000 1.000 0.000 0.000 0.000
#> SRR949077     4  0.0000     0.9354 0.000 0.000 0.000 1.000 0.000
#> SRR949079     4  0.0000     0.9354 0.000 0.000 0.000 1.000 0.000
#> SRR949080     4  0.0000     0.9354 0.000 0.000 0.000 1.000 0.000
#> SRR949081     2  0.4392     0.3310 0.008 0.612 0.380 0.000 0.000
#> SRR949082     2  0.1121     0.8118 0.000 0.956 0.044 0.000 0.000
#> SRR949083     1  0.4045     0.9821 0.644 0.000 0.356 0.000 0.000
#> SRR949084     1  0.4045     0.9821 0.644 0.000 0.356 0.000 0.000
#> SRR949085     2  0.0000     0.8348 0.000 1.000 0.000 0.000 0.000
#> SRR949087     2  0.0000     0.8348 0.000 1.000 0.000 0.000 0.000
#> SRR949088     2  0.0000     0.8348 0.000 1.000 0.000 0.000 0.000
#> SRR949086     3  0.2516     0.5942 0.140 0.000 0.860 0.000 0.000
#> SRR949089     2  0.3796     0.7895 0.300 0.700 0.000 0.000 0.000
#> SRR949090     4  0.0000     0.9354 0.000 0.000 0.000 1.000 0.000
#> SRR949092     1  0.4045     0.9821 0.644 0.000 0.356 0.000 0.000
#> SRR949093     1  0.4045     0.9821 0.644 0.000 0.356 0.000 0.000
#> SRR949091     4  0.0000     0.9354 0.000 0.000 0.000 1.000 0.000
#> SRR949095     3  0.6453     0.0864 0.180 0.000 0.432 0.388 0.000
#> SRR949094     4  0.3281     0.7683 0.060 0.000 0.092 0.848 0.000
#> SRR949096     1  0.4045     0.9821 0.644 0.000 0.356 0.000 0.000
#> SRR949097     1  0.4045     0.9821 0.644 0.000 0.356 0.000 0.000
#> SRR949098     2  0.3796     0.7895 0.300 0.700 0.000 0.000 0.000
#> SRR949099     3  0.0404     0.6867 0.012 0.000 0.988 0.000 0.000
#> SRR949101     5  0.4768     0.4291 0.000 0.000 0.384 0.024 0.592
#> SRR949100     3  0.6284     0.1368 0.136 0.372 0.488 0.004 0.000
#> SRR949102     3  0.0693     0.6806 0.008 0.000 0.980 0.012 0.000
#> SRR949103     1  0.4045     0.9821 0.644 0.000 0.356 0.000 0.000
#> SRR949104     2  0.3796     0.7895 0.300 0.700 0.000 0.000 0.000
#> SRR949105     5  0.0000     0.8669 0.000 0.000 0.000 0.000 1.000
#> SRR949106     5  0.0000     0.8669 0.000 0.000 0.000 0.000 1.000
#> SRR949107     5  0.0000     0.8669 0.000 0.000 0.000 0.000 1.000
#> SRR949108     1  0.4045     0.9821 0.644 0.000 0.356 0.000 0.000
#> SRR949109     4  0.4696     0.6072 0.156 0.000 0.108 0.736 0.000
#> SRR949110     1  0.4235     0.8297 0.576 0.000 0.424 0.000 0.000
#> SRR949111     4  0.0798     0.9168 0.008 0.000 0.016 0.976 0.000
#> SRR949112     3  0.2424     0.6027 0.132 0.000 0.868 0.000 0.000
#> SRR949113     2  0.3796     0.7895 0.300 0.700 0.000 0.000 0.000
#> SRR949114     3  0.0000     0.6891 0.000 0.000 1.000 0.000 0.000
#> SRR949115     3  0.0000     0.6891 0.000 0.000 1.000 0.000 0.000
#> SRR949116     3  0.0000     0.6891 0.000 0.000 1.000 0.000 0.000
#> SRR949117     3  0.4251    -0.1342 0.372 0.004 0.624 0.000 0.000
#> SRR949118     3  0.0000     0.6891 0.000 0.000 1.000 0.000 0.000
#> SRR949119     3  0.4030     0.3131 0.352 0.000 0.648 0.000 0.000
#> SRR949120     3  0.4045     0.3007 0.356 0.000 0.644 0.000 0.000
#> SRR949121     1  0.4074     0.9698 0.636 0.000 0.364 0.000 0.000
#> SRR949122     1  0.4060     0.9763 0.640 0.000 0.360 0.000 0.000
#> SRR949123     2  0.3796     0.7895 0.300 0.700 0.000 0.000 0.000
#> SRR949124     2  0.3796     0.7895 0.300 0.700 0.000 0.000 0.000
#> SRR949125     4  0.0000     0.9354 0.000 0.000 0.000 1.000 0.000
#> SRR949126     4  0.0000     0.9354 0.000 0.000 0.000 1.000 0.000
#> SRR949127     2  0.0000     0.8348 0.000 1.000 0.000 0.000 0.000
#> SRR949128     2  0.0000     0.8348 0.000 1.000 0.000 0.000 0.000
#> SRR949129     2  0.0000     0.8348 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
#> SRR949076     4  0.0146     0.8798 0.004 0.000 0.00 0.996 0.000 0.000
#> SRR949078     6  0.3864    -0.0635 0.000 0.480 0.00 0.000 0.000 0.520
#> SRR949077     4  0.0000     0.8821 0.000 0.000 0.00 1.000 0.000 0.000
#> SRR949079     4  0.0000     0.8821 0.000 0.000 0.00 1.000 0.000 0.000
#> SRR949080     4  0.0000     0.8821 0.000 0.000 0.00 1.000 0.000 0.000
#> SRR949081     2  0.7009     0.2099 0.132 0.480 0.00 0.000 0.196 0.192
#> SRR949082     6  0.4535    -0.1045 0.032 0.480 0.00 0.000 0.000 0.488
#> SRR949083     1  0.0000     0.9327 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR949084     1  0.0000     0.9327 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR949085     6  0.3864    -0.0635 0.000 0.480 0.00 0.000 0.000 0.520
#> SRR949087     6  0.3864    -0.0635 0.000 0.480 0.00 0.000 0.000 0.520
#> SRR949088     6  0.3864    -0.0635 0.000 0.480 0.00 0.000 0.000 0.520
#> SRR949086     6  0.5655    -0.2971 0.360 0.000 0.00 0.000 0.160 0.480
#> SRR949089     2  0.0000     0.8003 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR949090     4  0.0000     0.8821 0.000 0.000 0.00 1.000 0.000 0.000
#> SRR949092     1  0.0000     0.9327 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR949093     1  0.0000     0.9327 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR949091     4  0.0000     0.8821 0.000 0.000 0.00 1.000 0.000 0.000
#> SRR949095     4  0.6090    -0.0565 0.380 0.000 0.00 0.472 0.108 0.040
#> SRR949094     4  0.2454     0.7276 0.160 0.000 0.00 0.840 0.000 0.000
#> SRR949096     1  0.0000     0.9327 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR949097     1  0.0000     0.9327 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR949098     2  0.0000     0.8003 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR949099     6  0.5655    -0.1234 0.160 0.000 0.00 0.000 0.360 0.480
#> SRR949101     3  0.4246     0.3286 0.000 0.000 0.58 0.000 0.400 0.020
#> SRR949100     2  0.6048     0.1237 0.340 0.476 0.00 0.004 0.172 0.008
#> SRR949102     5  0.1957     0.3810 0.112 0.000 0.00 0.000 0.888 0.000
#> SRR949103     1  0.0000     0.9327 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR949104     2  0.0000     0.8003 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR949105     3  0.0000     0.8271 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR949106     3  0.0000     0.8271 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR949107     3  0.0000     0.8271 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR949108     1  0.0000     0.9327 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR949109     4  0.3405     0.5463 0.272 0.000 0.00 0.724 0.000 0.004
#> SRR949110     1  0.1387     0.8318 0.932 0.000 0.00 0.000 0.068 0.000
#> SRR949111     4  0.0632     0.8671 0.024 0.000 0.00 0.976 0.000 0.000
#> SRR949112     6  0.5848    -0.2458 0.296 0.000 0.00 0.000 0.224 0.480
#> SRR949113     2  0.0000     0.8003 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR949114     6  0.5404    -0.0880 0.116 0.000 0.00 0.000 0.404 0.480
#> SRR949115     6  0.5404    -0.0880 0.116 0.000 0.00 0.000 0.404 0.480
#> SRR949116     6  0.5404    -0.0880 0.116 0.000 0.00 0.000 0.404 0.480
#> SRR949117     1  0.4851     0.2146 0.632 0.000 0.00 0.000 0.096 0.272
#> SRR949118     6  0.5404    -0.0880 0.116 0.000 0.00 0.000 0.404 0.480
#> SRR949119     5  0.3464     0.7068 0.312 0.000 0.00 0.000 0.688 0.000
#> SRR949120     5  0.3464     0.7068 0.312 0.000 0.00 0.000 0.688 0.000
#> SRR949121     1  0.0146     0.9290 0.996 0.000 0.00 0.000 0.004 0.000
#> SRR949122     1  0.0458     0.9141 0.984 0.000 0.00 0.000 0.016 0.000
#> SRR949123     2  0.0000     0.8003 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR949124     2  0.0000     0.8003 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR949125     4  0.0000     0.8821 0.000 0.000 0.00 1.000 0.000 0.000
#> SRR949126     4  0.0000     0.8821 0.000 0.000 0.00 1.000 0.000 0.000
#> SRR949127     6  0.3864    -0.0635 0.000 0.480 0.00 0.000 0.000 0.520
#> SRR949128     6  0.3864    -0.0635 0.000 0.480 0.00 0.000 0.000 0.520
#> SRR949129     6  0.3864    -0.0635 0.000 0.480 0.00 0.000 0.000 0.520

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

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

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

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.885           0.954       0.969         0.5065 0.493   0.493
#> 3 3 0.470           0.680       0.855         0.2884 0.734   0.512
#> 4 4 0.691           0.717       0.848         0.0884 0.923   0.787
#> 5 5 0.820           0.844       0.921         0.0941 0.843   0.543
#> 6 6 0.878           0.837       0.890         0.0393 0.975   0.882

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

suggest_best_k(res)
#> [1] 2

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR949076     2  0.0938      0.959 0.012 0.988
#> SRR949078     2  0.1184      0.959 0.016 0.984
#> SRR949077     2  0.0938      0.959 0.012 0.988
#> SRR949079     2  0.0938      0.959 0.012 0.988
#> SRR949080     2  0.0938      0.959 0.012 0.988
#> SRR949081     2  0.7602      0.774 0.220 0.780
#> SRR949082     2  0.1843      0.956 0.028 0.972
#> SRR949083     1  0.0000      0.988 1.000 0.000
#> SRR949084     1  0.0000      0.988 1.000 0.000
#> SRR949085     2  0.1184      0.959 0.016 0.984
#> SRR949087     2  0.5629      0.874 0.132 0.868
#> SRR949088     2  0.5842      0.867 0.140 0.860
#> SRR949086     1  0.1633      0.979 0.976 0.024
#> SRR949089     2  0.1184      0.959 0.016 0.984
#> SRR949090     2  0.0938      0.959 0.012 0.988
#> SRR949092     1  0.0000      0.988 1.000 0.000
#> SRR949093     1  0.0000      0.988 1.000 0.000
#> SRR949091     2  0.0938      0.959 0.012 0.988
#> SRR949095     2  0.1843      0.958 0.028 0.972
#> SRR949094     2  0.0938      0.959 0.012 0.988
#> SRR949096     1  0.0000      0.988 1.000 0.000
#> SRR949097     1  0.0000      0.988 1.000 0.000
#> SRR949098     2  0.1184      0.959 0.016 0.984
#> SRR949099     1  0.0938      0.985 0.988 0.012
#> SRR949101     1  0.6623      0.806 0.828 0.172
#> SRR949100     2  0.8327      0.715 0.264 0.736
#> SRR949102     2  0.6247      0.843 0.156 0.844
#> SRR949103     1  0.0000      0.988 1.000 0.000
#> SRR949104     2  0.1184      0.959 0.016 0.984
#> SRR949105     1  0.1843      0.978 0.972 0.028
#> SRR949106     1  0.1843      0.978 0.972 0.028
#> SRR949107     1  0.1843      0.978 0.972 0.028
#> SRR949108     1  0.0000      0.988 1.000 0.000
#> SRR949109     2  0.0938      0.959 0.012 0.988
#> SRR949110     1  0.0000      0.988 1.000 0.000
#> SRR949111     2  0.0938      0.959 0.012 0.988
#> SRR949112     1  0.0000      0.988 1.000 0.000
#> SRR949113     2  0.1184      0.959 0.016 0.984
#> SRR949114     1  0.0000      0.988 1.000 0.000
#> SRR949115     1  0.0000      0.988 1.000 0.000
#> SRR949116     1  0.0000      0.988 1.000 0.000
#> SRR949117     1  0.1184      0.983 0.984 0.016
#> SRR949118     1  0.1414      0.982 0.980 0.020
#> SRR949119     1  0.0376      0.987 0.996 0.004
#> SRR949120     1  0.0376      0.987 0.996 0.004
#> SRR949121     1  0.0000      0.988 1.000 0.000
#> SRR949122     1  0.0000      0.988 1.000 0.000
#> SRR949123     2  0.1184      0.959 0.016 0.984
#> SRR949124     2  0.1184      0.959 0.016 0.984
#> SRR949125     2  0.0938      0.959 0.012 0.988
#> SRR949126     2  0.0938      0.959 0.012 0.988
#> SRR949127     2  0.1843      0.956 0.028 0.972
#> SRR949128     2  0.1843      0.956 0.028 0.972
#> SRR949129     2  0.1843      0.956 0.028 0.972

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR949076     1  0.0000     0.8034 1.000 0.000 0.000
#> SRR949078     2  0.3192     0.7740 0.000 0.888 0.112
#> SRR949077     1  0.0000     0.8034 1.000 0.000 0.000
#> SRR949079     1  0.0000     0.8034 1.000 0.000 0.000
#> SRR949080     1  0.0000     0.8034 1.000 0.000 0.000
#> SRR949081     1  0.8702     0.4263 0.568 0.140 0.292
#> SRR949082     2  0.3752     0.7404 0.000 0.856 0.144
#> SRR949083     3  0.0000     0.8417 0.000 0.000 1.000
#> SRR949084     3  0.0000     0.8417 0.000 0.000 1.000
#> SRR949085     2  0.0592     0.8288 0.000 0.988 0.012
#> SRR949087     1  0.9515     0.3297 0.480 0.216 0.304
#> SRR949088     1  0.9471     0.3310 0.484 0.208 0.308
#> SRR949086     3  0.8571     0.3617 0.272 0.140 0.588
#> SRR949089     2  0.0424     0.8290 0.000 0.992 0.008
#> SRR949090     1  0.0000     0.8034 1.000 0.000 0.000
#> SRR949092     3  0.0000     0.8417 0.000 0.000 1.000
#> SRR949093     3  0.0000     0.8417 0.000 0.000 1.000
#> SRR949091     1  0.0000     0.8034 1.000 0.000 0.000
#> SRR949095     3  0.9541     0.0540 0.348 0.200 0.452
#> SRR949094     1  0.0000     0.8034 1.000 0.000 0.000
#> SRR949096     3  0.0000     0.8417 0.000 0.000 1.000
#> SRR949097     3  0.0000     0.8417 0.000 0.000 1.000
#> SRR949098     2  0.0424     0.8290 0.000 0.992 0.008
#> SRR949099     3  0.7702     0.5383 0.180 0.140 0.680
#> SRR949101     1  0.8286     0.4575 0.624 0.140 0.236
#> SRR949100     1  0.8853     0.3686 0.540 0.140 0.320
#> SRR949102     1  0.8571     0.4590 0.588 0.140 0.272
#> SRR949103     3  0.0000     0.8417 0.000 0.000 1.000
#> SRR949104     2  0.0424     0.8290 0.000 0.992 0.008
#> SRR949105     2  0.9931     0.1698 0.288 0.388 0.324
#> SRR949106     2  0.9931     0.1698 0.288 0.388 0.324
#> SRR949107     2  0.9931     0.1698 0.288 0.388 0.324
#> SRR949108     3  0.0000     0.8417 0.000 0.000 1.000
#> SRR949109     1  0.0000     0.8034 1.000 0.000 0.000
#> SRR949110     3  0.0000     0.8417 0.000 0.000 1.000
#> SRR949111     1  0.0000     0.8034 1.000 0.000 0.000
#> SRR949112     3  0.5220     0.6267 0.012 0.208 0.780
#> SRR949113     2  0.0424     0.8290 0.000 0.992 0.008
#> SRR949114     3  0.0661     0.8386 0.008 0.004 0.988
#> SRR949115     3  0.0661     0.8386 0.008 0.004 0.988
#> SRR949116     3  0.0661     0.8386 0.008 0.004 0.988
#> SRR949117     3  0.9050     0.0574 0.376 0.140 0.484
#> SRR949118     3  0.8113     0.4794 0.212 0.144 0.644
#> SRR949119     3  0.4094     0.7670 0.100 0.028 0.872
#> SRR949120     3  0.4094     0.7670 0.100 0.028 0.872
#> SRR949121     3  0.0000     0.8417 0.000 0.000 1.000
#> SRR949122     3  0.4555     0.6433 0.000 0.200 0.800
#> SRR949123     2  0.3038     0.7794 0.000 0.896 0.104
#> SRR949124     2  0.0424     0.8290 0.000 0.992 0.008
#> SRR949125     1  0.0000     0.8034 1.000 0.000 0.000
#> SRR949126     1  0.0000     0.8034 1.000 0.000 0.000
#> SRR949127     2  0.0424     0.8277 0.000 0.992 0.008
#> SRR949128     2  0.0424     0.8277 0.000 0.992 0.008
#> SRR949129     2  0.0424     0.8277 0.000 0.992 0.008

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR949076     4  0.0000      0.815 0.000 0.000 0.000 1.000
#> SRR949078     2  0.0804      0.973 0.000 0.980 0.008 0.012
#> SRR949077     4  0.0188      0.813 0.004 0.000 0.000 0.996
#> SRR949079     4  0.0000      0.815 0.000 0.000 0.000 1.000
#> SRR949080     4  0.0000      0.815 0.000 0.000 0.000 1.000
#> SRR949081     4  0.8661      0.107 0.328 0.088 0.128 0.456
#> SRR949082     2  0.0804      0.970 0.008 0.980 0.000 0.012
#> SRR949083     1  0.0188      0.731 0.996 0.000 0.004 0.000
#> SRR949084     1  0.2125      0.729 0.920 0.004 0.076 0.000
#> SRR949085     2  0.0469      0.978 0.000 0.988 0.012 0.000
#> SRR949087     1  0.9474      0.200 0.376 0.308 0.152 0.164
#> SRR949088     1  0.9455      0.199 0.376 0.312 0.152 0.160
#> SRR949086     1  0.8806      0.365 0.452 0.064 0.256 0.228
#> SRR949089     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR949090     4  0.0000      0.815 0.000 0.000 0.000 1.000
#> SRR949092     1  0.0188      0.731 0.996 0.000 0.004 0.000
#> SRR949093     1  0.0188      0.731 0.996 0.000 0.004 0.000
#> SRR949091     4  0.0000      0.815 0.000 0.000 0.000 1.000
#> SRR949095     1  0.9269      0.148 0.412 0.120 0.176 0.292
#> SRR949094     4  0.0188      0.813 0.004 0.000 0.000 0.996
#> SRR949096     1  0.1082      0.721 0.972 0.004 0.020 0.004
#> SRR949097     1  0.1557      0.731 0.944 0.000 0.056 0.000
#> SRR949098     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR949099     1  0.7452      0.573 0.604 0.088 0.248 0.060
#> SRR949101     4  0.8638      0.212 0.180 0.060 0.304 0.456
#> SRR949100     4  0.8383      0.172 0.324 0.076 0.116 0.484
#> SRR949102     4  0.7847      0.283 0.300 0.064 0.092 0.544
#> SRR949103     1  0.1743      0.731 0.940 0.000 0.056 0.004
#> SRR949104     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR949105     3  0.0707      1.000 0.020 0.000 0.980 0.000
#> SRR949106     3  0.0707      1.000 0.020 0.000 0.980 0.000
#> SRR949107     3  0.0707      1.000 0.020 0.000 0.980 0.000
#> SRR949108     1  0.0779      0.727 0.980 0.004 0.016 0.000
#> SRR949109     4  0.0000      0.815 0.000 0.000 0.000 1.000
#> SRR949110     1  0.1022      0.732 0.968 0.000 0.032 0.000
#> SRR949111     4  0.0000      0.815 0.000 0.000 0.000 1.000
#> SRR949112     1  0.4871      0.693 0.768 0.008 0.188 0.036
#> SRR949113     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR949114     1  0.4313      0.658 0.736 0.004 0.260 0.000
#> SRR949115     1  0.4313      0.658 0.736 0.004 0.260 0.000
#> SRR949116     1  0.4313      0.658 0.736 0.004 0.260 0.000
#> SRR949117     1  0.7976      0.508 0.548 0.072 0.280 0.100
#> SRR949118     1  0.7545      0.453 0.516 0.084 0.360 0.040
#> SRR949119     1  0.5615      0.607 0.748 0.028 0.056 0.168
#> SRR949120     1  0.5615      0.607 0.748 0.028 0.056 0.168
#> SRR949121     1  0.0592      0.733 0.984 0.000 0.016 0.000
#> SRR949122     1  0.3831      0.689 0.792 0.004 0.204 0.000
#> SRR949123     2  0.0469      0.978 0.000 0.988 0.012 0.000
#> SRR949124     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR949125     4  0.0000      0.815 0.000 0.000 0.000 1.000
#> SRR949126     4  0.0000      0.815 0.000 0.000 0.000 1.000
#> SRR949127     2  0.1637      0.956 0.000 0.940 0.060 0.000
#> SRR949128     2  0.1637      0.956 0.000 0.940 0.060 0.000
#> SRR949129     2  0.1637      0.956 0.000 0.940 0.060 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
#> SRR949076     4  0.0000      1.000 0.000 0.000 0.000 1.000  0
#> SRR949078     2  0.3160      0.882 0.004 0.808 0.188 0.000  0
#> SRR949077     4  0.0000      1.000 0.000 0.000 0.000 1.000  0
#> SRR949079     4  0.0000      1.000 0.000 0.000 0.000 1.000  0
#> SRR949080     4  0.0000      1.000 0.000 0.000 0.000 1.000  0
#> SRR949081     3  0.0609      0.764 0.000 0.000 0.980 0.020  0
#> SRR949082     2  0.3266      0.872 0.004 0.796 0.200 0.000  0
#> SRR949083     1  0.0000      0.942 1.000 0.000 0.000 0.000  0
#> SRR949084     1  0.0162      0.942 0.996 0.000 0.004 0.000  0
#> SRR949085     2  0.2930      0.885 0.004 0.832 0.164 0.000  0
#> SRR949087     3  0.0162      0.769 0.000 0.000 0.996 0.004  0
#> SRR949088     3  0.0162      0.769 0.000 0.000 0.996 0.004  0
#> SRR949086     3  0.0162      0.769 0.000 0.000 0.996 0.004  0
#> SRR949089     2  0.0000      0.846 0.000 1.000 0.000 0.000  0
#> SRR949090     4  0.0000      1.000 0.000 0.000 0.000 1.000  0
#> SRR949092     1  0.0000      0.942 1.000 0.000 0.000 0.000  0
#> SRR949093     1  0.0000      0.942 1.000 0.000 0.000 0.000  0
#> SRR949091     4  0.0000      1.000 0.000 0.000 0.000 1.000  0
#> SRR949095     3  0.6890      0.450 0.048 0.168 0.556 0.228  0
#> SRR949094     4  0.0000      1.000 0.000 0.000 0.000 1.000  0
#> SRR949096     1  0.0000      0.942 1.000 0.000 0.000 0.000  0
#> SRR949097     1  0.0162      0.942 0.996 0.000 0.004 0.000  0
#> SRR949098     2  0.0000      0.846 0.000 1.000 0.000 0.000  0
#> SRR949099     3  0.0000      0.767 0.000 0.000 1.000 0.000  0
#> SRR949101     3  0.4030      0.464 0.000 0.000 0.648 0.352  0
#> SRR949100     3  0.0865      0.764 0.004 0.000 0.972 0.024  0
#> SRR949102     3  0.3305      0.620 0.000 0.000 0.776 0.224  0
#> SRR949103     1  0.0162      0.942 0.996 0.000 0.004 0.000  0
#> SRR949104     2  0.0000      0.846 0.000 1.000 0.000 0.000  0
#> SRR949105     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> SRR949106     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> SRR949107     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> SRR949108     1  0.0000      0.942 1.000 0.000 0.000 0.000  0
#> SRR949109     4  0.0000      1.000 0.000 0.000 0.000 1.000  0
#> SRR949110     1  0.0162      0.942 0.996 0.000 0.004 0.000  0
#> SRR949111     4  0.0000      1.000 0.000 0.000 0.000 1.000  0
#> SRR949112     1  0.2011      0.866 0.908 0.000 0.088 0.004  0
#> SRR949113     2  0.0000      0.846 0.000 1.000 0.000 0.000  0
#> SRR949114     3  0.4101      0.405 0.372 0.000 0.628 0.000  0
#> SRR949115     3  0.4171      0.354 0.396 0.000 0.604 0.000  0
#> SRR949116     3  0.4287      0.178 0.460 0.000 0.540 0.000  0
#> SRR949117     3  0.0162      0.769 0.000 0.000 0.996 0.004  0
#> SRR949118     3  0.0000      0.767 0.000 0.000 1.000 0.000  0
#> SRR949119     1  0.4402      0.678 0.740 0.000 0.056 0.204  0
#> SRR949120     1  0.4402      0.678 0.740 0.000 0.056 0.204  0
#> SRR949121     1  0.0000      0.942 1.000 0.000 0.000 0.000  0
#> SRR949122     1  0.0162      0.942 0.996 0.000 0.004 0.000  0
#> SRR949123     2  0.2732      0.886 0.000 0.840 0.160 0.000  0
#> SRR949124     2  0.0000      0.846 0.000 1.000 0.000 0.000  0
#> SRR949125     4  0.0000      1.000 0.000 0.000 0.000 1.000  0
#> SRR949126     4  0.0000      1.000 0.000 0.000 0.000 1.000  0
#> SRR949127     2  0.3074      0.880 0.000 0.804 0.196 0.000  0
#> SRR949128     2  0.3074      0.880 0.000 0.804 0.196 0.000  0
#> SRR949129     2  0.3074      0.880 0.000 0.804 0.196 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2 p3    p4    p5    p6
#> SRR949076     4  0.0260      0.982 0.000 0.008  0 0.992 0.000 0.000
#> SRR949078     2  0.4146      0.979 0.000 0.676  0 0.000 0.036 0.288
#> SRR949077     4  0.0260      0.983 0.000 0.008  0 0.992 0.000 0.000
#> SRR949079     4  0.0713      0.983 0.000 0.028  0 0.972 0.000 0.000
#> SRR949080     4  0.0713      0.983 0.000 0.028  0 0.972 0.000 0.000
#> SRR949081     5  0.1806      0.737 0.000 0.088  0 0.004 0.908 0.000
#> SRR949082     2  0.4210      0.974 0.000 0.672  0 0.000 0.040 0.288
#> SRR949083     1  0.0000      0.942 1.000 0.000  0 0.000 0.000 0.000
#> SRR949084     1  0.0146      0.940 0.996 0.000  0 0.000 0.004 0.000
#> SRR949085     2  0.3871      0.957 0.000 0.676  0 0.000 0.016 0.308
#> SRR949087     5  0.0000      0.766 0.000 0.000  0 0.000 1.000 0.000
#> SRR949088     5  0.0000      0.766 0.000 0.000  0 0.000 1.000 0.000
#> SRR949086     5  0.0146      0.765 0.000 0.000  0 0.004 0.996 0.000
#> SRR949089     6  0.0000      0.883 0.000 0.000  0 0.000 0.000 1.000
#> SRR949090     4  0.0547      0.985 0.000 0.020  0 0.980 0.000 0.000
#> SRR949092     1  0.0000      0.942 1.000 0.000  0 0.000 0.000 0.000
#> SRR949093     1  0.0000      0.942 1.000 0.000  0 0.000 0.000 0.000
#> SRR949091     4  0.0547      0.976 0.000 0.020  0 0.980 0.000 0.000
#> SRR949095     5  0.6086      0.459 0.020 0.256  0 0.180 0.540 0.004
#> SRR949094     4  0.0146      0.984 0.000 0.004  0 0.996 0.000 0.000
#> SRR949096     1  0.0000      0.942 1.000 0.000  0 0.000 0.000 0.000
#> SRR949097     1  0.0000      0.942 1.000 0.000  0 0.000 0.000 0.000
#> SRR949098     6  0.0000      0.883 0.000 0.000  0 0.000 0.000 1.000
#> SRR949099     5  0.0000      0.766 0.000 0.000  0 0.000 1.000 0.000
#> SRR949101     5  0.5234      0.442 0.000 0.124  0 0.300 0.576 0.000
#> SRR949100     5  0.1075      0.756 0.000 0.048  0 0.000 0.952 0.000
#> SRR949102     5  0.2726      0.709 0.000 0.112  0 0.032 0.856 0.000
#> SRR949103     1  0.0000      0.942 1.000 0.000  0 0.000 0.000 0.000
#> SRR949104     6  0.0000      0.883 0.000 0.000  0 0.000 0.000 1.000
#> SRR949105     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR949106     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR949107     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR949108     1  0.0000      0.942 1.000 0.000  0 0.000 0.000 0.000
#> SRR949109     4  0.0000      0.985 0.000 0.000  0 1.000 0.000 0.000
#> SRR949110     1  0.0000      0.942 1.000 0.000  0 0.000 0.000 0.000
#> SRR949111     4  0.0000      0.985 0.000 0.000  0 1.000 0.000 0.000
#> SRR949112     1  0.2301      0.841 0.884 0.020  0 0.000 0.096 0.000
#> SRR949113     6  0.1387      0.824 0.000 0.068  0 0.000 0.000 0.932
#> SRR949114     5  0.3890      0.343 0.400 0.004  0 0.000 0.596 0.000
#> SRR949115     5  0.3923      0.304 0.416 0.004  0 0.000 0.580 0.000
#> SRR949116     5  0.3997      0.083 0.488 0.004  0 0.000 0.508 0.000
#> SRR949117     5  0.0000      0.766 0.000 0.000  0 0.000 1.000 0.000
#> SRR949118     5  0.0000      0.766 0.000 0.000  0 0.000 1.000 0.000
#> SRR949119     1  0.4551      0.670 0.676 0.268  0 0.036 0.020 0.000
#> SRR949120     1  0.4551      0.670 0.676 0.268  0 0.036 0.020 0.000
#> SRR949121     1  0.0000      0.942 1.000 0.000  0 0.000 0.000 0.000
#> SRR949122     1  0.0146      0.940 0.996 0.000  0 0.000 0.004 0.000
#> SRR949123     6  0.3871      0.193 0.000 0.308  0 0.000 0.016 0.676
#> SRR949124     6  0.0000      0.883 0.000 0.000  0 0.000 0.000 1.000
#> SRR949125     4  0.0713      0.983 0.000 0.028  0 0.972 0.000 0.000
#> SRR949126     4  0.0713      0.983 0.000 0.028  0 0.972 0.000 0.000
#> SRR949127     2  0.4009      0.984 0.000 0.684  0 0.000 0.028 0.288
#> SRR949128     2  0.4009      0.984 0.000 0.684  0 0.000 0.028 0.288
#> SRR949129     2  0.4009      0.984 0.000 0.684  0 0.000 0.028 0.288

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

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 16816 rows and 54 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 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-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.812           0.869       0.948         0.4808 0.516   0.516
#> 3 3 0.706           0.821       0.906         0.3869 0.676   0.442
#> 4 4 0.926           0.894       0.956         0.1349 0.853   0.587
#> 5 5 0.847           0.767       0.870         0.0438 0.931   0.734
#> 6 6 0.860           0.779       0.876         0.0365 0.932   0.703

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
#> SRR949076     1  0.0000      0.950 1.000 0.000
#> SRR949078     2  0.0000      0.926 0.000 1.000
#> SRR949077     1  0.0000      0.950 1.000 0.000
#> SRR949079     1  0.0000      0.950 1.000 0.000
#> SRR949080     1  0.0000      0.950 1.000 0.000
#> SRR949081     2  0.0938      0.920 0.012 0.988
#> SRR949082     2  0.0000      0.926 0.000 1.000
#> SRR949083     1  0.0000      0.950 1.000 0.000
#> SRR949084     1  0.0000      0.950 1.000 0.000
#> SRR949085     2  0.0000      0.926 0.000 1.000
#> SRR949087     2  0.0000      0.926 0.000 1.000
#> SRR949088     2  0.0000      0.926 0.000 1.000
#> SRR949086     1  0.9608      0.338 0.616 0.384
#> SRR949089     2  0.0000      0.926 0.000 1.000
#> SRR949090     1  0.0000      0.950 1.000 0.000
#> SRR949092     1  0.0000      0.950 1.000 0.000
#> SRR949093     1  0.0000      0.950 1.000 0.000
#> SRR949091     1  0.0000      0.950 1.000 0.000
#> SRR949095     1  0.8207      0.641 0.744 0.256
#> SRR949094     1  0.0000      0.950 1.000 0.000
#> SRR949096     1  0.0000      0.950 1.000 0.000
#> SRR949097     1  0.0000      0.950 1.000 0.000
#> SRR949098     2  0.0000      0.926 0.000 1.000
#> SRR949099     1  0.0376      0.946 0.996 0.004
#> SRR949101     1  0.9580      0.362 0.620 0.380
#> SRR949100     2  0.8555      0.608 0.280 0.720
#> SRR949102     1  0.8081      0.655 0.752 0.248
#> SRR949103     1  0.0000      0.950 1.000 0.000
#> SRR949104     2  0.0000      0.926 0.000 1.000
#> SRR949105     2  0.3584      0.883 0.068 0.932
#> SRR949106     2  0.3733      0.879 0.072 0.928
#> SRR949107     2  0.2778      0.898 0.048 0.952
#> SRR949108     1  0.0000      0.950 1.000 0.000
#> SRR949109     1  0.0000      0.950 1.000 0.000
#> SRR949110     1  0.0000      0.950 1.000 0.000
#> SRR949111     1  0.0000      0.950 1.000 0.000
#> SRR949112     1  0.6712      0.761 0.824 0.176
#> SRR949113     2  0.0000      0.926 0.000 1.000
#> SRR949114     1  0.0000      0.950 1.000 0.000
#> SRR949115     1  0.0000      0.950 1.000 0.000
#> SRR949116     1  0.0000      0.950 1.000 0.000
#> SRR949117     2  0.9922      0.208 0.448 0.552
#> SRR949118     2  0.9896      0.233 0.440 0.560
#> SRR949119     1  0.0000      0.950 1.000 0.000
#> SRR949120     1  0.0000      0.950 1.000 0.000
#> SRR949121     1  0.0000      0.950 1.000 0.000
#> SRR949122     1  0.0000      0.950 1.000 0.000
#> SRR949123     2  0.0000      0.926 0.000 1.000
#> SRR949124     2  0.0000      0.926 0.000 1.000
#> SRR949125     1  0.0000      0.950 1.000 0.000
#> SRR949126     1  0.0000      0.950 1.000 0.000
#> SRR949127     2  0.0000      0.926 0.000 1.000
#> SRR949128     2  0.0000      0.926 0.000 1.000
#> SRR949129     2  0.0000      0.926 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
#> SRR949076     1  0.2959     0.8531 0.900 0.000 0.100
#> SRR949078     2  0.0000     0.9398 0.000 1.000 0.000
#> SRR949077     1  0.2959     0.8531 0.900 0.000 0.100
#> SRR949079     1  0.2959     0.8531 0.900 0.000 0.100
#> SRR949080     1  0.2959     0.8531 0.900 0.000 0.100
#> SRR949081     2  0.3293     0.8762 0.088 0.900 0.012
#> SRR949082     2  0.0000     0.9398 0.000 1.000 0.000
#> SRR949083     3  0.0000     0.9277 0.000 0.000 1.000
#> SRR949084     3  0.0000     0.9277 0.000 0.000 1.000
#> SRR949085     2  0.0000     0.9398 0.000 1.000 0.000
#> SRR949087     2  0.3234     0.8861 0.072 0.908 0.020
#> SRR949088     2  0.3234     0.8861 0.072 0.908 0.020
#> SRR949086     2  0.8069    -0.0151 0.460 0.476 0.064
#> SRR949089     2  0.0000     0.9398 0.000 1.000 0.000
#> SRR949090     1  0.2959     0.8531 0.900 0.000 0.100
#> SRR949092     3  0.0000     0.9277 0.000 0.000 1.000
#> SRR949093     3  0.0000     0.9277 0.000 0.000 1.000
#> SRR949091     1  0.2625     0.8455 0.916 0.000 0.084
#> SRR949095     1  0.8338     0.3924 0.516 0.400 0.084
#> SRR949094     1  0.2959     0.8531 0.900 0.000 0.100
#> SRR949096     3  0.0000     0.9277 0.000 0.000 1.000
#> SRR949097     3  0.0000     0.9277 0.000 0.000 1.000
#> SRR949098     2  0.0000     0.9398 0.000 1.000 0.000
#> SRR949099     3  0.2959     0.8681 0.100 0.000 0.900
#> SRR949101     1  0.0000     0.7900 1.000 0.000 0.000
#> SRR949100     2  0.3550     0.8612 0.024 0.896 0.080
#> SRR949102     1  0.5956     0.6643 0.768 0.188 0.044
#> SRR949103     3  0.0000     0.9277 0.000 0.000 1.000
#> SRR949104     2  0.0000     0.9398 0.000 1.000 0.000
#> SRR949105     1  0.6686     0.3421 0.612 0.372 0.016
#> SRR949106     1  0.6667     0.3514 0.616 0.368 0.016
#> SRR949107     1  0.6686     0.3421 0.612 0.372 0.016
#> SRR949108     3  0.0000     0.9277 0.000 0.000 1.000
#> SRR949109     1  0.2959     0.8531 0.900 0.000 0.100
#> SRR949110     3  0.0000     0.9277 0.000 0.000 1.000
#> SRR949111     1  0.2959     0.8531 0.900 0.000 0.100
#> SRR949112     3  0.0000     0.9277 0.000 0.000 1.000
#> SRR949113     2  0.0000     0.9398 0.000 1.000 0.000
#> SRR949114     3  0.2959     0.8681 0.100 0.000 0.900
#> SRR949115     3  0.2711     0.8771 0.088 0.000 0.912
#> SRR949116     3  0.2711     0.8771 0.088 0.000 0.912
#> SRR949117     3  0.8390     0.3432 0.100 0.340 0.560
#> SRR949118     3  0.8285     0.4627 0.112 0.288 0.600
#> SRR949119     3  0.0237     0.9252 0.004 0.000 0.996
#> SRR949120     3  0.0424     0.9221 0.008 0.000 0.992
#> SRR949121     3  0.0000     0.9277 0.000 0.000 1.000
#> SRR949122     3  0.0000     0.9277 0.000 0.000 1.000
#> SRR949123     2  0.0000     0.9398 0.000 1.000 0.000
#> SRR949124     2  0.0000     0.9398 0.000 1.000 0.000
#> SRR949125     1  0.2959     0.8531 0.900 0.000 0.100
#> SRR949126     1  0.2959     0.8531 0.900 0.000 0.100
#> SRR949127     2  0.0000     0.9398 0.000 1.000 0.000
#> SRR949128     2  0.0000     0.9398 0.000 1.000 0.000
#> SRR949129     2  0.0000     0.9398 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
#> SRR949076     4  0.0000     0.9569 0.000 0.000 0.000 1.000
#> SRR949078     2  0.0000     0.9545 0.000 1.000 0.000 0.000
#> SRR949077     4  0.0000     0.9569 0.000 0.000 0.000 1.000
#> SRR949079     4  0.0000     0.9569 0.000 0.000 0.000 1.000
#> SRR949080     4  0.0000     0.9569 0.000 0.000 0.000 1.000
#> SRR949081     3  0.1118     0.8974 0.000 0.036 0.964 0.000
#> SRR949082     2  0.0000     0.9545 0.000 1.000 0.000 0.000
#> SRR949083     1  0.0000     0.9693 1.000 0.000 0.000 0.000
#> SRR949084     1  0.0000     0.9693 1.000 0.000 0.000 0.000
#> SRR949085     2  0.0000     0.9545 0.000 1.000 0.000 0.000
#> SRR949087     3  0.4741     0.6957 0.028 0.228 0.744 0.000
#> SRR949088     3  0.4212     0.7234 0.012 0.216 0.772 0.000
#> SRR949086     3  0.0469     0.9142 0.000 0.000 0.988 0.012
#> SRR949089     2  0.0000     0.9545 0.000 1.000 0.000 0.000
#> SRR949090     4  0.0000     0.9569 0.000 0.000 0.000 1.000
#> SRR949092     1  0.0000     0.9693 1.000 0.000 0.000 0.000
#> SRR949093     1  0.0000     0.9693 1.000 0.000 0.000 0.000
#> SRR949091     4  0.0000     0.9569 0.000 0.000 0.000 1.000
#> SRR949095     4  0.5229     0.2590 0.000 0.428 0.008 0.564
#> SRR949094     4  0.0000     0.9569 0.000 0.000 0.000 1.000
#> SRR949096     1  0.0000     0.9693 1.000 0.000 0.000 0.000
#> SRR949097     1  0.0000     0.9693 1.000 0.000 0.000 0.000
#> SRR949098     2  0.0000     0.9545 0.000 1.000 0.000 0.000
#> SRR949099     3  0.0469     0.9124 0.012 0.000 0.988 0.000
#> SRR949101     3  0.0707     0.9122 0.000 0.000 0.980 0.020
#> SRR949100     2  0.6008    -0.0936 0.040 0.496 0.464 0.000
#> SRR949102     3  0.4543     0.5130 0.000 0.000 0.676 0.324
#> SRR949103     1  0.0000     0.9693 1.000 0.000 0.000 0.000
#> SRR949104     2  0.0000     0.9545 0.000 1.000 0.000 0.000
#> SRR949105     3  0.0657     0.9150 0.000 0.004 0.984 0.012
#> SRR949106     3  0.0657     0.9150 0.000 0.004 0.984 0.012
#> SRR949107     3  0.0657     0.9150 0.000 0.004 0.984 0.012
#> SRR949108     1  0.0000     0.9693 1.000 0.000 0.000 0.000
#> SRR949109     4  0.0000     0.9569 0.000 0.000 0.000 1.000
#> SRR949110     1  0.0000     0.9693 1.000 0.000 0.000 0.000
#> SRR949111     4  0.0000     0.9569 0.000 0.000 0.000 1.000
#> SRR949112     1  0.0000     0.9693 1.000 0.000 0.000 0.000
#> SRR949113     2  0.0000     0.9545 0.000 1.000 0.000 0.000
#> SRR949114     1  0.0000     0.9693 1.000 0.000 0.000 0.000
#> SRR949115     1  0.0000     0.9693 1.000 0.000 0.000 0.000
#> SRR949116     1  0.0000     0.9693 1.000 0.000 0.000 0.000
#> SRR949117     3  0.0469     0.9124 0.012 0.000 0.988 0.000
#> SRR949118     3  0.0469     0.9124 0.012 0.000 0.988 0.000
#> SRR949119     1  0.4472     0.7074 0.760 0.000 0.020 0.220
#> SRR949120     1  0.4399     0.7198 0.768 0.000 0.020 0.212
#> SRR949121     1  0.0000     0.9693 1.000 0.000 0.000 0.000
#> SRR949122     1  0.0000     0.9693 1.000 0.000 0.000 0.000
#> SRR949123     2  0.0000     0.9545 0.000 1.000 0.000 0.000
#> SRR949124     2  0.0000     0.9545 0.000 1.000 0.000 0.000
#> SRR949125     4  0.0000     0.9569 0.000 0.000 0.000 1.000
#> SRR949126     4  0.0000     0.9569 0.000 0.000 0.000 1.000
#> SRR949127     2  0.0000     0.9545 0.000 1.000 0.000 0.000
#> SRR949128     2  0.0000     0.9545 0.000 1.000 0.000 0.000
#> SRR949129     2  0.0000     0.9545 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
#> SRR949076     4  0.0000     0.9996 0.000 0.000 0.000 1.000 0.000
#> SRR949078     2  0.3074     0.8018 0.000 0.804 0.000 0.000 0.196
#> SRR949077     4  0.0000     0.9996 0.000 0.000 0.000 1.000 0.000
#> SRR949079     4  0.0000     0.9996 0.000 0.000 0.000 1.000 0.000
#> SRR949080     4  0.0000     0.9996 0.000 0.000 0.000 1.000 0.000
#> SRR949081     5  0.4557     0.1750 0.000 0.008 0.476 0.000 0.516
#> SRR949082     2  0.3177     0.7965 0.000 0.792 0.000 0.000 0.208
#> SRR949083     1  0.0000     0.9601 1.000 0.000 0.000 0.000 0.000
#> SRR949084     1  0.0000     0.9601 1.000 0.000 0.000 0.000 0.000
#> SRR949085     2  0.1732     0.8317 0.000 0.920 0.000 0.000 0.080
#> SRR949087     3  0.6963     0.2440 0.016 0.284 0.464 0.000 0.236
#> SRR949088     3  0.6911     0.2192 0.012 0.296 0.456 0.000 0.236
#> SRR949086     3  0.1478     0.5482 0.000 0.000 0.936 0.000 0.064
#> SRR949089     2  0.0000     0.8395 0.000 1.000 0.000 0.000 0.000
#> SRR949090     4  0.0000     0.9996 0.000 0.000 0.000 1.000 0.000
#> SRR949092     1  0.0000     0.9601 1.000 0.000 0.000 0.000 0.000
#> SRR949093     1  0.0000     0.9601 1.000 0.000 0.000 0.000 0.000
#> SRR949091     4  0.0000     0.9996 0.000 0.000 0.000 1.000 0.000
#> SRR949095     2  0.4268     0.0971 0.000 0.556 0.000 0.444 0.000
#> SRR949094     4  0.0162     0.9959 0.000 0.000 0.000 0.996 0.004
#> SRR949096     1  0.0000     0.9601 1.000 0.000 0.000 0.000 0.000
#> SRR949097     1  0.0000     0.9601 1.000 0.000 0.000 0.000 0.000
#> SRR949098     2  0.0000     0.8395 0.000 1.000 0.000 0.000 0.000
#> SRR949099     3  0.1732     0.5462 0.000 0.000 0.920 0.000 0.080
#> SRR949101     3  0.4251     0.5422 0.000 0.004 0.756 0.040 0.200
#> SRR949100     3  0.7184     0.0568 0.000 0.340 0.368 0.016 0.276
#> SRR949102     5  0.6066     0.3806 0.000 0.020 0.320 0.088 0.572
#> SRR949103     1  0.0000     0.9601 1.000 0.000 0.000 0.000 0.000
#> SRR949104     2  0.0000     0.8395 0.000 1.000 0.000 0.000 0.000
#> SRR949105     3  0.3333     0.5632 0.000 0.004 0.788 0.000 0.208
#> SRR949106     3  0.3333     0.5632 0.000 0.004 0.788 0.000 0.208
#> SRR949107     3  0.3333     0.5632 0.000 0.004 0.788 0.000 0.208
#> SRR949108     1  0.0000     0.9601 1.000 0.000 0.000 0.000 0.000
#> SRR949109     4  0.0000     0.9996 0.000 0.000 0.000 1.000 0.000
#> SRR949110     1  0.0000     0.9601 1.000 0.000 0.000 0.000 0.000
#> SRR949111     4  0.0000     0.9996 0.000 0.000 0.000 1.000 0.000
#> SRR949112     1  0.0000     0.9601 1.000 0.000 0.000 0.000 0.000
#> SRR949113     2  0.0000     0.8395 0.000 1.000 0.000 0.000 0.000
#> SRR949114     1  0.2932     0.8215 0.864 0.000 0.104 0.000 0.032
#> SRR949115     1  0.2932     0.8215 0.864 0.000 0.104 0.000 0.032
#> SRR949116     1  0.2932     0.8215 0.864 0.000 0.104 0.000 0.032
#> SRR949117     3  0.2516     0.5352 0.000 0.000 0.860 0.000 0.140
#> SRR949118     3  0.1410     0.5483 0.000 0.000 0.940 0.000 0.060
#> SRR949119     5  0.5427     0.5317 0.368 0.000 0.024 0.028 0.580
#> SRR949120     5  0.5361     0.5270 0.372 0.000 0.024 0.024 0.580
#> SRR949121     1  0.0000     0.9601 1.000 0.000 0.000 0.000 0.000
#> SRR949122     1  0.0000     0.9601 1.000 0.000 0.000 0.000 0.000
#> SRR949123     2  0.0000     0.8395 0.000 1.000 0.000 0.000 0.000
#> SRR949124     2  0.0000     0.8395 0.000 1.000 0.000 0.000 0.000
#> SRR949125     4  0.0000     0.9996 0.000 0.000 0.000 1.000 0.000
#> SRR949126     4  0.0000     0.9996 0.000 0.000 0.000 1.000 0.000
#> SRR949127     2  0.3819     0.7751 0.000 0.756 0.016 0.000 0.228
#> SRR949128     2  0.3819     0.7751 0.000 0.756 0.016 0.000 0.228
#> SRR949129     2  0.3819     0.7751 0.000 0.756 0.016 0.000 0.228

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR949076     4  0.0000     0.9904 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949078     2  0.4809     0.6947 0.000 0.668 0.000 0.000 0.140 0.192
#> SRR949077     4  0.0000     0.9904 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949079     4  0.0000     0.9904 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949080     4  0.0000     0.9904 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949081     6  0.3828     0.0012 0.000 0.000 0.000 0.000 0.440 0.560
#> SRR949082     2  0.4273     0.7247 0.000 0.732 0.000 0.000 0.148 0.120
#> SRR949083     1  0.0000     0.9968 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949084     1  0.0000     0.9968 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949085     2  0.1745     0.7738 0.000 0.920 0.000 0.000 0.068 0.012
#> SRR949087     6  0.4256     0.4636 0.024 0.044 0.012 0.000 0.148 0.772
#> SRR949088     6  0.4345     0.4621 0.024 0.044 0.016 0.000 0.148 0.768
#> SRR949086     6  0.3748     0.5091 0.000 0.000 0.108 0.000 0.108 0.784
#> SRR949089     2  0.0000     0.7813 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949090     4  0.0000     0.9904 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949092     1  0.0000     0.9968 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949093     1  0.0000     0.9968 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949091     4  0.0508     0.9899 0.000 0.000 0.012 0.984 0.004 0.000
#> SRR949095     2  0.4209     0.1927 0.000 0.588 0.012 0.396 0.004 0.000
#> SRR949094     4  0.0547     0.9776 0.000 0.000 0.000 0.980 0.020 0.000
#> SRR949096     1  0.0000     0.9968 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949097     1  0.0000     0.9968 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949098     2  0.0000     0.7813 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949099     6  0.3703     0.5104 0.000 0.000 0.108 0.000 0.104 0.788
#> SRR949101     3  0.1938     0.8938 0.000 0.000 0.920 0.040 0.004 0.036
#> SRR949100     6  0.4100     0.4867 0.000 0.032 0.016 0.020 0.152 0.780
#> SRR949102     5  0.3441     0.5909 0.000 0.004 0.004 0.008 0.768 0.216
#> SRR949103     1  0.0000     0.9968 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949104     2  0.0000     0.7813 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949105     3  0.0458     0.9657 0.000 0.000 0.984 0.000 0.000 0.016
#> SRR949106     3  0.0458     0.9657 0.000 0.000 0.984 0.000 0.000 0.016
#> SRR949107     3  0.0458     0.9657 0.000 0.000 0.984 0.000 0.000 0.016
#> SRR949108     1  0.0000     0.9968 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949109     4  0.0508     0.9899 0.000 0.000 0.012 0.984 0.004 0.000
#> SRR949110     1  0.0000     0.9968 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949111     4  0.0508     0.9899 0.000 0.000 0.012 0.984 0.004 0.000
#> SRR949112     1  0.0891     0.9637 0.968 0.000 0.000 0.000 0.008 0.024
#> SRR949113     2  0.0000     0.7813 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949114     6  0.4770     0.2513 0.448 0.000 0.004 0.000 0.040 0.508
#> SRR949115     6  0.4770     0.2513 0.448 0.000 0.004 0.000 0.040 0.508
#> SRR949116     6  0.4770     0.2513 0.448 0.000 0.004 0.000 0.040 0.508
#> SRR949117     6  0.1411     0.5379 0.000 0.000 0.060 0.000 0.004 0.936
#> SRR949118     6  0.3834     0.4949 0.000 0.000 0.116 0.000 0.108 0.776
#> SRR949119     5  0.2872     0.8261 0.152 0.000 0.012 0.000 0.832 0.004
#> SRR949120     5  0.2872     0.8261 0.152 0.000 0.012 0.000 0.832 0.004
#> SRR949121     1  0.0000     0.9968 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949122     1  0.0000     0.9968 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949123     2  0.0363     0.7751 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR949124     2  0.0000     0.7813 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949125     4  0.0508     0.9899 0.000 0.000 0.012 0.984 0.004 0.000
#> SRR949126     4  0.0508     0.9899 0.000 0.000 0.012 0.984 0.004 0.000
#> SRR949127     2  0.5265     0.6387 0.000 0.592 0.000 0.000 0.148 0.260
#> SRR949128     2  0.5265     0.6387 0.000 0.592 0.000 0.000 0.148 0.260
#> SRR949129     2  0.5283     0.6343 0.000 0.588 0.000 0.000 0.148 0.264

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

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

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

collect_plots(res)

plot of chunk MAD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.592           0.781       0.909         0.3550 0.628   0.628
#> 3 3 0.355           0.580       0.801         0.5854 0.677   0.524
#> 4 4 0.397           0.443       0.664         0.2328 0.736   0.451
#> 5 5 0.606           0.615       0.758         0.1041 0.836   0.509
#> 6 6 0.682           0.605       0.762         0.0478 0.987   0.940

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

suggest_best_k(res)
#> [1] 5

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
#> SRR949076     1   0.634     0.7526 0.840 0.160
#> SRR949078     2   0.999     0.2666 0.484 0.516
#> SRR949077     1   0.634     0.7526 0.840 0.160
#> SRR949079     1   0.000     0.9190 1.000 0.000
#> SRR949080     1   0.000     0.9190 1.000 0.000
#> SRR949081     1   0.697     0.7093 0.812 0.188
#> SRR949082     2   0.999     0.2666 0.484 0.516
#> SRR949083     1   0.634     0.7526 0.840 0.160
#> SRR949084     1   0.000     0.9190 1.000 0.000
#> SRR949085     2   0.000     0.7663 0.000 1.000
#> SRR949087     1   0.969     0.1027 0.604 0.396
#> SRR949088     1   0.969     0.1027 0.604 0.396
#> SRR949086     1   0.224     0.9063 0.964 0.036
#> SRR949089     2   0.000     0.7663 0.000 1.000
#> SRR949090     1   0.000     0.9190 1.000 0.000
#> SRR949092     1   0.000     0.9190 1.000 0.000
#> SRR949093     1   0.000     0.9190 1.000 0.000
#> SRR949091     1   0.204     0.9071 0.968 0.032
#> SRR949095     1   0.990    -0.0647 0.560 0.440
#> SRR949094     1   0.000     0.9190 1.000 0.000
#> SRR949096     1   0.000     0.9190 1.000 0.000
#> SRR949097     1   0.000     0.9190 1.000 0.000
#> SRR949098     2   0.000     0.7663 0.000 1.000
#> SRR949099     1   0.000     0.9190 1.000 0.000
#> SRR949101     1   0.204     0.9071 0.968 0.032
#> SRR949100     2   0.999     0.2850 0.484 0.516
#> SRR949102     1   0.697     0.7093 0.812 0.188
#> SRR949103     1   0.000     0.9190 1.000 0.000
#> SRR949104     2   0.000     0.7663 0.000 1.000
#> SRR949105     1   0.204     0.9071 0.968 0.032
#> SRR949106     1   0.204     0.9071 0.968 0.032
#> SRR949107     1   0.204     0.9071 0.968 0.032
#> SRR949108     1   0.000     0.9190 1.000 0.000
#> SRR949109     1   0.000     0.9190 1.000 0.000
#> SRR949110     1   0.000     0.9190 1.000 0.000
#> SRR949111     1   0.000     0.9190 1.000 0.000
#> SRR949112     1   0.000     0.9190 1.000 0.000
#> SRR949113     2   0.000     0.7663 0.000 1.000
#> SRR949114     1   0.204     0.9071 0.968 0.032
#> SRR949115     1   0.204     0.9071 0.968 0.032
#> SRR949116     1   0.204     0.9071 0.968 0.032
#> SRR949117     1   0.224     0.9063 0.964 0.036
#> SRR949118     1   0.204     0.9071 0.968 0.032
#> SRR949119     1   0.000     0.9190 1.000 0.000
#> SRR949120     1   0.000     0.9190 1.000 0.000
#> SRR949121     1   0.000     0.9190 1.000 0.000
#> SRR949122     1   0.000     0.9190 1.000 0.000
#> SRR949123     2   0.574     0.7404 0.136 0.864
#> SRR949124     2   0.000     0.7663 0.000 1.000
#> SRR949125     1   0.000     0.9190 1.000 0.000
#> SRR949126     1   0.000     0.9190 1.000 0.000
#> SRR949127     2   0.861     0.6620 0.284 0.716
#> SRR949128     2   0.861     0.6620 0.284 0.716
#> SRR949129     2   0.861     0.6620 0.284 0.716

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR949076     1  0.6225      0.345 0.568 0.000 0.432
#> SRR949078     1  0.4504      0.365 0.804 0.196 0.000
#> SRR949077     1  0.6225      0.345 0.568 0.000 0.432
#> SRR949079     3  0.5926      0.192 0.356 0.000 0.644
#> SRR949080     3  0.5926      0.192 0.356 0.000 0.644
#> SRR949081     1  0.6339      0.428 0.632 0.008 0.360
#> SRR949082     1  0.4504      0.365 0.804 0.196 0.000
#> SRR949083     1  0.5497      0.432 0.708 0.000 0.292
#> SRR949084     1  0.6267      0.147 0.548 0.000 0.452
#> SRR949085     2  0.1964      0.901 0.056 0.944 0.000
#> SRR949087     1  0.4821      0.513 0.848 0.064 0.088
#> SRR949088     1  0.4821      0.513 0.848 0.064 0.088
#> SRR949086     3  0.1411      0.776 0.036 0.000 0.964
#> SRR949089     2  0.0000      0.934 0.000 1.000 0.000
#> SRR949090     3  0.3192      0.739 0.112 0.000 0.888
#> SRR949092     3  0.4178      0.776 0.172 0.000 0.828
#> SRR949093     3  0.4178      0.776 0.172 0.000 0.828
#> SRR949091     3  0.1289      0.778 0.032 0.000 0.968
#> SRR949095     1  0.1482      0.466 0.968 0.020 0.012
#> SRR949094     3  0.5926      0.192 0.356 0.000 0.644
#> SRR949096     1  0.6267      0.147 0.548 0.000 0.452
#> SRR949097     3  0.4062      0.782 0.164 0.000 0.836
#> SRR949098     2  0.0000      0.934 0.000 1.000 0.000
#> SRR949099     3  0.2261      0.794 0.068 0.000 0.932
#> SRR949101     3  0.1289      0.778 0.032 0.000 0.968
#> SRR949100     1  0.9441      0.261 0.484 0.316 0.200
#> SRR949102     1  0.6339      0.428 0.632 0.008 0.360
#> SRR949103     3  0.4062      0.782 0.164 0.000 0.836
#> SRR949104     2  0.0237      0.934 0.004 0.996 0.000
#> SRR949105     3  0.1289      0.778 0.032 0.000 0.968
#> SRR949106     3  0.1289      0.778 0.032 0.000 0.968
#> SRR949107     3  0.1289      0.778 0.032 0.000 0.968
#> SRR949108     3  0.4062      0.782 0.164 0.000 0.836
#> SRR949109     3  0.3192      0.739 0.112 0.000 0.888
#> SRR949110     3  0.4062      0.782 0.164 0.000 0.836
#> SRR949111     3  0.3192      0.739 0.112 0.000 0.888
#> SRR949112     3  0.4062      0.782 0.164 0.000 0.836
#> SRR949113     2  0.0237      0.934 0.004 0.996 0.000
#> SRR949114     3  0.3816      0.776 0.148 0.000 0.852
#> SRR949115     3  0.3816      0.776 0.148 0.000 0.852
#> SRR949116     3  0.3816      0.776 0.148 0.000 0.852
#> SRR949117     3  0.1411      0.776 0.036 0.000 0.964
#> SRR949118     3  0.1289      0.778 0.032 0.000 0.968
#> SRR949119     1  0.6280      0.127 0.540 0.000 0.460
#> SRR949120     1  0.6280      0.127 0.540 0.000 0.460
#> SRR949121     3  0.4062      0.782 0.164 0.000 0.836
#> SRR949122     3  0.4062      0.782 0.164 0.000 0.836
#> SRR949123     2  0.5591      0.583 0.304 0.696 0.000
#> SRR949124     2  0.0000      0.934 0.000 1.000 0.000
#> SRR949125     3  0.3192      0.739 0.112 0.000 0.888
#> SRR949126     3  0.3192      0.739 0.112 0.000 0.888
#> SRR949127     1  0.6295     -0.150 0.528 0.472 0.000
#> SRR949128     1  0.6295     -0.150 0.528 0.472 0.000
#> SRR949129     1  0.6295     -0.150 0.528 0.472 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR949076     1   0.490    -0.0046 0.584 0.000 0.000 0.416
#> SRR949078     4   0.327     0.5527 0.000 0.168 0.000 0.832
#> SRR949077     1   0.490    -0.0046 0.584 0.000 0.000 0.416
#> SRR949079     1   0.331     0.3692 0.828 0.000 0.000 0.172
#> SRR949080     1   0.331     0.3692 0.828 0.000 0.000 0.172
#> SRR949081     4   0.661     0.3354 0.168 0.000 0.204 0.628
#> SRR949082     4   0.327     0.5527 0.000 0.168 0.000 0.832
#> SRR949083     4   0.719     0.0227 0.244 0.000 0.204 0.552
#> SRR949084     1   0.760     0.2997 0.436 0.000 0.204 0.360
#> SRR949085     2   0.156     0.8450 0.000 0.944 0.000 0.056
#> SRR949087     4   0.385     0.6022 0.044 0.036 0.052 0.868
#> SRR949088     4   0.385     0.6022 0.044 0.036 0.052 0.868
#> SRR949086     3   0.475     0.7198 0.304 0.000 0.688 0.008
#> SRR949089     2   0.000     0.8753 0.000 1.000 0.000 0.000
#> SRR949090     1   0.201     0.3243 0.920 0.000 0.080 0.000
#> SRR949092     1   0.688     0.3803 0.520 0.000 0.368 0.112
#> SRR949093     1   0.688     0.3803 0.520 0.000 0.368 0.112
#> SRR949091     3   0.500     0.5130 0.484 0.000 0.516 0.000
#> SRR949095     4   0.287     0.5379 0.136 0.000 0.000 0.864
#> SRR949094     1   0.331     0.3692 0.828 0.000 0.000 0.172
#> SRR949096     1   0.760     0.2997 0.436 0.000 0.204 0.360
#> SRR949097     1   0.689     0.3750 0.512 0.000 0.376 0.112
#> SRR949098     2   0.000     0.8753 0.000 1.000 0.000 0.000
#> SRR949099     1   0.564     0.0908 0.636 0.000 0.324 0.040
#> SRR949101     3   0.419     0.7422 0.268 0.000 0.732 0.000
#> SRR949100     4   0.885     0.3806 0.180 0.164 0.144 0.512
#> SRR949102     4   0.661     0.3354 0.168 0.000 0.204 0.628
#> SRR949103     1   0.689     0.3750 0.512 0.000 0.376 0.112
#> SRR949104     2   0.298     0.8351 0.000 0.872 0.120 0.008
#> SRR949105     3   0.419     0.7422 0.268 0.000 0.732 0.000
#> SRR949106     3   0.419     0.7422 0.268 0.000 0.732 0.000
#> SRR949107     3   0.419     0.7422 0.268 0.000 0.732 0.000
#> SRR949108     1   0.689     0.3750 0.512 0.000 0.376 0.112
#> SRR949109     1   0.187     0.3370 0.928 0.000 0.072 0.000
#> SRR949110     1   0.689     0.3750 0.512 0.000 0.376 0.112
#> SRR949111     1   0.187     0.3370 0.928 0.000 0.072 0.000
#> SRR949112     1   0.689     0.3750 0.512 0.000 0.376 0.112
#> SRR949113     2   0.298     0.8351 0.000 0.872 0.120 0.008
#> SRR949114     3   0.668     0.1529 0.312 0.000 0.576 0.112
#> SRR949115     3   0.668     0.1529 0.312 0.000 0.576 0.112
#> SRR949116     3   0.668     0.1529 0.312 0.000 0.576 0.112
#> SRR949117     3   0.475     0.7198 0.304 0.000 0.688 0.008
#> SRR949118     3   0.422     0.7414 0.272 0.000 0.728 0.000
#> SRR949119     1   0.762     0.3202 0.444 0.000 0.212 0.344
#> SRR949120     1   0.762     0.3202 0.444 0.000 0.212 0.344
#> SRR949121     1   0.689     0.3750 0.512 0.000 0.376 0.112
#> SRR949122     1   0.689     0.3750 0.512 0.000 0.376 0.112
#> SRR949123     2   0.456     0.4678 0.000 0.672 0.000 0.328
#> SRR949124     2   0.000     0.8753 0.000 1.000 0.000 0.000
#> SRR949125     1   0.187     0.3370 0.928 0.000 0.072 0.000
#> SRR949126     1   0.187     0.3370 0.928 0.000 0.072 0.000
#> SRR949127     4   0.681     0.2685 0.000 0.320 0.120 0.560
#> SRR949128     4   0.681     0.2685 0.000 0.320 0.120 0.560
#> SRR949129     4   0.681     0.2685 0.000 0.320 0.120 0.560

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR949076     4  0.4374      0.407 0.028 0.000 0.000 0.700 0.272
#> SRR949078     5  0.2806      0.594 0.000 0.152 0.000 0.004 0.844
#> SRR949077     4  0.4374      0.407 0.028 0.000 0.000 0.700 0.272
#> SRR949079     4  0.5851      0.664 0.272 0.000 0.000 0.588 0.140
#> SRR949080     4  0.5851      0.664 0.272 0.000 0.000 0.588 0.140
#> SRR949081     5  0.7021      0.349 0.140 0.000 0.232 0.072 0.556
#> SRR949082     5  0.2806      0.594 0.000 0.152 0.000 0.004 0.844
#> SRR949083     1  0.7106      0.155 0.428 0.000 0.060 0.112 0.400
#> SRR949084     1  0.6325      0.386 0.620 0.000 0.060 0.088 0.232
#> SRR949085     2  0.4575      0.797 0.000 0.712 0.000 0.236 0.052
#> SRR949087     5  0.2653      0.624 0.052 0.020 0.028 0.000 0.900
#> SRR949088     5  0.2653      0.624 0.052 0.020 0.028 0.000 0.900
#> SRR949086     3  0.3043      0.880 0.104 0.000 0.864 0.008 0.024
#> SRR949089     2  0.3612      0.818 0.000 0.732 0.000 0.268 0.000
#> SRR949090     4  0.5178      0.642 0.476 0.000 0.040 0.484 0.000
#> SRR949092     1  0.0162      0.704 0.996 0.000 0.000 0.004 0.000
#> SRR949093     1  0.0162      0.704 0.996 0.000 0.000 0.004 0.000
#> SRR949091     3  0.5498      0.392 0.076 0.000 0.568 0.356 0.000
#> SRR949095     5  0.3701      0.530 0.004 0.000 0.060 0.112 0.824
#> SRR949094     4  0.5851      0.664 0.272 0.000 0.000 0.588 0.140
#> SRR949096     1  0.6325      0.386 0.620 0.000 0.060 0.088 0.232
#> SRR949097     1  0.0162      0.707 0.996 0.000 0.004 0.000 0.000
#> SRR949098     2  0.3612      0.818 0.000 0.732 0.000 0.268 0.000
#> SRR949099     1  0.4397      0.349 0.696 0.000 0.276 0.028 0.000
#> SRR949101     3  0.1544      0.909 0.068 0.000 0.932 0.000 0.000
#> SRR949100     5  0.7251      0.428 0.200 0.268 0.016 0.020 0.496
#> SRR949102     5  0.7946      0.331 0.140 0.000 0.232 0.176 0.452
#> SRR949103     1  0.0162      0.707 0.996 0.000 0.004 0.000 0.000
#> SRR949104     2  0.0290      0.692 0.000 0.992 0.000 0.000 0.008
#> SRR949105     3  0.1544      0.909 0.068 0.000 0.932 0.000 0.000
#> SRR949106     3  0.1544      0.909 0.068 0.000 0.932 0.000 0.000
#> SRR949107     3  0.1544      0.909 0.068 0.000 0.932 0.000 0.000
#> SRR949108     1  0.0162      0.707 0.996 0.000 0.004 0.000 0.000
#> SRR949109     4  0.5049      0.647 0.480 0.000 0.032 0.488 0.000
#> SRR949110     1  0.0162      0.707 0.996 0.000 0.004 0.000 0.000
#> SRR949111     4  0.5049      0.647 0.480 0.000 0.032 0.488 0.000
#> SRR949112     1  0.0162      0.707 0.996 0.000 0.004 0.000 0.000
#> SRR949113     2  0.0404      0.688 0.000 0.988 0.000 0.000 0.012
#> SRR949114     1  0.3492      0.580 0.796 0.000 0.188 0.000 0.016
#> SRR949115     1  0.3492      0.580 0.796 0.000 0.188 0.000 0.016
#> SRR949116     1  0.3492      0.580 0.796 0.000 0.188 0.000 0.016
#> SRR949117     3  0.3043      0.880 0.104 0.000 0.864 0.008 0.024
#> SRR949118     3  0.2331      0.902 0.068 0.000 0.908 0.008 0.016
#> SRR949119     1  0.5732      0.338 0.624 0.000 0.000 0.192 0.184
#> SRR949120     1  0.5732      0.338 0.624 0.000 0.000 0.192 0.184
#> SRR949121     1  0.0162      0.707 0.996 0.000 0.004 0.000 0.000
#> SRR949122     1  0.0162      0.707 0.996 0.000 0.004 0.000 0.000
#> SRR949123     2  0.6973      0.419 0.000 0.404 0.008 0.268 0.320
#> SRR949124     2  0.3612      0.818 0.000 0.732 0.000 0.268 0.000
#> SRR949125     4  0.5049      0.647 0.480 0.000 0.032 0.488 0.000
#> SRR949126     4  0.5049      0.647 0.480 0.000 0.032 0.488 0.000
#> SRR949127     5  0.4235      0.443 0.000 0.424 0.000 0.000 0.576
#> SRR949128     5  0.4235      0.443 0.000 0.424 0.000 0.000 0.576
#> SRR949129     5  0.4235      0.443 0.000 0.424 0.000 0.000 0.576

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR949076     4  0.0363     0.3691 0.000 0.000 0.000 0.988 0.000 0.012
#> SRR949078     5  0.2655     0.6360 0.000 0.140 0.000 0.004 0.848 0.008
#> SRR949077     4  0.0363     0.3691 0.000 0.000 0.000 0.988 0.000 0.012
#> SRR949079     4  0.3023     0.6943 0.232 0.000 0.000 0.768 0.000 0.000
#> SRR949080     4  0.3023     0.6943 0.232 0.000 0.000 0.768 0.000 0.000
#> SRR949081     6  0.5291     0.4322 0.000 0.000 0.016 0.060 0.448 0.476
#> SRR949082     5  0.2655     0.6360 0.000 0.140 0.000 0.004 0.848 0.008
#> SRR949083     1  0.6633     0.0552 0.404 0.000 0.000 0.064 0.388 0.144
#> SRR949084     1  0.5982     0.4333 0.596 0.000 0.000 0.064 0.220 0.120
#> SRR949085     2  0.1606     0.7873 0.000 0.932 0.000 0.004 0.056 0.008
#> SRR949087     5  0.2231     0.5622 0.028 0.016 0.000 0.000 0.908 0.048
#> SRR949088     5  0.2231     0.5622 0.028 0.016 0.000 0.000 0.908 0.048
#> SRR949086     3  0.4267     0.6715 0.012 0.000 0.688 0.000 0.028 0.272
#> SRR949089     2  0.0000     0.8059 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949090     4  0.4912     0.6922 0.432 0.000 0.008 0.516 0.000 0.044
#> SRR949092     1  0.0291     0.7143 0.992 0.000 0.000 0.004 0.000 0.004
#> SRR949093     1  0.0291     0.7143 0.992 0.000 0.000 0.004 0.000 0.004
#> SRR949091     3  0.4518     0.3670 0.000 0.000 0.604 0.352 0.000 0.044
#> SRR949095     5  0.3453     0.3216 0.000 0.000 0.000 0.064 0.804 0.132
#> SRR949094     4  0.3023     0.6943 0.232 0.000 0.000 0.768 0.000 0.000
#> SRR949096     1  0.5982     0.4333 0.596 0.000 0.000 0.064 0.220 0.120
#> SRR949097     1  0.0632     0.7157 0.976 0.000 0.000 0.000 0.000 0.024
#> SRR949098     2  0.0000     0.8059 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949099     1  0.4766     0.2830 0.612 0.000 0.072 0.000 0.000 0.316
#> SRR949101     3  0.0000     0.7821 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949100     5  0.5372     0.3739 0.112 0.000 0.000 0.000 0.484 0.404
#> SRR949102     6  0.5768     0.5438 0.000 0.000 0.016 0.408 0.112 0.464
#> SRR949103     1  0.0632     0.7157 0.976 0.000 0.000 0.000 0.000 0.024
#> SRR949104     2  0.3330     0.6717 0.000 0.716 0.000 0.000 0.000 0.284
#> SRR949105     3  0.0000     0.7821 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949106     3  0.0000     0.7821 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949107     3  0.0000     0.7821 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949108     1  0.0000     0.7157 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949109     4  0.4681     0.6990 0.432 0.000 0.000 0.524 0.000 0.044
#> SRR949110     1  0.0632     0.7157 0.976 0.000 0.000 0.000 0.000 0.024
#> SRR949111     4  0.4681     0.6990 0.432 0.000 0.000 0.524 0.000 0.044
#> SRR949112     1  0.0000     0.7157 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949113     2  0.3468     0.6675 0.000 0.712 0.000 0.000 0.004 0.284
#> SRR949114     1  0.3432     0.6145 0.800 0.000 0.148 0.000 0.000 0.052
#> SRR949115     1  0.3432     0.6145 0.800 0.000 0.148 0.000 0.000 0.052
#> SRR949116     1  0.3432     0.6145 0.800 0.000 0.148 0.000 0.000 0.052
#> SRR949117     3  0.4267     0.6715 0.012 0.000 0.688 0.000 0.028 0.272
#> SRR949118     3  0.3244     0.6937 0.000 0.000 0.732 0.000 0.000 0.268
#> SRR949119     1  0.5147     0.2351 0.548 0.000 0.000 0.356 0.000 0.096
#> SRR949120     1  0.5147     0.2351 0.548 0.000 0.000 0.356 0.000 0.096
#> SRR949121     1  0.0000     0.7157 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949122     1  0.0000     0.7157 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949123     2  0.4408     0.4064 0.000 0.664 0.000 0.000 0.280 0.056
#> SRR949124     2  0.0000     0.8059 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949125     4  0.4681     0.6990 0.432 0.000 0.000 0.524 0.000 0.044
#> SRR949126     4  0.4681     0.6990 0.432 0.000 0.000 0.524 0.000 0.044
#> SRR949127     5  0.5336     0.6164 0.000 0.144 0.000 0.000 0.572 0.284
#> SRR949128     5  0.5336     0.6164 0.000 0.144 0.000 0.000 0.572 0.284
#> SRR949129     5  0.5336     0.6164 0.000 0.144 0.000 0.000 0.572 0.284

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

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

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

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.666           0.877       0.932         0.4310 0.575   0.575
#> 3 3 0.459           0.547       0.773         0.4614 0.735   0.568
#> 4 4 0.536           0.582       0.729         0.1585 0.834   0.585
#> 5 5 0.594           0.627       0.727         0.0779 0.943   0.778
#> 6 6 0.716           0.536       0.712         0.0435 0.983   0.919

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

suggest_best_k(res)
#> [1] 5

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
#> SRR949076     1  0.2778      0.918 0.952 0.048
#> SRR949078     2  0.1184      0.930 0.016 0.984
#> SRR949077     1  0.2778      0.918 0.952 0.048
#> SRR949079     1  0.2778      0.918 0.952 0.048
#> SRR949080     1  0.2778      0.918 0.952 0.048
#> SRR949081     2  0.8555      0.616 0.280 0.720
#> SRR949082     2  0.1184      0.930 0.016 0.984
#> SRR949083     1  0.2778      0.918 0.952 0.048
#> SRR949084     1  0.2778      0.918 0.952 0.048
#> SRR949085     2  0.0672      0.929 0.008 0.992
#> SRR949087     2  0.6343      0.811 0.160 0.840
#> SRR949088     2  0.6343      0.811 0.160 0.840
#> SRR949086     1  0.6801      0.810 0.820 0.180
#> SRR949089     2  0.0672      0.929 0.008 0.992
#> SRR949090     1  0.0000      0.922 1.000 0.000
#> SRR949092     1  0.2778      0.918 0.952 0.048
#> SRR949093     1  0.2778      0.918 0.952 0.048
#> SRR949091     1  0.1843      0.914 0.972 0.028
#> SRR949095     2  0.9129      0.540 0.328 0.672
#> SRR949094     1  0.0000      0.922 1.000 0.000
#> SRR949096     1  0.2778      0.918 0.952 0.048
#> SRR949097     1  0.0000      0.922 1.000 0.000
#> SRR949098     2  0.0672      0.929 0.008 0.992
#> SRR949099     1  0.0000      0.922 1.000 0.000
#> SRR949101     1  0.6712      0.814 0.824 0.176
#> SRR949100     1  0.9833      0.300 0.576 0.424
#> SRR949102     1  0.7139      0.806 0.804 0.196
#> SRR949103     1  0.0000      0.922 1.000 0.000
#> SRR949104     2  0.0672      0.929 0.008 0.992
#> SRR949105     1  0.6887      0.806 0.816 0.184
#> SRR949106     1  0.6887      0.806 0.816 0.184
#> SRR949107     1  0.6887      0.806 0.816 0.184
#> SRR949108     1  0.0000      0.922 1.000 0.000
#> SRR949109     1  0.0000      0.922 1.000 0.000
#> SRR949110     1  0.0000      0.922 1.000 0.000
#> SRR949111     1  0.0000      0.922 1.000 0.000
#> SRR949112     1  0.2778      0.918 0.952 0.048
#> SRR949113     2  0.1184      0.930 0.016 0.984
#> SRR949114     1  0.1843      0.914 0.972 0.028
#> SRR949115     1  0.1843      0.914 0.972 0.028
#> SRR949116     1  0.1843      0.914 0.972 0.028
#> SRR949117     1  0.6801      0.810 0.820 0.180
#> SRR949118     1  0.6712      0.814 0.824 0.176
#> SRR949119     1  0.2778      0.918 0.952 0.048
#> SRR949120     1  0.2778      0.918 0.952 0.048
#> SRR949121     1  0.0000      0.922 1.000 0.000
#> SRR949122     1  0.2778      0.918 0.952 0.048
#> SRR949123     2  0.0672      0.929 0.008 0.992
#> SRR949124     2  0.0672      0.929 0.008 0.992
#> SRR949125     1  0.0000      0.922 1.000 0.000
#> SRR949126     1  0.0000      0.922 1.000 0.000
#> SRR949127     2  0.1184      0.930 0.016 0.984
#> SRR949128     2  0.1184      0.930 0.016 0.984
#> SRR949129     2  0.1184      0.930 0.016 0.984

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR949076     1  0.5115      0.562 0.768 0.004 0.228
#> SRR949078     2  0.1453      0.895 0.024 0.968 0.008
#> SRR949077     1  0.5070      0.564 0.772 0.004 0.224
#> SRR949079     1  0.5244      0.565 0.756 0.004 0.240
#> SRR949080     1  0.5244      0.565 0.756 0.004 0.240
#> SRR949081     1  0.9144     -0.075 0.448 0.408 0.144
#> SRR949082     2  0.1453      0.895 0.024 0.968 0.008
#> SRR949083     1  0.1315      0.637 0.972 0.020 0.008
#> SRR949084     1  0.0848      0.642 0.984 0.008 0.008
#> SRR949085     2  0.1529      0.901 0.000 0.960 0.040
#> SRR949087     2  0.8085      0.401 0.332 0.584 0.084
#> SRR949088     2  0.8085      0.401 0.332 0.584 0.084
#> SRR949086     3  0.5791      0.728 0.148 0.060 0.792
#> SRR949089     2  0.1643      0.900 0.000 0.956 0.044
#> SRR949090     3  0.6302     -0.229 0.480 0.000 0.520
#> SRR949092     1  0.1878      0.648 0.952 0.004 0.044
#> SRR949093     1  0.1878      0.648 0.952 0.004 0.044
#> SRR949091     3  0.2400      0.659 0.064 0.004 0.932
#> SRR949095     1  0.7015      0.179 0.584 0.392 0.024
#> SRR949094     1  0.5016      0.565 0.760 0.000 0.240
#> SRR949096     1  0.0848      0.642 0.984 0.008 0.008
#> SRR949097     1  0.5480      0.427 0.732 0.004 0.264
#> SRR949098     2  0.1643      0.900 0.000 0.956 0.044
#> SRR949099     3  0.6264      0.364 0.380 0.004 0.616
#> SRR949101     3  0.3973      0.729 0.088 0.032 0.880
#> SRR949100     1  0.9374      0.194 0.464 0.360 0.176
#> SRR949102     1  0.6361      0.480 0.728 0.040 0.232
#> SRR949103     1  0.5656      0.390 0.712 0.004 0.284
#> SRR949104     2  0.1529      0.901 0.000 0.960 0.040
#> SRR949105     3  0.5165      0.743 0.096 0.072 0.832
#> SRR949106     3  0.5165      0.743 0.096 0.072 0.832
#> SRR949107     3  0.5165      0.743 0.096 0.072 0.832
#> SRR949108     1  0.1878      0.648 0.952 0.004 0.044
#> SRR949109     3  0.6305     -0.240 0.484 0.000 0.516
#> SRR949110     1  0.5480      0.427 0.732 0.004 0.264
#> SRR949111     1  0.6267      0.289 0.548 0.000 0.452
#> SRR949112     1  0.2400      0.640 0.932 0.004 0.064
#> SRR949113     2  0.1647      0.901 0.004 0.960 0.036
#> SRR949114     1  0.6678     -0.130 0.512 0.008 0.480
#> SRR949115     1  0.6678     -0.130 0.512 0.008 0.480
#> SRR949116     1  0.6678     -0.130 0.512 0.008 0.480
#> SRR949117     3  0.5791      0.728 0.148 0.060 0.792
#> SRR949118     3  0.5222      0.732 0.144 0.040 0.816
#> SRR949119     1  0.1950      0.649 0.952 0.008 0.040
#> SRR949120     1  0.1950      0.649 0.952 0.008 0.040
#> SRR949121     1  0.2772      0.631 0.916 0.004 0.080
#> SRR949122     1  0.1878      0.648 0.952 0.004 0.044
#> SRR949123     2  0.1643      0.900 0.000 0.956 0.044
#> SRR949124     2  0.1643      0.900 0.000 0.956 0.044
#> SRR949125     1  0.6307      0.208 0.512 0.000 0.488
#> SRR949126     1  0.6307      0.208 0.512 0.000 0.488
#> SRR949127     2  0.1031      0.898 0.024 0.976 0.000
#> SRR949128     2  0.1031      0.898 0.024 0.976 0.000
#> SRR949129     2  0.1031      0.898 0.024 0.976 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR949076     4  0.5284     0.5541 0.264 0.000 0.040 0.696
#> SRR949078     2  0.4781     0.8011 0.008 0.772 0.032 0.188
#> SRR949077     4  0.5078     0.5488 0.272 0.000 0.028 0.700
#> SRR949079     4  0.5417     0.5863 0.284 0.000 0.040 0.676
#> SRR949080     4  0.5417     0.5863 0.284 0.000 0.040 0.676
#> SRR949081     4  0.9443    -0.0852 0.168 0.204 0.200 0.428
#> SRR949082     2  0.4781     0.8011 0.008 0.772 0.032 0.188
#> SRR949083     1  0.3975     0.5089 0.760 0.000 0.000 0.240
#> SRR949084     1  0.3444     0.5536 0.816 0.000 0.000 0.184
#> SRR949085     2  0.0336     0.8301 0.000 0.992 0.008 0.000
#> SRR949087     2  0.9525     0.3427 0.236 0.360 0.120 0.284
#> SRR949088     2  0.9525     0.3427 0.236 0.360 0.120 0.284
#> SRR949086     3  0.2775     0.8156 0.084 0.000 0.896 0.020
#> SRR949089     2  0.0188     0.8304 0.000 0.996 0.004 0.000
#> SRR949090     4  0.7474     0.5493 0.292 0.000 0.212 0.496
#> SRR949092     1  0.1174     0.6767 0.968 0.000 0.012 0.020
#> SRR949093     1  0.1174     0.6767 0.968 0.000 0.012 0.020
#> SRR949091     3  0.4718     0.5048 0.012 0.000 0.708 0.280
#> SRR949095     4  0.8733    -0.1022 0.268 0.256 0.048 0.428
#> SRR949094     4  0.5417     0.5863 0.284 0.000 0.040 0.676
#> SRR949096     1  0.3444     0.5536 0.816 0.000 0.000 0.184
#> SRR949097     1  0.3013     0.6401 0.888 0.000 0.080 0.032
#> SRR949098     2  0.0336     0.8301 0.000 0.992 0.008 0.000
#> SRR949099     3  0.6285     0.2169 0.412 0.000 0.528 0.060
#> SRR949101     3  0.2670     0.8179 0.040 0.000 0.908 0.052
#> SRR949100     1  0.9501    -0.0660 0.388 0.244 0.128 0.240
#> SRR949102     4  0.8088     0.1905 0.300 0.012 0.248 0.440
#> SRR949103     1  0.3342     0.6246 0.868 0.000 0.100 0.032
#> SRR949104     2  0.0000     0.8306 0.000 1.000 0.000 0.000
#> SRR949105     3  0.3796     0.8247 0.056 0.000 0.848 0.096
#> SRR949106     3  0.3796     0.8247 0.056 0.000 0.848 0.096
#> SRR949107     3  0.3796     0.8247 0.056 0.000 0.848 0.096
#> SRR949108     1  0.0672     0.6769 0.984 0.000 0.008 0.008
#> SRR949109     4  0.7474     0.5493 0.292 0.000 0.212 0.496
#> SRR949110     1  0.2943     0.6411 0.892 0.000 0.076 0.032
#> SRR949111     4  0.7330     0.5669 0.304 0.000 0.184 0.512
#> SRR949112     1  0.1388     0.6787 0.960 0.000 0.028 0.012
#> SRR949113     2  0.0000     0.8306 0.000 1.000 0.000 0.000
#> SRR949114     1  0.5650     0.1543 0.544 0.000 0.432 0.024
#> SRR949115     1  0.5650     0.1543 0.544 0.000 0.432 0.024
#> SRR949116     1  0.5650     0.1543 0.544 0.000 0.432 0.024
#> SRR949117     3  0.3037     0.8033 0.100 0.000 0.880 0.020
#> SRR949118     3  0.2596     0.8216 0.068 0.000 0.908 0.024
#> SRR949119     1  0.4277     0.4048 0.720 0.000 0.000 0.280
#> SRR949120     1  0.4277     0.4048 0.720 0.000 0.000 0.280
#> SRR949121     1  0.1305     0.6785 0.960 0.000 0.036 0.004
#> SRR949122     1  0.0336     0.6785 0.992 0.000 0.008 0.000
#> SRR949123     2  0.0000     0.8306 0.000 1.000 0.000 0.000
#> SRR949124     2  0.0000     0.8306 0.000 1.000 0.000 0.000
#> SRR949125     4  0.7412     0.5652 0.296 0.000 0.200 0.504
#> SRR949126     4  0.7412     0.5652 0.296 0.000 0.200 0.504
#> SRR949127     2  0.4604     0.8089 0.004 0.784 0.036 0.176
#> SRR949128     2  0.4604     0.8089 0.004 0.784 0.036 0.176
#> SRR949129     2  0.4604     0.8089 0.004 0.784 0.036 0.176

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR949076     4  0.4991      0.627 0.092 0.000 0.008 0.720 0.180
#> SRR949078     2  0.4707      0.513 0.000 0.588 0.000 0.020 0.392
#> SRR949077     4  0.4914      0.628 0.108 0.000 0.000 0.712 0.180
#> SRR949079     4  0.4155      0.738 0.144 0.000 0.000 0.780 0.076
#> SRR949080     4  0.4155      0.738 0.144 0.000 0.000 0.780 0.076
#> SRR949081     5  0.7420      0.596 0.068 0.068 0.124 0.132 0.608
#> SRR949082     2  0.4707      0.513 0.000 0.588 0.000 0.020 0.392
#> SRR949083     1  0.4879      0.530 0.716 0.000 0.000 0.108 0.176
#> SRR949084     1  0.3862      0.623 0.808 0.000 0.000 0.104 0.088
#> SRR949085     2  0.0510      0.784 0.000 0.984 0.000 0.016 0.000
#> SRR949087     5  0.6696      0.533 0.144 0.212 0.032 0.012 0.600
#> SRR949088     5  0.6696      0.533 0.144 0.212 0.032 0.012 0.600
#> SRR949086     3  0.3673      0.711 0.028 0.000 0.820 0.012 0.140
#> SRR949089     2  0.0404      0.784 0.000 0.988 0.000 0.012 0.000
#> SRR949090     4  0.5195      0.738 0.136 0.000 0.092 0.736 0.036
#> SRR949092     1  0.0162      0.725 0.996 0.000 0.000 0.004 0.000
#> SRR949093     1  0.0162      0.725 0.996 0.000 0.000 0.004 0.000
#> SRR949091     3  0.5259      0.299 0.016 0.000 0.588 0.368 0.028
#> SRR949095     5  0.6295      0.623 0.108 0.088 0.004 0.132 0.668
#> SRR949094     4  0.3975      0.741 0.144 0.000 0.000 0.792 0.064
#> SRR949096     1  0.3967      0.617 0.800 0.000 0.000 0.108 0.092
#> SRR949097     1  0.4339      0.656 0.800 0.000 0.028 0.100 0.072
#> SRR949098     2  0.0404      0.784 0.000 0.988 0.000 0.012 0.000
#> SRR949099     3  0.8033      0.248 0.244 0.000 0.408 0.108 0.240
#> SRR949101     3  0.2267      0.731 0.008 0.000 0.916 0.028 0.048
#> SRR949100     5  0.7206      0.484 0.152 0.100 0.036 0.096 0.616
#> SRR949102     5  0.7854      0.286 0.092 0.008 0.148 0.308 0.444
#> SRR949103     1  0.4421      0.654 0.796 0.000 0.032 0.100 0.072
#> SRR949104     2  0.0162      0.785 0.000 0.996 0.000 0.000 0.004
#> SRR949105     3  0.3268      0.726 0.004 0.000 0.856 0.060 0.080
#> SRR949106     3  0.3268      0.726 0.004 0.000 0.856 0.060 0.080
#> SRR949107     3  0.3268      0.726 0.004 0.000 0.856 0.060 0.080
#> SRR949108     1  0.0451      0.723 0.988 0.000 0.000 0.004 0.008
#> SRR949109     4  0.5172      0.742 0.144 0.000 0.084 0.736 0.036
#> SRR949110     1  0.4404      0.658 0.796 0.000 0.028 0.096 0.080
#> SRR949111     4  0.4655      0.768 0.140 0.000 0.080 0.764 0.016
#> SRR949112     1  0.0833      0.721 0.976 0.000 0.004 0.004 0.016
#> SRR949113     2  0.0162      0.785 0.000 0.996 0.000 0.000 0.004
#> SRR949114     1  0.6330      0.252 0.512 0.000 0.376 0.028 0.084
#> SRR949115     1  0.6330      0.252 0.512 0.000 0.376 0.028 0.084
#> SRR949116     1  0.6330      0.252 0.512 0.000 0.376 0.028 0.084
#> SRR949117     3  0.3673      0.711 0.028 0.000 0.820 0.012 0.140
#> SRR949118     3  0.3667      0.707 0.020 0.000 0.812 0.012 0.156
#> SRR949119     1  0.5797      0.377 0.592 0.000 0.000 0.276 0.132
#> SRR949120     1  0.5797      0.377 0.592 0.000 0.000 0.276 0.132
#> SRR949121     1  0.0727      0.722 0.980 0.000 0.004 0.004 0.012
#> SRR949122     1  0.0162      0.725 0.996 0.000 0.000 0.004 0.000
#> SRR949123     2  0.0000      0.785 0.000 1.000 0.000 0.000 0.000
#> SRR949124     2  0.0000      0.785 0.000 1.000 0.000 0.000 0.000
#> SRR949125     4  0.4382      0.767 0.140 0.000 0.084 0.772 0.004
#> SRR949126     4  0.4382      0.767 0.140 0.000 0.084 0.772 0.004
#> SRR949127     2  0.4440      0.626 0.000 0.660 0.004 0.012 0.324
#> SRR949128     2  0.4440      0.626 0.000 0.660 0.004 0.012 0.324
#> SRR949129     2  0.4440      0.626 0.000 0.660 0.004 0.012 0.324

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR949076     4  0.5647     0.5247 0.020 0.000 0.000 0.592 0.144 0.244
#> SRR949078     2  0.4314     0.5136 0.000 0.536 0.000 0.000 0.444 0.020
#> SRR949077     4  0.5717     0.5024 0.020 0.000 0.000 0.580 0.148 0.252
#> SRR949079     4  0.4251     0.6912 0.056 0.000 0.000 0.772 0.044 0.128
#> SRR949080     4  0.4251     0.6912 0.056 0.000 0.000 0.772 0.044 0.128
#> SRR949081     5  0.5884     0.4213 0.032 0.000 0.044 0.040 0.580 0.304
#> SRR949082     2  0.4314     0.5136 0.000 0.536 0.000 0.000 0.444 0.020
#> SRR949083     1  0.5761     0.4464 0.600 0.000 0.000 0.028 0.184 0.188
#> SRR949084     1  0.5165     0.5496 0.700 0.000 0.000 0.068 0.088 0.144
#> SRR949085     2  0.1268     0.7550 0.000 0.952 0.000 0.004 0.008 0.036
#> SRR949087     5  0.5092     0.4833 0.104 0.084 0.024 0.000 0.736 0.052
#> SRR949088     5  0.5092     0.4833 0.104 0.084 0.024 0.000 0.736 0.052
#> SRR949086     3  0.5673     0.4483 0.004 0.000 0.512 0.008 0.112 0.364
#> SRR949089     2  0.0935     0.7545 0.000 0.964 0.000 0.004 0.000 0.032
#> SRR949090     4  0.3407     0.6719 0.064 0.000 0.036 0.852 0.020 0.028
#> SRR949092     1  0.0870     0.6617 0.972 0.000 0.000 0.012 0.012 0.004
#> SRR949093     1  0.0870     0.6617 0.972 0.000 0.000 0.012 0.012 0.004
#> SRR949091     4  0.5696    -0.0898 0.000 0.000 0.396 0.444 0.000 0.160
#> SRR949095     5  0.5056     0.4805 0.048 0.000 0.000 0.048 0.664 0.240
#> SRR949094     4  0.3924     0.6944 0.056 0.000 0.000 0.796 0.032 0.116
#> SRR949096     1  0.5251     0.5438 0.692 0.000 0.000 0.072 0.088 0.148
#> SRR949097     1  0.4175     0.5366 0.780 0.000 0.000 0.112 0.036 0.072
#> SRR949098     2  0.1080     0.7541 0.000 0.960 0.000 0.004 0.004 0.032
#> SRR949099     6  0.8776     0.0000 0.200 0.000 0.236 0.116 0.176 0.272
#> SRR949101     3  0.4034     0.5421 0.000 0.000 0.692 0.024 0.004 0.280
#> SRR949100     5  0.5748     0.2376 0.112 0.020 0.004 0.080 0.688 0.096
#> SRR949102     5  0.7195     0.2469 0.048 0.000 0.060 0.108 0.396 0.388
#> SRR949103     1  0.4218     0.5318 0.776 0.000 0.000 0.116 0.036 0.072
#> SRR949104     2  0.0405     0.7573 0.000 0.988 0.000 0.000 0.004 0.008
#> SRR949105     3  0.0508     0.5817 0.000 0.000 0.984 0.012 0.004 0.000
#> SRR949106     3  0.0508     0.5817 0.000 0.000 0.984 0.012 0.004 0.000
#> SRR949107     3  0.0508     0.5817 0.000 0.000 0.984 0.012 0.004 0.000
#> SRR949108     1  0.1332     0.6590 0.952 0.000 0.000 0.008 0.012 0.028
#> SRR949109     4  0.3304     0.6719 0.068 0.000 0.036 0.856 0.020 0.020
#> SRR949110     1  0.4213     0.5464 0.780 0.000 0.000 0.100 0.040 0.080
#> SRR949111     4  0.3229     0.6970 0.064 0.000 0.036 0.860 0.012 0.028
#> SRR949112     1  0.0622     0.6565 0.980 0.000 0.000 0.000 0.008 0.012
#> SRR949113     2  0.0622     0.7573 0.000 0.980 0.000 0.000 0.012 0.008
#> SRR949114     1  0.6454     0.1988 0.536 0.000 0.164 0.028 0.020 0.252
#> SRR949115     1  0.6454     0.1988 0.536 0.000 0.164 0.028 0.020 0.252
#> SRR949116     1  0.6454     0.1988 0.536 0.000 0.164 0.028 0.020 0.252
#> SRR949117     3  0.5739     0.4490 0.008 0.000 0.512 0.008 0.108 0.364
#> SRR949118     3  0.5444     0.4609 0.000 0.000 0.524 0.008 0.100 0.368
#> SRR949119     1  0.6763     0.3762 0.508 0.000 0.000 0.180 0.100 0.212
#> SRR949120     1  0.6763     0.3762 0.508 0.000 0.000 0.180 0.100 0.212
#> SRR949121     1  0.0260     0.6579 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR949122     1  0.0000     0.6597 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949123     2  0.0260     0.7556 0.000 0.992 0.000 0.000 0.000 0.008
#> SRR949124     2  0.0146     0.7552 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR949125     4  0.2461     0.6938 0.064 0.000 0.044 0.888 0.000 0.004
#> SRR949126     4  0.2461     0.6938 0.064 0.000 0.044 0.888 0.000 0.004
#> SRR949127     2  0.4649     0.5731 0.000 0.560 0.000 0.004 0.400 0.036
#> SRR949128     2  0.4649     0.5731 0.000 0.560 0.000 0.004 0.400 0.036
#> SRR949129     2  0.4649     0.5731 0.000 0.560 0.000 0.004 0.400 0.036

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-kmeans-collect-classes

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

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

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.698           0.871       0.941         0.4805 0.547   0.547
#> 3 3 0.710           0.693       0.885         0.3983 0.751   0.554
#> 4 4 0.857           0.851       0.928         0.1206 0.880   0.649
#> 5 5 0.785           0.710       0.826         0.0550 0.958   0.831
#> 6 6 0.759           0.673       0.800         0.0369 0.996   0.980

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
#> SRR949076     1   0.730      0.717 0.796 0.204
#> SRR949078     2   0.000      0.995 0.000 1.000
#> SRR949077     1   0.722      0.722 0.800 0.200
#> SRR949079     1   0.000      0.903 1.000 0.000
#> SRR949080     1   0.000      0.903 1.000 0.000
#> SRR949081     2   0.000      0.995 0.000 1.000
#> SRR949082     2   0.000      0.995 0.000 1.000
#> SRR949083     1   0.973      0.341 0.596 0.404
#> SRR949084     1   0.000      0.903 1.000 0.000
#> SRR949085     2   0.000      0.995 0.000 1.000
#> SRR949087     2   0.000      0.995 0.000 1.000
#> SRR949088     2   0.000      0.995 0.000 1.000
#> SRR949086     1   0.949      0.513 0.632 0.368
#> SRR949089     2   0.000      0.995 0.000 1.000
#> SRR949090     1   0.000      0.903 1.000 0.000
#> SRR949092     1   0.000      0.903 1.000 0.000
#> SRR949093     1   0.000      0.903 1.000 0.000
#> SRR949091     1   0.000      0.903 1.000 0.000
#> SRR949095     2   0.000      0.995 0.000 1.000
#> SRR949094     1   0.000      0.903 1.000 0.000
#> SRR949096     1   0.000      0.903 1.000 0.000
#> SRR949097     1   0.000      0.903 1.000 0.000
#> SRR949098     2   0.000      0.995 0.000 1.000
#> SRR949099     1   0.000      0.903 1.000 0.000
#> SRR949101     1   0.662      0.769 0.828 0.172
#> SRR949100     2   0.000      0.995 0.000 1.000
#> SRR949102     2   0.358      0.914 0.068 0.932
#> SRR949103     1   0.000      0.903 1.000 0.000
#> SRR949104     2   0.000      0.995 0.000 1.000
#> SRR949105     1   0.949      0.513 0.632 0.368
#> SRR949106     1   0.949      0.513 0.632 0.368
#> SRR949107     1   0.949      0.513 0.632 0.368
#> SRR949108     1   0.000      0.903 1.000 0.000
#> SRR949109     1   0.000      0.903 1.000 0.000
#> SRR949110     1   0.000      0.903 1.000 0.000
#> SRR949111     1   0.000      0.903 1.000 0.000
#> SRR949112     1   0.000      0.903 1.000 0.000
#> SRR949113     2   0.000      0.995 0.000 1.000
#> SRR949114     1   0.000      0.903 1.000 0.000
#> SRR949115     1   0.000      0.903 1.000 0.000
#> SRR949116     1   0.000      0.903 1.000 0.000
#> SRR949117     1   0.949      0.513 0.632 0.368
#> SRR949118     1   0.900      0.594 0.684 0.316
#> SRR949119     1   0.000      0.903 1.000 0.000
#> SRR949120     1   0.000      0.903 1.000 0.000
#> SRR949121     1   0.000      0.903 1.000 0.000
#> SRR949122     1   0.000      0.903 1.000 0.000
#> SRR949123     2   0.000      0.995 0.000 1.000
#> SRR949124     2   0.000      0.995 0.000 1.000
#> SRR949125     1   0.000      0.903 1.000 0.000
#> SRR949126     1   0.000      0.903 1.000 0.000
#> SRR949127     2   0.000      0.995 0.000 1.000
#> SRR949128     2   0.000      0.995 0.000 1.000
#> SRR949129     2   0.000      0.995 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
#> SRR949076     1  0.6204     0.2619 0.576 0.000 0.424
#> SRR949078     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949077     1  0.6204     0.2619 0.576 0.000 0.424
#> SRR949079     1  0.6204     0.2619 0.576 0.000 0.424
#> SRR949080     1  0.6204     0.2619 0.576 0.000 0.424
#> SRR949081     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949082     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949083     1  0.0000     0.7454 1.000 0.000 0.000
#> SRR949084     1  0.0000     0.7454 1.000 0.000 0.000
#> SRR949085     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949087     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949088     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949086     3  0.0592     0.7297 0.000 0.012 0.988
#> SRR949089     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949090     3  0.5058     0.5565 0.244 0.000 0.756
#> SRR949092     1  0.0000     0.7454 1.000 0.000 0.000
#> SRR949093     1  0.0000     0.7454 1.000 0.000 0.000
#> SRR949091     3  0.0000     0.7355 0.000 0.000 1.000
#> SRR949095     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949094     1  0.6204     0.2619 0.576 0.000 0.424
#> SRR949096     1  0.0000     0.7454 1.000 0.000 0.000
#> SRR949097     1  0.5678     0.3280 0.684 0.000 0.316
#> SRR949098     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949099     3  0.0000     0.7355 0.000 0.000 1.000
#> SRR949101     3  0.0000     0.7355 0.000 0.000 1.000
#> SRR949100     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949102     3  0.9885     0.0287 0.308 0.284 0.408
#> SRR949103     1  0.5733     0.3099 0.676 0.000 0.324
#> SRR949104     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949105     3  0.0000     0.7355 0.000 0.000 1.000
#> SRR949106     3  0.0000     0.7355 0.000 0.000 1.000
#> SRR949107     3  0.0000     0.7355 0.000 0.000 1.000
#> SRR949108     1  0.0000     0.7454 1.000 0.000 0.000
#> SRR949109     3  0.5098     0.5519 0.248 0.000 0.752
#> SRR949110     1  0.5678     0.3280 0.684 0.000 0.316
#> SRR949111     3  0.5138     0.5466 0.252 0.000 0.748
#> SRR949112     1  0.0000     0.7454 1.000 0.000 0.000
#> SRR949113     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949114     3  0.6204     0.1951 0.424 0.000 0.576
#> SRR949115     3  0.6204     0.1951 0.424 0.000 0.576
#> SRR949116     3  0.6204     0.1951 0.424 0.000 0.576
#> SRR949117     3  0.0424     0.7320 0.000 0.008 0.992
#> SRR949118     3  0.0000     0.7355 0.000 0.000 1.000
#> SRR949119     1  0.0000     0.7454 1.000 0.000 0.000
#> SRR949120     1  0.0000     0.7454 1.000 0.000 0.000
#> SRR949121     1  0.0000     0.7454 1.000 0.000 0.000
#> SRR949122     1  0.0000     0.7454 1.000 0.000 0.000
#> SRR949123     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949124     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949125     3  0.5138     0.5466 0.252 0.000 0.748
#> SRR949126     3  0.5138     0.5466 0.252 0.000 0.748
#> SRR949127     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949128     2  0.0000     1.0000 0.000 1.000 0.000
#> SRR949129     2  0.0000     1.0000 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
#> SRR949076     4  0.1978      0.850 0.068 0.004 0.000 0.928
#> SRR949078     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> SRR949077     4  0.1867      0.850 0.072 0.000 0.000 0.928
#> SRR949079     4  0.0336      0.887 0.008 0.000 0.000 0.992
#> SRR949080     4  0.0336      0.887 0.008 0.000 0.000 0.992
#> SRR949081     2  0.4998      0.704 0.000 0.748 0.200 0.052
#> SRR949082     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> SRR949083     1  0.1474      0.924 0.948 0.000 0.000 0.052
#> SRR949084     1  0.1474      0.924 0.948 0.000 0.000 0.052
#> SRR949085     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> SRR949087     2  0.0188      0.974 0.000 0.996 0.000 0.004
#> SRR949088     2  0.0188      0.974 0.000 0.996 0.000 0.004
#> SRR949086     3  0.0000      0.814 0.000 0.000 1.000 0.000
#> SRR949089     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> SRR949090     4  0.1798      0.890 0.040 0.000 0.016 0.944
#> SRR949092     1  0.0000      0.941 1.000 0.000 0.000 0.000
#> SRR949093     1  0.0000      0.941 1.000 0.000 0.000 0.000
#> SRR949091     3  0.4697      0.392 0.000 0.000 0.644 0.356
#> SRR949095     2  0.1474      0.930 0.000 0.948 0.000 0.052
#> SRR949094     4  0.0336      0.887 0.008 0.000 0.000 0.992
#> SRR949096     1  0.1474      0.924 0.948 0.000 0.000 0.052
#> SRR949097     1  0.1867      0.903 0.928 0.000 0.000 0.072
#> SRR949098     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> SRR949099     3  0.3128      0.731 0.040 0.000 0.884 0.076
#> SRR949101     3  0.0000      0.814 0.000 0.000 1.000 0.000
#> SRR949100     2  0.1792      0.914 0.000 0.932 0.000 0.068
#> SRR949102     4  0.8437      0.118 0.020 0.316 0.292 0.372
#> SRR949103     1  0.1867      0.903 0.928 0.000 0.000 0.072
#> SRR949104     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> SRR949105     3  0.0000      0.814 0.000 0.000 1.000 0.000
#> SRR949106     3  0.0000      0.814 0.000 0.000 1.000 0.000
#> SRR949107     3  0.0000      0.814 0.000 0.000 1.000 0.000
#> SRR949108     1  0.0000      0.941 1.000 0.000 0.000 0.000
#> SRR949109     4  0.1798      0.890 0.040 0.000 0.016 0.944
#> SRR949110     1  0.1792      0.906 0.932 0.000 0.000 0.068
#> SRR949111     4  0.1798      0.890 0.040 0.000 0.016 0.944
#> SRR949112     1  0.0000      0.941 1.000 0.000 0.000 0.000
#> SRR949113     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> SRR949114     3  0.4907      0.394 0.420 0.000 0.580 0.000
#> SRR949115     3  0.4907      0.394 0.420 0.000 0.580 0.000
#> SRR949116     3  0.4907      0.394 0.420 0.000 0.580 0.000
#> SRR949117     3  0.0000      0.814 0.000 0.000 1.000 0.000
#> SRR949118     3  0.0000      0.814 0.000 0.000 1.000 0.000
#> SRR949119     1  0.3074      0.851 0.848 0.000 0.000 0.152
#> SRR949120     1  0.3074      0.851 0.848 0.000 0.000 0.152
#> SRR949121     1  0.0000      0.941 1.000 0.000 0.000 0.000
#> SRR949122     1  0.0000      0.941 1.000 0.000 0.000 0.000
#> SRR949123     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> SRR949124     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> SRR949125     4  0.1798      0.890 0.040 0.000 0.016 0.944
#> SRR949126     4  0.1798      0.890 0.040 0.000 0.016 0.944
#> SRR949127     2  0.0188      0.974 0.000 0.996 0.000 0.004
#> SRR949128     2  0.0188      0.974 0.000 0.996 0.000 0.004
#> SRR949129     2  0.0188      0.974 0.000 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR949076     4  0.3796     0.7313 0.000 0.000 0.000 0.700 0.300
#> SRR949078     2  0.0794     0.9058 0.000 0.972 0.000 0.000 0.028
#> SRR949077     4  0.3895     0.7101 0.000 0.000 0.000 0.680 0.320
#> SRR949079     4  0.2929     0.8215 0.000 0.000 0.000 0.820 0.180
#> SRR949080     4  0.2929     0.8215 0.000 0.000 0.000 0.820 0.180
#> SRR949081     5  0.6289    -0.1121 0.000 0.396 0.152 0.000 0.452
#> SRR949082     2  0.0794     0.9058 0.000 0.972 0.000 0.000 0.028
#> SRR949083     1  0.3612     0.6702 0.732 0.000 0.000 0.000 0.268
#> SRR949084     1  0.3074     0.7118 0.804 0.000 0.000 0.000 0.196
#> SRR949085     2  0.0000     0.9136 0.000 1.000 0.000 0.000 0.000
#> SRR949087     2  0.2813     0.8383 0.000 0.832 0.000 0.000 0.168
#> SRR949088     2  0.2813     0.8383 0.000 0.832 0.000 0.000 0.168
#> SRR949086     3  0.0794     0.8261 0.000 0.000 0.972 0.000 0.028
#> SRR949089     2  0.0000     0.9136 0.000 1.000 0.000 0.000 0.000
#> SRR949090     4  0.0963     0.8124 0.000 0.000 0.000 0.964 0.036
#> SRR949092     1  0.0290     0.7518 0.992 0.000 0.000 0.000 0.008
#> SRR949093     1  0.0290     0.7518 0.992 0.000 0.000 0.000 0.008
#> SRR949091     3  0.4161     0.2452 0.000 0.000 0.608 0.392 0.000
#> SRR949095     2  0.4138     0.4325 0.000 0.616 0.000 0.000 0.384
#> SRR949094     4  0.2929     0.8215 0.000 0.000 0.000 0.820 0.180
#> SRR949096     1  0.3143     0.7086 0.796 0.000 0.000 0.000 0.204
#> SRR949097     1  0.4766     0.6223 0.708 0.000 0.000 0.220 0.072
#> SRR949098     2  0.0000     0.9136 0.000 1.000 0.000 0.000 0.000
#> SRR949099     3  0.6055     0.3702 0.032 0.000 0.632 0.232 0.104
#> SRR949101     3  0.0000     0.8302 0.000 0.000 1.000 0.000 0.000
#> SRR949100     2  0.5233     0.5977 0.000 0.680 0.000 0.192 0.128
#> SRR949102     5  0.7379     0.0273 0.004 0.072 0.220 0.176 0.528
#> SRR949103     1  0.4766     0.6223 0.708 0.000 0.000 0.220 0.072
#> SRR949104     2  0.0000     0.9136 0.000 1.000 0.000 0.000 0.000
#> SRR949105     3  0.0162     0.8319 0.000 0.000 0.996 0.004 0.000
#> SRR949106     3  0.0162     0.8319 0.000 0.000 0.996 0.004 0.000
#> SRR949107     3  0.0162     0.8319 0.000 0.000 0.996 0.004 0.000
#> SRR949108     1  0.0290     0.7527 0.992 0.000 0.000 0.000 0.008
#> SRR949109     4  0.1043     0.8096 0.000 0.000 0.000 0.960 0.040
#> SRR949110     1  0.4514     0.6508 0.740 0.000 0.000 0.188 0.072
#> SRR949111     4  0.0162     0.8313 0.000 0.000 0.000 0.996 0.004
#> SRR949112     1  0.3816     0.4117 0.696 0.000 0.000 0.000 0.304
#> SRR949113     2  0.0000     0.9136 0.000 1.000 0.000 0.000 0.000
#> SRR949114     5  0.6632     0.3652 0.220 0.000 0.380 0.000 0.400
#> SRR949115     5  0.6632     0.3652 0.220 0.000 0.380 0.000 0.400
#> SRR949116     5  0.6632     0.3652 0.220 0.000 0.380 0.000 0.400
#> SRR949117     3  0.0703     0.8280 0.000 0.000 0.976 0.000 0.024
#> SRR949118     3  0.0703     0.8280 0.000 0.000 0.976 0.000 0.024
#> SRR949119     1  0.5315     0.5654 0.600 0.000 0.000 0.068 0.332
#> SRR949120     1  0.5315     0.5654 0.600 0.000 0.000 0.068 0.332
#> SRR949121     1  0.0404     0.7507 0.988 0.000 0.000 0.000 0.012
#> SRR949122     1  0.0290     0.7512 0.992 0.000 0.000 0.000 0.008
#> SRR949123     2  0.0000     0.9136 0.000 1.000 0.000 0.000 0.000
#> SRR949124     2  0.0000     0.9136 0.000 1.000 0.000 0.000 0.000
#> SRR949125     4  0.0000     0.8326 0.000 0.000 0.000 1.000 0.000
#> SRR949126     4  0.0000     0.8326 0.000 0.000 0.000 1.000 0.000
#> SRR949127     2  0.1341     0.8978 0.000 0.944 0.000 0.000 0.056
#> SRR949128     2  0.1341     0.8978 0.000 0.944 0.000 0.000 0.056
#> SRR949129     2  0.1341     0.8978 0.000 0.944 0.000 0.000 0.056

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR949076     4  0.3446      0.640 0.000 0.000 0.000 0.692 0.308 0.000
#> SRR949078     2  0.0717      0.788 0.000 0.976 0.000 0.000 0.016 0.008
#> SRR949077     4  0.3482      0.629 0.000 0.000 0.000 0.684 0.316 0.000
#> SRR949079     4  0.2165      0.833 0.000 0.000 0.000 0.884 0.108 0.008
#> SRR949080     4  0.2165      0.833 0.000 0.000 0.000 0.884 0.108 0.008
#> SRR949081     5  0.4441      0.709 0.000 0.204 0.028 0.000 0.724 0.044
#> SRR949082     2  0.0725      0.785 0.000 0.976 0.000 0.000 0.012 0.012
#> SRR949083     1  0.4204      0.587 0.696 0.000 0.000 0.000 0.252 0.052
#> SRR949084     1  0.3168      0.655 0.804 0.000 0.000 0.000 0.172 0.024
#> SRR949085     2  0.0000      0.792 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949087     2  0.5771      0.371 0.000 0.484 0.004 0.000 0.352 0.160
#> SRR949088     2  0.5771      0.371 0.000 0.484 0.004 0.000 0.352 0.160
#> SRR949086     3  0.2350      0.772 0.000 0.000 0.880 0.000 0.100 0.020
#> SRR949089     2  0.0000      0.792 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949090     4  0.1864      0.807 0.000 0.000 0.004 0.924 0.032 0.040
#> SRR949092     1  0.0632      0.703 0.976 0.000 0.000 0.000 0.000 0.024
#> SRR949093     1  0.0632      0.703 0.976 0.000 0.000 0.000 0.000 0.024
#> SRR949091     3  0.3782      0.246 0.000 0.000 0.588 0.412 0.000 0.000
#> SRR949095     2  0.4642     -0.163 0.000 0.508 0.000 0.000 0.452 0.040
#> SRR949094     4  0.2165      0.833 0.000 0.000 0.000 0.884 0.108 0.008
#> SRR949096     1  0.3269      0.649 0.792 0.000 0.000 0.000 0.184 0.024
#> SRR949097     1  0.5899      0.535 0.616 0.000 0.000 0.124 0.068 0.192
#> SRR949098     2  0.0000      0.792 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949099     3  0.7335      0.314 0.024 0.000 0.492 0.124 0.172 0.188
#> SRR949101     3  0.0291      0.788 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR949100     2  0.6757      0.361 0.000 0.484 0.000 0.076 0.196 0.244
#> SRR949102     5  0.5229      0.697 0.000 0.072 0.072 0.092 0.732 0.032
#> SRR949103     1  0.5899      0.535 0.616 0.000 0.000 0.124 0.068 0.192
#> SRR949104     2  0.0000      0.792 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949105     3  0.0000      0.789 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949106     3  0.0000      0.789 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949107     3  0.0000      0.789 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949108     1  0.0363      0.706 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR949109     4  0.1864      0.807 0.000 0.000 0.004 0.924 0.032 0.040
#> SRR949110     1  0.5736      0.546 0.640 0.000 0.000 0.116 0.072 0.172
#> SRR949111     4  0.0405      0.844 0.000 0.000 0.004 0.988 0.000 0.008
#> SRR949112     1  0.3841      0.152 0.616 0.000 0.000 0.000 0.004 0.380
#> SRR949113     2  0.0000      0.792 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949114     6  0.4756      1.000 0.128 0.000 0.200 0.000 0.000 0.672
#> SRR949115     6  0.4756      1.000 0.128 0.000 0.200 0.000 0.000 0.672
#> SRR949116     6  0.4756      1.000 0.128 0.000 0.200 0.000 0.000 0.672
#> SRR949117     3  0.2214      0.774 0.000 0.000 0.888 0.000 0.096 0.016
#> SRR949118     3  0.2510      0.767 0.000 0.000 0.872 0.000 0.100 0.028
#> SRR949119     1  0.5511      0.317 0.516 0.000 0.000 0.060 0.392 0.032
#> SRR949120     1  0.5511      0.317 0.516 0.000 0.000 0.060 0.392 0.032
#> SRR949121     1  0.1219      0.692 0.948 0.000 0.000 0.000 0.004 0.048
#> SRR949122     1  0.0858      0.702 0.968 0.000 0.000 0.000 0.004 0.028
#> SRR949123     2  0.0000      0.792 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949124     2  0.0000      0.792 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949125     4  0.0146      0.847 0.000 0.000 0.004 0.996 0.000 0.000
#> SRR949126     4  0.0146      0.847 0.000 0.000 0.004 0.996 0.000 0.000
#> SRR949127     2  0.3962      0.703 0.000 0.764 0.000 0.000 0.120 0.116
#> SRR949128     2  0.3962      0.703 0.000 0.764 0.000 0.000 0.120 0.116
#> SRR949129     2  0.3962      0.703 0.000 0.764 0.000 0.000 0.120 0.116

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

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

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.923           0.928       0.971         0.4334 0.575   0.575
#> 3 3 0.827           0.902       0.951         0.5333 0.732   0.544
#> 4 4 0.902           0.933       0.971         0.1008 0.870   0.644
#> 5 5 0.999           0.962       0.984         0.0666 0.934   0.764
#> 6 6 0.885           0.831       0.893         0.0451 0.956   0.801

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

suggest_best_k(res)
#> [1] 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
#> SRR949076     1  0.0000      0.968 1.000 0.000
#> SRR949078     2  0.0000      0.970 0.000 1.000
#> SRR949077     1  0.0000      0.968 1.000 0.000
#> SRR949079     1  0.0000      0.968 1.000 0.000
#> SRR949080     1  0.0000      0.968 1.000 0.000
#> SRR949081     2  0.0000      0.970 0.000 1.000
#> SRR949082     2  0.0000      0.970 0.000 1.000
#> SRR949083     1  0.0000      0.968 1.000 0.000
#> SRR949084     1  0.0000      0.968 1.000 0.000
#> SRR949085     2  0.0000      0.970 0.000 1.000
#> SRR949087     2  0.2423      0.939 0.040 0.960
#> SRR949088     2  0.2236      0.943 0.036 0.964
#> SRR949086     1  0.0000      0.968 1.000 0.000
#> SRR949089     2  0.0000      0.970 0.000 1.000
#> SRR949090     1  0.0000      0.968 1.000 0.000
#> SRR949092     1  0.0000      0.968 1.000 0.000
#> SRR949093     1  0.0000      0.968 1.000 0.000
#> SRR949091     1  0.0000      0.968 1.000 0.000
#> SRR949095     2  0.9358      0.429 0.352 0.648
#> SRR949094     1  0.0000      0.968 1.000 0.000
#> SRR949096     1  0.0000      0.968 1.000 0.000
#> SRR949097     1  0.0000      0.968 1.000 0.000
#> SRR949098     2  0.0000      0.970 0.000 1.000
#> SRR949099     1  0.0000      0.968 1.000 0.000
#> SRR949101     1  0.0000      0.968 1.000 0.000
#> SRR949100     2  0.0376      0.967 0.004 0.996
#> SRR949102     1  0.0000      0.968 1.000 0.000
#> SRR949103     1  0.0000      0.968 1.000 0.000
#> SRR949104     2  0.0000      0.970 0.000 1.000
#> SRR949105     1  0.8207      0.659 0.744 0.256
#> SRR949106     1  0.7453      0.728 0.788 0.212
#> SRR949107     1  0.7745      0.705 0.772 0.228
#> SRR949108     1  0.0000      0.968 1.000 0.000
#> SRR949109     1  0.0000      0.968 1.000 0.000
#> SRR949110     1  0.0000      0.968 1.000 0.000
#> SRR949111     1  0.0000      0.968 1.000 0.000
#> SRR949112     1  0.0000      0.968 1.000 0.000
#> SRR949113     2  0.0000      0.970 0.000 1.000
#> SRR949114     1  0.0000      0.968 1.000 0.000
#> SRR949115     1  0.0000      0.968 1.000 0.000
#> SRR949116     1  0.0000      0.968 1.000 0.000
#> SRR949117     1  0.0000      0.968 1.000 0.000
#> SRR949118     1  0.0000      0.968 1.000 0.000
#> SRR949119     1  0.0000      0.968 1.000 0.000
#> SRR949120     1  0.0000      0.968 1.000 0.000
#> SRR949121     1  0.0000      0.968 1.000 0.000
#> SRR949122     1  0.0000      0.968 1.000 0.000
#> SRR949123     1  0.9896      0.230 0.560 0.440
#> SRR949124     2  0.0000      0.970 0.000 1.000
#> SRR949125     1  0.0000      0.968 1.000 0.000
#> SRR949126     1  0.0000      0.968 1.000 0.000
#> SRR949127     2  0.0000      0.970 0.000 1.000
#> SRR949128     2  0.0000      0.970 0.000 1.000
#> SRR949129     2  0.0000      0.970 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
#> SRR949076     3  0.1289      0.907 0.032 0.000 0.968
#> SRR949078     2  0.0000      0.956 0.000 1.000 0.000
#> SRR949077     3  0.4796      0.710 0.220 0.000 0.780
#> SRR949079     3  0.1163      0.909 0.028 0.000 0.972
#> SRR949080     3  0.1163      0.909 0.028 0.000 0.972
#> SRR949081     2  0.0000      0.956 0.000 1.000 0.000
#> SRR949082     2  0.0000      0.956 0.000 1.000 0.000
#> SRR949083     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949084     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949085     2  0.0000      0.956 0.000 1.000 0.000
#> SRR949087     2  0.0237      0.953 0.004 0.996 0.000
#> SRR949088     2  0.0424      0.950 0.008 0.992 0.000
#> SRR949086     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949089     2  0.0000      0.956 0.000 1.000 0.000
#> SRR949090     3  0.1163      0.909 0.028 0.000 0.972
#> SRR949092     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949093     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949091     3  0.0000      0.891 0.000 0.000 1.000
#> SRR949095     2  0.8399      0.482 0.188 0.624 0.188
#> SRR949094     3  0.1163      0.909 0.028 0.000 0.972
#> SRR949096     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949097     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949098     2  0.0000      0.956 0.000 1.000 0.000
#> SRR949099     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949101     3  0.5733      0.520 0.324 0.000 0.676
#> SRR949100     2  0.0000      0.956 0.000 1.000 0.000
#> SRR949102     1  0.4235      0.797 0.824 0.000 0.176
#> SRR949103     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949104     2  0.0000      0.956 0.000 1.000 0.000
#> SRR949105     3  0.4897      0.761 0.016 0.172 0.812
#> SRR949106     3  0.4897      0.761 0.016 0.172 0.812
#> SRR949107     3  0.4897      0.761 0.016 0.172 0.812
#> SRR949108     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949109     3  0.1163      0.909 0.028 0.000 0.972
#> SRR949110     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949111     3  0.1163      0.909 0.028 0.000 0.972
#> SRR949112     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949113     2  0.0000      0.956 0.000 1.000 0.000
#> SRR949114     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949115     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949116     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949117     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949118     1  0.3412      0.850 0.876 0.000 0.124
#> SRR949119     1  0.4291      0.792 0.820 0.000 0.180
#> SRR949120     1  0.4291      0.792 0.820 0.000 0.180
#> SRR949121     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949122     1  0.0000      0.966 1.000 0.000 0.000
#> SRR949123     2  0.4974      0.676 0.236 0.764 0.000
#> SRR949124     2  0.0000      0.956 0.000 1.000 0.000
#> SRR949125     3  0.1163      0.909 0.028 0.000 0.972
#> SRR949126     3  0.1163      0.909 0.028 0.000 0.972
#> SRR949127     2  0.0000      0.956 0.000 1.000 0.000
#> SRR949128     2  0.0000      0.956 0.000 1.000 0.000
#> SRR949129     2  0.0000      0.956 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR949076     4   0.000     0.8991 0.000 0.000 0.000 1.000
#> SRR949078     2   0.000     1.0000 0.000 1.000 0.000 0.000
#> SRR949077     4   0.281     0.8408 0.132 0.000 0.000 0.868
#> SRR949079     4   0.000     0.8991 0.000 0.000 0.000 1.000
#> SRR949080     4   0.000     0.8991 0.000 0.000 0.000 1.000
#> SRR949081     2   0.000     1.0000 0.000 1.000 0.000 0.000
#> SRR949082     2   0.000     1.0000 0.000 1.000 0.000 0.000
#> SRR949083     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949084     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949085     2   0.000     1.0000 0.000 1.000 0.000 0.000
#> SRR949087     2   0.000     1.0000 0.000 1.000 0.000 0.000
#> SRR949088     2   0.000     1.0000 0.000 1.000 0.000 0.000
#> SRR949086     1   0.478     0.4056 0.624 0.000 0.376 0.000
#> SRR949089     2   0.000     1.0000 0.000 1.000 0.000 0.000
#> SRR949090     4   0.000     0.8991 0.000 0.000 0.000 1.000
#> SRR949092     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949093     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949091     4   0.499     0.0707 0.000 0.000 0.468 0.532
#> SRR949095     4   0.344     0.8378 0.120 0.024 0.000 0.856
#> SRR949094     4   0.000     0.8991 0.000 0.000 0.000 1.000
#> SRR949096     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949097     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949098     2   0.000     1.0000 0.000 1.000 0.000 0.000
#> SRR949099     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949101     3   0.000     1.0000 0.000 0.000 1.000 0.000
#> SRR949100     2   0.000     1.0000 0.000 1.000 0.000 0.000
#> SRR949102     4   0.281     0.8408 0.132 0.000 0.000 0.868
#> SRR949103     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949104     2   0.000     1.0000 0.000 1.000 0.000 0.000
#> SRR949105     3   0.000     1.0000 0.000 0.000 1.000 0.000
#> SRR949106     3   0.000     1.0000 0.000 0.000 1.000 0.000
#> SRR949107     3   0.000     1.0000 0.000 0.000 1.000 0.000
#> SRR949108     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949109     4   0.000     0.8991 0.000 0.000 0.000 1.000
#> SRR949110     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949111     4   0.000     0.8991 0.000 0.000 0.000 1.000
#> SRR949112     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949113     2   0.000     1.0000 0.000 1.000 0.000 0.000
#> SRR949114     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949115     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949116     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949117     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949118     3   0.000     1.0000 0.000 0.000 1.000 0.000
#> SRR949119     4   0.297     0.8310 0.144 0.000 0.000 0.856
#> SRR949120     4   0.297     0.8310 0.144 0.000 0.000 0.856
#> SRR949121     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949122     1   0.000     0.9776 1.000 0.000 0.000 0.000
#> SRR949123     2   0.000     1.0000 0.000 1.000 0.000 0.000
#> SRR949124     2   0.000     1.0000 0.000 1.000 0.000 0.000
#> SRR949125     4   0.000     0.8991 0.000 0.000 0.000 1.000
#> SRR949126     4   0.000     0.8991 0.000 0.000 0.000 1.000
#> SRR949127     2   0.000     1.0000 0.000 1.000 0.000 0.000
#> SRR949128     2   0.000     1.0000 0.000 1.000 0.000 0.000
#> SRR949129     2   0.000     1.0000 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
#> SRR949076     4  0.0000      0.977 0.000 0.000 0.000 1.000 0.000
#> SRR949078     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000
#> SRR949077     4  0.0290      0.973 0.008 0.000 0.000 0.992 0.000
#> SRR949079     4  0.0000      0.977 0.000 0.000 0.000 1.000 0.000
#> SRR949080     4  0.0000      0.977 0.000 0.000 0.000 1.000 0.000
#> SRR949081     2  0.0162      0.991 0.000 0.996 0.000 0.004 0.000
#> SRR949082     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000
#> SRR949083     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> SRR949084     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> SRR949085     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000
#> SRR949087     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000
#> SRR949088     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000
#> SRR949086     3  0.0290      0.923 0.008 0.000 0.992 0.000 0.000
#> SRR949089     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000
#> SRR949090     4  0.0000      0.977 0.000 0.000 0.000 1.000 0.000
#> SRR949092     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> SRR949093     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> SRR949091     3  0.3143      0.696 0.000 0.000 0.796 0.204 0.000
#> SRR949095     4  0.0693      0.965 0.008 0.012 0.000 0.980 0.000
#> SRR949094     4  0.0000      0.977 0.000 0.000 0.000 1.000 0.000
#> SRR949096     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> SRR949097     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> SRR949098     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000
#> SRR949099     1  0.0290      0.976 0.992 0.000 0.008 0.000 0.000
#> SRR949101     5  0.0162      0.996 0.000 0.000 0.004 0.000 0.996
#> SRR949100     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000
#> SRR949102     4  0.3388      0.739 0.008 0.000 0.200 0.792 0.000
#> SRR949103     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> SRR949104     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000
#> SRR949105     5  0.0000      0.999 0.000 0.000 0.000 0.000 1.000
#> SRR949106     5  0.0000      0.999 0.000 0.000 0.000 0.000 1.000
#> SRR949107     5  0.0000      0.999 0.000 0.000 0.000 0.000 1.000
#> SRR949108     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> SRR949109     4  0.0000      0.977 0.000 0.000 0.000 1.000 0.000
#> SRR949110     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> SRR949111     4  0.0000      0.977 0.000 0.000 0.000 1.000 0.000
#> SRR949112     1  0.2966      0.775 0.816 0.000 0.184 0.000 0.000
#> SRR949113     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000
#> SRR949114     3  0.0000      0.925 0.000 0.000 1.000 0.000 0.000
#> SRR949115     3  0.0000      0.925 0.000 0.000 1.000 0.000 0.000
#> SRR949116     3  0.0000      0.925 0.000 0.000 1.000 0.000 0.000
#> SRR949117     3  0.1197      0.890 0.048 0.000 0.952 0.000 0.000
#> SRR949118     3  0.1671      0.876 0.000 0.000 0.924 0.000 0.076
#> SRR949119     4  0.0609      0.965 0.020 0.000 0.000 0.980 0.000
#> SRR949120     4  0.0609      0.965 0.020 0.000 0.000 0.980 0.000
#> SRR949121     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> SRR949122     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> SRR949123     2  0.1544      0.924 0.000 0.932 0.068 0.000 0.000
#> SRR949124     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000
#> SRR949125     4  0.0000      0.977 0.000 0.000 0.000 1.000 0.000
#> SRR949126     4  0.0000      0.977 0.000 0.000 0.000 1.000 0.000
#> SRR949127     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000
#> SRR949128     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000
#> SRR949129     2  0.0000      0.995 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
#> SRR949076     4  0.0000      0.900 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949078     5  0.3607      0.949 0.000 0.348 0.000 0.000 0.652 0.000
#> SRR949077     4  0.0363      0.897 0.012 0.000 0.000 0.988 0.000 0.000
#> SRR949079     4  0.0000      0.900 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949080     4  0.0000      0.900 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949081     5  0.2730      0.643 0.000 0.192 0.000 0.000 0.808 0.000
#> SRR949082     5  0.3607      0.949 0.000 0.348 0.000 0.000 0.652 0.000
#> SRR949083     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949084     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949085     2  0.3860     -0.526 0.000 0.528 0.000 0.000 0.472 0.000
#> SRR949087     5  0.3578      0.941 0.000 0.340 0.000 0.000 0.660 0.000
#> SRR949088     5  0.3578      0.941 0.000 0.340 0.000 0.000 0.660 0.000
#> SRR949086     6  0.0520      0.905 0.008 0.000 0.000 0.000 0.008 0.984
#> SRR949089     2  0.0000      0.695 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949090     4  0.1863      0.884 0.000 0.000 0.000 0.896 0.104 0.000
#> SRR949092     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949093     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949091     6  0.4599      0.589 0.000 0.000 0.000 0.212 0.104 0.684
#> SRR949095     4  0.0767      0.895 0.008 0.012 0.000 0.976 0.004 0.000
#> SRR949094     4  0.0000      0.900 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949096     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949097     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949098     2  0.0000      0.695 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949099     1  0.1398      0.933 0.940 0.000 0.000 0.000 0.052 0.008
#> SRR949101     3  0.0146      0.996 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR949100     5  0.3607      0.949 0.000 0.348 0.000 0.000 0.652 0.000
#> SRR949102     4  0.4154      0.716 0.008 0.000 0.000 0.712 0.244 0.036
#> SRR949103     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949104     2  0.2631      0.498 0.000 0.820 0.000 0.000 0.180 0.000
#> SRR949105     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949106     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949107     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949108     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949109     4  0.1863      0.884 0.000 0.000 0.000 0.896 0.104 0.000
#> SRR949110     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949111     4  0.1863      0.884 0.000 0.000 0.000 0.896 0.104 0.000
#> SRR949112     1  0.2664      0.783 0.816 0.000 0.000 0.000 0.000 0.184
#> SRR949113     2  0.3868     -0.567 0.000 0.508 0.000 0.000 0.492 0.000
#> SRR949114     6  0.0000      0.909 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR949115     6  0.0000      0.909 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR949116     6  0.0000      0.909 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR949117     6  0.1333      0.873 0.048 0.000 0.000 0.000 0.008 0.944
#> SRR949118     6  0.1501      0.862 0.000 0.000 0.076 0.000 0.000 0.924
#> SRR949119     4  0.3394      0.755 0.012 0.000 0.000 0.752 0.236 0.000
#> SRR949120     4  0.3394      0.755 0.012 0.000 0.000 0.752 0.236 0.000
#> SRR949121     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949122     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949123     2  0.0000      0.695 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949124     2  0.0000      0.695 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949125     4  0.1863      0.884 0.000 0.000 0.000 0.896 0.104 0.000
#> SRR949126     4  0.1863      0.884 0.000 0.000 0.000 0.896 0.104 0.000
#> SRR949127     5  0.3607      0.949 0.000 0.348 0.000 0.000 0.652 0.000
#> SRR949128     5  0.3607      0.949 0.000 0.348 0.000 0.000 0.652 0.000
#> SRR949129     5  0.3607      0.949 0.000 0.348 0.000 0.000 0.652 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

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

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.354           0.766       0.860         0.4336 0.547   0.547
#> 3 3 0.394           0.548       0.758         0.4060 0.682   0.470
#> 4 4 0.580           0.679       0.825         0.1760 0.860   0.619
#> 5 5 0.614           0.560       0.731         0.0833 0.867   0.571
#> 6 6 0.593           0.533       0.677         0.0349 0.930   0.714

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
#> SRR949076     1  0.9522      0.387 0.628 0.372
#> SRR949078     2  0.3733      0.908 0.072 0.928
#> SRR949077     1  0.9522      0.387 0.628 0.372
#> SRR949079     1  0.9460      0.408 0.636 0.364
#> SRR949080     1  0.9460      0.408 0.636 0.364
#> SRR949081     2  0.7745      0.792 0.228 0.772
#> SRR949082     2  0.3733      0.908 0.072 0.928
#> SRR949083     1  0.3274      0.827 0.940 0.060
#> SRR949084     1  0.2423      0.839 0.960 0.040
#> SRR949085     2  0.3733      0.908 0.072 0.928
#> SRR949087     2  0.7815      0.787 0.232 0.768
#> SRR949088     2  0.7815      0.787 0.232 0.768
#> SRR949086     1  0.0672      0.830 0.992 0.008
#> SRR949089     2  0.3733      0.908 0.072 0.928
#> SRR949090     1  0.9087      0.494 0.676 0.324
#> SRR949092     1  0.2236      0.841 0.964 0.036
#> SRR949093     1  0.2236      0.841 0.964 0.036
#> SRR949091     1  0.1414      0.827 0.980 0.020
#> SRR949095     2  0.7815      0.787 0.232 0.768
#> SRR949094     1  0.9170      0.480 0.668 0.332
#> SRR949096     1  0.2236      0.841 0.964 0.036
#> SRR949097     1  0.2236      0.841 0.964 0.036
#> SRR949098     2  0.3733      0.908 0.072 0.928
#> SRR949099     1  0.0376      0.830 0.996 0.004
#> SRR949101     1  0.0672      0.830 0.992 0.008
#> SRR949100     2  0.9248      0.564 0.340 0.660
#> SRR949102     2  0.8909      0.694 0.308 0.692
#> SRR949103     1  0.2236      0.841 0.964 0.036
#> SRR949104     2  0.3733      0.908 0.072 0.928
#> SRR949105     1  0.4022      0.783 0.920 0.080
#> SRR949106     1  0.4022      0.783 0.920 0.080
#> SRR949107     1  0.4022      0.783 0.920 0.080
#> SRR949108     1  0.2236      0.841 0.964 0.036
#> SRR949109     1  0.9170      0.480 0.668 0.332
#> SRR949110     1  0.2236      0.841 0.964 0.036
#> SRR949111     1  0.9170      0.480 0.668 0.332
#> SRR949112     1  0.2236      0.841 0.964 0.036
#> SRR949113     2  0.3733      0.908 0.072 0.928
#> SRR949114     1  0.2236      0.841 0.964 0.036
#> SRR949115     1  0.2236      0.841 0.964 0.036
#> SRR949116     1  0.2236      0.841 0.964 0.036
#> SRR949117     1  0.0672      0.830 0.992 0.008
#> SRR949118     1  0.3879      0.786 0.924 0.076
#> SRR949119     1  0.2236      0.841 0.964 0.036
#> SRR949120     1  0.2236      0.841 0.964 0.036
#> SRR949121     1  0.2236      0.841 0.964 0.036
#> SRR949122     1  0.2236      0.841 0.964 0.036
#> SRR949123     2  0.3733      0.908 0.072 0.928
#> SRR949124     2  0.3733      0.908 0.072 0.928
#> SRR949125     1  0.9170      0.480 0.668 0.332
#> SRR949126     1  0.9170      0.480 0.668 0.332
#> SRR949127     2  0.3733      0.908 0.072 0.928
#> SRR949128     2  0.3733      0.908 0.072 0.928
#> SRR949129     2  0.3733      0.908 0.072 0.928

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR949076     3  0.7228      0.679 0.364 0.036 0.600
#> SRR949078     2  0.0592      0.865 0.012 0.988 0.000
#> SRR949077     3  0.7228      0.679 0.364 0.036 0.600
#> SRR949079     3  0.7141      0.679 0.368 0.032 0.600
#> SRR949080     3  0.7141      0.679 0.368 0.032 0.600
#> SRR949081     2  0.9263     -0.288 0.360 0.476 0.164
#> SRR949082     2  0.0592      0.865 0.012 0.988 0.000
#> SRR949083     1  0.4887      0.557 0.772 0.228 0.000
#> SRR949084     1  0.6081      0.519 0.652 0.344 0.004
#> SRR949085     2  0.0000      0.869 0.000 1.000 0.000
#> SRR949087     1  0.9566      0.357 0.440 0.360 0.200
#> SRR949088     1  0.9566      0.357 0.440 0.360 0.200
#> SRR949086     1  0.6824      0.164 0.576 0.016 0.408
#> SRR949089     2  0.0000      0.869 0.000 1.000 0.000
#> SRR949090     3  0.6510      0.691 0.364 0.012 0.624
#> SRR949092     1  0.2261      0.565 0.932 0.068 0.000
#> SRR949093     1  0.2261      0.565 0.932 0.068 0.000
#> SRR949091     3  0.2599      0.538 0.052 0.016 0.932
#> SRR949095     2  0.9263     -0.288 0.360 0.476 0.164
#> SRR949094     3  0.6529      0.691 0.368 0.012 0.620
#> SRR949096     1  0.6081      0.519 0.652 0.344 0.004
#> SRR949097     1  0.0237      0.537 0.996 0.000 0.004
#> SRR949098     2  0.0000      0.869 0.000 1.000 0.000
#> SRR949099     1  0.4575      0.354 0.828 0.012 0.160
#> SRR949101     3  0.3091      0.536 0.072 0.016 0.912
#> SRR949100     1  0.9633      0.347 0.436 0.352 0.212
#> SRR949102     3  0.9388      0.344 0.388 0.172 0.440
#> SRR949103     1  0.0237      0.537 0.996 0.000 0.004
#> SRR949104     2  0.0000      0.869 0.000 1.000 0.000
#> SRR949105     3  0.3573      0.513 0.120 0.004 0.876
#> SRR949106     3  0.3644      0.510 0.124 0.004 0.872
#> SRR949107     3  0.3644      0.510 0.124 0.004 0.872
#> SRR949108     1  0.4413      0.563 0.852 0.124 0.024
#> SRR949109     3  0.6510      0.691 0.364 0.012 0.624
#> SRR949110     1  0.0237      0.537 0.996 0.000 0.004
#> SRR949111     3  0.6529      0.691 0.368 0.012 0.620
#> SRR949112     1  0.7262      0.486 0.624 0.332 0.044
#> SRR949113     2  0.0592      0.865 0.012 0.988 0.000
#> SRR949114     1  0.5775      0.357 0.728 0.012 0.260
#> SRR949115     1  0.5406      0.394 0.764 0.012 0.224
#> SRR949116     1  0.5406      0.394 0.764 0.012 0.224
#> SRR949117     1  0.6888      0.136 0.552 0.016 0.432
#> SRR949118     3  0.6955     -0.135 0.488 0.016 0.496
#> SRR949119     1  0.8798      0.404 0.520 0.356 0.124
#> SRR949120     1  0.8836      0.404 0.520 0.352 0.128
#> SRR949121     1  0.1482      0.546 0.968 0.012 0.020
#> SRR949122     1  0.5760      0.526 0.672 0.328 0.000
#> SRR949123     2  0.0000      0.869 0.000 1.000 0.000
#> SRR949124     2  0.0000      0.869 0.000 1.000 0.000
#> SRR949125     3  0.6529      0.691 0.368 0.012 0.620
#> SRR949126     3  0.6529      0.691 0.368 0.012 0.620
#> SRR949127     2  0.1989      0.848 0.004 0.948 0.048
#> SRR949128     2  0.1989      0.848 0.004 0.948 0.048
#> SRR949129     2  0.1989      0.848 0.004 0.948 0.048

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR949076     4  0.1109      0.765 0.028 0.000 0.004 0.968
#> SRR949078     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> SRR949077     4  0.1109      0.765 0.028 0.004 0.000 0.968
#> SRR949079     4  0.0921      0.775 0.028 0.000 0.000 0.972
#> SRR949080     4  0.0921      0.775 0.028 0.000 0.000 0.972
#> SRR949081     2  0.7943      0.356 0.104 0.572 0.080 0.244
#> SRR949082     2  0.0188      0.952 0.000 0.996 0.004 0.000
#> SRR949083     1  0.3945      0.710 0.780 0.004 0.000 0.216
#> SRR949084     1  0.3801      0.709 0.780 0.000 0.000 0.220
#> SRR949085     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> SRR949087     1  0.6975      0.439 0.572 0.316 0.012 0.100
#> SRR949088     1  0.6992      0.434 0.568 0.320 0.012 0.100
#> SRR949086     3  0.5285      0.240 0.468 0.000 0.524 0.008
#> SRR949089     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> SRR949090     4  0.3852      0.735 0.192 0.000 0.008 0.800
#> SRR949092     1  0.2814      0.755 0.868 0.000 0.000 0.132
#> SRR949093     1  0.2921      0.755 0.860 0.000 0.000 0.140
#> SRR949091     4  0.4800      0.341 0.004 0.000 0.340 0.656
#> SRR949095     4  0.7996      0.133 0.224 0.372 0.008 0.396
#> SRR949094     4  0.1356      0.776 0.032 0.000 0.008 0.960
#> SRR949096     1  0.3837      0.713 0.776 0.000 0.000 0.224
#> SRR949097     1  0.1389      0.734 0.952 0.000 0.000 0.048
#> SRR949098     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> SRR949099     1  0.4839      0.531 0.764 0.000 0.184 0.052
#> SRR949101     3  0.4560      0.370 0.004 0.000 0.700 0.296
#> SRR949100     1  0.6840      0.442 0.580 0.312 0.008 0.100
#> SRR949102     4  0.6239      0.587 0.048 0.160 0.072 0.720
#> SRR949103     1  0.1389      0.734 0.952 0.000 0.000 0.048
#> SRR949104     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> SRR949105     3  0.0376      0.678 0.004 0.000 0.992 0.004
#> SRR949106     3  0.0376      0.678 0.004 0.000 0.992 0.004
#> SRR949107     3  0.0376      0.678 0.004 0.000 0.992 0.004
#> SRR949108     1  0.3032      0.752 0.868 0.000 0.008 0.124
#> SRR949109     4  0.3972      0.726 0.204 0.000 0.008 0.788
#> SRR949110     1  0.1389      0.734 0.952 0.000 0.000 0.048
#> SRR949111     4  0.2976      0.768 0.120 0.000 0.008 0.872
#> SRR949112     1  0.2466      0.750 0.900 0.000 0.004 0.096
#> SRR949113     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> SRR949114     1  0.4454      0.353 0.692 0.000 0.308 0.000
#> SRR949115     1  0.4608      0.362 0.692 0.000 0.304 0.004
#> SRR949116     1  0.4560      0.378 0.700 0.000 0.296 0.004
#> SRR949117     3  0.5285      0.240 0.468 0.000 0.524 0.008
#> SRR949118     3  0.4331      0.528 0.288 0.000 0.712 0.000
#> SRR949119     4  0.4762      0.515 0.300 0.004 0.004 0.692
#> SRR949120     4  0.4809      0.501 0.308 0.004 0.004 0.684
#> SRR949121     1  0.2469      0.756 0.892 0.000 0.000 0.108
#> SRR949122     1  0.2469      0.757 0.892 0.000 0.000 0.108
#> SRR949123     2  0.0188      0.951 0.000 0.996 0.000 0.004
#> SRR949124     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> SRR949125     4  0.2918      0.770 0.116 0.000 0.008 0.876
#> SRR949126     4  0.2976      0.768 0.120 0.000 0.008 0.872
#> SRR949127     2  0.1471      0.937 0.024 0.960 0.004 0.012
#> SRR949128     2  0.1471      0.937 0.024 0.960 0.004 0.012
#> SRR949129     2  0.1471      0.937 0.024 0.960 0.004 0.012

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR949076     4  0.1168      0.707 0.000 0.008 0.000 0.960 0.032
#> SRR949078     2  0.1690      0.922 0.008 0.944 0.000 0.024 0.024
#> SRR949077     4  0.1822      0.723 0.024 0.000 0.004 0.936 0.036
#> SRR949079     4  0.2331      0.774 0.080 0.000 0.000 0.900 0.020
#> SRR949080     4  0.2331      0.774 0.080 0.000 0.000 0.900 0.020
#> SRR949081     5  0.9760      0.840 0.168 0.236 0.128 0.180 0.288
#> SRR949082     2  0.1153      0.927 0.004 0.964 0.000 0.024 0.008
#> SRR949083     1  0.3966      0.462 0.788 0.004 0.000 0.168 0.040
#> SRR949084     1  0.3376      0.531 0.840 0.004 0.004 0.128 0.024
#> SRR949085     2  0.0000      0.939 0.000 1.000 0.000 0.000 0.000
#> SRR949087     1  0.9483     -0.355 0.292 0.112 0.240 0.100 0.256
#> SRR949088     1  0.9483     -0.355 0.292 0.112 0.240 0.100 0.256
#> SRR949086     3  0.1205      0.528 0.040 0.000 0.956 0.000 0.004
#> SRR949089     2  0.0162      0.939 0.000 0.996 0.000 0.000 0.004
#> SRR949090     4  0.4936      0.728 0.172 0.000 0.116 0.712 0.000
#> SRR949092     1  0.1831      0.563 0.920 0.000 0.000 0.076 0.004
#> SRR949093     1  0.2408      0.547 0.892 0.000 0.000 0.092 0.016
#> SRR949091     3  0.6216      0.439 0.000 0.000 0.548 0.208 0.244
#> SRR949095     5  0.9539      0.835 0.252 0.188 0.076 0.196 0.288
#> SRR949094     4  0.2983      0.787 0.076 0.000 0.056 0.868 0.000
#> SRR949096     1  0.3304      0.531 0.840 0.000 0.004 0.128 0.028
#> SRR949097     1  0.5838      0.422 0.620 0.000 0.248 0.008 0.124
#> SRR949098     2  0.0486      0.938 0.004 0.988 0.004 0.000 0.004
#> SRR949099     3  0.6232     -0.110 0.380 0.000 0.488 0.004 0.128
#> SRR949101     3  0.4522      0.543 0.000 0.000 0.708 0.044 0.248
#> SRR949100     1  0.8887     -0.292 0.372 0.112 0.216 0.044 0.256
#> SRR949102     4  0.7490     -0.292 0.028 0.040 0.152 0.520 0.260
#> SRR949103     1  0.5745      0.423 0.620 0.000 0.252 0.004 0.124
#> SRR949104     2  0.0162      0.939 0.000 0.996 0.000 0.000 0.004
#> SRR949105     3  0.3949      0.566 0.000 0.000 0.668 0.000 0.332
#> SRR949106     3  0.3949      0.566 0.000 0.000 0.668 0.000 0.332
#> SRR949107     3  0.3949      0.566 0.000 0.000 0.668 0.000 0.332
#> SRR949108     1  0.2819      0.584 0.884 0.004 0.052 0.060 0.000
#> SRR949109     4  0.4936      0.728 0.172 0.000 0.116 0.712 0.000
#> SRR949110     1  0.5838      0.422 0.620 0.000 0.248 0.008 0.124
#> SRR949111     4  0.3821      0.798 0.148 0.000 0.052 0.800 0.000
#> SRR949112     1  0.4452      0.559 0.772 0.004 0.168 0.040 0.016
#> SRR949113     2  0.0324      0.939 0.004 0.992 0.000 0.000 0.004
#> SRR949114     3  0.4709      0.100 0.400 0.000 0.584 0.008 0.008
#> SRR949115     3  0.4709      0.100 0.400 0.000 0.584 0.008 0.008
#> SRR949116     3  0.4718      0.092 0.404 0.000 0.580 0.008 0.008
#> SRR949117     3  0.2068      0.515 0.092 0.000 0.904 0.004 0.000
#> SRR949118     3  0.3395      0.563 0.000 0.000 0.764 0.000 0.236
#> SRR949119     1  0.5676      0.314 0.632 0.000 0.004 0.240 0.124
#> SRR949120     1  0.5676      0.314 0.632 0.000 0.004 0.240 0.124
#> SRR949121     1  0.4578      0.525 0.712 0.004 0.244 0.040 0.000
#> SRR949122     1  0.2597      0.585 0.896 0.004 0.060 0.040 0.000
#> SRR949123     2  0.1012      0.925 0.000 0.968 0.000 0.012 0.020
#> SRR949124     2  0.0162      0.939 0.000 0.996 0.000 0.000 0.004
#> SRR949125     4  0.3821      0.798 0.148 0.000 0.052 0.800 0.000
#> SRR949126     4  0.3821      0.798 0.148 0.000 0.052 0.800 0.000
#> SRR949127     2  0.2806      0.858 0.004 0.844 0.000 0.000 0.152
#> SRR949128     2  0.2806      0.858 0.004 0.844 0.000 0.000 0.152
#> SRR949129     2  0.2806      0.858 0.004 0.844 0.000 0.000 0.152

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR949076     4  0.4738     0.7672 0.112 0.008 0.000 0.752 0.072 NA
#> SRR949078     2  0.2873     0.7426 0.044 0.872 0.000 0.068 0.012 NA
#> SRR949077     4  0.5561     0.8150 0.176 0.032 0.000 0.680 0.072 NA
#> SRR949079     4  0.5195     0.8204 0.200 0.000 0.000 0.676 0.068 NA
#> SRR949080     4  0.5195     0.8204 0.200 0.000 0.000 0.676 0.068 NA
#> SRR949081     5  0.8656     0.0957 0.128 0.256 0.000 0.176 0.304 NA
#> SRR949082     2  0.3039     0.7416 0.028 0.868 0.000 0.068 0.028 NA
#> SRR949083     1  0.2914     0.6079 0.864 0.004 0.000 0.068 0.004 NA
#> SRR949084     1  0.1411     0.6467 0.936 0.004 0.000 0.000 0.000 NA
#> SRR949085     2  0.0865     0.7827 0.000 0.964 0.000 0.000 0.000 NA
#> SRR949087     5  0.8439     0.1548 0.292 0.156 0.000 0.076 0.300 NA
#> SRR949088     5  0.8439     0.1548 0.292 0.156 0.000 0.076 0.300 NA
#> SRR949086     3  0.5900     0.4208 0.032 0.000 0.524 0.080 0.356 NA
#> SRR949089     2  0.2260     0.7834 0.000 0.860 0.000 0.000 0.000 NA
#> SRR949090     4  0.3270     0.8399 0.152 0.024 0.004 0.816 0.004 NA
#> SRR949092     1  0.0508     0.6585 0.984 0.000 0.000 0.000 0.012 NA
#> SRR949093     1  0.0508     0.6585 0.984 0.000 0.000 0.000 0.012 NA
#> SRR949091     3  0.5279     0.3626 0.000 0.024 0.584 0.336 0.052 NA
#> SRR949095     5  0.8724     0.1000 0.140 0.252 0.000 0.176 0.292 NA
#> SRR949094     4  0.4096     0.8322 0.204 0.028 0.000 0.744 0.000 NA
#> SRR949096     1  0.2333     0.6210 0.872 0.004 0.000 0.004 0.000 NA
#> SRR949097     1  0.4227     0.1273 0.496 0.000 0.000 0.008 0.492 NA
#> SRR949098     2  0.2738     0.7777 0.004 0.820 0.000 0.000 0.000 NA
#> SRR949099     5  0.4548     0.1121 0.156 0.000 0.116 0.008 0.720 NA
#> SRR949101     3  0.3833     0.6304 0.000 0.016 0.804 0.108 0.068 NA
#> SRR949100     1  0.7930    -0.2276 0.344 0.188 0.000 0.028 0.296 NA
#> SRR949102     4  0.8451     0.1309 0.116 0.064 0.020 0.336 0.320 NA
#> SRR949103     1  0.4227     0.1273 0.496 0.000 0.000 0.008 0.492 NA
#> SRR949104     2  0.2178     0.7856 0.000 0.868 0.000 0.000 0.000 NA
#> SRR949105     3  0.0260     0.7050 0.000 0.000 0.992 0.008 0.000 NA
#> SRR949106     3  0.0260     0.7050 0.000 0.000 0.992 0.008 0.000 NA
#> SRR949107     3  0.0260     0.7050 0.000 0.000 0.992 0.008 0.000 NA
#> SRR949108     1  0.1616     0.6552 0.940 0.000 0.000 0.012 0.028 NA
#> SRR949109     4  0.3457     0.8383 0.152 0.028 0.004 0.808 0.008 NA
#> SRR949110     5  0.4227    -0.2756 0.492 0.000 0.000 0.008 0.496 NA
#> SRR949111     4  0.2662     0.8399 0.152 0.000 0.004 0.840 0.004 NA
#> SRR949112     1  0.3397     0.5862 0.836 0.000 0.000 0.024 0.084 NA
#> SRR949113     2  0.1257     0.7754 0.020 0.952 0.000 0.000 0.028 NA
#> SRR949114     5  0.7463     0.0658 0.272 0.000 0.296 0.072 0.344 NA
#> SRR949115     5  0.7463     0.0658 0.272 0.000 0.296 0.072 0.344 NA
#> SRR949116     5  0.7463     0.0658 0.272 0.000 0.296 0.072 0.344 NA
#> SRR949117     3  0.5933     0.4164 0.032 0.000 0.524 0.084 0.352 NA
#> SRR949118     3  0.3704     0.6665 0.012 0.000 0.804 0.048 0.132 NA
#> SRR949119     1  0.5648     0.4212 0.604 0.000 0.000 0.108 0.036 NA
#> SRR949120     1  0.5648     0.4212 0.604 0.000 0.000 0.108 0.036 NA
#> SRR949121     1  0.2841     0.5486 0.824 0.000 0.000 0.012 0.164 NA
#> SRR949122     1  0.2085     0.6350 0.912 0.000 0.000 0.008 0.024 NA
#> SRR949123     2  0.3346     0.7713 0.008 0.816 0.000 0.000 0.036 NA
#> SRR949124     2  0.2260     0.7834 0.000 0.860 0.000 0.000 0.000 NA
#> SRR949125     4  0.2624     0.8388 0.148 0.000 0.004 0.844 0.004 NA
#> SRR949126     4  0.2624     0.8388 0.148 0.000 0.004 0.844 0.004 NA
#> SRR949127     2  0.3899     0.5998 0.000 0.592 0.000 0.004 0.000 NA
#> SRR949128     2  0.3899     0.5998 0.000 0.592 0.000 0.004 0.000 NA
#> SRR949129     2  0.3899     0.5998 0.000 0.592 0.000 0.004 0.000 NA

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

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-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

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

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.994           0.944       0.977          0.427 0.575   0.575
#> 3 3 0.641           0.810       0.903          0.564 0.679   0.475
#> 4 4 0.712           0.749       0.885          0.128 0.787   0.457
#> 5 5 0.689           0.570       0.774          0.055 0.984   0.935
#> 6 6 0.737           0.602       0.750          0.040 0.879   0.537

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
#> SRR949076     1  0.0000      0.980 1.000 0.000
#> SRR949078     2  0.0000      0.966 0.000 1.000
#> SRR949077     1  0.0000      0.980 1.000 0.000
#> SRR949079     1  0.0000      0.980 1.000 0.000
#> SRR949080     1  0.0000      0.980 1.000 0.000
#> SRR949081     2  0.0000      0.966 0.000 1.000
#> SRR949082     2  0.0000      0.966 0.000 1.000
#> SRR949083     1  0.0000      0.980 1.000 0.000
#> SRR949084     1  0.0000      0.980 1.000 0.000
#> SRR949085     2  0.0000      0.966 0.000 1.000
#> SRR949087     2  0.4022      0.902 0.080 0.920
#> SRR949088     2  0.4022      0.902 0.080 0.920
#> SRR949086     1  0.1184      0.968 0.984 0.016
#> SRR949089     2  0.0000      0.966 0.000 1.000
#> SRR949090     1  0.0000      0.980 1.000 0.000
#> SRR949092     1  0.0000      0.980 1.000 0.000
#> SRR949093     1  0.0000      0.980 1.000 0.000
#> SRR949091     1  0.0000      0.980 1.000 0.000
#> SRR949095     2  0.9209      0.501 0.336 0.664
#> SRR949094     1  0.0000      0.980 1.000 0.000
#> SRR949096     1  0.0000      0.980 1.000 0.000
#> SRR949097     1  0.0000      0.980 1.000 0.000
#> SRR949098     2  0.0000      0.966 0.000 1.000
#> SRR949099     1  0.0000      0.980 1.000 0.000
#> SRR949101     1  0.0000      0.980 1.000 0.000
#> SRR949100     1  0.9963      0.108 0.536 0.464
#> SRR949102     1  0.0376      0.977 0.996 0.004
#> SRR949103     1  0.0000      0.980 1.000 0.000
#> SRR949104     2  0.0000      0.966 0.000 1.000
#> SRR949105     1  0.2778      0.939 0.952 0.048
#> SRR949106     1  0.4161      0.903 0.916 0.084
#> SRR949107     1  0.4161      0.903 0.916 0.084
#> SRR949108     1  0.0000      0.980 1.000 0.000
#> SRR949109     1  0.0000      0.980 1.000 0.000
#> SRR949110     1  0.0000      0.980 1.000 0.000
#> SRR949111     1  0.0000      0.980 1.000 0.000
#> SRR949112     1  0.0672      0.974 0.992 0.008
#> SRR949113     2  0.0000      0.966 0.000 1.000
#> SRR949114     1  0.0000      0.980 1.000 0.000
#> SRR949115     1  0.0000      0.980 1.000 0.000
#> SRR949116     1  0.0000      0.980 1.000 0.000
#> SRR949117     1  0.1633      0.961 0.976 0.024
#> SRR949118     1  0.0000      0.980 1.000 0.000
#> SRR949119     1  0.0000      0.980 1.000 0.000
#> SRR949120     1  0.0000      0.980 1.000 0.000
#> SRR949121     1  0.0000      0.980 1.000 0.000
#> SRR949122     1  0.0000      0.980 1.000 0.000
#> SRR949123     2  0.0000      0.966 0.000 1.000
#> SRR949124     2  0.0000      0.966 0.000 1.000
#> SRR949125     1  0.0000      0.980 1.000 0.000
#> SRR949126     1  0.0000      0.980 1.000 0.000
#> SRR949127     2  0.0000      0.966 0.000 1.000
#> SRR949128     2  0.0000      0.966 0.000 1.000
#> SRR949129     2  0.0000      0.966 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
#> SRR949076     1  0.4346      0.777 0.816 0.000 0.184
#> SRR949078     2  0.0000      0.949 0.000 1.000 0.000
#> SRR949077     1  0.3879      0.795 0.848 0.000 0.152
#> SRR949079     1  0.4346      0.777 0.816 0.000 0.184
#> SRR949080     1  0.4346      0.777 0.816 0.000 0.184
#> SRR949081     1  0.6527      0.268 0.588 0.404 0.008
#> SRR949082     2  0.0000      0.949 0.000 1.000 0.000
#> SRR949083     1  0.0592      0.850 0.988 0.000 0.012
#> SRR949084     1  0.0592      0.850 0.988 0.000 0.012
#> SRR949085     2  0.0000      0.949 0.000 1.000 0.000
#> SRR949087     2  0.3619      0.828 0.136 0.864 0.000
#> SRR949088     2  0.3482      0.837 0.128 0.872 0.000
#> SRR949086     3  0.3207      0.837 0.012 0.084 0.904
#> SRR949089     2  0.0000      0.949 0.000 1.000 0.000
#> SRR949090     3  0.1529      0.864 0.040 0.000 0.960
#> SRR949092     1  0.0592      0.850 0.988 0.000 0.012
#> SRR949093     1  0.0592      0.850 0.988 0.000 0.012
#> SRR949091     3  0.0592      0.864 0.012 0.000 0.988
#> SRR949095     1  0.4999      0.746 0.820 0.152 0.028
#> SRR949094     1  0.4555      0.765 0.800 0.000 0.200
#> SRR949096     1  0.0592      0.850 0.988 0.000 0.012
#> SRR949097     1  0.5859      0.299 0.656 0.000 0.344
#> SRR949098     2  0.0000      0.949 0.000 1.000 0.000
#> SRR949099     3  0.4002      0.813 0.160 0.000 0.840
#> SRR949101     3  0.0000      0.869 0.000 0.000 1.000
#> SRR949100     2  0.6062      0.361 0.384 0.616 0.000
#> SRR949102     1  0.4452      0.773 0.808 0.000 0.192
#> SRR949103     3  0.5882      0.636 0.348 0.000 0.652
#> SRR949104     2  0.0000      0.949 0.000 1.000 0.000
#> SRR949105     3  0.0829      0.872 0.012 0.004 0.984
#> SRR949106     3  0.0829      0.872 0.012 0.004 0.984
#> SRR949107     3  0.0829      0.872 0.012 0.004 0.984
#> SRR949108     1  0.0592      0.850 0.988 0.000 0.012
#> SRR949109     3  0.2878      0.844 0.096 0.000 0.904
#> SRR949110     1  0.5968      0.231 0.636 0.000 0.364
#> SRR949111     3  0.4121      0.774 0.168 0.000 0.832
#> SRR949112     1  0.0592      0.850 0.988 0.000 0.012
#> SRR949113     2  0.0000      0.949 0.000 1.000 0.000
#> SRR949114     3  0.4654      0.787 0.208 0.000 0.792
#> SRR949115     3  0.5058      0.761 0.244 0.000 0.756
#> SRR949116     3  0.5058      0.761 0.244 0.000 0.756
#> SRR949117     3  0.4891      0.799 0.040 0.124 0.836
#> SRR949118     3  0.0747      0.872 0.016 0.000 0.984
#> SRR949119     1  0.0424      0.847 0.992 0.000 0.008
#> SRR949120     1  0.0424      0.847 0.992 0.000 0.008
#> SRR949121     1  0.0592      0.850 0.988 0.000 0.012
#> SRR949122     1  0.0592      0.850 0.988 0.000 0.012
#> SRR949123     2  0.0000      0.949 0.000 1.000 0.000
#> SRR949124     2  0.0000      0.949 0.000 1.000 0.000
#> SRR949125     3  0.2878      0.844 0.096 0.000 0.904
#> SRR949126     3  0.2878      0.844 0.096 0.000 0.904
#> SRR949127     2  0.0000      0.949 0.000 1.000 0.000
#> SRR949128     2  0.0000      0.949 0.000 1.000 0.000
#> SRR949129     2  0.0000      0.949 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
#> SRR949076     4  0.0000     0.7128 0.000 0.000 0.000 1.000
#> SRR949078     2  0.0000     0.9320 0.000 1.000 0.000 0.000
#> SRR949077     4  0.0188     0.7138 0.000 0.000 0.004 0.996
#> SRR949079     4  0.0592     0.7153 0.000 0.000 0.016 0.984
#> SRR949080     4  0.0592     0.7153 0.000 0.000 0.016 0.984
#> SRR949081     4  0.7472     0.0625 0.008 0.412 0.136 0.444
#> SRR949082     2  0.0000     0.9320 0.000 1.000 0.000 0.000
#> SRR949083     1  0.3219     0.7844 0.836 0.000 0.000 0.164
#> SRR949084     1  0.2973     0.8014 0.856 0.000 0.000 0.144
#> SRR949085     2  0.0000     0.9320 0.000 1.000 0.000 0.000
#> SRR949087     2  0.4720     0.5720 0.324 0.672 0.000 0.004
#> SRR949088     2  0.4761     0.5567 0.332 0.664 0.000 0.004
#> SRR949086     3  0.0592     0.8600 0.016 0.000 0.984 0.000
#> SRR949089     2  0.0000     0.9320 0.000 1.000 0.000 0.000
#> SRR949090     4  0.4941     0.3255 0.000 0.000 0.436 0.564
#> SRR949092     1  0.0000     0.8989 1.000 0.000 0.000 0.000
#> SRR949093     1  0.0000     0.8989 1.000 0.000 0.000 0.000
#> SRR949091     3  0.3486     0.6428 0.000 0.000 0.812 0.188
#> SRR949095     4  0.3306     0.6277 0.004 0.156 0.000 0.840
#> SRR949094     4  0.1389     0.7118 0.000 0.000 0.048 0.952
#> SRR949096     1  0.3074     0.7946 0.848 0.000 0.000 0.152
#> SRR949097     1  0.0188     0.8974 0.996 0.000 0.000 0.004
#> SRR949098     2  0.0000     0.9320 0.000 1.000 0.000 0.000
#> SRR949099     3  0.4585     0.4674 0.332 0.000 0.668 0.000
#> SRR949101     3  0.0000     0.8623 0.000 0.000 1.000 0.000
#> SRR949100     2  0.4862     0.7696 0.108 0.800 0.012 0.080
#> SRR949102     4  0.2921     0.6647 0.000 0.000 0.140 0.860
#> SRR949103     1  0.0188     0.8969 0.996 0.000 0.004 0.000
#> SRR949104     2  0.0000     0.9320 0.000 1.000 0.000 0.000
#> SRR949105     3  0.0000     0.8623 0.000 0.000 1.000 0.000
#> SRR949106     3  0.0000     0.8623 0.000 0.000 1.000 0.000
#> SRR949107     3  0.0000     0.8623 0.000 0.000 1.000 0.000
#> SRR949108     1  0.0000     0.8989 1.000 0.000 0.000 0.000
#> SRR949109     4  0.4898     0.3674 0.000 0.000 0.416 0.584
#> SRR949110     1  0.0000     0.8989 1.000 0.000 0.000 0.000
#> SRR949111     4  0.3942     0.6181 0.000 0.000 0.236 0.764
#> SRR949112     1  0.0000     0.8989 1.000 0.000 0.000 0.000
#> SRR949113     2  0.0000     0.9320 0.000 1.000 0.000 0.000
#> SRR949114     1  0.4500     0.5230 0.684 0.000 0.316 0.000
#> SRR949115     1  0.3688     0.7123 0.792 0.000 0.208 0.000
#> SRR949116     1  0.3649     0.7174 0.796 0.000 0.204 0.000
#> SRR949117     3  0.3958     0.7504 0.160 0.024 0.816 0.000
#> SRR949118     3  0.2216     0.8200 0.092 0.000 0.908 0.000
#> SRR949119     4  0.4790     0.2707 0.380 0.000 0.000 0.620
#> SRR949120     4  0.4804     0.2615 0.384 0.000 0.000 0.616
#> SRR949121     1  0.0000     0.8989 1.000 0.000 0.000 0.000
#> SRR949122     1  0.0000     0.8989 1.000 0.000 0.000 0.000
#> SRR949123     2  0.0000     0.9320 0.000 1.000 0.000 0.000
#> SRR949124     2  0.0000     0.9320 0.000 1.000 0.000 0.000
#> SRR949125     4  0.4277     0.5829 0.000 0.000 0.280 0.720
#> SRR949126     4  0.4277     0.5829 0.000 0.000 0.280 0.720
#> SRR949127     2  0.0000     0.9320 0.000 1.000 0.000 0.000
#> SRR949128     2  0.0000     0.9320 0.000 1.000 0.000 0.000
#> SRR949129     2  0.0000     0.9320 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
#> SRR949076     4  0.1908      0.649 0.000 0.000 0.000 0.908 0.092
#> SRR949078     2  0.0000      0.881 0.000 1.000 0.000 0.000 0.000
#> SRR949077     4  0.2074      0.645 0.000 0.000 0.000 0.896 0.104
#> SRR949079     4  0.0000      0.649 0.000 0.000 0.000 1.000 0.000
#> SRR949080     4  0.0000      0.649 0.000 0.000 0.000 1.000 0.000
#> SRR949081     4  0.8983      0.284 0.072 0.144 0.132 0.408 0.244
#> SRR949082     2  0.0000      0.881 0.000 1.000 0.000 0.000 0.000
#> SRR949083     1  0.2927      0.691 0.872 0.000 0.000 0.068 0.060
#> SRR949084     1  0.2719      0.693 0.884 0.000 0.000 0.068 0.048
#> SRR949085     2  0.0000      0.881 0.000 1.000 0.000 0.000 0.000
#> SRR949087     2  0.7437      0.253 0.344 0.448 0.096 0.000 0.112
#> SRR949088     2  0.7437      0.254 0.344 0.448 0.096 0.000 0.112
#> SRR949086     3  0.2389      0.687 0.004 0.000 0.880 0.000 0.116
#> SRR949089     2  0.0000      0.881 0.000 1.000 0.000 0.000 0.000
#> SRR949090     4  0.6200      0.186 0.000 0.000 0.320 0.520 0.160
#> SRR949092     1  0.0609      0.731 0.980 0.000 0.000 0.000 0.020
#> SRR949093     1  0.0609      0.731 0.980 0.000 0.000 0.000 0.020
#> SRR949091     5  0.6819     -0.159 0.000 0.000 0.312 0.340 0.348
#> SRR949095     4  0.4985      0.564 0.000 0.076 0.000 0.680 0.244
#> SRR949094     4  0.0955      0.643 0.000 0.000 0.004 0.968 0.028
#> SRR949096     1  0.3336      0.664 0.844 0.000 0.000 0.096 0.060
#> SRR949097     1  0.2583      0.690 0.864 0.000 0.004 0.000 0.132
#> SRR949098     2  0.0000      0.881 0.000 1.000 0.000 0.000 0.000
#> SRR949099     3  0.6628      0.162 0.372 0.000 0.408 0.000 0.220
#> SRR949101     3  0.4342      0.493 0.000 0.000 0.728 0.040 0.232
#> SRR949100     2  0.7565      0.415 0.156 0.536 0.060 0.024 0.224
#> SRR949102     4  0.5555      0.532 0.004 0.000 0.104 0.636 0.256
#> SRR949103     1  0.3123      0.657 0.812 0.000 0.004 0.000 0.184
#> SRR949104     2  0.0000      0.881 0.000 1.000 0.000 0.000 0.000
#> SRR949105     3  0.0324      0.697 0.000 0.000 0.992 0.004 0.004
#> SRR949106     3  0.0162      0.697 0.000 0.000 0.996 0.004 0.000
#> SRR949107     3  0.0162      0.697 0.000 0.000 0.996 0.004 0.000
#> SRR949108     1  0.2471      0.689 0.864 0.000 0.000 0.000 0.136
#> SRR949109     4  0.6147      0.254 0.000 0.000 0.256 0.556 0.188
#> SRR949110     1  0.2389      0.697 0.880 0.000 0.004 0.000 0.116
#> SRR949111     4  0.4350      0.530 0.000 0.000 0.152 0.764 0.084
#> SRR949112     1  0.3661      0.516 0.724 0.000 0.000 0.000 0.276
#> SRR949113     2  0.0000      0.881 0.000 1.000 0.000 0.000 0.000
#> SRR949114     5  0.5854     -0.351 0.436 0.000 0.096 0.000 0.468
#> SRR949115     1  0.5458     -0.147 0.476 0.000 0.060 0.000 0.464
#> SRR949116     1  0.5458     -0.147 0.476 0.000 0.060 0.000 0.464
#> SRR949117     3  0.5738      0.492 0.132 0.000 0.604 0.000 0.264
#> SRR949118     3  0.4691      0.584 0.044 0.000 0.680 0.000 0.276
#> SRR949119     4  0.6009      0.454 0.180 0.000 0.000 0.580 0.240
#> SRR949120     4  0.6009      0.454 0.180 0.000 0.000 0.580 0.240
#> SRR949121     1  0.2424      0.695 0.868 0.000 0.000 0.000 0.132
#> SRR949122     1  0.2471      0.689 0.864 0.000 0.000 0.000 0.136
#> SRR949123     2  0.1043      0.857 0.000 0.960 0.000 0.000 0.040
#> SRR949124     2  0.0404      0.875 0.000 0.988 0.000 0.000 0.012
#> SRR949125     4  0.4743      0.492 0.000 0.000 0.156 0.732 0.112
#> SRR949126     4  0.4781      0.488 0.000 0.000 0.160 0.728 0.112
#> SRR949127     2  0.0404      0.877 0.000 0.988 0.000 0.000 0.012
#> SRR949128     2  0.0510      0.875 0.000 0.984 0.000 0.000 0.016
#> SRR949129     2  0.0000      0.881 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
#> SRR949076     4  0.3828    0.03128 0.000 0.000 0.000 0.560 0.440 0.000
#> SRR949078     2  0.0363    0.92680 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR949077     4  0.3944    0.04093 0.004 0.000 0.000 0.568 0.428 0.000
#> SRR949079     4  0.2562    0.62231 0.000 0.000 0.000 0.828 0.172 0.000
#> SRR949080     4  0.2562    0.62231 0.000 0.000 0.000 0.828 0.172 0.000
#> SRR949081     5  0.6627    0.54813 0.280 0.028 0.100 0.048 0.540 0.004
#> SRR949082     2  0.0363    0.92538 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR949083     1  0.3946    0.46600 0.768 0.000 0.000 0.004 0.076 0.152
#> SRR949084     1  0.4626    0.44903 0.704 0.000 0.000 0.004 0.128 0.164
#> SRR949085     2  0.0000    0.92937 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949087     1  0.6411    0.19217 0.528 0.252 0.176 0.000 0.036 0.008
#> SRR949088     1  0.6406    0.18092 0.520 0.260 0.180 0.000 0.032 0.008
#> SRR949086     3  0.3814    0.77635 0.096 0.000 0.816 0.008 0.052 0.028
#> SRR949089     2  0.0000    0.92937 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949090     4  0.3605    0.63772 0.000 0.000 0.084 0.804 0.108 0.004
#> SRR949092     1  0.3758    0.35452 0.700 0.000 0.000 0.000 0.016 0.284
#> SRR949093     1  0.3738    0.35936 0.704 0.000 0.000 0.000 0.016 0.280
#> SRR949091     4  0.4795    0.57249 0.000 0.000 0.112 0.696 0.012 0.180
#> SRR949095     5  0.5002    0.67159 0.024 0.068 0.000 0.228 0.676 0.004
#> SRR949094     4  0.2003    0.65916 0.000 0.000 0.000 0.884 0.116 0.000
#> SRR949096     1  0.5024    0.42831 0.672 0.000 0.000 0.012 0.180 0.136
#> SRR949097     1  0.5858    0.40021 0.636 0.000 0.004 0.064 0.164 0.132
#> SRR949098     2  0.0000    0.92937 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949099     1  0.6580    0.15870 0.540 0.000 0.192 0.060 0.200 0.008
#> SRR949101     3  0.3934    0.72635 0.000 0.000 0.764 0.044 0.012 0.180
#> SRR949100     2  0.7981    0.00907 0.284 0.364 0.040 0.096 0.212 0.004
#> SRR949102     5  0.6541    0.67347 0.068 0.000 0.064 0.180 0.608 0.080
#> SRR949103     1  0.5519    0.42561 0.676 0.000 0.004 0.064 0.132 0.124
#> SRR949104     2  0.0000    0.92937 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949105     3  0.1251    0.81733 0.000 0.000 0.956 0.024 0.008 0.012
#> SRR949106     3  0.1251    0.81733 0.000 0.000 0.956 0.024 0.008 0.012
#> SRR949107     3  0.1251    0.81733 0.000 0.000 0.956 0.024 0.008 0.012
#> SRR949108     6  0.4830    0.26477 0.412 0.000 0.000 0.008 0.040 0.540
#> SRR949109     4  0.3804    0.63021 0.004 0.000 0.032 0.792 0.152 0.020
#> SRR949110     1  0.6289    0.33221 0.568 0.000 0.004 0.056 0.160 0.212
#> SRR949111     4  0.3513    0.63215 0.020 0.000 0.024 0.804 0.152 0.000
#> SRR949112     6  0.3240    0.57529 0.244 0.000 0.000 0.004 0.000 0.752
#> SRR949113     2  0.0000    0.92937 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949114     6  0.0767    0.66531 0.004 0.000 0.008 0.012 0.000 0.976
#> SRR949115     6  0.0405    0.67196 0.004 0.000 0.008 0.000 0.000 0.988
#> SRR949116     6  0.0405    0.67196 0.004 0.000 0.008 0.000 0.000 0.988
#> SRR949117     3  0.5320    0.72412 0.148 0.000 0.680 0.000 0.052 0.120
#> SRR949118     3  0.5934    0.65429 0.116 0.000 0.600 0.004 0.048 0.232
#> SRR949119     5  0.4683    0.74666 0.052 0.000 0.000 0.176 0.724 0.048
#> SRR949120     5  0.4683    0.74666 0.052 0.000 0.000 0.176 0.724 0.048
#> SRR949121     1  0.3838   -0.08890 0.552 0.000 0.000 0.000 0.000 0.448
#> SRR949122     6  0.3899    0.36261 0.404 0.000 0.000 0.000 0.004 0.592
#> SRR949123     2  0.1584    0.88062 0.000 0.928 0.000 0.000 0.008 0.064
#> SRR949124     2  0.0790    0.91275 0.000 0.968 0.000 0.000 0.000 0.032
#> SRR949125     4  0.1682    0.69111 0.000 0.000 0.020 0.928 0.000 0.052
#> SRR949126     4  0.1921    0.69058 0.000 0.000 0.032 0.916 0.000 0.052
#> SRR949127     2  0.0777    0.92158 0.024 0.972 0.000 0.000 0.000 0.004
#> SRR949128     2  0.0922    0.91972 0.024 0.968 0.000 0.000 0.004 0.004
#> SRR949129     2  0.0777    0.92158 0.024 0.972 0.000 0.000 0.000 0.004

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

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-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

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 16816 rows and 54 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 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-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.621           0.877       0.942         0.4280 0.547   0.547
#> 3 3 0.614           0.663       0.847         0.2952 0.843   0.722
#> 4 4 0.774           0.914       0.947         0.2397 0.841   0.643
#> 5 5 0.897           0.898       0.929         0.0316 0.994   0.982
#> 6 6 0.898           0.886       0.909         0.0338 0.978   0.925

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
#> SRR949076     2   0.932      0.589 0.348 0.652
#> SRR949078     2   0.000      0.862 0.000 1.000
#> SRR949077     2   0.932      0.589 0.348 0.652
#> SRR949079     1   0.000      0.964 1.000 0.000
#> SRR949080     1   0.000      0.964 1.000 0.000
#> SRR949081     2   0.932      0.589 0.348 0.652
#> SRR949082     2   0.000      0.862 0.000 1.000
#> SRR949083     2   0.932      0.589 0.348 0.652
#> SRR949084     1   0.000      0.964 1.000 0.000
#> SRR949085     2   0.000      0.862 0.000 1.000
#> SRR949087     1   0.767      0.692 0.776 0.224
#> SRR949088     1   0.767      0.692 0.776 0.224
#> SRR949086     1   0.595      0.816 0.856 0.144
#> SRR949089     2   0.000      0.862 0.000 1.000
#> SRR949090     1   0.000      0.964 1.000 0.000
#> SRR949092     1   0.000      0.964 1.000 0.000
#> SRR949093     1   0.000      0.964 1.000 0.000
#> SRR949091     1   0.000      0.964 1.000 0.000
#> SRR949095     2   0.932      0.589 0.348 0.652
#> SRR949094     1   0.000      0.964 1.000 0.000
#> SRR949096     1   0.000      0.964 1.000 0.000
#> SRR949097     1   0.000      0.964 1.000 0.000
#> SRR949098     2   0.000      0.862 0.000 1.000
#> SRR949099     1   0.000      0.964 1.000 0.000
#> SRR949101     1   0.714      0.741 0.804 0.196
#> SRR949100     1   0.000      0.964 1.000 0.000
#> SRR949102     2   0.932      0.589 0.348 0.652
#> SRR949103     1   0.000      0.964 1.000 0.000
#> SRR949104     2   0.000      0.862 0.000 1.000
#> SRR949105     1   0.000      0.964 1.000 0.000
#> SRR949106     1   0.000      0.964 1.000 0.000
#> SRR949107     1   0.000      0.964 1.000 0.000
#> SRR949108     1   0.000      0.964 1.000 0.000
#> SRR949109     1   0.000      0.964 1.000 0.000
#> SRR949110     1   0.000      0.964 1.000 0.000
#> SRR949111     1   0.000      0.964 1.000 0.000
#> SRR949112     1   0.000      0.964 1.000 0.000
#> SRR949113     2   0.000      0.862 0.000 1.000
#> SRR949114     1   0.000      0.964 1.000 0.000
#> SRR949115     1   0.000      0.964 1.000 0.000
#> SRR949116     1   0.000      0.964 1.000 0.000
#> SRR949117     1   0.595      0.816 0.856 0.144
#> SRR949118     1   0.574      0.827 0.864 0.136
#> SRR949119     1   0.000      0.964 1.000 0.000
#> SRR949120     1   0.000      0.964 1.000 0.000
#> SRR949121     1   0.000      0.964 1.000 0.000
#> SRR949122     1   0.000      0.964 1.000 0.000
#> SRR949123     2   0.000      0.862 0.000 1.000
#> SRR949124     2   0.000      0.862 0.000 1.000
#> SRR949125     1   0.000      0.964 1.000 0.000
#> SRR949126     1   0.000      0.964 1.000 0.000
#> SRR949127     2   0.000      0.862 0.000 1.000
#> SRR949128     2   0.000      0.862 0.000 1.000
#> SRR949129     2   0.000      0.862 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
#> SRR949076     3   0.657     0.6022 0.348 0.016 0.636
#> SRR949078     2   0.606     0.6355 0.000 0.616 0.384
#> SRR949077     3   0.657     0.6022 0.348 0.016 0.636
#> SRR949079     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949080     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949081     3   0.657     0.6022 0.348 0.016 0.636
#> SRR949082     2   0.606     0.6355 0.000 0.616 0.384
#> SRR949083     3   0.657     0.6022 0.348 0.016 0.636
#> SRR949084     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949085     2   0.000     0.9017 0.000 1.000 0.000
#> SRR949087     1   0.484     0.3736 0.776 0.000 0.224
#> SRR949088     1   0.484     0.3736 0.776 0.000 0.224
#> SRR949086     3   0.631    -0.0410 0.492 0.000 0.508
#> SRR949089     2   0.000     0.9017 0.000 1.000 0.000
#> SRR949090     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949092     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949093     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949091     1   0.597     0.3446 0.636 0.000 0.364
#> SRR949095     3   0.657     0.6022 0.348 0.016 0.636
#> SRR949094     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949096     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949097     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949098     2   0.000     0.9017 0.000 1.000 0.000
#> SRR949099     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949101     3   0.624     0.0716 0.440 0.000 0.560
#> SRR949100     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949102     3   0.657     0.6022 0.348 0.016 0.636
#> SRR949103     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949104     2   0.000     0.9017 0.000 1.000 0.000
#> SRR949105     1   0.597     0.3446 0.636 0.000 0.364
#> SRR949106     1   0.597     0.3446 0.636 0.000 0.364
#> SRR949107     1   0.597     0.3446 0.636 0.000 0.364
#> SRR949108     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949109     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949110     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949111     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949112     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949113     2   0.000     0.9017 0.000 1.000 0.000
#> SRR949114     1   0.597     0.3446 0.636 0.000 0.364
#> SRR949115     1   0.597     0.3446 0.636 0.000 0.364
#> SRR949116     1   0.597     0.3446 0.636 0.000 0.364
#> SRR949117     3   0.631    -0.0410 0.492 0.000 0.508
#> SRR949118     3   0.631    -0.0682 0.500 0.000 0.500
#> SRR949119     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949120     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949121     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949122     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949123     2   0.000     0.9017 0.000 1.000 0.000
#> SRR949124     2   0.000     0.9017 0.000 1.000 0.000
#> SRR949125     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949126     1   0.000     0.8235 1.000 0.000 0.000
#> SRR949127     2   0.348     0.8651 0.000 0.872 0.128
#> SRR949128     2   0.348     0.8651 0.000 0.872 0.128
#> SRR949129     2   0.348     0.8651 0.000 0.872 0.128

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR949076     4   0.000      1.000 0.000 0.000 0.000 1.000
#> SRR949078     2   0.480      0.504 0.000 0.616 0.000 0.384
#> SRR949077     4   0.000      1.000 0.000 0.000 0.000 1.000
#> SRR949079     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949080     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949081     4   0.000      1.000 0.000 0.000 0.000 1.000
#> SRR949082     2   0.480      0.504 0.000 0.616 0.000 0.384
#> SRR949083     4   0.000      1.000 0.000 0.000 0.000 1.000
#> SRR949084     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949085     2   0.000      0.887 0.000 1.000 0.000 0.000
#> SRR949087     1   0.428      0.689 0.764 0.000 0.012 0.224
#> SRR949088     1   0.428      0.689 0.764 0.000 0.012 0.224
#> SRR949086     3   0.308      0.835 0.024 0.000 0.880 0.096
#> SRR949089     2   0.000      0.887 0.000 1.000 0.000 0.000
#> SRR949090     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949092     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949093     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949091     3   0.287      0.922 0.136 0.000 0.864 0.000
#> SRR949095     4   0.000      1.000 0.000 0.000 0.000 1.000
#> SRR949094     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949096     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949097     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949098     2   0.000      0.887 0.000 1.000 0.000 0.000
#> SRR949099     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949101     3   0.164      0.806 0.000 0.000 0.940 0.060
#> SRR949100     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949102     4   0.000      1.000 0.000 0.000 0.000 1.000
#> SRR949103     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949104     2   0.000      0.887 0.000 1.000 0.000 0.000
#> SRR949105     3   0.287      0.922 0.136 0.000 0.864 0.000
#> SRR949106     3   0.287      0.922 0.136 0.000 0.864 0.000
#> SRR949107     3   0.287      0.922 0.136 0.000 0.864 0.000
#> SRR949108     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949109     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949110     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949111     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949112     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949113     2   0.000      0.887 0.000 1.000 0.000 0.000
#> SRR949114     3   0.287      0.922 0.136 0.000 0.864 0.000
#> SRR949115     3   0.287      0.922 0.136 0.000 0.864 0.000
#> SRR949116     3   0.287      0.922 0.136 0.000 0.864 0.000
#> SRR949117     3   0.308      0.835 0.024 0.000 0.880 0.096
#> SRR949118     3   0.000      0.831 0.000 0.000 1.000 0.000
#> SRR949119     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949120     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949121     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949122     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949123     2   0.000      0.887 0.000 1.000 0.000 0.000
#> SRR949124     2   0.000      0.887 0.000 1.000 0.000 0.000
#> SRR949125     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949126     1   0.000      0.978 1.000 0.000 0.000 0.000
#> SRR949127     2   0.276      0.840 0.000 0.872 0.000 0.128
#> SRR949128     2   0.276      0.840 0.000 0.872 0.000 0.128
#> SRR949129     2   0.276      0.840 0.000 0.872 0.000 0.128

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette   p1    p2    p3    p4    p5
#> SRR949076     4  0.3452      1.000 0.00 0.000 0.000 0.756 0.244
#> SRR949078     2  0.5172      0.505 0.00 0.616 0.000 0.060 0.324
#> SRR949077     5  0.0609      0.946 0.00 0.000 0.000 0.020 0.980
#> SRR949079     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949080     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949081     5  0.1410      0.886 0.00 0.000 0.000 0.060 0.940
#> SRR949082     2  0.5172      0.505 0.00 0.616 0.000 0.060 0.324
#> SRR949083     5  0.0000      0.955 0.00 0.000 0.000 0.000 1.000
#> SRR949084     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949085     2  0.0000      0.878 0.00 1.000 0.000 0.000 0.000
#> SRR949087     1  0.4501      0.662 0.74 0.000 0.036 0.012 0.212
#> SRR949088     1  0.4501      0.662 0.74 0.000 0.036 0.012 0.212
#> SRR949086     3  0.4417      0.767 0.00 0.000 0.760 0.148 0.092
#> SRR949089     2  0.0000      0.878 0.00 1.000 0.000 0.000 0.000
#> SRR949090     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949092     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949093     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949091     3  0.1043      0.893 0.04 0.000 0.960 0.000 0.000
#> SRR949095     5  0.0000      0.955 0.00 0.000 0.000 0.000 1.000
#> SRR949094     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949096     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949097     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949098     2  0.0000      0.878 0.00 1.000 0.000 0.000 0.000
#> SRR949099     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949101     3  0.3707      0.731 0.00 0.000 0.716 0.284 0.000
#> SRR949100     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949102     4  0.3452      1.000 0.00 0.000 0.000 0.756 0.244
#> SRR949103     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949104     2  0.0404      0.877 0.00 0.988 0.000 0.012 0.000
#> SRR949105     3  0.1043      0.893 0.04 0.000 0.960 0.000 0.000
#> SRR949106     3  0.1043      0.893 0.04 0.000 0.960 0.000 0.000
#> SRR949107     3  0.1043      0.893 0.04 0.000 0.960 0.000 0.000
#> SRR949108     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949109     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949110     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949111     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949112     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949113     2  0.0404      0.877 0.00 0.988 0.000 0.012 0.000
#> SRR949114     3  0.1043      0.893 0.04 0.000 0.960 0.000 0.000
#> SRR949115     3  0.1043      0.893 0.04 0.000 0.960 0.000 0.000
#> SRR949116     3  0.1043      0.893 0.04 0.000 0.960 0.000 0.000
#> SRR949117     3  0.4417      0.767 0.00 0.000 0.760 0.148 0.092
#> SRR949118     3  0.3305      0.778 0.00 0.000 0.776 0.224 0.000
#> SRR949119     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949120     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949121     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949122     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949123     2  0.0000      0.878 0.00 1.000 0.000 0.000 0.000
#> SRR949124     2  0.0000      0.878 0.00 1.000 0.000 0.000 0.000
#> SRR949125     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949126     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000
#> SRR949127     2  0.2873      0.833 0.00 0.860 0.000 0.020 0.120
#> SRR949128     2  0.2873      0.833 0.00 0.860 0.000 0.020 0.120
#> SRR949129     2  0.2873      0.833 0.00 0.860 0.000 0.020 0.120

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette   p1    p2    p3    p4    p5    p6
#> SRR949076     4  0.2454      1.000 0.00 0.000 0.000 0.840 0.160 0.000
#> SRR949078     2  0.5176      0.575 0.00 0.616 0.000 0.092 0.280 0.012
#> SRR949077     5  0.0547      0.933 0.00 0.000 0.000 0.020 0.980 0.000
#> SRR949079     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949080     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949081     5  0.2070      0.834 0.00 0.012 0.000 0.092 0.896 0.000
#> SRR949082     2  0.5176      0.575 0.00 0.616 0.000 0.092 0.280 0.012
#> SRR949083     5  0.0000      0.941 0.00 0.000 0.000 0.000 1.000 0.000
#> SRR949084     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949085     2  0.3747      0.534 0.00 0.604 0.000 0.000 0.000 0.396
#> SRR949087     1  0.4268      0.667 0.74 0.020 0.036 0.004 0.200 0.000
#> SRR949088     1  0.4268      0.667 0.74 0.020 0.036 0.004 0.200 0.000
#> SRR949086     3  0.5746      0.703 0.00 0.152 0.656 0.096 0.092 0.004
#> SRR949089     6  0.0146      1.000 0.00 0.004 0.000 0.000 0.000 0.996
#> SRR949090     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949092     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949093     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949091     3  0.0000      0.863 0.00 0.000 1.000 0.000 0.000 0.000
#> SRR949095     5  0.0000      0.941 0.00 0.000 0.000 0.000 1.000 0.000
#> SRR949094     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949096     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949097     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949098     6  0.0146      1.000 0.00 0.004 0.000 0.000 0.000 0.996
#> SRR949099     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949101     3  0.5408      0.660 0.00 0.184 0.600 0.212 0.000 0.004
#> SRR949100     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949102     4  0.2454      1.000 0.00 0.000 0.000 0.840 0.160 0.000
#> SRR949103     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949104     2  0.2762      0.749 0.00 0.804 0.000 0.000 0.000 0.196
#> SRR949105     3  0.0000      0.863 0.00 0.000 1.000 0.000 0.000 0.000
#> SRR949106     3  0.0000      0.863 0.00 0.000 1.000 0.000 0.000 0.000
#> SRR949107     3  0.0000      0.863 0.00 0.000 1.000 0.000 0.000 0.000
#> SRR949108     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949109     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949110     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949111     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949112     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949113     2  0.2762      0.749 0.00 0.804 0.000 0.000 0.000 0.196
#> SRR949114     3  0.0000      0.863 0.00 0.000 1.000 0.000 0.000 0.000
#> SRR949115     3  0.0000      0.863 0.00 0.000 1.000 0.000 0.000 0.000
#> SRR949116     3  0.0000      0.863 0.00 0.000 1.000 0.000 0.000 0.000
#> SRR949117     3  0.5746      0.703 0.00 0.152 0.656 0.096 0.092 0.004
#> SRR949118     3  0.4997      0.712 0.00 0.176 0.660 0.160 0.000 0.004
#> SRR949119     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949120     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949121     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949122     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949123     6  0.0146      1.000 0.00 0.004 0.000 0.000 0.000 0.996
#> SRR949124     6  0.0146      1.000 0.00 0.004 0.000 0.000 0.000 0.996
#> SRR949125     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949126     1  0.0000      0.977 1.00 0.000 0.000 0.000 0.000 0.000
#> SRR949127     2  0.3252      0.795 0.00 0.824 0.000 0.000 0.108 0.068
#> SRR949128     2  0.3252      0.795 0.00 0.824 0.000 0.000 0.108 0.068
#> SRR949129     2  0.3252      0.795 0.00 0.824 0.000 0.000 0.108 0.068

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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

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

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

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.955       0.981         0.4656 0.535   0.535
#> 3 3 0.561           0.717       0.825         0.3768 0.776   0.600
#> 4 4 0.686           0.792       0.857         0.1260 0.899   0.729
#> 5 5 0.729           0.746       0.798         0.0855 0.887   0.612
#> 6 6 0.729           0.745       0.799         0.0457 0.970   0.847

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

suggest_best_k(res)
#> [1] 2

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR949076     2   0.000      0.975 0.000 1.000
#> SRR949078     2   0.000      0.975 0.000 1.000
#> SRR949077     2   0.973      0.307 0.404 0.596
#> SRR949079     1   0.000      0.981 1.000 0.000
#> SRR949080     1   0.000      0.981 1.000 0.000
#> SRR949081     2   0.000      0.975 0.000 1.000
#> SRR949082     2   0.000      0.975 0.000 1.000
#> SRR949083     2   0.118      0.962 0.016 0.984
#> SRR949084     1   0.000      0.981 1.000 0.000
#> SRR949085     2   0.000      0.975 0.000 1.000
#> SRR949087     1   0.760      0.716 0.780 0.220
#> SRR949088     1   0.760      0.716 0.780 0.220
#> SRR949086     1   0.141      0.973 0.980 0.020
#> SRR949089     2   0.000      0.975 0.000 1.000
#> SRR949090     1   0.000      0.981 1.000 0.000
#> SRR949092     1   0.000      0.981 1.000 0.000
#> SRR949093     1   0.000      0.981 1.000 0.000
#> SRR949091     1   0.118      0.975 0.984 0.016
#> SRR949095     2   0.141      0.960 0.020 0.980
#> SRR949094     1   0.000      0.981 1.000 0.000
#> SRR949096     1   0.000      0.981 1.000 0.000
#> SRR949097     1   0.000      0.981 1.000 0.000
#> SRR949098     2   0.000      0.975 0.000 1.000
#> SRR949099     1   0.000      0.981 1.000 0.000
#> SRR949101     2   0.000      0.975 0.000 1.000
#> SRR949100     1   0.000      0.981 1.000 0.000
#> SRR949102     2   0.000      0.975 0.000 1.000
#> SRR949103     1   0.000      0.981 1.000 0.000
#> SRR949104     2   0.000      0.975 0.000 1.000
#> SRR949105     1   0.118      0.975 0.984 0.016
#> SRR949106     1   0.118      0.975 0.984 0.016
#> SRR949107     1   0.118      0.975 0.984 0.016
#> SRR949108     1   0.000      0.981 1.000 0.000
#> SRR949109     1   0.000      0.981 1.000 0.000
#> SRR949110     1   0.000      0.981 1.000 0.000
#> SRR949111     1   0.000      0.981 1.000 0.000
#> SRR949112     1   0.000      0.981 1.000 0.000
#> SRR949113     2   0.000      0.975 0.000 1.000
#> SRR949114     1   0.118      0.975 0.984 0.016
#> SRR949115     1   0.118      0.975 0.984 0.016
#> SRR949116     1   0.118      0.975 0.984 0.016
#> SRR949117     1   0.118      0.975 0.984 0.016
#> SRR949118     1   0.118      0.975 0.984 0.016
#> SRR949119     1   0.000      0.981 1.000 0.000
#> SRR949120     1   0.000      0.981 1.000 0.000
#> SRR949121     1   0.000      0.981 1.000 0.000
#> SRR949122     1   0.000      0.981 1.000 0.000
#> SRR949123     2   0.000      0.975 0.000 1.000
#> SRR949124     2   0.000      0.975 0.000 1.000
#> SRR949125     1   0.000      0.981 1.000 0.000
#> SRR949126     1   0.000      0.981 1.000 0.000
#> SRR949127     2   0.000      0.975 0.000 1.000
#> SRR949128     2   0.000      0.975 0.000 1.000
#> SRR949129     2   0.000      0.975 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR949076     2   0.701      0.739 0.064 0.696 0.240
#> SRR949078     2   0.186      0.866 0.000 0.948 0.052
#> SRR949077     1   0.891      0.309 0.556 0.164 0.280
#> SRR949079     1   0.000      0.739 1.000 0.000 0.000
#> SRR949080     1   0.000      0.739 1.000 0.000 0.000
#> SRR949081     2   0.537      0.802 0.016 0.776 0.208
#> SRR949082     2   0.186      0.866 0.000 0.948 0.052
#> SRR949083     2   0.924      0.562 0.224 0.532 0.244
#> SRR949084     1   0.585      0.562 0.776 0.044 0.180
#> SRR949085     2   0.164      0.857 0.000 0.956 0.044
#> SRR949087     1   0.930      0.224 0.496 0.180 0.324
#> SRR949088     1   0.930      0.224 0.496 0.180 0.324
#> SRR949086     3   0.343      0.666 0.112 0.004 0.884
#> SRR949089     2   0.164      0.857 0.000 0.956 0.044
#> SRR949090     1   0.484      0.646 0.776 0.000 0.224
#> SRR949092     1   0.103      0.732 0.976 0.000 0.024
#> SRR949093     1   0.103      0.732 0.976 0.000 0.024
#> SRR949091     3   0.522      0.847 0.260 0.000 0.740
#> SRR949095     2   0.962      0.471 0.280 0.472 0.248
#> SRR949094     1   0.141      0.734 0.964 0.000 0.036
#> SRR949096     1   0.337      0.683 0.904 0.024 0.072
#> SRR949097     1   0.484      0.646 0.776 0.000 0.224
#> SRR949098     2   0.164      0.857 0.000 0.956 0.044
#> SRR949099     1   0.484      0.646 0.776 0.000 0.224
#> SRR949101     3   0.440      0.387 0.000 0.188 0.812
#> SRR949100     1   0.445      0.667 0.808 0.000 0.192
#> SRR949102     2   0.465      0.810 0.000 0.792 0.208
#> SRR949103     1   0.484      0.646 0.776 0.000 0.224
#> SRR949104     2   0.164      0.857 0.000 0.956 0.044
#> SRR949105     3   0.525      0.846 0.264 0.000 0.736
#> SRR949106     3   0.525      0.846 0.264 0.000 0.736
#> SRR949107     3   0.525      0.846 0.264 0.000 0.736
#> SRR949108     1   0.186      0.730 0.948 0.000 0.052
#> SRR949109     1   0.484      0.646 0.776 0.000 0.224
#> SRR949110     1   0.484      0.646 0.776 0.000 0.224
#> SRR949111     1   0.484      0.646 0.776 0.000 0.224
#> SRR949112     1   0.355      0.653 0.868 0.000 0.132
#> SRR949113     2   0.000      0.863 0.000 1.000 0.000
#> SRR949114     3   0.525      0.846 0.264 0.000 0.736
#> SRR949115     3   0.522      0.847 0.260 0.000 0.740
#> SRR949116     3   0.522      0.847 0.260 0.000 0.740
#> SRR949117     3   0.429      0.761 0.180 0.000 0.820
#> SRR949118     3   0.400      0.796 0.160 0.000 0.840
#> SRR949119     1   0.000      0.739 1.000 0.000 0.000
#> SRR949120     1   0.000      0.739 1.000 0.000 0.000
#> SRR949121     1   0.164      0.725 0.956 0.000 0.044
#> SRR949122     1   0.175      0.723 0.952 0.000 0.048
#> SRR949123     2   0.164      0.857 0.000 0.956 0.044
#> SRR949124     2   0.164      0.857 0.000 0.956 0.044
#> SRR949125     1   0.484      0.646 0.776 0.000 0.224
#> SRR949126     1   0.484      0.646 0.776 0.000 0.224
#> SRR949127     2   0.280      0.860 0.000 0.908 0.092
#> SRR949128     2   0.280      0.860 0.000 0.908 0.092
#> SRR949129     2   0.280      0.860 0.000 0.908 0.092

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR949076     4  0.2081      0.859 0.000 0.084 0.000 0.916
#> SRR949078     2  0.5708      0.436 0.000 0.556 0.028 0.416
#> SRR949077     4  0.1724      0.864 0.032 0.020 0.000 0.948
#> SRR949079     1  0.2760      0.832 0.872 0.000 0.000 0.128
#> SRR949080     1  0.2760      0.832 0.872 0.000 0.000 0.128
#> SRR949081     4  0.3444      0.732 0.000 0.184 0.000 0.816
#> SRR949082     2  0.5731      0.414 0.000 0.544 0.028 0.428
#> SRR949083     4  0.1677      0.878 0.012 0.040 0.000 0.948
#> SRR949084     1  0.5112      0.502 0.560 0.000 0.004 0.436
#> SRR949085     2  0.0000      0.757 0.000 1.000 0.000 0.000
#> SRR949087     4  0.3363      0.856 0.020 0.024 0.072 0.884
#> SRR949088     4  0.3363      0.856 0.020 0.024 0.072 0.884
#> SRR949086     3  0.2466      0.902 0.028 0.000 0.916 0.056
#> SRR949089     2  0.0000      0.757 0.000 1.000 0.000 0.000
#> SRR949090     1  0.1022      0.845 0.968 0.000 0.032 0.000
#> SRR949092     1  0.4584      0.723 0.696 0.000 0.004 0.300
#> SRR949093     1  0.4584      0.723 0.696 0.000 0.004 0.300
#> SRR949091     3  0.2480      0.940 0.088 0.000 0.904 0.008
#> SRR949095     4  0.1863      0.878 0.012 0.040 0.004 0.944
#> SRR949094     1  0.2011      0.841 0.920 0.000 0.000 0.080
#> SRR949096     1  0.4741      0.689 0.668 0.000 0.004 0.328
#> SRR949097     1  0.1022      0.845 0.968 0.000 0.032 0.000
#> SRR949098     2  0.0000      0.757 0.000 1.000 0.000 0.000
#> SRR949099     1  0.1022      0.845 0.968 0.000 0.032 0.000
#> SRR949101     3  0.4057      0.787 0.000 0.032 0.816 0.152
#> SRR949100     1  0.0657      0.845 0.984 0.000 0.012 0.004
#> SRR949102     4  0.3688      0.679 0.000 0.208 0.000 0.792
#> SRR949103     1  0.1022      0.845 0.968 0.000 0.032 0.000
#> SRR949104     2  0.1635      0.751 0.000 0.948 0.044 0.008
#> SRR949105     3  0.2610      0.941 0.088 0.000 0.900 0.012
#> SRR949106     3  0.2610      0.941 0.088 0.000 0.900 0.012
#> SRR949107     3  0.2610      0.941 0.088 0.000 0.900 0.012
#> SRR949108     1  0.0188      0.845 0.996 0.000 0.000 0.004
#> SRR949109     1  0.1022      0.845 0.968 0.000 0.032 0.000
#> SRR949110     1  0.1022      0.845 0.968 0.000 0.032 0.000
#> SRR949111     1  0.1022      0.845 0.968 0.000 0.032 0.000
#> SRR949112     1  0.5475      0.685 0.656 0.000 0.036 0.308
#> SRR949113     2  0.4713      0.708 0.000 0.776 0.052 0.172
#> SRR949114     3  0.2843      0.940 0.088 0.000 0.892 0.020
#> SRR949115     3  0.2843      0.940 0.088 0.000 0.892 0.020
#> SRR949116     3  0.2843      0.940 0.088 0.000 0.892 0.020
#> SRR949117     3  0.2385      0.905 0.028 0.000 0.920 0.052
#> SRR949118     3  0.2227      0.917 0.036 0.000 0.928 0.036
#> SRR949119     1  0.2944      0.831 0.868 0.000 0.004 0.128
#> SRR949120     1  0.2944      0.831 0.868 0.000 0.004 0.128
#> SRR949121     1  0.4584      0.723 0.696 0.000 0.004 0.300
#> SRR949122     1  0.4560      0.727 0.700 0.000 0.004 0.296
#> SRR949123     2  0.0000      0.757 0.000 1.000 0.000 0.000
#> SRR949124     2  0.0000      0.757 0.000 1.000 0.000 0.000
#> SRR949125     1  0.1022      0.845 0.968 0.000 0.032 0.000
#> SRR949126     1  0.1022      0.845 0.968 0.000 0.032 0.000
#> SRR949127     2  0.6412      0.586 0.000 0.592 0.088 0.320
#> SRR949128     2  0.6412      0.586 0.000 0.592 0.088 0.320
#> SRR949129     2  0.6412      0.586 0.000 0.592 0.088 0.320

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR949076     5   0.203      0.779 0.056 0.012 0.000 0.008 0.924
#> SRR949078     5   0.506      0.259 0.000 0.360 0.000 0.044 0.596
#> SRR949077     5   0.208      0.778 0.084 0.000 0.000 0.008 0.908
#> SRR949079     1   0.297      0.632 0.816 0.000 0.000 0.184 0.000
#> SRR949080     1   0.297      0.632 0.816 0.000 0.000 0.184 0.000
#> SRR949081     5   0.175      0.770 0.028 0.036 0.000 0.000 0.936
#> SRR949082     5   0.497      0.311 0.000 0.336 0.000 0.044 0.620
#> SRR949083     5   0.199      0.780 0.076 0.004 0.000 0.004 0.916
#> SRR949084     1   0.219      0.731 0.900 0.000 0.000 0.008 0.092
#> SRR949085     2   0.029      0.766 0.000 0.992 0.000 0.000 0.008
#> SRR949087     5   0.617      0.603 0.252 0.000 0.016 0.136 0.596
#> SRR949088     5   0.617      0.603 0.252 0.000 0.016 0.136 0.596
#> SRR949086     3   0.245      0.904 0.000 0.000 0.896 0.076 0.028
#> SRR949089     2   0.029      0.766 0.000 0.992 0.000 0.000 0.008
#> SRR949090     4   0.445      0.992 0.340 0.000 0.016 0.644 0.000
#> SRR949092     1   0.127      0.768 0.948 0.000 0.000 0.000 0.052
#> SRR949093     1   0.127      0.768 0.948 0.000 0.000 0.000 0.052
#> SRR949091     3   0.163      0.918 0.000 0.000 0.936 0.056 0.008
#> SRR949095     5   0.312      0.771 0.100 0.004 0.000 0.036 0.860
#> SRR949094     1   0.340      0.526 0.764 0.000 0.000 0.236 0.000
#> SRR949096     1   0.147      0.767 0.948 0.000 0.000 0.016 0.036
#> SRR949097     4   0.448      0.991 0.348 0.000 0.016 0.636 0.000
#> SRR949098     2   0.029      0.766 0.000 0.992 0.000 0.000 0.008
#> SRR949099     4   0.448      0.991 0.348 0.000 0.016 0.636 0.000
#> SRR949101     3   0.417      0.772 0.000 0.000 0.764 0.052 0.184
#> SRR949100     1   0.431     -0.670 0.504 0.000 0.000 0.496 0.000
#> SRR949102     5   0.199      0.759 0.016 0.048 0.000 0.008 0.928
#> SRR949103     4   0.448      0.991 0.348 0.000 0.016 0.636 0.000
#> SRR949104     2   0.273      0.740 0.000 0.868 0.000 0.116 0.016
#> SRR949105     3   0.214      0.910 0.000 0.000 0.916 0.052 0.032
#> SRR949106     3   0.214      0.910 0.000 0.000 0.916 0.052 0.032
#> SRR949107     3   0.214      0.910 0.000 0.000 0.916 0.052 0.032
#> SRR949108     1   0.307      0.598 0.804 0.000 0.000 0.196 0.000
#> SRR949109     4   0.445      0.992 0.340 0.000 0.016 0.644 0.000
#> SRR949110     4   0.448      0.991 0.348 0.000 0.016 0.636 0.000
#> SRR949111     4   0.445      0.992 0.340 0.000 0.016 0.644 0.000
#> SRR949112     1   0.249      0.736 0.904 0.000 0.008 0.032 0.056
#> SRR949113     2   0.537      0.639 0.000 0.668 0.000 0.184 0.148
#> SRR949114     3   0.188      0.917 0.008 0.000 0.932 0.048 0.012
#> SRR949115     3   0.188      0.917 0.008 0.000 0.932 0.048 0.012
#> SRR949116     3   0.188      0.917 0.008 0.000 0.932 0.048 0.012
#> SRR949117     3   0.233      0.907 0.004 0.000 0.904 0.076 0.016
#> SRR949118     3   0.160      0.916 0.000 0.000 0.940 0.048 0.012
#> SRR949119     1   0.207      0.716 0.896 0.000 0.000 0.104 0.000
#> SRR949120     1   0.207      0.716 0.896 0.000 0.000 0.104 0.000
#> SRR949121     1   0.156      0.765 0.940 0.000 0.000 0.008 0.052
#> SRR949122     1   0.156      0.765 0.940 0.000 0.000 0.008 0.052
#> SRR949123     2   0.029      0.766 0.000 0.992 0.000 0.000 0.008
#> SRR949124     2   0.029      0.766 0.000 0.992 0.000 0.000 0.008
#> SRR949125     4   0.445      0.992 0.340 0.000 0.016 0.644 0.000
#> SRR949126     4   0.445      0.992 0.340 0.000 0.016 0.644 0.000
#> SRR949127     2   0.725      0.470 0.020 0.484 0.012 0.220 0.264
#> SRR949128     2   0.725      0.470 0.020 0.484 0.012 0.220 0.264
#> SRR949129     2   0.725      0.470 0.020 0.484 0.012 0.220 0.264

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR949076     5  0.2307      0.720 0.028 0.004 0.000 0.016 0.908 0.044
#> SRR949078     5  0.4602      0.406 0.000 0.260 0.000 0.004 0.668 0.068
#> SRR949077     5  0.1777      0.725 0.044 0.000 0.000 0.004 0.928 0.024
#> SRR949079     1  0.4641      0.668 0.684 0.000 0.000 0.200 0.000 0.116
#> SRR949080     1  0.4641      0.668 0.684 0.000 0.000 0.200 0.000 0.116
#> SRR949081     5  0.1180      0.722 0.016 0.012 0.000 0.000 0.960 0.012
#> SRR949082     5  0.4393      0.455 0.000 0.224 0.000 0.004 0.704 0.068
#> SRR949083     5  0.1265      0.726 0.044 0.000 0.000 0.000 0.948 0.008
#> SRR949084     1  0.1625      0.799 0.928 0.000 0.000 0.000 0.060 0.012
#> SRR949085     2  0.0260      0.781 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR949087     5  0.6464      0.229 0.272 0.000 0.004 0.012 0.404 0.308
#> SRR949088     5  0.6464      0.229 0.272 0.000 0.004 0.012 0.404 0.308
#> SRR949086     3  0.1442      0.838 0.004 0.000 0.944 0.012 0.000 0.040
#> SRR949089     2  0.0260      0.781 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR949090     4  0.2178      0.932 0.132 0.000 0.000 0.868 0.000 0.000
#> SRR949092     1  0.1364      0.833 0.952 0.000 0.000 0.016 0.020 0.012
#> SRR949093     1  0.1364      0.833 0.952 0.000 0.000 0.016 0.020 0.012
#> SRR949091     3  0.0146      0.851 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR949095     5  0.3013      0.691 0.068 0.000 0.000 0.000 0.844 0.088
#> SRR949094     1  0.5011      0.555 0.620 0.000 0.000 0.264 0.000 0.116
#> SRR949096     1  0.1462      0.827 0.936 0.000 0.000 0.008 0.000 0.056
#> SRR949097     4  0.3062      0.933 0.144 0.000 0.000 0.824 0.000 0.032
#> SRR949098     2  0.0260      0.781 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR949099     4  0.3062      0.933 0.144 0.000 0.000 0.824 0.000 0.032
#> SRR949101     3  0.3582      0.727 0.000 0.004 0.816 0.016 0.124 0.040
#> SRR949100     4  0.4315      0.686 0.328 0.000 0.000 0.636 0.000 0.036
#> SRR949102     5  0.2465      0.710 0.012 0.016 0.000 0.016 0.900 0.056
#> SRR949103     4  0.3062      0.933 0.144 0.000 0.000 0.824 0.000 0.032
#> SRR949104     2  0.3910      0.132 0.000 0.660 0.000 0.004 0.008 0.328
#> SRR949105     3  0.4499      0.833 0.000 0.004 0.712 0.076 0.004 0.204
#> SRR949106     3  0.4499      0.833 0.000 0.004 0.712 0.076 0.004 0.204
#> SRR949107     3  0.4499      0.833 0.000 0.004 0.712 0.076 0.004 0.204
#> SRR949108     1  0.3261      0.719 0.780 0.000 0.000 0.204 0.000 0.016
#> SRR949109     4  0.2178      0.932 0.132 0.000 0.000 0.868 0.000 0.000
#> SRR949110     4  0.3062      0.933 0.144 0.000 0.000 0.824 0.000 0.032
#> SRR949111     4  0.2431      0.930 0.132 0.000 0.000 0.860 0.000 0.008
#> SRR949112     1  0.2330      0.812 0.908 0.000 0.004 0.024 0.024 0.040
#> SRR949113     2  0.5197     -0.602 0.000 0.484 0.000 0.004 0.076 0.436
#> SRR949114     3  0.4304      0.855 0.004 0.000 0.772 0.092 0.024 0.108
#> SRR949115     3  0.4304      0.855 0.004 0.000 0.772 0.092 0.024 0.108
#> SRR949116     3  0.4304      0.855 0.004 0.000 0.772 0.092 0.024 0.108
#> SRR949117     3  0.1442      0.838 0.004 0.000 0.944 0.012 0.000 0.040
#> SRR949118     3  0.0260      0.849 0.000 0.000 0.992 0.000 0.000 0.008
#> SRR949119     1  0.2786      0.811 0.860 0.000 0.000 0.084 0.000 0.056
#> SRR949120     1  0.2786      0.811 0.860 0.000 0.000 0.084 0.000 0.056
#> SRR949121     1  0.1546      0.830 0.944 0.000 0.000 0.016 0.020 0.020
#> SRR949122     1  0.1787      0.826 0.932 0.000 0.000 0.016 0.020 0.032
#> SRR949123     2  0.0260      0.781 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR949124     2  0.0260      0.781 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR949125     4  0.3551      0.893 0.148 0.000 0.000 0.792 0.000 0.060
#> SRR949126     4  0.3551      0.893 0.148 0.000 0.000 0.792 0.000 0.060
#> SRR949127     6  0.5663      1.000 0.008 0.332 0.000 0.000 0.136 0.524
#> SRR949128     6  0.5663      1.000 0.008 0.332 0.000 0.000 0.136 0.524
#> SRR949129     6  0.5663      1.000 0.008 0.332 0.000 0.000 0.136 0.524

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

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

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

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.963       0.986         0.4968 0.508   0.508
#> 3 3 1.000           0.989       0.994         0.3105 0.815   0.644
#> 4 4 0.856           0.874       0.928         0.1185 0.912   0.751
#> 5 5 0.843           0.889       0.883         0.0948 0.877   0.577
#> 6 6 0.847           0.790       0.861         0.0363 0.977   0.881

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR949076     2   0.000     1.0000 0.000 1.000
#> SRR949078     2   0.000     1.0000 0.000 1.000
#> SRR949077     2   0.000     1.0000 0.000 1.000
#> SRR949079     1   0.000     0.9756 1.000 0.000
#> SRR949080     1   0.000     0.9756 1.000 0.000
#> SRR949081     2   0.000     1.0000 0.000 1.000
#> SRR949082     2   0.000     1.0000 0.000 1.000
#> SRR949083     2   0.000     1.0000 0.000 1.000
#> SRR949084     1   0.000     0.9756 1.000 0.000
#> SRR949085     2   0.000     1.0000 0.000 1.000
#> SRR949087     2   0.000     1.0000 0.000 1.000
#> SRR949088     2   0.000     1.0000 0.000 1.000
#> SRR949086     2   0.000     1.0000 0.000 1.000
#> SRR949089     2   0.000     1.0000 0.000 1.000
#> SRR949090     1   0.000     0.9756 1.000 0.000
#> SRR949092     1   0.000     0.9756 1.000 0.000
#> SRR949093     1   0.000     0.9756 1.000 0.000
#> SRR949091     1   0.000     0.9756 1.000 0.000
#> SRR949095     2   0.000     1.0000 0.000 1.000
#> SRR949094     1   0.000     0.9756 1.000 0.000
#> SRR949096     1   0.000     0.9756 1.000 0.000
#> SRR949097     1   0.000     0.9756 1.000 0.000
#> SRR949098     2   0.000     1.0000 0.000 1.000
#> SRR949099     1   0.000     0.9756 1.000 0.000
#> SRR949101     2   0.000     1.0000 0.000 1.000
#> SRR949100     1   0.000     0.9756 1.000 0.000
#> SRR949102     2   0.000     1.0000 0.000 1.000
#> SRR949103     1   0.000     0.9756 1.000 0.000
#> SRR949104     2   0.000     1.0000 0.000 1.000
#> SRR949105     1   0.000     0.9756 1.000 0.000
#> SRR949106     1   0.000     0.9756 1.000 0.000
#> SRR949107     1   0.000     0.9756 1.000 0.000
#> SRR949108     1   0.000     0.9756 1.000 0.000
#> SRR949109     1   0.000     0.9756 1.000 0.000
#> SRR949110     1   0.000     0.9756 1.000 0.000
#> SRR949111     1   0.000     0.9756 1.000 0.000
#> SRR949112     1   0.000     0.9756 1.000 0.000
#> SRR949113     2   0.000     1.0000 0.000 1.000
#> SRR949114     1   0.000     0.9756 1.000 0.000
#> SRR949115     1   0.000     0.9756 1.000 0.000
#> SRR949116     1   0.000     0.9756 1.000 0.000
#> SRR949117     1   1.000     0.0718 0.512 0.488
#> SRR949118     1   0.827     0.6472 0.740 0.260
#> SRR949119     1   0.000     0.9756 1.000 0.000
#> SRR949120     1   0.000     0.9756 1.000 0.000
#> SRR949121     1   0.000     0.9756 1.000 0.000
#> SRR949122     1   0.000     0.9756 1.000 0.000
#> SRR949123     2   0.000     1.0000 0.000 1.000
#> SRR949124     2   0.000     1.0000 0.000 1.000
#> SRR949125     1   0.000     0.9756 1.000 0.000
#> SRR949126     1   0.000     0.9756 1.000 0.000
#> SRR949127     2   0.000     1.0000 0.000 1.000
#> SRR949128     2   0.000     1.0000 0.000 1.000
#> SRR949129     2   0.000     1.0000 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
#> SRR949076     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949078     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949077     2  0.0424      0.991 0.008 0.992 0.000
#> SRR949079     1  0.0000      0.996 1.000 0.000 0.000
#> SRR949080     1  0.0000      0.996 1.000 0.000 0.000
#> SRR949081     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949082     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949083     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949084     1  0.0000      0.996 1.000 0.000 0.000
#> SRR949085     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949087     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949088     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949086     3  0.0424      0.971 0.000 0.008 0.992
#> SRR949089     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949090     1  0.0424      0.995 0.992 0.000 0.008
#> SRR949092     1  0.0000      0.996 1.000 0.000 0.000
#> SRR949093     1  0.0000      0.996 1.000 0.000 0.000
#> SRR949091     3  0.0000      0.978 0.000 0.000 1.000
#> SRR949095     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949094     1  0.0000      0.996 1.000 0.000 0.000
#> SRR949096     1  0.0000      0.996 1.000 0.000 0.000
#> SRR949097     1  0.0424      0.995 0.992 0.000 0.008
#> SRR949098     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949099     1  0.0424      0.995 0.992 0.000 0.008
#> SRR949101     3  0.4654      0.739 0.000 0.208 0.792
#> SRR949100     1  0.0424      0.995 0.992 0.000 0.008
#> SRR949102     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949103     1  0.0424      0.995 0.992 0.000 0.008
#> SRR949104     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949105     3  0.0000      0.978 0.000 0.000 1.000
#> SRR949106     3  0.0000      0.978 0.000 0.000 1.000
#> SRR949107     3  0.0000      0.978 0.000 0.000 1.000
#> SRR949108     1  0.0000      0.996 1.000 0.000 0.000
#> SRR949109     1  0.0424      0.995 0.992 0.000 0.008
#> SRR949110     1  0.0424      0.995 0.992 0.000 0.008
#> SRR949111     1  0.0424      0.995 0.992 0.000 0.008
#> SRR949112     1  0.0000      0.996 1.000 0.000 0.000
#> SRR949113     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949114     3  0.0000      0.978 0.000 0.000 1.000
#> SRR949115     3  0.0000      0.978 0.000 0.000 1.000
#> SRR949116     3  0.0000      0.978 0.000 0.000 1.000
#> SRR949117     3  0.0000      0.978 0.000 0.000 1.000
#> SRR949118     3  0.0000      0.978 0.000 0.000 1.000
#> SRR949119     1  0.0000      0.996 1.000 0.000 0.000
#> SRR949120     1  0.0000      0.996 1.000 0.000 0.000
#> SRR949121     1  0.0000      0.996 1.000 0.000 0.000
#> SRR949122     1  0.0000      0.996 1.000 0.000 0.000
#> SRR949123     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949124     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949125     1  0.0424      0.995 0.992 0.000 0.008
#> SRR949126     1  0.0424      0.995 0.992 0.000 0.008
#> SRR949127     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949128     2  0.0000      1.000 0.000 1.000 0.000
#> SRR949129     2  0.0000      1.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2  p3    p4
#> SRR949076     4  0.2973      0.791 0.000 0.144 0.0 0.856
#> SRR949078     2  0.4679      0.335 0.000 0.648 0.0 0.352
#> SRR949077     4  0.0000      0.740 0.000 0.000 0.0 1.000
#> SRR949079     1  0.2814      0.923 0.868 0.000 0.0 0.132
#> SRR949080     1  0.2814      0.923 0.868 0.000 0.0 0.132
#> SRR949081     4  0.2973      0.791 0.000 0.144 0.0 0.856
#> SRR949082     2  0.4697      0.323 0.000 0.644 0.0 0.356
#> SRR949083     4  0.1940      0.794 0.000 0.076 0.0 0.924
#> SRR949084     4  0.4477      0.343 0.312 0.000 0.0 0.688
#> SRR949085     2  0.0336      0.912 0.000 0.992 0.0 0.008
#> SRR949087     4  0.4222      0.706 0.000 0.272 0.0 0.728
#> SRR949088     4  0.4222      0.706 0.000 0.272 0.0 0.728
#> SRR949086     3  0.0000      0.981 0.000 0.000 1.0 0.000
#> SRR949089     2  0.0336      0.912 0.000 0.992 0.0 0.008
#> SRR949090     1  0.0000      0.941 1.000 0.000 0.0 0.000
#> SRR949092     1  0.2921      0.920 0.860 0.000 0.0 0.140
#> SRR949093     1  0.2921      0.920 0.860 0.000 0.0 0.140
#> SRR949091     3  0.0000      0.981 0.000 0.000 1.0 0.000
#> SRR949095     4  0.1940      0.794 0.000 0.076 0.0 0.924
#> SRR949094     1  0.2814      0.923 0.868 0.000 0.0 0.132
#> SRR949096     1  0.2921      0.920 0.860 0.000 0.0 0.140
#> SRR949097     1  0.0000      0.941 1.000 0.000 0.0 0.000
#> SRR949098     2  0.0336      0.912 0.000 0.992 0.0 0.008
#> SRR949099     1  0.0000      0.941 1.000 0.000 0.0 0.000
#> SRR949101     3  0.4605      0.778 0.000 0.092 0.8 0.108
#> SRR949100     1  0.0000      0.941 1.000 0.000 0.0 0.000
#> SRR949102     4  0.4406      0.627 0.000 0.300 0.0 0.700
#> SRR949103     1  0.0000      0.941 1.000 0.000 0.0 0.000
#> SRR949104     2  0.0000      0.912 0.000 1.000 0.0 0.000
#> SRR949105     3  0.0000      0.981 0.000 0.000 1.0 0.000
#> SRR949106     3  0.0000      0.981 0.000 0.000 1.0 0.000
#> SRR949107     3  0.0000      0.981 0.000 0.000 1.0 0.000
#> SRR949108     1  0.1211      0.942 0.960 0.000 0.0 0.040
#> SRR949109     1  0.0000      0.941 1.000 0.000 0.0 0.000
#> SRR949110     1  0.0000      0.941 1.000 0.000 0.0 0.000
#> SRR949111     1  0.0000      0.941 1.000 0.000 0.0 0.000
#> SRR949112     1  0.1637      0.941 0.940 0.000 0.0 0.060
#> SRR949113     2  0.0000      0.912 0.000 1.000 0.0 0.000
#> SRR949114     3  0.0000      0.981 0.000 0.000 1.0 0.000
#> SRR949115     3  0.0000      0.981 0.000 0.000 1.0 0.000
#> SRR949116     3  0.0000      0.981 0.000 0.000 1.0 0.000
#> SRR949117     3  0.0000      0.981 0.000 0.000 1.0 0.000
#> SRR949118     3  0.0000      0.981 0.000 0.000 1.0 0.000
#> SRR949119     1  0.2921      0.920 0.860 0.000 0.0 0.140
#> SRR949120     1  0.2921      0.920 0.860 0.000 0.0 0.140
#> SRR949121     1  0.1940      0.938 0.924 0.000 0.0 0.076
#> SRR949122     1  0.1637      0.941 0.940 0.000 0.0 0.060
#> SRR949123     2  0.0336      0.912 0.000 0.992 0.0 0.008
#> SRR949124     2  0.0336      0.912 0.000 0.992 0.0 0.008
#> SRR949125     1  0.0000      0.941 1.000 0.000 0.0 0.000
#> SRR949126     1  0.0000      0.941 1.000 0.000 0.0 0.000
#> SRR949127     2  0.0000      0.912 0.000 1.000 0.0 0.000
#> SRR949128     2  0.0000      0.912 0.000 1.000 0.0 0.000
#> SRR949129     2  0.0000      0.912 0.000 1.000 0.0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR949076     5  0.0703      0.844 0.000 0.024 0.000 0.000 0.976
#> SRR949078     5  0.4273      0.384 0.000 0.448 0.000 0.000 0.552
#> SRR949077     5  0.0609      0.839 0.020 0.000 0.000 0.000 0.980
#> SRR949079     1  0.4262      0.631 0.560 0.000 0.000 0.440 0.000
#> SRR949080     1  0.4262      0.631 0.560 0.000 0.000 0.440 0.000
#> SRR949081     5  0.1270      0.842 0.000 0.052 0.000 0.000 0.948
#> SRR949082     5  0.4242      0.432 0.000 0.428 0.000 0.000 0.572
#> SRR949083     5  0.0693      0.842 0.012 0.008 0.000 0.000 0.980
#> SRR949084     1  0.3670      0.818 0.820 0.000 0.000 0.112 0.068
#> SRR949085     2  0.0510      0.975 0.000 0.984 0.000 0.000 0.016
#> SRR949087     5  0.4294      0.784 0.152 0.080 0.000 0.000 0.768
#> SRR949088     5  0.4294      0.784 0.152 0.080 0.000 0.000 0.768
#> SRR949086     3  0.1952      0.927 0.084 0.000 0.912 0.000 0.004
#> SRR949089     2  0.0510      0.975 0.000 0.984 0.000 0.000 0.016
#> SRR949090     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949092     1  0.2929      0.878 0.820 0.000 0.000 0.180 0.000
#> SRR949093     1  0.2929      0.878 0.820 0.000 0.000 0.180 0.000
#> SRR949091     3  0.0000      0.966 0.000 0.000 1.000 0.000 0.000
#> SRR949095     5  0.1106      0.843 0.024 0.012 0.000 0.000 0.964
#> SRR949094     1  0.4268      0.624 0.556 0.000 0.000 0.444 0.000
#> SRR949096     1  0.3048      0.876 0.820 0.000 0.000 0.176 0.004
#> SRR949097     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949098     2  0.0510      0.975 0.000 0.984 0.000 0.000 0.016
#> SRR949099     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949101     3  0.4203      0.790 0.016 0.132 0.796 0.000 0.056
#> SRR949100     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949102     5  0.2020      0.824 0.000 0.100 0.000 0.000 0.900
#> SRR949103     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949104     2  0.0000      0.974 0.000 1.000 0.000 0.000 0.000
#> SRR949105     3  0.0000      0.966 0.000 0.000 1.000 0.000 0.000
#> SRR949106     3  0.0000      0.966 0.000 0.000 1.000 0.000 0.000
#> SRR949107     3  0.0000      0.966 0.000 0.000 1.000 0.000 0.000
#> SRR949108     1  0.3857      0.811 0.688 0.000 0.000 0.312 0.000
#> SRR949109     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949110     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949111     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949112     1  0.3366      0.854 0.768 0.000 0.000 0.232 0.000
#> SRR949113     2  0.0000      0.974 0.000 1.000 0.000 0.000 0.000
#> SRR949114     3  0.0404      0.964 0.012 0.000 0.988 0.000 0.000
#> SRR949115     3  0.0404      0.964 0.012 0.000 0.988 0.000 0.000
#> SRR949116     3  0.0404      0.964 0.012 0.000 0.988 0.000 0.000
#> SRR949117     3  0.1357      0.948 0.048 0.000 0.948 0.000 0.004
#> SRR949118     3  0.0671      0.961 0.016 0.000 0.980 0.000 0.004
#> SRR949119     1  0.3003      0.880 0.812 0.000 0.000 0.188 0.000
#> SRR949120     1  0.3003      0.880 0.812 0.000 0.000 0.188 0.000
#> SRR949121     1  0.3039      0.878 0.808 0.000 0.000 0.192 0.000
#> SRR949122     1  0.3395      0.861 0.764 0.000 0.000 0.236 0.000
#> SRR949123     2  0.0510      0.975 0.000 0.984 0.000 0.000 0.016
#> SRR949124     2  0.0510      0.975 0.000 0.984 0.000 0.000 0.016
#> SRR949125     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949126     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949127     2  0.1211      0.955 0.024 0.960 0.000 0.000 0.016
#> SRR949128     2  0.1211      0.955 0.024 0.960 0.000 0.000 0.016
#> SRR949129     2  0.1211      0.955 0.024 0.960 0.000 0.000 0.016

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR949076     5  0.1686     0.6694 0.000 0.064 0.000 0.000 0.924 0.012
#> SRR949078     2  0.3862    -0.1859 0.000 0.524 0.000 0.000 0.476 0.000
#> SRR949077     5  0.0622     0.6833 0.008 0.000 0.000 0.000 0.980 0.012
#> SRR949079     1  0.3695     0.6551 0.712 0.000 0.000 0.272 0.000 0.016
#> SRR949080     1  0.3695     0.6551 0.712 0.000 0.000 0.272 0.000 0.016
#> SRR949081     5  0.0632     0.6847 0.000 0.024 0.000 0.000 0.976 0.000
#> SRR949082     5  0.3869    -0.0125 0.000 0.500 0.000 0.000 0.500 0.000
#> SRR949083     5  0.0260     0.6813 0.008 0.000 0.000 0.000 0.992 0.000
#> SRR949084     1  0.1151     0.7434 0.956 0.000 0.000 0.012 0.032 0.000
#> SRR949085     2  0.0363     0.8518 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR949087     6  0.4902     1.0000 0.000 0.060 0.000 0.000 0.460 0.480
#> SRR949088     6  0.4902     1.0000 0.000 0.060 0.000 0.000 0.460 0.480
#> SRR949086     3  0.3602     0.8027 0.032 0.000 0.760 0.000 0.000 0.208
#> SRR949089     2  0.0363     0.8518 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR949090     4  0.0146     0.9941 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR949092     1  0.3892     0.7545 0.740 0.000 0.000 0.048 0.000 0.212
#> SRR949093     1  0.3892     0.7545 0.740 0.000 0.000 0.048 0.000 0.212
#> SRR949091     3  0.0937     0.8947 0.000 0.000 0.960 0.000 0.000 0.040
#> SRR949095     5  0.0717     0.6667 0.008 0.000 0.000 0.000 0.976 0.016
#> SRR949094     1  0.3674     0.6597 0.716 0.000 0.000 0.268 0.000 0.016
#> SRR949096     1  0.1152     0.7648 0.952 0.000 0.000 0.044 0.004 0.000
#> SRR949097     4  0.0000     0.9960 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949098     2  0.0363     0.8518 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR949099     4  0.0000     0.9960 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949101     3  0.5216     0.7247 0.028 0.136 0.708 0.000 0.020 0.108
#> SRR949100     4  0.0000     0.9960 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949102     5  0.2572     0.5918 0.000 0.136 0.000 0.000 0.852 0.012
#> SRR949103     4  0.0000     0.9960 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949104     2  0.1471     0.8402 0.004 0.932 0.000 0.000 0.000 0.064
#> SRR949105     3  0.0146     0.8978 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR949106     3  0.0146     0.8978 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR949107     3  0.0146     0.8978 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR949108     1  0.5521     0.5208 0.488 0.000 0.000 0.376 0.000 0.136
#> SRR949109     4  0.0000     0.9960 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949110     4  0.0000     0.9960 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949111     4  0.0000     0.9960 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949112     1  0.5143     0.7063 0.612 0.000 0.000 0.140 0.000 0.248
#> SRR949113     2  0.1471     0.8402 0.004 0.932 0.000 0.000 0.000 0.064
#> SRR949114     3  0.1753     0.8749 0.004 0.000 0.912 0.000 0.000 0.084
#> SRR949115     3  0.1753     0.8749 0.004 0.000 0.912 0.000 0.000 0.084
#> SRR949116     3  0.1753     0.8749 0.004 0.000 0.912 0.000 0.000 0.084
#> SRR949117     3  0.2983     0.8517 0.032 0.000 0.832 0.000 0.000 0.136
#> SRR949118     3  0.2633     0.8656 0.032 0.000 0.864 0.000 0.000 0.104
#> SRR949119     1  0.1444     0.7717 0.928 0.000 0.000 0.072 0.000 0.000
#> SRR949120     1  0.1444     0.7717 0.928 0.000 0.000 0.072 0.000 0.000
#> SRR949121     1  0.4167     0.7452 0.708 0.000 0.000 0.056 0.000 0.236
#> SRR949122     1  0.5146     0.7078 0.616 0.000 0.000 0.148 0.000 0.236
#> SRR949123     2  0.0363     0.8518 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR949124     2  0.0363     0.8518 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR949125     4  0.0458     0.9863 0.000 0.000 0.000 0.984 0.000 0.016
#> SRR949126     4  0.0458     0.9863 0.000 0.000 0.000 0.984 0.000 0.016
#> SRR949127     2  0.2902     0.7770 0.004 0.800 0.000 0.000 0.000 0.196
#> SRR949128     2  0.2902     0.7770 0.004 0.800 0.000 0.000 0.000 0.196
#> SRR949129     2  0.2902     0.7770 0.004 0.800 0.000 0.000 0.000 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-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

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

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

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.779           0.826       0.937         0.3633 0.628   0.628
#> 3 3 0.456           0.523       0.753         0.7496 0.686   0.507
#> 4 4 0.766           0.848       0.873         0.0755 0.695   0.385
#> 5 5 0.824           0.798       0.916         0.1509 0.817   0.510
#> 6 6 0.859           0.793       0.911         0.0214 0.958   0.814

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

suggest_best_k(res)
#> [1] 5

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
#> SRR949076     1  0.9661     0.2064 0.608 0.392
#> SRR949078     2  0.0000     0.8387 0.000 1.000
#> SRR949077     1  0.0000     0.9485 1.000 0.000
#> SRR949079     1  0.0000     0.9485 1.000 0.000
#> SRR949080     1  0.0000     0.9485 1.000 0.000
#> SRR949081     2  0.8955     0.5479 0.312 0.688
#> SRR949082     2  0.0000     0.8387 0.000 1.000
#> SRR949083     1  0.8555     0.5184 0.720 0.280
#> SRR949084     1  0.0000     0.9485 1.000 0.000
#> SRR949085     2  0.0000     0.8387 0.000 1.000
#> SRR949087     1  0.1184     0.9343 0.984 0.016
#> SRR949088     1  0.1414     0.9304 0.980 0.020
#> SRR949086     1  0.0000     0.9485 1.000 0.000
#> SRR949089     2  0.0000     0.8387 0.000 1.000
#> SRR949090     1  0.0000     0.9485 1.000 0.000
#> SRR949092     1  0.0000     0.9485 1.000 0.000
#> SRR949093     1  0.0000     0.9485 1.000 0.000
#> SRR949091     1  0.0000     0.9485 1.000 0.000
#> SRR949095     1  0.4690     0.8335 0.900 0.100
#> SRR949094     1  0.0000     0.9485 1.000 0.000
#> SRR949096     1  0.0000     0.9485 1.000 0.000
#> SRR949097     1  0.0000     0.9485 1.000 0.000
#> SRR949098     2  0.0000     0.8387 0.000 1.000
#> SRR949099     1  0.0000     0.9485 1.000 0.000
#> SRR949101     1  0.9850     0.0816 0.572 0.428
#> SRR949100     1  0.0938     0.9382 0.988 0.012
#> SRR949102     1  0.9850     0.0816 0.572 0.428
#> SRR949103     1  0.0000     0.9485 1.000 0.000
#> SRR949104     2  0.0000     0.8387 0.000 1.000
#> SRR949105     1  0.0000     0.9485 1.000 0.000
#> SRR949106     1  0.0000     0.9485 1.000 0.000
#> SRR949107     1  0.0000     0.9485 1.000 0.000
#> SRR949108     1  0.0000     0.9485 1.000 0.000
#> SRR949109     1  0.0000     0.9485 1.000 0.000
#> SRR949110     1  0.0000     0.9485 1.000 0.000
#> SRR949111     1  0.0000     0.9485 1.000 0.000
#> SRR949112     1  0.0000     0.9485 1.000 0.000
#> SRR949113     2  0.0000     0.8387 0.000 1.000
#> SRR949114     1  0.0000     0.9485 1.000 0.000
#> SRR949115     1  0.0000     0.9485 1.000 0.000
#> SRR949116     1  0.0000     0.9485 1.000 0.000
#> SRR949117     1  0.0000     0.9485 1.000 0.000
#> SRR949118     1  0.0000     0.9485 1.000 0.000
#> SRR949119     1  0.0000     0.9485 1.000 0.000
#> SRR949120     1  0.0000     0.9485 1.000 0.000
#> SRR949121     1  0.0000     0.9485 1.000 0.000
#> SRR949122     1  0.0000     0.9485 1.000 0.000
#> SRR949123     2  0.0000     0.8387 0.000 1.000
#> SRR949124     2  0.0000     0.8387 0.000 1.000
#> SRR949125     1  0.0000     0.9485 1.000 0.000
#> SRR949126     1  0.0000     0.9485 1.000 0.000
#> SRR949127     2  0.9977     0.2237 0.472 0.528
#> SRR949128     2  0.9977     0.2237 0.472 0.528
#> SRR949129     2  0.9977     0.2237 0.472 0.528

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR949076     1   0.304     0.6339 0.896 0.104 0.000
#> SRR949078     2   0.000     0.8522 0.000 1.000 0.000
#> SRR949077     1   0.000     0.7033 1.000 0.000 0.000
#> SRR949079     3   0.630     0.5546 0.472 0.000 0.528
#> SRR949080     3   0.630     0.5546 0.472 0.000 0.528
#> SRR949081     2   0.348     0.8029 0.128 0.872 0.000
#> SRR949082     2   0.327     0.8094 0.116 0.884 0.000
#> SRR949083     1   0.304     0.6339 0.896 0.104 0.000
#> SRR949084     1   0.000     0.7033 1.000 0.000 0.000
#> SRR949085     2   0.000     0.8522 0.000 1.000 0.000
#> SRR949087     1   0.429     0.5870 0.820 0.180 0.000
#> SRR949088     1   0.470     0.5575 0.788 0.212 0.000
#> SRR949086     1   0.625     0.2924 0.556 0.000 0.444
#> SRR949089     2   0.000     0.8522 0.000 1.000 0.000
#> SRR949090     3   0.630     0.5546 0.472 0.000 0.528
#> SRR949092     1   0.000     0.7033 1.000 0.000 0.000
#> SRR949093     1   0.000     0.7033 1.000 0.000 0.000
#> SRR949091     3   0.510     0.0803 0.248 0.000 0.752
#> SRR949095     1   0.000     0.7033 1.000 0.000 0.000
#> SRR949094     3   0.630     0.5546 0.472 0.000 0.528
#> SRR949096     1   0.000     0.7033 1.000 0.000 0.000
#> SRR949097     3   0.630     0.5546 0.472 0.000 0.528
#> SRR949098     2   0.000     0.8522 0.000 1.000 0.000
#> SRR949099     3   0.630     0.5546 0.472 0.000 0.528
#> SRR949101     1   0.630     0.2685 0.528 0.000 0.472
#> SRR949100     1   0.757     0.4523 0.684 0.200 0.116
#> SRR949102     2   0.576     0.6147 0.328 0.672 0.000
#> SRR949103     3   0.630     0.5546 0.472 0.000 0.528
#> SRR949104     2   0.000     0.8522 0.000 1.000 0.000
#> SRR949105     3   0.000     0.2868 0.000 0.000 1.000
#> SRR949106     3   0.455     0.1445 0.200 0.000 0.800
#> SRR949107     3   0.406     0.1791 0.164 0.000 0.836
#> SRR949108     3   0.630     0.5429 0.480 0.000 0.520
#> SRR949109     3   0.630     0.5546 0.472 0.000 0.528
#> SRR949110     3   0.630     0.5546 0.472 0.000 0.528
#> SRR949111     3   0.630     0.5546 0.472 0.000 0.528
#> SRR949112     1   0.000     0.7033 1.000 0.000 0.000
#> SRR949113     2   0.000     0.8522 0.000 1.000 0.000
#> SRR949114     3   0.615    -0.1524 0.408 0.000 0.592
#> SRR949115     3   0.615    -0.1524 0.408 0.000 0.592
#> SRR949116     3   0.615    -0.1524 0.408 0.000 0.592
#> SRR949117     1   0.630     0.2685 0.528 0.000 0.472
#> SRR949118     3   0.617    -0.1593 0.412 0.000 0.588
#> SRR949119     1   0.604    -0.2884 0.620 0.000 0.380
#> SRR949120     3   0.631     0.5301 0.488 0.000 0.512
#> SRR949121     1   0.000     0.7033 1.000 0.000 0.000
#> SRR949122     1   0.000     0.7033 1.000 0.000 0.000
#> SRR949123     2   0.000     0.8522 0.000 1.000 0.000
#> SRR949124     2   0.000     0.8522 0.000 1.000 0.000
#> SRR949125     3   0.630     0.5546 0.472 0.000 0.528
#> SRR949126     3   0.630     0.5546 0.472 0.000 0.528
#> SRR949127     2   0.608     0.5237 0.388 0.612 0.000
#> SRR949128     2   0.610     0.5161 0.392 0.608 0.000
#> SRR949129     2   0.576     0.6147 0.328 0.672 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR949076     1  0.5327      0.760 0.720 0.220 0.000 0.060
#> SRR949078     2  0.3726      0.765 0.000 0.788 0.000 0.212
#> SRR949077     1  0.5486      0.819 0.720 0.080 0.000 0.200
#> SRR949079     1  0.0188      0.832 0.996 0.000 0.000 0.004
#> SRR949080     1  0.0188      0.832 0.996 0.000 0.000 0.004
#> SRR949081     2  0.2814      0.833 0.000 0.868 0.000 0.132
#> SRR949082     2  0.3356      0.814 0.000 0.824 0.000 0.176
#> SRR949083     1  0.5647      0.813 0.720 0.116 0.000 0.164
#> SRR949084     1  0.5486      0.819 0.720 0.080 0.000 0.200
#> SRR949085     4  0.3610      1.000 0.000 0.200 0.000 0.800
#> SRR949087     1  0.7535      0.500 0.464 0.336 0.000 0.200
#> SRR949088     1  0.7586      0.440 0.436 0.364 0.000 0.200
#> SRR949086     3  0.3374      0.867 0.028 0.080 0.880 0.012
#> SRR949089     4  0.3610      1.000 0.000 0.200 0.000 0.800
#> SRR949090     1  0.0000      0.832 1.000 0.000 0.000 0.000
#> SRR949092     1  0.5288      0.823 0.732 0.068 0.000 0.200
#> SRR949093     1  0.5356      0.822 0.728 0.072 0.000 0.200
#> SRR949091     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> SRR949095     1  0.5727      0.811 0.704 0.096 0.000 0.200
#> SRR949094     1  0.0000      0.832 1.000 0.000 0.000 0.000
#> SRR949096     1  0.5073      0.826 0.744 0.056 0.000 0.200
#> SRR949097     1  0.0000      0.832 1.000 0.000 0.000 0.000
#> SRR949098     4  0.3610      1.000 0.000 0.200 0.000 0.800
#> SRR949099     1  0.0000      0.832 1.000 0.000 0.000 0.000
#> SRR949101     3  0.2101      0.923 0.000 0.060 0.928 0.012
#> SRR949100     1  0.7346      0.606 0.520 0.280 0.000 0.200
#> SRR949102     2  0.2814      0.833 0.000 0.868 0.000 0.132
#> SRR949103     1  0.0000      0.832 1.000 0.000 0.000 0.000
#> SRR949104     2  0.2011      0.830 0.000 0.920 0.000 0.080
#> SRR949105     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> SRR949106     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> SRR949107     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> SRR949108     1  0.0000      0.832 1.000 0.000 0.000 0.000
#> SRR949109     1  0.0000      0.832 1.000 0.000 0.000 0.000
#> SRR949110     1  0.0000      0.832 1.000 0.000 0.000 0.000
#> SRR949111     1  0.0000      0.832 1.000 0.000 0.000 0.000
#> SRR949112     1  0.5486      0.819 0.720 0.080 0.000 0.200
#> SRR949113     2  0.2011      0.830 0.000 0.920 0.000 0.080
#> SRR949114     3  0.0469      0.961 0.000 0.000 0.988 0.012
#> SRR949115     3  0.0469      0.961 0.000 0.000 0.988 0.012
#> SRR949116     3  0.0469      0.961 0.000 0.000 0.988 0.012
#> SRR949117     3  0.2706      0.890 0.000 0.080 0.900 0.020
#> SRR949118     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> SRR949119     1  0.3486      0.833 0.812 0.000 0.000 0.188
#> SRR949120     1  0.3486      0.833 0.812 0.000 0.000 0.188
#> SRR949121     1  0.5486      0.819 0.720 0.080 0.000 0.200
#> SRR949122     1  0.5486      0.819 0.720 0.080 0.000 0.200
#> SRR949123     4  0.3610      1.000 0.000 0.200 0.000 0.800
#> SRR949124     4  0.3610      1.000 0.000 0.200 0.000 0.800
#> SRR949125     1  0.0000      0.832 1.000 0.000 0.000 0.000
#> SRR949126     1  0.0000      0.832 1.000 0.000 0.000 0.000
#> SRR949127     2  0.0000      0.853 0.000 1.000 0.000 0.000
#> SRR949128     2  0.0000      0.853 0.000 1.000 0.000 0.000
#> SRR949129     2  0.0000      0.853 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
#> SRR949076     1  0.0404     0.8623 0.988 0.00 0.000 0.000 0.012
#> SRR949078     5  0.2280     0.7891 0.000 0.12 0.000 0.000 0.880
#> SRR949077     1  0.0000     0.8704 1.000 0.00 0.000 0.000 0.000
#> SRR949079     1  0.4161     0.5036 0.608 0.00 0.000 0.392 0.000
#> SRR949080     1  0.4150     0.5101 0.612 0.00 0.000 0.388 0.000
#> SRR949081     5  0.2280     0.7891 0.000 0.12 0.000 0.000 0.880
#> SRR949082     5  0.2280     0.7891 0.000 0.12 0.000 0.000 0.880
#> SRR949083     1  0.0000     0.8704 1.000 0.00 0.000 0.000 0.000
#> SRR949084     1  0.0000     0.8704 1.000 0.00 0.000 0.000 0.000
#> SRR949085     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000
#> SRR949087     5  0.4305     0.0638 0.488 0.00 0.000 0.000 0.512
#> SRR949088     5  0.4297     0.1202 0.472 0.00 0.000 0.000 0.528
#> SRR949086     3  0.1544     0.8786 0.068 0.00 0.932 0.000 0.000
#> SRR949089     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000
#> SRR949090     4  0.0000     0.9003 0.000 0.00 0.000 1.000 0.000
#> SRR949092     1  0.0000     0.8704 1.000 0.00 0.000 0.000 0.000
#> SRR949093     1  0.0000     0.8704 1.000 0.00 0.000 0.000 0.000
#> SRR949091     3  0.0000     0.9253 0.000 0.00 1.000 0.000 0.000
#> SRR949095     1  0.2966     0.6809 0.816 0.00 0.000 0.000 0.184
#> SRR949094     1  0.4171     0.4966 0.604 0.00 0.000 0.396 0.000
#> SRR949096     1  0.0000     0.8704 1.000 0.00 0.000 0.000 0.000
#> SRR949097     4  0.0000     0.9003 0.000 0.00 0.000 1.000 0.000
#> SRR949098     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000
#> SRR949099     4  0.0000     0.9003 0.000 0.00 0.000 1.000 0.000
#> SRR949101     3  0.2280     0.8200 0.000 0.00 0.880 0.000 0.120
#> SRR949100     4  0.4171     0.3551 0.396 0.00 0.000 0.604 0.000
#> SRR949102     5  0.2280     0.7891 0.000 0.12 0.000 0.000 0.880
#> SRR949103     4  0.0000     0.9003 0.000 0.00 0.000 1.000 0.000
#> SRR949104     5  0.0000     0.8136 0.000 0.00 0.000 0.000 1.000
#> SRR949105     3  0.0000     0.9253 0.000 0.00 1.000 0.000 0.000
#> SRR949106     3  0.0000     0.9253 0.000 0.00 1.000 0.000 0.000
#> SRR949107     3  0.0000     0.9253 0.000 0.00 1.000 0.000 0.000
#> SRR949108     1  0.4126     0.5219 0.620 0.00 0.000 0.380 0.000
#> SRR949109     4  0.0000     0.9003 0.000 0.00 0.000 1.000 0.000
#> SRR949110     4  0.0000     0.9003 0.000 0.00 0.000 1.000 0.000
#> SRR949111     4  0.0000     0.9003 0.000 0.00 0.000 1.000 0.000
#> SRR949112     1  0.0000     0.8704 1.000 0.00 0.000 0.000 0.000
#> SRR949113     5  0.0000     0.8136 0.000 0.00 0.000 0.000 1.000
#> SRR949114     4  0.4171     0.2385 0.000 0.00 0.396 0.604 0.000
#> SRR949115     3  0.3003     0.7719 0.000 0.00 0.812 0.188 0.000
#> SRR949116     3  0.2605     0.8214 0.000 0.00 0.852 0.148 0.000
#> SRR949117     3  0.0703     0.9146 0.024 0.00 0.976 0.000 0.000
#> SRR949118     3  0.0000     0.9253 0.000 0.00 1.000 0.000 0.000
#> SRR949119     1  0.0000     0.8704 1.000 0.00 0.000 0.000 0.000
#> SRR949120     1  0.0000     0.8704 1.000 0.00 0.000 0.000 0.000
#> SRR949121     1  0.0000     0.8704 1.000 0.00 0.000 0.000 0.000
#> SRR949122     1  0.0000     0.8704 1.000 0.00 0.000 0.000 0.000
#> SRR949123     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000
#> SRR949124     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000
#> SRR949125     4  0.0000     0.9003 0.000 0.00 0.000 1.000 0.000
#> SRR949126     4  0.0000     0.9003 0.000 0.00 0.000 1.000 0.000
#> SRR949127     5  0.0000     0.8136 0.000 0.00 0.000 0.000 1.000
#> SRR949128     5  0.0000     0.8136 0.000 0.00 0.000 0.000 1.000
#> SRR949129     5  0.0000     0.8136 0.000 0.00 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
#> SRR949076     1  0.0993    0.83101 0.964 0.00 0.000 0.000 0.012 0.024
#> SRR949078     5  0.2048    0.77694 0.000 0.12 0.000 0.000 0.880 0.000
#> SRR949077     1  0.0000    0.84732 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR949079     1  0.3747    0.48541 0.604 0.00 0.000 0.396 0.000 0.000
#> SRR949080     1  0.3737    0.49209 0.608 0.00 0.000 0.392 0.000 0.000
#> SRR949081     5  0.2662    0.77206 0.000 0.12 0.000 0.000 0.856 0.024
#> SRR949082     5  0.2048    0.77694 0.000 0.12 0.000 0.000 0.880 0.000
#> SRR949083     1  0.0632    0.83716 0.976 0.00 0.000 0.000 0.000 0.024
#> SRR949084     1  0.0000    0.84732 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR949085     2  0.0000    1.00000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR949087     5  0.4408    0.00473 0.488 0.00 0.000 0.000 0.488 0.024
#> SRR949088     5  0.4405    0.06534 0.472 0.00 0.000 0.000 0.504 0.024
#> SRR949086     1  0.4671    0.27814 0.532 0.00 0.044 0.000 0.000 0.424
#> SRR949089     2  0.0000    1.00000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR949090     4  0.0000    0.93979 0.000 0.00 0.000 1.000 0.000 0.000
#> SRR949092     1  0.0000    0.84732 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR949093     1  0.0000    0.84732 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR949091     3  0.1267    0.85084 0.000 0.00 0.940 0.000 0.000 0.060
#> SRR949095     1  0.3098    0.68433 0.812 0.00 0.000 0.000 0.164 0.024
#> SRR949094     1  0.3756    0.47832 0.600 0.00 0.000 0.400 0.000 0.000
#> SRR949096     1  0.0000    0.84732 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR949097     4  0.0000    0.93979 0.000 0.00 0.000 1.000 0.000 0.000
#> SRR949098     2  0.0000    1.00000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR949099     4  0.0000    0.93979 0.000 0.00 0.000 1.000 0.000 0.000
#> SRR949101     3  0.4066    0.37690 0.000 0.00 0.596 0.000 0.012 0.392
#> SRR949100     4  0.3756    0.33551 0.400 0.00 0.000 0.600 0.000 0.000
#> SRR949102     5  0.2662    0.77206 0.000 0.12 0.000 0.000 0.856 0.024
#> SRR949103     4  0.0000    0.93979 0.000 0.00 0.000 1.000 0.000 0.000
#> SRR949104     5  0.0000    0.80330 0.000 0.00 0.000 0.000 1.000 0.000
#> SRR949105     3  0.0000    0.87800 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR949106     3  0.0000    0.87800 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR949107     3  0.0000    0.87800 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR949108     1  0.3717    0.50452 0.616 0.00 0.000 0.384 0.000 0.000
#> SRR949109     4  0.0000    0.93979 0.000 0.00 0.000 1.000 0.000 0.000
#> SRR949110     4  0.0000    0.93979 0.000 0.00 0.000 1.000 0.000 0.000
#> SRR949111     4  0.0000    0.93979 0.000 0.00 0.000 1.000 0.000 0.000
#> SRR949112     1  0.0000    0.84732 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR949113     5  0.0000    0.80330 0.000 0.00 0.000 0.000 1.000 0.000
#> SRR949114     6  0.0632    0.99054 0.000 0.00 0.024 0.000 0.000 0.976
#> SRR949115     6  0.0632    0.99054 0.000 0.00 0.024 0.000 0.000 0.976
#> SRR949116     6  0.0632    0.99054 0.000 0.00 0.024 0.000 0.000 0.976
#> SRR949117     6  0.0000    0.96225 0.000 0.00 0.000 0.000 0.000 1.000
#> SRR949118     6  0.0632    0.99054 0.000 0.00 0.024 0.000 0.000 0.976
#> SRR949119     1  0.0000    0.84732 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR949120     1  0.0000    0.84732 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR949121     1  0.0000    0.84732 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR949122     1  0.0000    0.84732 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR949123     2  0.0000    1.00000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR949124     2  0.0000    1.00000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR949125     4  0.0000    0.93979 0.000 0.00 0.000 1.000 0.000 0.000
#> SRR949126     4  0.0000    0.93979 0.000 0.00 0.000 1.000 0.000 0.000
#> SRR949127     5  0.0000    0.80330 0.000 0.00 0.000 0.000 1.000 0.000
#> SRR949128     5  0.0000    0.80330 0.000 0.00 0.000 0.000 1.000 0.000
#> SRR949129     5  0.0000    0.80330 0.000 0.00 0.000 0.000 1.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-pam-collect-classes

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

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

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.923           0.910       0.944         0.2984 0.693   0.693
#> 3 3 0.780           0.811       0.906         1.0584 0.499   0.360
#> 4 4 0.623           0.705       0.805         0.1325 0.895   0.731
#> 5 5 0.744           0.667       0.840         0.1148 0.814   0.467
#> 6 6 0.876           0.841       0.929         0.0532 0.939   0.731

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
#> SRR949076     1  0.0000      0.952 1.000 0.000
#> SRR949078     1  0.2778      0.958 0.952 0.048
#> SRR949077     1  0.2778      0.958 0.952 0.048
#> SRR949079     2  0.0000      0.867 0.000 1.000
#> SRR949080     2  0.0000      0.867 0.000 1.000
#> SRR949081     1  0.2778      0.958 0.952 0.048
#> SRR949082     1  0.2778      0.958 0.952 0.048
#> SRR949083     1  0.2778      0.958 0.952 0.048
#> SRR949084     2  0.2236      0.856 0.036 0.964
#> SRR949085     1  0.0000      0.952 1.000 0.000
#> SRR949087     1  0.2778      0.958 0.952 0.048
#> SRR949088     1  0.2778      0.958 0.952 0.048
#> SRR949086     1  0.0000      0.952 1.000 0.000
#> SRR949089     1  0.0000      0.952 1.000 0.000
#> SRR949090     1  0.4022      0.944 0.920 0.080
#> SRR949092     2  0.0376      0.867 0.004 0.996
#> SRR949093     2  0.0376      0.867 0.004 0.996
#> SRR949091     1  0.0000      0.952 1.000 0.000
#> SRR949095     1  0.2948      0.956 0.948 0.052
#> SRR949094     1  0.6887      0.825 0.816 0.184
#> SRR949096     2  0.9608      0.419 0.384 0.616
#> SRR949097     1  0.4022      0.944 0.920 0.080
#> SRR949098     1  0.0000      0.952 1.000 0.000
#> SRR949099     1  0.4022      0.944 0.920 0.080
#> SRR949101     1  0.0000      0.952 1.000 0.000
#> SRR949100     1  0.3114      0.955 0.944 0.056
#> SRR949102     1  0.0000      0.952 1.000 0.000
#> SRR949103     1  0.4022      0.944 0.920 0.080
#> SRR949104     1  0.2778      0.958 0.952 0.048
#> SRR949105     1  0.0000      0.952 1.000 0.000
#> SRR949106     1  0.0000      0.952 1.000 0.000
#> SRR949107     1  0.0000      0.952 1.000 0.000
#> SRR949108     2  0.8499      0.632 0.276 0.724
#> SRR949109     1  0.4022      0.944 0.920 0.080
#> SRR949110     1  0.4022      0.944 0.920 0.080
#> SRR949111     1  0.4022      0.944 0.920 0.080
#> SRR949112     1  0.4022      0.944 0.920 0.080
#> SRR949113     1  0.2778      0.958 0.952 0.048
#> SRR949114     1  0.0000      0.952 1.000 0.000
#> SRR949115     1  0.0000      0.952 1.000 0.000
#> SRR949116     1  0.0000      0.952 1.000 0.000
#> SRR949117     1  0.0000      0.952 1.000 0.000
#> SRR949118     1  0.0000      0.952 1.000 0.000
#> SRR949119     2  0.0000      0.867 0.000 1.000
#> SRR949120     2  0.0000      0.867 0.000 1.000
#> SRR949121     2  0.9661      0.405 0.392 0.608
#> SRR949122     1  0.4022      0.944 0.920 0.080
#> SRR949123     1  0.0000      0.952 1.000 0.000
#> SRR949124     1  0.0000      0.952 1.000 0.000
#> SRR949125     1  0.5946      0.877 0.856 0.144
#> SRR949126     1  0.5946      0.877 0.856 0.144
#> SRR949127     1  0.2778      0.958 0.952 0.048
#> SRR949128     1  0.2778      0.958 0.952 0.048
#> SRR949129     1  0.2778      0.958 0.952 0.048

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR949076     2  0.7685      0.520 0.384 0.564 0.052
#> SRR949078     2  0.0000      0.715 0.000 1.000 0.000
#> SRR949077     2  0.6235      0.465 0.436 0.564 0.000
#> SRR949079     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949080     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949081     2  0.7451      0.509 0.396 0.564 0.040
#> SRR949082     2  0.0000      0.715 0.000 1.000 0.000
#> SRR949083     2  0.6235      0.465 0.436 0.564 0.000
#> SRR949084     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949085     2  0.0000      0.715 0.000 1.000 0.000
#> SRR949087     2  0.6302      0.375 0.480 0.520 0.000
#> SRR949088     2  0.6302      0.375 0.480 0.520 0.000
#> SRR949086     2  0.6307      0.186 0.000 0.512 0.488
#> SRR949089     2  0.0000      0.715 0.000 1.000 0.000
#> SRR949090     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949092     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949093     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949091     3  0.0000      1.000 0.000 0.000 1.000
#> SRR949095     2  0.6235      0.465 0.436 0.564 0.000
#> SRR949094     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949096     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949097     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949098     2  0.0000      0.715 0.000 1.000 0.000
#> SRR949099     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949101     2  0.6307      0.186 0.000 0.512 0.488
#> SRR949100     1  0.0424      0.990 0.992 0.008 0.000
#> SRR949102     2  0.7685      0.520 0.384 0.564 0.052
#> SRR949103     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949104     2  0.0000      0.715 0.000 1.000 0.000
#> SRR949105     3  0.0000      1.000 0.000 0.000 1.000
#> SRR949106     3  0.0000      1.000 0.000 0.000 1.000
#> SRR949107     3  0.0000      1.000 0.000 0.000 1.000
#> SRR949108     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949109     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949110     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949111     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949112     1  0.0424      0.990 0.992 0.008 0.000
#> SRR949113     2  0.0000      0.715 0.000 1.000 0.000
#> SRR949114     3  0.0000      1.000 0.000 0.000 1.000
#> SRR949115     3  0.0000      1.000 0.000 0.000 1.000
#> SRR949116     3  0.0000      1.000 0.000 0.000 1.000
#> SRR949117     2  0.6308      0.175 0.000 0.508 0.492
#> SRR949118     3  0.0000      1.000 0.000 0.000 1.000
#> SRR949119     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949120     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949121     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949122     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949123     2  0.0000      0.715 0.000 1.000 0.000
#> SRR949124     2  0.0000      0.715 0.000 1.000 0.000
#> SRR949125     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949126     1  0.0000      0.999 1.000 0.000 0.000
#> SRR949127     2  0.0000      0.715 0.000 1.000 0.000
#> SRR949128     2  0.0000      0.715 0.000 1.000 0.000
#> SRR949129     2  0.0000      0.715 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
#> SRR949076     2  0.4331      0.761 0.000 0.712 0.000 0.288
#> SRR949078     2  0.3610      0.777 0.000 0.800 0.000 0.200
#> SRR949077     2  0.4988      0.756 0.020 0.692 0.000 0.288
#> SRR949079     1  0.0000      0.726 1.000 0.000 0.000 0.000
#> SRR949080     1  0.0000      0.726 1.000 0.000 0.000 0.000
#> SRR949081     2  0.4331      0.761 0.000 0.712 0.000 0.288
#> SRR949082     2  0.3610      0.777 0.000 0.800 0.000 0.200
#> SRR949083     2  0.4331      0.761 0.000 0.712 0.000 0.288
#> SRR949084     1  0.3810      0.518 0.804 0.188 0.000 0.008
#> SRR949085     2  0.1940      0.782 0.000 0.924 0.000 0.076
#> SRR949087     2  0.5643      0.308 0.428 0.548 0.000 0.024
#> SRR949088     2  0.5643      0.308 0.428 0.548 0.000 0.024
#> SRR949086     2  0.4972      0.368 0.000 0.544 0.456 0.000
#> SRR949089     2  0.1557      0.763 0.000 0.944 0.000 0.056
#> SRR949090     4  0.4855      1.000 0.400 0.000 0.000 0.600
#> SRR949092     1  0.0000      0.726 1.000 0.000 0.000 0.000
#> SRR949093     1  0.0000      0.726 1.000 0.000 0.000 0.000
#> SRR949091     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR949095     2  0.5157      0.535 0.284 0.688 0.000 0.028
#> SRR949094     1  0.2401      0.644 0.904 0.092 0.000 0.004
#> SRR949096     1  0.1545      0.701 0.952 0.040 0.000 0.008
#> SRR949097     4  0.4855      1.000 0.400 0.000 0.000 0.600
#> SRR949098     2  0.1557      0.763 0.000 0.944 0.000 0.056
#> SRR949099     4  0.4855      1.000 0.400 0.000 0.000 0.600
#> SRR949101     2  0.4972      0.368 0.000 0.544 0.456 0.000
#> SRR949100     2  0.5138      0.324 0.392 0.600 0.000 0.008
#> SRR949102     2  0.4331      0.761 0.000 0.712 0.000 0.288
#> SRR949103     4  0.4855      1.000 0.400 0.000 0.000 0.600
#> SRR949104     2  0.0817      0.773 0.000 0.976 0.000 0.024
#> SRR949105     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR949106     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR949107     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR949108     1  0.2973      0.512 0.856 0.000 0.000 0.144
#> SRR949109     4  0.4855      1.000 0.400 0.000 0.000 0.600
#> SRR949110     4  0.4855      1.000 0.400 0.000 0.000 0.600
#> SRR949111     4  0.4855      1.000 0.400 0.000 0.000 0.600
#> SRR949112     1  0.5288     -0.111 0.520 0.472 0.000 0.008
#> SRR949113     2  0.0817      0.773 0.000 0.976 0.000 0.024
#> SRR949114     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR949115     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR949116     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR949117     2  0.4981      0.352 0.000 0.536 0.464 0.000
#> SRR949118     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR949119     1  0.0000      0.726 1.000 0.000 0.000 0.000
#> SRR949120     1  0.0000      0.726 1.000 0.000 0.000 0.000
#> SRR949121     1  0.0188      0.725 0.996 0.004 0.000 0.000
#> SRR949122     1  0.3610      0.487 0.800 0.200 0.000 0.000
#> SRR949123     2  0.3569      0.778 0.000 0.804 0.000 0.196
#> SRR949124     2  0.1557      0.763 0.000 0.944 0.000 0.056
#> SRR949125     1  0.4643     -0.181 0.656 0.000 0.000 0.344
#> SRR949126     1  0.4643     -0.181 0.656 0.000 0.000 0.344
#> SRR949127     2  0.1557      0.768 0.000 0.944 0.000 0.056
#> SRR949128     2  0.1557      0.768 0.000 0.944 0.000 0.056
#> SRR949129     2  0.1557      0.768 0.000 0.944 0.000 0.056

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR949076     5  0.0000      0.694 0.000 0.000 0.000 0.000 1.000
#> SRR949078     5  0.4278     -0.339 0.000 0.452 0.000 0.000 0.548
#> SRR949077     5  0.0000      0.694 0.000 0.000 0.000 0.000 1.000
#> SRR949079     1  0.0000      0.801 1.000 0.000 0.000 0.000 0.000
#> SRR949080     1  0.0000      0.801 1.000 0.000 0.000 0.000 0.000
#> SRR949081     5  0.0000      0.694 0.000 0.000 0.000 0.000 1.000
#> SRR949082     5  0.4242     -0.282 0.000 0.428 0.000 0.000 0.572
#> SRR949083     5  0.0000      0.694 0.000 0.000 0.000 0.000 1.000
#> SRR949084     1  0.1671      0.768 0.924 0.000 0.000 0.000 0.076
#> SRR949085     2  0.4235      0.469 0.000 0.576 0.000 0.000 0.424
#> SRR949087     1  0.6466      0.135 0.480 0.204 0.000 0.000 0.316
#> SRR949088     1  0.6455      0.148 0.484 0.204 0.000 0.000 0.312
#> SRR949086     3  0.4029      0.549 0.000 0.004 0.680 0.000 0.316
#> SRR949089     2  0.3636      0.678 0.000 0.728 0.000 0.000 0.272
#> SRR949090     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949092     1  0.0162      0.801 0.996 0.000 0.000 0.000 0.004
#> SRR949093     1  0.0162      0.801 0.996 0.000 0.000 0.000 0.004
#> SRR949091     3  0.0000      0.878 0.000 0.000 1.000 0.000 0.000
#> SRR949095     5  0.6038      0.185 0.240 0.184 0.000 0.000 0.576
#> SRR949094     1  0.1408      0.788 0.948 0.044 0.000 0.008 0.000
#> SRR949096     1  0.0162      0.801 0.996 0.000 0.000 0.000 0.004
#> SRR949097     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949098     2  0.3636      0.678 0.000 0.728 0.000 0.000 0.272
#> SRR949099     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949101     3  0.4009      0.556 0.000 0.004 0.684 0.000 0.312
#> SRR949100     1  0.8180      0.244 0.408 0.200 0.000 0.240 0.152
#> SRR949102     5  0.0000      0.694 0.000 0.000 0.000 0.000 1.000
#> SRR949103     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949104     2  0.3752      0.664 0.000 0.708 0.000 0.000 0.292
#> SRR949105     3  0.0000      0.878 0.000 0.000 1.000 0.000 0.000
#> SRR949106     3  0.0000      0.878 0.000 0.000 1.000 0.000 0.000
#> SRR949107     3  0.0000      0.878 0.000 0.000 1.000 0.000 0.000
#> SRR949108     1  0.0609      0.798 0.980 0.000 0.000 0.020 0.000
#> SRR949109     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949110     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949111     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR949112     1  0.5135      0.600 0.696 0.200 0.000 0.004 0.100
#> SRR949113     2  0.3752      0.664 0.000 0.708 0.000 0.000 0.292
#> SRR949114     3  0.0000      0.878 0.000 0.000 1.000 0.000 0.000
#> SRR949115     3  0.0000      0.878 0.000 0.000 1.000 0.000 0.000
#> SRR949116     3  0.0000      0.878 0.000 0.000 1.000 0.000 0.000
#> SRR949117     3  0.3861      0.604 0.000 0.004 0.712 0.000 0.284
#> SRR949118     3  0.1197      0.849 0.000 0.000 0.952 0.000 0.048
#> SRR949119     1  0.0000      0.801 1.000 0.000 0.000 0.000 0.000
#> SRR949120     1  0.0000      0.801 1.000 0.000 0.000 0.000 0.000
#> SRR949121     1  0.0324      0.801 0.992 0.000 0.000 0.004 0.004
#> SRR949122     1  0.4814      0.631 0.724 0.192 0.000 0.004 0.080
#> SRR949123     2  0.4300      0.340 0.000 0.524 0.000 0.000 0.476
#> SRR949124     2  0.3966      0.621 0.000 0.664 0.000 0.000 0.336
#> SRR949125     1  0.4126      0.448 0.620 0.000 0.000 0.380 0.000
#> SRR949126     1  0.4126      0.448 0.620 0.000 0.000 0.380 0.000
#> SRR949127     2  0.1671      0.585 0.000 0.924 0.000 0.000 0.076
#> SRR949128     2  0.1671      0.585 0.000 0.924 0.000 0.000 0.076
#> SRR949129     2  0.1671      0.585 0.000 0.924 0.000 0.000 0.076

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR949076     5  0.0000     0.8568 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR949078     5  0.3706     0.4221 0.000 0.380 0.000 0.000 0.620 0.000
#> SRR949077     5  0.0000     0.8568 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR949079     1  0.0000     0.9236 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949080     1  0.0000     0.9236 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949081     5  0.0000     0.8568 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR949082     5  0.3695     0.4309 0.000 0.376 0.000 0.000 0.624 0.000
#> SRR949083     5  0.0000     0.8568 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR949084     1  0.2134     0.8867 0.904 0.000 0.044 0.000 0.052 0.000
#> SRR949085     2  0.0000     0.8372 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949087     1  0.3718     0.8091 0.784 0.000 0.132 0.000 0.084 0.000
#> SRR949088     1  0.3718     0.8091 0.784 0.000 0.132 0.000 0.084 0.000
#> SRR949086     3  0.1556     0.9221 0.000 0.000 0.920 0.000 0.080 0.000
#> SRR949089     2  0.0000     0.8372 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949090     4  0.0000     0.8699 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949092     1  0.0000     0.9236 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949093     1  0.0000     0.9236 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949091     3  0.0000     0.9686 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949095     5  0.1141     0.8083 0.052 0.000 0.000 0.000 0.948 0.000
#> SRR949094     1  0.0000     0.9236 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949096     1  0.0000     0.9236 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949097     4  0.0000     0.8699 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949098     2  0.0000     0.8372 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949099     4  0.0000     0.8699 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949101     3  0.1556     0.9221 0.000 0.000 0.920 0.000 0.080 0.000
#> SRR949100     4  0.6510     0.0572 0.376 0.000 0.132 0.432 0.060 0.000
#> SRR949102     5  0.0000     0.8568 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR949103     4  0.0000     0.8699 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949104     2  0.4141     0.3793 0.000 0.556 0.000 0.000 0.012 0.432
#> SRR949105     3  0.0000     0.9686 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949106     3  0.0000     0.9686 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949107     3  0.0000     0.9686 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949108     1  0.0000     0.9236 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949109     4  0.0000     0.8699 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949110     4  0.0000     0.8699 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949111     4  0.0000     0.8699 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR949112     1  0.3667     0.8116 0.788 0.000 0.132 0.000 0.080 0.000
#> SRR949113     2  0.4141     0.3793 0.000 0.556 0.000 0.000 0.012 0.432
#> SRR949114     3  0.0000     0.9686 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949115     3  0.0000     0.9686 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949116     3  0.0000     0.9686 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR949117     3  0.1556     0.9221 0.000 0.000 0.920 0.000 0.080 0.000
#> SRR949118     3  0.0458     0.9618 0.000 0.000 0.984 0.000 0.016 0.000
#> SRR949119     1  0.0000     0.9236 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949120     1  0.0000     0.9236 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR949121     1  0.1092     0.9112 0.960 0.000 0.020 0.000 0.020 0.000
#> SRR949122     1  0.3213     0.8314 0.820 0.000 0.132 0.000 0.048 0.000
#> SRR949123     2  0.0260     0.8319 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR949124     2  0.0000     0.8372 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949125     4  0.2527     0.7445 0.168 0.000 0.000 0.832 0.000 0.000
#> SRR949126     4  0.2454     0.7524 0.160 0.000 0.000 0.840 0.000 0.000
#> SRR949127     6  0.0000     1.0000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR949128     6  0.0000     1.0000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR949129     6  0.0000     1.0000 0.000 0.000 0.000 0.000 0.000 1.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

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

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

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.969       0.988         0.3706 0.628   0.628
#> 3 3 0.947           0.922       0.970         0.7646 0.690   0.515
#> 4 4 0.809           0.844       0.926         0.1294 0.846   0.590
#> 5 5 0.715           0.584       0.804         0.0712 0.924   0.722
#> 6 6 0.664           0.618       0.789         0.0485 0.843   0.411

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR949076     1  0.0000      0.993 1.000 0.000
#> SRR949078     2  0.0000      0.968 0.000 1.000
#> SRR949077     1  0.0000      0.993 1.000 0.000
#> SRR949079     1  0.0000      0.993 1.000 0.000
#> SRR949080     1  0.0000      0.993 1.000 0.000
#> SRR949081     2  0.9522      0.396 0.372 0.628
#> SRR949082     2  0.0000      0.968 0.000 1.000
#> SRR949083     1  0.0376      0.989 0.996 0.004
#> SRR949084     1  0.0000      0.993 1.000 0.000
#> SRR949085     2  0.0000      0.968 0.000 1.000
#> SRR949087     1  0.0000      0.993 1.000 0.000
#> SRR949088     1  0.0000      0.993 1.000 0.000
#> SRR949086     1  0.0000      0.993 1.000 0.000
#> SRR949089     2  0.0000      0.968 0.000 1.000
#> SRR949090     1  0.0000      0.993 1.000 0.000
#> SRR949092     1  0.0000      0.993 1.000 0.000
#> SRR949093     1  0.0000      0.993 1.000 0.000
#> SRR949091     1  0.0000      0.993 1.000 0.000
#> SRR949095     1  0.1633      0.969 0.976 0.024
#> SRR949094     1  0.0000      0.993 1.000 0.000
#> SRR949096     1  0.0000      0.993 1.000 0.000
#> SRR949097     1  0.0000      0.993 1.000 0.000
#> SRR949098     2  0.0000      0.968 0.000 1.000
#> SRR949099     1  0.0000      0.993 1.000 0.000
#> SRR949101     1  0.0000      0.993 1.000 0.000
#> SRR949100     1  0.0000      0.993 1.000 0.000
#> SRR949102     1  0.8144      0.648 0.748 0.252
#> SRR949103     1  0.0000      0.993 1.000 0.000
#> SRR949104     2  0.0000      0.968 0.000 1.000
#> SRR949105     1  0.0000      0.993 1.000 0.000
#> SRR949106     1  0.0000      0.993 1.000 0.000
#> SRR949107     1  0.0000      0.993 1.000 0.000
#> SRR949108     1  0.0000      0.993 1.000 0.000
#> SRR949109     1  0.0000      0.993 1.000 0.000
#> SRR949110     1  0.0000      0.993 1.000 0.000
#> SRR949111     1  0.0000      0.993 1.000 0.000
#> SRR949112     1  0.0000      0.993 1.000 0.000
#> SRR949113     2  0.0000      0.968 0.000 1.000
#> SRR949114     1  0.0000      0.993 1.000 0.000
#> SRR949115     1  0.0000      0.993 1.000 0.000
#> SRR949116     1  0.0000      0.993 1.000 0.000
#> SRR949117     1  0.0000      0.993 1.000 0.000
#> SRR949118     1  0.0000      0.993 1.000 0.000
#> SRR949119     1  0.0000      0.993 1.000 0.000
#> SRR949120     1  0.0000      0.993 1.000 0.000
#> SRR949121     1  0.0000      0.993 1.000 0.000
#> SRR949122     1  0.0000      0.993 1.000 0.000
#> SRR949123     2  0.0000      0.968 0.000 1.000
#> SRR949124     2  0.0000      0.968 0.000 1.000
#> SRR949125     1  0.0000      0.993 1.000 0.000
#> SRR949126     1  0.0000      0.993 1.000 0.000
#> SRR949127     2  0.0376      0.965 0.004 0.996
#> SRR949128     2  0.0376      0.965 0.004 0.996
#> SRR949129     2  0.0000      0.968 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
#> SRR949076     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949078     2  0.4121      0.801 0.168 0.832 0.000
#> SRR949077     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949079     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949080     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949081     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949082     2  0.5016      0.699 0.240 0.760 0.000
#> SRR949083     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949084     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949085     2  0.0000      0.961 0.000 1.000 0.000
#> SRR949087     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949088     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949086     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949089     2  0.0000      0.961 0.000 1.000 0.000
#> SRR949090     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949092     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949093     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949091     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949095     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949094     1  0.1964      0.910 0.944 0.000 0.056
#> SRR949096     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949097     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949098     2  0.0000      0.961 0.000 1.000 0.000
#> SRR949099     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949101     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949100     3  0.0424      0.959 0.008 0.000 0.992
#> SRR949102     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949103     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949104     2  0.0000      0.961 0.000 1.000 0.000
#> SRR949105     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949106     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949107     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949108     3  0.6244      0.181 0.440 0.000 0.560
#> SRR949109     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949110     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949111     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949112     3  0.4654      0.718 0.208 0.000 0.792
#> SRR949113     2  0.0000      0.961 0.000 1.000 0.000
#> SRR949114     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949115     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949116     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949117     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949118     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949119     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949120     1  0.0000      0.963 1.000 0.000 0.000
#> SRR949121     1  0.2878      0.866 0.904 0.000 0.096
#> SRR949122     1  0.6111      0.324 0.604 0.000 0.396
#> SRR949123     2  0.0000      0.961 0.000 1.000 0.000
#> SRR949124     2  0.0000      0.961 0.000 1.000 0.000
#> SRR949125     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949126     3  0.0000      0.967 0.000 0.000 1.000
#> SRR949127     2  0.0000      0.961 0.000 1.000 0.000
#> SRR949128     2  0.0000      0.961 0.000 1.000 0.000
#> SRR949129     2  0.0000      0.961 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
#> SRR949076     4  0.0000      0.950 0.000 0.000 0.000 1.000
#> SRR949078     2  0.4522      0.499 0.000 0.680 0.000 0.320
#> SRR949077     4  0.0000      0.950 0.000 0.000 0.000 1.000
#> SRR949079     4  0.1637      0.936 0.060 0.000 0.000 0.940
#> SRR949080     4  0.1557      0.938 0.056 0.000 0.000 0.944
#> SRR949081     4  0.0000      0.950 0.000 0.000 0.000 1.000
#> SRR949082     4  0.2760      0.844 0.000 0.128 0.000 0.872
#> SRR949083     4  0.0000      0.950 0.000 0.000 0.000 1.000
#> SRR949084     4  0.0188      0.950 0.004 0.000 0.000 0.996
#> SRR949085     2  0.0000      0.911 0.000 1.000 0.000 0.000
#> SRR949087     4  0.1022      0.945 0.032 0.000 0.000 0.968
#> SRR949088     4  0.1637      0.930 0.060 0.000 0.000 0.940
#> SRR949086     3  0.0000      0.929 0.000 0.000 1.000 0.000
#> SRR949089     2  0.0000      0.911 0.000 1.000 0.000 0.000
#> SRR949090     1  0.2589      0.776 0.884 0.000 0.116 0.000
#> SRR949092     4  0.1211      0.945 0.040 0.000 0.000 0.960
#> SRR949093     4  0.0592      0.950 0.016 0.000 0.000 0.984
#> SRR949091     3  0.0188      0.928 0.004 0.000 0.996 0.000
#> SRR949095     4  0.0188      0.950 0.004 0.000 0.000 0.996
#> SRR949094     4  0.1297      0.944 0.020 0.000 0.016 0.964
#> SRR949096     4  0.0336      0.950 0.008 0.000 0.000 0.992
#> SRR949097     1  0.0000      0.826 1.000 0.000 0.000 0.000
#> SRR949098     2  0.0000      0.911 0.000 1.000 0.000 0.000
#> SRR949099     1  0.0336      0.826 0.992 0.000 0.008 0.000
#> SRR949101     3  0.0000      0.929 0.000 0.000 1.000 0.000
#> SRR949100     1  0.0000      0.826 1.000 0.000 0.000 0.000
#> SRR949102     4  0.0188      0.949 0.000 0.000 0.004 0.996
#> SRR949103     1  0.1389      0.819 0.952 0.000 0.048 0.000
#> SRR949104     2  0.0000      0.911 0.000 1.000 0.000 0.000
#> SRR949105     3  0.0469      0.925 0.012 0.000 0.988 0.000
#> SRR949106     3  0.0336      0.927 0.008 0.000 0.992 0.000
#> SRR949107     3  0.0336      0.927 0.008 0.000 0.992 0.000
#> SRR949108     1  0.3958      0.751 0.824 0.000 0.032 0.144
#> SRR949109     3  0.4967      0.189 0.452 0.000 0.548 0.000
#> SRR949110     1  0.0000      0.826 1.000 0.000 0.000 0.000
#> SRR949111     1  0.1118      0.823 0.964 0.000 0.036 0.000
#> SRR949112     1  0.7890      0.206 0.380 0.000 0.312 0.308
#> SRR949113     2  0.0000      0.911 0.000 1.000 0.000 0.000
#> SRR949114     3  0.0000      0.929 0.000 0.000 1.000 0.000
#> SRR949115     3  0.0000      0.929 0.000 0.000 1.000 0.000
#> SRR949116     3  0.0000      0.929 0.000 0.000 1.000 0.000
#> SRR949117     3  0.0000      0.929 0.000 0.000 1.000 0.000
#> SRR949118     3  0.0000      0.929 0.000 0.000 1.000 0.000
#> SRR949119     4  0.2530      0.898 0.112 0.000 0.000 0.888
#> SRR949120     4  0.3649      0.785 0.204 0.000 0.000 0.796
#> SRR949121     4  0.3032      0.876 0.124 0.000 0.008 0.868
#> SRR949122     1  0.3933      0.696 0.792 0.000 0.008 0.200
#> SRR949123     2  0.0000      0.911 0.000 1.000 0.000 0.000
#> SRR949124     2  0.0000      0.911 0.000 1.000 0.000 0.000
#> SRR949125     3  0.3636      0.774 0.172 0.000 0.820 0.008
#> SRR949126     3  0.3356      0.776 0.176 0.000 0.824 0.000
#> SRR949127     1  0.4164      0.581 0.736 0.264 0.000 0.000
#> SRR949128     1  0.3907      0.628 0.768 0.232 0.000 0.000
#> SRR949129     2  0.4072      0.603 0.252 0.748 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
#> SRR949076     5  0.4219    0.41845 0.000 0.000 0.000 0.416 0.584
#> SRR949078     2  0.4517    0.10420 0.000 0.556 0.000 0.008 0.436
#> SRR949077     5  0.3424    0.62554 0.000 0.000 0.000 0.240 0.760
#> SRR949079     5  0.6334    0.29081 0.360 0.000 0.012 0.120 0.508
#> SRR949080     5  0.6293    0.33512 0.328 0.000 0.008 0.136 0.528
#> SRR949081     5  0.0290    0.74844 0.000 0.000 0.000 0.008 0.992
#> SRR949082     5  0.1121    0.73876 0.000 0.044 0.000 0.000 0.956
#> SRR949083     5  0.0000    0.74848 0.000 0.000 0.000 0.000 1.000
#> SRR949084     5  0.0671    0.75078 0.016 0.000 0.000 0.004 0.980
#> SRR949085     2  0.0000    0.89022 0.000 1.000 0.000 0.000 0.000
#> SRR949087     5  0.1997    0.73087 0.000 0.000 0.040 0.036 0.924
#> SRR949088     5  0.2464    0.72603 0.012 0.000 0.048 0.032 0.908
#> SRR949086     3  0.1695    0.77493 0.008 0.000 0.940 0.044 0.008
#> SRR949089     2  0.0000    0.89022 0.000 1.000 0.000 0.000 0.000
#> SRR949090     1  0.4359    0.17395 0.584 0.000 0.412 0.004 0.000
#> SRR949092     5  0.2124    0.71690 0.096 0.000 0.000 0.004 0.900
#> SRR949093     5  0.1041    0.74801 0.032 0.000 0.000 0.004 0.964
#> SRR949091     3  0.1282    0.78554 0.004 0.000 0.952 0.044 0.000
#> SRR949095     5  0.0162    0.74841 0.000 0.000 0.000 0.004 0.996
#> SRR949094     5  0.6986    0.27854 0.248 0.000 0.028 0.220 0.504
#> SRR949096     5  0.0992    0.75089 0.024 0.000 0.000 0.008 0.968
#> SRR949097     1  0.0000    0.66984 1.000 0.000 0.000 0.000 0.000
#> SRR949098     2  0.0000    0.89022 0.000 1.000 0.000 0.000 0.000
#> SRR949099     1  0.0794    0.66769 0.972 0.000 0.028 0.000 0.000
#> SRR949101     3  0.0290    0.79578 0.000 0.000 0.992 0.008 0.000
#> SRR949100     1  0.0162    0.66947 0.996 0.000 0.000 0.004 0.000
#> SRR949102     5  0.4425    0.35542 0.000 0.000 0.004 0.452 0.544
#> SRR949103     1  0.0880    0.66660 0.968 0.000 0.032 0.000 0.000
#> SRR949104     2  0.0000    0.89022 0.000 1.000 0.000 0.000 0.000
#> SRR949105     3  0.0566    0.79345 0.012 0.000 0.984 0.004 0.000
#> SRR949106     3  0.0290    0.79339 0.008 0.000 0.992 0.000 0.000
#> SRR949107     3  0.0404    0.79139 0.012 0.000 0.988 0.000 0.000
#> SRR949108     1  0.3684    0.43737 0.720 0.000 0.000 0.280 0.000
#> SRR949109     1  0.4655    0.00642 0.512 0.000 0.476 0.012 0.000
#> SRR949110     1  0.0000    0.66984 1.000 0.000 0.000 0.000 0.000
#> SRR949111     1  0.1106    0.66450 0.964 0.000 0.024 0.012 0.000
#> SRR949112     4  0.3496    0.34997 0.200 0.000 0.012 0.788 0.000
#> SRR949113     2  0.0000    0.89022 0.000 1.000 0.000 0.000 0.000
#> SRR949114     3  0.4420    0.48027 0.004 0.000 0.548 0.448 0.000
#> SRR949115     3  0.4437    0.46079 0.004 0.000 0.532 0.464 0.000
#> SRR949116     3  0.4440    0.45548 0.004 0.000 0.528 0.468 0.000
#> SRR949117     3  0.0955    0.79563 0.004 0.000 0.968 0.028 0.000
#> SRR949118     3  0.2179    0.75632 0.000 0.000 0.888 0.112 0.000
#> SRR949119     4  0.6492    0.16923 0.348 0.000 0.000 0.456 0.196
#> SRR949120     1  0.5498   -0.16066 0.496 0.000 0.000 0.440 0.064
#> SRR949121     5  0.6655   -0.03435 0.296 0.000 0.000 0.260 0.444
#> SRR949122     1  0.4045    0.32947 0.644 0.000 0.000 0.356 0.000
#> SRR949123     2  0.1205    0.86306 0.000 0.956 0.004 0.040 0.000
#> SRR949124     2  0.0000    0.89022 0.000 1.000 0.000 0.000 0.000
#> SRR949125     4  0.6312    0.46457 0.156 0.000 0.392 0.452 0.000
#> SRR949126     4  0.6363    0.46797 0.164 0.000 0.392 0.444 0.000
#> SRR949127     1  0.3906    0.45719 0.704 0.292 0.000 0.004 0.000
#> SRR949128     1  0.3635    0.49888 0.748 0.248 0.000 0.004 0.000
#> SRR949129     2  0.3266    0.66696 0.200 0.796 0.000 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR949076     4  0.3151     0.6442 0.000 0.000 0.000 0.748 0.252 0.000
#> SRR949078     2  0.4693     0.5387 0.000 0.684 0.000 0.140 0.176 0.000
#> SRR949077     4  0.3774     0.4640 0.000 0.000 0.000 0.592 0.408 0.000
#> SRR949079     4  0.6919     0.5811 0.084 0.000 0.144 0.536 0.212 0.024
#> SRR949080     4  0.6816     0.6037 0.084 0.000 0.128 0.548 0.216 0.024
#> SRR949081     5  0.0858     0.8802 0.000 0.000 0.004 0.028 0.968 0.000
#> SRR949082     5  0.2006     0.8235 0.000 0.104 0.000 0.004 0.892 0.000
#> SRR949083     5  0.0603     0.8794 0.000 0.000 0.000 0.016 0.980 0.004
#> SRR949084     5  0.1944     0.8757 0.024 0.000 0.000 0.036 0.924 0.016
#> SRR949085     2  0.0000     0.9186 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949087     5  0.2747     0.8364 0.008 0.004 0.076 0.036 0.876 0.000
#> SRR949088     5  0.2879     0.8336 0.016 0.000 0.072 0.044 0.868 0.000
#> SRR949086     3  0.4988     0.3689 0.000 0.000 0.676 0.028 0.076 0.220
#> SRR949089     2  0.0000     0.9186 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949090     3  0.4949     0.5950 0.196 0.000 0.696 0.056 0.000 0.052
#> SRR949092     5  0.3726     0.7909 0.080 0.000 0.000 0.032 0.816 0.072
#> SRR949093     5  0.3329     0.8185 0.052 0.000 0.000 0.032 0.844 0.072
#> SRR949091     3  0.3039     0.6640 0.008 0.000 0.852 0.056 0.000 0.084
#> SRR949095     5  0.1082     0.8767 0.004 0.000 0.000 0.040 0.956 0.000
#> SRR949094     3  0.7853     0.0871 0.080 0.000 0.396 0.312 0.116 0.096
#> SRR949096     5  0.1924     0.8673 0.048 0.000 0.000 0.028 0.920 0.004
#> SRR949097     1  0.0922     0.6628 0.968 0.000 0.004 0.004 0.000 0.024
#> SRR949098     2  0.0000     0.9186 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949099     1  0.1340     0.6574 0.948 0.000 0.040 0.004 0.000 0.008
#> SRR949101     3  0.2506     0.6616 0.000 0.000 0.880 0.052 0.000 0.068
#> SRR949100     1  0.0692     0.6528 0.976 0.000 0.000 0.020 0.000 0.004
#> SRR949102     4  0.3590     0.6549 0.000 0.000 0.004 0.776 0.188 0.032
#> SRR949103     1  0.3355     0.6153 0.828 0.000 0.040 0.016 0.000 0.116
#> SRR949104     2  0.0146     0.9167 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR949105     3  0.1219     0.6602 0.004 0.000 0.948 0.000 0.000 0.048
#> SRR949106     3  0.0865     0.6606 0.000 0.000 0.964 0.000 0.000 0.036
#> SRR949107     3  0.0865     0.6606 0.000 0.000 0.964 0.000 0.000 0.036
#> SRR949108     1  0.4744     0.4581 0.684 0.000 0.012 0.080 0.000 0.224
#> SRR949109     3  0.5579     0.5100 0.252 0.000 0.616 0.048 0.000 0.084
#> SRR949110     1  0.2113     0.6430 0.896 0.000 0.008 0.004 0.000 0.092
#> SRR949111     1  0.5456    -0.1255 0.496 0.000 0.420 0.036 0.000 0.048
#> SRR949112     6  0.3693     0.5991 0.120 0.000 0.000 0.092 0.000 0.788
#> SRR949113     2  0.0000     0.9186 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949114     6  0.1644     0.6816 0.000 0.000 0.076 0.004 0.000 0.920
#> SRR949115     6  0.1584     0.6867 0.000 0.000 0.064 0.008 0.000 0.928
#> SRR949116     6  0.1584     0.6867 0.000 0.000 0.064 0.008 0.000 0.928
#> SRR949117     3  0.4099     0.1564 0.000 0.000 0.612 0.016 0.000 0.372
#> SRR949118     6  0.4157     0.1455 0.000 0.000 0.444 0.012 0.000 0.544
#> SRR949119     4  0.5063     0.4997 0.276 0.000 0.000 0.640 0.044 0.040
#> SRR949120     4  0.4718     0.3919 0.340 0.000 0.000 0.608 0.008 0.044
#> SRR949121     6  0.5963     0.4680 0.132 0.000 0.004 0.048 0.212 0.604
#> SRR949122     6  0.5105     0.0604 0.428 0.000 0.004 0.068 0.000 0.500
#> SRR949123     2  0.2480     0.8309 0.000 0.872 0.000 0.024 0.000 0.104
#> SRR949124     2  0.0000     0.9186 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR949125     3  0.5900     0.5575 0.064 0.000 0.608 0.212 0.000 0.116
#> SRR949126     3  0.5889     0.5692 0.068 0.000 0.616 0.196 0.000 0.120
#> SRR949127     1  0.4263     0.0615 0.504 0.480 0.000 0.016 0.000 0.000
#> SRR949128     1  0.4184     0.2571 0.576 0.408 0.000 0.016 0.000 0.000
#> SRR949129     2  0.2404     0.8027 0.112 0.872 0.000 0.016 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-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

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