cola Report for recount2:SRP039077

Date: 2019-12-25 23:58:01 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 14036 rows and 60 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] 14036    60

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
SD:hclust 6 1.000 0.982 0.999 ** 2,3,5
SD:kmeans 2 1.000 1.000 1.000 **
SD:pam 6 1.000 1.000 1.000 ** 2,3,5
SD:NMF 2 1.000 1.000 1.000 **
CV:hclust 4 1.000 0.983 1.000 ** 2
CV:kmeans 2 1.000 1.000 1.000 **
CV:skmeans 3 1.000 1.000 1.000 ** 2
CV:NMF 3 1.000 0.998 0.993 ** 2
MAD:hclust 6 1.000 0.980 0.993 ** 2,4,5
MAD:kmeans 2 1.000 1.000 1.000 **
MAD:NMF 2 1.000 1.000 1.000 **
ATC:hclust 6 1.000 0.973 0.971 ** 2,4,5
ATC:kmeans 2 1.000 1.000 1.000 **
ATC:pam 6 1.000 1.000 1.000 ** 2,3,4,5
ATC:NMF 2 1.000 1.000 1.000 **
MAD:pam 5 0.968 0.918 0.968 ** 2,3,4
ATC:mclust 6 0.966 0.988 0.956 ** 3,4,5
SD:mclust 6 0.951 0.976 0.954 ** 3,4,5
MAD:mclust 6 0.947 0.861 0.913 * 2,3,4,5
CV:pam 6 0.946 0.880 0.946 * 2,3
ATC:skmeans 5 0.939 0.967 0.917 * 2,3,4
CV:mclust 5 0.918 0.949 0.965 * 2,3
MAD:skmeans 6 0.917 0.896 0.907 * 2,3
SD:skmeans 6 0.916 0.818 0.874 * 2,3

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

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

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

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

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

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

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

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

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

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

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

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

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

Membership heatmap

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

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

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

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

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

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

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

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

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

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

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

Signature heatmap

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

Note in following heatmaps, rows are scaled.

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

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

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

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

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

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

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

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

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

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

Statistics table

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

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 1.000           1.000       1.000          0.508 0.492   0.492
#> CV:NMF      2 1.000           1.000       1.000          0.508 0.492   0.492
#> MAD:NMF     2 1.000           1.000       1.000          0.508 0.492   0.492
#> ATC:NMF     2 1.000           1.000       1.000          0.508 0.492   0.492
#> SD:skmeans  2 1.000           1.000       1.000          0.508 0.492   0.492
#> CV:skmeans  2 1.000           1.000       1.000          0.508 0.492   0.492
#> MAD:skmeans 2 1.000           1.000       1.000          0.508 0.492   0.492
#> ATC:skmeans 2 1.000           1.000       1.000          0.508 0.492   0.492
#> SD:mclust   2 0.602           0.864       0.896          0.460 0.492   0.492
#> CV:mclust   2 1.000           0.995       0.995          0.506 0.492   0.492
#> MAD:mclust  2 1.000           0.981       0.986          0.388 0.619   0.619
#> ATC:mclust  2 0.602           0.903       0.933          0.410 0.619   0.619
#> SD:kmeans   2 1.000           1.000       1.000          0.508 0.492   0.492
#> CV:kmeans   2 1.000           1.000       1.000          0.508 0.492   0.492
#> MAD:kmeans  2 1.000           1.000       1.000          0.508 0.492   0.492
#> ATC:kmeans  2 1.000           1.000       1.000          0.508 0.492   0.492
#> SD:pam      2 1.000           1.000       1.000          0.508 0.492   0.492
#> CV:pam      2 1.000           1.000       1.000          0.508 0.492   0.492
#> MAD:pam     2 1.000           1.000       1.000          0.508 0.492   0.492
#> ATC:pam     2 1.000           1.000       1.000          0.508 0.492   0.492
#> SD:hclust   2 1.000           1.000       1.000          0.508 0.492   0.492
#> CV:hclust   2 1.000           1.000       1.000          0.508 0.492   0.492
#> MAD:hclust  2 1.000           1.000       1.000          0.508 0.492   0.492
#> ATC:hclust  2 1.000           1.000       1.000          0.508 0.492   0.492
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.850           0.996       0.945         0.2174 0.864   0.724
#> CV:NMF      3 1.000           0.998       0.993         0.2615 0.864   0.724
#> MAD:NMF     3 0.864           0.998       0.970         0.2385 0.864   0.724
#> ATC:NMF     3 1.000           0.979       0.977         0.0285 1.000   1.000
#> SD:skmeans  3 1.000           0.998       0.994         0.2650 0.864   0.724
#> CV:skmeans  3 1.000           1.000       1.000         0.2664 0.864   0.724
#> MAD:skmeans 3 1.000           0.999       0.999         0.2662 0.864   0.724
#> ATC:skmeans 3 1.000           0.995       0.987         0.2631 0.864   0.724
#> SD:mclust   3 1.000           1.000       1.000         0.4010 0.864   0.724
#> CV:mclust   3 1.000           0.999       1.000         0.2724 0.864   0.724
#> MAD:mclust  3 1.000           0.999       1.000         0.6573 0.738   0.576
#> ATC:mclust  3 1.000           1.000       1.000         0.5712 0.738   0.576
#> SD:kmeans   3 0.686           0.806       0.789         0.2324 1.000   1.000
#> CV:kmeans   3 0.684           0.823       0.801         0.2162 1.000   1.000
#> MAD:kmeans  3 0.684           0.819       0.796         0.2206 1.000   1.000
#> ATC:kmeans  3 0.718           0.923       0.794         0.2304 0.864   0.724
#> SD:pam      3 1.000           1.000       1.000         0.2664 0.864   0.724
#> CV:pam      3 1.000           1.000       1.000         0.2664 0.864   0.724
#> MAD:pam     3 1.000           1.000       1.000         0.2664 0.864   0.724
#> ATC:pam     3 1.000           1.000       1.000         0.2664 0.864   0.724
#> SD:hclust   3 1.000           1.000       1.000         0.2664 0.864   0.724
#> CV:hclust   3 0.868           0.895       0.935         0.0938 0.983   0.966
#> MAD:hclust  3 0.868           0.831       0.902         0.1246 0.983   0.966
#> ATC:hclust  3 1.000           0.983       0.999         0.0337 0.983   0.966
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.913           0.960       0.949         0.0580 1.000   1.000
#> CV:NMF      4 0.877           0.958       0.952         0.0421 1.000   1.000
#> MAD:NMF     4 0.895           0.963       0.959         0.0519 1.000   1.000
#> ATC:NMF     4 0.789           0.906       0.905         0.0855 1.000   1.000
#> SD:skmeans  4 0.850           0.947       0.955         0.1449 0.913   0.756
#> CV:skmeans  4 0.939           0.957       0.969         0.0339 0.992   0.976
#> MAD:skmeans 4 0.845           0.748       0.844         0.0964 0.881   0.667
#> ATC:skmeans 4 0.945           0.972       0.975         0.1388 0.913   0.756
#> SD:mclust   4 1.000           1.000       1.000         0.1350 0.913   0.756
#> CV:mclust   4 1.000           0.980       0.997         0.0151 0.992   0.976
#> MAD:mclust  4 0.905           0.945       0.942         0.1491 0.913   0.756
#> ATC:mclust  4 1.000           1.000       1.000         0.1350 0.913   0.756
#> SD:kmeans   4 0.654           0.641       0.693         0.1068 0.777   0.548
#> CV:kmeans   4 0.687           0.863       0.779         0.1025 0.864   0.724
#> MAD:kmeans  4 0.678           0.795       0.720         0.1066 0.777   0.548
#> ATC:kmeans  4 0.654           0.813       0.806         0.1073 0.913   0.756
#> SD:pam      4 0.858           0.833       0.907         0.1613 0.905   0.734
#> CV:pam      4 0.852           0.880       0.925         0.1776 0.881   0.667
#> MAD:pam     4 0.909           0.882       0.942         0.1615 0.905   0.734
#> ATC:pam     4 0.959           0.925       0.968         0.1545 0.905   0.734
#> SD:hclust   4 0.877           0.869       0.893         0.0849 0.992   0.976
#> CV:hclust   4 1.000           0.983       1.000         0.1730 0.873   0.732
#> MAD:hclust  4 1.000           0.983       1.000         0.1409 0.873   0.732
#> ATC:hclust  4 1.000           0.983       0.999         0.1652 0.913   0.817
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.846           0.913       0.906         0.0480 1.000   1.000
#> CV:NMF      5 0.835           0.893       0.883         0.0528 1.000   1.000
#> MAD:NMF     5 0.833           0.918       0.919         0.0406 1.000   1.000
#> ATC:NMF     5 0.763           0.861       0.859         0.1621 0.797   0.587
#> SD:skmeans  5 0.901           0.869       0.880         0.0505 1.000   1.000
#> CV:skmeans  5 0.808           0.765       0.843         0.1191 0.881   0.659
#> MAD:skmeans 5 0.845           0.891       0.932         0.0662 0.905   0.679
#> ATC:skmeans 5 0.939           0.967       0.917         0.0520 0.941   0.780
#> SD:mclust   5 0.943           0.954       0.964         0.0813 0.941   0.780
#> CV:mclust   5 0.918           0.949       0.965         0.1672 0.881   0.659
#> MAD:mclust  5 0.947           0.869       0.899         0.0719 0.941   0.780
#> ATC:mclust  5 1.000           0.997       0.997         0.0812 0.941   0.780
#> SD:kmeans   5 0.610           0.808       0.698         0.0707 0.941   0.780
#> CV:kmeans   5 0.627           0.751       0.764         0.0708 0.913   0.756
#> MAD:kmeans  5 0.613           0.764       0.741         0.0628 1.000   1.000
#> ATC:kmeans  5 0.631           0.738       0.691         0.0647 0.925   0.731
#> SD:pam      5 0.978           0.933       0.971         0.0669 0.930   0.737
#> CV:pam      5 0.852           0.844       0.855         0.0237 0.947   0.787
#> MAD:pam     5 0.968           0.918       0.968         0.0659 0.928   0.730
#> ATC:pam     5 0.959           0.894       0.959         0.0700 0.928   0.732
#> SD:hclust   5 0.935           0.904       0.936         0.0887 0.913   0.750
#> CV:hclust   5 0.838           0.759       0.834         0.0915 0.881   0.659
#> MAD:hclust  5 1.000           0.967       0.989         0.1371 0.913   0.750
#> ATC:hclust  5 1.000           0.983       1.000         0.1031 0.937   0.837
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.835           0.882       0.880         0.0371 0.913   0.756
#> CV:NMF      6 0.829           0.764       0.828         0.0654 0.905   0.732
#> MAD:NMF     6 0.835           0.882       0.884         0.0380 0.913   0.756
#> ATC:NMF     6 0.761           0.936       0.873         0.0380 0.969   0.896
#> SD:skmeans  6 0.916           0.818       0.874         0.0388 0.928   0.734
#> CV:skmeans  6 0.839           0.843       0.771         0.0507 0.972   0.879
#> MAD:skmeans 6 0.917           0.896       0.907         0.0537 0.941   0.773
#> ATC:skmeans 6 0.917           0.931       0.945         0.0408 0.992   0.960
#> SD:mclust   6 0.951           0.976       0.954         0.0384 0.968   0.849
#> CV:mclust   6 0.872           0.864       0.897         0.0320 1.000   1.000
#> MAD:mclust  6 0.947           0.861       0.913         0.0134 0.980   0.905
#> ATC:mclust  6 0.966           0.988       0.956         0.0319 0.968   0.849
#> SD:kmeans   6 0.758           0.723       0.718         0.0513 0.941   0.780
#> CV:kmeans   6 0.742           0.540       0.707         0.0556 0.980   0.925
#> MAD:kmeans  6 0.611           0.765       0.704         0.0582 0.941   0.780
#> ATC:kmeans  6 0.735           0.688       0.739         0.0514 0.917   0.701
#> SD:pam      6 1.000           1.000       1.000         0.0299 0.963   0.824
#> CV:pam      6 0.946           0.880       0.946         0.0384 0.973   0.872
#> MAD:pam     6 0.956           0.897       0.968         0.0106 0.992   0.958
#> ATC:pam     6 1.000           1.000       1.000         0.0330 0.964   0.826
#> SD:hclust   6 1.000           0.982       0.999         0.0555 0.937   0.758
#> CV:hclust   6 0.842           0.872       0.903         0.0483 0.909   0.681
#> MAD:hclust  6 1.000           0.980       0.993         0.0778 0.937   0.758
#> ATC:hclust  6 1.000           0.973       0.971         0.1764 0.873   0.609

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

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 1.000           1.000       1.000         0.2664 0.864   0.724
#> 4 4 0.877           0.869       0.893         0.0849 0.992   0.976
#> 5 5 0.935           0.904       0.936         0.0887 0.913   0.750
#> 6 6 1.000           0.982       0.999         0.0555 0.937   0.758

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1179081     3       0          1  0  0  1
#> SRR1179082     3       0          1  0  0  1
#> SRR1179083     3       0          1  0  0  1
#> SRR1179084     3       0          1  0  0  1
#> SRR1179085     3       0          1  0  0  1
#> SRR1179086     3       0          1  0  0  1
#> SRR1179087     3       0          1  0  0  1
#> SRR1179088     3       0          1  0  0  1
#> SRR1179089     3       0          1  0  0  1
#> SRR1179090     3       0          1  0  0  1
#> SRR1179091     3       0          1  0  0  1
#> SRR1179092     3       0          1  0  0  1
#> SRR1179093     3       0          1  0  0  1
#> SRR1179094     3       0          1  0  0  1
#> SRR1179095     3       0          1  0  0  1
#> SRR1179096     2       0          1  0  1  0
#> SRR1179097     2       0          1  0  1  0
#> SRR1179098     2       0          1  0  1  0
#> SRR1179099     2       0          1  0  1  0
#> SRR1179100     2       0          1  0  1  0
#> SRR1179101     2       0          1  0  1  0
#> SRR1179102     2       0          1  0  1  0
#> SRR1179103     2       0          1  0  1  0
#> SRR1179104     2       0          1  0  1  0
#> SRR1179105     2       0          1  0  1  0
#> SRR1179106     2       0          1  0  1  0
#> SRR1179107     2       0          1  0  1  0
#> SRR1179108     2       0          1  0  1  0
#> SRR1179109     2       0          1  0  1  0
#> SRR1179110     2       0          1  0  1  0
#> SRR1179111     2       0          1  0  1  0
#> SRR1179112     1       0          1  1  0  0
#> SRR1179113     1       0          1  1  0  0
#> SRR1179114     1       0          1  1  0  0
#> SRR1179115     1       0          1  1  0  0
#> SRR1179116     1       0          1  1  0  0
#> SRR1179117     1       0          1  1  0  0
#> SRR1179118     1       0          1  1  0  0
#> SRR1179119     1       0          1  1  0  0
#> SRR1179120     1       0          1  1  0  0
#> SRR1179121     1       0          1  1  0  0
#> SRR1179122     1       0          1  1  0  0
#> SRR1179123     1       0          1  1  0  0
#> SRR1179124     1       0          1  1  0  0
#> SRR1179125     1       0          1  1  0  0
#> SRR1179126     1       0          1  1  0  0
#> SRR1179127     1       0          1  1  0  0
#> SRR1179128     1       0          1  1  0  0
#> SRR1179129     1       0          1  1  0  0
#> SRR1179130     1       0          1  1  0  0
#> SRR1179131     1       0          1  1  0  0
#> SRR1179132     1       0          1  1  0  0
#> SRR1179134     1       0          1  1  0  0
#> SRR1179135     1       0          1  1  0  0
#> SRR1179136     1       0          1  1  0  0
#> SRR1179137     1       0          1  1  0  0
#> SRR1179138     1       0          1  1  0  0
#> SRR1179139     1       0          1  1  0  0
#> SRR1179140     1       0          1  1  0  0
#> SRR1179141     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2 p3    p4
#> SRR1179081     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179082     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179083     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179084     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179085     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179086     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179087     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179088     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179089     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179090     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179091     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179092     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179093     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179094     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179095     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179096     4   0.494      0.000 0.000 0.436  0 0.564
#> SRR1179097     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR1179098     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR1179099     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR1179100     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR1179101     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR1179102     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR1179103     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR1179104     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR1179105     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR1179106     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR1179107     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR1179108     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR1179109     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR1179110     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR1179111     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR1179112     1   0.000      0.773 1.000 0.000  0 0.000
#> SRR1179113     1   0.000      0.773 1.000 0.000  0 0.000
#> SRR1179114     1   0.000      0.773 1.000 0.000  0 0.000
#> SRR1179115     1   0.000      0.773 1.000 0.000  0 0.000
#> SRR1179116     1   0.000      0.773 1.000 0.000  0 0.000
#> SRR1179117     1   0.000      0.773 1.000 0.000  0 0.000
#> SRR1179118     1   0.000      0.773 1.000 0.000  0 0.000
#> SRR1179119     1   0.000      0.773 1.000 0.000  0 0.000
#> SRR1179120     1   0.156      0.750 0.944 0.000  0 0.056
#> SRR1179121     1   0.156      0.750 0.944 0.000  0 0.056
#> SRR1179122     1   0.156      0.750 0.944 0.000  0 0.056
#> SRR1179123     1   0.156      0.750 0.944 0.000  0 0.056
#> SRR1179124     1   0.156      0.750 0.944 0.000  0 0.056
#> SRR1179125     1   0.156      0.750 0.944 0.000  0 0.056
#> SRR1179126     1   0.156      0.750 0.944 0.000  0 0.056
#> SRR1179127     1   0.479      0.764 0.620 0.000  0 0.380
#> SRR1179128     1   0.479      0.764 0.620 0.000  0 0.380
#> SRR1179129     1   0.479      0.764 0.620 0.000  0 0.380
#> SRR1179130     1   0.479      0.764 0.620 0.000  0 0.380
#> SRR1179131     1   0.479      0.764 0.620 0.000  0 0.380
#> SRR1179132     1   0.479      0.764 0.620 0.000  0 0.380
#> SRR1179134     1   0.479      0.764 0.620 0.000  0 0.380
#> SRR1179135     1   0.479      0.764 0.620 0.000  0 0.380
#> SRR1179136     1   0.479      0.764 0.620 0.000  0 0.380
#> SRR1179137     1   0.479      0.764 0.620 0.000  0 0.380
#> SRR1179138     1   0.479      0.764 0.620 0.000  0 0.380
#> SRR1179139     1   0.479      0.764 0.620 0.000  0 0.380
#> SRR1179140     1   0.479      0.764 0.620 0.000  0 0.380
#> SRR1179141     1   0.479      0.764 0.620 0.000  0 0.380

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette  p1    p2 p3    p4    p5
#> SRR1179081     3   0.000      1.000 0.0 0.000  1 0.000 0.000
#> SRR1179082     3   0.000      1.000 0.0 0.000  1 0.000 0.000
#> SRR1179083     3   0.000      1.000 0.0 0.000  1 0.000 0.000
#> SRR1179084     3   0.000      1.000 0.0 0.000  1 0.000 0.000
#> SRR1179085     3   0.000      1.000 0.0 0.000  1 0.000 0.000
#> SRR1179086     3   0.000      1.000 0.0 0.000  1 0.000 0.000
#> SRR1179087     3   0.000      1.000 0.0 0.000  1 0.000 0.000
#> SRR1179088     3   0.000      1.000 0.0 0.000  1 0.000 0.000
#> SRR1179089     3   0.000      1.000 0.0 0.000  1 0.000 0.000
#> SRR1179090     3   0.000      1.000 0.0 0.000  1 0.000 0.000
#> SRR1179091     3   0.000      1.000 0.0 0.000  1 0.000 0.000
#> SRR1179092     3   0.000      1.000 0.0 0.000  1 0.000 0.000
#> SRR1179093     3   0.000      1.000 0.0 0.000  1 0.000 0.000
#> SRR1179094     3   0.000      1.000 0.0 0.000  1 0.000 0.000
#> SRR1179095     3   0.000      1.000 0.0 0.000  1 0.000 0.000
#> SRR1179096     5   0.409      0.000 0.0 0.368  0 0.000 0.632
#> SRR1179097     2   0.000      1.000 0.0 1.000  0 0.000 0.000
#> SRR1179098     2   0.000      1.000 0.0 1.000  0 0.000 0.000
#> SRR1179099     2   0.000      1.000 0.0 1.000  0 0.000 0.000
#> SRR1179100     2   0.000      1.000 0.0 1.000  0 0.000 0.000
#> SRR1179101     2   0.000      1.000 0.0 1.000  0 0.000 0.000
#> SRR1179102     2   0.000      1.000 0.0 1.000  0 0.000 0.000
#> SRR1179103     2   0.000      1.000 0.0 1.000  0 0.000 0.000
#> SRR1179104     2   0.000      1.000 0.0 1.000  0 0.000 0.000
#> SRR1179105     2   0.000      1.000 0.0 1.000  0 0.000 0.000
#> SRR1179106     2   0.000      1.000 0.0 1.000  0 0.000 0.000
#> SRR1179107     2   0.000      1.000 0.0 1.000  0 0.000 0.000
#> SRR1179108     2   0.000      1.000 0.0 1.000  0 0.000 0.000
#> SRR1179109     2   0.000      1.000 0.0 1.000  0 0.000 0.000
#> SRR1179110     2   0.000      1.000 0.0 1.000  0 0.000 0.000
#> SRR1179111     2   0.000      1.000 0.0 1.000  0 0.000 0.000
#> SRR1179112     1   0.487      0.688 0.6 0.000  0 0.032 0.368
#> SRR1179113     1   0.487      0.688 0.6 0.000  0 0.032 0.368
#> SRR1179114     1   0.487      0.688 0.6 0.000  0 0.032 0.368
#> SRR1179115     1   0.487      0.688 0.6 0.000  0 0.032 0.368
#> SRR1179116     1   0.487      0.688 0.6 0.000  0 0.032 0.368
#> SRR1179117     1   0.487      0.688 0.6 0.000  0 0.032 0.368
#> SRR1179118     1   0.487      0.688 0.6 0.000  0 0.032 0.368
#> SRR1179119     1   0.487      0.688 0.6 0.000  0 0.032 0.368
#> SRR1179120     4   0.000      1.000 0.0 0.000  0 1.000 0.000
#> SRR1179121     4   0.000      1.000 0.0 0.000  0 1.000 0.000
#> SRR1179122     4   0.000      1.000 0.0 0.000  0 1.000 0.000
#> SRR1179123     4   0.000      1.000 0.0 0.000  0 1.000 0.000
#> SRR1179124     4   0.000      1.000 0.0 0.000  0 1.000 0.000
#> SRR1179125     4   0.000      1.000 0.0 0.000  0 1.000 0.000
#> SRR1179126     4   0.000      1.000 0.0 0.000  0 1.000 0.000
#> SRR1179127     1   0.000      0.840 1.0 0.000  0 0.000 0.000
#> SRR1179128     1   0.000      0.840 1.0 0.000  0 0.000 0.000
#> SRR1179129     1   0.000      0.840 1.0 0.000  0 0.000 0.000
#> SRR1179130     1   0.000      0.840 1.0 0.000  0 0.000 0.000
#> SRR1179131     1   0.000      0.840 1.0 0.000  0 0.000 0.000
#> SRR1179132     1   0.000      0.840 1.0 0.000  0 0.000 0.000
#> SRR1179134     1   0.000      0.840 1.0 0.000  0 0.000 0.000
#> SRR1179135     1   0.000      0.840 1.0 0.000  0 0.000 0.000
#> SRR1179136     1   0.000      0.840 1.0 0.000  0 0.000 0.000
#> SRR1179137     1   0.000      0.840 1.0 0.000  0 0.000 0.000
#> SRR1179138     1   0.000      0.840 1.0 0.000  0 0.000 0.000
#> SRR1179139     1   0.000      0.840 1.0 0.000  0 0.000 0.000
#> SRR1179140     1   0.000      0.840 1.0 0.000  0 0.000 0.000
#> SRR1179141     1   0.000      0.840 1.0 0.000  0 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
#> SRR1179081     3   0.000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1179082     3   0.000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1179083     3   0.000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1179084     3   0.000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1179085     3   0.000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1179086     3   0.000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1179087     3   0.000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1179088     3   0.000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1179089     3   0.000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1179090     3   0.000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1179091     3   0.000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1179092     3   0.000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1179093     3   0.000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1179094     3   0.000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1179095     3   0.000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1179096     6   0.026      0.000  0 0.008  0  0 0.000 0.992
#> SRR1179097     2   0.000      1.000  0 1.000  0  0 0.000 0.000
#> SRR1179098     2   0.000      1.000  0 1.000  0  0 0.000 0.000
#> SRR1179099     2   0.000      1.000  0 1.000  0  0 0.000 0.000
#> SRR1179100     2   0.000      1.000  0 1.000  0  0 0.000 0.000
#> SRR1179101     2   0.000      1.000  0 1.000  0  0 0.000 0.000
#> SRR1179102     2   0.000      1.000  0 1.000  0  0 0.000 0.000
#> SRR1179103     2   0.000      1.000  0 1.000  0  0 0.000 0.000
#> SRR1179104     2   0.000      1.000  0 1.000  0  0 0.000 0.000
#> SRR1179105     2   0.000      1.000  0 1.000  0  0 0.000 0.000
#> SRR1179106     2   0.000      1.000  0 1.000  0  0 0.000 0.000
#> SRR1179107     2   0.000      1.000  0 1.000  0  0 0.000 0.000
#> SRR1179108     2   0.000      1.000  0 1.000  0  0 0.000 0.000
#> SRR1179109     2   0.000      1.000  0 1.000  0  0 0.000 0.000
#> SRR1179110     2   0.000      1.000  0 1.000  0  0 0.000 0.000
#> SRR1179111     2   0.000      1.000  0 1.000  0  0 0.000 0.000
#> SRR1179112     1   0.000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1179113     1   0.000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1179114     1   0.000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1179115     1   0.000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1179116     1   0.000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1179117     1   0.000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1179118     1   0.000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1179119     1   0.000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1179120     4   0.000      1.000  0 0.000  0  1 0.000 0.000
#> SRR1179121     4   0.000      1.000  0 0.000  0  1 0.000 0.000
#> SRR1179122     4   0.000      1.000  0 0.000  0  1 0.000 0.000
#> SRR1179123     4   0.000      1.000  0 0.000  0  1 0.000 0.000
#> SRR1179124     4   0.000      1.000  0 0.000  0  1 0.000 0.000
#> SRR1179125     4   0.000      1.000  0 0.000  0  1 0.000 0.000
#> SRR1179126     4   0.000      1.000  0 0.000  0  1 0.000 0.000
#> SRR1179127     5   0.026      0.996  0 0.000  0  0 0.992 0.008
#> SRR1179128     5   0.026      0.996  0 0.000  0  0 0.992 0.008
#> SRR1179129     5   0.026      0.996  0 0.000  0  0 0.992 0.008
#> SRR1179130     5   0.026      0.996  0 0.000  0  0 0.992 0.008
#> SRR1179131     5   0.026      0.996  0 0.000  0  0 0.992 0.008
#> SRR1179132     5   0.026      0.996  0 0.000  0  0 0.992 0.008
#> SRR1179134     5   0.026      0.996  0 0.000  0  0 0.992 0.008
#> SRR1179135     5   0.000      0.996  0 0.000  0  0 1.000 0.000
#> SRR1179136     5   0.000      0.996  0 0.000  0  0 1.000 0.000
#> SRR1179137     5   0.000      0.996  0 0.000  0  0 1.000 0.000
#> SRR1179138     5   0.000      0.996  0 0.000  0  0 1.000 0.000
#> SRR1179139     5   0.000      0.996  0 0.000  0  0 1.000 0.000
#> SRR1179140     5   0.000      0.996  0 0.000  0  0 1.000 0.000
#> SRR1179141     5   0.000      0.996  0 0.000  0  0 1.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 0.686           0.806       0.789         0.2324 1.000   1.000
#> 4 4 0.654           0.641       0.693         0.1068 0.777   0.548
#> 5 5 0.610           0.808       0.698         0.0707 0.941   0.780
#> 6 6 0.758           0.723       0.718         0.0513 0.941   0.780

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
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2 p3
#> SRR1179081     2  0.6286      0.775 0.000 0.536 NA
#> SRR1179082     2  0.6286      0.775 0.000 0.536 NA
#> SRR1179083     2  0.6286      0.775 0.000 0.536 NA
#> SRR1179084     2  0.6286      0.775 0.000 0.536 NA
#> SRR1179085     2  0.6286      0.775 0.000 0.536 NA
#> SRR1179086     2  0.6286      0.775 0.000 0.536 NA
#> SRR1179087     2  0.6286      0.775 0.000 0.536 NA
#> SRR1179088     2  0.6286      0.775 0.000 0.536 NA
#> SRR1179089     2  0.6286      0.775 0.000 0.536 NA
#> SRR1179090     2  0.6286      0.775 0.000 0.536 NA
#> SRR1179091     2  0.6286      0.775 0.000 0.536 NA
#> SRR1179092     2  0.6286      0.775 0.000 0.536 NA
#> SRR1179093     2  0.6286      0.775 0.000 0.536 NA
#> SRR1179094     2  0.6286      0.775 0.000 0.536 NA
#> SRR1179095     2  0.6286      0.775 0.000 0.536 NA
#> SRR1179096     2  0.0237      0.788 0.000 0.996 NA
#> SRR1179097     2  0.0000      0.791 0.000 1.000 NA
#> SRR1179098     2  0.0000      0.791 0.000 1.000 NA
#> SRR1179099     2  0.0000      0.791 0.000 1.000 NA
#> SRR1179100     2  0.0000      0.791 0.000 1.000 NA
#> SRR1179101     2  0.0000      0.791 0.000 1.000 NA
#> SRR1179102     2  0.0000      0.791 0.000 1.000 NA
#> SRR1179103     2  0.0000      0.791 0.000 1.000 NA
#> SRR1179104     2  0.0000      0.791 0.000 1.000 NA
#> SRR1179105     2  0.0000      0.791 0.000 1.000 NA
#> SRR1179106     2  0.0000      0.791 0.000 1.000 NA
#> SRR1179107     2  0.0000      0.791 0.000 1.000 NA
#> SRR1179108     2  0.0000      0.791 0.000 1.000 NA
#> SRR1179109     2  0.0000      0.791 0.000 1.000 NA
#> SRR1179110     2  0.0000      0.791 0.000 1.000 NA
#> SRR1179111     2  0.0000      0.791 0.000 1.000 NA
#> SRR1179112     1  0.6095      0.842 0.608 0.000 NA
#> SRR1179113     1  0.6095      0.842 0.608 0.000 NA
#> SRR1179114     1  0.6095      0.842 0.608 0.000 NA
#> SRR1179115     1  0.6095      0.842 0.608 0.000 NA
#> SRR1179116     1  0.6095      0.842 0.608 0.000 NA
#> SRR1179117     1  0.6095      0.842 0.608 0.000 NA
#> SRR1179118     1  0.6095      0.842 0.608 0.000 NA
#> SRR1179119     1  0.6095      0.842 0.608 0.000 NA
#> SRR1179120     1  0.0000      0.786 1.000 0.000 NA
#> SRR1179121     1  0.0000      0.786 1.000 0.000 NA
#> SRR1179122     1  0.0000      0.786 1.000 0.000 NA
#> SRR1179123     1  0.0000      0.786 1.000 0.000 NA
#> SRR1179124     1  0.0000      0.786 1.000 0.000 NA
#> SRR1179125     1  0.0000      0.786 1.000 0.000 NA
#> SRR1179126     1  0.0000      0.786 1.000 0.000 NA
#> SRR1179127     1  0.5431      0.849 0.716 0.000 NA
#> SRR1179128     1  0.5431      0.849 0.716 0.000 NA
#> SRR1179129     1  0.5431      0.849 0.716 0.000 NA
#> SRR1179130     1  0.5431      0.849 0.716 0.000 NA
#> SRR1179131     1  0.5431      0.849 0.716 0.000 NA
#> SRR1179132     1  0.5431      0.849 0.716 0.000 NA
#> SRR1179134     1  0.5431      0.849 0.716 0.000 NA
#> SRR1179135     1  0.6295      0.846 0.528 0.000 NA
#> SRR1179136     1  0.6295      0.846 0.528 0.000 NA
#> SRR1179137     1  0.6295      0.846 0.528 0.000 NA
#> SRR1179138     1  0.6295      0.846 0.528 0.000 NA
#> SRR1179139     1  0.6295      0.846 0.528 0.000 NA
#> SRR1179140     1  0.6295      0.846 0.528 0.000 NA
#> SRR1179141     1  0.6295      0.846 0.528 0.000 NA

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1179081     3  0.6258      0.932 0.000 0.324 0.600 0.076
#> SRR1179082     3  0.6197      0.933 0.000 0.324 0.604 0.072
#> SRR1179083     3  0.5936      0.938 0.000 0.324 0.620 0.056
#> SRR1179084     3  0.6197      0.933 0.000 0.324 0.604 0.072
#> SRR1179085     3  0.5866      0.938 0.000 0.324 0.624 0.052
#> SRR1179086     3  0.5936      0.938 0.000 0.324 0.620 0.056
#> SRR1179087     3  0.6071      0.935 0.000 0.324 0.612 0.064
#> SRR1179088     3  0.6197      0.933 0.000 0.324 0.604 0.072
#> SRR1179089     3  0.5866      0.935 0.000 0.324 0.624 0.052
#> SRR1179090     3  0.5090      0.942 0.000 0.324 0.660 0.016
#> SRR1179091     3  0.5866      0.935 0.000 0.324 0.624 0.052
#> SRR1179092     3  0.5866      0.935 0.000 0.324 0.624 0.052
#> SRR1179093     3  0.5866      0.935 0.000 0.324 0.624 0.052
#> SRR1179094     3  0.5866      0.935 0.000 0.324 0.624 0.052
#> SRR1179095     3  0.5473      0.942 0.000 0.324 0.644 0.032
#> SRR1179096     2  0.2469      0.863 0.000 0.892 0.000 0.108
#> SRR1179097     2  0.0188      0.954 0.000 0.996 0.000 0.004
#> SRR1179098     2  0.0188      0.954 0.000 0.996 0.000 0.004
#> SRR1179099     2  0.0188      0.954 0.000 0.996 0.000 0.004
#> SRR1179100     2  0.0188      0.954 0.000 0.996 0.000 0.004
#> SRR1179101     2  0.0188      0.954 0.000 0.996 0.000 0.004
#> SRR1179102     2  0.0188      0.954 0.000 0.996 0.000 0.004
#> SRR1179103     2  0.0188      0.954 0.000 0.996 0.000 0.004
#> SRR1179104     2  0.1792      0.952 0.000 0.932 0.000 0.068
#> SRR1179105     2  0.1792      0.952 0.000 0.932 0.000 0.068
#> SRR1179106     2  0.1792      0.952 0.000 0.932 0.000 0.068
#> SRR1179107     2  0.1557      0.955 0.000 0.944 0.000 0.056
#> SRR1179108     2  0.1557      0.955 0.000 0.944 0.000 0.056
#> SRR1179109     2  0.1557      0.955 0.000 0.944 0.000 0.056
#> SRR1179110     2  0.1792      0.952 0.000 0.932 0.000 0.068
#> SRR1179111     2  0.1557      0.955 0.000 0.944 0.000 0.056
#> SRR1179112     1  0.0000      0.352 1.000 0.000 0.000 0.000
#> SRR1179113     1  0.0000      0.352 1.000 0.000 0.000 0.000
#> SRR1179114     1  0.0000      0.352 1.000 0.000 0.000 0.000
#> SRR1179115     1  0.0000      0.352 1.000 0.000 0.000 0.000
#> SRR1179116     1  0.0000      0.352 1.000 0.000 0.000 0.000
#> SRR1179117     1  0.0000      0.352 1.000 0.000 0.000 0.000
#> SRR1179118     1  0.0000      0.352 1.000 0.000 0.000 0.000
#> SRR1179119     1  0.0000      0.352 1.000 0.000 0.000 0.000
#> SRR1179120     1  0.7660      0.189 0.452 0.000 0.232 0.316
#> SRR1179121     1  0.7660      0.189 0.452 0.000 0.232 0.316
#> SRR1179122     1  0.7660      0.189 0.452 0.000 0.232 0.316
#> SRR1179123     1  0.7660      0.189 0.452 0.000 0.232 0.316
#> SRR1179124     1  0.7660      0.189 0.452 0.000 0.232 0.316
#> SRR1179125     1  0.7660      0.189 0.452 0.000 0.232 0.316
#> SRR1179126     1  0.7689      0.184 0.452 0.000 0.248 0.300
#> SRR1179127     4  0.4994      1.000 0.480 0.000 0.000 0.520
#> SRR1179128     4  0.4994      1.000 0.480 0.000 0.000 0.520
#> SRR1179129     4  0.4994      1.000 0.480 0.000 0.000 0.520
#> SRR1179130     4  0.4994      1.000 0.480 0.000 0.000 0.520
#> SRR1179131     4  0.4994      1.000 0.480 0.000 0.000 0.520
#> SRR1179132     4  0.4994      1.000 0.480 0.000 0.000 0.520
#> SRR1179134     4  0.4994      1.000 0.480 0.000 0.000 0.520
#> SRR1179135     1  0.6369     -0.272 0.572 0.000 0.076 0.352
#> SRR1179136     1  0.6369     -0.272 0.572 0.000 0.076 0.352
#> SRR1179137     1  0.6369     -0.272 0.572 0.000 0.076 0.352
#> SRR1179138     1  0.6369     -0.272 0.572 0.000 0.076 0.352
#> SRR1179139     1  0.6369     -0.272 0.572 0.000 0.076 0.352
#> SRR1179140     1  0.6369     -0.272 0.572 0.000 0.076 0.352
#> SRR1179141     1  0.6369     -0.272 0.572 0.000 0.076 0.352

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1179081     3  0.2879      0.883 0.000 0.000 0.868 0.032 0.100
#> SRR1179082     3  0.3409      0.909 0.000 0.000 0.836 0.112 0.052
#> SRR1179083     3  0.3037      0.913 0.000 0.000 0.860 0.100 0.040
#> SRR1179084     3  0.3409      0.909 0.000 0.000 0.836 0.112 0.052
#> SRR1179085     3  0.3058      0.914 0.000 0.000 0.860 0.096 0.044
#> SRR1179086     3  0.3037      0.913 0.000 0.000 0.860 0.100 0.040
#> SRR1179087     3  0.3289      0.910 0.000 0.000 0.844 0.108 0.048
#> SRR1179088     3  0.3409      0.909 0.000 0.000 0.836 0.112 0.052
#> SRR1179089     3  0.0992      0.909 0.000 0.000 0.968 0.008 0.024
#> SRR1179090     3  0.0290      0.916 0.000 0.000 0.992 0.008 0.000
#> SRR1179091     3  0.0992      0.909 0.000 0.000 0.968 0.008 0.024
#> SRR1179092     3  0.0798      0.912 0.000 0.000 0.976 0.008 0.016
#> SRR1179093     3  0.0671      0.912 0.000 0.000 0.980 0.004 0.016
#> SRR1179094     3  0.0992      0.909 0.000 0.000 0.968 0.008 0.024
#> SRR1179095     3  0.1522      0.919 0.000 0.000 0.944 0.044 0.012
#> SRR1179096     2  0.7458      0.715 0.000 0.532 0.188 0.136 0.144
#> SRR1179097     2  0.3039      0.914 0.000 0.808 0.192 0.000 0.000
#> SRR1179098     2  0.3039      0.914 0.000 0.808 0.192 0.000 0.000
#> SRR1179099     2  0.3039      0.914 0.000 0.808 0.192 0.000 0.000
#> SRR1179100     2  0.3039      0.914 0.000 0.808 0.192 0.000 0.000
#> SRR1179101     2  0.3039      0.914 0.000 0.808 0.192 0.000 0.000
#> SRR1179102     2  0.3039      0.914 0.000 0.808 0.192 0.000 0.000
#> SRR1179103     2  0.3039      0.914 0.000 0.808 0.192 0.000 0.000
#> SRR1179104     2  0.6164      0.905 0.000 0.644 0.192 0.120 0.044
#> SRR1179105     2  0.6164      0.905 0.000 0.644 0.192 0.120 0.044
#> SRR1179106     2  0.6164      0.905 0.000 0.644 0.192 0.120 0.044
#> SRR1179107     2  0.5655      0.915 0.000 0.684 0.192 0.088 0.036
#> SRR1179108     2  0.5655      0.915 0.000 0.684 0.192 0.088 0.036
#> SRR1179109     2  0.5655      0.915 0.000 0.684 0.192 0.088 0.036
#> SRR1179110     2  0.6164      0.905 0.000 0.644 0.192 0.120 0.044
#> SRR1179111     2  0.5655      0.915 0.000 0.684 0.192 0.088 0.036
#> SRR1179112     1  0.1026      0.572 0.968 0.024 0.000 0.004 0.004
#> SRR1179113     1  0.0000      0.589 1.000 0.000 0.000 0.000 0.000
#> SRR1179114     1  0.0000      0.589 1.000 0.000 0.000 0.000 0.000
#> SRR1179115     1  0.0000      0.589 1.000 0.000 0.000 0.000 0.000
#> SRR1179116     1  0.0000      0.589 1.000 0.000 0.000 0.000 0.000
#> SRR1179117     1  0.0000      0.589 1.000 0.000 0.000 0.000 0.000
#> SRR1179118     1  0.0000      0.589 1.000 0.000 0.000 0.000 0.000
#> SRR1179119     1  0.0000      0.589 1.000 0.000 0.000 0.000 0.000
#> SRR1179120     4  0.6138      0.990 0.272 0.000 0.000 0.552 0.176
#> SRR1179121     4  0.6138      0.990 0.272 0.000 0.000 0.552 0.176
#> SRR1179122     4  0.6285      0.988 0.272 0.004 0.000 0.548 0.176
#> SRR1179123     4  0.6138      0.990 0.272 0.000 0.000 0.552 0.176
#> SRR1179124     4  0.6138      0.990 0.272 0.000 0.000 0.552 0.176
#> SRR1179125     4  0.6285      0.988 0.272 0.004 0.000 0.548 0.176
#> SRR1179126     4  0.7089      0.944 0.272 0.036 0.000 0.496 0.196
#> SRR1179127     5  0.4101      1.000 0.372 0.000 0.000 0.000 0.628
#> SRR1179128     5  0.4101      1.000 0.372 0.000 0.000 0.000 0.628
#> SRR1179129     5  0.4101      1.000 0.372 0.000 0.000 0.000 0.628
#> SRR1179130     5  0.4101      1.000 0.372 0.000 0.000 0.000 0.628
#> SRR1179131     5  0.4101      1.000 0.372 0.000 0.000 0.000 0.628
#> SRR1179132     5  0.4101      1.000 0.372 0.000 0.000 0.000 0.628
#> SRR1179134     5  0.4101      1.000 0.372 0.000 0.000 0.000 0.628
#> SRR1179135     1  0.7127      0.269 0.508 0.112 0.000 0.076 0.304
#> SRR1179136     1  0.7088      0.271 0.508 0.124 0.000 0.064 0.304
#> SRR1179137     1  0.7088      0.271 0.508 0.124 0.000 0.064 0.304
#> SRR1179138     1  0.7088      0.271 0.508 0.124 0.000 0.064 0.304
#> SRR1179139     1  0.7127      0.269 0.508 0.112 0.000 0.076 0.304
#> SRR1179140     1  0.7088      0.271 0.508 0.124 0.000 0.064 0.304
#> SRR1179141     1  0.7142      0.265 0.508 0.104 0.000 0.084 0.304

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4 p5 p6
#> SRR1179081     3  0.6645      0.779 0.012 0.076 0.520 0.000 NA NA
#> SRR1179082     3  0.2002      0.847 0.004 0.076 0.908 0.000 NA NA
#> SRR1179083     3  0.2257      0.851 0.012 0.076 0.900 0.000 NA NA
#> SRR1179084     3  0.1858      0.847 0.000 0.076 0.912 0.000 NA NA
#> SRR1179085     3  0.2265      0.854 0.004 0.076 0.896 0.000 NA NA
#> SRR1179086     3  0.2269      0.850 0.008 0.076 0.900 0.000 NA NA
#> SRR1179087     3  0.1644      0.849 0.004 0.076 0.920 0.000 NA NA
#> SRR1179088     3  0.1858      0.847 0.000 0.076 0.912 0.000 NA NA
#> SRR1179089     3  0.4989      0.844 0.004 0.076 0.592 0.000 NA NA
#> SRR1179090     3  0.5186      0.856 0.016 0.076 0.648 0.000 NA NA
#> SRR1179091     3  0.4868      0.843 0.000 0.076 0.592 0.000 NA NA
#> SRR1179092     3  0.5092      0.843 0.000 0.076 0.588 0.000 NA NA
#> SRR1179093     3  0.5274      0.846 0.008 0.076 0.596 0.000 NA NA
#> SRR1179094     3  0.4868      0.843 0.000 0.076 0.592 0.000 NA NA
#> SRR1179095     3  0.4650      0.858 0.008 0.076 0.684 0.000 NA NA
#> SRR1179096     2  0.6153      0.626 0.076 0.576 0.004 0.000 NA NA
#> SRR1179097     2  0.0000      0.863 0.000 1.000 0.000 0.000 NA NA
#> SRR1179098     2  0.0000      0.863 0.000 1.000 0.000 0.000 NA NA
#> SRR1179099     2  0.0000      0.863 0.000 1.000 0.000 0.000 NA NA
#> SRR1179100     2  0.0000      0.863 0.000 1.000 0.000 0.000 NA NA
#> SRR1179101     2  0.0000      0.863 0.000 1.000 0.000 0.000 NA NA
#> SRR1179102     2  0.0000      0.863 0.000 1.000 0.000 0.000 NA NA
#> SRR1179103     2  0.0000      0.863 0.000 1.000 0.000 0.000 NA NA
#> SRR1179104     2  0.4023      0.860 0.016 0.724 0.000 0.000 NA NA
#> SRR1179105     2  0.3665      0.861 0.000 0.728 0.000 0.000 NA NA
#> SRR1179106     2  0.3863      0.861 0.008 0.728 0.000 0.000 NA NA
#> SRR1179107     2  0.3488      0.870 0.004 0.764 0.000 0.000 NA NA
#> SRR1179108     2  0.3568      0.870 0.008 0.764 0.000 0.000 NA NA
#> SRR1179109     2  0.3488      0.870 0.004 0.764 0.000 0.000 NA NA
#> SRR1179110     2  0.3934      0.861 0.012 0.728 0.000 0.000 NA NA
#> SRR1179111     2  0.3488      0.870 0.004 0.764 0.000 0.000 NA NA
#> SRR1179112     1  0.8019      0.480 0.280 0.000 0.016 0.192 NA NA
#> SRR1179113     1  0.7676      0.492 0.288 0.000 0.000 0.192 NA NA
#> SRR1179114     1  0.7877      0.492 0.288 0.000 0.008 0.192 NA NA
#> SRR1179115     1  0.7676      0.492 0.288 0.000 0.000 0.192 NA NA
#> SRR1179116     1  0.7877      0.492 0.288 0.000 0.008 0.192 NA NA
#> SRR1179117     1  0.7877      0.492 0.288 0.000 0.008 0.192 NA NA
#> SRR1179118     1  0.7676      0.492 0.288 0.000 0.000 0.192 NA NA
#> SRR1179119     1  0.7676      0.492 0.288 0.000 0.000 0.192 NA NA
#> SRR1179120     4  0.0000      0.987 0.000 0.000 0.000 1.000 NA NA
#> SRR1179121     4  0.0000      0.987 0.000 0.000 0.000 1.000 NA NA
#> SRR1179122     4  0.0000      0.987 0.000 0.000 0.000 1.000 NA NA
#> SRR1179123     4  0.0146      0.986 0.000 0.000 0.000 0.996 NA NA
#> SRR1179124     4  0.0146      0.986 0.000 0.000 0.000 0.996 NA NA
#> SRR1179125     4  0.0000      0.987 0.000 0.000 0.000 1.000 NA NA
#> SRR1179126     4  0.2001      0.929 0.000 0.000 0.020 0.920 NA NA
#> SRR1179127     1  0.3852      0.362 0.664 0.000 0.012 0.324 NA NA
#> SRR1179128     1  0.3652      0.363 0.672 0.000 0.004 0.324 NA NA
#> SRR1179129     1  0.3938      0.362 0.660 0.000 0.016 0.324 NA NA
#> SRR1179130     1  0.3515      0.363 0.676 0.000 0.000 0.324 NA NA
#> SRR1179131     1  0.3938      0.362 0.660 0.000 0.016 0.324 NA NA
#> SRR1179132     1  0.3515      0.363 0.676 0.000 0.000 0.324 NA NA
#> SRR1179134     1  0.3515      0.363 0.676 0.000 0.000 0.324 NA NA
#> SRR1179135     1  0.5630      0.549 0.536 0.000 0.008 0.136 NA NA
#> SRR1179136     1  0.5421      0.549 0.536 0.000 0.000 0.136 NA NA
#> SRR1179137     1  0.5421      0.549 0.536 0.000 0.000 0.136 NA NA
#> SRR1179138     1  0.5431      0.549 0.532 0.000 0.000 0.136 NA NA
#> SRR1179139     1  0.5642      0.548 0.532 0.000 0.008 0.136 NA NA
#> SRR1179140     1  0.5421      0.549 0.536 0.000 0.000 0.136 NA NA
#> SRR1179141     1  0.5741      0.548 0.524 0.000 0.012 0.136 NA NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-kmeans-collect-classes

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

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 1.000           0.998       0.994         0.2650 0.864   0.724
#> 4 4 0.850           0.947       0.955         0.1449 0.913   0.756
#> 5 5 0.901           0.869       0.880         0.0505 1.000   1.000
#> 6 6 0.916           0.818       0.874         0.0388 0.928   0.734

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1179081     3  0.0747      1.000 0.000 0.016 0.984
#> SRR1179082     3  0.0747      1.000 0.000 0.016 0.984
#> SRR1179083     3  0.0747      1.000 0.000 0.016 0.984
#> SRR1179084     3  0.0747      1.000 0.000 0.016 0.984
#> SRR1179085     3  0.0747      1.000 0.000 0.016 0.984
#> SRR1179086     3  0.0747      1.000 0.000 0.016 0.984
#> SRR1179087     3  0.0747      1.000 0.000 0.016 0.984
#> SRR1179088     3  0.0747      1.000 0.000 0.016 0.984
#> SRR1179089     3  0.0747      1.000 0.000 0.016 0.984
#> SRR1179090     3  0.0747      1.000 0.000 0.016 0.984
#> SRR1179091     3  0.0747      1.000 0.000 0.016 0.984
#> SRR1179092     3  0.0747      1.000 0.000 0.016 0.984
#> SRR1179093     3  0.0747      1.000 0.000 0.016 0.984
#> SRR1179094     3  0.0747      1.000 0.000 0.016 0.984
#> SRR1179095     3  0.0747      1.000 0.000 0.016 0.984
#> SRR1179096     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179097     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179098     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179099     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179100     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179101     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179102     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179103     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179104     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179105     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179106     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179107     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179108     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179109     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179110     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179111     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179112     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179113     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179114     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179115     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179116     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179117     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179118     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179119     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179120     1  0.0747      0.990 0.984 0.000 0.016
#> SRR1179121     1  0.0747      0.990 0.984 0.000 0.016
#> SRR1179122     1  0.0747      0.990 0.984 0.000 0.016
#> SRR1179123     1  0.0747      0.990 0.984 0.000 0.016
#> SRR1179124     1  0.0747      0.990 0.984 0.000 0.016
#> SRR1179125     1  0.0747      0.990 0.984 0.000 0.016
#> SRR1179126     1  0.0747      0.990 0.984 0.000 0.016
#> SRR1179127     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179128     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179129     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179130     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179131     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179132     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179134     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179135     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179136     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179137     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179138     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179139     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179140     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179141     1  0.0000      0.997 1.000 0.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
#> SRR1179081     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179082     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179083     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179084     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179085     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179086     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179087     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179088     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179089     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179090     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179091     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179092     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179093     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179094     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179095     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1179096     2   0.112      0.970 0.000 0.964  0 0.036
#> SRR1179097     2   0.000      0.998 0.000 1.000  0 0.000
#> SRR1179098     2   0.000      0.998 0.000 1.000  0 0.000
#> SRR1179099     2   0.000      0.998 0.000 1.000  0 0.000
#> SRR1179100     2   0.000      0.998 0.000 1.000  0 0.000
#> SRR1179101     2   0.000      0.998 0.000 1.000  0 0.000
#> SRR1179102     2   0.000      0.998 0.000 1.000  0 0.000
#> SRR1179103     2   0.000      0.998 0.000 1.000  0 0.000
#> SRR1179104     2   0.000      0.998 0.000 1.000  0 0.000
#> SRR1179105     2   0.000      0.998 0.000 1.000  0 0.000
#> SRR1179106     2   0.000      0.998 0.000 1.000  0 0.000
#> SRR1179107     2   0.000      0.998 0.000 1.000  0 0.000
#> SRR1179108     2   0.000      0.998 0.000 1.000  0 0.000
#> SRR1179109     2   0.000      0.998 0.000 1.000  0 0.000
#> SRR1179110     2   0.000      0.998 0.000 1.000  0 0.000
#> SRR1179111     2   0.000      0.998 0.000 1.000  0 0.000
#> SRR1179112     1   0.307      0.850 0.848 0.000  0 0.152
#> SRR1179113     1   0.307      0.850 0.848 0.000  0 0.152
#> SRR1179114     1   0.307      0.850 0.848 0.000  0 0.152
#> SRR1179115     1   0.307      0.850 0.848 0.000  0 0.152
#> SRR1179116     1   0.307      0.850 0.848 0.000  0 0.152
#> SRR1179117     1   0.307      0.850 0.848 0.000  0 0.152
#> SRR1179118     1   0.307      0.850 0.848 0.000  0 0.152
#> SRR1179119     1   0.307      0.850 0.848 0.000  0 0.152
#> SRR1179120     4   0.121      1.000 0.040 0.000  0 0.960
#> SRR1179121     4   0.121      1.000 0.040 0.000  0 0.960
#> SRR1179122     4   0.121      1.000 0.040 0.000  0 0.960
#> SRR1179123     4   0.121      1.000 0.040 0.000  0 0.960
#> SRR1179124     4   0.121      1.000 0.040 0.000  0 0.960
#> SRR1179125     4   0.121      1.000 0.040 0.000  0 0.960
#> SRR1179126     4   0.121      1.000 0.040 0.000  0 0.960
#> SRR1179127     1   0.292      0.845 0.860 0.000  0 0.140
#> SRR1179128     1   0.292      0.845 0.860 0.000  0 0.140
#> SRR1179129     1   0.292      0.845 0.860 0.000  0 0.140
#> SRR1179130     1   0.292      0.845 0.860 0.000  0 0.140
#> SRR1179131     1   0.292      0.845 0.860 0.000  0 0.140
#> SRR1179132     1   0.292      0.845 0.860 0.000  0 0.140
#> SRR1179134     1   0.292      0.845 0.860 0.000  0 0.140
#> SRR1179135     1   0.000      0.879 1.000 0.000  0 0.000
#> SRR1179136     1   0.000      0.879 1.000 0.000  0 0.000
#> SRR1179137     1   0.000      0.879 1.000 0.000  0 0.000
#> SRR1179138     1   0.000      0.879 1.000 0.000  0 0.000
#> SRR1179139     1   0.000      0.879 1.000 0.000  0 0.000
#> SRR1179140     1   0.000      0.879 1.000 0.000  0 0.000
#> SRR1179141     1   0.000      0.879 1.000 0.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3    p4 p5
#> SRR1179081     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> SRR1179082     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> SRR1179083     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> SRR1179084     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> SRR1179085     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> SRR1179086     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> SRR1179087     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> SRR1179088     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> SRR1179089     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> SRR1179090     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> SRR1179091     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> SRR1179092     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> SRR1179093     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> SRR1179094     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> SRR1179095     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> SRR1179096     2  0.4114      0.601 0.000 0.624  0 0.000 NA
#> SRR1179097     2  0.0162      0.977 0.000 0.996  0 0.000 NA
#> SRR1179098     2  0.0162      0.977 0.000 0.996  0 0.000 NA
#> SRR1179099     2  0.0162      0.977 0.000 0.996  0 0.000 NA
#> SRR1179100     2  0.0162      0.977 0.000 0.996  0 0.000 NA
#> SRR1179101     2  0.0162      0.977 0.000 0.996  0 0.000 NA
#> SRR1179102     2  0.0162      0.977 0.000 0.996  0 0.000 NA
#> SRR1179103     2  0.0162      0.977 0.000 0.996  0 0.000 NA
#> SRR1179104     2  0.0000      0.977 0.000 1.000  0 0.000 NA
#> SRR1179105     2  0.0000      0.977 0.000 1.000  0 0.000 NA
#> SRR1179106     2  0.0000      0.977 0.000 1.000  0 0.000 NA
#> SRR1179107     2  0.0000      0.977 0.000 1.000  0 0.000 NA
#> SRR1179108     2  0.0000      0.977 0.000 1.000  0 0.000 NA
#> SRR1179109     2  0.0000      0.977 0.000 1.000  0 0.000 NA
#> SRR1179110     2  0.0000      0.977 0.000 1.000  0 0.000 NA
#> SRR1179111     2  0.0000      0.977 0.000 1.000  0 0.000 NA
#> SRR1179112     1  0.4640      0.711 0.696 0.000  0 0.048 NA
#> SRR1179113     1  0.4640      0.711 0.696 0.000  0 0.048 NA
#> SRR1179114     1  0.4640      0.711 0.696 0.000  0 0.048 NA
#> SRR1179115     1  0.4640      0.711 0.696 0.000  0 0.048 NA
#> SRR1179116     1  0.4640      0.711 0.696 0.000  0 0.048 NA
#> SRR1179117     1  0.4640      0.711 0.696 0.000  0 0.048 NA
#> SRR1179118     1  0.4640      0.711 0.696 0.000  0 0.048 NA
#> SRR1179119     1  0.4640      0.711 0.696 0.000  0 0.048 NA
#> SRR1179120     4  0.0000      1.000 0.000 0.000  0 1.000 NA
#> SRR1179121     4  0.0000      1.000 0.000 0.000  0 1.000 NA
#> SRR1179122     4  0.0000      1.000 0.000 0.000  0 1.000 NA
#> SRR1179123     4  0.0000      1.000 0.000 0.000  0 1.000 NA
#> SRR1179124     4  0.0000      1.000 0.000 0.000  0 1.000 NA
#> SRR1179125     4  0.0000      1.000 0.000 0.000  0 1.000 NA
#> SRR1179126     4  0.0000      1.000 0.000 0.000  0 1.000 NA
#> SRR1179127     1  0.5542      0.581 0.500 0.000  0 0.068 NA
#> SRR1179128     1  0.5542      0.581 0.500 0.000  0 0.068 NA
#> SRR1179129     1  0.5542      0.581 0.500 0.000  0 0.068 NA
#> SRR1179130     1  0.5542      0.581 0.500 0.000  0 0.068 NA
#> SRR1179131     1  0.5542      0.581 0.500 0.000  0 0.068 NA
#> SRR1179132     1  0.5542      0.581 0.500 0.000  0 0.068 NA
#> SRR1179134     1  0.5542      0.581 0.500 0.000  0 0.068 NA
#> SRR1179135     1  0.0000      0.733 1.000 0.000  0 0.000 NA
#> SRR1179136     1  0.0000      0.733 1.000 0.000  0 0.000 NA
#> SRR1179137     1  0.0000      0.733 1.000 0.000  0 0.000 NA
#> SRR1179138     1  0.0000      0.733 1.000 0.000  0 0.000 NA
#> SRR1179139     1  0.0000      0.733 1.000 0.000  0 0.000 NA
#> SRR1179140     1  0.0000      0.733 1.000 0.000  0 0.000 NA
#> SRR1179141     1  0.0000      0.733 1.000 0.000  0 0.000 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3    p4    p5    p6
#> SRR1179081     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179082     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179083     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179084     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179085     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179086     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179087     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179088     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179089     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179090     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179091     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179092     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179093     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179094     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179095     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179096     6  0.3050      0.000 0.000 0.236  0 0.000 0.000 0.764
#> SRR1179097     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179098     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179099     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179100     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179101     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179102     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179103     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179104     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179105     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179106     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179107     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179108     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179109     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179110     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179111     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179112     1  0.0993      0.959 0.964 0.000  0 0.012 0.024 0.000
#> SRR1179113     1  0.0363      0.994 0.988 0.000  0 0.012 0.000 0.000
#> SRR1179114     1  0.0363      0.994 0.988 0.000  0 0.012 0.000 0.000
#> SRR1179115     1  0.0363      0.994 0.988 0.000  0 0.012 0.000 0.000
#> SRR1179116     1  0.0363      0.994 0.988 0.000  0 0.012 0.000 0.000
#> SRR1179117     1  0.0363      0.994 0.988 0.000  0 0.012 0.000 0.000
#> SRR1179118     1  0.0363      0.994 0.988 0.000  0 0.012 0.000 0.000
#> SRR1179119     1  0.0363      0.994 0.988 0.000  0 0.012 0.000 0.000
#> SRR1179120     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1179121     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1179122     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1179123     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1179124     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1179125     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1179126     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1179127     5  0.5237      0.437 0.120 0.000  0 0.012 0.632 0.236
#> SRR1179128     5  0.5237      0.437 0.120 0.000  0 0.012 0.632 0.236
#> SRR1179129     5  0.5237      0.437 0.120 0.000  0 0.012 0.632 0.236
#> SRR1179130     5  0.5237      0.437 0.120 0.000  0 0.012 0.632 0.236
#> SRR1179131     5  0.5237      0.437 0.120 0.000  0 0.012 0.632 0.236
#> SRR1179132     5  0.5237      0.437 0.120 0.000  0 0.012 0.632 0.236
#> SRR1179134     5  0.5237      0.437 0.120 0.000  0 0.012 0.632 0.236
#> SRR1179135     5  0.3868      0.155 0.492 0.000  0 0.000 0.508 0.000
#> SRR1179136     5  0.3868      0.155 0.492 0.000  0 0.000 0.508 0.000
#> SRR1179137     5  0.3868      0.155 0.492 0.000  0 0.000 0.508 0.000
#> SRR1179138     5  0.3868      0.155 0.492 0.000  0 0.000 0.508 0.000
#> SRR1179139     5  0.3868      0.155 0.492 0.000  0 0.000 0.508 0.000
#> SRR1179140     5  0.3868      0.155 0.492 0.000  0 0.000 0.508 0.000
#> SRR1179141     5  0.3867      0.153 0.488 0.000  0 0.000 0.512 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-skmeans-collect-classes

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

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

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 1.000           1.000       1.000         0.2664 0.864   0.724
#> 4 4 0.858           0.833       0.907         0.1613 0.905   0.734
#> 5 5 0.978           0.933       0.971         0.0669 0.930   0.737
#> 6 6 1.000           1.000       1.000         0.0299 0.963   0.824

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1179081     3       0          1  0  0  1
#> SRR1179082     3       0          1  0  0  1
#> SRR1179083     3       0          1  0  0  1
#> SRR1179084     3       0          1  0  0  1
#> SRR1179085     3       0          1  0  0  1
#> SRR1179086     3       0          1  0  0  1
#> SRR1179087     3       0          1  0  0  1
#> SRR1179088     3       0          1  0  0  1
#> SRR1179089     3       0          1  0  0  1
#> SRR1179090     3       0          1  0  0  1
#> SRR1179091     3       0          1  0  0  1
#> SRR1179092     3       0          1  0  0  1
#> SRR1179093     3       0          1  0  0  1
#> SRR1179094     3       0          1  0  0  1
#> SRR1179095     3       0          1  0  0  1
#> SRR1179096     2       0          1  0  1  0
#> SRR1179097     2       0          1  0  1  0
#> SRR1179098     2       0          1  0  1  0
#> SRR1179099     2       0          1  0  1  0
#> SRR1179100     2       0          1  0  1  0
#> SRR1179101     2       0          1  0  1  0
#> SRR1179102     2       0          1  0  1  0
#> SRR1179103     2       0          1  0  1  0
#> SRR1179104     2       0          1  0  1  0
#> SRR1179105     2       0          1  0  1  0
#> SRR1179106     2       0          1  0  1  0
#> SRR1179107     2       0          1  0  1  0
#> SRR1179108     2       0          1  0  1  0
#> SRR1179109     2       0          1  0  1  0
#> SRR1179110     2       0          1  0  1  0
#> SRR1179111     2       0          1  0  1  0
#> SRR1179112     1       0          1  1  0  0
#> SRR1179113     1       0          1  1  0  0
#> SRR1179114     1       0          1  1  0  0
#> SRR1179115     1       0          1  1  0  0
#> SRR1179116     1       0          1  1  0  0
#> SRR1179117     1       0          1  1  0  0
#> SRR1179118     1       0          1  1  0  0
#> SRR1179119     1       0          1  1  0  0
#> SRR1179120     1       0          1  1  0  0
#> SRR1179121     1       0          1  1  0  0
#> SRR1179122     1       0          1  1  0  0
#> SRR1179123     1       0          1  1  0  0
#> SRR1179124     1       0          1  1  0  0
#> SRR1179125     1       0          1  1  0  0
#> SRR1179126     1       0          1  1  0  0
#> SRR1179127     1       0          1  1  0  0
#> SRR1179128     1       0          1  1  0  0
#> SRR1179129     1       0          1  1  0  0
#> SRR1179130     1       0          1  1  0  0
#> SRR1179131     1       0          1  1  0  0
#> SRR1179132     1       0          1  1  0  0
#> SRR1179134     1       0          1  1  0  0
#> SRR1179135     1       0          1  1  0  0
#> SRR1179136     1       0          1  1  0  0
#> SRR1179137     1       0          1  1  0  0
#> SRR1179138     1       0          1  1  0  0
#> SRR1179139     1       0          1  1  0  0
#> SRR1179140     1       0          1  1  0  0
#> SRR1179141     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2 p3    p4
#> SRR1179081     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR1179082     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR1179083     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR1179084     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR1179085     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR1179086     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR1179087     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR1179088     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR1179089     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR1179090     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR1179091     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR1179092     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR1179093     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR1179094     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR1179095     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR1179096     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179097     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179098     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179099     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179100     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179101     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179102     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179103     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179104     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179105     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179106     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179107     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179108     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179109     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179110     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179111     2  0.0000     1.0000 0.000  1  0 0.000
#> SRR1179112     1  0.3688     0.6939 0.792  0  0 0.208
#> SRR1179113     1  0.3688     0.6939 0.792  0  0 0.208
#> SRR1179114     1  0.3688     0.6939 0.792  0  0 0.208
#> SRR1179115     1  0.3688     0.6939 0.792  0  0 0.208
#> SRR1179116     1  0.3688     0.6939 0.792  0  0 0.208
#> SRR1179117     1  0.3688     0.6939 0.792  0  0 0.208
#> SRR1179118     1  0.3688     0.6939 0.792  0  0 0.208
#> SRR1179119     1  0.3688     0.6939 0.792  0  0 0.208
#> SRR1179120     4  0.1716     0.7613 0.064  0  0 0.936
#> SRR1179121     4  0.1867     0.7960 0.072  0  0 0.928
#> SRR1179122     4  0.1474     0.7960 0.052  0  0 0.948
#> SRR1179123     4  0.3172     0.7303 0.160  0  0 0.840
#> SRR1179124     4  0.3356     0.7155 0.176  0  0 0.824
#> SRR1179125     4  0.1557     0.7927 0.056  0  0 0.944
#> SRR1179126     4  0.3024     0.6494 0.148  0  0 0.852
#> SRR1179127     1  0.4941     0.1030 0.564  0  0 0.436
#> SRR1179128     1  0.3219     0.7028 0.836  0  0 0.164
#> SRR1179129     1  0.4898     0.1765 0.584  0  0 0.416
#> SRR1179130     1  0.3074     0.7115 0.848  0  0 0.152
#> SRR1179131     4  0.5000     0.0316 0.496  0  0 0.504
#> SRR1179132     1  0.3219     0.7028 0.836  0  0 0.164
#> SRR1179134     1  0.3356     0.6910 0.824  0  0 0.176
#> SRR1179135     1  0.2530     0.7257 0.888  0  0 0.112
#> SRR1179136     1  0.2589     0.7302 0.884  0  0 0.116
#> SRR1179137     1  0.3024     0.7135 0.852  0  0 0.148
#> SRR1179138     1  0.3024     0.7135 0.852  0  0 0.148
#> SRR1179139     1  0.0707     0.7287 0.980  0  0 0.020
#> SRR1179140     1  0.3024     0.7135 0.852  0  0 0.148
#> SRR1179141     1  0.2921     0.7172 0.860  0  0 0.140

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2 p3 p4    p5
#> SRR1179081     3   0.000      1.000 0.000  0  1  0 0.000
#> SRR1179082     3   0.000      1.000 0.000  0  1  0 0.000
#> SRR1179083     3   0.000      1.000 0.000  0  1  0 0.000
#> SRR1179084     3   0.000      1.000 0.000  0  1  0 0.000
#> SRR1179085     3   0.000      1.000 0.000  0  1  0 0.000
#> SRR1179086     3   0.000      1.000 0.000  0  1  0 0.000
#> SRR1179087     3   0.000      1.000 0.000  0  1  0 0.000
#> SRR1179088     3   0.000      1.000 0.000  0  1  0 0.000
#> SRR1179089     3   0.000      1.000 0.000  0  1  0 0.000
#> SRR1179090     3   0.000      1.000 0.000  0  1  0 0.000
#> SRR1179091     3   0.000      1.000 0.000  0  1  0 0.000
#> SRR1179092     3   0.000      1.000 0.000  0  1  0 0.000
#> SRR1179093     3   0.000      1.000 0.000  0  1  0 0.000
#> SRR1179094     3   0.000      1.000 0.000  0  1  0 0.000
#> SRR1179095     3   0.000      1.000 0.000  0  1  0 0.000
#> SRR1179096     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179097     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179098     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179099     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179100     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179101     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179102     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179103     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179104     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179105     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179106     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179107     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179108     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179109     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179110     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179111     2   0.000      1.000 0.000  1  0  0 0.000
#> SRR1179112     1   0.000      0.860 1.000  0  0  0 0.000
#> SRR1179113     1   0.000      0.860 1.000  0  0  0 0.000
#> SRR1179114     1   0.000      0.860 1.000  0  0  0 0.000
#> SRR1179115     1   0.000      0.860 1.000  0  0  0 0.000
#> SRR1179116     1   0.000      0.860 1.000  0  0  0 0.000
#> SRR1179117     1   0.000      0.860 1.000  0  0  0 0.000
#> SRR1179118     1   0.000      0.860 1.000  0  0  0 0.000
#> SRR1179119     1   0.000      0.860 1.000  0  0  0 0.000
#> SRR1179120     4   0.000      1.000 0.000  0  0  1 0.000
#> SRR1179121     4   0.000      1.000 0.000  0  0  1 0.000
#> SRR1179122     4   0.000      1.000 0.000  0  0  1 0.000
#> SRR1179123     4   0.000      1.000 0.000  0  0  1 0.000
#> SRR1179124     4   0.000      1.000 0.000  0  0  1 0.000
#> SRR1179125     4   0.000      1.000 0.000  0  0  1 0.000
#> SRR1179126     4   0.000      1.000 0.000  0  0  1 0.000
#> SRR1179127     5   0.000      0.961 0.000  0  0  0 1.000
#> SRR1179128     5   0.000      0.961 0.000  0  0  0 1.000
#> SRR1179129     5   0.000      0.961 0.000  0  0  0 1.000
#> SRR1179130     5   0.000      0.961 0.000  0  0  0 1.000
#> SRR1179131     5   0.000      0.961 0.000  0  0  0 1.000
#> SRR1179132     5   0.000      0.961 0.000  0  0  0 1.000
#> SRR1179134     5   0.000      0.961 0.000  0  0  0 1.000
#> SRR1179135     1   0.431      0.138 0.508  0  0  0 0.492
#> SRR1179136     1   0.406      0.497 0.640  0  0  0 0.360
#> SRR1179137     5   0.173      0.889 0.080  0  0  0 0.920
#> SRR1179138     5   0.327      0.671 0.220  0  0  0 0.780
#> SRR1179139     1   0.348      0.672 0.752  0  0  0 0.248
#> SRR1179140     5   0.000      0.961 0.000  0  0  0 1.000
#> SRR1179141     1   0.397      0.534 0.664  0  0  0 0.336

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1179081     3       0          1  0  0  1  0  0  0
#> SRR1179082     3       0          1  0  0  1  0  0  0
#> SRR1179083     3       0          1  0  0  1  0  0  0
#> SRR1179084     3       0          1  0  0  1  0  0  0
#> SRR1179085     3       0          1  0  0  1  0  0  0
#> SRR1179086     3       0          1  0  0  1  0  0  0
#> SRR1179087     3       0          1  0  0  1  0  0  0
#> SRR1179088     3       0          1  0  0  1  0  0  0
#> SRR1179089     3       0          1  0  0  1  0  0  0
#> SRR1179090     3       0          1  0  0  1  0  0  0
#> SRR1179091     3       0          1  0  0  1  0  0  0
#> SRR1179092     3       0          1  0  0  1  0  0  0
#> SRR1179093     3       0          1  0  0  1  0  0  0
#> SRR1179094     3       0          1  0  0  1  0  0  0
#> SRR1179095     3       0          1  0  0  1  0  0  0
#> SRR1179096     2       0          1  0  1  0  0  0  0
#> SRR1179097     2       0          1  0  1  0  0  0  0
#> SRR1179098     2       0          1  0  1  0  0  0  0
#> SRR1179099     2       0          1  0  1  0  0  0  0
#> SRR1179100     2       0          1  0  1  0  0  0  0
#> SRR1179101     2       0          1  0  1  0  0  0  0
#> SRR1179102     2       0          1  0  1  0  0  0  0
#> SRR1179103     2       0          1  0  1  0  0  0  0
#> SRR1179104     2       0          1  0  1  0  0  0  0
#> SRR1179105     2       0          1  0  1  0  0  0  0
#> SRR1179106     2       0          1  0  1  0  0  0  0
#> SRR1179107     2       0          1  0  1  0  0  0  0
#> SRR1179108     2       0          1  0  1  0  0  0  0
#> SRR1179109     2       0          1  0  1  0  0  0  0
#> SRR1179110     2       0          1  0  1  0  0  0  0
#> SRR1179111     2       0          1  0  1  0  0  0  0
#> SRR1179112     1       0          1  1  0  0  0  0  0
#> SRR1179113     1       0          1  1  0  0  0  0  0
#> SRR1179114     1       0          1  1  0  0  0  0  0
#> SRR1179115     1       0          1  1  0  0  0  0  0
#> SRR1179116     1       0          1  1  0  0  0  0  0
#> SRR1179117     1       0          1  1  0  0  0  0  0
#> SRR1179118     1       0          1  1  0  0  0  0  0
#> SRR1179119     1       0          1  1  0  0  0  0  0
#> SRR1179120     4       0          1  0  0  0  1  0  0
#> SRR1179121     4       0          1  0  0  0  1  0  0
#> SRR1179122     4       0          1  0  0  0  1  0  0
#> SRR1179123     4       0          1  0  0  0  1  0  0
#> SRR1179124     4       0          1  0  0  0  1  0  0
#> SRR1179125     4       0          1  0  0  0  1  0  0
#> SRR1179126     4       0          1  0  0  0  1  0  0
#> SRR1179127     5       0          1  0  0  0  0  1  0
#> SRR1179128     5       0          1  0  0  0  0  1  0
#> SRR1179129     5       0          1  0  0  0  0  1  0
#> SRR1179130     5       0          1  0  0  0  0  1  0
#> SRR1179131     5       0          1  0  0  0  0  1  0
#> SRR1179132     5       0          1  0  0  0  0  1  0
#> SRR1179134     5       0          1  0  0  0  0  1  0
#> SRR1179135     6       0          1  0  0  0  0  0  1
#> SRR1179136     6       0          1  0  0  0  0  0  1
#> SRR1179137     6       0          1  0  0  0  0  0  1
#> SRR1179138     6       0          1  0  0  0  0  0  1
#> SRR1179139     6       0          1  0  0  0  0  0  1
#> SRR1179140     6       0          1  0  0  0  0  0  1
#> SRR1179141     6       0          1  0  0  0  0  0  1

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

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

collect_plots(res)

plot of chunk SD-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.602           0.864       0.896         0.4596 0.492   0.492
#> 3 3 1.000           1.000       1.000         0.4010 0.864   0.724
#> 4 4 1.000           1.000       1.000         0.1350 0.913   0.756
#> 5 5 0.943           0.954       0.964         0.0813 0.941   0.780
#> 6 6 0.951           0.976       0.954         0.0384 0.968   0.849

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1179081     2   0.184      0.768 0.028 0.972
#> SRR1179082     2   0.184      0.768 0.028 0.972
#> SRR1179083     2   0.184      0.768 0.028 0.972
#> SRR1179084     2   0.184      0.768 0.028 0.972
#> SRR1179085     2   0.184      0.768 0.028 0.972
#> SRR1179086     2   0.184      0.768 0.028 0.972
#> SRR1179087     2   0.184      0.768 0.028 0.972
#> SRR1179088     2   0.184      0.768 0.028 0.972
#> SRR1179089     2   0.184      0.768 0.028 0.972
#> SRR1179090     2   0.184      0.768 0.028 0.972
#> SRR1179091     2   0.184      0.768 0.028 0.972
#> SRR1179092     2   0.184      0.768 0.028 0.972
#> SRR1179093     2   0.184      0.768 0.028 0.972
#> SRR1179094     2   0.184      0.768 0.028 0.972
#> SRR1179095     2   0.184      0.768 0.028 0.972
#> SRR1179096     2   0.946      0.706 0.364 0.636
#> SRR1179097     2   0.946      0.706 0.364 0.636
#> SRR1179098     2   0.946      0.706 0.364 0.636
#> SRR1179099     2   0.946      0.706 0.364 0.636
#> SRR1179100     2   0.946      0.706 0.364 0.636
#> SRR1179101     2   0.946      0.706 0.364 0.636
#> SRR1179102     2   0.946      0.706 0.364 0.636
#> SRR1179103     2   0.946      0.706 0.364 0.636
#> SRR1179104     2   0.946      0.706 0.364 0.636
#> SRR1179105     2   0.946      0.706 0.364 0.636
#> SRR1179106     2   0.946      0.706 0.364 0.636
#> SRR1179107     2   0.946      0.706 0.364 0.636
#> SRR1179108     2   0.946      0.706 0.364 0.636
#> SRR1179109     2   0.946      0.706 0.364 0.636
#> SRR1179110     2   0.946      0.706 0.364 0.636
#> SRR1179111     2   0.946      0.706 0.364 0.636
#> SRR1179112     1   0.000      1.000 1.000 0.000
#> SRR1179113     1   0.000      1.000 1.000 0.000
#> SRR1179114     1   0.000      1.000 1.000 0.000
#> SRR1179115     1   0.000      1.000 1.000 0.000
#> SRR1179116     1   0.000      1.000 1.000 0.000
#> SRR1179117     1   0.000      1.000 1.000 0.000
#> SRR1179118     1   0.000      1.000 1.000 0.000
#> SRR1179119     1   0.000      1.000 1.000 0.000
#> SRR1179120     1   0.000      1.000 1.000 0.000
#> SRR1179121     1   0.000      1.000 1.000 0.000
#> SRR1179122     1   0.000      1.000 1.000 0.000
#> SRR1179123     1   0.000      1.000 1.000 0.000
#> SRR1179124     1   0.000      1.000 1.000 0.000
#> SRR1179125     1   0.000      1.000 1.000 0.000
#> SRR1179126     1   0.000      1.000 1.000 0.000
#> SRR1179127     1   0.000      1.000 1.000 0.000
#> SRR1179128     1   0.000      1.000 1.000 0.000
#> SRR1179129     1   0.000      1.000 1.000 0.000
#> SRR1179130     1   0.000      1.000 1.000 0.000
#> SRR1179131     1   0.000      1.000 1.000 0.000
#> SRR1179132     1   0.000      1.000 1.000 0.000
#> SRR1179134     1   0.000      1.000 1.000 0.000
#> SRR1179135     1   0.000      1.000 1.000 0.000
#> SRR1179136     1   0.000      1.000 1.000 0.000
#> SRR1179137     1   0.000      1.000 1.000 0.000
#> SRR1179138     1   0.000      1.000 1.000 0.000
#> SRR1179139     1   0.000      1.000 1.000 0.000
#> SRR1179140     1   0.000      1.000 1.000 0.000
#> SRR1179141     1   0.000      1.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1179081     3       0          1  0  0  1
#> SRR1179082     3       0          1  0  0  1
#> SRR1179083     3       0          1  0  0  1
#> SRR1179084     3       0          1  0  0  1
#> SRR1179085     3       0          1  0  0  1
#> SRR1179086     3       0          1  0  0  1
#> SRR1179087     3       0          1  0  0  1
#> SRR1179088     3       0          1  0  0  1
#> SRR1179089     3       0          1  0  0  1
#> SRR1179090     3       0          1  0  0  1
#> SRR1179091     3       0          1  0  0  1
#> SRR1179092     3       0          1  0  0  1
#> SRR1179093     3       0          1  0  0  1
#> SRR1179094     3       0          1  0  0  1
#> SRR1179095     3       0          1  0  0  1
#> SRR1179096     2       0          1  0  1  0
#> SRR1179097     2       0          1  0  1  0
#> SRR1179098     2       0          1  0  1  0
#> SRR1179099     2       0          1  0  1  0
#> SRR1179100     2       0          1  0  1  0
#> SRR1179101     2       0          1  0  1  0
#> SRR1179102     2       0          1  0  1  0
#> SRR1179103     2       0          1  0  1  0
#> SRR1179104     2       0          1  0  1  0
#> SRR1179105     2       0          1  0  1  0
#> SRR1179106     2       0          1  0  1  0
#> SRR1179107     2       0          1  0  1  0
#> SRR1179108     2       0          1  0  1  0
#> SRR1179109     2       0          1  0  1  0
#> SRR1179110     2       0          1  0  1  0
#> SRR1179111     2       0          1  0  1  0
#> SRR1179112     1       0          1  1  0  0
#> SRR1179113     1       0          1  1  0  0
#> SRR1179114     1       0          1  1  0  0
#> SRR1179115     1       0          1  1  0  0
#> SRR1179116     1       0          1  1  0  0
#> SRR1179117     1       0          1  1  0  0
#> SRR1179118     1       0          1  1  0  0
#> SRR1179119     1       0          1  1  0  0
#> SRR1179120     1       0          1  1  0  0
#> SRR1179121     1       0          1  1  0  0
#> SRR1179122     1       0          1  1  0  0
#> SRR1179123     1       0          1  1  0  0
#> SRR1179124     1       0          1  1  0  0
#> SRR1179125     1       0          1  1  0  0
#> SRR1179126     1       0          1  1  0  0
#> SRR1179127     1       0          1  1  0  0
#> SRR1179128     1       0          1  1  0  0
#> SRR1179129     1       0          1  1  0  0
#> SRR1179130     1       0          1  1  0  0
#> SRR1179131     1       0          1  1  0  0
#> SRR1179132     1       0          1  1  0  0
#> SRR1179134     1       0          1  1  0  0
#> SRR1179135     1       0          1  1  0  0
#> SRR1179136     1       0          1  1  0  0
#> SRR1179137     1       0          1  1  0  0
#> SRR1179138     1       0          1  1  0  0
#> SRR1179139     1       0          1  1  0  0
#> SRR1179140     1       0          1  1  0  0
#> SRR1179141     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1 p2 p3 p4
#> SRR1179081     3       0          1  0  0  1  0
#> SRR1179082     3       0          1  0  0  1  0
#> SRR1179083     3       0          1  0  0  1  0
#> SRR1179084     3       0          1  0  0  1  0
#> SRR1179085     3       0          1  0  0  1  0
#> SRR1179086     3       0          1  0  0  1  0
#> SRR1179087     3       0          1  0  0  1  0
#> SRR1179088     3       0          1  0  0  1  0
#> SRR1179089     3       0          1  0  0  1  0
#> SRR1179090     3       0          1  0  0  1  0
#> SRR1179091     3       0          1  0  0  1  0
#> SRR1179092     3       0          1  0  0  1  0
#> SRR1179093     3       0          1  0  0  1  0
#> SRR1179094     3       0          1  0  0  1  0
#> SRR1179095     3       0          1  0  0  1  0
#> SRR1179096     2       0          1  0  1  0  0
#> SRR1179097     2       0          1  0  1  0  0
#> SRR1179098     2       0          1  0  1  0  0
#> SRR1179099     2       0          1  0  1  0  0
#> SRR1179100     2       0          1  0  1  0  0
#> SRR1179101     2       0          1  0  1  0  0
#> SRR1179102     2       0          1  0  1  0  0
#> SRR1179103     2       0          1  0  1  0  0
#> SRR1179104     2       0          1  0  1  0  0
#> SRR1179105     2       0          1  0  1  0  0
#> SRR1179106     2       0          1  0  1  0  0
#> SRR1179107     2       0          1  0  1  0  0
#> SRR1179108     2       0          1  0  1  0  0
#> SRR1179109     2       0          1  0  1  0  0
#> SRR1179110     2       0          1  0  1  0  0
#> SRR1179111     2       0          1  0  1  0  0
#> SRR1179112     1       0          1  1  0  0  0
#> SRR1179113     1       0          1  1  0  0  0
#> SRR1179114     1       0          1  1  0  0  0
#> SRR1179115     1       0          1  1  0  0  0
#> SRR1179116     1       0          1  1  0  0  0
#> SRR1179117     1       0          1  1  0  0  0
#> SRR1179118     1       0          1  1  0  0  0
#> SRR1179119     1       0          1  1  0  0  0
#> SRR1179120     4       0          1  0  0  0  1
#> SRR1179121     4       0          1  0  0  0  1
#> SRR1179122     4       0          1  0  0  0  1
#> SRR1179123     4       0          1  0  0  0  1
#> SRR1179124     4       0          1  0  0  0  1
#> SRR1179125     4       0          1  0  0  0  1
#> SRR1179126     4       0          1  0  0  0  1
#> SRR1179127     1       0          1  1  0  0  0
#> SRR1179128     1       0          1  1  0  0  0
#> SRR1179129     1       0          1  1  0  0  0
#> SRR1179130     1       0          1  1  0  0  0
#> SRR1179131     1       0          1  1  0  0  0
#> SRR1179132     1       0          1  1  0  0  0
#> SRR1179134     1       0          1  1  0  0  0
#> SRR1179135     1       0          1  1  0  0  0
#> SRR1179136     1       0          1  1  0  0  0
#> SRR1179137     1       0          1  1  0  0  0
#> SRR1179138     1       0          1  1  0  0  0
#> SRR1179139     1       0          1  1  0  0  0
#> SRR1179140     1       0          1  1  0  0  0
#> SRR1179141     1       0          1  1  0  0  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2 p3 p4    p5
#> SRR1179081     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179082     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179083     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179084     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179085     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179086     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179087     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179088     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179089     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179090     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179091     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179092     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179093     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179094     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179095     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179096     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179097     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179098     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179099     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179100     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179101     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179102     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179103     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179104     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179105     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179106     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179107     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179108     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179109     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179110     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179111     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179112     1  0.3730      0.789 0.712  0  0  0 0.288
#> SRR1179113     1  0.3586      0.816 0.736  0  0  0 0.264
#> SRR1179114     1  0.3586      0.816 0.736  0  0  0 0.264
#> SRR1179115     1  0.3586      0.816 0.736  0  0  0 0.264
#> SRR1179116     1  0.3586      0.816 0.736  0  0  0 0.264
#> SRR1179117     1  0.3586      0.816 0.736  0  0  0 0.264
#> SRR1179118     1  0.3586      0.816 0.736  0  0  0 0.264
#> SRR1179119     1  0.3586      0.816 0.736  0  0  0 0.264
#> SRR1179120     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179121     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179122     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179123     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179124     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179125     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179126     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179127     1  0.0162      0.819 0.996  0  0  0 0.004
#> SRR1179128     1  0.0162      0.819 0.996  0  0  0 0.004
#> SRR1179129     1  0.0162      0.819 0.996  0  0  0 0.004
#> SRR1179130     1  0.0162      0.819 0.996  0  0  0 0.004
#> SRR1179131     1  0.0162      0.819 0.996  0  0  0 0.004
#> SRR1179132     1  0.0162      0.819 0.996  0  0  0 0.004
#> SRR1179134     1  0.0162      0.819 0.996  0  0  0 0.004
#> SRR1179135     5  0.0000      1.000 0.000  0  0  0 1.000
#> SRR1179136     5  0.0000      1.000 0.000  0  0  0 1.000
#> SRR1179137     5  0.0000      1.000 0.000  0  0  0 1.000
#> SRR1179138     5  0.0000      1.000 0.000  0  0  0 1.000
#> SRR1179139     5  0.0000      1.000 0.000  0  0  0 1.000
#> SRR1179140     5  0.0000      1.000 0.000  0  0  0 1.000
#> SRR1179141     5  0.0000      1.000 0.000  0  0  0 1.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3    p4    p5    p6
#> SRR1179081     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179082     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179083     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179084     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179085     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179086     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179087     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179088     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179089     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179090     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179091     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179092     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179093     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179094     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179095     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1179096     2  0.3168      0.875 0.000 0.804  0 0.000 0.172 0.024
#> SRR1179097     2  0.0000      0.953 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179098     2  0.0000      0.953 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179099     2  0.0000      0.953 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179100     2  0.0000      0.953 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179101     2  0.0146      0.953 0.000 0.996  0 0.000 0.004 0.000
#> SRR1179102     2  0.0260      0.952 0.000 0.992  0 0.000 0.008 0.000
#> SRR1179103     2  0.0000      0.953 0.000 1.000  0 0.000 0.000 0.000
#> SRR1179104     2  0.2805      0.890 0.000 0.828  0 0.000 0.160 0.012
#> SRR1179105     2  0.0146      0.953 0.000 0.996  0 0.000 0.004 0.000
#> SRR1179106     2  0.2473      0.902 0.000 0.856  0 0.000 0.136 0.008
#> SRR1179107     2  0.0260      0.953 0.000 0.992  0 0.000 0.008 0.000
#> SRR1179108     2  0.2553      0.899 0.000 0.848  0 0.000 0.144 0.008
#> SRR1179109     2  0.0260      0.953 0.000 0.992  0 0.000 0.008 0.000
#> SRR1179110     2  0.2593      0.897 0.000 0.844  0 0.000 0.148 0.008
#> SRR1179111     2  0.0260      0.953 0.000 0.992  0 0.000 0.008 0.000
#> SRR1179112     1  0.1444      0.912 0.928 0.000  0 0.000 0.000 0.072
#> SRR1179113     1  0.0146      0.980 0.996 0.000  0 0.000 0.000 0.004
#> SRR1179114     1  0.0000      0.982 1.000 0.000  0 0.000 0.000 0.000
#> SRR1179115     1  0.0000      0.982 1.000 0.000  0 0.000 0.000 0.000
#> SRR1179116     1  0.0000      0.982 1.000 0.000  0 0.000 0.000 0.000
#> SRR1179117     1  0.0000      0.982 1.000 0.000  0 0.000 0.000 0.000
#> SRR1179118     1  0.0632      0.966 0.976 0.000  0 0.000 0.000 0.024
#> SRR1179119     1  0.0000      0.982 1.000 0.000  0 0.000 0.000 0.000
#> SRR1179120     4  0.0000      0.999 0.000 0.000  0 1.000 0.000 0.000
#> SRR1179121     4  0.0000      0.999 0.000 0.000  0 1.000 0.000 0.000
#> SRR1179122     4  0.0146      0.997 0.000 0.000  0 0.996 0.004 0.000
#> SRR1179123     4  0.0000      0.999 0.000 0.000  0 1.000 0.000 0.000
#> SRR1179124     4  0.0146      0.997 0.000 0.000  0 0.996 0.004 0.000
#> SRR1179125     4  0.0000      0.999 0.000 0.000  0 1.000 0.000 0.000
#> SRR1179126     4  0.0146      0.997 0.000 0.000  0 0.996 0.004 0.000
#> SRR1179127     5  0.3071      0.983 0.180 0.000  0 0.000 0.804 0.016
#> SRR1179128     5  0.3156      0.988 0.180 0.000  0 0.000 0.800 0.020
#> SRR1179129     5  0.3202      0.987 0.176 0.000  0 0.000 0.800 0.024
#> SRR1179130     5  0.3156      0.985 0.180 0.000  0 0.000 0.800 0.020
#> SRR1179131     5  0.3168      0.986 0.172 0.000  0 0.000 0.804 0.024
#> SRR1179132     5  0.3046      0.985 0.188 0.000  0 0.000 0.800 0.012
#> SRR1179134     5  0.3104      0.988 0.184 0.000  0 0.000 0.800 0.016
#> SRR1179135     6  0.0632      0.999 0.024 0.000  0 0.000 0.000 0.976
#> SRR1179136     6  0.0777      0.998 0.024 0.000  0 0.000 0.004 0.972
#> SRR1179137     6  0.0777      0.998 0.024 0.000  0 0.000 0.004 0.972
#> SRR1179138     6  0.0777      0.998 0.024 0.000  0 0.000 0.004 0.972
#> SRR1179139     6  0.0632      0.999 0.024 0.000  0 0.000 0.000 0.976
#> SRR1179140     6  0.0632      0.999 0.024 0.000  0 0.000 0.000 0.976
#> SRR1179141     6  0.0632      0.999 0.024 0.000  0 0.000 0.000 0.976

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

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 0.850           0.996       0.945         0.2174 0.864   0.724
#> 4 4 0.913           0.960       0.949         0.0580 1.000   1.000
#> 5 5 0.846           0.913       0.906         0.0480 1.000   1.000
#> 6 6 0.835           0.882       0.880         0.0371 0.913   0.756

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
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1179081     3  0.4605      1.000 0.000 0.204 0.796
#> SRR1179082     3  0.4605      1.000 0.000 0.204 0.796
#> SRR1179083     3  0.4605      1.000 0.000 0.204 0.796
#> SRR1179084     3  0.4605      1.000 0.000 0.204 0.796
#> SRR1179085     3  0.4605      1.000 0.000 0.204 0.796
#> SRR1179086     3  0.4605      1.000 0.000 0.204 0.796
#> SRR1179087     3  0.4605      1.000 0.000 0.204 0.796
#> SRR1179088     3  0.4605      1.000 0.000 0.204 0.796
#> SRR1179089     3  0.4605      1.000 0.000 0.204 0.796
#> SRR1179090     3  0.4605      1.000 0.000 0.204 0.796
#> SRR1179091     3  0.4605      1.000 0.000 0.204 0.796
#> SRR1179092     3  0.4605      1.000 0.000 0.204 0.796
#> SRR1179093     3  0.4605      1.000 0.000 0.204 0.796
#> SRR1179094     3  0.4605      1.000 0.000 0.204 0.796
#> SRR1179095     3  0.4605      1.000 0.000 0.204 0.796
#> SRR1179096     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179097     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179098     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179099     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179100     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179101     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179102     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179103     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179104     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179105     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179106     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179107     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179108     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179109     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179110     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179111     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179112     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1179113     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1179114     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1179115     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1179116     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1179117     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1179118     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1179119     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1179120     1  0.1163      0.982 0.972 0.000 0.028
#> SRR1179121     1  0.1031      0.984 0.976 0.000 0.024
#> SRR1179122     1  0.1031      0.984 0.976 0.000 0.024
#> SRR1179123     1  0.1163      0.982 0.972 0.000 0.028
#> SRR1179124     1  0.1031      0.984 0.976 0.000 0.024
#> SRR1179125     1  0.1163      0.982 0.972 0.000 0.028
#> SRR1179126     1  0.1031      0.984 0.976 0.000 0.024
#> SRR1179127     1  0.0424      0.993 0.992 0.000 0.008
#> SRR1179128     1  0.0237      0.993 0.996 0.000 0.004
#> SRR1179129     1  0.0424      0.993 0.992 0.000 0.008
#> SRR1179130     1  0.0237      0.993 0.996 0.000 0.004
#> SRR1179131     1  0.0424      0.993 0.992 0.000 0.008
#> SRR1179132     1  0.0237      0.993 0.996 0.000 0.004
#> SRR1179134     1  0.0237      0.993 0.996 0.000 0.004
#> SRR1179135     1  0.0237      0.993 0.996 0.000 0.004
#> SRR1179136     1  0.0237      0.993 0.996 0.000 0.004
#> SRR1179137     1  0.0237      0.993 0.996 0.000 0.004
#> SRR1179138     1  0.0237      0.993 0.996 0.000 0.004
#> SRR1179139     1  0.0237      0.993 0.996 0.000 0.004
#> SRR1179140     1  0.0237      0.993 0.996 0.000 0.004
#> SRR1179141     1  0.0237      0.993 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1179081     3  0.1940      0.999 0.000 0.076 0.924 0.000
#> SRR1179082     3  0.2125      0.997 0.000 0.076 0.920 0.004
#> SRR1179083     3  0.1940      0.999 0.000 0.076 0.924 0.000
#> SRR1179084     3  0.2125      0.997 0.000 0.076 0.920 0.004
#> SRR1179085     3  0.1940      0.999 0.000 0.076 0.924 0.000
#> SRR1179086     3  0.1940      0.999 0.000 0.076 0.924 0.000
#> SRR1179087     3  0.1940      0.999 0.000 0.076 0.924 0.000
#> SRR1179088     3  0.2125      0.997 0.000 0.076 0.920 0.004
#> SRR1179089     3  0.1940      0.999 0.000 0.076 0.924 0.000
#> SRR1179090     3  0.1940      0.999 0.000 0.076 0.924 0.000
#> SRR1179091     3  0.1940      0.999 0.000 0.076 0.924 0.000
#> SRR1179092     3  0.1940      0.999 0.000 0.076 0.924 0.000
#> SRR1179093     3  0.1940      0.999 0.000 0.076 0.924 0.000
#> SRR1179094     3  0.1940      0.999 0.000 0.076 0.924 0.000
#> SRR1179095     3  0.1940      0.999 0.000 0.076 0.924 0.000
#> SRR1179096     2  0.0524      0.981 0.000 0.988 0.004 0.008
#> SRR1179097     2  0.0657      0.991 0.000 0.984 0.012 0.004
#> SRR1179098     2  0.0657      0.991 0.000 0.984 0.012 0.004
#> SRR1179099     2  0.0524      0.993 0.000 0.988 0.008 0.004
#> SRR1179100     2  0.0657      0.991 0.000 0.984 0.012 0.004
#> SRR1179101     2  0.0524      0.993 0.000 0.988 0.008 0.004
#> SRR1179102     2  0.0657      0.991 0.000 0.984 0.012 0.004
#> SRR1179103     2  0.0524      0.993 0.000 0.988 0.008 0.004
#> SRR1179104     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1179105     2  0.0188      0.994 0.000 0.996 0.004 0.000
#> SRR1179106     2  0.0188      0.994 0.000 0.996 0.004 0.000
#> SRR1179107     2  0.0188      0.994 0.000 0.996 0.004 0.000
#> SRR1179108     2  0.0188      0.994 0.000 0.996 0.004 0.000
#> SRR1179109     2  0.0188      0.994 0.000 0.996 0.004 0.000
#> SRR1179110     2  0.0188      0.994 0.000 0.996 0.004 0.000
#> SRR1179111     2  0.0188      0.994 0.000 0.996 0.004 0.000
#> SRR1179112     1  0.0336      0.948 0.992 0.000 0.000 0.008
#> SRR1179113     1  0.0336      0.948 0.992 0.000 0.000 0.008
#> SRR1179114     1  0.0336      0.948 0.992 0.000 0.000 0.008
#> SRR1179115     1  0.0336      0.948 0.992 0.000 0.000 0.008
#> SRR1179116     1  0.0336      0.948 0.992 0.000 0.000 0.008
#> SRR1179117     1  0.0336      0.948 0.992 0.000 0.000 0.008
#> SRR1179118     1  0.0336      0.948 0.992 0.000 0.000 0.008
#> SRR1179119     1  0.0336      0.948 0.992 0.000 0.000 0.008
#> SRR1179120     1  0.3907      0.844 0.768 0.000 0.000 0.232
#> SRR1179121     1  0.3873      0.846 0.772 0.000 0.000 0.228
#> SRR1179122     1  0.3907      0.844 0.768 0.000 0.000 0.232
#> SRR1179123     1  0.3907      0.844 0.768 0.000 0.000 0.232
#> SRR1179124     1  0.3907      0.844 0.768 0.000 0.000 0.232
#> SRR1179125     1  0.3907      0.844 0.768 0.000 0.000 0.232
#> SRR1179126     1  0.3873      0.846 0.772 0.000 0.000 0.228
#> SRR1179127     1  0.0592      0.945 0.984 0.000 0.000 0.016
#> SRR1179128     1  0.0000      0.948 1.000 0.000 0.000 0.000
#> SRR1179129     1  0.0707      0.944 0.980 0.000 0.000 0.020
#> SRR1179130     1  0.0000      0.948 1.000 0.000 0.000 0.000
#> SRR1179131     1  0.1118      0.938 0.964 0.000 0.000 0.036
#> SRR1179132     1  0.0000      0.948 1.000 0.000 0.000 0.000
#> SRR1179134     1  0.0000      0.948 1.000 0.000 0.000 0.000
#> SRR1179135     1  0.0336      0.946 0.992 0.000 0.000 0.008
#> SRR1179136     1  0.0336      0.946 0.992 0.000 0.000 0.008
#> SRR1179137     1  0.0336      0.946 0.992 0.000 0.000 0.008
#> SRR1179138     1  0.0336      0.946 0.992 0.000 0.000 0.008
#> SRR1179139     1  0.0336      0.946 0.992 0.000 0.000 0.008
#> SRR1179140     1  0.0336      0.946 0.992 0.000 0.000 0.008
#> SRR1179141     1  0.0336      0.946 0.992 0.000 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4 p5
#> SRR1179081     3  0.0000      1.000 0.000 0.000 1.000 0.000 NA
#> SRR1179082     3  0.0000      1.000 0.000 0.000 1.000 0.000 NA
#> SRR1179083     3  0.0000      1.000 0.000 0.000 1.000 0.000 NA
#> SRR1179084     3  0.0162      0.997 0.000 0.000 0.996 0.000 NA
#> SRR1179085     3  0.0000      1.000 0.000 0.000 1.000 0.000 NA
#> SRR1179086     3  0.0000      1.000 0.000 0.000 1.000 0.000 NA
#> SRR1179087     3  0.0000      1.000 0.000 0.000 1.000 0.000 NA
#> SRR1179088     3  0.0162      0.997 0.000 0.000 0.996 0.000 NA
#> SRR1179089     3  0.0000      1.000 0.000 0.000 1.000 0.000 NA
#> SRR1179090     3  0.0000      1.000 0.000 0.000 1.000 0.000 NA
#> SRR1179091     3  0.0000      1.000 0.000 0.000 1.000 0.000 NA
#> SRR1179092     3  0.0000      1.000 0.000 0.000 1.000 0.000 NA
#> SRR1179093     3  0.0000      1.000 0.000 0.000 1.000 0.000 NA
#> SRR1179094     3  0.0000      1.000 0.000 0.000 1.000 0.000 NA
#> SRR1179095     3  0.0000      1.000 0.000 0.000 1.000 0.000 NA
#> SRR1179096     2  0.1430      0.983 0.000 0.944 0.052 0.004 NA
#> SRR1179097     2  0.1608      0.984 0.000 0.928 0.072 0.000 NA
#> SRR1179098     2  0.1671      0.982 0.000 0.924 0.076 0.000 NA
#> SRR1179099     2  0.1608      0.984 0.000 0.928 0.072 0.000 NA
#> SRR1179100     2  0.1608      0.984 0.000 0.928 0.072 0.000 NA
#> SRR1179101     2  0.1671      0.982 0.000 0.924 0.076 0.000 NA
#> SRR1179102     2  0.1608      0.984 0.000 0.928 0.072 0.000 NA
#> SRR1179103     2  0.1608      0.984 0.000 0.928 0.072 0.000 NA
#> SRR1179104     2  0.1197      0.986 0.000 0.952 0.048 0.000 NA
#> SRR1179105     2  0.1282      0.983 0.000 0.952 0.044 0.004 NA
#> SRR1179106     2  0.1197      0.986 0.000 0.952 0.048 0.000 NA
#> SRR1179107     2  0.1357      0.986 0.000 0.948 0.048 0.004 NA
#> SRR1179108     2  0.1270      0.986 0.000 0.948 0.052 0.000 NA
#> SRR1179109     2  0.1357      0.986 0.000 0.948 0.048 0.004 NA
#> SRR1179110     2  0.1197      0.986 0.000 0.952 0.048 0.000 NA
#> SRR1179111     2  0.1357      0.986 0.000 0.948 0.048 0.004 NA
#> SRR1179112     1  0.1282      0.876 0.952 0.000 0.000 0.044 NA
#> SRR1179113     1  0.1282      0.876 0.952 0.000 0.000 0.044 NA
#> SRR1179114     1  0.1282      0.876 0.952 0.000 0.000 0.044 NA
#> SRR1179115     1  0.1282      0.876 0.952 0.000 0.000 0.044 NA
#> SRR1179116     1  0.1282      0.876 0.952 0.000 0.000 0.044 NA
#> SRR1179117     1  0.1282      0.876 0.952 0.000 0.000 0.044 NA
#> SRR1179118     1  0.1282      0.876 0.952 0.000 0.000 0.044 NA
#> SRR1179119     1  0.1282      0.876 0.952 0.000 0.000 0.044 NA
#> SRR1179120     1  0.4262      0.711 0.560 0.000 0.000 0.440 NA
#> SRR1179121     1  0.4262      0.711 0.560 0.000 0.000 0.440 NA
#> SRR1179122     1  0.4262      0.711 0.560 0.000 0.000 0.440 NA
#> SRR1179123     1  0.4262      0.711 0.560 0.000 0.000 0.440 NA
#> SRR1179124     1  0.4262      0.711 0.560 0.000 0.000 0.440 NA
#> SRR1179125     1  0.4262      0.711 0.560 0.000 0.000 0.440 NA
#> SRR1179126     1  0.4262      0.711 0.560 0.000 0.000 0.440 NA
#> SRR1179127     1  0.2329      0.854 0.876 0.000 0.000 0.124 NA
#> SRR1179128     1  0.0703      0.874 0.976 0.000 0.000 0.024 NA
#> SRR1179129     1  0.2471      0.850 0.864 0.000 0.000 0.136 NA
#> SRR1179130     1  0.0609      0.873 0.980 0.000 0.000 0.020 NA
#> SRR1179131     1  0.2605      0.846 0.852 0.000 0.000 0.148 NA
#> SRR1179132     1  0.0880      0.874 0.968 0.000 0.000 0.032 NA
#> SRR1179134     1  0.1197      0.873 0.952 0.000 0.000 0.048 NA
#> SRR1179135     1  0.1544      0.858 0.932 0.000 0.000 0.068 NA
#> SRR1179136     1  0.1410      0.860 0.940 0.000 0.000 0.060 NA
#> SRR1179137     1  0.1544      0.858 0.932 0.000 0.000 0.068 NA
#> SRR1179138     1  0.1478      0.859 0.936 0.000 0.000 0.064 NA
#> SRR1179139     1  0.1478      0.859 0.936 0.000 0.000 0.064 NA
#> SRR1179140     1  0.1608      0.856 0.928 0.000 0.000 0.072 NA
#> SRR1179141     1  0.1544      0.858 0.932 0.000 0.000 0.068 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1179081     3  0.0777      0.983 0.000 0.000 0.972 0.000 0.004 NA
#> SRR1179082     3  0.0000      0.995 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1179083     3  0.0146      0.995 0.000 0.004 0.996 0.000 0.000 NA
#> SRR1179084     3  0.0146      0.995 0.000 0.000 0.996 0.000 0.000 NA
#> SRR1179085     3  0.0291      0.995 0.000 0.004 0.992 0.000 0.000 NA
#> SRR1179086     3  0.0291      0.995 0.000 0.004 0.992 0.000 0.000 NA
#> SRR1179087     3  0.0146      0.995 0.000 0.000 0.996 0.000 0.000 NA
#> SRR1179088     3  0.0000      0.995 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1179089     3  0.0508      0.990 0.000 0.004 0.984 0.000 0.000 NA
#> SRR1179090     3  0.0146      0.995 0.000 0.004 0.996 0.000 0.000 NA
#> SRR1179091     3  0.0291      0.995 0.000 0.004 0.992 0.000 0.000 NA
#> SRR1179092     3  0.0146      0.995 0.000 0.000 0.996 0.000 0.000 NA
#> SRR1179093     3  0.0146      0.995 0.000 0.004 0.996 0.000 0.000 NA
#> SRR1179094     3  0.0146      0.995 0.000 0.004 0.996 0.000 0.000 NA
#> SRR1179095     3  0.0000      0.995 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1179096     2  0.3112      0.882 0.000 0.836 0.068 0.000 0.000 NA
#> SRR1179097     2  0.0937      0.987 0.000 0.960 0.040 0.000 0.000 NA
#> SRR1179098     2  0.0865      0.987 0.000 0.964 0.036 0.000 0.000 NA
#> SRR1179099     2  0.0937      0.987 0.000 0.960 0.040 0.000 0.000 NA
#> SRR1179100     2  0.0937      0.987 0.000 0.960 0.040 0.000 0.000 NA
#> SRR1179101     2  0.0937      0.987 0.000 0.960 0.040 0.000 0.000 NA
#> SRR1179102     2  0.0937      0.987 0.000 0.960 0.040 0.000 0.000 NA
#> SRR1179103     2  0.1082      0.986 0.000 0.956 0.040 0.000 0.000 NA
#> SRR1179104     2  0.0922      0.980 0.000 0.968 0.024 0.000 0.004 NA
#> SRR1179105     2  0.0790      0.987 0.000 0.968 0.032 0.000 0.000 NA
#> SRR1179106     2  0.1003      0.983 0.000 0.964 0.028 0.000 0.004 NA
#> SRR1179107     2  0.0865      0.987 0.000 0.964 0.036 0.000 0.000 NA
#> SRR1179108     2  0.0713      0.985 0.000 0.972 0.028 0.000 0.000 NA
#> SRR1179109     2  0.0790      0.986 0.000 0.968 0.032 0.000 0.000 NA
#> SRR1179110     2  0.0935      0.986 0.000 0.964 0.032 0.000 0.004 NA
#> SRR1179111     2  0.0790      0.987 0.000 0.968 0.032 0.000 0.000 NA
#> SRR1179112     1  0.2527      0.717 0.876 0.000 0.000 0.084 0.040 NA
#> SRR1179113     1  0.2509      0.716 0.876 0.000 0.000 0.088 0.036 NA
#> SRR1179114     1  0.2560      0.714 0.872 0.000 0.000 0.092 0.036 NA
#> SRR1179115     1  0.2560      0.714 0.872 0.000 0.000 0.092 0.036 NA
#> SRR1179116     1  0.2560      0.714 0.872 0.000 0.000 0.092 0.036 NA
#> SRR1179117     1  0.2509      0.716 0.876 0.000 0.000 0.088 0.036 NA
#> SRR1179118     1  0.2509      0.716 0.876 0.000 0.000 0.088 0.036 NA
#> SRR1179119     1  0.2560      0.714 0.872 0.000 0.000 0.092 0.036 NA
#> SRR1179120     4  0.3804      0.997 0.424 0.000 0.000 0.576 0.000 NA
#> SRR1179121     4  0.3804      0.997 0.424 0.000 0.000 0.576 0.000 NA
#> SRR1179122     4  0.3804      0.997 0.424 0.000 0.000 0.576 0.000 NA
#> SRR1179123     4  0.3804      0.997 0.424 0.000 0.000 0.576 0.000 NA
#> SRR1179124     4  0.3804      0.997 0.424 0.000 0.000 0.576 0.000 NA
#> SRR1179125     4  0.3804      0.997 0.424 0.000 0.000 0.576 0.000 NA
#> SRR1179126     4  0.4045      0.980 0.428 0.000 0.000 0.564 0.008 NA
#> SRR1179127     1  0.3247      0.574 0.808 0.000 0.000 0.156 0.036 NA
#> SRR1179128     1  0.2277      0.706 0.892 0.000 0.000 0.076 0.032 NA
#> SRR1179129     1  0.3284      0.549 0.800 0.000 0.000 0.168 0.032 NA
#> SRR1179130     1  0.2119      0.719 0.904 0.000 0.000 0.060 0.036 NA
#> SRR1179131     1  0.3312      0.533 0.792 0.000 0.000 0.180 0.028 NA
#> SRR1179132     1  0.2350      0.706 0.888 0.000 0.000 0.076 0.036 NA
#> SRR1179134     1  0.2331      0.700 0.888 0.000 0.000 0.080 0.032 NA
#> SRR1179135     1  0.2003      0.729 0.884 0.000 0.000 0.000 0.116 NA
#> SRR1179136     1  0.1814      0.740 0.900 0.000 0.000 0.000 0.100 NA
#> SRR1179137     1  0.1910      0.736 0.892 0.000 0.000 0.000 0.108 NA
#> SRR1179138     1  0.1910      0.736 0.892 0.000 0.000 0.000 0.108 NA
#> SRR1179139     1  0.1910      0.736 0.892 0.000 0.000 0.000 0.108 NA
#> SRR1179140     1  0.2003      0.734 0.884 0.000 0.000 0.000 0.116 NA
#> SRR1179141     1  0.1910      0.736 0.892 0.000 0.000 0.000 0.108 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-NMF-collect-classes

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

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 0.868           0.895       0.935         0.0938 0.983   0.966
#> 4 4 1.000           0.983       1.000         0.1730 0.873   0.732
#> 5 5 0.838           0.759       0.834         0.0915 0.881   0.659
#> 6 6 0.842           0.872       0.903         0.0483 0.909   0.681

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
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1   p2   p3
#> SRR1179081     3   0.522      0.830  0 0.26 0.74
#> SRR1179082     3   0.522      0.830  0 0.26 0.74
#> SRR1179083     3   0.522      0.830  0 0.26 0.74
#> SRR1179084     3   0.522      0.830  0 0.26 0.74
#> SRR1179085     3   0.522      0.830  0 0.26 0.74
#> SRR1179086     3   0.522      0.830  0 0.26 0.74
#> SRR1179087     3   0.522      0.830  0 0.26 0.74
#> SRR1179088     3   0.522      0.830  0 0.26 0.74
#> SRR1179089     3   0.522      0.830  0 0.26 0.74
#> SRR1179090     3   0.522      0.830  0 0.26 0.74
#> SRR1179091     3   0.522      0.830  0 0.26 0.74
#> SRR1179092     3   0.522      0.830  0 0.26 0.74
#> SRR1179093     3   0.522      0.830  0 0.26 0.74
#> SRR1179094     3   0.522      0.830  0 0.26 0.74
#> SRR1179095     3   0.522      0.830  0 0.26 0.74
#> SRR1179096     2   0.522      0.000  0 0.74 0.26
#> SRR1179097     3   0.000      0.818  0 0.00 1.00
#> SRR1179098     3   0.000      0.818  0 0.00 1.00
#> SRR1179099     3   0.000      0.818  0 0.00 1.00
#> SRR1179100     3   0.000      0.818  0 0.00 1.00
#> SRR1179101     3   0.000      0.818  0 0.00 1.00
#> SRR1179102     3   0.000      0.818  0 0.00 1.00
#> SRR1179103     3   0.000      0.818  0 0.00 1.00
#> SRR1179104     3   0.000      0.818  0 0.00 1.00
#> SRR1179105     3   0.000      0.818  0 0.00 1.00
#> SRR1179106     3   0.000      0.818  0 0.00 1.00
#> SRR1179107     3   0.000      0.818  0 0.00 1.00
#> SRR1179108     3   0.000      0.818  0 0.00 1.00
#> SRR1179109     3   0.000      0.818  0 0.00 1.00
#> SRR1179110     3   0.000      0.818  0 0.00 1.00
#> SRR1179111     3   0.000      0.818  0 0.00 1.00
#> SRR1179112     1   0.000      1.000  1 0.00 0.00
#> SRR1179113     1   0.000      1.000  1 0.00 0.00
#> SRR1179114     1   0.000      1.000  1 0.00 0.00
#> SRR1179115     1   0.000      1.000  1 0.00 0.00
#> SRR1179116     1   0.000      1.000  1 0.00 0.00
#> SRR1179117     1   0.000      1.000  1 0.00 0.00
#> SRR1179118     1   0.000      1.000  1 0.00 0.00
#> SRR1179119     1   0.000      1.000  1 0.00 0.00
#> SRR1179120     1   0.000      1.000  1 0.00 0.00
#> SRR1179121     1   0.000      1.000  1 0.00 0.00
#> SRR1179122     1   0.000      1.000  1 0.00 0.00
#> SRR1179123     1   0.000      1.000  1 0.00 0.00
#> SRR1179124     1   0.000      1.000  1 0.00 0.00
#> SRR1179125     1   0.000      1.000  1 0.00 0.00
#> SRR1179126     1   0.000      1.000  1 0.00 0.00
#> SRR1179127     1   0.000      1.000  1 0.00 0.00
#> SRR1179128     1   0.000      1.000  1 0.00 0.00
#> SRR1179129     1   0.000      1.000  1 0.00 0.00
#> SRR1179130     1   0.000      1.000  1 0.00 0.00
#> SRR1179131     1   0.000      1.000  1 0.00 0.00
#> SRR1179132     1   0.000      1.000  1 0.00 0.00
#> SRR1179134     1   0.000      1.000  1 0.00 0.00
#> SRR1179135     1   0.000      1.000  1 0.00 0.00
#> SRR1179136     1   0.000      1.000  1 0.00 0.00
#> SRR1179137     1   0.000      1.000  1 0.00 0.00
#> SRR1179138     1   0.000      1.000  1 0.00 0.00
#> SRR1179139     1   0.000      1.000  1 0.00 0.00
#> SRR1179140     1   0.000      1.000  1 0.00 0.00
#> SRR1179141     1   0.000      1.000  1 0.00 0.00

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1 p2 p3 p4
#> SRR1179081     3       0          1  0  0  1  0
#> SRR1179082     3       0          1  0  0  1  0
#> SRR1179083     3       0          1  0  0  1  0
#> SRR1179084     3       0          1  0  0  1  0
#> SRR1179085     3       0          1  0  0  1  0
#> SRR1179086     3       0          1  0  0  1  0
#> SRR1179087     3       0          1  0  0  1  0
#> SRR1179088     3       0          1  0  0  1  0
#> SRR1179089     3       0          1  0  0  1  0
#> SRR1179090     3       0          1  0  0  1  0
#> SRR1179091     3       0          1  0  0  1  0
#> SRR1179092     3       0          1  0  0  1  0
#> SRR1179093     3       0          1  0  0  1  0
#> SRR1179094     3       0          1  0  0  1  0
#> SRR1179095     3       0          1  0  0  1  0
#> SRR1179096     4       0          0  0  0  0  1
#> SRR1179097     2       0          1  0  1  0  0
#> SRR1179098     2       0          1  0  1  0  0
#> SRR1179099     2       0          1  0  1  0  0
#> SRR1179100     2       0          1  0  1  0  0
#> SRR1179101     2       0          1  0  1  0  0
#> SRR1179102     2       0          1  0  1  0  0
#> SRR1179103     2       0          1  0  1  0  0
#> SRR1179104     2       0          1  0  1  0  0
#> SRR1179105     2       0          1  0  1  0  0
#> SRR1179106     2       0          1  0  1  0  0
#> SRR1179107     2       0          1  0  1  0  0
#> SRR1179108     2       0          1  0  1  0  0
#> SRR1179109     2       0          1  0  1  0  0
#> SRR1179110     2       0          1  0  1  0  0
#> SRR1179111     2       0          1  0  1  0  0
#> SRR1179112     1       0          1  1  0  0  0
#> SRR1179113     1       0          1  1  0  0  0
#> SRR1179114     1       0          1  1  0  0  0
#> SRR1179115     1       0          1  1  0  0  0
#> SRR1179116     1       0          1  1  0  0  0
#> SRR1179117     1       0          1  1  0  0  0
#> SRR1179118     1       0          1  1  0  0  0
#> SRR1179119     1       0          1  1  0  0  0
#> SRR1179120     1       0          1  1  0  0  0
#> SRR1179121     1       0          1  1  0  0  0
#> SRR1179122     1       0          1  1  0  0  0
#> SRR1179123     1       0          1  1  0  0  0
#> SRR1179124     1       0          1  1  0  0  0
#> SRR1179125     1       0          1  1  0  0  0
#> SRR1179126     1       0          1  1  0  0  0
#> SRR1179127     1       0          1  1  0  0  0
#> SRR1179128     1       0          1  1  0  0  0
#> SRR1179129     1       0          1  1  0  0  0
#> SRR1179130     1       0          1  1  0  0  0
#> SRR1179131     1       0          1  1  0  0  0
#> SRR1179132     1       0          1  1  0  0  0
#> SRR1179134     1       0          1  1  0  0  0
#> SRR1179135     1       0          1  1  0  0  0
#> SRR1179136     1       0          1  1  0  0  0
#> SRR1179137     1       0          1  1  0  0  0
#> SRR1179138     1       0          1  1  0  0  0
#> SRR1179139     1       0          1  1  0  0  0
#> SRR1179140     1       0          1  1  0  0  0
#> SRR1179141     1       0          1  1  0  0  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2    p3    p4 p5
#> SRR1179081     3   0.331      0.731 0.000  0 0.776 0.224  0
#> SRR1179082     3   0.000      0.984 0.000  0 1.000 0.000  0
#> SRR1179083     3   0.000      0.984 0.000  0 1.000 0.000  0
#> SRR1179084     3   0.000      0.984 0.000  0 1.000 0.000  0
#> SRR1179085     3   0.000      0.984 0.000  0 1.000 0.000  0
#> SRR1179086     3   0.000      0.984 0.000  0 1.000 0.000  0
#> SRR1179087     3   0.000      0.984 0.000  0 1.000 0.000  0
#> SRR1179088     3   0.000      0.984 0.000  0 1.000 0.000  0
#> SRR1179089     3   0.000      0.984 0.000  0 1.000 0.000  0
#> SRR1179090     3   0.000      0.984 0.000  0 1.000 0.000  0
#> SRR1179091     3   0.000      0.984 0.000  0 1.000 0.000  0
#> SRR1179092     3   0.000      0.984 0.000  0 1.000 0.000  0
#> SRR1179093     3   0.000      0.984 0.000  0 1.000 0.000  0
#> SRR1179094     3   0.000      0.984 0.000  0 1.000 0.000  0
#> SRR1179095     3   0.000      0.984 0.000  0 1.000 0.000  0
#> SRR1179096     5   0.000      0.000 0.000  0 0.000 0.000  1
#> SRR1179097     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1179098     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1179099     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1179100     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1179101     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1179102     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1179103     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1179104     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1179105     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1179106     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1179107     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1179108     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1179109     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1179110     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1179111     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1179112     1   0.423      0.214 0.576  0 0.000 0.424  0
#> SRR1179113     4   0.429      0.982 0.464  0 0.000 0.536  0
#> SRR1179114     4   0.429      0.982 0.464  0 0.000 0.536  0
#> SRR1179115     4   0.429      0.982 0.464  0 0.000 0.536  0
#> SRR1179116     4   0.429      0.982 0.464  0 0.000 0.536  0
#> SRR1179117     4   0.429      0.982 0.464  0 0.000 0.536  0
#> SRR1179118     4   0.429      0.982 0.464  0 0.000 0.536  0
#> SRR1179119     4   0.429      0.982 0.464  0 0.000 0.536  0
#> SRR1179120     4   0.429      0.981 0.468  0 0.000 0.532  0
#> SRR1179121     4   0.429      0.981 0.468  0 0.000 0.532  0
#> SRR1179122     4   0.429      0.981 0.468  0 0.000 0.532  0
#> SRR1179123     4   0.429      0.981 0.468  0 0.000 0.532  0
#> SRR1179124     4   0.429      0.981 0.468  0 0.000 0.532  0
#> SRR1179125     4   0.429      0.981 0.468  0 0.000 0.532  0
#> SRR1179126     4   0.422      0.840 0.416  0 0.000 0.584  0
#> SRR1179127     1   0.410     -0.246 0.628  0 0.000 0.372  0
#> SRR1179128     1   0.410     -0.246 0.628  0 0.000 0.372  0
#> SRR1179129     1   0.410     -0.246 0.628  0 0.000 0.372  0
#> SRR1179130     1   0.410     -0.246 0.628  0 0.000 0.372  0
#> SRR1179131     1   0.410     -0.246 0.628  0 0.000 0.372  0
#> SRR1179132     1   0.410     -0.246 0.628  0 0.000 0.372  0
#> SRR1179134     1   0.410     -0.246 0.628  0 0.000 0.372  0
#> SRR1179135     1   0.000      0.562 1.000  0 0.000 0.000  0
#> SRR1179136     1   0.000      0.562 1.000  0 0.000 0.000  0
#> SRR1179137     1   0.000      0.562 1.000  0 0.000 0.000  0
#> SRR1179138     1   0.000      0.562 1.000  0 0.000 0.000  0
#> SRR1179139     1   0.000      0.562 1.000  0 0.000 0.000  0
#> SRR1179140     1   0.000      0.562 1.000  0 0.000 0.000  0
#> SRR1179141     1   0.000      0.562 1.000  0 0.000 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
#> SRR1179081     3  0.5206      0.390 0.128 0.000 0.588 0.000 0.284  0
#> SRR1179082     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000  0
#> SRR1179083     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000  0
#> SRR1179084     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000  0
#> SRR1179085     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000  0
#> SRR1179086     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000  0
#> SRR1179087     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000  0
#> SRR1179088     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000  0
#> SRR1179089     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000  0
#> SRR1179090     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000  0
#> SRR1179091     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000  0
#> SRR1179092     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000  0
#> SRR1179093     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000  0
#> SRR1179094     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000  0
#> SRR1179095     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000  0
#> SRR1179096     6  0.0000      0.000 0.000 0.000 0.000 0.000 0.000  1
#> SRR1179097     2  0.0363      0.992 0.000 0.988 0.000 0.000 0.012  0
#> SRR1179098     2  0.0363      0.992 0.000 0.988 0.000 0.000 0.012  0
#> SRR1179099     2  0.0363      0.992 0.000 0.988 0.000 0.000 0.012  0
#> SRR1179100     2  0.0363      0.992 0.000 0.988 0.000 0.000 0.012  0
#> SRR1179101     2  0.0363      0.992 0.000 0.988 0.000 0.000 0.012  0
#> SRR1179102     2  0.0363      0.992 0.000 0.988 0.000 0.000 0.012  0
#> SRR1179103     2  0.0363      0.992 0.000 0.988 0.000 0.000 0.012  0
#> SRR1179104     2  0.0405      0.987 0.004 0.988 0.000 0.000 0.008  0
#> SRR1179105     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000  0
#> SRR1179106     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000  0
#> SRR1179107     2  0.0146      0.991 0.004 0.996 0.000 0.000 0.000  0
#> SRR1179108     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000  0
#> SRR1179109     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000  0
#> SRR1179110     2  0.0291      0.989 0.004 0.992 0.000 0.000 0.004  0
#> SRR1179111     2  0.0146      0.991 0.004 0.996 0.000 0.000 0.000  0
#> SRR1179112     5  0.3710      0.000 0.012 0.000 0.000 0.292 0.696  0
#> SRR1179113     4  0.0000      0.839 0.000 0.000 0.000 1.000 0.000  0
#> SRR1179114     4  0.0000      0.839 0.000 0.000 0.000 1.000 0.000  0
#> SRR1179115     4  0.0000      0.839 0.000 0.000 0.000 1.000 0.000  0
#> SRR1179116     4  0.0000      0.839 0.000 0.000 0.000 1.000 0.000  0
#> SRR1179117     4  0.0000      0.839 0.000 0.000 0.000 1.000 0.000  0
#> SRR1179118     4  0.0000      0.839 0.000 0.000 0.000 1.000 0.000  0
#> SRR1179119     4  0.0000      0.839 0.000 0.000 0.000 1.000 0.000  0
#> SRR1179120     4  0.1421      0.827 0.028 0.000 0.000 0.944 0.028  0
#> SRR1179121     4  0.1421      0.827 0.028 0.000 0.000 0.944 0.028  0
#> SRR1179122     4  0.1421      0.827 0.028 0.000 0.000 0.944 0.028  0
#> SRR1179123     4  0.1421      0.827 0.028 0.000 0.000 0.944 0.028  0
#> SRR1179124     4  0.1421      0.827 0.028 0.000 0.000 0.944 0.028  0
#> SRR1179125     4  0.1421      0.827 0.028 0.000 0.000 0.944 0.028  0
#> SRR1179126     4  0.2488      0.730 0.076 0.000 0.000 0.880 0.044  0
#> SRR1179127     4  0.3050      0.702 0.236 0.000 0.000 0.764 0.000  0
#> SRR1179128     4  0.3050      0.702 0.236 0.000 0.000 0.764 0.000  0
#> SRR1179129     4  0.3050      0.702 0.236 0.000 0.000 0.764 0.000  0
#> SRR1179130     4  0.3050      0.702 0.236 0.000 0.000 0.764 0.000  0
#> SRR1179131     4  0.3050      0.702 0.236 0.000 0.000 0.764 0.000  0
#> SRR1179132     4  0.3050      0.702 0.236 0.000 0.000 0.764 0.000  0
#> SRR1179134     4  0.3050      0.702 0.236 0.000 0.000 0.764 0.000  0
#> SRR1179135     1  0.2762      1.000 0.804 0.000 0.000 0.196 0.000  0
#> SRR1179136     1  0.2762      1.000 0.804 0.000 0.000 0.196 0.000  0
#> SRR1179137     1  0.2762      1.000 0.804 0.000 0.000 0.196 0.000  0
#> SRR1179138     1  0.2762      1.000 0.804 0.000 0.000 0.196 0.000  0
#> SRR1179139     1  0.2762      1.000 0.804 0.000 0.000 0.196 0.000  0
#> SRR1179140     1  0.2762      1.000 0.804 0.000 0.000 0.196 0.000  0
#> SRR1179141     1  0.2762      1.000 0.804 0.000 0.000 0.196 0.000  0

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 0.684           0.823       0.801         0.2162 1.000   1.000
#> 4 4 0.687           0.863       0.779         0.1025 0.864   0.724
#> 5 5 0.627           0.751       0.764         0.0708 0.913   0.756
#> 6 6 0.742           0.540       0.707         0.0556 0.980   0.925

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
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2 p3
#> SRR1179081     2   0.000      0.790 0.000 1.000 NA
#> SRR1179082     2   0.000      0.790 0.000 1.000 NA
#> SRR1179083     2   0.000      0.790 0.000 1.000 NA
#> SRR1179084     2   0.000      0.790 0.000 1.000 NA
#> SRR1179085     2   0.000      0.790 0.000 1.000 NA
#> SRR1179086     2   0.000      0.790 0.000 1.000 NA
#> SRR1179087     2   0.000      0.790 0.000 1.000 NA
#> SRR1179088     2   0.000      0.790 0.000 1.000 NA
#> SRR1179089     2   0.000      0.790 0.000 1.000 NA
#> SRR1179090     2   0.000      0.790 0.000 1.000 NA
#> SRR1179091     2   0.000      0.790 0.000 1.000 NA
#> SRR1179092     2   0.000      0.790 0.000 1.000 NA
#> SRR1179093     2   0.000      0.790 0.000 1.000 NA
#> SRR1179094     2   0.000      0.790 0.000 1.000 NA
#> SRR1179095     2   0.000      0.790 0.000 1.000 NA
#> SRR1179096     2   0.631      0.773 0.000 0.508 NA
#> SRR1179097     2   0.624      0.803 0.000 0.560 NA
#> SRR1179098     2   0.624      0.803 0.000 0.560 NA
#> SRR1179099     2   0.624      0.803 0.000 0.560 NA
#> SRR1179100     2   0.624      0.803 0.000 0.560 NA
#> SRR1179101     2   0.624      0.803 0.000 0.560 NA
#> SRR1179102     2   0.624      0.803 0.000 0.560 NA
#> SRR1179103     2   0.624      0.803 0.000 0.560 NA
#> SRR1179104     2   0.624      0.803 0.000 0.560 NA
#> SRR1179105     2   0.624      0.803 0.000 0.560 NA
#> SRR1179106     2   0.624      0.803 0.000 0.560 NA
#> SRR1179107     2   0.624      0.803 0.000 0.560 NA
#> SRR1179108     2   0.624      0.803 0.000 0.560 NA
#> SRR1179109     2   0.624      0.803 0.000 0.560 NA
#> SRR1179110     2   0.624      0.803 0.000 0.560 NA
#> SRR1179111     2   0.624      0.803 0.000 0.560 NA
#> SRR1179112     1   0.263      0.851 0.916 0.000 NA
#> SRR1179113     1   0.186      0.862 0.948 0.000 NA
#> SRR1179114     1   0.186      0.862 0.948 0.000 NA
#> SRR1179115     1   0.186      0.862 0.948 0.000 NA
#> SRR1179116     1   0.186      0.862 0.948 0.000 NA
#> SRR1179117     1   0.186      0.862 0.948 0.000 NA
#> SRR1179118     1   0.186      0.862 0.948 0.000 NA
#> SRR1179119     1   0.186      0.862 0.948 0.000 NA
#> SRR1179120     1   0.341      0.856 0.876 0.000 NA
#> SRR1179121     1   0.341      0.856 0.876 0.000 NA
#> SRR1179122     1   0.341      0.856 0.876 0.000 NA
#> SRR1179123     1   0.341      0.856 0.876 0.000 NA
#> SRR1179124     1   0.341      0.856 0.876 0.000 NA
#> SRR1179125     1   0.341      0.856 0.876 0.000 NA
#> SRR1179126     1   0.355      0.854 0.868 0.000 NA
#> SRR1179127     1   0.497      0.867 0.764 0.000 NA
#> SRR1179128     1   0.497      0.867 0.764 0.000 NA
#> SRR1179129     1   0.497      0.867 0.764 0.000 NA
#> SRR1179130     1   0.497      0.867 0.764 0.000 NA
#> SRR1179131     1   0.497      0.867 0.764 0.000 NA
#> SRR1179132     1   0.497      0.867 0.764 0.000 NA
#> SRR1179134     1   0.497      0.867 0.764 0.000 NA
#> SRR1179135     1   0.553      0.826 0.704 0.000 NA
#> SRR1179136     1   0.553      0.826 0.704 0.000 NA
#> SRR1179137     1   0.553      0.826 0.704 0.000 NA
#> SRR1179138     1   0.553      0.826 0.704 0.000 NA
#> SRR1179139     1   0.553      0.826 0.704 0.000 NA
#> SRR1179140     1   0.553      0.826 0.704 0.000 NA
#> SRR1179141     1   0.553      0.826 0.704 0.000 NA

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3 p4
#> SRR1179081     3  0.1118      0.970 0.000 0.000 0.964 NA
#> SRR1179082     3  0.0469      0.979 0.000 0.000 0.988 NA
#> SRR1179083     3  0.0469      0.979 0.000 0.000 0.988 NA
#> SRR1179084     3  0.0469      0.979 0.000 0.000 0.988 NA
#> SRR1179085     3  0.0469      0.979 0.000 0.000 0.988 NA
#> SRR1179086     3  0.0469      0.980 0.000 0.000 0.988 NA
#> SRR1179087     3  0.0469      0.979 0.000 0.000 0.988 NA
#> SRR1179088     3  0.0469      0.979 0.000 0.000 0.988 NA
#> SRR1179089     3  0.0707      0.979 0.000 0.000 0.980 NA
#> SRR1179090     3  0.0707      0.979 0.000 0.000 0.980 NA
#> SRR1179091     3  0.1022      0.976 0.000 0.000 0.968 NA
#> SRR1179092     3  0.1022      0.976 0.000 0.000 0.968 NA
#> SRR1179093     3  0.1022      0.976 0.000 0.000 0.968 NA
#> SRR1179094     3  0.0921      0.977 0.000 0.000 0.972 NA
#> SRR1179095     3  0.0707      0.979 0.000 0.000 0.980 NA
#> SRR1179096     2  0.7784      0.654 0.000 0.428 0.292 NA
#> SRR1179097     2  0.5047      0.962 0.000 0.668 0.316 NA
#> SRR1179098     2  0.5047      0.962 0.000 0.668 0.316 NA
#> SRR1179099     2  0.5047      0.962 0.000 0.668 0.316 NA
#> SRR1179100     2  0.5047      0.962 0.000 0.668 0.316 NA
#> SRR1179101     2  0.5047      0.962 0.000 0.668 0.316 NA
#> SRR1179102     2  0.5047      0.962 0.000 0.668 0.316 NA
#> SRR1179103     2  0.5047      0.962 0.000 0.668 0.316 NA
#> SRR1179104     2  0.5152      0.962 0.000 0.664 0.316 NA
#> SRR1179105     2  0.5152      0.962 0.000 0.664 0.316 NA
#> SRR1179106     2  0.5152      0.962 0.000 0.664 0.316 NA
#> SRR1179107     2  0.5152      0.962 0.000 0.664 0.316 NA
#> SRR1179108     2  0.5152      0.962 0.000 0.664 0.316 NA
#> SRR1179109     2  0.4500      0.962 0.000 0.684 0.316 NA
#> SRR1179110     2  0.5152      0.962 0.000 0.664 0.316 NA
#> SRR1179111     2  0.5152      0.962 0.000 0.664 0.316 NA
#> SRR1179112     1  0.6056      0.749 0.660 0.092 0.000 NA
#> SRR1179113     1  0.5426      0.766 0.708 0.060 0.000 NA
#> SRR1179114     1  0.5426      0.766 0.708 0.060 0.000 NA
#> SRR1179115     1  0.5426      0.766 0.708 0.060 0.000 NA
#> SRR1179116     1  0.5426      0.766 0.708 0.060 0.000 NA
#> SRR1179117     1  0.5426      0.766 0.708 0.060 0.000 NA
#> SRR1179118     1  0.5426      0.766 0.708 0.060 0.000 NA
#> SRR1179119     1  0.5426      0.766 0.708 0.060 0.000 NA
#> SRR1179120     1  0.2706      0.781 0.900 0.080 0.000 NA
#> SRR1179121     1  0.2706      0.781 0.900 0.080 0.000 NA
#> SRR1179122     1  0.2706      0.781 0.900 0.080 0.000 NA
#> SRR1179123     1  0.2706      0.781 0.900 0.080 0.000 NA
#> SRR1179124     1  0.2706      0.781 0.900 0.080 0.000 NA
#> SRR1179125     1  0.2706      0.781 0.900 0.080 0.000 NA
#> SRR1179126     1  0.3335      0.778 0.860 0.120 0.000 NA
#> SRR1179127     1  0.3959      0.788 0.840 0.068 0.000 NA
#> SRR1179128     1  0.3959      0.788 0.840 0.068 0.000 NA
#> SRR1179129     1  0.3959      0.788 0.840 0.068 0.000 NA
#> SRR1179130     1  0.3959      0.788 0.840 0.068 0.000 NA
#> SRR1179131     1  0.3959      0.788 0.840 0.068 0.000 NA
#> SRR1179132     1  0.3959      0.788 0.840 0.068 0.000 NA
#> SRR1179134     1  0.3959      0.788 0.840 0.068 0.000 NA
#> SRR1179135     1  0.5285      0.710 0.524 0.008 0.000 NA
#> SRR1179136     1  0.5158      0.710 0.524 0.004 0.000 NA
#> SRR1179137     1  0.5158      0.710 0.524 0.004 0.000 NA
#> SRR1179138     1  0.4992      0.710 0.524 0.000 0.000 NA
#> SRR1179139     1  0.4992      0.710 0.524 0.000 0.000 NA
#> SRR1179140     1  0.5285      0.710 0.524 0.008 0.000 NA
#> SRR1179141     1  0.5161      0.709 0.520 0.004 0.000 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4 p5
#> SRR1179081     3   0.581      0.894 0.000 0.200 0.672 0.084 NA
#> SRR1179082     3   0.437      0.948 0.000 0.200 0.752 0.040 NA
#> SRR1179083     3   0.444      0.948 0.000 0.200 0.748 0.044 NA
#> SRR1179084     3   0.444      0.948 0.000 0.200 0.748 0.044 NA
#> SRR1179085     3   0.430      0.949 0.000 0.200 0.756 0.036 NA
#> SRR1179086     3   0.354      0.952 0.000 0.200 0.788 0.008 NA
#> SRR1179087     3   0.437      0.948 0.000 0.200 0.752 0.040 NA
#> SRR1179088     3   0.444      0.948 0.000 0.200 0.748 0.044 NA
#> SRR1179089     3   0.430      0.951 0.000 0.200 0.756 0.036 NA
#> SRR1179090     3   0.422      0.951 0.000 0.200 0.760 0.032 NA
#> SRR1179091     3   0.458      0.948 0.000 0.200 0.744 0.040 NA
#> SRR1179092     3   0.465      0.947 0.000 0.200 0.740 0.044 NA
#> SRR1179093     3   0.458      0.948 0.000 0.200 0.744 0.040 NA
#> SRR1179094     3   0.450      0.950 0.000 0.200 0.748 0.036 NA
#> SRR1179095     3   0.437      0.951 0.000 0.200 0.752 0.040 NA
#> SRR1179096     2   0.621      0.491 0.000 0.536 0.024 0.084 NA
#> SRR1179097     2   0.000      0.913 0.000 1.000 0.000 0.000 NA
#> SRR1179098     2   0.000      0.913 0.000 1.000 0.000 0.000 NA
#> SRR1179099     2   0.000      0.913 0.000 1.000 0.000 0.000 NA
#> SRR1179100     2   0.000      0.913 0.000 1.000 0.000 0.000 NA
#> SRR1179101     2   0.000      0.913 0.000 1.000 0.000 0.000 NA
#> SRR1179102     2   0.000      0.913 0.000 1.000 0.000 0.000 NA
#> SRR1179103     2   0.000      0.913 0.000 1.000 0.000 0.000 NA
#> SRR1179104     2   0.247      0.919 0.000 0.884 0.000 0.104 NA
#> SRR1179105     2   0.252      0.919 0.000 0.880 0.000 0.108 NA
#> SRR1179106     2   0.252      0.919 0.000 0.880 0.000 0.108 NA
#> SRR1179107     2   0.252      0.919 0.000 0.880 0.000 0.108 NA
#> SRR1179108     2   0.252      0.919 0.000 0.880 0.000 0.108 NA
#> SRR1179109     2   0.236      0.919 0.000 0.892 0.000 0.096 NA
#> SRR1179110     2   0.252      0.919 0.000 0.880 0.000 0.108 NA
#> SRR1179111     2   0.252      0.919 0.000 0.880 0.000 0.108 NA
#> SRR1179112     1   0.321      0.344 0.872 0.000 0.060 0.040 NA
#> SRR1179113     1   0.000      0.426 1.000 0.000 0.000 0.000 NA
#> SRR1179114     1   0.000      0.426 1.000 0.000 0.000 0.000 NA
#> SRR1179115     1   0.000      0.426 1.000 0.000 0.000 0.000 NA
#> SRR1179116     1   0.000      0.426 1.000 0.000 0.000 0.000 NA
#> SRR1179117     1   0.000      0.426 1.000 0.000 0.000 0.000 NA
#> SRR1179118     1   0.000      0.426 1.000 0.000 0.000 0.000 NA
#> SRR1179119     1   0.000      0.426 1.000 0.000 0.000 0.000 NA
#> SRR1179120     1   0.581      0.554 0.544 0.000 0.068 0.012 NA
#> SRR1179121     1   0.581      0.554 0.544 0.000 0.068 0.012 NA
#> SRR1179122     1   0.581      0.554 0.544 0.000 0.068 0.012 NA
#> SRR1179123     1   0.581      0.554 0.544 0.000 0.068 0.012 NA
#> SRR1179124     1   0.581      0.554 0.544 0.000 0.068 0.012 NA
#> SRR1179125     1   0.581      0.554 0.544 0.000 0.068 0.012 NA
#> SRR1179126     1   0.608      0.537 0.524 0.000 0.092 0.012 NA
#> SRR1179127     1   0.664      0.367 0.412 0.000 0.000 0.224 NA
#> SRR1179128     1   0.664      0.367 0.412 0.000 0.000 0.224 NA
#> SRR1179129     1   0.664      0.367 0.412 0.000 0.000 0.224 NA
#> SRR1179130     1   0.664      0.367 0.412 0.000 0.000 0.224 NA
#> SRR1179131     1   0.664      0.367 0.412 0.000 0.000 0.224 NA
#> SRR1179132     1   0.664      0.367 0.412 0.000 0.000 0.224 NA
#> SRR1179134     1   0.664      0.367 0.412 0.000 0.000 0.224 NA
#> SRR1179135     4   0.432      0.990 0.396 0.000 0.004 0.600 NA
#> SRR1179136     4   0.432      0.990 0.396 0.000 0.004 0.600 NA
#> SRR1179137     4   0.432      0.990 0.396 0.000 0.000 0.600 NA
#> SRR1179138     4   0.417      0.991 0.396 0.000 0.000 0.604 NA
#> SRR1179139     4   0.417      0.991 0.396 0.000 0.000 0.604 NA
#> SRR1179140     4   0.470      0.984 0.396 0.000 0.008 0.588 NA
#> SRR1179141     4   0.498      0.976 0.396 0.000 0.020 0.576 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1179081     3  0.5761      0.801 0.052 0.092 0.692 0.060 0.000 0.104
#> SRR1179082     3  0.2001      0.868 0.004 0.092 0.900 0.004 0.000 0.000
#> SRR1179083     3  0.2113      0.867 0.004 0.092 0.896 0.008 0.000 0.000
#> SRR1179084     3  0.2001      0.868 0.004 0.092 0.900 0.004 0.000 0.000
#> SRR1179085     3  0.2001      0.868 0.004 0.092 0.900 0.004 0.000 0.000
#> SRR1179086     3  0.2826      0.877 0.000 0.092 0.856 0.000 0.000 0.052
#> SRR1179087     3  0.1714      0.870 0.000 0.092 0.908 0.000 0.000 0.000
#> SRR1179088     3  0.2113      0.867 0.004 0.092 0.896 0.008 0.000 0.000
#> SRR1179089     3  0.4328      0.872 0.000 0.092 0.716 0.000 0.000 0.192
#> SRR1179090     3  0.4238      0.873 0.000 0.092 0.728 0.000 0.000 0.180
#> SRR1179091     3  0.4570      0.862 0.000 0.092 0.680 0.000 0.000 0.228
#> SRR1179092     3  0.4570      0.862 0.000 0.092 0.680 0.000 0.000 0.228
#> SRR1179093     3  0.4570      0.862 0.000 0.092 0.680 0.000 0.000 0.228
#> SRR1179094     3  0.4520      0.866 0.000 0.092 0.688 0.000 0.000 0.220
#> SRR1179095     3  0.4494      0.867 0.000 0.092 0.692 0.000 0.000 0.216
#> SRR1179096     6  0.6312      0.000 0.072 0.312 0.000 0.104 0.000 0.512
#> SRR1179097     2  0.4120      0.777 0.140 0.776 0.000 0.044 0.000 0.040
#> SRR1179098     2  0.4120      0.777 0.140 0.776 0.000 0.044 0.000 0.040
#> SRR1179099     2  0.4120      0.777 0.140 0.776 0.000 0.044 0.000 0.040
#> SRR1179100     2  0.4120      0.777 0.140 0.776 0.000 0.044 0.000 0.040
#> SRR1179101     2  0.4120      0.777 0.140 0.776 0.000 0.044 0.000 0.040
#> SRR1179102     2  0.4120      0.777 0.140 0.776 0.000 0.044 0.000 0.040
#> SRR1179103     2  0.4120      0.777 0.140 0.776 0.000 0.044 0.000 0.040
#> SRR1179104     2  0.0603      0.796 0.004 0.980 0.000 0.016 0.000 0.000
#> SRR1179105     2  0.0508      0.802 0.004 0.984 0.000 0.012 0.000 0.000
#> SRR1179106     2  0.0508      0.800 0.004 0.984 0.000 0.012 0.000 0.000
#> SRR1179107     2  0.0363      0.800 0.000 0.988 0.000 0.012 0.000 0.000
#> SRR1179108     2  0.0405      0.803 0.004 0.988 0.000 0.008 0.000 0.000
#> SRR1179109     2  0.0748      0.804 0.004 0.976 0.000 0.016 0.000 0.004
#> SRR1179110     2  0.0363      0.800 0.000 0.988 0.000 0.012 0.000 0.000
#> SRR1179111     2  0.0363      0.800 0.000 0.988 0.000 0.012 0.000 0.000
#> SRR1179112     4  0.8086      0.000 0.200 0.000 0.044 0.376 0.232 0.148
#> SRR1179113     5  0.8035     -0.604 0.220 0.000 0.080 0.312 0.324 0.064
#> SRR1179114     5  0.8035     -0.604 0.220 0.000 0.080 0.312 0.324 0.064
#> SRR1179115     5  0.8035     -0.604 0.220 0.000 0.080 0.312 0.324 0.064
#> SRR1179116     5  0.8035     -0.604 0.220 0.000 0.080 0.312 0.324 0.064
#> SRR1179117     5  0.8035     -0.604 0.220 0.000 0.080 0.312 0.324 0.064
#> SRR1179118     5  0.8035     -0.604 0.220 0.000 0.080 0.312 0.324 0.064
#> SRR1179119     5  0.8035     -0.604 0.220 0.000 0.080 0.312 0.324 0.064
#> SRR1179120     5  0.4091      0.342 0.008 0.000 0.000 0.472 0.520 0.000
#> SRR1179121     5  0.4091      0.342 0.008 0.000 0.000 0.472 0.520 0.000
#> SRR1179122     5  0.4091      0.342 0.008 0.000 0.000 0.472 0.520 0.000
#> SRR1179123     5  0.4091      0.342 0.008 0.000 0.000 0.472 0.520 0.000
#> SRR1179124     5  0.4091      0.342 0.008 0.000 0.000 0.472 0.520 0.000
#> SRR1179125     5  0.4091      0.342 0.008 0.000 0.000 0.472 0.520 0.000
#> SRR1179126     5  0.5342      0.284 0.020 0.000 0.008 0.460 0.472 0.040
#> SRR1179127     5  0.0146      0.370 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1179128     5  0.0260      0.370 0.000 0.000 0.000 0.000 0.992 0.008
#> SRR1179129     5  0.0146      0.370 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1179130     5  0.0000      0.370 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1179131     5  0.0146      0.370 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1179132     5  0.0146      0.370 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1179134     5  0.0260      0.370 0.000 0.000 0.000 0.000 0.992 0.008
#> SRR1179135     1  0.4241      0.980 0.608 0.000 0.000 0.000 0.368 0.024
#> SRR1179136     1  0.4138      0.983 0.616 0.000 0.004 0.000 0.368 0.012
#> SRR1179137     1  0.3672      0.988 0.632 0.000 0.000 0.000 0.368 0.000
#> SRR1179138     1  0.3672      0.988 0.632 0.000 0.000 0.000 0.368 0.000
#> SRR1179139     1  0.3807      0.987 0.628 0.000 0.000 0.000 0.368 0.004
#> SRR1179140     1  0.4004      0.986 0.620 0.000 0.000 0.000 0.368 0.012
#> SRR1179141     1  0.4241      0.976 0.608 0.000 0.000 0.000 0.368 0.024

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 1.000           1.000       1.000         0.2664 0.864   0.724
#> 4 4 0.939           0.957       0.969         0.0339 0.992   0.976
#> 5 5 0.808           0.765       0.843         0.1191 0.881   0.659
#> 6 6 0.839           0.843       0.771         0.0507 0.972   0.879

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
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1179081     3       0          1  0  0  1
#> SRR1179082     3       0          1  0  0  1
#> SRR1179083     3       0          1  0  0  1
#> SRR1179084     3       0          1  0  0  1
#> SRR1179085     3       0          1  0  0  1
#> SRR1179086     3       0          1  0  0  1
#> SRR1179087     3       0          1  0  0  1
#> SRR1179088     3       0          1  0  0  1
#> SRR1179089     3       0          1  0  0  1
#> SRR1179090     3       0          1  0  0  1
#> SRR1179091     3       0          1  0  0  1
#> SRR1179092     3       0          1  0  0  1
#> SRR1179093     3       0          1  0  0  1
#> SRR1179094     3       0          1  0  0  1
#> SRR1179095     3       0          1  0  0  1
#> SRR1179096     2       0          1  0  1  0
#> SRR1179097     2       0          1  0  1  0
#> SRR1179098     2       0          1  0  1  0
#> SRR1179099     2       0          1  0  1  0
#> SRR1179100     2       0          1  0  1  0
#> SRR1179101     2       0          1  0  1  0
#> SRR1179102     2       0          1  0  1  0
#> SRR1179103     2       0          1  0  1  0
#> SRR1179104     2       0          1  0  1  0
#> SRR1179105     2       0          1  0  1  0
#> SRR1179106     2       0          1  0  1  0
#> SRR1179107     2       0          1  0  1  0
#> SRR1179108     2       0          1  0  1  0
#> SRR1179109     2       0          1  0  1  0
#> SRR1179110     2       0          1  0  1  0
#> SRR1179111     2       0          1  0  1  0
#> SRR1179112     1       0          1  1  0  0
#> SRR1179113     1       0          1  1  0  0
#> SRR1179114     1       0          1  1  0  0
#> SRR1179115     1       0          1  1  0  0
#> SRR1179116     1       0          1  1  0  0
#> SRR1179117     1       0          1  1  0  0
#> SRR1179118     1       0          1  1  0  0
#> SRR1179119     1       0          1  1  0  0
#> SRR1179120     1       0          1  1  0  0
#> SRR1179121     1       0          1  1  0  0
#> SRR1179122     1       0          1  1  0  0
#> SRR1179123     1       0          1  1  0  0
#> SRR1179124     1       0          1  1  0  0
#> SRR1179125     1       0          1  1  0  0
#> SRR1179126     1       0          1  1  0  0
#> SRR1179127     1       0          1  1  0  0
#> SRR1179128     1       0          1  1  0  0
#> SRR1179129     1       0          1  1  0  0
#> SRR1179130     1       0          1  1  0  0
#> SRR1179131     1       0          1  1  0  0
#> SRR1179132     1       0          1  1  0  0
#> SRR1179134     1       0          1  1  0  0
#> SRR1179135     1       0          1  1  0  0
#> SRR1179136     1       0          1  1  0  0
#> SRR1179137     1       0          1  1  0  0
#> SRR1179138     1       0          1  1  0  0
#> SRR1179139     1       0          1  1  0  0
#> SRR1179140     1       0          1  1  0  0
#> SRR1179141     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1179081     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1179082     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1179083     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1179084     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1179085     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1179086     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1179087     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1179088     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1179089     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1179090     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1179091     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1179092     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1179093     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1179094     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1179095     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1179096     4  0.2814      0.000 0.000 0.132 0.000 0.868
#> SRR1179097     2  0.0188      1.000 0.000 0.996 0.004 0.000
#> SRR1179098     2  0.0188      1.000 0.000 0.996 0.004 0.000
#> SRR1179099     2  0.0188      1.000 0.000 0.996 0.004 0.000
#> SRR1179100     2  0.0188      1.000 0.000 0.996 0.004 0.000
#> SRR1179101     2  0.0188      1.000 0.000 0.996 0.004 0.000
#> SRR1179102     2  0.0188      1.000 0.000 0.996 0.004 0.000
#> SRR1179103     2  0.0188      1.000 0.000 0.996 0.004 0.000
#> SRR1179104     2  0.0188      1.000 0.000 0.996 0.004 0.000
#> SRR1179105     2  0.0188      1.000 0.000 0.996 0.004 0.000
#> SRR1179106     2  0.0188      1.000 0.000 0.996 0.004 0.000
#> SRR1179107     2  0.0188      1.000 0.000 0.996 0.004 0.000
#> SRR1179108     2  0.0188      1.000 0.000 0.996 0.004 0.000
#> SRR1179109     2  0.0188      1.000 0.000 0.996 0.004 0.000
#> SRR1179110     2  0.0188      1.000 0.000 0.996 0.004 0.000
#> SRR1179111     2  0.0188      1.000 0.000 0.996 0.004 0.000
#> SRR1179112     1  0.0188      0.948 0.996 0.000 0.000 0.004
#> SRR1179113     1  0.0188      0.948 0.996 0.000 0.000 0.004
#> SRR1179114     1  0.0188      0.948 0.996 0.000 0.000 0.004
#> SRR1179115     1  0.0188      0.948 0.996 0.000 0.000 0.004
#> SRR1179116     1  0.0188      0.948 0.996 0.000 0.000 0.004
#> SRR1179117     1  0.0188      0.948 0.996 0.000 0.000 0.004
#> SRR1179118     1  0.0188      0.948 0.996 0.000 0.000 0.004
#> SRR1179119     1  0.0188      0.948 0.996 0.000 0.000 0.004
#> SRR1179120     1  0.1743      0.945 0.940 0.004 0.000 0.056
#> SRR1179121     1  0.1743      0.945 0.940 0.004 0.000 0.056
#> SRR1179122     1  0.1743      0.945 0.940 0.004 0.000 0.056
#> SRR1179123     1  0.1743      0.945 0.940 0.004 0.000 0.056
#> SRR1179124     1  0.1743      0.945 0.940 0.004 0.000 0.056
#> SRR1179125     1  0.1743      0.945 0.940 0.004 0.000 0.056
#> SRR1179126     1  0.1743      0.945 0.940 0.004 0.000 0.056
#> SRR1179127     1  0.2345      0.947 0.900 0.000 0.000 0.100
#> SRR1179128     1  0.2345      0.947 0.900 0.000 0.000 0.100
#> SRR1179129     1  0.2345      0.947 0.900 0.000 0.000 0.100
#> SRR1179130     1  0.2345      0.947 0.900 0.000 0.000 0.100
#> SRR1179131     1  0.2345      0.947 0.900 0.000 0.000 0.100
#> SRR1179132     1  0.2345      0.947 0.900 0.000 0.000 0.100
#> SRR1179134     1  0.2345      0.947 0.900 0.000 0.000 0.100
#> SRR1179135     1  0.1867      0.939 0.928 0.000 0.000 0.072
#> SRR1179136     1  0.1867      0.939 0.928 0.000 0.000 0.072
#> SRR1179137     1  0.1867      0.939 0.928 0.000 0.000 0.072
#> SRR1179138     1  0.1867      0.939 0.928 0.000 0.000 0.072
#> SRR1179139     1  0.1867      0.939 0.928 0.000 0.000 0.072
#> SRR1179140     1  0.1867      0.939 0.928 0.000 0.000 0.072
#> SRR1179141     1  0.1867      0.939 0.928 0.000 0.000 0.072

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1179081     3  0.2377      0.861 0.128 0.000 0.872 0.000 0.000
#> SRR1179082     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR1179083     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR1179084     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR1179085     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR1179086     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR1179087     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR1179088     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR1179089     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR1179090     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR1179091     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR1179092     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR1179093     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR1179094     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR1179095     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR1179096     5  0.0290      0.000 0.000 0.008 0.000 0.000 0.992
#> SRR1179097     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR1179098     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR1179099     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR1179100     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR1179101     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR1179102     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR1179103     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR1179104     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR1179105     2  0.0162      0.997 0.004 0.996 0.000 0.000 0.000
#> SRR1179106     2  0.0162      0.997 0.004 0.996 0.000 0.000 0.000
#> SRR1179107     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR1179108     2  0.0162      0.997 0.004 0.996 0.000 0.000 0.000
#> SRR1179109     2  0.0162      0.997 0.004 0.996 0.000 0.000 0.000
#> SRR1179110     2  0.0162      0.997 0.004 0.996 0.000 0.000 0.000
#> SRR1179111     2  0.0162      0.997 0.004 0.996 0.000 0.000 0.000
#> SRR1179112     4  0.0162      0.651 0.004 0.000 0.000 0.996 0.000
#> SRR1179113     4  0.0000      0.658 0.000 0.000 0.000 1.000 0.000
#> SRR1179114     4  0.0000      0.658 0.000 0.000 0.000 1.000 0.000
#> SRR1179115     4  0.0000      0.658 0.000 0.000 0.000 1.000 0.000
#> SRR1179116     4  0.0000      0.658 0.000 0.000 0.000 1.000 0.000
#> SRR1179117     4  0.0000      0.658 0.000 0.000 0.000 1.000 0.000
#> SRR1179118     4  0.0000      0.658 0.000 0.000 0.000 1.000 0.000
#> SRR1179119     4  0.0000      0.658 0.000 0.000 0.000 1.000 0.000
#> SRR1179120     4  0.3949      0.629 0.332 0.000 0.000 0.668 0.000
#> SRR1179121     4  0.3949      0.629 0.332 0.000 0.000 0.668 0.000
#> SRR1179122     4  0.3949      0.629 0.332 0.000 0.000 0.668 0.000
#> SRR1179123     4  0.3949      0.629 0.332 0.000 0.000 0.668 0.000
#> SRR1179124     4  0.3949      0.629 0.332 0.000 0.000 0.668 0.000
#> SRR1179125     4  0.3949      0.629 0.332 0.000 0.000 0.668 0.000
#> SRR1179126     4  0.3949      0.629 0.332 0.000 0.000 0.668 0.000
#> SRR1179127     1  0.4273      0.378 0.552 0.000 0.000 0.448 0.000
#> SRR1179128     1  0.4273      0.378 0.552 0.000 0.000 0.448 0.000
#> SRR1179129     1  0.4273      0.378 0.552 0.000 0.000 0.448 0.000
#> SRR1179130     1  0.4273      0.378 0.552 0.000 0.000 0.448 0.000
#> SRR1179131     1  0.4273      0.378 0.552 0.000 0.000 0.448 0.000
#> SRR1179132     1  0.4273      0.378 0.552 0.000 0.000 0.448 0.000
#> SRR1179134     1  0.4273      0.378 0.552 0.000 0.000 0.448 0.000
#> SRR1179135     1  0.4549      0.557 0.528 0.000 0.000 0.464 0.008
#> SRR1179136     1  0.4546      0.559 0.532 0.000 0.000 0.460 0.008
#> SRR1179137     1  0.4549      0.557 0.528 0.000 0.000 0.464 0.008
#> SRR1179138     1  0.4549      0.557 0.528 0.000 0.000 0.464 0.008
#> SRR1179139     1  0.4555      0.553 0.520 0.000 0.000 0.472 0.008
#> SRR1179140     1  0.4542      0.558 0.536 0.000 0.000 0.456 0.008
#> SRR1179141     1  0.4546      0.559 0.532 0.000 0.000 0.460 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1179081     3  0.6695      0.196 0.232 0.000 0.508 0.172 0.088 0.000
#> SRR1179082     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1179083     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1179084     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1179085     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1179086     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1179087     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1179088     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1179089     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1179090     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1179091     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1179092     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1179093     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1179094     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1179095     3  0.0000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1179096     6  0.0000      0.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1179097     2  0.1375      0.970 0.028 0.952 0.000 0.008 0.008 0.004
#> SRR1179098     2  0.1375      0.970 0.028 0.952 0.000 0.008 0.008 0.004
#> SRR1179099     2  0.1375      0.970 0.028 0.952 0.000 0.008 0.008 0.004
#> SRR1179100     2  0.1375      0.970 0.028 0.952 0.000 0.008 0.008 0.004
#> SRR1179101     2  0.1375      0.970 0.028 0.952 0.000 0.008 0.008 0.004
#> SRR1179102     2  0.1375      0.970 0.028 0.952 0.000 0.008 0.008 0.004
#> SRR1179103     2  0.1375      0.970 0.028 0.952 0.000 0.008 0.008 0.004
#> SRR1179104     2  0.0405      0.970 0.000 0.988 0.000 0.004 0.008 0.000
#> SRR1179105     2  0.0146      0.973 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR1179106     2  0.0291      0.972 0.000 0.992 0.000 0.004 0.004 0.000
#> SRR1179107     2  0.0146      0.973 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1179108     2  0.0146      0.973 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1179109     2  0.0146      0.973 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1179110     2  0.0146      0.973 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1179111     2  0.0291      0.972 0.000 0.992 0.000 0.004 0.004 0.000
#> SRR1179112     4  0.4712      0.587 0.384 0.000 0.000 0.564 0.052 0.000
#> SRR1179113     4  0.4864      0.598 0.384 0.000 0.000 0.552 0.064 0.000
#> SRR1179114     4  0.4864      0.598 0.384 0.000 0.000 0.552 0.064 0.000
#> SRR1179115     4  0.4864      0.598 0.384 0.000 0.000 0.552 0.064 0.000
#> SRR1179116     4  0.4864      0.598 0.384 0.000 0.000 0.552 0.064 0.000
#> SRR1179117     4  0.4864      0.598 0.384 0.000 0.000 0.552 0.064 0.000
#> SRR1179118     4  0.4864      0.598 0.384 0.000 0.000 0.552 0.064 0.000
#> SRR1179119     4  0.4864      0.598 0.384 0.000 0.000 0.552 0.064 0.000
#> SRR1179120     4  0.3221      0.532 0.000 0.000 0.000 0.736 0.264 0.000
#> SRR1179121     4  0.3221      0.532 0.000 0.000 0.000 0.736 0.264 0.000
#> SRR1179122     4  0.3221      0.532 0.000 0.000 0.000 0.736 0.264 0.000
#> SRR1179123     4  0.3221      0.532 0.000 0.000 0.000 0.736 0.264 0.000
#> SRR1179124     4  0.3221      0.532 0.000 0.000 0.000 0.736 0.264 0.000
#> SRR1179125     4  0.3221      0.532 0.000 0.000 0.000 0.736 0.264 0.000
#> SRR1179126     4  0.3221      0.532 0.000 0.000 0.000 0.736 0.264 0.000
#> SRR1179127     5  0.1863      1.000 0.000 0.000 0.000 0.104 0.896 0.000
#> SRR1179128     5  0.1863      1.000 0.000 0.000 0.000 0.104 0.896 0.000
#> SRR1179129     5  0.1863      1.000 0.000 0.000 0.000 0.104 0.896 0.000
#> SRR1179130     5  0.1863      1.000 0.000 0.000 0.000 0.104 0.896 0.000
#> SRR1179131     5  0.1863      1.000 0.000 0.000 0.000 0.104 0.896 0.000
#> SRR1179132     5  0.1863      1.000 0.000 0.000 0.000 0.104 0.896 0.000
#> SRR1179134     5  0.1863      1.000 0.000 0.000 0.000 0.104 0.896 0.000
#> SRR1179135     1  0.3684      0.976 0.664 0.000 0.000 0.004 0.332 0.000
#> SRR1179136     1  0.4109      0.971 0.648 0.000 0.000 0.024 0.328 0.000
#> SRR1179137     1  0.3883      0.980 0.656 0.000 0.000 0.012 0.332 0.000
#> SRR1179138     1  0.3774      0.980 0.664 0.000 0.000 0.008 0.328 0.000
#> SRR1179139     1  0.3758      0.979 0.668 0.000 0.000 0.008 0.324 0.000
#> SRR1179140     1  0.3804      0.977 0.656 0.000 0.000 0.008 0.336 0.000
#> SRR1179141     1  0.4285      0.945 0.644 0.000 0.000 0.036 0.320 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 14036 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 1.000           1.000       1.000         0.2664 0.864   0.724
#> 4 4 0.852           0.880       0.925         0.1776 0.881   0.667
#> 5 5 0.852           0.844       0.855         0.0237 0.947   0.787
#> 6 6 0.946           0.880       0.946         0.0384 0.973   0.872

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1179081     3       0          1  0  0  1
#> SRR1179082     3       0          1  0  0  1
#> SRR1179083     3       0          1  0  0  1
#> SRR1179084     3       0          1  0  0  1
#> SRR1179085     3       0          1  0  0  1
#> SRR1179086     3       0          1  0  0  1
#> SRR1179087     3       0          1  0  0  1
#> SRR1179088     3       0          1  0  0  1
#> SRR1179089     3       0          1  0  0  1
#> SRR1179090     3       0          1  0  0  1
#> SRR1179091     3       0          1  0  0  1
#> SRR1179092     3       0          1  0  0  1
#> SRR1179093     3       0          1  0  0  1
#> SRR1179094     3       0          1  0  0  1
#> SRR1179095     3       0          1  0  0  1
#> SRR1179096     2       0          1  0  1  0
#> SRR1179097     2       0          1  0  1  0
#> SRR1179098     2       0          1  0  1  0
#> SRR1179099     2       0          1  0  1  0
#> SRR1179100     2       0          1  0  1  0
#> SRR1179101     2       0          1  0  1  0
#> SRR1179102     2       0          1  0  1  0
#> SRR1179103     2       0          1  0  1  0
#> SRR1179104     2       0          1  0  1  0
#> SRR1179105     2       0          1  0  1  0
#> SRR1179106     2       0          1  0  1  0
#> SRR1179107     2       0          1  0  1  0
#> SRR1179108     2       0          1  0  1  0
#> SRR1179109     2       0          1  0  1  0
#> SRR1179110     2       0          1  0  1  0
#> SRR1179111     2       0          1  0  1  0
#> SRR1179112     1       0          1  1  0  0
#> SRR1179113     1       0          1  1  0  0
#> SRR1179114     1       0          1  1  0  0
#> SRR1179115     1       0          1  1  0  0
#> SRR1179116     1       0          1  1  0  0
#> SRR1179117     1       0          1  1  0  0
#> SRR1179118     1       0          1  1  0  0
#> SRR1179119     1       0          1  1  0  0
#> SRR1179120     1       0          1  1  0  0
#> SRR1179121     1       0          1  1  0  0
#> SRR1179122     1       0          1  1  0  0
#> SRR1179123     1       0          1  1  0  0
#> SRR1179124     1       0          1  1  0  0
#> SRR1179125     1       0          1  1  0  0
#> SRR1179126     1       0          1  1  0  0
#> SRR1179127     1       0          1  1  0  0
#> SRR1179128     1       0          1  1  0  0
#> SRR1179129     1       0          1  1  0  0
#> SRR1179130     1       0          1  1  0  0
#> SRR1179131     1       0          1  1  0  0
#> SRR1179132     1       0          1  1  0  0
#> SRR1179134     1       0          1  1  0  0
#> SRR1179135     1       0          1  1  0  0
#> SRR1179136     1       0          1  1  0  0
#> SRR1179137     1       0          1  1  0  0
#> SRR1179138     1       0          1  1  0  0
#> SRR1179139     1       0          1  1  0  0
#> SRR1179140     1       0          1  1  0  0
#> SRR1179141     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2 p3    p4
#> SRR1179081     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179082     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179083     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179084     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179085     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179086     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179087     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179088     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179089     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179090     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179091     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179092     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179093     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179094     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179095     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179096     2  0.0188      0.997 0.000 0.996  0 0.004
#> SRR1179097     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179098     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179099     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179100     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179101     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179102     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179103     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179104     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179105     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179106     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179107     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179108     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179109     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179110     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179111     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179112     1  0.0000      0.848 1.000 0.000  0 0.000
#> SRR1179113     1  0.0188      0.849 0.996 0.000  0 0.004
#> SRR1179114     1  0.0188      0.849 0.996 0.000  0 0.004
#> SRR1179115     1  0.0000      0.848 1.000 0.000  0 0.000
#> SRR1179116     1  0.0707      0.848 0.980 0.000  0 0.020
#> SRR1179117     1  0.0000      0.848 1.000 0.000  0 0.000
#> SRR1179118     1  0.0000      0.848 1.000 0.000  0 0.000
#> SRR1179119     1  0.0000      0.848 1.000 0.000  0 0.000
#> SRR1179120     4  0.4164      0.754 0.264 0.000  0 0.736
#> SRR1179121     4  0.4193      0.750 0.268 0.000  0 0.732
#> SRR1179122     4  0.4103      0.759 0.256 0.000  0 0.744
#> SRR1179123     4  0.3975      0.763 0.240 0.000  0 0.760
#> SRR1179124     4  0.4103      0.759 0.256 0.000  0 0.744
#> SRR1179125     4  0.3907      0.764 0.232 0.000  0 0.768
#> SRR1179126     4  0.4164      0.754 0.264 0.000  0 0.736
#> SRR1179127     4  0.1474      0.726 0.052 0.000  0 0.948
#> SRR1179128     4  0.3688      0.618 0.208 0.000  0 0.792
#> SRR1179129     4  0.1557      0.725 0.056 0.000  0 0.944
#> SRR1179130     4  0.3873      0.589 0.228 0.000  0 0.772
#> SRR1179131     4  0.2647      0.705 0.120 0.000  0 0.880
#> SRR1179132     4  0.3356      0.660 0.176 0.000  0 0.824
#> SRR1179134     4  0.3444      0.649 0.184 0.000  0 0.816
#> SRR1179135     1  0.4564      0.651 0.672 0.000  0 0.328
#> SRR1179136     1  0.1867      0.836 0.928 0.000  0 0.072
#> SRR1179137     1  0.4222      0.714 0.728 0.000  0 0.272
#> SRR1179138     1  0.3975      0.744 0.760 0.000  0 0.240
#> SRR1179139     1  0.3172      0.773 0.840 0.000  0 0.160
#> SRR1179140     1  0.4564      0.648 0.672 0.000  0 0.328
#> SRR1179141     1  0.4193      0.713 0.732 0.000  0 0.268

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3    p4    p5
#> SRR1179081     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> SRR1179082     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> SRR1179083     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> SRR1179084     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> SRR1179085     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> SRR1179086     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> SRR1179087     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> SRR1179088     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> SRR1179089     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> SRR1179090     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> SRR1179091     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> SRR1179092     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> SRR1179093     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> SRR1179094     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> SRR1179095     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> SRR1179096     5  0.6431    -0.1245 0.216 0.284  0 0.000 0.500
#> SRR1179097     2  0.0000     1.0000 0.000 1.000  0 0.000 0.000
#> SRR1179098     2  0.0000     1.0000 0.000 1.000  0 0.000 0.000
#> SRR1179099     2  0.0000     1.0000 0.000 1.000  0 0.000 0.000
#> SRR1179100     2  0.0000     1.0000 0.000 1.000  0 0.000 0.000
#> SRR1179101     2  0.0000     1.0000 0.000 1.000  0 0.000 0.000
#> SRR1179102     2  0.0000     1.0000 0.000 1.000  0 0.000 0.000
#> SRR1179103     2  0.0000     1.0000 0.000 1.000  0 0.000 0.000
#> SRR1179104     2  0.0000     1.0000 0.000 1.000  0 0.000 0.000
#> SRR1179105     2  0.0000     1.0000 0.000 1.000  0 0.000 0.000
#> SRR1179106     2  0.0000     1.0000 0.000 1.000  0 0.000 0.000
#> SRR1179107     2  0.0000     1.0000 0.000 1.000  0 0.000 0.000
#> SRR1179108     2  0.0000     1.0000 0.000 1.000  0 0.000 0.000
#> SRR1179109     2  0.0000     1.0000 0.000 1.000  0 0.000 0.000
#> SRR1179110     2  0.0000     1.0000 0.000 1.000  0 0.000 0.000
#> SRR1179111     2  0.0000     1.0000 0.000 1.000  0 0.000 0.000
#> SRR1179112     1  0.3395     0.8065 0.764 0.000  0 0.236 0.000
#> SRR1179113     1  0.3366     0.8074 0.768 0.000  0 0.232 0.000
#> SRR1179114     1  0.3366     0.8074 0.768 0.000  0 0.232 0.000
#> SRR1179115     1  0.3395     0.8065 0.764 0.000  0 0.236 0.000
#> SRR1179116     1  0.3274     0.8057 0.780 0.000  0 0.220 0.000
#> SRR1179117     1  0.3395     0.8065 0.764 0.000  0 0.236 0.000
#> SRR1179118     1  0.3395     0.8065 0.764 0.000  0 0.236 0.000
#> SRR1179119     1  0.3395     0.8065 0.764 0.000  0 0.236 0.000
#> SRR1179120     4  0.0510     0.9805 0.016 0.000  0 0.984 0.000
#> SRR1179121     4  0.0609     0.9750 0.020 0.000  0 0.980 0.000
#> SRR1179122     4  0.0404     0.9810 0.012 0.000  0 0.988 0.000
#> SRR1179123     4  0.0451     0.9644 0.004 0.000  0 0.988 0.008
#> SRR1179124     4  0.0404     0.9810 0.012 0.000  0 0.988 0.000
#> SRR1179125     4  0.0404     0.9519 0.000 0.000  0 0.988 0.012
#> SRR1179126     4  0.0510     0.9805 0.016 0.000  0 0.984 0.000
#> SRR1179127     5  0.5344     0.6157 0.052 0.000  0 0.448 0.500
#> SRR1179128     5  0.6047     0.6696 0.124 0.000  0 0.376 0.500
#> SRR1179129     5  0.5232     0.6036 0.044 0.000  0 0.456 0.500
#> SRR1179130     5  0.6149     0.6632 0.140 0.000  0 0.360 0.500
#> SRR1179131     5  0.5631     0.6512 0.076 0.000  0 0.424 0.500
#> SRR1179132     5  0.5928     0.6644 0.108 0.000  0 0.392 0.500
#> SRR1179134     5  0.5959     0.6722 0.112 0.000  0 0.388 0.500
#> SRR1179135     5  0.6068    -0.0507 0.428 0.000  0 0.120 0.452
#> SRR1179136     1  0.6093     0.5983 0.568 0.000  0 0.192 0.240
#> SRR1179137     1  0.5312     0.5314 0.648 0.000  0 0.096 0.256
#> SRR1179138     1  0.5013     0.6339 0.696 0.000  0 0.100 0.204
#> SRR1179139     1  0.5487     0.6822 0.620 0.000  0 0.280 0.100
#> SRR1179140     1  0.5641     0.0192 0.488 0.000  0 0.076 0.436
#> SRR1179141     1  0.4744     0.5669 0.692 0.000  0 0.056 0.252

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3    p4    p5 p6
#> SRR1179081     3  0.0000      1.000 0.000 0.000  1 0.000 0.000  0
#> SRR1179082     3  0.0000      1.000 0.000 0.000  1 0.000 0.000  0
#> SRR1179083     3  0.0000      1.000 0.000 0.000  1 0.000 0.000  0
#> SRR1179084     3  0.0000      1.000 0.000 0.000  1 0.000 0.000  0
#> SRR1179085     3  0.0000      1.000 0.000 0.000  1 0.000 0.000  0
#> SRR1179086     3  0.0000      1.000 0.000 0.000  1 0.000 0.000  0
#> SRR1179087     3  0.0000      1.000 0.000 0.000  1 0.000 0.000  0
#> SRR1179088     3  0.0000      1.000 0.000 0.000  1 0.000 0.000  0
#> SRR1179089     3  0.0000      1.000 0.000 0.000  1 0.000 0.000  0
#> SRR1179090     3  0.0000      1.000 0.000 0.000  1 0.000 0.000  0
#> SRR1179091     3  0.0000      1.000 0.000 0.000  1 0.000 0.000  0
#> SRR1179092     3  0.0000      1.000 0.000 0.000  1 0.000 0.000  0
#> SRR1179093     3  0.0000      1.000 0.000 0.000  1 0.000 0.000  0
#> SRR1179094     3  0.0000      1.000 0.000 0.000  1 0.000 0.000  0
#> SRR1179095     3  0.0000      1.000 0.000 0.000  1 0.000 0.000  0
#> SRR1179096     6  0.0000      0.000 0.000 0.000  0 0.000 0.000  1
#> SRR1179097     2  0.0260      0.983 0.000 0.992  0 0.008 0.000  0
#> SRR1179098     2  0.0260      0.983 0.000 0.992  0 0.008 0.000  0
#> SRR1179099     2  0.0260      0.983 0.000 0.992  0 0.008 0.000  0
#> SRR1179100     2  0.0260      0.983 0.000 0.992  0 0.008 0.000  0
#> SRR1179101     2  0.0260      0.983 0.000 0.992  0 0.008 0.000  0
#> SRR1179102     2  0.0260      0.983 0.000 0.992  0 0.008 0.000  0
#> SRR1179103     2  0.0260      0.983 0.000 0.992  0 0.008 0.000  0
#> SRR1179104     2  0.0146      0.983 0.000 0.996  0 0.004 0.000  0
#> SRR1179105     2  0.0713      0.981 0.000 0.972  0 0.028 0.000  0
#> SRR1179106     2  0.0713      0.981 0.000 0.972  0 0.028 0.000  0
#> SRR1179107     2  0.0632      0.982 0.000 0.976  0 0.024 0.000  0
#> SRR1179108     2  0.0713      0.981 0.000 0.972  0 0.028 0.000  0
#> SRR1179109     2  0.0632      0.982 0.000 0.976  0 0.024 0.000  0
#> SRR1179110     2  0.0713      0.981 0.000 0.972  0 0.028 0.000  0
#> SRR1179111     2  0.0713      0.981 0.000 0.972  0 0.028 0.000  0
#> SRR1179112     1  0.1075      0.812 0.952 0.000  0 0.048 0.000  0
#> SRR1179113     1  0.1007      0.815 0.956 0.000  0 0.044 0.000  0
#> SRR1179114     1  0.1007      0.815 0.956 0.000  0 0.044 0.000  0
#> SRR1179115     1  0.1007      0.815 0.956 0.000  0 0.044 0.000  0
#> SRR1179116     1  0.1007      0.815 0.956 0.000  0 0.044 0.000  0
#> SRR1179117     1  0.1007      0.815 0.956 0.000  0 0.044 0.000  0
#> SRR1179118     1  0.1007      0.815 0.956 0.000  0 0.044 0.000  0
#> SRR1179119     1  0.1007      0.815 0.956 0.000  0 0.044 0.000  0
#> SRR1179120     4  0.0865      0.990 0.036 0.000  0 0.964 0.000  0
#> SRR1179121     4  0.0865      0.990 0.036 0.000  0 0.964 0.000  0
#> SRR1179122     4  0.0865      0.990 0.036 0.000  0 0.964 0.000  0
#> SRR1179123     4  0.1010      0.987 0.036 0.000  0 0.960 0.004  0
#> SRR1179124     4  0.0865      0.990 0.036 0.000  0 0.964 0.000  0
#> SRR1179125     4  0.1168      0.970 0.028 0.000  0 0.956 0.016  0
#> SRR1179126     4  0.1204      0.967 0.056 0.000  0 0.944 0.000  0
#> SRR1179127     5  0.0000      0.900 0.000 0.000  0 0.000 1.000  0
#> SRR1179128     5  0.0363      0.892 0.000 0.000  0 0.012 0.988  0
#> SRR1179129     5  0.0000      0.900 0.000 0.000  0 0.000 1.000  0
#> SRR1179130     5  0.0000      0.900 0.000 0.000  0 0.000 1.000  0
#> SRR1179131     5  0.0000      0.900 0.000 0.000  0 0.000 1.000  0
#> SRR1179132     5  0.0000      0.900 0.000 0.000  0 0.000 1.000  0
#> SRR1179134     5  0.0000      0.900 0.000 0.000  0 0.000 1.000  0
#> SRR1179135     5  0.2877      0.767 0.168 0.000  0 0.012 0.820  0
#> SRR1179136     1  0.3717      0.326 0.616 0.000  0 0.000 0.384  0
#> SRR1179137     5  0.4184      0.249 0.408 0.000  0 0.016 0.576  0
#> SRR1179138     1  0.3938      0.448 0.660 0.000  0 0.016 0.324  0
#> SRR1179139     1  0.4284      0.555 0.688 0.000  0 0.056 0.256  0
#> SRR1179140     5  0.2135      0.819 0.128 0.000  0 0.000 0.872  0
#> SRR1179141     1  0.3950      0.186 0.564 0.000  0 0.004 0.432  0

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.995       0.995         0.5060 0.492   0.492
#> 3 3 1.000           0.999       1.000         0.2724 0.864   0.724
#> 4 4 1.000           0.980       0.997         0.0151 0.992   0.976
#> 5 5 0.918           0.949       0.965         0.1672 0.881   0.659
#> 6 6 0.872           0.864       0.897         0.0320 1.000   1.000

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette   p1   p2
#> SRR1179081     2   0.000      0.989 0.00 1.00
#> SRR1179082     2   0.000      0.989 0.00 1.00
#> SRR1179083     2   0.000      0.989 0.00 1.00
#> SRR1179084     2   0.000      0.989 0.00 1.00
#> SRR1179085     2   0.000      0.989 0.00 1.00
#> SRR1179086     2   0.000      0.989 0.00 1.00
#> SRR1179087     2   0.000      0.989 0.00 1.00
#> SRR1179088     2   0.000      0.989 0.00 1.00
#> SRR1179089     2   0.000      0.989 0.00 1.00
#> SRR1179090     2   0.000      0.989 0.00 1.00
#> SRR1179091     2   0.000      0.989 0.00 1.00
#> SRR1179092     2   0.000      0.989 0.00 1.00
#> SRR1179093     2   0.000      0.989 0.00 1.00
#> SRR1179094     2   0.000      0.989 0.00 1.00
#> SRR1179095     2   0.000      0.989 0.00 1.00
#> SRR1179096     2   0.141      0.990 0.02 0.98
#> SRR1179097     2   0.141      0.990 0.02 0.98
#> SRR1179098     2   0.141      0.990 0.02 0.98
#> SRR1179099     2   0.141      0.990 0.02 0.98
#> SRR1179100     2   0.141      0.990 0.02 0.98
#> SRR1179101     2   0.141      0.990 0.02 0.98
#> SRR1179102     2   0.141      0.990 0.02 0.98
#> SRR1179103     2   0.141      0.990 0.02 0.98
#> SRR1179104     2   0.141      0.990 0.02 0.98
#> SRR1179105     2   0.141      0.990 0.02 0.98
#> SRR1179106     2   0.141      0.990 0.02 0.98
#> SRR1179107     2   0.141      0.990 0.02 0.98
#> SRR1179108     2   0.141      0.990 0.02 0.98
#> SRR1179109     2   0.141      0.990 0.02 0.98
#> SRR1179110     2   0.141      0.990 0.02 0.98
#> SRR1179111     2   0.141      0.990 0.02 0.98
#> SRR1179112     1   0.000      1.000 1.00 0.00
#> SRR1179113     1   0.000      1.000 1.00 0.00
#> SRR1179114     1   0.000      1.000 1.00 0.00
#> SRR1179115     1   0.000      1.000 1.00 0.00
#> SRR1179116     1   0.000      1.000 1.00 0.00
#> SRR1179117     1   0.000      1.000 1.00 0.00
#> SRR1179118     1   0.000      1.000 1.00 0.00
#> SRR1179119     1   0.000      1.000 1.00 0.00
#> SRR1179120     1   0.000      1.000 1.00 0.00
#> SRR1179121     1   0.000      1.000 1.00 0.00
#> SRR1179122     1   0.000      1.000 1.00 0.00
#> SRR1179123     1   0.000      1.000 1.00 0.00
#> SRR1179124     1   0.000      1.000 1.00 0.00
#> SRR1179125     1   0.000      1.000 1.00 0.00
#> SRR1179126     1   0.000      1.000 1.00 0.00
#> SRR1179127     1   0.000      1.000 1.00 0.00
#> SRR1179128     1   0.000      1.000 1.00 0.00
#> SRR1179129     1   0.000      1.000 1.00 0.00
#> SRR1179130     1   0.000      1.000 1.00 0.00
#> SRR1179131     1   0.000      1.000 1.00 0.00
#> SRR1179132     1   0.000      1.000 1.00 0.00
#> SRR1179134     1   0.000      1.000 1.00 0.00
#> SRR1179135     1   0.000      1.000 1.00 0.00
#> SRR1179136     1   0.000      1.000 1.00 0.00
#> SRR1179137     1   0.000      1.000 1.00 0.00
#> SRR1179138     1   0.000      1.000 1.00 0.00
#> SRR1179139     1   0.000      1.000 1.00 0.00
#> SRR1179140     1   0.000      1.000 1.00 0.00
#> SRR1179141     1   0.000      1.000 1.00 0.00

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2   p3
#> SRR1179081     3   0.000      1.000 0.000 0.000 1.00
#> SRR1179082     3   0.000      1.000 0.000 0.000 1.00
#> SRR1179083     3   0.000      1.000 0.000 0.000 1.00
#> SRR1179084     3   0.000      1.000 0.000 0.000 1.00
#> SRR1179085     3   0.000      1.000 0.000 0.000 1.00
#> SRR1179086     3   0.000      1.000 0.000 0.000 1.00
#> SRR1179087     3   0.000      1.000 0.000 0.000 1.00
#> SRR1179088     3   0.000      1.000 0.000 0.000 1.00
#> SRR1179089     3   0.000      1.000 0.000 0.000 1.00
#> SRR1179090     3   0.000      1.000 0.000 0.000 1.00
#> SRR1179091     3   0.000      1.000 0.000 0.000 1.00
#> SRR1179092     3   0.000      1.000 0.000 0.000 1.00
#> SRR1179093     3   0.000      1.000 0.000 0.000 1.00
#> SRR1179094     3   0.000      1.000 0.000 0.000 1.00
#> SRR1179095     3   0.000      1.000 0.000 0.000 1.00
#> SRR1179096     2   0.113      0.977 0.004 0.976 0.02
#> SRR1179097     2   0.000      0.998 0.000 1.000 0.00
#> SRR1179098     2   0.000      0.998 0.000 1.000 0.00
#> SRR1179099     2   0.000      0.998 0.000 1.000 0.00
#> SRR1179100     2   0.000      0.998 0.000 1.000 0.00
#> SRR1179101     2   0.000      0.998 0.000 1.000 0.00
#> SRR1179102     2   0.000      0.998 0.000 1.000 0.00
#> SRR1179103     2   0.000      0.998 0.000 1.000 0.00
#> SRR1179104     2   0.000      0.998 0.000 1.000 0.00
#> SRR1179105     2   0.000      0.998 0.000 1.000 0.00
#> SRR1179106     2   0.000      0.998 0.000 1.000 0.00
#> SRR1179107     2   0.000      0.998 0.000 1.000 0.00
#> SRR1179108     2   0.000      0.998 0.000 1.000 0.00
#> SRR1179109     2   0.000      0.998 0.000 1.000 0.00
#> SRR1179110     2   0.000      0.998 0.000 1.000 0.00
#> SRR1179111     2   0.000      0.998 0.000 1.000 0.00
#> SRR1179112     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179113     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179114     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179115     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179116     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179117     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179118     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179119     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179120     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179121     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179122     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179123     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179124     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179125     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179126     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179127     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179128     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179129     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179130     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179131     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179132     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179134     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179135     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179136     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179137     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179138     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179139     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179140     1   0.000      1.000 1.000 0.000 0.00
#> SRR1179141     1   0.000      1.000 1.000 0.000 0.00

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2 p3    p4
#> SRR1179081     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179082     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179083     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179084     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179085     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179086     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179087     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179088     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179089     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179090     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179091     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179092     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179093     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179094     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179095     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1179096     4  0.0524      0.000 0.008 0.004  0 0.988
#> SRR1179097     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179098     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179099     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179100     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179101     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179102     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179103     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179104     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179105     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179106     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179107     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179108     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179109     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179110     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179111     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR1179112     1  0.0000      0.994 1.000 0.000  0 0.000
#> SRR1179113     1  0.0000      0.994 1.000 0.000  0 0.000
#> SRR1179114     1  0.0000      0.994 1.000 0.000  0 0.000
#> SRR1179115     1  0.0000      0.994 1.000 0.000  0 0.000
#> SRR1179116     1  0.0000      0.994 1.000 0.000  0 0.000
#> SRR1179117     1  0.0000      0.994 1.000 0.000  0 0.000
#> SRR1179118     1  0.0000      0.994 1.000 0.000  0 0.000
#> SRR1179119     1  0.0000      0.994 1.000 0.000  0 0.000
#> SRR1179120     1  0.0000      0.994 1.000 0.000  0 0.000
#> SRR1179121     1  0.0000      0.994 1.000 0.000  0 0.000
#> SRR1179122     1  0.0000      0.994 1.000 0.000  0 0.000
#> SRR1179123     1  0.0000      0.994 1.000 0.000  0 0.000
#> SRR1179124     1  0.0000      0.994 1.000 0.000  0 0.000
#> SRR1179125     1  0.0000      0.994 1.000 0.000  0 0.000
#> SRR1179126     1  0.0000      0.994 1.000 0.000  0 0.000
#> SRR1179127     1  0.0469      0.994 0.988 0.000  0 0.012
#> SRR1179128     1  0.0469      0.994 0.988 0.000  0 0.012
#> SRR1179129     1  0.0469      0.994 0.988 0.000  0 0.012
#> SRR1179130     1  0.0469      0.994 0.988 0.000  0 0.012
#> SRR1179131     1  0.0469      0.994 0.988 0.000  0 0.012
#> SRR1179132     1  0.0469      0.994 0.988 0.000  0 0.012
#> SRR1179134     1  0.0469      0.994 0.988 0.000  0 0.012
#> SRR1179135     1  0.0469      0.994 0.988 0.000  0 0.012
#> SRR1179136     1  0.0469      0.994 0.988 0.000  0 0.012
#> SRR1179137     1  0.0469      0.994 0.988 0.000  0 0.012
#> SRR1179138     1  0.0469      0.994 0.988 0.000  0 0.012
#> SRR1179139     1  0.0469      0.994 0.988 0.000  0 0.012
#> SRR1179140     1  0.0469      0.994 0.988 0.000  0 0.012
#> SRR1179141     1  0.0469      0.994 0.988 0.000  0 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
#> SRR1179081     3  0.0609      0.980 0.000 0.000 0.98 0.020  0
#> SRR1179082     3  0.0000      0.999 0.000 0.000 1.00 0.000  0
#> SRR1179083     3  0.0000      0.999 0.000 0.000 1.00 0.000  0
#> SRR1179084     3  0.0000      0.999 0.000 0.000 1.00 0.000  0
#> SRR1179085     3  0.0000      0.999 0.000 0.000 1.00 0.000  0
#> SRR1179086     3  0.0000      0.999 0.000 0.000 1.00 0.000  0
#> SRR1179087     3  0.0000      0.999 0.000 0.000 1.00 0.000  0
#> SRR1179088     3  0.0000      0.999 0.000 0.000 1.00 0.000  0
#> SRR1179089     3  0.0000      0.999 0.000 0.000 1.00 0.000  0
#> SRR1179090     3  0.0000      0.999 0.000 0.000 1.00 0.000  0
#> SRR1179091     3  0.0000      0.999 0.000 0.000 1.00 0.000  0
#> SRR1179092     3  0.0000      0.999 0.000 0.000 1.00 0.000  0
#> SRR1179093     3  0.0000      0.999 0.000 0.000 1.00 0.000  0
#> SRR1179094     3  0.0000      0.999 0.000 0.000 1.00 0.000  0
#> SRR1179095     3  0.0000      0.999 0.000 0.000 1.00 0.000  0
#> SRR1179096     5  0.0000      0.000 0.000 0.000 0.00 0.000  1
#> SRR1179097     2  0.0510      0.989 0.000 0.984 0.00 0.016  0
#> SRR1179098     2  0.0510      0.989 0.000 0.984 0.00 0.016  0
#> SRR1179099     2  0.0510      0.989 0.000 0.984 0.00 0.016  0
#> SRR1179100     2  0.0510      0.989 0.000 0.984 0.00 0.016  0
#> SRR1179101     2  0.0510      0.989 0.000 0.984 0.00 0.016  0
#> SRR1179102     2  0.0510      0.989 0.000 0.984 0.00 0.016  0
#> SRR1179103     2  0.0510      0.989 0.000 0.984 0.00 0.016  0
#> SRR1179104     2  0.0162      0.990 0.000 0.996 0.00 0.004  0
#> SRR1179105     2  0.0162      0.990 0.000 0.996 0.00 0.004  0
#> SRR1179106     2  0.0162      0.990 0.000 0.996 0.00 0.004  0
#> SRR1179107     2  0.0000      0.990 0.000 1.000 0.00 0.000  0
#> SRR1179108     2  0.0162      0.990 0.000 0.996 0.00 0.004  0
#> SRR1179109     2  0.0162      0.990 0.000 0.996 0.00 0.004  0
#> SRR1179110     2  0.0162      0.990 0.000 0.996 0.00 0.004  0
#> SRR1179111     2  0.0162      0.990 0.000 0.996 0.00 0.004  0
#> SRR1179112     4  0.1608      0.886 0.072 0.000 0.00 0.928  0
#> SRR1179113     4  0.1410      0.904 0.060 0.000 0.00 0.940  0
#> SRR1179114     4  0.1410      0.904 0.060 0.000 0.00 0.940  0
#> SRR1179115     4  0.1410      0.904 0.060 0.000 0.00 0.940  0
#> SRR1179116     4  0.1410      0.904 0.060 0.000 0.00 0.940  0
#> SRR1179117     4  0.1410      0.904 0.060 0.000 0.00 0.940  0
#> SRR1179118     4  0.1410      0.904 0.060 0.000 0.00 0.940  0
#> SRR1179119     4  0.1410      0.904 0.060 0.000 0.00 0.940  0
#> SRR1179120     4  0.3074      0.872 0.196 0.000 0.00 0.804  0
#> SRR1179121     4  0.3109      0.871 0.200 0.000 0.00 0.800  0
#> SRR1179122     4  0.3074      0.872 0.196 0.000 0.00 0.804  0
#> SRR1179123     4  0.3039      0.874 0.192 0.000 0.00 0.808  0
#> SRR1179124     4  0.3074      0.872 0.196 0.000 0.00 0.804  0
#> SRR1179125     4  0.3074      0.872 0.196 0.000 0.00 0.804  0
#> SRR1179126     4  0.2471      0.878 0.136 0.000 0.00 0.864  0
#> SRR1179127     1  0.0404      0.987 0.988 0.000 0.00 0.012  0
#> SRR1179128     1  0.0404      0.987 0.988 0.000 0.00 0.012  0
#> SRR1179129     1  0.0404      0.987 0.988 0.000 0.00 0.012  0
#> SRR1179130     1  0.0000      0.982 1.000 0.000 0.00 0.000  0
#> SRR1179131     1  0.0000      0.982 1.000 0.000 0.00 0.000  0
#> SRR1179132     1  0.0000      0.982 1.000 0.000 0.00 0.000  0
#> SRR1179134     1  0.0162      0.980 0.996 0.000 0.00 0.004  0
#> SRR1179135     1  0.0609      0.988 0.980 0.000 0.00 0.020  0
#> SRR1179136     1  0.0703      0.987 0.976 0.000 0.00 0.024  0
#> SRR1179137     1  0.0703      0.987 0.976 0.000 0.00 0.024  0
#> SRR1179138     1  0.0703      0.987 0.976 0.000 0.00 0.024  0
#> SRR1179139     1  0.0609      0.988 0.980 0.000 0.00 0.020  0
#> SRR1179140     1  0.0703      0.987 0.976 0.000 0.00 0.024  0
#> SRR1179141     1  0.0703      0.987 0.976 0.000 0.00 0.024  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
#> SRR1179081     3  0.1765      0.901 0.000 0.000 0.904 NA 0.000  0
#> SRR1179082     3  0.0146      0.990 0.000 0.000 0.996 NA 0.000  0
#> SRR1179083     3  0.0000      0.992 0.000 0.000 1.000 NA 0.000  0
#> SRR1179084     3  0.0146      0.990 0.000 0.000 0.996 NA 0.000  0
#> SRR1179085     3  0.0000      0.992 0.000 0.000 1.000 NA 0.000  0
#> SRR1179086     3  0.0000      0.992 0.000 0.000 1.000 NA 0.000  0
#> SRR1179087     3  0.0000      0.992 0.000 0.000 1.000 NA 0.000  0
#> SRR1179088     3  0.0000      0.992 0.000 0.000 1.000 NA 0.000  0
#> SRR1179089     3  0.0260      0.987 0.000 0.000 0.992 NA 0.000  0
#> SRR1179090     3  0.0000      0.992 0.000 0.000 1.000 NA 0.000  0
#> SRR1179091     3  0.0000      0.992 0.000 0.000 1.000 NA 0.000  0
#> SRR1179092     3  0.0000      0.992 0.000 0.000 1.000 NA 0.000  0
#> SRR1179093     3  0.0000      0.992 0.000 0.000 1.000 NA 0.000  0
#> SRR1179094     3  0.0146      0.990 0.000 0.000 0.996 NA 0.000  0
#> SRR1179095     3  0.0000      0.992 0.000 0.000 1.000 NA 0.000  0
#> SRR1179096     6  0.0000      0.000 0.000 0.000 0.000 NA 0.000  1
#> SRR1179097     2  0.0260      0.778 0.000 0.992 0.000 NA 0.000  0
#> SRR1179098     2  0.0260      0.778 0.000 0.992 0.000 NA 0.000  0
#> SRR1179099     2  0.0146      0.780 0.000 0.996 0.000 NA 0.000  0
#> SRR1179100     2  0.0000      0.782 0.000 1.000 0.000 NA 0.000  0
#> SRR1179101     2  0.0000      0.782 0.000 1.000 0.000 NA 0.000  0
#> SRR1179102     2  0.0260      0.782 0.000 0.992 0.000 NA 0.000  0
#> SRR1179103     2  0.0146      0.780 0.000 0.996 0.000 NA 0.000  0
#> SRR1179104     2  0.3634      0.791 0.000 0.644 0.000 NA 0.000  0
#> SRR1179105     2  0.3659      0.788 0.000 0.636 0.000 NA 0.000  0
#> SRR1179106     2  0.3647      0.790 0.000 0.640 0.000 NA 0.000  0
#> SRR1179107     2  0.3337      0.796 0.004 0.736 0.000 NA 0.000  0
#> SRR1179108     2  0.3647      0.790 0.000 0.640 0.000 NA 0.000  0
#> SRR1179109     2  0.3695      0.781 0.000 0.624 0.000 NA 0.000  0
#> SRR1179110     2  0.3592      0.794 0.000 0.656 0.000 NA 0.000  0
#> SRR1179111     2  0.3647      0.790 0.000 0.640 0.000 NA 0.000  0
#> SRR1179112     1  0.3917      0.551 0.692 0.000 0.000 NA 0.024  0
#> SRR1179113     1  0.1010      0.830 0.960 0.000 0.000 NA 0.036  0
#> SRR1179114     1  0.1320      0.826 0.948 0.000 0.000 NA 0.036  0
#> SRR1179115     1  0.1225      0.827 0.952 0.000 0.000 NA 0.036  0
#> SRR1179116     1  0.0865      0.829 0.964 0.000 0.000 NA 0.036  0
#> SRR1179117     1  0.1010      0.830 0.960 0.000 0.000 NA 0.036  0
#> SRR1179118     1  0.1225      0.827 0.952 0.000 0.000 NA 0.036  0
#> SRR1179119     1  0.1320      0.826 0.948 0.000 0.000 NA 0.036  0
#> SRR1179120     1  0.4462      0.811 0.712 0.000 0.000 NA 0.152  0
#> SRR1179121     1  0.4499      0.810 0.708 0.000 0.000 NA 0.152  0
#> SRR1179122     1  0.4462      0.811 0.712 0.000 0.000 NA 0.152  0
#> SRR1179123     1  0.4462      0.811 0.712 0.000 0.000 NA 0.152  0
#> SRR1179124     1  0.4499      0.810 0.708 0.000 0.000 NA 0.152  0
#> SRR1179125     1  0.4499      0.810 0.708 0.000 0.000 NA 0.152  0
#> SRR1179126     1  0.4904      0.741 0.644 0.000 0.000 NA 0.120  0
#> SRR1179127     5  0.1124      0.957 0.008 0.000 0.000 NA 0.956  0
#> SRR1179128     5  0.1124      0.955 0.008 0.000 0.000 NA 0.956  0
#> SRR1179129     5  0.1196      0.955 0.008 0.000 0.000 NA 0.952  0
#> SRR1179130     5  0.1398      0.950 0.008 0.000 0.000 NA 0.940  0
#> SRR1179131     5  0.1196      0.955 0.008 0.000 0.000 NA 0.952  0
#> SRR1179132     5  0.1265      0.954 0.008 0.000 0.000 NA 0.948  0
#> SRR1179134     5  0.1858      0.934 0.012 0.000 0.000 NA 0.912  0
#> SRR1179135     5  0.0717      0.959 0.016 0.000 0.000 NA 0.976  0
#> SRR1179136     5  0.0717      0.958 0.016 0.000 0.000 NA 0.976  0
#> SRR1179137     5  0.0914      0.956 0.016 0.000 0.000 NA 0.968  0
#> SRR1179138     5  0.1320      0.946 0.016 0.000 0.000 NA 0.948  0
#> SRR1179139     5  0.0603      0.958 0.016 0.000 0.000 NA 0.980  0
#> SRR1179140     5  0.1003      0.955 0.016 0.000 0.000 NA 0.964  0
#> SRR1179141     5  0.1176      0.950 0.024 0.000 0.000 NA 0.956  0

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 1.000           0.998       0.993         0.2615 0.864   0.724
#> 4 4 0.877           0.958       0.952         0.0421 1.000   1.000
#> 5 5 0.835           0.893       0.883         0.0528 1.000   1.000
#> 6 6 0.829           0.764       0.828         0.0654 0.905   0.732

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1179081     3  0.0892      1.000 0.000 0.020 0.980
#> SRR1179082     3  0.0892      1.000 0.000 0.020 0.980
#> SRR1179083     3  0.0892      1.000 0.000 0.020 0.980
#> SRR1179084     3  0.0892      1.000 0.000 0.020 0.980
#> SRR1179085     3  0.0892      1.000 0.000 0.020 0.980
#> SRR1179086     3  0.0892      1.000 0.000 0.020 0.980
#> SRR1179087     3  0.0892      1.000 0.000 0.020 0.980
#> SRR1179088     3  0.0892      1.000 0.000 0.020 0.980
#> SRR1179089     3  0.0892      1.000 0.000 0.020 0.980
#> SRR1179090     3  0.0892      1.000 0.000 0.020 0.980
#> SRR1179091     3  0.0892      1.000 0.000 0.020 0.980
#> SRR1179092     3  0.0892      1.000 0.000 0.020 0.980
#> SRR1179093     3  0.0892      1.000 0.000 0.020 0.980
#> SRR1179094     3  0.0892      1.000 0.000 0.020 0.980
#> SRR1179095     3  0.0892      1.000 0.000 0.020 0.980
#> SRR1179096     2  0.0000      0.996 0.000 1.000 0.000
#> SRR1179097     2  0.0237      0.996 0.000 0.996 0.004
#> SRR1179098     2  0.0424      0.996 0.000 0.992 0.008
#> SRR1179099     2  0.0424      0.996 0.000 0.992 0.008
#> SRR1179100     2  0.0424      0.996 0.000 0.992 0.008
#> SRR1179101     2  0.0424      0.996 0.000 0.992 0.008
#> SRR1179102     2  0.0424      0.996 0.000 0.992 0.008
#> SRR1179103     2  0.0424      0.996 0.000 0.992 0.008
#> SRR1179104     2  0.0000      0.996 0.000 1.000 0.000
#> SRR1179105     2  0.0000      0.996 0.000 1.000 0.000
#> SRR1179106     2  0.0237      0.996 0.000 0.996 0.004
#> SRR1179107     2  0.0237      0.996 0.000 0.996 0.004
#> SRR1179108     2  0.0000      0.996 0.000 1.000 0.000
#> SRR1179109     2  0.0000      0.996 0.000 1.000 0.000
#> SRR1179110     2  0.0000      0.996 0.000 1.000 0.000
#> SRR1179111     2  0.0000      0.996 0.000 1.000 0.000
#> SRR1179112     1  0.0000      0.998 1.000 0.000 0.000
#> SRR1179113     1  0.0000      0.998 1.000 0.000 0.000
#> SRR1179114     1  0.0000      0.998 1.000 0.000 0.000
#> SRR1179115     1  0.0000      0.998 1.000 0.000 0.000
#> SRR1179116     1  0.0000      0.998 1.000 0.000 0.000
#> SRR1179117     1  0.0000      0.998 1.000 0.000 0.000
#> SRR1179118     1  0.0000      0.998 1.000 0.000 0.000
#> SRR1179119     1  0.0000      0.998 1.000 0.000 0.000
#> SRR1179120     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1179121     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1179122     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1179123     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1179124     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1179125     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1179126     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1179127     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1179128     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1179129     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1179130     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1179131     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1179132     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1179134     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1179135     1  0.0000      0.998 1.000 0.000 0.000
#> SRR1179136     1  0.0000      0.998 1.000 0.000 0.000
#> SRR1179137     1  0.0000      0.998 1.000 0.000 0.000
#> SRR1179138     1  0.0000      0.998 1.000 0.000 0.000
#> SRR1179139     1  0.0000      0.998 1.000 0.000 0.000
#> SRR1179140     1  0.0000      0.998 1.000 0.000 0.000
#> SRR1179141     1  0.0000      0.998 1.000 0.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
#> SRR1179081     3  0.0336      0.996 0.000 0.000 0.992 NA
#> SRR1179082     3  0.0000      0.998 0.000 0.000 1.000 NA
#> SRR1179083     3  0.0188      0.997 0.000 0.000 0.996 NA
#> SRR1179084     3  0.0188      0.997 0.000 0.000 0.996 NA
#> SRR1179085     3  0.0336      0.996 0.000 0.000 0.992 NA
#> SRR1179086     3  0.0000      0.998 0.000 0.000 1.000 NA
#> SRR1179087     3  0.0000      0.998 0.000 0.000 1.000 NA
#> SRR1179088     3  0.0000      0.998 0.000 0.000 1.000 NA
#> SRR1179089     3  0.0188      0.997 0.000 0.000 0.996 NA
#> SRR1179090     3  0.0188      0.997 0.000 0.000 0.996 NA
#> SRR1179091     3  0.0000      0.998 0.000 0.000 1.000 NA
#> SRR1179092     3  0.0188      0.997 0.000 0.000 0.996 NA
#> SRR1179093     3  0.0000      0.998 0.000 0.000 1.000 NA
#> SRR1179094     3  0.0188      0.997 0.000 0.000 0.996 NA
#> SRR1179095     3  0.0000      0.998 0.000 0.000 1.000 NA
#> SRR1179096     2  0.4686      0.816 0.000 0.788 0.068 NA
#> SRR1179097     2  0.0188      0.986 0.000 0.996 0.004 NA
#> SRR1179098     2  0.0000      0.986 0.000 1.000 0.000 NA
#> SRR1179099     2  0.0188      0.986 0.000 0.996 0.004 NA
#> SRR1179100     2  0.0188      0.986 0.000 0.996 0.004 NA
#> SRR1179101     2  0.0188      0.986 0.000 0.996 0.004 NA
#> SRR1179102     2  0.0188      0.986 0.000 0.996 0.004 NA
#> SRR1179103     2  0.0524      0.984 0.000 0.988 0.004 NA
#> SRR1179104     2  0.0188      0.986 0.000 0.996 0.000 NA
#> SRR1179105     2  0.0188      0.986 0.000 0.996 0.000 NA
#> SRR1179106     2  0.0188      0.986 0.000 0.996 0.000 NA
#> SRR1179107     2  0.0000      0.986 0.000 1.000 0.000 NA
#> SRR1179108     2  0.0188      0.986 0.000 0.996 0.000 NA
#> SRR1179109     2  0.0188      0.986 0.000 0.996 0.000 NA
#> SRR1179110     2  0.0188      0.986 0.000 0.996 0.000 NA
#> SRR1179111     2  0.0000      0.986 0.000 1.000 0.000 NA
#> SRR1179112     1  0.0336      0.932 0.992 0.000 0.000 NA
#> SRR1179113     1  0.0000      0.933 1.000 0.000 0.000 NA
#> SRR1179114     1  0.0188      0.932 0.996 0.000 0.000 NA
#> SRR1179115     1  0.0188      0.932 0.996 0.000 0.000 NA
#> SRR1179116     1  0.0188      0.932 0.996 0.000 0.000 NA
#> SRR1179117     1  0.0188      0.932 0.996 0.000 0.000 NA
#> SRR1179118     1  0.0000      0.933 1.000 0.000 0.000 NA
#> SRR1179119     1  0.0336      0.933 0.992 0.000 0.000 NA
#> SRR1179120     1  0.2647      0.929 0.880 0.000 0.000 NA
#> SRR1179121     1  0.2647      0.929 0.880 0.000 0.000 NA
#> SRR1179122     1  0.2647      0.929 0.880 0.000 0.000 NA
#> SRR1179123     1  0.2647      0.929 0.880 0.000 0.000 NA
#> SRR1179124     1  0.2647      0.929 0.880 0.000 0.000 NA
#> SRR1179125     1  0.2647      0.929 0.880 0.000 0.000 NA
#> SRR1179126     1  0.2647      0.929 0.880 0.000 0.000 NA
#> SRR1179127     1  0.3172      0.929 0.840 0.000 0.000 NA
#> SRR1179128     1  0.3123      0.930 0.844 0.000 0.000 NA
#> SRR1179129     1  0.3074      0.930 0.848 0.000 0.000 NA
#> SRR1179130     1  0.3074      0.931 0.848 0.000 0.000 NA
#> SRR1179131     1  0.3172      0.929 0.840 0.000 0.000 NA
#> SRR1179132     1  0.3024      0.931 0.852 0.000 0.000 NA
#> SRR1179134     1  0.3024      0.931 0.852 0.000 0.000 NA
#> SRR1179135     1  0.2149      0.916 0.912 0.000 0.000 NA
#> SRR1179136     1  0.2081      0.918 0.916 0.000 0.000 NA
#> SRR1179137     1  0.2149      0.916 0.912 0.000 0.000 NA
#> SRR1179138     1  0.2216      0.917 0.908 0.000 0.000 NA
#> SRR1179139     1  0.2149      0.916 0.912 0.000 0.000 NA
#> SRR1179140     1  0.2149      0.916 0.912 0.000 0.000 NA
#> SRR1179141     1  0.2149      0.916 0.912 0.000 0.000 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4 p5
#> SRR1179081     3  0.0510      0.990 0.000 0.000 0.984 0.000 NA
#> SRR1179082     3  0.0162      0.996 0.000 0.000 0.996 0.000 NA
#> SRR1179083     3  0.0000      0.998 0.000 0.000 1.000 0.000 NA
#> SRR1179084     3  0.0000      0.998 0.000 0.000 1.000 0.000 NA
#> SRR1179085     3  0.0000      0.998 0.000 0.000 1.000 0.000 NA
#> SRR1179086     3  0.0000      0.998 0.000 0.000 1.000 0.000 NA
#> SRR1179087     3  0.0000      0.998 0.000 0.000 1.000 0.000 NA
#> SRR1179088     3  0.0000      0.998 0.000 0.000 1.000 0.000 NA
#> SRR1179089     3  0.0000      0.998 0.000 0.000 1.000 0.000 NA
#> SRR1179090     3  0.0000      0.998 0.000 0.000 1.000 0.000 NA
#> SRR1179091     3  0.0000      0.998 0.000 0.000 1.000 0.000 NA
#> SRR1179092     3  0.0162      0.997 0.000 0.000 0.996 0.000 NA
#> SRR1179093     3  0.0162      0.997 0.000 0.000 0.996 0.000 NA
#> SRR1179094     3  0.0404      0.993 0.000 0.000 0.988 0.000 NA
#> SRR1179095     3  0.0000      0.998 0.000 0.000 1.000 0.000 NA
#> SRR1179096     2  0.5714      0.533 0.000 0.512 0.072 0.004 NA
#> SRR1179097     2  0.0451      0.971 0.000 0.988 0.008 0.000 NA
#> SRR1179098     2  0.0324      0.972 0.000 0.992 0.004 0.000 NA
#> SRR1179099     2  0.0579      0.970 0.000 0.984 0.008 0.000 NA
#> SRR1179100     2  0.0693      0.967 0.000 0.980 0.012 0.000 NA
#> SRR1179101     2  0.0290      0.972 0.000 0.992 0.008 0.000 NA
#> SRR1179102     2  0.0324      0.972 0.000 0.992 0.004 0.000 NA
#> SRR1179103     2  0.0290      0.972 0.000 0.992 0.008 0.000 NA
#> SRR1179104     2  0.0324      0.972 0.000 0.992 0.004 0.000 NA
#> SRR1179105     2  0.0451      0.972 0.000 0.988 0.004 0.000 NA
#> SRR1179106     2  0.0324      0.972 0.000 0.992 0.004 0.000 NA
#> SRR1179107     2  0.0324      0.972 0.000 0.992 0.004 0.000 NA
#> SRR1179108     2  0.0162      0.972 0.000 0.996 0.004 0.000 NA
#> SRR1179109     2  0.0324      0.972 0.000 0.992 0.004 0.000 NA
#> SRR1179110     2  0.0162      0.972 0.000 0.996 0.004 0.000 NA
#> SRR1179111     2  0.0162      0.972 0.000 0.996 0.004 0.000 NA
#> SRR1179112     1  0.0290      0.829 0.992 0.000 0.000 0.008 NA
#> SRR1179113     1  0.0000      0.830 1.000 0.000 0.000 0.000 NA
#> SRR1179114     1  0.0000      0.830 1.000 0.000 0.000 0.000 NA
#> SRR1179115     1  0.0000      0.830 1.000 0.000 0.000 0.000 NA
#> SRR1179116     1  0.0000      0.830 1.000 0.000 0.000 0.000 NA
#> SRR1179117     1  0.0000      0.830 1.000 0.000 0.000 0.000 NA
#> SRR1179118     1  0.0162      0.830 0.996 0.000 0.000 0.004 NA
#> SRR1179119     1  0.0000      0.830 1.000 0.000 0.000 0.000 NA
#> SRR1179120     1  0.3612      0.820 0.732 0.000 0.000 0.268 NA
#> SRR1179121     1  0.3612      0.820 0.732 0.000 0.000 0.268 NA
#> SRR1179122     1  0.3612      0.820 0.732 0.000 0.000 0.268 NA
#> SRR1179123     1  0.3612      0.820 0.732 0.000 0.000 0.268 NA
#> SRR1179124     1  0.3612      0.820 0.732 0.000 0.000 0.268 NA
#> SRR1179125     1  0.3612      0.820 0.732 0.000 0.000 0.268 NA
#> SRR1179126     1  0.3636      0.818 0.728 0.000 0.000 0.272 NA
#> SRR1179127     1  0.4211      0.823 0.636 0.000 0.000 0.360 NA
#> SRR1179128     1  0.3932      0.830 0.672 0.000 0.000 0.328 NA
#> SRR1179129     1  0.3999      0.822 0.656 0.000 0.000 0.344 NA
#> SRR1179130     1  0.4015      0.827 0.652 0.000 0.000 0.348 NA
#> SRR1179131     1  0.4225      0.820 0.632 0.000 0.000 0.364 NA
#> SRR1179132     1  0.3999      0.825 0.656 0.000 0.000 0.344 NA
#> SRR1179134     1  0.3816      0.833 0.696 0.000 0.000 0.304 NA
#> SRR1179135     1  0.3906      0.768 0.744 0.000 0.000 0.240 NA
#> SRR1179136     1  0.3642      0.773 0.760 0.000 0.000 0.232 NA
#> SRR1179137     1  0.3863      0.764 0.740 0.000 0.000 0.248 NA
#> SRR1179138     1  0.3779      0.773 0.752 0.000 0.000 0.236 NA
#> SRR1179139     1  0.3779      0.773 0.752 0.000 0.000 0.236 NA
#> SRR1179140     1  0.3961      0.763 0.736 0.000 0.000 0.248 NA
#> SRR1179141     1  0.3863      0.764 0.740 0.000 0.000 0.248 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3 p4    p5    p6
#> SRR1179081     3  0.1503      0.941 0.016 0.000 0.944 NA 0.000 0.032
#> SRR1179082     3  0.0291      0.987 0.000 0.000 0.992 NA 0.000 0.004
#> SRR1179083     3  0.0551      0.984 0.004 0.000 0.984 NA 0.000 0.008
#> SRR1179084     3  0.0291      0.988 0.000 0.004 0.992 NA 0.000 0.000
#> SRR1179085     3  0.0291      0.988 0.000 0.004 0.992 NA 0.000 0.000
#> SRR1179086     3  0.0260      0.986 0.000 0.000 0.992 NA 0.000 0.008
#> SRR1179087     3  0.0551      0.986 0.000 0.004 0.984 NA 0.000 0.008
#> SRR1179088     3  0.0291      0.988 0.000 0.004 0.992 NA 0.000 0.000
#> SRR1179089     3  0.0260      0.986 0.000 0.000 0.992 NA 0.000 0.008
#> SRR1179090     3  0.0146      0.988 0.004 0.000 0.996 NA 0.000 0.000
#> SRR1179091     3  0.0291      0.988 0.004 0.004 0.992 NA 0.000 0.000
#> SRR1179092     3  0.0436      0.987 0.004 0.004 0.988 NA 0.000 0.004
#> SRR1179093     3  0.0260      0.986 0.000 0.000 0.992 NA 0.000 0.008
#> SRR1179094     3  0.0146      0.988 0.000 0.004 0.996 NA 0.000 0.000
#> SRR1179095     3  0.0291      0.988 0.000 0.004 0.992 NA 0.000 0.000
#> SRR1179096     6  0.4634      0.000 0.000 0.188 0.124 NA 0.000 0.688
#> SRR1179097     2  0.0891      0.972 0.000 0.968 0.024 NA 0.000 0.008
#> SRR1179098     2  0.0622      0.977 0.000 0.980 0.012 NA 0.000 0.008
#> SRR1179099     2  0.0858      0.970 0.000 0.968 0.028 NA 0.000 0.004
#> SRR1179100     2  0.1116      0.966 0.000 0.960 0.028 NA 0.000 0.008
#> SRR1179101     2  0.1080      0.964 0.000 0.960 0.032 NA 0.000 0.004
#> SRR1179102     2  0.0547      0.975 0.000 0.980 0.020 NA 0.000 0.000
#> SRR1179103     2  0.1225      0.957 0.000 0.952 0.036 NA 0.000 0.000
#> SRR1179104     2  0.0520      0.978 0.000 0.984 0.008 NA 0.000 0.000
#> SRR1179105     2  0.0436      0.974 0.000 0.988 0.004 NA 0.000 0.004
#> SRR1179106     2  0.0405      0.976 0.000 0.988 0.004 NA 0.000 0.000
#> SRR1179107     2  0.0260      0.977 0.000 0.992 0.008 NA 0.000 0.000
#> SRR1179108     2  0.0146      0.973 0.000 0.996 0.000 NA 0.000 0.000
#> SRR1179109     2  0.0551      0.974 0.000 0.984 0.004 NA 0.000 0.004
#> SRR1179110     2  0.0665      0.976 0.000 0.980 0.008 NA 0.000 0.004
#> SRR1179111     2  0.0405      0.974 0.000 0.988 0.004 NA 0.000 0.000
#> SRR1179112     5  0.0405      0.408 0.004 0.000 0.000 NA 0.988 0.000
#> SRR1179113     5  0.0146      0.411 0.004 0.000 0.000 NA 0.996 0.000
#> SRR1179114     5  0.0146      0.418 0.000 0.000 0.000 NA 0.996 0.000
#> SRR1179115     5  0.0146      0.411 0.004 0.000 0.000 NA 0.996 0.000
#> SRR1179116     5  0.0146      0.420 0.000 0.000 0.000 NA 0.996 0.000
#> SRR1179117     5  0.0260      0.421 0.000 0.000 0.000 NA 0.992 0.000
#> SRR1179118     5  0.0146      0.411 0.004 0.000 0.000 NA 0.996 0.000
#> SRR1179119     5  0.0363      0.424 0.000 0.000 0.000 NA 0.988 0.000
#> SRR1179120     5  0.4089      0.584 0.008 0.000 0.000 NA 0.524 0.000
#> SRR1179121     5  0.4089      0.584 0.008 0.000 0.000 NA 0.524 0.000
#> SRR1179122     5  0.4089      0.584 0.008 0.000 0.000 NA 0.524 0.000
#> SRR1179123     5  0.4091      0.583 0.008 0.000 0.000 NA 0.520 0.000
#> SRR1179124     5  0.4091      0.583 0.008 0.000 0.000 NA 0.520 0.000
#> SRR1179125     5  0.4091      0.583 0.008 0.000 0.000 NA 0.520 0.000
#> SRR1179126     5  0.4091      0.583 0.008 0.000 0.000 NA 0.520 0.000
#> SRR1179127     5  0.6078      0.319 0.320 0.000 0.000 NA 0.396 0.000
#> SRR1179128     5  0.5994      0.298 0.316 0.000 0.000 NA 0.432 0.000
#> SRR1179129     5  0.6062      0.390 0.268 0.000 0.000 NA 0.396 0.000
#> SRR1179130     5  0.6013      0.272 0.328 0.000 0.000 NA 0.420 0.000
#> SRR1179131     5  0.6085      0.318 0.320 0.000 0.000 NA 0.392 0.000
#> SRR1179132     5  0.5992      0.341 0.292 0.000 0.000 NA 0.440 0.000
#> SRR1179134     5  0.5958      0.406 0.248 0.000 0.000 NA 0.448 0.000
#> SRR1179135     1  0.3872      0.969 0.604 0.000 0.000 NA 0.392 0.000
#> SRR1179136     1  0.3823      0.950 0.564 0.000 0.000 NA 0.436 0.000
#> SRR1179137     1  0.3747      0.968 0.604 0.000 0.000 NA 0.396 0.000
#> SRR1179138     1  0.3765      0.973 0.596 0.000 0.000 NA 0.404 0.000
#> SRR1179139     1  0.3823      0.950 0.564 0.000 0.000 NA 0.436 0.000
#> SRR1179140     1  0.3872      0.968 0.604 0.000 0.000 NA 0.392 0.000
#> SRR1179141     1  0.3907      0.972 0.588 0.000 0.000 NA 0.408 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-NMF-collect-classes

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

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

collect_plots(res)

plot of chunk MAD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 0.868           0.831       0.902         0.1246 0.983   0.966
#> 4 4 1.000           0.983       1.000         0.1409 0.873   0.732
#> 5 5 1.000           0.967       0.989         0.1371 0.913   0.750
#> 6 6 1.000           0.980       0.993         0.0778 0.937   0.758

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1    p2    p3
#> SRR1179081     3    0.00      0.724  0 0.000 1.000
#> SRR1179082     3    0.00      0.724  0 0.000 1.000
#> SRR1179083     3    0.00      0.724  0 0.000 1.000
#> SRR1179084     3    0.00      0.724  0 0.000 1.000
#> SRR1179085     3    0.00      0.724  0 0.000 1.000
#> SRR1179086     3    0.00      0.724  0 0.000 1.000
#> SRR1179087     3    0.00      0.724  0 0.000 1.000
#> SRR1179088     3    0.00      0.724  0 0.000 1.000
#> SRR1179089     3    0.00      0.724  0 0.000 1.000
#> SRR1179090     3    0.00      0.724  0 0.000 1.000
#> SRR1179091     3    0.00      0.724  0 0.000 1.000
#> SRR1179092     3    0.00      0.724  0 0.000 1.000
#> SRR1179093     3    0.00      0.724  0 0.000 1.000
#> SRR1179094     3    0.00      0.724  0 0.000 1.000
#> SRR1179095     3    0.00      0.724  0 0.000 1.000
#> SRR1179096     2    0.00      0.000  0 1.000 0.000
#> SRR1179097     3    0.61      0.667  0 0.392 0.608
#> SRR1179098     3    0.61      0.667  0 0.392 0.608
#> SRR1179099     3    0.61      0.667  0 0.392 0.608
#> SRR1179100     3    0.61      0.667  0 0.392 0.608
#> SRR1179101     3    0.61      0.667  0 0.392 0.608
#> SRR1179102     3    0.61      0.667  0 0.392 0.608
#> SRR1179103     3    0.61      0.667  0 0.392 0.608
#> SRR1179104     3    0.61      0.667  0 0.392 0.608
#> SRR1179105     3    0.61      0.667  0 0.392 0.608
#> SRR1179106     3    0.61      0.667  0 0.392 0.608
#> SRR1179107     3    0.61      0.667  0 0.392 0.608
#> SRR1179108     3    0.61      0.667  0 0.392 0.608
#> SRR1179109     3    0.61      0.667  0 0.392 0.608
#> SRR1179110     3    0.61      0.667  0 0.392 0.608
#> SRR1179111     3    0.61      0.667  0 0.392 0.608
#> SRR1179112     1    0.00      1.000  1 0.000 0.000
#> SRR1179113     1    0.00      1.000  1 0.000 0.000
#> SRR1179114     1    0.00      1.000  1 0.000 0.000
#> SRR1179115     1    0.00      1.000  1 0.000 0.000
#> SRR1179116     1    0.00      1.000  1 0.000 0.000
#> SRR1179117     1    0.00      1.000  1 0.000 0.000
#> SRR1179118     1    0.00      1.000  1 0.000 0.000
#> SRR1179119     1    0.00      1.000  1 0.000 0.000
#> SRR1179120     1    0.00      1.000  1 0.000 0.000
#> SRR1179121     1    0.00      1.000  1 0.000 0.000
#> SRR1179122     1    0.00      1.000  1 0.000 0.000
#> SRR1179123     1    0.00      1.000  1 0.000 0.000
#> SRR1179124     1    0.00      1.000  1 0.000 0.000
#> SRR1179125     1    0.00      1.000  1 0.000 0.000
#> SRR1179126     1    0.00      1.000  1 0.000 0.000
#> SRR1179127     1    0.00      1.000  1 0.000 0.000
#> SRR1179128     1    0.00      1.000  1 0.000 0.000
#> SRR1179129     1    0.00      1.000  1 0.000 0.000
#> SRR1179130     1    0.00      1.000  1 0.000 0.000
#> SRR1179131     1    0.00      1.000  1 0.000 0.000
#> SRR1179132     1    0.00      1.000  1 0.000 0.000
#> SRR1179134     1    0.00      1.000  1 0.000 0.000
#> SRR1179135     1    0.00      1.000  1 0.000 0.000
#> SRR1179136     1    0.00      1.000  1 0.000 0.000
#> SRR1179137     1    0.00      1.000  1 0.000 0.000
#> SRR1179138     1    0.00      1.000  1 0.000 0.000
#> SRR1179139     1    0.00      1.000  1 0.000 0.000
#> SRR1179140     1    0.00      1.000  1 0.000 0.000
#> SRR1179141     1    0.00      1.000  1 0.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
#> SRR1179081     3       0          1  0  0  1  0
#> SRR1179082     3       0          1  0  0  1  0
#> SRR1179083     3       0          1  0  0  1  0
#> SRR1179084     3       0          1  0  0  1  0
#> SRR1179085     3       0          1  0  0  1  0
#> SRR1179086     3       0          1  0  0  1  0
#> SRR1179087     3       0          1  0  0  1  0
#> SRR1179088     3       0          1  0  0  1  0
#> SRR1179089     3       0          1  0  0  1  0
#> SRR1179090     3       0          1  0  0  1  0
#> SRR1179091     3       0          1  0  0  1  0
#> SRR1179092     3       0          1  0  0  1  0
#> SRR1179093     3       0          1  0  0  1  0
#> SRR1179094     3       0          1  0  0  1  0
#> SRR1179095     3       0          1  0  0  1  0
#> SRR1179096     4       0          0  0  0  0  1
#> SRR1179097     2       0          1  0  1  0  0
#> SRR1179098     2       0          1  0  1  0  0
#> SRR1179099     2       0          1  0  1  0  0
#> SRR1179100     2       0          1  0  1  0  0
#> SRR1179101     2       0          1  0  1  0  0
#> SRR1179102     2       0          1  0  1  0  0
#> SRR1179103     2       0          1  0  1  0  0
#> SRR1179104     2       0          1  0  1  0  0
#> SRR1179105     2       0          1  0  1  0  0
#> SRR1179106     2       0          1  0  1  0  0
#> SRR1179107     2       0          1  0  1  0  0
#> SRR1179108     2       0          1  0  1  0  0
#> SRR1179109     2       0          1  0  1  0  0
#> SRR1179110     2       0          1  0  1  0  0
#> SRR1179111     2       0          1  0  1  0  0
#> SRR1179112     1       0          1  1  0  0  0
#> SRR1179113     1       0          1  1  0  0  0
#> SRR1179114     1       0          1  1  0  0  0
#> SRR1179115     1       0          1  1  0  0  0
#> SRR1179116     1       0          1  1  0  0  0
#> SRR1179117     1       0          1  1  0  0  0
#> SRR1179118     1       0          1  1  0  0  0
#> SRR1179119     1       0          1  1  0  0  0
#> SRR1179120     1       0          1  1  0  0  0
#> SRR1179121     1       0          1  1  0  0  0
#> SRR1179122     1       0          1  1  0  0  0
#> SRR1179123     1       0          1  1  0  0  0
#> SRR1179124     1       0          1  1  0  0  0
#> SRR1179125     1       0          1  1  0  0  0
#> SRR1179126     1       0          1  1  0  0  0
#> SRR1179127     1       0          1  1  0  0  0
#> SRR1179128     1       0          1  1  0  0  0
#> SRR1179129     1       0          1  1  0  0  0
#> SRR1179130     1       0          1  1  0  0  0
#> SRR1179131     1       0          1  1  0  0  0
#> SRR1179132     1       0          1  1  0  0  0
#> SRR1179134     1       0          1  1  0  0  0
#> SRR1179135     1       0          1  1  0  0  0
#> SRR1179136     1       0          1  1  0  0  0
#> SRR1179137     1       0          1  1  0  0  0
#> SRR1179138     1       0          1  1  0  0  0
#> SRR1179139     1       0          1  1  0  0  0
#> SRR1179140     1       0          1  1  0  0  0
#> SRR1179141     1       0          1  1  0  0  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette   p1 p2 p3   p4 p5
#> SRR1179081     3   0.000      1.000 0.00  0  1 0.00  0
#> SRR1179082     3   0.000      1.000 0.00  0  1 0.00  0
#> SRR1179083     3   0.000      1.000 0.00  0  1 0.00  0
#> SRR1179084     3   0.000      1.000 0.00  0  1 0.00  0
#> SRR1179085     3   0.000      1.000 0.00  0  1 0.00  0
#> SRR1179086     3   0.000      1.000 0.00  0  1 0.00  0
#> SRR1179087     3   0.000      1.000 0.00  0  1 0.00  0
#> SRR1179088     3   0.000      1.000 0.00  0  1 0.00  0
#> SRR1179089     3   0.000      1.000 0.00  0  1 0.00  0
#> SRR1179090     3   0.000      1.000 0.00  0  1 0.00  0
#> SRR1179091     3   0.000      1.000 0.00  0  1 0.00  0
#> SRR1179092     3   0.000      1.000 0.00  0  1 0.00  0
#> SRR1179093     3   0.000      1.000 0.00  0  1 0.00  0
#> SRR1179094     3   0.000      1.000 0.00  0  1 0.00  0
#> SRR1179095     3   0.000      1.000 0.00  0  1 0.00  0
#> SRR1179096     5   0.000      0.000 0.00  0  0 0.00  1
#> SRR1179097     2   0.000      1.000 0.00  1  0 0.00  0
#> SRR1179098     2   0.000      1.000 0.00  1  0 0.00  0
#> SRR1179099     2   0.000      1.000 0.00  1  0 0.00  0
#> SRR1179100     2   0.000      1.000 0.00  1  0 0.00  0
#> SRR1179101     2   0.000      1.000 0.00  1  0 0.00  0
#> SRR1179102     2   0.000      1.000 0.00  1  0 0.00  0
#> SRR1179103     2   0.000      1.000 0.00  1  0 0.00  0
#> SRR1179104     2   0.000      1.000 0.00  1  0 0.00  0
#> SRR1179105     2   0.000      1.000 0.00  1  0 0.00  0
#> SRR1179106     2   0.000      1.000 0.00  1  0 0.00  0
#> SRR1179107     2   0.000      1.000 0.00  1  0 0.00  0
#> SRR1179108     2   0.000      1.000 0.00  1  0 0.00  0
#> SRR1179109     2   0.000      1.000 0.00  1  0 0.00  0
#> SRR1179110     2   0.000      1.000 0.00  1  0 0.00  0
#> SRR1179111     2   0.000      1.000 0.00  1  0 0.00  0
#> SRR1179112     1   0.173      0.937 0.92  0  0 0.08  0
#> SRR1179113     1   0.173      0.937 0.92  0  0 0.08  0
#> SRR1179114     1   0.173      0.937 0.92  0  0 0.08  0
#> SRR1179115     1   0.173      0.937 0.92  0  0 0.08  0
#> SRR1179116     1   0.173      0.937 0.92  0  0 0.08  0
#> SRR1179117     1   0.173      0.937 0.92  0  0 0.08  0
#> SRR1179118     1   0.173      0.937 0.92  0  0 0.08  0
#> SRR1179119     1   0.173      0.937 0.92  0  0 0.08  0
#> SRR1179120     4   0.000      1.000 0.00  0  0 1.00  0
#> SRR1179121     4   0.000      1.000 0.00  0  0 1.00  0
#> SRR1179122     4   0.000      1.000 0.00  0  0 1.00  0
#> SRR1179123     4   0.000      1.000 0.00  0  0 1.00  0
#> SRR1179124     4   0.000      1.000 0.00  0  0 1.00  0
#> SRR1179125     4   0.000      1.000 0.00  0  0 1.00  0
#> SRR1179126     4   0.000      1.000 0.00  0  0 1.00  0
#> SRR1179127     1   0.000      0.965 1.00  0  0 0.00  0
#> SRR1179128     1   0.000      0.965 1.00  0  0 0.00  0
#> SRR1179129     1   0.000      0.965 1.00  0  0 0.00  0
#> SRR1179130     1   0.000      0.965 1.00  0  0 0.00  0
#> SRR1179131     1   0.000      0.965 1.00  0  0 0.00  0
#> SRR1179132     1   0.000      0.965 1.00  0  0 0.00  0
#> SRR1179134     1   0.000      0.965 1.00  0  0 0.00  0
#> SRR1179135     1   0.000      0.965 1.00  0  0 0.00  0
#> SRR1179136     1   0.000      0.965 1.00  0  0 0.00  0
#> SRR1179137     1   0.000      0.965 1.00  0  0 0.00  0
#> SRR1179138     1   0.000      0.965 1.00  0  0 0.00  0
#> SRR1179139     1   0.000      0.965 1.00  0  0 0.00  0
#> SRR1179140     1   0.000      0.965 1.00  0  0 0.00  0
#> SRR1179141     1   0.000      0.965 1.00  0  0 0.00  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
#> SRR1179081     3   0.000      1.000 0.00  0  1  0 0.00  0
#> SRR1179082     3   0.000      1.000 0.00  0  1  0 0.00  0
#> SRR1179083     3   0.000      1.000 0.00  0  1  0 0.00  0
#> SRR1179084     3   0.000      1.000 0.00  0  1  0 0.00  0
#> SRR1179085     3   0.000      1.000 0.00  0  1  0 0.00  0
#> SRR1179086     3   0.000      1.000 0.00  0  1  0 0.00  0
#> SRR1179087     3   0.000      1.000 0.00  0  1  0 0.00  0
#> SRR1179088     3   0.000      1.000 0.00  0  1  0 0.00  0
#> SRR1179089     3   0.000      1.000 0.00  0  1  0 0.00  0
#> SRR1179090     3   0.000      1.000 0.00  0  1  0 0.00  0
#> SRR1179091     3   0.000      1.000 0.00  0  1  0 0.00  0
#> SRR1179092     3   0.000      1.000 0.00  0  1  0 0.00  0
#> SRR1179093     3   0.000      1.000 0.00  0  1  0 0.00  0
#> SRR1179094     3   0.000      1.000 0.00  0  1  0 0.00  0
#> SRR1179095     3   0.000      1.000 0.00  0  1  0 0.00  0
#> SRR1179096     6   0.000      0.000 0.00  0  0  0 0.00  1
#> SRR1179097     2   0.000      1.000 0.00  1  0  0 0.00  0
#> SRR1179098     2   0.000      1.000 0.00  1  0  0 0.00  0
#> SRR1179099     2   0.000      1.000 0.00  1  0  0 0.00  0
#> SRR1179100     2   0.000      1.000 0.00  1  0  0 0.00  0
#> SRR1179101     2   0.000      1.000 0.00  1  0  0 0.00  0
#> SRR1179102     2   0.000      1.000 0.00  1  0  0 0.00  0
#> SRR1179103     2   0.000      1.000 0.00  1  0  0 0.00  0
#> SRR1179104     2   0.000      1.000 0.00  1  0  0 0.00  0
#> SRR1179105     2   0.000      1.000 0.00  1  0  0 0.00  0
#> SRR1179106     2   0.000      1.000 0.00  1  0  0 0.00  0
#> SRR1179107     2   0.000      1.000 0.00  1  0  0 0.00  0
#> SRR1179108     2   0.000      1.000 0.00  1  0  0 0.00  0
#> SRR1179109     2   0.000      1.000 0.00  1  0  0 0.00  0
#> SRR1179110     2   0.000      1.000 0.00  1  0  0 0.00  0
#> SRR1179111     2   0.000      1.000 0.00  1  0  0 0.00  0
#> SRR1179112     1   0.000      0.902 1.00  0  0  0 0.00  0
#> SRR1179113     1   0.127      0.987 0.94  0  0  0 0.06  0
#> SRR1179114     1   0.127      0.987 0.94  0  0  0 0.06  0
#> SRR1179115     1   0.127      0.987 0.94  0  0  0 0.06  0
#> SRR1179116     1   0.127      0.987 0.94  0  0  0 0.06  0
#> SRR1179117     1   0.127      0.987 0.94  0  0  0 0.06  0
#> SRR1179118     1   0.127      0.987 0.94  0  0  0 0.06  0
#> SRR1179119     1   0.127      0.987 0.94  0  0  0 0.06  0
#> SRR1179120     4   0.000      1.000 0.00  0  0  1 0.00  0
#> SRR1179121     4   0.000      1.000 0.00  0  0  1 0.00  0
#> SRR1179122     4   0.000      1.000 0.00  0  0  1 0.00  0
#> SRR1179123     4   0.000      1.000 0.00  0  0  1 0.00  0
#> SRR1179124     4   0.000      1.000 0.00  0  0  1 0.00  0
#> SRR1179125     4   0.000      1.000 0.00  0  0  1 0.00  0
#> SRR1179126     4   0.000      1.000 0.00  0  0  1 0.00  0
#> SRR1179127     5   0.000      1.000 0.00  0  0  0 1.00  0
#> SRR1179128     5   0.000      1.000 0.00  0  0  0 1.00  0
#> SRR1179129     5   0.000      1.000 0.00  0  0  0 1.00  0
#> SRR1179130     5   0.000      1.000 0.00  0  0  0 1.00  0
#> SRR1179131     5   0.000      1.000 0.00  0  0  0 1.00  0
#> SRR1179132     5   0.000      1.000 0.00  0  0  0 1.00  0
#> SRR1179134     5   0.000      1.000 0.00  0  0  0 1.00  0
#> SRR1179135     5   0.000      1.000 0.00  0  0  0 1.00  0
#> SRR1179136     5   0.000      1.000 0.00  0  0  0 1.00  0
#> SRR1179137     5   0.000      1.000 0.00  0  0  0 1.00  0
#> SRR1179138     5   0.000      1.000 0.00  0  0  0 1.00  0
#> SRR1179139     5   0.000      1.000 0.00  0  0  0 1.00  0
#> SRR1179140     5   0.000      1.000 0.00  0  0  0 1.00  0
#> SRR1179141     5   0.000      1.000 0.00  0  0  0 1.00  0

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 0.684           0.819       0.796         0.2206 1.000   1.000
#> 4 4 0.678           0.795       0.720         0.1066 0.777   0.548
#> 5 5 0.613           0.764       0.741         0.0628 1.000   1.000
#> 6 6 0.611           0.765       0.704         0.0582 0.941   0.780

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
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2 p3
#> SRR1179081     2   0.626      0.785 0.000 0.552 NA
#> SRR1179082     2   0.626      0.785 0.000 0.552 NA
#> SRR1179083     2   0.626      0.785 0.000 0.552 NA
#> SRR1179084     2   0.626      0.785 0.000 0.552 NA
#> SRR1179085     2   0.626      0.785 0.000 0.552 NA
#> SRR1179086     2   0.626      0.785 0.000 0.552 NA
#> SRR1179087     2   0.626      0.785 0.000 0.552 NA
#> SRR1179088     2   0.626      0.785 0.000 0.552 NA
#> SRR1179089     2   0.626      0.785 0.000 0.552 NA
#> SRR1179090     2   0.626      0.785 0.000 0.552 NA
#> SRR1179091     2   0.626      0.785 0.000 0.552 NA
#> SRR1179092     2   0.626      0.785 0.000 0.552 NA
#> SRR1179093     2   0.626      0.785 0.000 0.552 NA
#> SRR1179094     2   0.626      0.785 0.000 0.552 NA
#> SRR1179095     2   0.626      0.785 0.000 0.552 NA
#> SRR1179096     2   0.175      0.771 0.000 0.952 NA
#> SRR1179097     2   0.000      0.799 0.000 1.000 NA
#> SRR1179098     2   0.000      0.799 0.000 1.000 NA
#> SRR1179099     2   0.000      0.799 0.000 1.000 NA
#> SRR1179100     2   0.000      0.799 0.000 1.000 NA
#> SRR1179101     2   0.000      0.799 0.000 1.000 NA
#> SRR1179102     2   0.000      0.799 0.000 1.000 NA
#> SRR1179103     2   0.000      0.799 0.000 1.000 NA
#> SRR1179104     2   0.000      0.799 0.000 1.000 NA
#> SRR1179105     2   0.000      0.799 0.000 1.000 NA
#> SRR1179106     2   0.000      0.799 0.000 1.000 NA
#> SRR1179107     2   0.000      0.799 0.000 1.000 NA
#> SRR1179108     2   0.000      0.799 0.000 1.000 NA
#> SRR1179109     2   0.000      0.799 0.000 1.000 NA
#> SRR1179110     2   0.000      0.799 0.000 1.000 NA
#> SRR1179111     2   0.000      0.799 0.000 1.000 NA
#> SRR1179112     1   0.406      0.863 0.836 0.000 NA
#> SRR1179113     1   0.388      0.866 0.848 0.000 NA
#> SRR1179114     1   0.388      0.866 0.848 0.000 NA
#> SRR1179115     1   0.388      0.866 0.848 0.000 NA
#> SRR1179116     1   0.388      0.866 0.848 0.000 NA
#> SRR1179117     1   0.388      0.866 0.848 0.000 NA
#> SRR1179118     1   0.388      0.866 0.848 0.000 NA
#> SRR1179119     1   0.388      0.866 0.848 0.000 NA
#> SRR1179120     1   0.406      0.806 0.836 0.000 NA
#> SRR1179121     1   0.406      0.806 0.836 0.000 NA
#> SRR1179122     1   0.406      0.806 0.836 0.000 NA
#> SRR1179123     1   0.406      0.806 0.836 0.000 NA
#> SRR1179124     1   0.406      0.806 0.836 0.000 NA
#> SRR1179125     1   0.406      0.806 0.836 0.000 NA
#> SRR1179126     1   0.406      0.806 0.836 0.000 NA
#> SRR1179127     1   0.327      0.867 0.884 0.000 NA
#> SRR1179128     1   0.327      0.867 0.884 0.000 NA
#> SRR1179129     1   0.327      0.867 0.884 0.000 NA
#> SRR1179130     1   0.327      0.867 0.884 0.000 NA
#> SRR1179131     1   0.327      0.867 0.884 0.000 NA
#> SRR1179132     1   0.327      0.867 0.884 0.000 NA
#> SRR1179134     1   0.327      0.867 0.884 0.000 NA
#> SRR1179135     1   0.556      0.852 0.700 0.000 NA
#> SRR1179136     1   0.556      0.852 0.700 0.000 NA
#> SRR1179137     1   0.556      0.852 0.700 0.000 NA
#> SRR1179138     1   0.556      0.852 0.700 0.000 NA
#> SRR1179139     1   0.556      0.852 0.700 0.000 NA
#> SRR1179140     1   0.556      0.852 0.700 0.000 NA
#> SRR1179141     1   0.556      0.852 0.700 0.000 NA

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1179081     3  0.6031      0.956 0.000 0.388 0.564 0.048
#> SRR1179082     3  0.5352      0.976 0.000 0.388 0.596 0.016
#> SRR1179083     3  0.5352      0.976 0.000 0.388 0.596 0.016
#> SRR1179084     3  0.5352      0.976 0.000 0.388 0.596 0.016
#> SRR1179085     3  0.5352      0.976 0.000 0.388 0.596 0.016
#> SRR1179086     3  0.5352      0.976 0.000 0.388 0.596 0.016
#> SRR1179087     3  0.5352      0.976 0.000 0.388 0.596 0.016
#> SRR1179088     3  0.5352      0.976 0.000 0.388 0.596 0.016
#> SRR1179089     3  0.5723      0.967 0.000 0.388 0.580 0.032
#> SRR1179090     3  0.4991      0.976 0.000 0.388 0.608 0.004
#> SRR1179091     3  0.5723      0.967 0.000 0.388 0.580 0.032
#> SRR1179092     3  0.5548      0.971 0.000 0.388 0.588 0.024
#> SRR1179093     3  0.5453      0.972 0.000 0.388 0.592 0.020
#> SRR1179094     3  0.5723      0.967 0.000 0.388 0.580 0.032
#> SRR1179095     3  0.4991      0.976 0.000 0.388 0.608 0.004
#> SRR1179096     2  0.3831      0.738 0.000 0.792 0.004 0.204
#> SRR1179097     2  0.0707      0.972 0.000 0.980 0.000 0.020
#> SRR1179098     2  0.0707      0.972 0.000 0.980 0.000 0.020
#> SRR1179099     2  0.0707      0.972 0.000 0.980 0.000 0.020
#> SRR1179100     2  0.0592      0.972 0.000 0.984 0.000 0.016
#> SRR1179101     2  0.0707      0.972 0.000 0.980 0.000 0.020
#> SRR1179102     2  0.0707      0.972 0.000 0.980 0.000 0.020
#> SRR1179103     2  0.0707      0.972 0.000 0.980 0.000 0.020
#> SRR1179104     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR1179105     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR1179106     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR1179107     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR1179108     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR1179109     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR1179110     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR1179111     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR1179112     1  0.1297      0.486 0.964 0.000 0.020 0.016
#> SRR1179113     1  0.0000      0.510 1.000 0.000 0.000 0.000
#> SRR1179114     1  0.0000      0.510 1.000 0.000 0.000 0.000
#> SRR1179115     1  0.0000      0.510 1.000 0.000 0.000 0.000
#> SRR1179116     1  0.0000      0.510 1.000 0.000 0.000 0.000
#> SRR1179117     1  0.0000      0.510 1.000 0.000 0.000 0.000
#> SRR1179118     1  0.0000      0.510 1.000 0.000 0.000 0.000
#> SRR1179119     1  0.0000      0.510 1.000 0.000 0.000 0.000
#> SRR1179120     4  0.4898      0.998 0.416 0.000 0.000 0.584
#> SRR1179121     4  0.4898      0.998 0.416 0.000 0.000 0.584
#> SRR1179122     4  0.4898      0.998 0.416 0.000 0.000 0.584
#> SRR1179123     4  0.4898      0.998 0.416 0.000 0.000 0.584
#> SRR1179124     4  0.4898      0.998 0.416 0.000 0.000 0.584
#> SRR1179125     4  0.4898      0.998 0.416 0.000 0.000 0.584
#> SRR1179126     4  0.5320      0.987 0.416 0.000 0.012 0.572
#> SRR1179127     1  0.7252      0.384 0.528 0.000 0.180 0.292
#> SRR1179128     1  0.7252      0.384 0.528 0.000 0.180 0.292
#> SRR1179129     1  0.7252      0.384 0.528 0.000 0.180 0.292
#> SRR1179130     1  0.7252      0.384 0.528 0.000 0.180 0.292
#> SRR1179131     1  0.7252      0.384 0.528 0.000 0.180 0.292
#> SRR1179132     1  0.7252      0.384 0.528 0.000 0.180 0.292
#> SRR1179134     1  0.7252      0.384 0.528 0.000 0.180 0.292
#> SRR1179135     1  0.6585      0.580 0.584 0.000 0.312 0.104
#> SRR1179136     1  0.6585      0.580 0.584 0.000 0.312 0.104
#> SRR1179137     1  0.6585      0.580 0.584 0.000 0.312 0.104
#> SRR1179138     1  0.6585      0.580 0.584 0.000 0.312 0.104
#> SRR1179139     1  0.6585      0.580 0.584 0.000 0.312 0.104
#> SRR1179140     1  0.6585      0.580 0.584 0.000 0.312 0.104
#> SRR1179141     1  0.6585      0.580 0.584 0.000 0.312 0.104

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4 p5
#> SRR1179081     3  0.6381      0.883 0.000 0.224 0.620 0.092 NA
#> SRR1179082     3  0.5380      0.911 0.000 0.224 0.672 0.008 NA
#> SRR1179083     3  0.5281      0.912 0.000 0.224 0.680 0.008 NA
#> SRR1179084     3  0.5380      0.911 0.000 0.224 0.672 0.008 NA
#> SRR1179085     3  0.5281      0.913 0.000 0.224 0.680 0.008 NA
#> SRR1179086     3  0.5229      0.912 0.000 0.224 0.684 0.008 NA
#> SRR1179087     3  0.5331      0.911 0.000 0.224 0.676 0.008 NA
#> SRR1179088     3  0.5380      0.911 0.000 0.224 0.672 0.008 NA
#> SRR1179089     3  0.5515      0.897 0.000 0.224 0.680 0.056 NA
#> SRR1179090     3  0.3737      0.915 0.000 0.224 0.764 0.004 NA
#> SRR1179091     3  0.5515      0.897 0.000 0.224 0.680 0.056 NA
#> SRR1179092     3  0.5023      0.906 0.000 0.224 0.708 0.040 NA
#> SRR1179093     3  0.5305      0.902 0.000 0.224 0.692 0.052 NA
#> SRR1179094     3  0.5515      0.897 0.000 0.224 0.680 0.056 NA
#> SRR1179095     3  0.4065      0.914 0.000 0.224 0.752 0.016 NA
#> SRR1179096     2  0.5800      0.488 0.000 0.544 0.008 0.076 NA
#> SRR1179097     2  0.2570      0.913 0.000 0.888 0.000 0.084 NA
#> SRR1179098     2  0.2570      0.913 0.000 0.888 0.000 0.084 NA
#> SRR1179099     2  0.2570      0.913 0.000 0.888 0.000 0.084 NA
#> SRR1179100     2  0.2482      0.913 0.000 0.892 0.000 0.084 NA
#> SRR1179101     2  0.2570      0.913 0.000 0.888 0.000 0.084 NA
#> SRR1179102     2  0.2570      0.913 0.000 0.888 0.000 0.084 NA
#> SRR1179103     2  0.2570      0.913 0.000 0.888 0.000 0.084 NA
#> SRR1179104     2  0.0000      0.920 0.000 1.000 0.000 0.000 NA
#> SRR1179105     2  0.0000      0.920 0.000 1.000 0.000 0.000 NA
#> SRR1179106     2  0.0000      0.920 0.000 1.000 0.000 0.000 NA
#> SRR1179107     2  0.0000      0.920 0.000 1.000 0.000 0.000 NA
#> SRR1179108     2  0.0000      0.920 0.000 1.000 0.000 0.000 NA
#> SRR1179109     2  0.0000      0.920 0.000 1.000 0.000 0.000 NA
#> SRR1179110     2  0.0000      0.920 0.000 1.000 0.000 0.000 NA
#> SRR1179111     2  0.0162      0.920 0.000 0.996 0.000 0.000 NA
#> SRR1179112     1  0.6542      0.463 0.624 0.000 0.188 0.096 NA
#> SRR1179113     1  0.6087      0.491 0.672 0.000 0.148 0.108 NA
#> SRR1179114     1  0.6087      0.491 0.672 0.000 0.148 0.108 NA
#> SRR1179115     1  0.6087      0.491 0.672 0.000 0.148 0.108 NA
#> SRR1179116     1  0.6087      0.491 0.672 0.000 0.148 0.108 NA
#> SRR1179117     1  0.6087      0.491 0.672 0.000 0.148 0.108 NA
#> SRR1179118     1  0.6087      0.491 0.672 0.000 0.148 0.108 NA
#> SRR1179119     1  0.6087      0.491 0.672 0.000 0.148 0.108 NA
#> SRR1179120     4  0.3707      0.991 0.284 0.000 0.000 0.716 NA
#> SRR1179121     4  0.3707      0.991 0.284 0.000 0.000 0.716 NA
#> SRR1179122     4  0.3707      0.991 0.284 0.000 0.000 0.716 NA
#> SRR1179123     4  0.3707      0.991 0.284 0.000 0.000 0.716 NA
#> SRR1179124     4  0.3707      0.991 0.284 0.000 0.000 0.716 NA
#> SRR1179125     4  0.3707      0.991 0.284 0.000 0.000 0.716 NA
#> SRR1179126     4  0.4953      0.947 0.284 0.000 0.004 0.664 NA
#> SRR1179127     1  0.3297      0.474 0.840 0.000 0.008 0.132 NA
#> SRR1179128     1  0.3297      0.474 0.840 0.000 0.008 0.132 NA
#> SRR1179129     1  0.3297      0.474 0.840 0.000 0.008 0.132 NA
#> SRR1179130     1  0.3297      0.474 0.840 0.000 0.008 0.132 NA
#> SRR1179131     1  0.3297      0.474 0.840 0.000 0.008 0.132 NA
#> SRR1179132     1  0.3297      0.474 0.840 0.000 0.008 0.132 NA
#> SRR1179134     1  0.3297      0.474 0.840 0.000 0.008 0.132 NA
#> SRR1179135     1  0.4142      0.555 0.684 0.000 0.004 0.004 NA
#> SRR1179136     1  0.4142      0.555 0.684 0.000 0.004 0.004 NA
#> SRR1179137     1  0.4142      0.555 0.684 0.000 0.004 0.004 NA
#> SRR1179138     1  0.3876      0.555 0.684 0.000 0.000 0.000 NA
#> SRR1179139     1  0.3876      0.555 0.684 0.000 0.000 0.000 NA
#> SRR1179140     1  0.3876      0.555 0.684 0.000 0.000 0.000 NA
#> SRR1179141     1  0.4142      0.555 0.684 0.000 0.004 0.004 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1179081     3  0.6635      0.808 0.012 0.100 0.552 0.108 0.000 NA
#> SRR1179082     3  0.2704      0.873 0.000 0.100 0.868 0.012 0.000 NA
#> SRR1179083     3  0.2567      0.876 0.004 0.100 0.876 0.008 0.000 NA
#> SRR1179084     3  0.2604      0.873 0.000 0.100 0.872 0.008 0.000 NA
#> SRR1179085     3  0.2405      0.879 0.000 0.100 0.880 0.004 0.000 NA
#> SRR1179086     3  0.2101      0.879 0.004 0.100 0.892 0.000 0.000 NA
#> SRR1179087     3  0.2405      0.875 0.000 0.100 0.880 0.004 0.000 NA
#> SRR1179088     3  0.2604      0.873 0.000 0.100 0.872 0.008 0.000 NA
#> SRR1179089     3  0.5626      0.847 0.000 0.100 0.600 0.036 0.000 NA
#> SRR1179090     3  0.4677      0.879 0.004 0.100 0.732 0.020 0.000 NA
#> SRR1179091     3  0.5626      0.847 0.000 0.100 0.600 0.036 0.000 NA
#> SRR1179092     3  0.5299      0.866 0.004 0.100 0.656 0.024 0.000 NA
#> SRR1179093     3  0.5187      0.866 0.000 0.100 0.656 0.024 0.000 NA
#> SRR1179094     3  0.5626      0.847 0.000 0.100 0.600 0.036 0.000 NA
#> SRR1179095     3  0.4610      0.878 0.000 0.100 0.728 0.020 0.000 NA
#> SRR1179096     2  0.6883      0.396 0.364 0.416 0.008 0.068 0.000 NA
#> SRR1179097     2  0.0146      0.874 0.004 0.996 0.000 0.000 0.000 NA
#> SRR1179098     2  0.0146      0.874 0.004 0.996 0.000 0.000 0.000 NA
#> SRR1179099     2  0.0146      0.874 0.004 0.996 0.000 0.000 0.000 NA
#> SRR1179100     2  0.0000      0.874 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1179101     2  0.0146      0.874 0.004 0.996 0.000 0.000 0.000 NA
#> SRR1179102     2  0.0146      0.874 0.004 0.996 0.000 0.000 0.000 NA
#> SRR1179103     2  0.0146      0.874 0.004 0.996 0.000 0.000 0.000 NA
#> SRR1179104     2  0.3283      0.881 0.000 0.804 0.000 0.036 0.000 NA
#> SRR1179105     2  0.2762      0.884 0.000 0.804 0.000 0.000 0.000 NA
#> SRR1179106     2  0.2871      0.883 0.000 0.804 0.000 0.004 0.000 NA
#> SRR1179107     2  0.2762      0.884 0.000 0.804 0.000 0.000 0.000 NA
#> SRR1179108     2  0.2948      0.883 0.000 0.804 0.000 0.008 0.000 NA
#> SRR1179109     2  0.2762      0.884 0.000 0.804 0.000 0.000 0.000 NA
#> SRR1179110     2  0.2871      0.883 0.000 0.804 0.000 0.004 0.000 NA
#> SRR1179111     2  0.2762      0.884 0.000 0.804 0.000 0.000 0.000 NA
#> SRR1179112     5  0.2663      0.366 0.016 0.000 0.032 0.012 0.892 NA
#> SRR1179113     5  0.0000      0.432 0.000 0.000 0.000 0.000 1.000 NA
#> SRR1179114     5  0.0146      0.432 0.000 0.000 0.004 0.000 0.996 NA
#> SRR1179115     5  0.0000      0.432 0.000 0.000 0.000 0.000 1.000 NA
#> SRR1179116     5  0.0146      0.432 0.000 0.000 0.004 0.000 0.996 NA
#> SRR1179117     5  0.0146      0.432 0.000 0.000 0.004 0.000 0.996 NA
#> SRR1179118     5  0.0000      0.432 0.000 0.000 0.000 0.000 1.000 NA
#> SRR1179119     5  0.0000      0.432 0.000 0.000 0.000 0.000 1.000 NA
#> SRR1179120     4  0.3101      0.985 0.000 0.000 0.000 0.756 0.244 NA
#> SRR1179121     4  0.3240      0.986 0.000 0.000 0.004 0.752 0.244 NA
#> SRR1179122     4  0.3349      0.983 0.000 0.000 0.000 0.748 0.244 NA
#> SRR1179123     4  0.3240      0.986 0.000 0.000 0.004 0.752 0.244 NA
#> SRR1179124     4  0.3240      0.986 0.000 0.000 0.004 0.752 0.244 NA
#> SRR1179125     4  0.3349      0.983 0.000 0.000 0.000 0.748 0.244 NA
#> SRR1179126     4  0.4778      0.935 0.020 0.000 0.016 0.688 0.244 NA
#> SRR1179127     5  0.7856      0.316 0.216 0.000 0.016 0.184 0.368 NA
#> SRR1179128     5  0.7531      0.317 0.216 0.000 0.000 0.184 0.368 NA
#> SRR1179129     5  0.7856      0.316 0.216 0.000 0.016 0.184 0.368 NA
#> SRR1179130     5  0.7644      0.317 0.216 0.000 0.004 0.184 0.368 NA
#> SRR1179131     5  0.7856      0.316 0.216 0.000 0.016 0.184 0.368 NA
#> SRR1179132     5  0.7725      0.316 0.216 0.000 0.008 0.184 0.368 NA
#> SRR1179134     5  0.7725      0.316 0.216 0.000 0.008 0.184 0.368 NA
#> SRR1179135     1  0.4322      0.988 0.548 0.000 0.004 0.004 0.436 NA
#> SRR1179136     1  0.4279      0.988 0.548 0.000 0.000 0.004 0.436 NA
#> SRR1179137     1  0.4361      0.986 0.544 0.000 0.000 0.004 0.436 NA
#> SRR1179138     1  0.3955      0.990 0.560 0.000 0.000 0.004 0.436 NA
#> SRR1179139     1  0.4088      0.989 0.556 0.000 0.004 0.004 0.436 NA
#> SRR1179140     1  0.3955      0.990 0.560 0.000 0.000 0.004 0.436 NA
#> SRR1179141     1  0.4423      0.982 0.544 0.000 0.008 0.004 0.436 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-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 14036 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 1.000           0.999       0.999         0.2662 0.864   0.724
#> 4 4 0.845           0.748       0.844         0.0964 0.881   0.667
#> 5 5 0.845           0.891       0.932         0.0662 0.905   0.679
#> 6 6 0.917           0.896       0.907         0.0537 0.941   0.773

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1179081     3  0.0237      1.000 0.000 0.004 0.996
#> SRR1179082     3  0.0237      1.000 0.000 0.004 0.996
#> SRR1179083     3  0.0237      1.000 0.000 0.004 0.996
#> SRR1179084     3  0.0237      1.000 0.000 0.004 0.996
#> SRR1179085     3  0.0237      1.000 0.000 0.004 0.996
#> SRR1179086     3  0.0237      1.000 0.000 0.004 0.996
#> SRR1179087     3  0.0237      1.000 0.000 0.004 0.996
#> SRR1179088     3  0.0237      1.000 0.000 0.004 0.996
#> SRR1179089     3  0.0237      1.000 0.000 0.004 0.996
#> SRR1179090     3  0.0237      1.000 0.000 0.004 0.996
#> SRR1179091     3  0.0237      1.000 0.000 0.004 0.996
#> SRR1179092     3  0.0237      1.000 0.000 0.004 0.996
#> SRR1179093     3  0.0237      1.000 0.000 0.004 0.996
#> SRR1179094     3  0.0237      1.000 0.000 0.004 0.996
#> SRR1179095     3  0.0237      1.000 0.000 0.004 0.996
#> SRR1179096     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179097     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179098     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179099     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179100     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179101     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179102     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179103     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179104     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179105     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179106     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179107     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179108     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179109     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179110     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179111     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1179112     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179113     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179114     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179115     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179116     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179117     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179118     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179119     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179120     1  0.0237      0.997 0.996 0.000 0.004
#> SRR1179121     1  0.0237      0.997 0.996 0.000 0.004
#> SRR1179122     1  0.0237      0.997 0.996 0.000 0.004
#> SRR1179123     1  0.0237      0.997 0.996 0.000 0.004
#> SRR1179124     1  0.0237      0.997 0.996 0.000 0.004
#> SRR1179125     1  0.0237      0.997 0.996 0.000 0.004
#> SRR1179126     1  0.0237      0.997 0.996 0.000 0.004
#> SRR1179127     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179128     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179129     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179130     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179131     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179132     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179134     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179135     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179136     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179137     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179138     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179139     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179140     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179141     1  0.0000      0.999 1.000 0.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
#> SRR1179081     3   0.000      1.000 0.000 0.00  1 0.000
#> SRR1179082     3   0.000      1.000 0.000 0.00  1 0.000
#> SRR1179083     3   0.000      1.000 0.000 0.00  1 0.000
#> SRR1179084     3   0.000      1.000 0.000 0.00  1 0.000
#> SRR1179085     3   0.000      1.000 0.000 0.00  1 0.000
#> SRR1179086     3   0.000      1.000 0.000 0.00  1 0.000
#> SRR1179087     3   0.000      1.000 0.000 0.00  1 0.000
#> SRR1179088     3   0.000      1.000 0.000 0.00  1 0.000
#> SRR1179089     3   0.000      1.000 0.000 0.00  1 0.000
#> SRR1179090     3   0.000      1.000 0.000 0.00  1 0.000
#> SRR1179091     3   0.000      1.000 0.000 0.00  1 0.000
#> SRR1179092     3   0.000      1.000 0.000 0.00  1 0.000
#> SRR1179093     3   0.000      1.000 0.000 0.00  1 0.000
#> SRR1179094     3   0.000      1.000 0.000 0.00  1 0.000
#> SRR1179095     3   0.000      1.000 0.000 0.00  1 0.000
#> SRR1179096     2   0.479      0.674 0.380 0.62  0 0.000
#> SRR1179097     2   0.000      0.982 0.000 1.00  0 0.000
#> SRR1179098     2   0.000      0.982 0.000 1.00  0 0.000
#> SRR1179099     2   0.000      0.982 0.000 1.00  0 0.000
#> SRR1179100     2   0.000      0.982 0.000 1.00  0 0.000
#> SRR1179101     2   0.000      0.982 0.000 1.00  0 0.000
#> SRR1179102     2   0.000      0.982 0.000 1.00  0 0.000
#> SRR1179103     2   0.000      0.982 0.000 1.00  0 0.000
#> SRR1179104     2   0.000      0.982 0.000 1.00  0 0.000
#> SRR1179105     2   0.000      0.982 0.000 1.00  0 0.000
#> SRR1179106     2   0.000      0.982 0.000 1.00  0 0.000
#> SRR1179107     2   0.000      0.982 0.000 1.00  0 0.000
#> SRR1179108     2   0.000      0.982 0.000 1.00  0 0.000
#> SRR1179109     2   0.000      0.982 0.000 1.00  0 0.000
#> SRR1179110     2   0.000      0.982 0.000 1.00  0 0.000
#> SRR1179111     2   0.000      0.982 0.000 1.00  0 0.000
#> SRR1179112     1   0.488      0.958 0.592 0.00  0 0.408
#> SRR1179113     1   0.488      0.958 0.592 0.00  0 0.408
#> SRR1179114     1   0.488      0.958 0.592 0.00  0 0.408
#> SRR1179115     1   0.488      0.958 0.592 0.00  0 0.408
#> SRR1179116     1   0.488      0.958 0.592 0.00  0 0.408
#> SRR1179117     1   0.488      0.958 0.592 0.00  0 0.408
#> SRR1179118     1   0.488      0.958 0.592 0.00  0 0.408
#> SRR1179119     1   0.488      0.958 0.592 0.00  0 0.408
#> SRR1179120     4   0.000      0.529 0.000 0.00  0 1.000
#> SRR1179121     4   0.000      0.529 0.000 0.00  0 1.000
#> SRR1179122     4   0.000      0.529 0.000 0.00  0 1.000
#> SRR1179123     4   0.000      0.529 0.000 0.00  0 1.000
#> SRR1179124     4   0.000      0.529 0.000 0.00  0 1.000
#> SRR1179125     4   0.000      0.529 0.000 0.00  0 1.000
#> SRR1179126     4   0.000      0.529 0.000 0.00  0 1.000
#> SRR1179127     4   0.500     -0.501 0.492 0.00  0 0.508
#> SRR1179128     4   0.500     -0.514 0.496 0.00  0 0.504
#> SRR1179129     4   0.500     -0.501 0.492 0.00  0 0.508
#> SRR1179130     4   0.500     -0.514 0.496 0.00  0 0.504
#> SRR1179131     4   0.500     -0.501 0.492 0.00  0 0.508
#> SRR1179132     4   0.500     -0.514 0.496 0.00  0 0.504
#> SRR1179134     4   0.500     -0.514 0.496 0.00  0 0.504
#> SRR1179135     1   0.479      0.953 0.620 0.00  0 0.380
#> SRR1179136     1   0.479      0.953 0.620 0.00  0 0.380
#> SRR1179137     1   0.479      0.953 0.620 0.00  0 0.380
#> SRR1179138     1   0.479      0.953 0.620 0.00  0 0.380
#> SRR1179139     1   0.479      0.953 0.620 0.00  0 0.380
#> SRR1179140     1   0.479      0.953 0.620 0.00  0 0.380
#> SRR1179141     1   0.479      0.953 0.620 0.00  0 0.380

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3    p4    p5
#> SRR1179081     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1179082     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1179083     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1179084     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1179085     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1179086     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1179087     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1179088     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1179089     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1179090     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1179091     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1179092     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1179093     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1179094     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1179095     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1179096     5  0.1197      0.000 0.000 0.048  0 0.000 0.952
#> SRR1179097     2  0.0162      0.996 0.000 0.996  0 0.004 0.000
#> SRR1179098     2  0.0162      0.996 0.000 0.996  0 0.004 0.000
#> SRR1179099     2  0.0162      0.996 0.000 0.996  0 0.004 0.000
#> SRR1179100     2  0.0162      0.996 0.000 0.996  0 0.004 0.000
#> SRR1179101     2  0.0162      0.996 0.000 0.996  0 0.004 0.000
#> SRR1179102     2  0.0162      0.996 0.000 0.996  0 0.004 0.000
#> SRR1179103     2  0.0162      0.996 0.000 0.996  0 0.004 0.000
#> SRR1179104     2  0.0162      0.996 0.000 0.996  0 0.000 0.004
#> SRR1179105     2  0.0000      0.996 0.000 1.000  0 0.000 0.000
#> SRR1179106     2  0.0162      0.996 0.000 0.996  0 0.000 0.004
#> SRR1179107     2  0.0162      0.996 0.000 0.996  0 0.000 0.004
#> SRR1179108     2  0.0162      0.996 0.000 0.996  0 0.000 0.004
#> SRR1179109     2  0.0162      0.996 0.000 0.996  0 0.000 0.004
#> SRR1179110     2  0.0162      0.996 0.000 0.996  0 0.000 0.004
#> SRR1179111     2  0.0000      0.996 0.000 1.000  0 0.000 0.000
#> SRR1179112     1  0.3492      0.776 0.796 0.000  0 0.188 0.016
#> SRR1179113     1  0.3456      0.778 0.800 0.000  0 0.184 0.016
#> SRR1179114     1  0.3456      0.778 0.800 0.000  0 0.184 0.016
#> SRR1179115     1  0.3456      0.778 0.800 0.000  0 0.184 0.016
#> SRR1179116     1  0.3456      0.778 0.800 0.000  0 0.184 0.016
#> SRR1179117     1  0.3456      0.778 0.800 0.000  0 0.184 0.016
#> SRR1179118     1  0.3456      0.778 0.800 0.000  0 0.184 0.016
#> SRR1179119     1  0.3456      0.778 0.800 0.000  0 0.184 0.016
#> SRR1179120     4  0.0290      1.000 0.008 0.000  0 0.992 0.000
#> SRR1179121     4  0.0290      1.000 0.008 0.000  0 0.992 0.000
#> SRR1179122     4  0.0290      1.000 0.008 0.000  0 0.992 0.000
#> SRR1179123     4  0.0290      1.000 0.008 0.000  0 0.992 0.000
#> SRR1179124     4  0.0290      1.000 0.008 0.000  0 0.992 0.000
#> SRR1179125     4  0.0290      1.000 0.008 0.000  0 0.992 0.000
#> SRR1179126     4  0.0290      1.000 0.008 0.000  0 0.992 0.000
#> SRR1179127     1  0.4397      0.683 0.696 0.000  0 0.276 0.028
#> SRR1179128     1  0.4397      0.683 0.696 0.000  0 0.276 0.028
#> SRR1179129     1  0.4397      0.683 0.696 0.000  0 0.276 0.028
#> SRR1179130     1  0.4397      0.683 0.696 0.000  0 0.276 0.028
#> SRR1179131     1  0.4397      0.683 0.696 0.000  0 0.276 0.028
#> SRR1179132     1  0.4397      0.683 0.696 0.000  0 0.276 0.028
#> SRR1179134     1  0.4397      0.683 0.696 0.000  0 0.276 0.028
#> SRR1179135     1  0.0324      0.790 0.992 0.000  0 0.004 0.004
#> SRR1179136     1  0.0324      0.790 0.992 0.000  0 0.004 0.004
#> SRR1179137     1  0.0324      0.790 0.992 0.000  0 0.004 0.004
#> SRR1179138     1  0.0324      0.790 0.992 0.000  0 0.004 0.004
#> SRR1179139     1  0.0324      0.790 0.992 0.000  0 0.004 0.004
#> SRR1179140     1  0.0324      0.790 0.992 0.000  0 0.004 0.004
#> SRR1179141     1  0.0324      0.790 0.992 0.000  0 0.004 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
#> SRR1179081     3  0.0820      0.972 0.012 0.000 0.972 0.000 0.016 0.00
#> SRR1179082     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.00
#> SRR1179083     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.00
#> SRR1179084     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.00
#> SRR1179085     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.00
#> SRR1179086     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.00
#> SRR1179087     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.00
#> SRR1179088     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.00
#> SRR1179089     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.00
#> SRR1179090     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.00
#> SRR1179091     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.00
#> SRR1179092     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.00
#> SRR1179093     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.00
#> SRR1179094     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.00
#> SRR1179095     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.00
#> SRR1179096     6  0.0547      0.000 0.000 0.020 0.000 0.000 0.000 0.98
#> SRR1179097     2  0.0520      0.991 0.008 0.984 0.000 0.000 0.008 0.00
#> SRR1179098     2  0.0520      0.991 0.008 0.984 0.000 0.000 0.008 0.00
#> SRR1179099     2  0.0520      0.991 0.008 0.984 0.000 0.000 0.008 0.00
#> SRR1179100     2  0.0520      0.991 0.008 0.984 0.000 0.000 0.008 0.00
#> SRR1179101     2  0.0520      0.991 0.008 0.984 0.000 0.000 0.008 0.00
#> SRR1179102     2  0.0520      0.991 0.008 0.984 0.000 0.000 0.008 0.00
#> SRR1179103     2  0.0520      0.991 0.008 0.984 0.000 0.000 0.008 0.00
#> SRR1179104     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000 0.00
#> SRR1179105     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000 0.00
#> SRR1179106     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000 0.00
#> SRR1179107     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000 0.00
#> SRR1179108     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000 0.00
#> SRR1179109     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000 0.00
#> SRR1179110     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000 0.00
#> SRR1179111     2  0.0000      0.992 0.000 1.000 0.000 0.000 0.000 0.00
#> SRR1179112     1  0.3506      0.598 0.792 0.000 0.000 0.052 0.156 0.00
#> SRR1179113     1  0.4294      0.700 0.672 0.000 0.000 0.048 0.280 0.00
#> SRR1179114     1  0.4294      0.700 0.672 0.000 0.000 0.048 0.280 0.00
#> SRR1179115     1  0.4294      0.700 0.672 0.000 0.000 0.048 0.280 0.00
#> SRR1179116     1  0.4274      0.698 0.676 0.000 0.000 0.048 0.276 0.00
#> SRR1179117     1  0.4294      0.700 0.672 0.000 0.000 0.048 0.280 0.00
#> SRR1179118     1  0.4274      0.698 0.676 0.000 0.000 0.048 0.276 0.00
#> SRR1179119     1  0.4294      0.700 0.672 0.000 0.000 0.048 0.280 0.00
#> SRR1179120     4  0.0146      1.000 0.000 0.000 0.000 0.996 0.004 0.00
#> SRR1179121     4  0.0146      1.000 0.000 0.000 0.000 0.996 0.004 0.00
#> SRR1179122     4  0.0146      1.000 0.000 0.000 0.000 0.996 0.004 0.00
#> SRR1179123     4  0.0146      1.000 0.000 0.000 0.000 0.996 0.004 0.00
#> SRR1179124     4  0.0146      1.000 0.000 0.000 0.000 0.996 0.004 0.00
#> SRR1179125     4  0.0146      1.000 0.000 0.000 0.000 0.996 0.004 0.00
#> SRR1179126     4  0.0146      1.000 0.000 0.000 0.000 0.996 0.004 0.00
#> SRR1179127     5  0.1714      1.000 0.000 0.000 0.000 0.092 0.908 0.00
#> SRR1179128     5  0.1714      1.000 0.000 0.000 0.000 0.092 0.908 0.00
#> SRR1179129     5  0.1714      1.000 0.000 0.000 0.000 0.092 0.908 0.00
#> SRR1179130     5  0.1714      1.000 0.000 0.000 0.000 0.092 0.908 0.00
#> SRR1179131     5  0.1714      1.000 0.000 0.000 0.000 0.092 0.908 0.00
#> SRR1179132     5  0.1714      1.000 0.000 0.000 0.000 0.092 0.908 0.00
#> SRR1179134     5  0.1714      1.000 0.000 0.000 0.000 0.092 0.908 0.00
#> SRR1179135     1  0.4167      0.638 0.612 0.000 0.000 0.000 0.368 0.02
#> SRR1179136     1  0.4178      0.643 0.608 0.000 0.000 0.000 0.372 0.02
#> SRR1179137     1  0.4189      0.636 0.604 0.000 0.000 0.000 0.376 0.02
#> SRR1179138     1  0.4189      0.637 0.604 0.000 0.000 0.000 0.376 0.02
#> SRR1179139     1  0.4209      0.639 0.596 0.000 0.000 0.000 0.384 0.02
#> SRR1179140     1  0.4199      0.633 0.600 0.000 0.000 0.000 0.380 0.02
#> SRR1179141     1  0.4144      0.642 0.620 0.000 0.000 0.000 0.360 0.02

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 14036 rows and 60 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 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 1.000           1.000       1.000         0.2664 0.864   0.724
#> 4 4 0.909           0.882       0.942         0.1615 0.905   0.734
#> 5 5 0.968           0.918       0.968         0.0659 0.928   0.730
#> 6 6 0.956           0.897       0.968         0.0106 0.992   0.958

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1179081     3       0          1  0  0  1
#> SRR1179082     3       0          1  0  0  1
#> SRR1179083     3       0          1  0  0  1
#> SRR1179084     3       0          1  0  0  1
#> SRR1179085     3       0          1  0  0  1
#> SRR1179086     3       0          1  0  0  1
#> SRR1179087     3       0          1  0  0  1
#> SRR1179088     3       0          1  0  0  1
#> SRR1179089     3       0          1  0  0  1
#> SRR1179090     3       0          1  0  0  1
#> SRR1179091     3       0          1  0  0  1
#> SRR1179092     3       0          1  0  0  1
#> SRR1179093     3       0          1  0  0  1
#> SRR1179094     3       0          1  0  0  1
#> SRR1179095     3       0          1  0  0  1
#> SRR1179096     2       0          1  0  1  0
#> SRR1179097     2       0          1  0  1  0
#> SRR1179098     2       0          1  0  1  0
#> SRR1179099     2       0          1  0  1  0
#> SRR1179100     2       0          1  0  1  0
#> SRR1179101     2       0          1  0  1  0
#> SRR1179102     2       0          1  0  1  0
#> SRR1179103     2       0          1  0  1  0
#> SRR1179104     2       0          1  0  1  0
#> SRR1179105     2       0          1  0  1  0
#> SRR1179106     2       0          1  0  1  0
#> SRR1179107     2       0          1  0  1  0
#> SRR1179108     2       0          1  0  1  0
#> SRR1179109     2       0          1  0  1  0
#> SRR1179110     2       0          1  0  1  0
#> SRR1179111     2       0          1  0  1  0
#> SRR1179112     1       0          1  1  0  0
#> SRR1179113     1       0          1  1  0  0
#> SRR1179114     1       0          1  1  0  0
#> SRR1179115     1       0          1  1  0  0
#> SRR1179116     1       0          1  1  0  0
#> SRR1179117     1       0          1  1  0  0
#> SRR1179118     1       0          1  1  0  0
#> SRR1179119     1       0          1  1  0  0
#> SRR1179120     1       0          1  1  0  0
#> SRR1179121     1       0          1  1  0  0
#> SRR1179122     1       0          1  1  0  0
#> SRR1179123     1       0          1  1  0  0
#> SRR1179124     1       0          1  1  0  0
#> SRR1179125     1       0          1  1  0  0
#> SRR1179126     1       0          1  1  0  0
#> SRR1179127     1       0          1  1  0  0
#> SRR1179128     1       0          1  1  0  0
#> SRR1179129     1       0          1  1  0  0
#> SRR1179130     1       0          1  1  0  0
#> SRR1179131     1       0          1  1  0  0
#> SRR1179132     1       0          1  1  0  0
#> SRR1179134     1       0          1  1  0  0
#> SRR1179135     1       0          1  1  0  0
#> SRR1179136     1       0          1  1  0  0
#> SRR1179137     1       0          1  1  0  0
#> SRR1179138     1       0          1  1  0  0
#> SRR1179139     1       0          1  1  0  0
#> SRR1179140     1       0          1  1  0  0
#> SRR1179141     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2 p3    p4
#> SRR1179081     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179082     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179083     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179084     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179085     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179086     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179087     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179088     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179089     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179090     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179091     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179092     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179093     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179094     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179095     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179096     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179097     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179098     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179099     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179100     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179101     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179102     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179103     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179104     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179105     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179106     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179107     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179108     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179109     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179110     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179111     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179112     1  0.3837      0.777 0.776  0  0 0.224
#> SRR1179113     1  0.3837      0.777 0.776  0  0 0.224
#> SRR1179114     1  0.3837      0.777 0.776  0  0 0.224
#> SRR1179115     1  0.3837      0.777 0.776  0  0 0.224
#> SRR1179116     1  0.3837      0.777 0.776  0  0 0.224
#> SRR1179117     1  0.3837      0.777 0.776  0  0 0.224
#> SRR1179118     1  0.3837      0.777 0.776  0  0 0.224
#> SRR1179119     1  0.3837      0.777 0.776  0  0 0.224
#> SRR1179120     4  0.0592      0.904 0.016  0  0 0.984
#> SRR1179121     4  0.1118      0.901 0.036  0  0 0.964
#> SRR1179122     4  0.1022      0.901 0.032  0  0 0.968
#> SRR1179123     4  0.0817      0.907 0.024  0  0 0.976
#> SRR1179124     4  0.0707      0.906 0.020  0  0 0.980
#> SRR1179125     4  0.0817      0.906 0.024  0  0 0.976
#> SRR1179126     4  0.0469      0.901 0.012  0  0 0.988
#> SRR1179127     4  0.4972      0.255 0.456  0  0 0.544
#> SRR1179128     1  0.1022      0.814 0.968  0  0 0.032
#> SRR1179129     1  0.4761      0.230 0.628  0  0 0.372
#> SRR1179130     1  0.0469      0.824 0.988  0  0 0.012
#> SRR1179131     1  0.4994     -0.172 0.520  0  0 0.480
#> SRR1179132     1  0.0469      0.824 0.988  0  0 0.012
#> SRR1179134     1  0.0469      0.824 0.988  0  0 0.012
#> SRR1179135     1  0.0188      0.825 0.996  0  0 0.004
#> SRR1179136     1  0.0707      0.826 0.980  0  0 0.020
#> SRR1179137     1  0.0592      0.825 0.984  0  0 0.016
#> SRR1179138     1  0.0469      0.824 0.988  0  0 0.012
#> SRR1179139     1  0.0817      0.825 0.976  0  0 0.024
#> SRR1179140     1  0.0469      0.824 0.988  0  0 0.012
#> SRR1179141     1  0.1792      0.821 0.932  0  0 0.068

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2 p3 p4    p5
#> SRR1179081     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179082     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179083     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179084     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179085     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179086     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179087     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179088     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179089     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179090     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179091     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179092     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179093     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179094     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179095     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179096     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179097     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179098     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179099     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179100     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179101     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179102     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179103     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179104     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179105     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179106     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179107     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179108     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179109     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179110     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179111     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179112     5  0.0000      0.918 0.000  0  0  0 1.000
#> SRR1179113     5  0.0000      0.918 0.000  0  0  0 1.000
#> SRR1179114     5  0.0000      0.918 0.000  0  0  0 1.000
#> SRR1179115     5  0.0000      0.918 0.000  0  0  0 1.000
#> SRR1179116     5  0.0000      0.918 0.000  0  0  0 1.000
#> SRR1179117     5  0.0000      0.918 0.000  0  0  0 1.000
#> SRR1179118     5  0.0000      0.918 0.000  0  0  0 1.000
#> SRR1179119     5  0.0000      0.918 0.000  0  0  0 1.000
#> SRR1179120     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179121     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179122     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179123     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179124     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179125     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179126     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179127     1  0.0000      0.863 1.000  0  0  0 0.000
#> SRR1179128     1  0.0000      0.863 1.000  0  0  0 0.000
#> SRR1179129     1  0.0000      0.863 1.000  0  0  0 0.000
#> SRR1179130     1  0.0000      0.863 1.000  0  0  0 0.000
#> SRR1179131     1  0.0000      0.863 1.000  0  0  0 0.000
#> SRR1179132     1  0.0000      0.863 1.000  0  0  0 0.000
#> SRR1179134     1  0.0000      0.863 1.000  0  0  0 0.000
#> SRR1179135     1  0.4030      0.480 0.648  0  0  0 0.352
#> SRR1179136     5  0.3636      0.566 0.272  0  0  0 0.728
#> SRR1179137     1  0.2471      0.772 0.864  0  0  0 0.136
#> SRR1179138     1  0.4015      0.491 0.652  0  0  0 0.348
#> SRR1179139     1  0.4297      0.144 0.528  0  0  0 0.472
#> SRR1179140     1  0.0703      0.853 0.976  0  0  0 0.024
#> SRR1179141     5  0.3999      0.404 0.344  0  0  0 0.656

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1 p2 p3 p4    p5 p6
#> SRR1179081     3  0.0000      1.000 0.000  0  1  0 0.000  0
#> SRR1179082     3  0.0000      1.000 0.000  0  1  0 0.000  0
#> SRR1179083     3  0.0000      1.000 0.000  0  1  0 0.000  0
#> SRR1179084     3  0.0000      1.000 0.000  0  1  0 0.000  0
#> SRR1179085     3  0.0000      1.000 0.000  0  1  0 0.000  0
#> SRR1179086     3  0.0000      1.000 0.000  0  1  0 0.000  0
#> SRR1179087     3  0.0000      1.000 0.000  0  1  0 0.000  0
#> SRR1179088     3  0.0000      1.000 0.000  0  1  0 0.000  0
#> SRR1179089     3  0.0000      1.000 0.000  0  1  0 0.000  0
#> SRR1179090     3  0.0000      1.000 0.000  0  1  0 0.000  0
#> SRR1179091     3  0.0000      1.000 0.000  0  1  0 0.000  0
#> SRR1179092     3  0.0000      1.000 0.000  0  1  0 0.000  0
#> SRR1179093     3  0.0000      1.000 0.000  0  1  0 0.000  0
#> SRR1179094     3  0.0000      1.000 0.000  0  1  0 0.000  0
#> SRR1179095     3  0.0000      1.000 0.000  0  1  0 0.000  0
#> SRR1179096     6  0.0000      0.000 0.000  0  0  0 0.000  1
#> SRR1179097     2  0.0000      1.000 0.000  1  0  0 0.000  0
#> SRR1179098     2  0.0000      1.000 0.000  1  0  0 0.000  0
#> SRR1179099     2  0.0000      1.000 0.000  1  0  0 0.000  0
#> SRR1179100     2  0.0000      1.000 0.000  1  0  0 0.000  0
#> SRR1179101     2  0.0000      1.000 0.000  1  0  0 0.000  0
#> SRR1179102     2  0.0000      1.000 0.000  1  0  0 0.000  0
#> SRR1179103     2  0.0000      1.000 0.000  1  0  0 0.000  0
#> SRR1179104     2  0.0000      1.000 0.000  1  0  0 0.000  0
#> SRR1179105     2  0.0000      1.000 0.000  1  0  0 0.000  0
#> SRR1179106     2  0.0000      1.000 0.000  1  0  0 0.000  0
#> SRR1179107     2  0.0000      1.000 0.000  1  0  0 0.000  0
#> SRR1179108     2  0.0000      1.000 0.000  1  0  0 0.000  0
#> SRR1179109     2  0.0000      1.000 0.000  1  0  0 0.000  0
#> SRR1179110     2  0.0000      1.000 0.000  1  0  0 0.000  0
#> SRR1179111     2  0.0000      1.000 0.000  1  0  0 0.000  0
#> SRR1179112     1  0.0000      0.907 1.000  0  0  0 0.000  0
#> SRR1179113     1  0.0000      0.907 1.000  0  0  0 0.000  0
#> SRR1179114     1  0.0000      0.907 1.000  0  0  0 0.000  0
#> SRR1179115     1  0.0000      0.907 1.000  0  0  0 0.000  0
#> SRR1179116     1  0.0000      0.907 1.000  0  0  0 0.000  0
#> SRR1179117     1  0.0000      0.907 1.000  0  0  0 0.000  0
#> SRR1179118     1  0.0000      0.907 1.000  0  0  0 0.000  0
#> SRR1179119     1  0.0000      0.907 1.000  0  0  0 0.000  0
#> SRR1179120     4  0.0000      1.000 0.000  0  0  1 0.000  0
#> SRR1179121     4  0.0000      1.000 0.000  0  0  1 0.000  0
#> SRR1179122     4  0.0000      1.000 0.000  0  0  1 0.000  0
#> SRR1179123     4  0.0000      1.000 0.000  0  0  1 0.000  0
#> SRR1179124     4  0.0000      1.000 0.000  0  0  1 0.000  0
#> SRR1179125     4  0.0000      1.000 0.000  0  0  1 0.000  0
#> SRR1179126     4  0.0000      1.000 0.000  0  0  1 0.000  0
#> SRR1179127     5  0.0000      0.840 0.000  0  0  0 1.000  0
#> SRR1179128     5  0.0000      0.840 0.000  0  0  0 1.000  0
#> SRR1179129     5  0.0000      0.840 0.000  0  0  0 1.000  0
#> SRR1179130     5  0.0000      0.840 0.000  0  0  0 1.000  0
#> SRR1179131     5  0.0000      0.840 0.000  0  0  0 1.000  0
#> SRR1179132     5  0.0000      0.840 0.000  0  0  0 1.000  0
#> SRR1179134     5  0.0000      0.840 0.000  0  0  0 1.000  0
#> SRR1179135     5  0.3620      0.480 0.352  0  0  0 0.648  0
#> SRR1179136     1  0.3266      0.566 0.728  0  0  0 0.272  0
#> SRR1179137     5  0.2219      0.748 0.136  0  0  0 0.864  0
#> SRR1179138     5  0.3607      0.491 0.348  0  0  0 0.652  0
#> SRR1179139     5  0.3860      0.144 0.472  0  0  0 0.528  0
#> SRR1179140     5  0.0632      0.830 0.024  0  0  0 0.976  0
#> SRR1179141     1  0.3592      0.404 0.656  0  0  0 0.344  0

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.981       0.986         0.3884 0.619   0.619
#> 3 3 1.000           0.999       1.000         0.6573 0.738   0.576
#> 4 4 0.905           0.945       0.942         0.1491 0.913   0.756
#> 5 5 0.947           0.869       0.899         0.0719 0.941   0.780
#> 6 6 0.947           0.861       0.913         0.0134 0.980   0.905

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1179081     2   0.000      1.000 0.000 1.000
#> SRR1179082     2   0.000      1.000 0.000 1.000
#> SRR1179083     2   0.000      1.000 0.000 1.000
#> SRR1179084     2   0.000      1.000 0.000 1.000
#> SRR1179085     2   0.000      1.000 0.000 1.000
#> SRR1179086     2   0.000      1.000 0.000 1.000
#> SRR1179087     2   0.000      1.000 0.000 1.000
#> SRR1179088     2   0.000      1.000 0.000 1.000
#> SRR1179089     2   0.000      1.000 0.000 1.000
#> SRR1179090     2   0.000      1.000 0.000 1.000
#> SRR1179091     2   0.000      1.000 0.000 1.000
#> SRR1179092     2   0.000      1.000 0.000 1.000
#> SRR1179093     2   0.000      1.000 0.000 1.000
#> SRR1179094     2   0.000      1.000 0.000 1.000
#> SRR1179095     2   0.000      1.000 0.000 1.000
#> SRR1179096     1   0.295      0.964 0.948 0.052
#> SRR1179097     1   0.295      0.964 0.948 0.052
#> SRR1179098     1   0.295      0.964 0.948 0.052
#> SRR1179099     1   0.295      0.964 0.948 0.052
#> SRR1179100     1   0.295      0.964 0.948 0.052
#> SRR1179101     1   0.295      0.964 0.948 0.052
#> SRR1179102     1   0.295      0.964 0.948 0.052
#> SRR1179103     1   0.295      0.964 0.948 0.052
#> SRR1179104     1   0.295      0.964 0.948 0.052
#> SRR1179105     1   0.295      0.964 0.948 0.052
#> SRR1179106     1   0.295      0.964 0.948 0.052
#> SRR1179107     1   0.295      0.964 0.948 0.052
#> SRR1179108     1   0.295      0.964 0.948 0.052
#> SRR1179109     1   0.295      0.964 0.948 0.052
#> SRR1179110     1   0.295      0.964 0.948 0.052
#> SRR1179111     1   0.295      0.964 0.948 0.052
#> SRR1179112     1   0.000      0.981 1.000 0.000
#> SRR1179113     1   0.000      0.981 1.000 0.000
#> SRR1179114     1   0.000      0.981 1.000 0.000
#> SRR1179115     1   0.000      0.981 1.000 0.000
#> SRR1179116     1   0.000      0.981 1.000 0.000
#> SRR1179117     1   0.000      0.981 1.000 0.000
#> SRR1179118     1   0.000      0.981 1.000 0.000
#> SRR1179119     1   0.000      0.981 1.000 0.000
#> SRR1179120     1   0.000      0.981 1.000 0.000
#> SRR1179121     1   0.000      0.981 1.000 0.000
#> SRR1179122     1   0.000      0.981 1.000 0.000
#> SRR1179123     1   0.000      0.981 1.000 0.000
#> SRR1179124     1   0.000      0.981 1.000 0.000
#> SRR1179125     1   0.000      0.981 1.000 0.000
#> SRR1179126     1   0.000      0.981 1.000 0.000
#> SRR1179127     1   0.000      0.981 1.000 0.000
#> SRR1179128     1   0.000      0.981 1.000 0.000
#> SRR1179129     1   0.000      0.981 1.000 0.000
#> SRR1179130     1   0.000      0.981 1.000 0.000
#> SRR1179131     1   0.000      0.981 1.000 0.000
#> SRR1179132     1   0.000      0.981 1.000 0.000
#> SRR1179134     1   0.000      0.981 1.000 0.000
#> SRR1179135     1   0.000      0.981 1.000 0.000
#> SRR1179136     1   0.000      0.981 1.000 0.000
#> SRR1179137     1   0.000      0.981 1.000 0.000
#> SRR1179138     1   0.000      0.981 1.000 0.000
#> SRR1179139     1   0.000      0.981 1.000 0.000
#> SRR1179140     1   0.000      0.981 1.000 0.000
#> SRR1179141     1   0.000      0.981 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2 p3
#> SRR1179081     3  0.0000      1.000 0.000 0.000  1
#> SRR1179082     3  0.0000      1.000 0.000 0.000  1
#> SRR1179083     3  0.0000      1.000 0.000 0.000  1
#> SRR1179084     3  0.0000      1.000 0.000 0.000  1
#> SRR1179085     3  0.0000      1.000 0.000 0.000  1
#> SRR1179086     3  0.0000      1.000 0.000 0.000  1
#> SRR1179087     3  0.0000      1.000 0.000 0.000  1
#> SRR1179088     3  0.0000      1.000 0.000 0.000  1
#> SRR1179089     3  0.0000      1.000 0.000 0.000  1
#> SRR1179090     3  0.0000      1.000 0.000 0.000  1
#> SRR1179091     3  0.0000      1.000 0.000 0.000  1
#> SRR1179092     3  0.0000      1.000 0.000 0.000  1
#> SRR1179093     3  0.0000      1.000 0.000 0.000  1
#> SRR1179094     3  0.0000      1.000 0.000 0.000  1
#> SRR1179095     3  0.0000      1.000 0.000 0.000  1
#> SRR1179096     2  0.0747      0.981 0.016 0.984  0
#> SRR1179097     2  0.0000      0.999 0.000 1.000  0
#> SRR1179098     2  0.0000      0.999 0.000 1.000  0
#> SRR1179099     2  0.0000      0.999 0.000 1.000  0
#> SRR1179100     2  0.0000      0.999 0.000 1.000  0
#> SRR1179101     2  0.0000      0.999 0.000 1.000  0
#> SRR1179102     2  0.0000      0.999 0.000 1.000  0
#> SRR1179103     2  0.0000      0.999 0.000 1.000  0
#> SRR1179104     2  0.0000      0.999 0.000 1.000  0
#> SRR1179105     2  0.0000      0.999 0.000 1.000  0
#> SRR1179106     2  0.0000      0.999 0.000 1.000  0
#> SRR1179107     2  0.0000      0.999 0.000 1.000  0
#> SRR1179108     2  0.0000      0.999 0.000 1.000  0
#> SRR1179109     2  0.0000      0.999 0.000 1.000  0
#> SRR1179110     2  0.0000      0.999 0.000 1.000  0
#> SRR1179111     2  0.0000      0.999 0.000 1.000  0
#> SRR1179112     1  0.0000      1.000 1.000 0.000  0
#> SRR1179113     1  0.0000      1.000 1.000 0.000  0
#> SRR1179114     1  0.0000      1.000 1.000 0.000  0
#> SRR1179115     1  0.0000      1.000 1.000 0.000  0
#> SRR1179116     1  0.0000      1.000 1.000 0.000  0
#> SRR1179117     1  0.0000      1.000 1.000 0.000  0
#> SRR1179118     1  0.0000      1.000 1.000 0.000  0
#> SRR1179119     1  0.0000      1.000 1.000 0.000  0
#> SRR1179120     1  0.0000      1.000 1.000 0.000  0
#> SRR1179121     1  0.0000      1.000 1.000 0.000  0
#> SRR1179122     1  0.0000      1.000 1.000 0.000  0
#> SRR1179123     1  0.0000      1.000 1.000 0.000  0
#> SRR1179124     1  0.0000      1.000 1.000 0.000  0
#> SRR1179125     1  0.0000      1.000 1.000 0.000  0
#> SRR1179126     1  0.0000      1.000 1.000 0.000  0
#> SRR1179127     1  0.0000      1.000 1.000 0.000  0
#> SRR1179128     1  0.0000      1.000 1.000 0.000  0
#> SRR1179129     1  0.0000      1.000 1.000 0.000  0
#> SRR1179130     1  0.0000      1.000 1.000 0.000  0
#> SRR1179131     1  0.0000      1.000 1.000 0.000  0
#> SRR1179132     1  0.0000      1.000 1.000 0.000  0
#> SRR1179134     1  0.0000      1.000 1.000 0.000  0
#> SRR1179135     1  0.0000      1.000 1.000 0.000  0
#> SRR1179136     1  0.0000      1.000 1.000 0.000  0
#> SRR1179137     1  0.0000      1.000 1.000 0.000  0
#> SRR1179138     1  0.0000      1.000 1.000 0.000  0
#> SRR1179139     1  0.0000      1.000 1.000 0.000  0
#> SRR1179140     1  0.0000      1.000 1.000 0.000  0
#> SRR1179141     1  0.0000      1.000 1.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1   p2 p3    p4
#> SRR1179081     3  0.0000      1.000 0.000 0.00  1 0.000
#> SRR1179082     3  0.0000      1.000 0.000 0.00  1 0.000
#> SRR1179083     3  0.0000      1.000 0.000 0.00  1 0.000
#> SRR1179084     3  0.0000      1.000 0.000 0.00  1 0.000
#> SRR1179085     3  0.0000      1.000 0.000 0.00  1 0.000
#> SRR1179086     3  0.0000      1.000 0.000 0.00  1 0.000
#> SRR1179087     3  0.0000      1.000 0.000 0.00  1 0.000
#> SRR1179088     3  0.0000      1.000 0.000 0.00  1 0.000
#> SRR1179089     3  0.0000      1.000 0.000 0.00  1 0.000
#> SRR1179090     3  0.0000      1.000 0.000 0.00  1 0.000
#> SRR1179091     3  0.0000      1.000 0.000 0.00  1 0.000
#> SRR1179092     3  0.0000      1.000 0.000 0.00  1 0.000
#> SRR1179093     3  0.0000      1.000 0.000 0.00  1 0.000
#> SRR1179094     3  0.0000      1.000 0.000 0.00  1 0.000
#> SRR1179095     3  0.0000      1.000 0.000 0.00  1 0.000
#> SRR1179096     2  0.0707      0.974 0.020 0.98  0 0.000
#> SRR1179097     2  0.0000      0.998 0.000 1.00  0 0.000
#> SRR1179098     2  0.0000      0.998 0.000 1.00  0 0.000
#> SRR1179099     2  0.0000      0.998 0.000 1.00  0 0.000
#> SRR1179100     2  0.0000      0.998 0.000 1.00  0 0.000
#> SRR1179101     2  0.0000      0.998 0.000 1.00  0 0.000
#> SRR1179102     2  0.0000      0.998 0.000 1.00  0 0.000
#> SRR1179103     2  0.0000      0.998 0.000 1.00  0 0.000
#> SRR1179104     2  0.0000      0.998 0.000 1.00  0 0.000
#> SRR1179105     2  0.0000      0.998 0.000 1.00  0 0.000
#> SRR1179106     2  0.0000      0.998 0.000 1.00  0 0.000
#> SRR1179107     2  0.0000      0.998 0.000 1.00  0 0.000
#> SRR1179108     2  0.0000      0.998 0.000 1.00  0 0.000
#> SRR1179109     2  0.0000      0.998 0.000 1.00  0 0.000
#> SRR1179110     2  0.0000      0.998 0.000 1.00  0 0.000
#> SRR1179111     2  0.0000      0.998 0.000 1.00  0 0.000
#> SRR1179112     1  0.3569      0.820 0.804 0.00  0 0.196
#> SRR1179113     1  0.3569      0.820 0.804 0.00  0 0.196
#> SRR1179114     1  0.3569      0.820 0.804 0.00  0 0.196
#> SRR1179115     1  0.3569      0.820 0.804 0.00  0 0.196
#> SRR1179116     1  0.3569      0.820 0.804 0.00  0 0.196
#> SRR1179117     1  0.3569      0.820 0.804 0.00  0 0.196
#> SRR1179118     1  0.3569      0.820 0.804 0.00  0 0.196
#> SRR1179119     1  0.3569      0.820 0.804 0.00  0 0.196
#> SRR1179120     4  0.0000      1.000 0.000 0.00  0 1.000
#> SRR1179121     4  0.0000      1.000 0.000 0.00  0 1.000
#> SRR1179122     4  0.0000      1.000 0.000 0.00  0 1.000
#> SRR1179123     4  0.0000      1.000 0.000 0.00  0 1.000
#> SRR1179124     4  0.0000      1.000 0.000 0.00  0 1.000
#> SRR1179125     4  0.0000      1.000 0.000 0.00  0 1.000
#> SRR1179126     4  0.0000      1.000 0.000 0.00  0 1.000
#> SRR1179127     1  0.2149      0.864 0.912 0.00  0 0.088
#> SRR1179128     1  0.2149      0.864 0.912 0.00  0 0.088
#> SRR1179129     1  0.2149      0.864 0.912 0.00  0 0.088
#> SRR1179130     1  0.2149      0.864 0.912 0.00  0 0.088
#> SRR1179131     1  0.2149      0.864 0.912 0.00  0 0.088
#> SRR1179132     1  0.2149      0.864 0.912 0.00  0 0.088
#> SRR1179134     1  0.2149      0.864 0.912 0.00  0 0.088
#> SRR1179135     1  0.0000      0.880 1.000 0.00  0 0.000
#> SRR1179136     1  0.0000      0.880 1.000 0.00  0 0.000
#> SRR1179137     1  0.0000      0.880 1.000 0.00  0 0.000
#> SRR1179138     1  0.0000      0.880 1.000 0.00  0 0.000
#> SRR1179139     1  0.0000      0.880 1.000 0.00  0 0.000
#> SRR1179140     1  0.0000      0.880 1.000 0.00  0 0.000
#> SRR1179141     1  0.0000      0.880 1.000 0.00  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
#> SRR1179081     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1179082     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1179083     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1179084     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1179085     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1179086     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1179087     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1179088     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1179089     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1179090     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1179091     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1179092     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1179093     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1179094     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1179095     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1179096     2   0.411      0.452 0.000 0.624  0  0 0.376
#> SRR1179097     2   0.000      0.975 0.000 1.000  0  0 0.000
#> SRR1179098     2   0.000      0.975 0.000 1.000  0  0 0.000
#> SRR1179099     2   0.000      0.975 0.000 1.000  0  0 0.000
#> SRR1179100     2   0.000      0.975 0.000 1.000  0  0 0.000
#> SRR1179101     2   0.000      0.975 0.000 1.000  0  0 0.000
#> SRR1179102     2   0.000      0.975 0.000 1.000  0  0 0.000
#> SRR1179103     2   0.000      0.975 0.000 1.000  0  0 0.000
#> SRR1179104     2   0.000      0.975 0.000 1.000  0  0 0.000
#> SRR1179105     2   0.000      0.975 0.000 1.000  0  0 0.000
#> SRR1179106     2   0.000      0.975 0.000 1.000  0  0 0.000
#> SRR1179107     2   0.000      0.975 0.000 1.000  0  0 0.000
#> SRR1179108     2   0.000      0.975 0.000 1.000  0  0 0.000
#> SRR1179109     2   0.000      0.975 0.000 1.000  0  0 0.000
#> SRR1179110     2   0.000      0.975 0.000 1.000  0  0 0.000
#> SRR1179111     2   0.000      0.975 0.000 1.000  0  0 0.000
#> SRR1179112     1   0.368     -0.365 0.720 0.000  0  0 0.280
#> SRR1179113     1   0.000      0.549 1.000 0.000  0  0 0.000
#> SRR1179114     1   0.000      0.549 1.000 0.000  0  0 0.000
#> SRR1179115     1   0.000      0.549 1.000 0.000  0  0 0.000
#> SRR1179116     1   0.000      0.549 1.000 0.000  0  0 0.000
#> SRR1179117     1   0.000      0.549 1.000 0.000  0  0 0.000
#> SRR1179118     1   0.127      0.451 0.948 0.000  0  0 0.052
#> SRR1179119     1   0.000      0.549 1.000 0.000  0  0 0.000
#> SRR1179120     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1179121     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1179122     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1179123     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1179124     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1179125     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1179126     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1179127     1   0.427      0.669 0.556 0.000  0  0 0.444
#> SRR1179128     1   0.427      0.669 0.556 0.000  0  0 0.444
#> SRR1179129     1   0.427      0.669 0.556 0.000  0  0 0.444
#> SRR1179130     1   0.427      0.667 0.552 0.000  0  0 0.448
#> SRR1179131     1   0.427      0.669 0.556 0.000  0  0 0.444
#> SRR1179132     1   0.427      0.669 0.556 0.000  0  0 0.444
#> SRR1179134     1   0.427      0.669 0.556 0.000  0  0 0.444
#> SRR1179135     5   0.427      1.000 0.444 0.000  0  0 0.556
#> SRR1179136     5   0.427      1.000 0.444 0.000  0  0 0.556
#> SRR1179137     5   0.427      1.000 0.444 0.000  0  0 0.556
#> SRR1179138     5   0.427      1.000 0.444 0.000  0  0 0.556
#> SRR1179139     5   0.427      1.000 0.444 0.000  0  0 0.556
#> SRR1179140     5   0.427      1.000 0.444 0.000  0  0 0.556
#> SRR1179141     5   0.427      1.000 0.444 0.000  0  0 0.556

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3 p4    p5    p6
#> SRR1179081     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179082     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179083     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179084     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179085     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179086     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179087     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179088     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179089     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179090     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179091     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179092     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179093     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179094     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179095     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179096     6  0.2340      0.000 0.000 0.148  0  0 0.000 0.852
#> SRR1179097     2  0.0000      0.999 0.000 1.000  0  0 0.000 0.000
#> SRR1179098     2  0.0000      0.999 0.000 1.000  0  0 0.000 0.000
#> SRR1179099     2  0.0000      0.999 0.000 1.000  0  0 0.000 0.000
#> SRR1179100     2  0.0000      0.999 0.000 1.000  0  0 0.000 0.000
#> SRR1179101     2  0.0000      0.999 0.000 1.000  0  0 0.000 0.000
#> SRR1179102     2  0.0000      0.999 0.000 1.000  0  0 0.000 0.000
#> SRR1179103     2  0.0000      0.999 0.000 1.000  0  0 0.000 0.000
#> SRR1179104     2  0.0458      0.981 0.000 0.984  0  0 0.000 0.016
#> SRR1179105     2  0.0000      0.999 0.000 1.000  0  0 0.000 0.000
#> SRR1179106     2  0.0000      0.999 0.000 1.000  0  0 0.000 0.000
#> SRR1179107     2  0.0000      0.999 0.000 1.000  0  0 0.000 0.000
#> SRR1179108     2  0.0000      0.999 0.000 1.000  0  0 0.000 0.000
#> SRR1179109     2  0.0000      0.999 0.000 1.000  0  0 0.000 0.000
#> SRR1179110     2  0.0000      0.999 0.000 1.000  0  0 0.000 0.000
#> SRR1179111     2  0.0000      0.999 0.000 1.000  0  0 0.000 0.000
#> SRR1179112     1  0.4989      0.240 0.628 0.000  0  0 0.252 0.120
#> SRR1179113     5  0.5510      0.538 0.340 0.000  0  0 0.516 0.144
#> SRR1179114     5  0.5510      0.538 0.340 0.000  0  0 0.516 0.144
#> SRR1179115     5  0.5510      0.538 0.340 0.000  0  0 0.516 0.144
#> SRR1179116     5  0.5510      0.538 0.340 0.000  0  0 0.516 0.144
#> SRR1179117     5  0.5510      0.538 0.340 0.000  0  0 0.516 0.144
#> SRR1179118     5  0.5583      0.390 0.412 0.000  0  0 0.448 0.140
#> SRR1179119     5  0.5510      0.538 0.340 0.000  0  0 0.516 0.144
#> SRR1179120     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1179121     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1179122     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1179123     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1179124     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1179125     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1179126     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1179127     5  0.0935      0.622 0.032 0.000  0  0 0.964 0.004
#> SRR1179128     5  0.0146      0.617 0.004 0.000  0  0 0.996 0.000
#> SRR1179129     5  0.0935      0.622 0.032 0.000  0  0 0.964 0.004
#> SRR1179130     5  0.0937      0.619 0.040 0.000  0  0 0.960 0.000
#> SRR1179131     5  0.0935      0.622 0.032 0.000  0  0 0.964 0.004
#> SRR1179132     5  0.0865      0.622 0.036 0.000  0  0 0.964 0.000
#> SRR1179134     5  0.0865      0.621 0.036 0.000  0  0 0.964 0.000
#> SRR1179135     1  0.0000      0.930 1.000 0.000  0  0 0.000 0.000
#> SRR1179136     1  0.0000      0.930 1.000 0.000  0  0 0.000 0.000
#> SRR1179137     1  0.0000      0.930 1.000 0.000  0  0 0.000 0.000
#> SRR1179138     1  0.0000      0.930 1.000 0.000  0  0 0.000 0.000
#> SRR1179139     1  0.0000      0.930 1.000 0.000  0  0 0.000 0.000
#> SRR1179140     1  0.0000      0.930 1.000 0.000  0  0 0.000 0.000
#> SRR1179141     1  0.0000      0.930 1.000 0.000  0  0 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 0.864           0.998       0.970         0.2385 0.864   0.724
#> 4 4 0.895           0.963       0.959         0.0519 1.000   1.000
#> 5 5 0.833           0.918       0.919         0.0406 1.000   1.000
#> 6 6 0.835           0.882       0.884         0.0380 0.913   0.756

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
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1179081     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179082     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179083     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179084     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179085     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179086     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179087     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179088     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179089     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179090     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179091     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179092     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179093     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179094     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179095     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179096     2  0.3192      0.998 0.000 0.888 0.112
#> SRR1179097     2  0.3267      0.997 0.000 0.884 0.116
#> SRR1179098     2  0.3267      0.997 0.000 0.884 0.116
#> SRR1179099     2  0.3267      0.997 0.000 0.884 0.116
#> SRR1179100     2  0.3267      0.997 0.000 0.884 0.116
#> SRR1179101     2  0.3267      0.997 0.000 0.884 0.116
#> SRR1179102     2  0.3267      0.997 0.000 0.884 0.116
#> SRR1179103     2  0.3267      0.997 0.000 0.884 0.116
#> SRR1179104     2  0.3192      0.998 0.000 0.888 0.112
#> SRR1179105     2  0.3192      0.998 0.000 0.888 0.112
#> SRR1179106     2  0.3192      0.998 0.000 0.888 0.112
#> SRR1179107     2  0.3192      0.998 0.000 0.888 0.112
#> SRR1179108     2  0.3192      0.998 0.000 0.888 0.112
#> SRR1179109     2  0.3192      0.998 0.000 0.888 0.112
#> SRR1179110     2  0.3192      0.998 0.000 0.888 0.112
#> SRR1179111     2  0.3192      0.998 0.000 0.888 0.112
#> SRR1179112     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179113     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179114     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179115     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179116     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179117     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179118     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179119     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179120     1  0.0592      0.993 0.988 0.012 0.000
#> SRR1179121     1  0.0592      0.993 0.988 0.012 0.000
#> SRR1179122     1  0.0592      0.993 0.988 0.012 0.000
#> SRR1179123     1  0.0592      0.993 0.988 0.012 0.000
#> SRR1179124     1  0.0592      0.993 0.988 0.012 0.000
#> SRR1179125     1  0.0592      0.993 0.988 0.012 0.000
#> SRR1179126     1  0.0424      0.995 0.992 0.008 0.000
#> SRR1179127     1  0.0237      0.996 0.996 0.004 0.000
#> SRR1179128     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179129     1  0.0237      0.996 0.996 0.004 0.000
#> SRR1179130     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179131     1  0.0237      0.996 0.996 0.004 0.000
#> SRR1179132     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179134     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179135     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179136     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179137     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179138     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179139     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179140     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1179141     1  0.0000      0.997 1.000 0.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
#> SRR1179081     3  0.0469      1.000 0.000 0.012 0.988 NA
#> SRR1179082     3  0.0469      1.000 0.000 0.012 0.988 NA
#> SRR1179083     3  0.0469      1.000 0.000 0.012 0.988 NA
#> SRR1179084     3  0.0469      1.000 0.000 0.012 0.988 NA
#> SRR1179085     3  0.0469      1.000 0.000 0.012 0.988 NA
#> SRR1179086     3  0.0469      1.000 0.000 0.012 0.988 NA
#> SRR1179087     3  0.0469      1.000 0.000 0.012 0.988 NA
#> SRR1179088     3  0.0469      1.000 0.000 0.012 0.988 NA
#> SRR1179089     3  0.0469      1.000 0.000 0.012 0.988 NA
#> SRR1179090     3  0.0469      1.000 0.000 0.012 0.988 NA
#> SRR1179091     3  0.0469      1.000 0.000 0.012 0.988 NA
#> SRR1179092     3  0.0469      1.000 0.000 0.012 0.988 NA
#> SRR1179093     3  0.0469      1.000 0.000 0.012 0.988 NA
#> SRR1179094     3  0.0469      1.000 0.000 0.012 0.988 NA
#> SRR1179095     3  0.0469      1.000 0.000 0.012 0.988 NA
#> SRR1179096     2  0.1022      0.968 0.000 0.968 0.000 NA
#> SRR1179097     2  0.0817      0.987 0.000 0.976 0.024 NA
#> SRR1179098     2  0.1022      0.984 0.000 0.968 0.032 NA
#> SRR1179099     2  0.1109      0.986 0.000 0.968 0.028 NA
#> SRR1179100     2  0.1109      0.986 0.000 0.968 0.028 NA
#> SRR1179101     2  0.0921      0.986 0.000 0.972 0.028 NA
#> SRR1179102     2  0.1109      0.986 0.000 0.968 0.028 NA
#> SRR1179103     2  0.0921      0.986 0.000 0.972 0.028 NA
#> SRR1179104     2  0.0188      0.985 0.000 0.996 0.004 NA
#> SRR1179105     2  0.0524      0.987 0.000 0.988 0.008 NA
#> SRR1179106     2  0.0336      0.987 0.000 0.992 0.008 NA
#> SRR1179107     2  0.0592      0.988 0.000 0.984 0.016 NA
#> SRR1179108     2  0.0524      0.987 0.000 0.988 0.008 NA
#> SRR1179109     2  0.0336      0.987 0.000 0.992 0.008 NA
#> SRR1179110     2  0.0336      0.987 0.000 0.992 0.008 NA
#> SRR1179111     2  0.0657      0.988 0.000 0.984 0.012 NA
#> SRR1179112     1  0.0188      0.947 0.996 0.000 0.000 NA
#> SRR1179113     1  0.0188      0.947 0.996 0.000 0.000 NA
#> SRR1179114     1  0.0188      0.947 0.996 0.000 0.000 NA
#> SRR1179115     1  0.0188      0.947 0.996 0.000 0.000 NA
#> SRR1179116     1  0.0188      0.947 0.996 0.000 0.000 NA
#> SRR1179117     1  0.0336      0.947 0.992 0.000 0.000 NA
#> SRR1179118     1  0.0188      0.947 0.996 0.000 0.000 NA
#> SRR1179119     1  0.0592      0.947 0.984 0.000 0.000 NA
#> SRR1179120     1  0.3528      0.891 0.808 0.000 0.000 NA
#> SRR1179121     1  0.3528      0.891 0.808 0.000 0.000 NA
#> SRR1179122     1  0.3528      0.891 0.808 0.000 0.000 NA
#> SRR1179123     1  0.3528      0.891 0.808 0.000 0.000 NA
#> SRR1179124     1  0.3528      0.891 0.808 0.000 0.000 NA
#> SRR1179125     1  0.3528      0.891 0.808 0.000 0.000 NA
#> SRR1179126     1  0.3528      0.891 0.808 0.000 0.000 NA
#> SRR1179127     1  0.2345      0.928 0.900 0.000 0.000 NA
#> SRR1179128     1  0.1118      0.945 0.964 0.000 0.000 NA
#> SRR1179129     1  0.2469      0.927 0.892 0.000 0.000 NA
#> SRR1179130     1  0.1118      0.945 0.964 0.000 0.000 NA
#> SRR1179131     1  0.2469      0.929 0.892 0.000 0.000 NA
#> SRR1179132     1  0.1302      0.944 0.956 0.000 0.000 NA
#> SRR1179134     1  0.1022      0.946 0.968 0.000 0.000 NA
#> SRR1179135     1  0.0707      0.943 0.980 0.000 0.000 NA
#> SRR1179136     1  0.0707      0.943 0.980 0.000 0.000 NA
#> SRR1179137     1  0.0707      0.943 0.980 0.000 0.000 NA
#> SRR1179138     1  0.0707      0.943 0.980 0.000 0.000 NA
#> SRR1179139     1  0.0707      0.943 0.980 0.000 0.000 NA
#> SRR1179140     1  0.0707      0.943 0.980 0.000 0.000 NA
#> SRR1179141     1  0.0707      0.943 0.980 0.000 0.000 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3 p4 p5
#> SRR1179081     3  0.0566      0.997 0.000 0.012 0.984 NA NA
#> SRR1179082     3  0.0566      0.998 0.000 0.012 0.984 NA NA
#> SRR1179083     3  0.0566      0.998 0.000 0.012 0.984 NA NA
#> SRR1179084     3  0.0566      0.998 0.000 0.012 0.984 NA NA
#> SRR1179085     3  0.0566      0.998 0.000 0.012 0.984 NA NA
#> SRR1179086     3  0.0566      0.998 0.000 0.012 0.984 NA NA
#> SRR1179087     3  0.0566      0.998 0.000 0.012 0.984 NA NA
#> SRR1179088     3  0.0566      0.998 0.000 0.012 0.984 NA NA
#> SRR1179089     3  0.0566      0.997 0.000 0.012 0.984 NA NA
#> SRR1179090     3  0.0404      0.998 0.000 0.012 0.988 NA NA
#> SRR1179091     3  0.0566      0.997 0.000 0.012 0.984 NA NA
#> SRR1179092     3  0.0404      0.998 0.000 0.012 0.988 NA NA
#> SRR1179093     3  0.0404      0.998 0.000 0.012 0.988 NA NA
#> SRR1179094     3  0.0566      0.997 0.000 0.012 0.984 NA NA
#> SRR1179095     3  0.0404      0.998 0.000 0.012 0.988 NA NA
#> SRR1179096     2  0.1756      0.956 0.000 0.940 0.016 NA NA
#> SRR1179097     2  0.0794      0.986 0.000 0.972 0.028 NA NA
#> SRR1179098     2  0.0794      0.986 0.000 0.972 0.028 NA NA
#> SRR1179099     2  0.0794      0.986 0.000 0.972 0.028 NA NA
#> SRR1179100     2  0.0703      0.987 0.000 0.976 0.024 NA NA
#> SRR1179101     2  0.0794      0.986 0.000 0.972 0.028 NA NA
#> SRR1179102     2  0.0880      0.983 0.000 0.968 0.032 NA NA
#> SRR1179103     2  0.0703      0.987 0.000 0.976 0.024 NA NA
#> SRR1179104     2  0.0162      0.985 0.000 0.996 0.004 NA NA
#> SRR1179105     2  0.0162      0.985 0.000 0.996 0.004 NA NA
#> SRR1179106     2  0.0290      0.987 0.000 0.992 0.008 NA NA
#> SRR1179107     2  0.0404      0.988 0.000 0.988 0.012 NA NA
#> SRR1179108     2  0.0290      0.987 0.000 0.992 0.008 NA NA
#> SRR1179109     2  0.0290      0.987 0.000 0.992 0.008 NA NA
#> SRR1179110     2  0.0162      0.985 0.000 0.996 0.004 NA NA
#> SRR1179111     2  0.0404      0.988 0.000 0.988 0.012 NA NA
#> SRR1179112     1  0.1168      0.879 0.960 0.000 0.000 NA NA
#> SRR1179113     1  0.1168      0.879 0.960 0.000 0.000 NA NA
#> SRR1179114     1  0.1168      0.879 0.960 0.000 0.000 NA NA
#> SRR1179115     1  0.1168      0.879 0.960 0.000 0.000 NA NA
#> SRR1179116     1  0.1168      0.879 0.960 0.000 0.000 NA NA
#> SRR1179117     1  0.1168      0.879 0.960 0.000 0.000 NA NA
#> SRR1179118     1  0.1168      0.879 0.960 0.000 0.000 NA NA
#> SRR1179119     1  0.1168      0.879 0.960 0.000 0.000 NA NA
#> SRR1179120     1  0.4101      0.771 0.628 0.000 0.000 NA NA
#> SRR1179121     1  0.4101      0.771 0.628 0.000 0.000 NA NA
#> SRR1179122     1  0.4101      0.771 0.628 0.000 0.000 NA NA
#> SRR1179123     1  0.4101      0.771 0.628 0.000 0.000 NA NA
#> SRR1179124     1  0.4101      0.771 0.628 0.000 0.000 NA NA
#> SRR1179125     1  0.4101      0.771 0.628 0.000 0.000 NA NA
#> SRR1179126     1  0.4101      0.771 0.628 0.000 0.000 NA NA
#> SRR1179127     1  0.3398      0.829 0.780 0.000 0.000 NA NA
#> SRR1179128     1  0.1282      0.877 0.952 0.000 0.000 NA NA
#> SRR1179129     1  0.3171      0.842 0.816 0.000 0.000 NA NA
#> SRR1179130     1  0.0798      0.876 0.976 0.000 0.000 NA NA
#> SRR1179131     1  0.3246      0.839 0.808 0.000 0.000 NA NA
#> SRR1179132     1  0.0955      0.877 0.968 0.000 0.000 NA NA
#> SRR1179134     1  0.0693      0.876 0.980 0.000 0.000 NA NA
#> SRR1179135     1  0.2127      0.847 0.892 0.000 0.000 NA NA
#> SRR1179136     1  0.1792      0.853 0.916 0.000 0.000 NA NA
#> SRR1179137     1  0.2127      0.844 0.892 0.000 0.000 NA NA
#> SRR1179138     1  0.2127      0.844 0.892 0.000 0.000 NA NA
#> SRR1179139     1  0.2074      0.846 0.896 0.000 0.000 NA NA
#> SRR1179140     1  0.2230      0.844 0.884 0.000 0.000 NA NA
#> SRR1179141     1  0.2179      0.846 0.888 0.000 0.000 NA NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1179081     3  0.0363      0.992 0.000 0.000 0.988 0.000 0.000 NA
#> SRR1179082     3  0.0260      0.995 0.000 0.000 0.992 0.000 0.000 NA
#> SRR1179083     3  0.0000      0.995 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1179084     3  0.0146      0.995 0.000 0.000 0.996 0.000 0.000 NA
#> SRR1179085     3  0.0260      0.995 0.000 0.000 0.992 0.000 0.000 NA
#> SRR1179086     3  0.0146      0.995 0.000 0.000 0.996 0.000 0.000 NA
#> SRR1179087     3  0.0146      0.995 0.000 0.000 0.996 0.000 0.000 NA
#> SRR1179088     3  0.0363      0.994 0.000 0.000 0.988 0.000 0.000 NA
#> SRR1179089     3  0.0260      0.993 0.000 0.000 0.992 0.000 0.000 NA
#> SRR1179090     3  0.0146      0.995 0.000 0.000 0.996 0.000 0.000 NA
#> SRR1179091     3  0.0260      0.995 0.000 0.000 0.992 0.000 0.000 NA
#> SRR1179092     3  0.0146      0.995 0.000 0.000 0.996 0.000 0.000 NA
#> SRR1179093     3  0.0260      0.995 0.000 0.000 0.992 0.000 0.000 NA
#> SRR1179094     3  0.0260      0.993 0.000 0.000 0.992 0.000 0.000 NA
#> SRR1179095     3  0.0260      0.995 0.000 0.000 0.992 0.000 0.000 NA
#> SRR1179096     2  0.4354      0.732 0.000 0.692 0.068 0.000 0.000 NA
#> SRR1179097     2  0.0363      0.977 0.000 0.988 0.012 0.000 0.000 NA
#> SRR1179098     2  0.0603      0.975 0.000 0.980 0.016 0.000 0.000 NA
#> SRR1179099     2  0.0405      0.977 0.000 0.988 0.008 0.000 0.000 NA
#> SRR1179100     2  0.0508      0.977 0.000 0.984 0.012 0.000 0.000 NA
#> SRR1179101     2  0.0458      0.975 0.000 0.984 0.016 0.000 0.000 NA
#> SRR1179102     2  0.0458      0.975 0.000 0.984 0.016 0.000 0.000 NA
#> SRR1179103     2  0.0508      0.977 0.000 0.984 0.012 0.000 0.000 NA
#> SRR1179104     2  0.0000      0.976 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1179105     2  0.0146      0.976 0.000 0.996 0.000 0.000 0.000 NA
#> SRR1179106     2  0.0146      0.976 0.000 0.996 0.000 0.000 0.000 NA
#> SRR1179107     2  0.0146      0.977 0.000 0.996 0.004 0.000 0.000 NA
#> SRR1179108     2  0.0000      0.976 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1179109     2  0.0405      0.976 0.000 0.988 0.004 0.000 0.000 NA
#> SRR1179110     2  0.0260      0.975 0.000 0.992 0.000 0.000 0.000 NA
#> SRR1179111     2  0.0405      0.976 0.000 0.988 0.004 0.000 0.000 NA
#> SRR1179112     1  0.2294      0.767 0.892 0.000 0.000 0.072 0.036 NA
#> SRR1179113     1  0.2058      0.776 0.908 0.000 0.000 0.056 0.036 NA
#> SRR1179114     1  0.2058      0.776 0.908 0.000 0.000 0.056 0.036 NA
#> SRR1179115     1  0.2119      0.774 0.904 0.000 0.000 0.060 0.036 NA
#> SRR1179116     1  0.2058      0.776 0.908 0.000 0.000 0.056 0.036 NA
#> SRR1179117     1  0.2058      0.776 0.908 0.000 0.000 0.056 0.036 NA
#> SRR1179118     1  0.2058      0.776 0.908 0.000 0.000 0.056 0.036 NA
#> SRR1179119     1  0.2058      0.776 0.908 0.000 0.000 0.056 0.036 NA
#> SRR1179120     4  0.3915      0.995 0.412 0.000 0.000 0.584 0.004 NA
#> SRR1179121     4  0.3782      0.995 0.412 0.000 0.000 0.588 0.000 NA
#> SRR1179122     4  0.3782      0.995 0.412 0.000 0.000 0.588 0.000 NA
#> SRR1179123     4  0.3915      0.995 0.412 0.000 0.000 0.584 0.004 NA
#> SRR1179124     4  0.3782      0.995 0.412 0.000 0.000 0.588 0.000 NA
#> SRR1179125     4  0.3915      0.995 0.412 0.000 0.000 0.584 0.004 NA
#> SRR1179126     4  0.3789      0.990 0.416 0.000 0.000 0.584 0.000 NA
#> SRR1179127     1  0.3881      0.302 0.720 0.000 0.000 0.252 0.024 NA
#> SRR1179128     1  0.2405      0.710 0.880 0.000 0.000 0.100 0.016 NA
#> SRR1179129     1  0.3650      0.444 0.756 0.000 0.000 0.216 0.024 NA
#> SRR1179130     1  0.2393      0.725 0.884 0.000 0.000 0.092 0.020 NA
#> SRR1179131     1  0.3678      0.422 0.752 0.000 0.000 0.220 0.024 NA
#> SRR1179132     1  0.2356      0.720 0.884 0.000 0.000 0.096 0.016 NA
#> SRR1179134     1  0.2182      0.739 0.900 0.000 0.000 0.076 0.020 NA
#> SRR1179135     1  0.1866      0.772 0.908 0.000 0.000 0.008 0.084 NA
#> SRR1179136     1  0.1075      0.786 0.952 0.000 0.000 0.000 0.048 NA
#> SRR1179137     1  0.1588      0.774 0.924 0.000 0.000 0.004 0.072 NA
#> SRR1179138     1  0.1700      0.772 0.916 0.000 0.000 0.004 0.080 NA
#> SRR1179139     1  0.1411      0.782 0.936 0.000 0.000 0.004 0.060 NA
#> SRR1179140     1  0.1806      0.767 0.908 0.000 0.000 0.004 0.088 NA
#> SRR1179141     1  0.1411      0.782 0.936 0.000 0.000 0.004 0.060 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-NMF-collect-classes

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

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

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2     1           1.000       1.000         0.5084 0.492   0.492
#> 3 3     1           0.983       0.999         0.0337 0.983   0.966
#> 4 4     1           0.983       0.999         0.1652 0.913   0.817
#> 5 5     1           0.983       1.000         0.1031 0.937   0.837
#> 6 6     1           0.973       0.971         0.1764 0.873   0.609

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1179081     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179082     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179083     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179084     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179085     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179086     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179087     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179088     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179089     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179090     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179091     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179092     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179093     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179094     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179095     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179096     2  0.0237      0.000 0.000 0.996 0.004
#> SRR1179097     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179098     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179099     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179100     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179101     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179102     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179103     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179104     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179105     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179106     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179107     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179108     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179109     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179110     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179111     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1179112     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179113     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179114     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179115     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179116     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179117     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179118     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179119     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179120     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1179121     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1179122     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1179123     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1179124     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1179125     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1179126     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1179127     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179128     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179129     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179130     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179131     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179132     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179134     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179135     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179136     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179137     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179138     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179139     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179140     1  0.0000      0.999 1.000 0.000 0.000
#> SRR1179141     1  0.0000      0.999 1.000 0.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
#> SRR1179081     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179082     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179083     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179084     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179085     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179086     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179087     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179088     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179089     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179090     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179091     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179092     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179093     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179094     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179095     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179096     2  0.0000      0.000 0.000  1  0 0.000
#> SRR1179097     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179098     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179099     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179100     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179101     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179102     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179103     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179104     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179105     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179106     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179107     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179108     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179109     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179110     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179111     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179112     1  0.0188      0.997 0.996  0  0 0.004
#> SRR1179113     1  0.0188      0.997 0.996  0  0 0.004
#> SRR1179114     1  0.0188      0.997 0.996  0  0 0.004
#> SRR1179115     1  0.0188      0.997 0.996  0  0 0.004
#> SRR1179116     1  0.0188      0.997 0.996  0  0 0.004
#> SRR1179117     1  0.0188      0.997 0.996  0  0 0.004
#> SRR1179118     1  0.0188      0.997 0.996  0  0 0.004
#> SRR1179119     1  0.0188      0.997 0.996  0  0 0.004
#> SRR1179120     4  0.0000      1.000 0.000  0  0 1.000
#> SRR1179121     4  0.0000      1.000 0.000  0  0 1.000
#> SRR1179122     4  0.0000      1.000 0.000  0  0 1.000
#> SRR1179123     4  0.0000      1.000 0.000  0  0 1.000
#> SRR1179124     4  0.0000      1.000 0.000  0  0 1.000
#> SRR1179125     4  0.0000      1.000 0.000  0  0 1.000
#> SRR1179126     4  0.0000      1.000 0.000  0  0 1.000
#> SRR1179127     1  0.0000      0.998 1.000  0  0 0.000
#> SRR1179128     1  0.0000      0.998 1.000  0  0 0.000
#> SRR1179129     1  0.0000      0.998 1.000  0  0 0.000
#> SRR1179130     1  0.0000      0.998 1.000  0  0 0.000
#> SRR1179131     1  0.0000      0.998 1.000  0  0 0.000
#> SRR1179132     1  0.0000      0.998 1.000  0  0 0.000
#> SRR1179134     1  0.0000      0.998 1.000  0  0 0.000
#> SRR1179135     1  0.0000      0.998 1.000  0  0 0.000
#> SRR1179136     1  0.0000      0.998 1.000  0  0 0.000
#> SRR1179137     1  0.0000      0.998 1.000  0  0 0.000
#> SRR1179138     1  0.0000      0.998 1.000  0  0 0.000
#> SRR1179139     1  0.0000      0.998 1.000  0  0 0.000
#> SRR1179140     1  0.0000      0.998 1.000  0  0 0.000
#> SRR1179141     1  0.0000      0.998 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
#> SRR1179081     3       0          1  0  0  1  0  0
#> SRR1179082     3       0          1  0  0  1  0  0
#> SRR1179083     3       0          1  0  0  1  0  0
#> SRR1179084     3       0          1  0  0  1  0  0
#> SRR1179085     3       0          1  0  0  1  0  0
#> SRR1179086     3       0          1  0  0  1  0  0
#> SRR1179087     3       0          1  0  0  1  0  0
#> SRR1179088     3       0          1  0  0  1  0  0
#> SRR1179089     3       0          1  0  0  1  0  0
#> SRR1179090     3       0          1  0  0  1  0  0
#> SRR1179091     3       0          1  0  0  1  0  0
#> SRR1179092     3       0          1  0  0  1  0  0
#> SRR1179093     3       0          1  0  0  1  0  0
#> SRR1179094     3       0          1  0  0  1  0  0
#> SRR1179095     3       0          1  0  0  1  0  0
#> SRR1179096     2       0          0  0  1  0  0  0
#> SRR1179097     3       0          1  0  0  1  0  0
#> SRR1179098     3       0          1  0  0  1  0  0
#> SRR1179099     3       0          1  0  0  1  0  0
#> SRR1179100     3       0          1  0  0  1  0  0
#> SRR1179101     3       0          1  0  0  1  0  0
#> SRR1179102     3       0          1  0  0  1  0  0
#> SRR1179103     3       0          1  0  0  1  0  0
#> SRR1179104     3       0          1  0  0  1  0  0
#> SRR1179105     3       0          1  0  0  1  0  0
#> SRR1179106     3       0          1  0  0  1  0  0
#> SRR1179107     3       0          1  0  0  1  0  0
#> SRR1179108     3       0          1  0  0  1  0  0
#> SRR1179109     3       0          1  0  0  1  0  0
#> SRR1179110     3       0          1  0  0  1  0  0
#> SRR1179111     3       0          1  0  0  1  0  0
#> SRR1179112     5       0          1  0  0  0  0  1
#> SRR1179113     5       0          1  0  0  0  0  1
#> SRR1179114     5       0          1  0  0  0  0  1
#> SRR1179115     5       0          1  0  0  0  0  1
#> SRR1179116     5       0          1  0  0  0  0  1
#> SRR1179117     5       0          1  0  0  0  0  1
#> SRR1179118     5       0          1  0  0  0  0  1
#> SRR1179119     5       0          1  0  0  0  0  1
#> SRR1179120     4       0          1  0  0  0  1  0
#> SRR1179121     4       0          1  0  0  0  1  0
#> SRR1179122     4       0          1  0  0  0  1  0
#> SRR1179123     4       0          1  0  0  0  1  0
#> SRR1179124     4       0          1  0  0  0  1  0
#> SRR1179125     4       0          1  0  0  0  1  0
#> SRR1179126     4       0          1  0  0  0  1  0
#> SRR1179127     1       0          1  1  0  0  0  0
#> SRR1179128     1       0          1  1  0  0  0  0
#> SRR1179129     1       0          1  1  0  0  0  0
#> SRR1179130     1       0          1  1  0  0  0  0
#> SRR1179131     1       0          1  1  0  0  0  0
#> SRR1179132     1       0          1  1  0  0  0  0
#> SRR1179134     1       0          1  1  0  0  0  0
#> SRR1179135     1       0          1  1  0  0  0  0
#> SRR1179136     1       0          1  1  0  0  0  0
#> SRR1179137     1       0          1  1  0  0  0  0
#> SRR1179138     1       0          1  1  0  0  0  0
#> SRR1179139     1       0          1  1  0  0  0  0
#> SRR1179140     1       0          1  1  0  0  0  0
#> SRR1179141     1       0          1  1  0  0  0  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
#> SRR1179081     3   0.156      1.000  0 0.08 0.92  0 0.00  0
#> SRR1179082     3   0.156      1.000  0 0.08 0.92  0 0.00  0
#> SRR1179083     3   0.156      1.000  0 0.08 0.92  0 0.00  0
#> SRR1179084     3   0.156      1.000  0 0.08 0.92  0 0.00  0
#> SRR1179085     3   0.156      1.000  0 0.08 0.92  0 0.00  0
#> SRR1179086     3   0.156      1.000  0 0.08 0.92  0 0.00  0
#> SRR1179087     3   0.156      1.000  0 0.08 0.92  0 0.00  0
#> SRR1179088     3   0.156      1.000  0 0.08 0.92  0 0.00  0
#> SRR1179089     3   0.156      1.000  0 0.08 0.92  0 0.00  0
#> SRR1179090     3   0.156      1.000  0 0.08 0.92  0 0.00  0
#> SRR1179091     3   0.156      1.000  0 0.08 0.92  0 0.00  0
#> SRR1179092     3   0.156      1.000  0 0.08 0.92  0 0.00  0
#> SRR1179093     3   0.156      1.000  0 0.08 0.92  0 0.00  0
#> SRR1179094     3   0.156      1.000  0 0.08 0.92  0 0.00  0
#> SRR1179095     3   0.156      1.000  0 0.08 0.92  0 0.00  0
#> SRR1179096     6   0.000      0.000  0 0.00 0.00  0 0.00  1
#> SRR1179097     2   0.000      1.000  0 1.00 0.00  0 0.00  0
#> SRR1179098     2   0.000      1.000  0 1.00 0.00  0 0.00  0
#> SRR1179099     2   0.000      1.000  0 1.00 0.00  0 0.00  0
#> SRR1179100     2   0.000      1.000  0 1.00 0.00  0 0.00  0
#> SRR1179101     2   0.000      1.000  0 1.00 0.00  0 0.00  0
#> SRR1179102     2   0.000      1.000  0 1.00 0.00  0 0.00  0
#> SRR1179103     2   0.000      1.000  0 1.00 0.00  0 0.00  0
#> SRR1179104     2   0.000      1.000  0 1.00 0.00  0 0.00  0
#> SRR1179105     2   0.000      1.000  0 1.00 0.00  0 0.00  0
#> SRR1179106     2   0.000      1.000  0 1.00 0.00  0 0.00  0
#> SRR1179107     2   0.000      1.000  0 1.00 0.00  0 0.00  0
#> SRR1179108     2   0.000      1.000  0 1.00 0.00  0 0.00  0
#> SRR1179109     2   0.000      1.000  0 1.00 0.00  0 0.00  0
#> SRR1179110     2   0.000      1.000  0 1.00 0.00  0 0.00  0
#> SRR1179111     2   0.000      1.000  0 1.00 0.00  0 0.00  0
#> SRR1179112     1   0.000      1.000  1 0.00 0.00  0 0.00  0
#> SRR1179113     1   0.000      1.000  1 0.00 0.00  0 0.00  0
#> SRR1179114     1   0.000      1.000  1 0.00 0.00  0 0.00  0
#> SRR1179115     1   0.000      1.000  1 0.00 0.00  0 0.00  0
#> SRR1179116     1   0.000      1.000  1 0.00 0.00  0 0.00  0
#> SRR1179117     1   0.000      1.000  1 0.00 0.00  0 0.00  0
#> SRR1179118     1   0.000      1.000  1 0.00 0.00  0 0.00  0
#> SRR1179119     1   0.000      1.000  1 0.00 0.00  0 0.00  0
#> SRR1179120     4   0.000      1.000  0 0.00 0.00  1 0.00  0
#> SRR1179121     4   0.000      1.000  0 0.00 0.00  1 0.00  0
#> SRR1179122     4   0.000      1.000  0 0.00 0.00  1 0.00  0
#> SRR1179123     4   0.000      1.000  0 0.00 0.00  1 0.00  0
#> SRR1179124     4   0.000      1.000  0 0.00 0.00  1 0.00  0
#> SRR1179125     4   0.000      1.000  0 0.00 0.00  1 0.00  0
#> SRR1179126     4   0.000      1.000  0 0.00 0.00  1 0.00  0
#> SRR1179127     5   0.000      0.957  0 0.00 0.00  0 1.00  0
#> SRR1179128     5   0.000      0.957  0 0.00 0.00  0 1.00  0
#> SRR1179129     5   0.000      0.957  0 0.00 0.00  0 1.00  0
#> SRR1179130     5   0.000      0.957  0 0.00 0.00  0 1.00  0
#> SRR1179131     5   0.000      0.957  0 0.00 0.00  0 1.00  0
#> SRR1179132     5   0.000      0.957  0 0.00 0.00  0 1.00  0
#> SRR1179134     5   0.000      0.957  0 0.00 0.00  0 1.00  0
#> SRR1179135     5   0.156      0.957  0 0.00 0.08  0 0.92  0
#> SRR1179136     5   0.156      0.957  0 0.00 0.08  0 0.92  0
#> SRR1179137     5   0.156      0.957  0 0.00 0.08  0 0.92  0
#> SRR1179138     5   0.156      0.957  0 0.00 0.08  0 0.92  0
#> SRR1179139     5   0.156      0.957  0 0.00 0.08  0 0.92  0
#> SRR1179140     5   0.156      0.957  0 0.00 0.08  0 0.92  0
#> SRR1179141     5   0.156      0.957  0 0.00 0.08  0 0.92  0

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

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

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

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 0.718           0.923       0.794         0.2304 0.864   0.724
#> 4 4 0.654           0.813       0.806         0.1073 0.913   0.756
#> 5 5 0.631           0.738       0.691         0.0647 0.925   0.731
#> 6 6 0.735           0.688       0.739         0.0514 0.917   0.701

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
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1179081     3   0.631      1.000 0.000 0.492 0.508
#> SRR1179082     3   0.631      1.000 0.000 0.492 0.508
#> SRR1179083     3   0.631      1.000 0.000 0.492 0.508
#> SRR1179084     3   0.631      1.000 0.000 0.492 0.508
#> SRR1179085     3   0.631      1.000 0.000 0.492 0.508
#> SRR1179086     3   0.631      1.000 0.000 0.492 0.508
#> SRR1179087     3   0.631      1.000 0.000 0.492 0.508
#> SRR1179088     3   0.631      1.000 0.000 0.492 0.508
#> SRR1179089     3   0.631      1.000 0.000 0.492 0.508
#> SRR1179090     3   0.631      1.000 0.000 0.492 0.508
#> SRR1179091     3   0.631      1.000 0.000 0.492 0.508
#> SRR1179092     3   0.631      1.000 0.000 0.492 0.508
#> SRR1179093     3   0.631      1.000 0.000 0.492 0.508
#> SRR1179094     3   0.631      1.000 0.000 0.492 0.508
#> SRR1179095     3   0.631      1.000 0.000 0.492 0.508
#> SRR1179096     2   0.141      0.929 0.000 0.964 0.036
#> SRR1179097     2   0.000      0.995 0.000 1.000 0.000
#> SRR1179098     2   0.000      0.995 0.000 1.000 0.000
#> SRR1179099     2   0.000      0.995 0.000 1.000 0.000
#> SRR1179100     2   0.000      0.995 0.000 1.000 0.000
#> SRR1179101     2   0.000      0.995 0.000 1.000 0.000
#> SRR1179102     2   0.000      0.995 0.000 1.000 0.000
#> SRR1179103     2   0.000      0.995 0.000 1.000 0.000
#> SRR1179104     2   0.000      0.995 0.000 1.000 0.000
#> SRR1179105     2   0.000      0.995 0.000 1.000 0.000
#> SRR1179106     2   0.000      0.995 0.000 1.000 0.000
#> SRR1179107     2   0.000      0.995 0.000 1.000 0.000
#> SRR1179108     2   0.000      0.995 0.000 1.000 0.000
#> SRR1179109     2   0.000      0.995 0.000 1.000 0.000
#> SRR1179110     2   0.000      0.995 0.000 1.000 0.000
#> SRR1179111     2   0.000      0.995 0.000 1.000 0.000
#> SRR1179112     1   0.280      0.864 0.908 0.000 0.092
#> SRR1179113     1   0.280      0.864 0.908 0.000 0.092
#> SRR1179114     1   0.280      0.864 0.908 0.000 0.092
#> SRR1179115     1   0.280      0.864 0.908 0.000 0.092
#> SRR1179116     1   0.280      0.864 0.908 0.000 0.092
#> SRR1179117     1   0.280      0.864 0.908 0.000 0.092
#> SRR1179118     1   0.280      0.864 0.908 0.000 0.092
#> SRR1179119     1   0.280      0.864 0.908 0.000 0.092
#> SRR1179120     1   0.621      0.790 0.572 0.000 0.428
#> SRR1179121     1   0.621      0.790 0.572 0.000 0.428
#> SRR1179122     1   0.621      0.790 0.572 0.000 0.428
#> SRR1179123     1   0.621      0.790 0.572 0.000 0.428
#> SRR1179124     1   0.621      0.790 0.572 0.000 0.428
#> SRR1179125     1   0.621      0.790 0.572 0.000 0.428
#> SRR1179126     1   0.621      0.790 0.572 0.000 0.428
#> SRR1179127     1   0.440      0.859 0.812 0.000 0.188
#> SRR1179128     1   0.440      0.859 0.812 0.000 0.188
#> SRR1179129     1   0.440      0.859 0.812 0.000 0.188
#> SRR1179130     1   0.440      0.859 0.812 0.000 0.188
#> SRR1179131     1   0.440      0.859 0.812 0.000 0.188
#> SRR1179132     1   0.440      0.859 0.812 0.000 0.188
#> SRR1179134     1   0.440      0.859 0.812 0.000 0.188
#> SRR1179135     1   0.000      0.867 1.000 0.000 0.000
#> SRR1179136     1   0.000      0.867 1.000 0.000 0.000
#> SRR1179137     1   0.000      0.867 1.000 0.000 0.000
#> SRR1179138     1   0.000      0.867 1.000 0.000 0.000
#> SRR1179139     1   0.000      0.867 1.000 0.000 0.000
#> SRR1179140     1   0.000      0.867 1.000 0.000 0.000
#> SRR1179141     1   0.000      0.867 1.000 0.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
#> SRR1179081     3  0.1557      0.942 0.000 0.000 0.944 0.056
#> SRR1179082     3  0.1474      0.949 0.000 0.000 0.948 0.052
#> SRR1179083     3  0.1474      0.949 0.000 0.000 0.948 0.052
#> SRR1179084     3  0.1474      0.949 0.000 0.000 0.948 0.052
#> SRR1179085     3  0.1474      0.949 0.000 0.000 0.948 0.052
#> SRR1179086     3  0.1474      0.949 0.000 0.000 0.948 0.052
#> SRR1179087     3  0.1474      0.949 0.000 0.000 0.948 0.052
#> SRR1179088     3  0.1474      0.949 0.000 0.000 0.948 0.052
#> SRR1179089     3  0.1557      0.942 0.000 0.000 0.944 0.056
#> SRR1179090     3  0.0336      0.949 0.000 0.000 0.992 0.008
#> SRR1179091     3  0.1557      0.942 0.000 0.000 0.944 0.056
#> SRR1179092     3  0.1557      0.942 0.000 0.000 0.944 0.056
#> SRR1179093     3  0.1557      0.942 0.000 0.000 0.944 0.056
#> SRR1179094     3  0.1557      0.942 0.000 0.000 0.944 0.056
#> SRR1179095     3  0.0000      0.950 0.000 0.000 1.000 0.000
#> SRR1179096     2  0.7252      0.714 0.000 0.544 0.228 0.228
#> SRR1179097     2  0.4606      0.970 0.000 0.724 0.264 0.012
#> SRR1179098     2  0.4606      0.970 0.000 0.724 0.264 0.012
#> SRR1179099     2  0.4606      0.970 0.000 0.724 0.264 0.012
#> SRR1179100     2  0.4606      0.970 0.000 0.724 0.264 0.012
#> SRR1179101     2  0.4606      0.970 0.000 0.724 0.264 0.012
#> SRR1179102     2  0.4606      0.970 0.000 0.724 0.264 0.012
#> SRR1179103     2  0.4606      0.970 0.000 0.724 0.264 0.012
#> SRR1179104     2  0.5022      0.959 0.000 0.708 0.264 0.028
#> SRR1179105     2  0.4164      0.969 0.000 0.736 0.264 0.000
#> SRR1179106     2  0.5022      0.959 0.000 0.708 0.264 0.028
#> SRR1179107     2  0.4164      0.969 0.000 0.736 0.264 0.000
#> SRR1179108     2  0.5022      0.959 0.000 0.708 0.264 0.028
#> SRR1179109     2  0.4164      0.969 0.000 0.736 0.264 0.000
#> SRR1179110     2  0.5022      0.959 0.000 0.708 0.264 0.028
#> SRR1179111     2  0.4164      0.969 0.000 0.736 0.264 0.000
#> SRR1179112     1  0.4565      0.642 0.796 0.140 0.000 0.064
#> SRR1179113     1  0.4514      0.644 0.800 0.136 0.000 0.064
#> SRR1179114     1  0.4514      0.644 0.800 0.136 0.000 0.064
#> SRR1179115     1  0.4514      0.644 0.800 0.136 0.000 0.064
#> SRR1179116     1  0.4514      0.644 0.800 0.136 0.000 0.064
#> SRR1179117     1  0.4514      0.644 0.800 0.136 0.000 0.064
#> SRR1179118     1  0.4514      0.644 0.800 0.136 0.000 0.064
#> SRR1179119     1  0.4514      0.644 0.800 0.136 0.000 0.064
#> SRR1179120     4  0.4730      0.997 0.364 0.000 0.000 0.636
#> SRR1179121     4  0.4730      0.997 0.364 0.000 0.000 0.636
#> SRR1179122     4  0.4730      0.997 0.364 0.000 0.000 0.636
#> SRR1179123     4  0.4730      0.997 0.364 0.000 0.000 0.636
#> SRR1179124     4  0.4730      0.997 0.364 0.000 0.000 0.636
#> SRR1179125     4  0.4730      0.997 0.364 0.000 0.000 0.636
#> SRR1179126     4  0.5269      0.982 0.364 0.016 0.000 0.620
#> SRR1179127     1  0.5431      0.349 0.712 0.064 0.000 0.224
#> SRR1179128     1  0.5431      0.349 0.712 0.064 0.000 0.224
#> SRR1179129     1  0.5431      0.349 0.712 0.064 0.000 0.224
#> SRR1179130     1  0.5431      0.349 0.712 0.064 0.000 0.224
#> SRR1179131     1  0.5431      0.349 0.712 0.064 0.000 0.224
#> SRR1179132     1  0.5431      0.349 0.712 0.064 0.000 0.224
#> SRR1179134     1  0.5431      0.349 0.712 0.064 0.000 0.224
#> SRR1179135     1  0.0469      0.685 0.988 0.012 0.000 0.000
#> SRR1179136     1  0.0469      0.685 0.988 0.012 0.000 0.000
#> SRR1179137     1  0.0469      0.685 0.988 0.012 0.000 0.000
#> SRR1179138     1  0.0469      0.685 0.988 0.012 0.000 0.000
#> SRR1179139     1  0.0469      0.685 0.988 0.012 0.000 0.000
#> SRR1179140     1  0.0469      0.685 0.988 0.012 0.000 0.000
#> SRR1179141     1  0.0469      0.685 0.988 0.012 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
#> SRR1179081     3  0.3864     0.8775 0.000 0.188 0.784 0.008 0.020
#> SRR1179082     3  0.6394     0.8837 0.000 0.188 0.596 0.192 0.024
#> SRR1179083     3  0.6394     0.8837 0.000 0.188 0.596 0.192 0.024
#> SRR1179084     3  0.6394     0.8837 0.000 0.188 0.596 0.192 0.024
#> SRR1179085     3  0.6394     0.8837 0.000 0.188 0.596 0.192 0.024
#> SRR1179086     3  0.6394     0.8837 0.000 0.188 0.596 0.192 0.024
#> SRR1179087     3  0.6394     0.8837 0.000 0.188 0.596 0.192 0.024
#> SRR1179088     3  0.6394     0.8837 0.000 0.188 0.596 0.192 0.024
#> SRR1179089     3  0.3586     0.8814 0.000 0.188 0.792 0.000 0.020
#> SRR1179090     3  0.3919     0.8887 0.000 0.188 0.776 0.036 0.000
#> SRR1179091     3  0.3586     0.8814 0.000 0.188 0.792 0.000 0.020
#> SRR1179092     3  0.3586     0.8814 0.000 0.188 0.792 0.000 0.020
#> SRR1179093     3  0.3586     0.8814 0.000 0.188 0.792 0.000 0.020
#> SRR1179094     3  0.3586     0.8814 0.000 0.188 0.792 0.000 0.020
#> SRR1179095     3  0.4479     0.8900 0.000 0.188 0.752 0.052 0.008
#> SRR1179096     2  0.6439     0.5461 0.000 0.568 0.024 0.136 0.272
#> SRR1179097     2  0.1557     0.9284 0.000 0.940 0.000 0.052 0.008
#> SRR1179098     2  0.1557     0.9284 0.000 0.940 0.000 0.052 0.008
#> SRR1179099     2  0.1557     0.9284 0.000 0.940 0.000 0.052 0.008
#> SRR1179100     2  0.1557     0.9284 0.000 0.940 0.000 0.052 0.008
#> SRR1179101     2  0.1557     0.9284 0.000 0.940 0.000 0.052 0.008
#> SRR1179102     2  0.1557     0.9284 0.000 0.940 0.000 0.052 0.008
#> SRR1179103     2  0.1557     0.9284 0.000 0.940 0.000 0.052 0.008
#> SRR1179104     2  0.1914     0.9022 0.000 0.924 0.000 0.060 0.016
#> SRR1179105     2  0.0000     0.9278 0.000 1.000 0.000 0.000 0.000
#> SRR1179106     2  0.1914     0.9022 0.000 0.924 0.000 0.060 0.016
#> SRR1179107     2  0.0000     0.9278 0.000 1.000 0.000 0.000 0.000
#> SRR1179108     2  0.1914     0.9022 0.000 0.924 0.000 0.060 0.016
#> SRR1179109     2  0.0000     0.9278 0.000 1.000 0.000 0.000 0.000
#> SRR1179110     2  0.1914     0.9022 0.000 0.924 0.000 0.060 0.016
#> SRR1179111     2  0.0000     0.9278 0.000 1.000 0.000 0.000 0.000
#> SRR1179112     5  0.5100     0.9648 0.372 0.000 0.012 0.024 0.592
#> SRR1179113     5  0.4470     0.9951 0.372 0.000 0.000 0.012 0.616
#> SRR1179114     5  0.4470     0.9951 0.372 0.000 0.000 0.012 0.616
#> SRR1179115     5  0.4470     0.9951 0.372 0.000 0.000 0.012 0.616
#> SRR1179116     5  0.4470     0.9951 0.372 0.000 0.000 0.012 0.616
#> SRR1179117     5  0.4470     0.9951 0.372 0.000 0.000 0.012 0.616
#> SRR1179118     5  0.4470     0.9951 0.372 0.000 0.000 0.012 0.616
#> SRR1179119     5  0.4470     0.9951 0.372 0.000 0.000 0.012 0.616
#> SRR1179120     4  0.5168     0.9965 0.452 0.000 0.000 0.508 0.040
#> SRR1179121     4  0.5168     0.9965 0.452 0.000 0.000 0.508 0.040
#> SRR1179122     4  0.5289     0.9954 0.452 0.000 0.000 0.500 0.048
#> SRR1179123     4  0.5230     0.9965 0.452 0.000 0.000 0.504 0.044
#> SRR1179124     4  0.5230     0.9954 0.452 0.000 0.000 0.504 0.044
#> SRR1179125     4  0.5230     0.9965 0.452 0.000 0.000 0.504 0.044
#> SRR1179126     1  0.6578    -0.9202 0.452 0.000 0.052 0.428 0.068
#> SRR1179127     1  0.0609     0.4551 0.980 0.000 0.020 0.000 0.000
#> SRR1179128     1  0.0000     0.4568 1.000 0.000 0.000 0.000 0.000
#> SRR1179129     1  0.0609     0.4551 0.980 0.000 0.020 0.000 0.000
#> SRR1179130     1  0.0000     0.4568 1.000 0.000 0.000 0.000 0.000
#> SRR1179131     1  0.0609     0.4551 0.980 0.000 0.020 0.000 0.000
#> SRR1179132     1  0.0000     0.4568 1.000 0.000 0.000 0.000 0.000
#> SRR1179134     1  0.0000     0.4568 1.000 0.000 0.000 0.000 0.000
#> SRR1179135     1  0.6685     0.0681 0.524 0.000 0.080 0.060 0.336
#> SRR1179136     1  0.6685     0.0681 0.524 0.000 0.080 0.060 0.336
#> SRR1179137     1  0.6685     0.0681 0.524 0.000 0.080 0.060 0.336
#> SRR1179138     1  0.6685     0.0681 0.524 0.000 0.080 0.060 0.336
#> SRR1179139     1  0.6685     0.0681 0.524 0.000 0.080 0.060 0.336
#> SRR1179140     1  0.6685     0.0681 0.524 0.000 0.080 0.060 0.336
#> SRR1179141     1  0.6685     0.0681 0.524 0.000 0.080 0.060 0.336

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4 p5    p6
#> SRR1179081     3  0.4529      0.788 0.000 0.096 0.776 0.068 NA 0.020
#> SRR1179082     3  0.5435      0.804 0.000 0.096 0.652 0.000 NA 0.048
#> SRR1179083     3  0.5435      0.804 0.000 0.096 0.652 0.000 NA 0.048
#> SRR1179084     3  0.5435      0.804 0.000 0.096 0.652 0.000 NA 0.048
#> SRR1179085     3  0.5545      0.804 0.000 0.096 0.652 0.004 NA 0.048
#> SRR1179086     3  0.5435      0.804 0.000 0.096 0.652 0.000 NA 0.048
#> SRR1179087     3  0.5545      0.804 0.000 0.096 0.652 0.004 NA 0.048
#> SRR1179088     3  0.5435      0.804 0.000 0.096 0.652 0.000 NA 0.048
#> SRR1179089     3  0.3750      0.799 0.000 0.096 0.824 0.024 NA 0.020
#> SRR1179090     3  0.2051      0.813 0.000 0.096 0.896 0.004 NA 0.004
#> SRR1179091     3  0.3750      0.799 0.000 0.096 0.824 0.024 NA 0.020
#> SRR1179092     3  0.3750      0.799 0.000 0.096 0.824 0.020 NA 0.024
#> SRR1179093     3  0.3831      0.799 0.000 0.096 0.820 0.024 NA 0.024
#> SRR1179094     3  0.3750      0.799 0.000 0.096 0.824 0.024 NA 0.020
#> SRR1179095     3  0.2518      0.814 0.000 0.096 0.880 0.004 NA 0.008
#> SRR1179096     6  0.3862      0.000 0.000 0.388 0.004 0.000 NA 0.608
#> SRR1179097     2  0.2858      0.813 0.000 0.864 0.000 0.028 NA 0.016
#> SRR1179098     2  0.2829      0.813 0.000 0.864 0.000 0.024 NA 0.016
#> SRR1179099     2  0.2829      0.813 0.000 0.864 0.000 0.024 NA 0.016
#> SRR1179100     2  0.2858      0.813 0.000 0.864 0.000 0.028 NA 0.016
#> SRR1179101     2  0.2829      0.813 0.000 0.864 0.000 0.024 NA 0.016
#> SRR1179102     2  0.2858      0.813 0.000 0.864 0.000 0.028 NA 0.016
#> SRR1179103     2  0.2829      0.813 0.000 0.864 0.000 0.024 NA 0.016
#> SRR1179104     2  0.2456      0.729 0.000 0.892 0.000 0.008 NA 0.048
#> SRR1179105     2  0.0363      0.811 0.000 0.988 0.000 0.012 NA 0.000
#> SRR1179106     2  0.2456      0.729 0.000 0.892 0.000 0.008 NA 0.048
#> SRR1179107     2  0.0363      0.811 0.000 0.988 0.000 0.012 NA 0.000
#> SRR1179108     2  0.2456      0.729 0.000 0.892 0.000 0.008 NA 0.048
#> SRR1179109     2  0.0508      0.809 0.000 0.984 0.000 0.012 NA 0.000
#> SRR1179110     2  0.2456      0.729 0.000 0.892 0.000 0.008 NA 0.048
#> SRR1179111     2  0.0363      0.811 0.000 0.988 0.000 0.012 NA 0.000
#> SRR1179112     1  0.2282      0.563 0.904 0.000 0.036 0.004 NA 0.052
#> SRR1179113     1  0.0405      0.575 0.988 0.000 0.008 0.004 NA 0.000
#> SRR1179114     1  0.0146      0.575 0.996 0.000 0.000 0.004 NA 0.000
#> SRR1179115     1  0.0405      0.575 0.988 0.000 0.008 0.004 NA 0.000
#> SRR1179116     1  0.0146      0.575 0.996 0.000 0.000 0.004 NA 0.000
#> SRR1179117     1  0.0146      0.575 0.996 0.000 0.000 0.004 NA 0.000
#> SRR1179118     1  0.0146      0.575 0.996 0.000 0.000 0.004 NA 0.000
#> SRR1179119     1  0.0291      0.575 0.992 0.000 0.004 0.004 NA 0.000
#> SRR1179120     4  0.2048      0.980 0.120 0.000 0.000 0.880 NA 0.000
#> SRR1179121     4  0.2048      0.980 0.120 0.000 0.000 0.880 NA 0.000
#> SRR1179122     4  0.2445      0.977 0.120 0.000 0.008 0.868 NA 0.000
#> SRR1179123     4  0.2048      0.980 0.120 0.000 0.000 0.880 NA 0.000
#> SRR1179124     4  0.2445      0.977 0.120 0.000 0.008 0.868 NA 0.000
#> SRR1179125     4  0.2048      0.980 0.120 0.000 0.000 0.880 NA 0.000
#> SRR1179126     4  0.4688      0.892 0.120 0.000 0.012 0.752 NA 0.084
#> SRR1179127     1  0.7692      0.265 0.312 0.000 0.004 0.272 NA 0.156
#> SRR1179128     1  0.7535      0.274 0.316 0.000 0.000 0.268 NA 0.144
#> SRR1179129     1  0.7692      0.265 0.312 0.000 0.004 0.272 NA 0.156
#> SRR1179130     1  0.7535      0.274 0.316 0.000 0.000 0.268 NA 0.144
#> SRR1179131     1  0.7692      0.265 0.312 0.000 0.004 0.272 NA 0.156
#> SRR1179132     1  0.7535      0.274 0.316 0.000 0.000 0.268 NA 0.144
#> SRR1179134     1  0.7535      0.274 0.316 0.000 0.000 0.268 NA 0.144
#> SRR1179135     1  0.3950      0.596 0.564 0.000 0.000 0.004 NA 0.000
#> SRR1179136     1  0.4076      0.596 0.564 0.000 0.000 0.004 NA 0.004
#> SRR1179137     1  0.3950      0.596 0.564 0.000 0.000 0.004 NA 0.000
#> SRR1179138     1  0.3950      0.596 0.564 0.000 0.000 0.004 NA 0.000
#> SRR1179139     1  0.4076      0.596 0.564 0.000 0.000 0.004 NA 0.004
#> SRR1179140     1  0.3950      0.596 0.564 0.000 0.000 0.004 NA 0.000
#> SRR1179141     1  0.4592      0.594 0.564 0.000 0.024 0.004 NA 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-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 14036 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 1.000           0.995       0.987         0.2631 0.864   0.724
#> 4 4 0.945           0.972       0.975         0.1388 0.913   0.756
#> 5 5 0.939           0.967       0.917         0.0520 0.941   0.780
#> 6 6 0.917           0.931       0.945         0.0408 0.992   0.960

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1179081     3   0.000      1.000 0.000 0.000 1.000
#> SRR1179082     3   0.000      1.000 0.000 0.000 1.000
#> SRR1179083     3   0.000      1.000 0.000 0.000 1.000
#> SRR1179084     3   0.000      1.000 0.000 0.000 1.000
#> SRR1179085     3   0.000      1.000 0.000 0.000 1.000
#> SRR1179086     3   0.000      1.000 0.000 0.000 1.000
#> SRR1179087     3   0.000      1.000 0.000 0.000 1.000
#> SRR1179088     3   0.000      1.000 0.000 0.000 1.000
#> SRR1179089     3   0.000      1.000 0.000 0.000 1.000
#> SRR1179090     3   0.000      1.000 0.000 0.000 1.000
#> SRR1179091     3   0.000      1.000 0.000 0.000 1.000
#> SRR1179092     3   0.000      1.000 0.000 0.000 1.000
#> SRR1179093     3   0.000      1.000 0.000 0.000 1.000
#> SRR1179094     3   0.000      1.000 0.000 0.000 1.000
#> SRR1179095     3   0.000      1.000 0.000 0.000 1.000
#> SRR1179096     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179097     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179098     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179099     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179100     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179101     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179102     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179103     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179104     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179105     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179106     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179107     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179108     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179109     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179110     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179111     2   0.141      1.000 0.000 0.964 0.036
#> SRR1179112     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179113     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179114     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179115     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179116     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179117     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179118     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179119     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179120     1   0.141      0.977 0.964 0.036 0.000
#> SRR1179121     1   0.141      0.977 0.964 0.036 0.000
#> SRR1179122     1   0.141      0.977 0.964 0.036 0.000
#> SRR1179123     1   0.141      0.977 0.964 0.036 0.000
#> SRR1179124     1   0.141      0.977 0.964 0.036 0.000
#> SRR1179125     1   0.141      0.977 0.964 0.036 0.000
#> SRR1179126     1   0.141      0.977 0.964 0.036 0.000
#> SRR1179127     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179128     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179129     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179130     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179131     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179132     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179134     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179135     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179136     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179137     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179138     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179139     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179140     1   0.000      0.993 1.000 0.000 0.000
#> SRR1179141     1   0.000      0.993 1.000 0.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
#> SRR1179081     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1179082     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1179083     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1179084     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1179085     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1179086     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1179087     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1179088     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1179089     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1179090     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1179091     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1179092     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1179093     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1179094     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1179095     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1179096     2  0.1302      0.962 0.000 0.956 0.000 0.044
#> SRR1179097     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1179098     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1179099     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1179100     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1179101     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1179102     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1179103     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1179104     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1179105     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1179106     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1179107     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1179108     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1179109     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1179110     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1179111     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1179112     1  0.0657      0.946 0.984 0.000 0.004 0.012
#> SRR1179113     1  0.0657      0.946 0.984 0.000 0.004 0.012
#> SRR1179114     1  0.0657      0.946 0.984 0.000 0.004 0.012
#> SRR1179115     1  0.0657      0.946 0.984 0.000 0.004 0.012
#> SRR1179116     1  0.0657      0.946 0.984 0.000 0.004 0.012
#> SRR1179117     1  0.0657      0.946 0.984 0.000 0.004 0.012
#> SRR1179118     1  0.0657      0.946 0.984 0.000 0.004 0.012
#> SRR1179119     1  0.0657      0.946 0.984 0.000 0.004 0.012
#> SRR1179120     4  0.1302      1.000 0.044 0.000 0.000 0.956
#> SRR1179121     4  0.1302      1.000 0.044 0.000 0.000 0.956
#> SRR1179122     4  0.1302      1.000 0.044 0.000 0.000 0.956
#> SRR1179123     4  0.1302      1.000 0.044 0.000 0.000 0.956
#> SRR1179124     4  0.1302      1.000 0.044 0.000 0.000 0.956
#> SRR1179125     4  0.1302      1.000 0.044 0.000 0.000 0.956
#> SRR1179126     4  0.1302      1.000 0.044 0.000 0.000 0.956
#> SRR1179127     1  0.2999      0.880 0.864 0.000 0.004 0.132
#> SRR1179128     1  0.2831      0.890 0.876 0.000 0.004 0.120
#> SRR1179129     1  0.2999      0.880 0.864 0.000 0.004 0.132
#> SRR1179130     1  0.2831      0.890 0.876 0.000 0.004 0.120
#> SRR1179131     1  0.2999      0.880 0.864 0.000 0.004 0.132
#> SRR1179132     1  0.2831      0.890 0.876 0.000 0.004 0.120
#> SRR1179134     1  0.2831      0.890 0.876 0.000 0.004 0.120
#> SRR1179135     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR1179136     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR1179137     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR1179138     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR1179139     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR1179140     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR1179141     1  0.0000      0.946 1.000 0.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
#> SRR1179081     3  0.0000      0.998 0.000 0.00 1.000 0.000 0.000
#> SRR1179082     3  0.0162      0.998 0.004 0.00 0.996 0.000 0.000
#> SRR1179083     3  0.0162      0.998 0.004 0.00 0.996 0.000 0.000
#> SRR1179084     3  0.0162      0.998 0.004 0.00 0.996 0.000 0.000
#> SRR1179085     3  0.0162      0.998 0.004 0.00 0.996 0.000 0.000
#> SRR1179086     3  0.0162      0.998 0.004 0.00 0.996 0.000 0.000
#> SRR1179087     3  0.0162      0.998 0.004 0.00 0.996 0.000 0.000
#> SRR1179088     3  0.0162      0.998 0.004 0.00 0.996 0.000 0.000
#> SRR1179089     3  0.0000      0.998 0.000 0.00 1.000 0.000 0.000
#> SRR1179090     3  0.0000      0.998 0.000 0.00 1.000 0.000 0.000
#> SRR1179091     3  0.0000      0.998 0.000 0.00 1.000 0.000 0.000
#> SRR1179092     3  0.0000      0.998 0.000 0.00 1.000 0.000 0.000
#> SRR1179093     3  0.0000      0.998 0.000 0.00 1.000 0.000 0.000
#> SRR1179094     3  0.0000      0.998 0.000 0.00 1.000 0.000 0.000
#> SRR1179095     3  0.0000      0.998 0.000 0.00 1.000 0.000 0.000
#> SRR1179096     2  0.5204      0.507 0.392 0.56 0.000 0.048 0.000
#> SRR1179097     2  0.0000      0.975 0.000 1.00 0.000 0.000 0.000
#> SRR1179098     2  0.0000      0.975 0.000 1.00 0.000 0.000 0.000
#> SRR1179099     2  0.0000      0.975 0.000 1.00 0.000 0.000 0.000
#> SRR1179100     2  0.0000      0.975 0.000 1.00 0.000 0.000 0.000
#> SRR1179101     2  0.0000      0.975 0.000 1.00 0.000 0.000 0.000
#> SRR1179102     2  0.0000      0.975 0.000 1.00 0.000 0.000 0.000
#> SRR1179103     2  0.0000      0.975 0.000 1.00 0.000 0.000 0.000
#> SRR1179104     2  0.0000      0.975 0.000 1.00 0.000 0.000 0.000
#> SRR1179105     2  0.0000      0.975 0.000 1.00 0.000 0.000 0.000
#> SRR1179106     2  0.0000      0.975 0.000 1.00 0.000 0.000 0.000
#> SRR1179107     2  0.0000      0.975 0.000 1.00 0.000 0.000 0.000
#> SRR1179108     2  0.0000      0.975 0.000 1.00 0.000 0.000 0.000
#> SRR1179109     2  0.0000      0.975 0.000 1.00 0.000 0.000 0.000
#> SRR1179110     2  0.0000      0.975 0.000 1.00 0.000 0.000 0.000
#> SRR1179111     2  0.0000      0.975 0.000 1.00 0.000 0.000 0.000
#> SRR1179112     1  0.4249      0.932 0.568 0.00 0.000 0.000 0.432
#> SRR1179113     1  0.4249      0.932 0.568 0.00 0.000 0.000 0.432
#> SRR1179114     1  0.4249      0.932 0.568 0.00 0.000 0.000 0.432
#> SRR1179115     1  0.4249      0.932 0.568 0.00 0.000 0.000 0.432
#> SRR1179116     1  0.4249      0.932 0.568 0.00 0.000 0.000 0.432
#> SRR1179117     1  0.4249      0.932 0.568 0.00 0.000 0.000 0.432
#> SRR1179118     1  0.4249      0.932 0.568 0.00 0.000 0.000 0.432
#> SRR1179119     1  0.4249      0.932 0.568 0.00 0.000 0.000 0.432
#> SRR1179120     4  0.1197      1.000 0.000 0.00 0.000 0.952 0.048
#> SRR1179121     4  0.1197      1.000 0.000 0.00 0.000 0.952 0.048
#> SRR1179122     4  0.1197      1.000 0.000 0.00 0.000 0.952 0.048
#> SRR1179123     4  0.1197      1.000 0.000 0.00 0.000 0.952 0.048
#> SRR1179124     4  0.1197      1.000 0.000 0.00 0.000 0.952 0.048
#> SRR1179125     4  0.1197      1.000 0.000 0.00 0.000 0.952 0.048
#> SRR1179126     4  0.1197      1.000 0.000 0.00 0.000 0.952 0.048
#> SRR1179127     5  0.0162      1.000 0.000 0.00 0.000 0.004 0.996
#> SRR1179128     5  0.0162      1.000 0.000 0.00 0.000 0.004 0.996
#> SRR1179129     5  0.0162      1.000 0.000 0.00 0.000 0.004 0.996
#> SRR1179130     5  0.0162      1.000 0.000 0.00 0.000 0.004 0.996
#> SRR1179131     5  0.0162      1.000 0.000 0.00 0.000 0.004 0.996
#> SRR1179132     5  0.0162      1.000 0.000 0.00 0.000 0.004 0.996
#> SRR1179134     5  0.0162      1.000 0.000 0.00 0.000 0.004 0.996
#> SRR1179135     1  0.4273      0.921 0.552 0.00 0.000 0.000 0.448
#> SRR1179136     1  0.4273      0.921 0.552 0.00 0.000 0.000 0.448
#> SRR1179137     1  0.4273      0.921 0.552 0.00 0.000 0.000 0.448
#> SRR1179138     1  0.4273      0.921 0.552 0.00 0.000 0.000 0.448
#> SRR1179139     1  0.4273      0.921 0.552 0.00 0.000 0.000 0.448
#> SRR1179140     1  0.4273      0.921 0.552 0.00 0.000 0.000 0.448
#> SRR1179141     1  0.4273      0.921 0.552 0.00 0.000 0.000 0.448

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1179081     3  0.0405      0.988 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1179082     3  0.0405      0.989 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1179083     3  0.0405      0.989 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1179084     3  0.0405      0.989 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1179085     3  0.0405      0.989 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1179086     3  0.0405      0.989 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1179087     3  0.0291      0.989 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR1179088     3  0.0405      0.989 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1179089     3  0.0405      0.988 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1179090     3  0.0146      0.989 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1179091     3  0.0405      0.988 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1179092     3  0.0405      0.988 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1179093     3  0.0405      0.988 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1179094     3  0.0405      0.988 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1179095     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1179096     6  0.2697      0.000 0.000 0.188 0.000 0.000 0.000 0.812
#> SRR1179097     2  0.0520      0.988 0.000 0.984 0.000 0.000 0.008 0.008
#> SRR1179098     2  0.0520      0.988 0.000 0.984 0.000 0.000 0.008 0.008
#> SRR1179099     2  0.0520      0.988 0.000 0.984 0.000 0.000 0.008 0.008
#> SRR1179100     2  0.0520      0.988 0.000 0.984 0.000 0.000 0.008 0.008
#> SRR1179101     2  0.0520      0.988 0.000 0.984 0.000 0.000 0.008 0.008
#> SRR1179102     2  0.0520      0.988 0.000 0.984 0.000 0.000 0.008 0.008
#> SRR1179103     2  0.0520      0.988 0.000 0.984 0.000 0.000 0.008 0.008
#> SRR1179104     2  0.0146      0.988 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR1179105     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1179106     2  0.0146      0.988 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR1179107     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1179108     2  0.0146      0.988 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR1179109     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1179110     2  0.0146      0.988 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR1179111     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1179112     1  0.4434      0.800 0.712 0.000 0.000 0.000 0.116 0.172
#> SRR1179113     1  0.4030      0.829 0.748 0.000 0.000 0.000 0.080 0.172
#> SRR1179114     1  0.4030      0.829 0.748 0.000 0.000 0.000 0.080 0.172
#> SRR1179115     1  0.4030      0.829 0.748 0.000 0.000 0.000 0.080 0.172
#> SRR1179116     1  0.4030      0.829 0.748 0.000 0.000 0.000 0.080 0.172
#> SRR1179117     1  0.4030      0.829 0.748 0.000 0.000 0.000 0.080 0.172
#> SRR1179118     1  0.4030      0.829 0.748 0.000 0.000 0.000 0.080 0.172
#> SRR1179119     1  0.4030      0.829 0.748 0.000 0.000 0.000 0.080 0.172
#> SRR1179120     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1179121     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1179122     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1179123     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1179124     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1179125     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1179126     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1179127     5  0.1584      1.000 0.064 0.000 0.000 0.008 0.928 0.000
#> SRR1179128     5  0.1584      1.000 0.064 0.000 0.000 0.008 0.928 0.000
#> SRR1179129     5  0.1584      1.000 0.064 0.000 0.000 0.008 0.928 0.000
#> SRR1179130     5  0.1584      1.000 0.064 0.000 0.000 0.008 0.928 0.000
#> SRR1179131     5  0.1584      1.000 0.064 0.000 0.000 0.008 0.928 0.000
#> SRR1179132     5  0.1584      1.000 0.064 0.000 0.000 0.008 0.928 0.000
#> SRR1179134     5  0.1584      1.000 0.064 0.000 0.000 0.008 0.928 0.000
#> SRR1179135     1  0.1327      0.803 0.936 0.000 0.000 0.000 0.064 0.000
#> SRR1179136     1  0.1267      0.802 0.940 0.000 0.000 0.000 0.060 0.000
#> SRR1179137     1  0.1387      0.802 0.932 0.000 0.000 0.000 0.068 0.000
#> SRR1179138     1  0.1267      0.802 0.940 0.000 0.000 0.000 0.060 0.000
#> SRR1179139     1  0.1267      0.802 0.940 0.000 0.000 0.000 0.060 0.000
#> SRR1179140     1  0.1387      0.802 0.932 0.000 0.000 0.000 0.068 0.000
#> SRR1179141     1  0.1387      0.796 0.932 0.000 0.000 0.000 0.068 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-skmeans-collect-classes

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

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

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000          0.508 0.492   0.492
#> 3 3 1.000           1.000       1.000          0.266 0.864   0.724
#> 4 4 0.959           0.925       0.968          0.155 0.905   0.734
#> 5 5 0.959           0.894       0.959          0.070 0.928   0.732
#> 6 6 1.000           1.000       1.000          0.033 0.964   0.826

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1179081     3       0          1  0  0  1
#> SRR1179082     3       0          1  0  0  1
#> SRR1179083     3       0          1  0  0  1
#> SRR1179084     3       0          1  0  0  1
#> SRR1179085     3       0          1  0  0  1
#> SRR1179086     3       0          1  0  0  1
#> SRR1179087     3       0          1  0  0  1
#> SRR1179088     3       0          1  0  0  1
#> SRR1179089     3       0          1  0  0  1
#> SRR1179090     3       0          1  0  0  1
#> SRR1179091     3       0          1  0  0  1
#> SRR1179092     3       0          1  0  0  1
#> SRR1179093     3       0          1  0  0  1
#> SRR1179094     3       0          1  0  0  1
#> SRR1179095     3       0          1  0  0  1
#> SRR1179096     2       0          1  0  1  0
#> SRR1179097     2       0          1  0  1  0
#> SRR1179098     2       0          1  0  1  0
#> SRR1179099     2       0          1  0  1  0
#> SRR1179100     2       0          1  0  1  0
#> SRR1179101     2       0          1  0  1  0
#> SRR1179102     2       0          1  0  1  0
#> SRR1179103     2       0          1  0  1  0
#> SRR1179104     2       0          1  0  1  0
#> SRR1179105     2       0          1  0  1  0
#> SRR1179106     2       0          1  0  1  0
#> SRR1179107     2       0          1  0  1  0
#> SRR1179108     2       0          1  0  1  0
#> SRR1179109     2       0          1  0  1  0
#> SRR1179110     2       0          1  0  1  0
#> SRR1179111     2       0          1  0  1  0
#> SRR1179112     1       0          1  1  0  0
#> SRR1179113     1       0          1  1  0  0
#> SRR1179114     1       0          1  1  0  0
#> SRR1179115     1       0          1  1  0  0
#> SRR1179116     1       0          1  1  0  0
#> SRR1179117     1       0          1  1  0  0
#> SRR1179118     1       0          1  1  0  0
#> SRR1179119     1       0          1  1  0  0
#> SRR1179120     1       0          1  1  0  0
#> SRR1179121     1       0          1  1  0  0
#> SRR1179122     1       0          1  1  0  0
#> SRR1179123     1       0          1  1  0  0
#> SRR1179124     1       0          1  1  0  0
#> SRR1179125     1       0          1  1  0  0
#> SRR1179126     1       0          1  1  0  0
#> SRR1179127     1       0          1  1  0  0
#> SRR1179128     1       0          1  1  0  0
#> SRR1179129     1       0          1  1  0  0
#> SRR1179130     1       0          1  1  0  0
#> SRR1179131     1       0          1  1  0  0
#> SRR1179132     1       0          1  1  0  0
#> SRR1179134     1       0          1  1  0  0
#> SRR1179135     1       0          1  1  0  0
#> SRR1179136     1       0          1  1  0  0
#> SRR1179137     1       0          1  1  0  0
#> SRR1179138     1       0          1  1  0  0
#> SRR1179139     1       0          1  1  0  0
#> SRR1179140     1       0          1  1  0  0
#> SRR1179141     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2 p3    p4
#> SRR1179081     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179082     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179083     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179084     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179085     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179086     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179087     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179088     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179089     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179090     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179091     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179092     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179093     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179094     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179095     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1179096     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179097     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179098     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179099     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179100     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179101     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179102     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179103     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179104     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179105     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179106     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179107     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179108     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179109     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179110     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179111     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1179112     1  0.0188      0.918 0.996  0  0 0.004
#> SRR1179113     1  0.0188      0.918 0.996  0  0 0.004
#> SRR1179114     1  0.0188      0.918 0.996  0  0 0.004
#> SRR1179115     1  0.0188      0.918 0.996  0  0 0.004
#> SRR1179116     1  0.0188      0.918 0.996  0  0 0.004
#> SRR1179117     1  0.0188      0.918 0.996  0  0 0.004
#> SRR1179118     1  0.0188      0.918 0.996  0  0 0.004
#> SRR1179119     1  0.0188      0.918 0.996  0  0 0.004
#> SRR1179120     4  0.0000      0.941 0.000  0  0 1.000
#> SRR1179121     4  0.0188      0.939 0.004  0  0 0.996
#> SRR1179122     4  0.0000      0.941 0.000  0  0 1.000
#> SRR1179123     4  0.0000      0.941 0.000  0  0 1.000
#> SRR1179124     4  0.0000      0.941 0.000  0  0 1.000
#> SRR1179125     4  0.0000      0.941 0.000  0  0 1.000
#> SRR1179126     4  0.0188      0.939 0.004  0  0 0.996
#> SRR1179127     1  0.4907      0.332 0.580  0  0 0.420
#> SRR1179128     1  0.1637      0.893 0.940  0  0 0.060
#> SRR1179129     1  0.4994      0.141 0.520  0  0 0.480
#> SRR1179130     1  0.2589      0.850 0.884  0  0 0.116
#> SRR1179131     4  0.4661      0.358 0.348  0  0 0.652
#> SRR1179132     1  0.3266      0.798 0.832  0  0 0.168
#> SRR1179134     1  0.3444      0.779 0.816  0  0 0.184
#> SRR1179135     1  0.0707      0.915 0.980  0  0 0.020
#> SRR1179136     1  0.0336      0.917 0.992  0  0 0.008
#> SRR1179137     1  0.0707      0.915 0.980  0  0 0.020
#> SRR1179138     1  0.0707      0.915 0.980  0  0 0.020
#> SRR1179139     1  0.0188      0.917 0.996  0  0 0.004
#> SRR1179140     1  0.0707      0.915 0.980  0  0 0.020
#> SRR1179141     1  0.0000      0.917 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
#> SRR1179081     3   0.000     1.0000 0.000  0  1  0 0.000
#> SRR1179082     3   0.000     1.0000 0.000  0  1  0 0.000
#> SRR1179083     3   0.000     1.0000 0.000  0  1  0 0.000
#> SRR1179084     3   0.000     1.0000 0.000  0  1  0 0.000
#> SRR1179085     3   0.000     1.0000 0.000  0  1  0 0.000
#> SRR1179086     3   0.000     1.0000 0.000  0  1  0 0.000
#> SRR1179087     3   0.000     1.0000 0.000  0  1  0 0.000
#> SRR1179088     3   0.000     1.0000 0.000  0  1  0 0.000
#> SRR1179089     3   0.000     1.0000 0.000  0  1  0 0.000
#> SRR1179090     3   0.000     1.0000 0.000  0  1  0 0.000
#> SRR1179091     3   0.000     1.0000 0.000  0  1  0 0.000
#> SRR1179092     3   0.000     1.0000 0.000  0  1  0 0.000
#> SRR1179093     3   0.000     1.0000 0.000  0  1  0 0.000
#> SRR1179094     3   0.000     1.0000 0.000  0  1  0 0.000
#> SRR1179095     3   0.000     1.0000 0.000  0  1  0 0.000
#> SRR1179096     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179097     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179098     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179099     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179100     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179101     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179102     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179103     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179104     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179105     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179106     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179107     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179108     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179109     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179110     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179111     2   0.000     1.0000 0.000  1  0  0 0.000
#> SRR1179112     1   0.000     0.8747 1.000  0  0  0 0.000
#> SRR1179113     1   0.000     0.8747 1.000  0  0  0 0.000
#> SRR1179114     1   0.000     0.8747 1.000  0  0  0 0.000
#> SRR1179115     1   0.000     0.8747 1.000  0  0  0 0.000
#> SRR1179116     1   0.000     0.8747 1.000  0  0  0 0.000
#> SRR1179117     1   0.000     0.8747 1.000  0  0  0 0.000
#> SRR1179118     1   0.000     0.8747 1.000  0  0  0 0.000
#> SRR1179119     1   0.000     0.8747 1.000  0  0  0 0.000
#> SRR1179120     4   0.000     1.0000 0.000  0  0  1 0.000
#> SRR1179121     4   0.000     1.0000 0.000  0  0  1 0.000
#> SRR1179122     4   0.000     1.0000 0.000  0  0  1 0.000
#> SRR1179123     4   0.000     1.0000 0.000  0  0  1 0.000
#> SRR1179124     4   0.000     1.0000 0.000  0  0  1 0.000
#> SRR1179125     4   0.000     1.0000 0.000  0  0  1 0.000
#> SRR1179126     4   0.000     1.0000 0.000  0  0  1 0.000
#> SRR1179127     5   0.000     0.8250 0.000  0  0  0 1.000
#> SRR1179128     5   0.000     0.8250 0.000  0  0  0 1.000
#> SRR1179129     5   0.000     0.8250 0.000  0  0  0 1.000
#> SRR1179130     5   0.000     0.8250 0.000  0  0  0 1.000
#> SRR1179131     5   0.000     0.8250 0.000  0  0  0 1.000
#> SRR1179132     5   0.000     0.8250 0.000  0  0  0 1.000
#> SRR1179134     5   0.000     0.8250 0.000  0  0  0 1.000
#> SRR1179135     5   0.415     0.3676 0.388  0  0  0 0.612
#> SRR1179136     1   0.397     0.4464 0.664  0  0  0 0.336
#> SRR1179137     5   0.430     0.0802 0.480  0  0  0 0.520
#> SRR1179138     5   0.422     0.2995 0.416  0  0  0 0.584
#> SRR1179139     1   0.388     0.4942 0.684  0  0  0 0.316
#> SRR1179140     5   0.281     0.7090 0.168  0  0  0 0.832
#> SRR1179141     1   0.393     0.4643 0.672  0  0  0 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
#> SRR1179081     3       0          1  0  0  1  0  0  0
#> SRR1179082     3       0          1  0  0  1  0  0  0
#> SRR1179083     3       0          1  0  0  1  0  0  0
#> SRR1179084     3       0          1  0  0  1  0  0  0
#> SRR1179085     3       0          1  0  0  1  0  0  0
#> SRR1179086     3       0          1  0  0  1  0  0  0
#> SRR1179087     3       0          1  0  0  1  0  0  0
#> SRR1179088     3       0          1  0  0  1  0  0  0
#> SRR1179089     3       0          1  0  0  1  0  0  0
#> SRR1179090     3       0          1  0  0  1  0  0  0
#> SRR1179091     3       0          1  0  0  1  0  0  0
#> SRR1179092     3       0          1  0  0  1  0  0  0
#> SRR1179093     3       0          1  0  0  1  0  0  0
#> SRR1179094     3       0          1  0  0  1  0  0  0
#> SRR1179095     3       0          1  0  0  1  0  0  0
#> SRR1179096     2       0          1  0  1  0  0  0  0
#> SRR1179097     2       0          1  0  1  0  0  0  0
#> SRR1179098     2       0          1  0  1  0  0  0  0
#> SRR1179099     2       0          1  0  1  0  0  0  0
#> SRR1179100     2       0          1  0  1  0  0  0  0
#> SRR1179101     2       0          1  0  1  0  0  0  0
#> SRR1179102     2       0          1  0  1  0  0  0  0
#> SRR1179103     2       0          1  0  1  0  0  0  0
#> SRR1179104     2       0          1  0  1  0  0  0  0
#> SRR1179105     2       0          1  0  1  0  0  0  0
#> SRR1179106     2       0          1  0  1  0  0  0  0
#> SRR1179107     2       0          1  0  1  0  0  0  0
#> SRR1179108     2       0          1  0  1  0  0  0  0
#> SRR1179109     2       0          1  0  1  0  0  0  0
#> SRR1179110     2       0          1  0  1  0  0  0  0
#> SRR1179111     2       0          1  0  1  0  0  0  0
#> SRR1179112     1       0          1  1  0  0  0  0  0
#> SRR1179113     1       0          1  1  0  0  0  0  0
#> SRR1179114     1       0          1  1  0  0  0  0  0
#> SRR1179115     1       0          1  1  0  0  0  0  0
#> SRR1179116     1       0          1  1  0  0  0  0  0
#> SRR1179117     1       0          1  1  0  0  0  0  0
#> SRR1179118     1       0          1  1  0  0  0  0  0
#> SRR1179119     1       0          1  1  0  0  0  0  0
#> SRR1179120     4       0          1  0  0  0  1  0  0
#> SRR1179121     4       0          1  0  0  0  1  0  0
#> SRR1179122     4       0          1  0  0  0  1  0  0
#> SRR1179123     4       0          1  0  0  0  1  0  0
#> SRR1179124     4       0          1  0  0  0  1  0  0
#> SRR1179125     4       0          1  0  0  0  1  0  0
#> SRR1179126     4       0          1  0  0  0  1  0  0
#> SRR1179127     5       0          1  0  0  0  0  1  0
#> SRR1179128     5       0          1  0  0  0  0  1  0
#> SRR1179129     5       0          1  0  0  0  0  1  0
#> SRR1179130     5       0          1  0  0  0  0  1  0
#> SRR1179131     5       0          1  0  0  0  0  1  0
#> SRR1179132     5       0          1  0  0  0  0  1  0
#> SRR1179134     5       0          1  0  0  0  0  1  0
#> SRR1179135     6       0          1  0  0  0  0  0  1
#> SRR1179136     6       0          1  0  0  0  0  0  1
#> SRR1179137     6       0          1  0  0  0  0  0  1
#> SRR1179138     6       0          1  0  0  0  0  0  1
#> SRR1179139     6       0          1  0  0  0  0  0  1
#> SRR1179140     6       0          1  0  0  0  0  0  1
#> SRR1179141     6       0          1  0  0  0  0  0  1

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

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

collect_plots(res)

plot of chunk ATC-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.602           0.903       0.933         0.4098 0.619   0.619
#> 3 3 1.000           1.000       1.000         0.5712 0.738   0.576
#> 4 4 1.000           1.000       1.000         0.1350 0.913   0.756
#> 5 5 1.000           0.997       0.997         0.0812 0.941   0.780
#> 6 6 0.966           0.988       0.956         0.0319 0.968   0.849

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1179081     2   0.141      1.000 0.020 0.980
#> SRR1179082     2   0.141      1.000 0.020 0.980
#> SRR1179083     2   0.141      1.000 0.020 0.980
#> SRR1179084     2   0.141      1.000 0.020 0.980
#> SRR1179085     2   0.141      1.000 0.020 0.980
#> SRR1179086     2   0.141      1.000 0.020 0.980
#> SRR1179087     2   0.141      1.000 0.020 0.980
#> SRR1179088     2   0.141      1.000 0.020 0.980
#> SRR1179089     2   0.141      1.000 0.020 0.980
#> SRR1179090     2   0.141      1.000 0.020 0.980
#> SRR1179091     2   0.141      1.000 0.020 0.980
#> SRR1179092     2   0.141      1.000 0.020 0.980
#> SRR1179093     2   0.141      1.000 0.020 0.980
#> SRR1179094     2   0.141      1.000 0.020 0.980
#> SRR1179095     2   0.141      1.000 0.020 0.980
#> SRR1179096     1   0.788      0.805 0.764 0.236
#> SRR1179097     1   0.788      0.805 0.764 0.236
#> SRR1179098     1   0.788      0.805 0.764 0.236
#> SRR1179099     1   0.788      0.805 0.764 0.236
#> SRR1179100     1   0.788      0.805 0.764 0.236
#> SRR1179101     1   0.788      0.805 0.764 0.236
#> SRR1179102     1   0.788      0.805 0.764 0.236
#> SRR1179103     1   0.788      0.805 0.764 0.236
#> SRR1179104     1   0.788      0.805 0.764 0.236
#> SRR1179105     1   0.788      0.805 0.764 0.236
#> SRR1179106     1   0.788      0.805 0.764 0.236
#> SRR1179107     1   0.788      0.805 0.764 0.236
#> SRR1179108     1   0.788      0.805 0.764 0.236
#> SRR1179109     1   0.788      0.805 0.764 0.236
#> SRR1179110     1   0.788      0.805 0.764 0.236
#> SRR1179111     1   0.788      0.805 0.764 0.236
#> SRR1179112     1   0.000      0.907 1.000 0.000
#> SRR1179113     1   0.000      0.907 1.000 0.000
#> SRR1179114     1   0.000      0.907 1.000 0.000
#> SRR1179115     1   0.000      0.907 1.000 0.000
#> SRR1179116     1   0.000      0.907 1.000 0.000
#> SRR1179117     1   0.000      0.907 1.000 0.000
#> SRR1179118     1   0.000      0.907 1.000 0.000
#> SRR1179119     1   0.000      0.907 1.000 0.000
#> SRR1179120     1   0.000      0.907 1.000 0.000
#> SRR1179121     1   0.000      0.907 1.000 0.000
#> SRR1179122     1   0.000      0.907 1.000 0.000
#> SRR1179123     1   0.000      0.907 1.000 0.000
#> SRR1179124     1   0.000      0.907 1.000 0.000
#> SRR1179125     1   0.000      0.907 1.000 0.000
#> SRR1179126     1   0.000      0.907 1.000 0.000
#> SRR1179127     1   0.000      0.907 1.000 0.000
#> SRR1179128     1   0.000      0.907 1.000 0.000
#> SRR1179129     1   0.000      0.907 1.000 0.000
#> SRR1179130     1   0.000      0.907 1.000 0.000
#> SRR1179131     1   0.000      0.907 1.000 0.000
#> SRR1179132     1   0.000      0.907 1.000 0.000
#> SRR1179134     1   0.000      0.907 1.000 0.000
#> SRR1179135     1   0.000      0.907 1.000 0.000
#> SRR1179136     1   0.000      0.907 1.000 0.000
#> SRR1179137     1   0.000      0.907 1.000 0.000
#> SRR1179138     1   0.000      0.907 1.000 0.000
#> SRR1179139     1   0.000      0.907 1.000 0.000
#> SRR1179140     1   0.000      0.907 1.000 0.000
#> SRR1179141     1   0.000      0.907 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1179081     3       0          1  0  0  1
#> SRR1179082     3       0          1  0  0  1
#> SRR1179083     3       0          1  0  0  1
#> SRR1179084     3       0          1  0  0  1
#> SRR1179085     3       0          1  0  0  1
#> SRR1179086     3       0          1  0  0  1
#> SRR1179087     3       0          1  0  0  1
#> SRR1179088     3       0          1  0  0  1
#> SRR1179089     3       0          1  0  0  1
#> SRR1179090     3       0          1  0  0  1
#> SRR1179091     3       0          1  0  0  1
#> SRR1179092     3       0          1  0  0  1
#> SRR1179093     3       0          1  0  0  1
#> SRR1179094     3       0          1  0  0  1
#> SRR1179095     3       0          1  0  0  1
#> SRR1179096     2       0          1  0  1  0
#> SRR1179097     2       0          1  0  1  0
#> SRR1179098     2       0          1  0  1  0
#> SRR1179099     2       0          1  0  1  0
#> SRR1179100     2       0          1  0  1  0
#> SRR1179101     2       0          1  0  1  0
#> SRR1179102     2       0          1  0  1  0
#> SRR1179103     2       0          1  0  1  0
#> SRR1179104     2       0          1  0  1  0
#> SRR1179105     2       0          1  0  1  0
#> SRR1179106     2       0          1  0  1  0
#> SRR1179107     2       0          1  0  1  0
#> SRR1179108     2       0          1  0  1  0
#> SRR1179109     2       0          1  0  1  0
#> SRR1179110     2       0          1  0  1  0
#> SRR1179111     2       0          1  0  1  0
#> SRR1179112     1       0          1  1  0  0
#> SRR1179113     1       0          1  1  0  0
#> SRR1179114     1       0          1  1  0  0
#> SRR1179115     1       0          1  1  0  0
#> SRR1179116     1       0          1  1  0  0
#> SRR1179117     1       0          1  1  0  0
#> SRR1179118     1       0          1  1  0  0
#> SRR1179119     1       0          1  1  0  0
#> SRR1179120     1       0          1  1  0  0
#> SRR1179121     1       0          1  1  0  0
#> SRR1179122     1       0          1  1  0  0
#> SRR1179123     1       0          1  1  0  0
#> SRR1179124     1       0          1  1  0  0
#> SRR1179125     1       0          1  1  0  0
#> SRR1179126     1       0          1  1  0  0
#> SRR1179127     1       0          1  1  0  0
#> SRR1179128     1       0          1  1  0  0
#> SRR1179129     1       0          1  1  0  0
#> SRR1179130     1       0          1  1  0  0
#> SRR1179131     1       0          1  1  0  0
#> SRR1179132     1       0          1  1  0  0
#> SRR1179134     1       0          1  1  0  0
#> SRR1179135     1       0          1  1  0  0
#> SRR1179136     1       0          1  1  0  0
#> SRR1179137     1       0          1  1  0  0
#> SRR1179138     1       0          1  1  0  0
#> SRR1179139     1       0          1  1  0  0
#> SRR1179140     1       0          1  1  0  0
#> SRR1179141     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1 p2 p3 p4
#> SRR1179081     3       0          1  0  0  1  0
#> SRR1179082     3       0          1  0  0  1  0
#> SRR1179083     3       0          1  0  0  1  0
#> SRR1179084     3       0          1  0  0  1  0
#> SRR1179085     3       0          1  0  0  1  0
#> SRR1179086     3       0          1  0  0  1  0
#> SRR1179087     3       0          1  0  0  1  0
#> SRR1179088     3       0          1  0  0  1  0
#> SRR1179089     3       0          1  0  0  1  0
#> SRR1179090     3       0          1  0  0  1  0
#> SRR1179091     3       0          1  0  0  1  0
#> SRR1179092     3       0          1  0  0  1  0
#> SRR1179093     3       0          1  0  0  1  0
#> SRR1179094     3       0          1  0  0  1  0
#> SRR1179095     3       0          1  0  0  1  0
#> SRR1179096     2       0          1  0  1  0  0
#> SRR1179097     2       0          1  0  1  0  0
#> SRR1179098     2       0          1  0  1  0  0
#> SRR1179099     2       0          1  0  1  0  0
#> SRR1179100     2       0          1  0  1  0  0
#> SRR1179101     2       0          1  0  1  0  0
#> SRR1179102     2       0          1  0  1  0  0
#> SRR1179103     2       0          1  0  1  0  0
#> SRR1179104     2       0          1  0  1  0  0
#> SRR1179105     2       0          1  0  1  0  0
#> SRR1179106     2       0          1  0  1  0  0
#> SRR1179107     2       0          1  0  1  0  0
#> SRR1179108     2       0          1  0  1  0  0
#> SRR1179109     2       0          1  0  1  0  0
#> SRR1179110     2       0          1  0  1  0  0
#> SRR1179111     2       0          1  0  1  0  0
#> SRR1179112     1       0          1  1  0  0  0
#> SRR1179113     1       0          1  1  0  0  0
#> SRR1179114     1       0          1  1  0  0  0
#> SRR1179115     1       0          1  1  0  0  0
#> SRR1179116     1       0          1  1  0  0  0
#> SRR1179117     1       0          1  1  0  0  0
#> SRR1179118     1       0          1  1  0  0  0
#> SRR1179119     1       0          1  1  0  0  0
#> SRR1179120     4       0          1  0  0  0  1
#> SRR1179121     4       0          1  0  0  0  1
#> SRR1179122     4       0          1  0  0  0  1
#> SRR1179123     4       0          1  0  0  0  1
#> SRR1179124     4       0          1  0  0  0  1
#> SRR1179125     4       0          1  0  0  0  1
#> SRR1179126     4       0          1  0  0  0  1
#> SRR1179127     1       0          1  1  0  0  0
#> SRR1179128     1       0          1  1  0  0  0
#> SRR1179129     1       0          1  1  0  0  0
#> SRR1179130     1       0          1  1  0  0  0
#> SRR1179131     1       0          1  1  0  0  0
#> SRR1179132     1       0          1  1  0  0  0
#> SRR1179134     1       0          1  1  0  0  0
#> SRR1179135     1       0          1  1  0  0  0
#> SRR1179136     1       0          1  1  0  0  0
#> SRR1179137     1       0          1  1  0  0  0
#> SRR1179138     1       0          1  1  0  0  0
#> SRR1179139     1       0          1  1  0  0  0
#> SRR1179140     1       0          1  1  0  0  0
#> SRR1179141     1       0          1  1  0  0  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2 p3 p4    p5
#> SRR1179081     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179082     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179083     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179084     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179085     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179086     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179087     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179088     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179089     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179090     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179091     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179092     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179093     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179094     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179095     3  0.0000      1.000 0.000  0  1  0 0.000
#> SRR1179096     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179097     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179098     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179099     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179100     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179101     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179102     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179103     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179104     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179105     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179106     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179107     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179108     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179109     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179110     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179111     2  0.0000      1.000 0.000  1  0  0 0.000
#> SRR1179112     1  0.0290      0.988 0.992  0  0  0 0.008
#> SRR1179113     1  0.0290      0.988 0.992  0  0  0 0.008
#> SRR1179114     1  0.0290      0.988 0.992  0  0  0 0.008
#> SRR1179115     1  0.0290      0.988 0.992  0  0  0 0.008
#> SRR1179116     1  0.0290      0.988 0.992  0  0  0 0.008
#> SRR1179117     1  0.0290      0.988 0.992  0  0  0 0.008
#> SRR1179118     1  0.0290      0.988 0.992  0  0  0 0.008
#> SRR1179119     1  0.0290      0.988 0.992  0  0  0 0.008
#> SRR1179120     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179121     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179122     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179123     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179124     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179125     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179126     4  0.0000      1.000 0.000  0  0  1 0.000
#> SRR1179127     5  0.0000      1.000 0.000  0  0  0 1.000
#> SRR1179128     5  0.0000      1.000 0.000  0  0  0 1.000
#> SRR1179129     5  0.0000      1.000 0.000  0  0  0 1.000
#> SRR1179130     5  0.0000      1.000 0.000  0  0  0 1.000
#> SRR1179131     5  0.0000      1.000 0.000  0  0  0 1.000
#> SRR1179132     5  0.0000      1.000 0.000  0  0  0 1.000
#> SRR1179134     5  0.0000      1.000 0.000  0  0  0 1.000
#> SRR1179135     1  0.0609      0.986 0.980  0  0  0 0.020
#> SRR1179136     1  0.0609      0.986 0.980  0  0  0 0.020
#> SRR1179137     1  0.0609      0.986 0.980  0  0  0 0.020
#> SRR1179138     1  0.0609      0.986 0.980  0  0  0 0.020
#> SRR1179139     1  0.0609      0.986 0.980  0  0  0 0.020
#> SRR1179140     1  0.0609      0.986 0.980  0  0  0 0.020
#> SRR1179141     1  0.0609      0.986 0.980  0  0  0 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
#> SRR1179081     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179082     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179083     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179084     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179085     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179086     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179087     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179088     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179089     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179090     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179091     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179092     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179093     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179094     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179095     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1179096     2  0.3426      0.746 0.276 0.720  0  0 0.004 0.000
#> SRR1179097     2  0.0000      0.976 0.000 1.000  0  0 0.000 0.000
#> SRR1179098     2  0.0000      0.976 0.000 1.000  0  0 0.000 0.000
#> SRR1179099     2  0.0000      0.976 0.000 1.000  0  0 0.000 0.000
#> SRR1179100     2  0.0000      0.976 0.000 1.000  0  0 0.000 0.000
#> SRR1179101     2  0.0000      0.976 0.000 1.000  0  0 0.000 0.000
#> SRR1179102     2  0.0146      0.974 0.000 0.996  0  0 0.004 0.000
#> SRR1179103     2  0.0000      0.976 0.000 1.000  0  0 0.000 0.000
#> SRR1179104     2  0.1765      0.918 0.096 0.904  0  0 0.000 0.000
#> SRR1179105     2  0.0000      0.976 0.000 1.000  0  0 0.000 0.000
#> SRR1179106     2  0.0632      0.967 0.024 0.976  0  0 0.000 0.000
#> SRR1179107     2  0.0000      0.976 0.000 1.000  0  0 0.000 0.000
#> SRR1179108     2  0.0632      0.967 0.024 0.976  0  0 0.000 0.000
#> SRR1179109     2  0.0000      0.976 0.000 1.000  0  0 0.000 0.000
#> SRR1179110     2  0.0632      0.967 0.024 0.976  0  0 0.000 0.000
#> SRR1179111     2  0.0000      0.976 0.000 1.000  0  0 0.000 0.000
#> SRR1179112     1  0.3428      0.999 0.696 0.000  0  0 0.000 0.304
#> SRR1179113     1  0.3428      0.999 0.696 0.000  0  0 0.000 0.304
#> SRR1179114     1  0.3428      0.999 0.696 0.000  0  0 0.000 0.304
#> SRR1179115     1  0.3428      0.999 0.696 0.000  0  0 0.000 0.304
#> SRR1179116     1  0.3428      0.999 0.696 0.000  0  0 0.000 0.304
#> SRR1179117     1  0.3428      0.999 0.696 0.000  0  0 0.000 0.304
#> SRR1179118     1  0.3428      0.999 0.696 0.000  0  0 0.000 0.304
#> SRR1179119     1  0.3547      0.993 0.696 0.000  0  0 0.004 0.300
#> SRR1179120     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1179121     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1179122     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1179123     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1179124     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1179125     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1179126     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1179127     5  0.0146      1.000 0.000 0.000  0  0 0.996 0.004
#> SRR1179128     5  0.0146      1.000 0.000 0.000  0  0 0.996 0.004
#> SRR1179129     5  0.0146      1.000 0.000 0.000  0  0 0.996 0.004
#> SRR1179130     5  0.0146      1.000 0.000 0.000  0  0 0.996 0.004
#> SRR1179131     5  0.0146      1.000 0.000 0.000  0  0 0.996 0.004
#> SRR1179132     5  0.0146      1.000 0.000 0.000  0  0 0.996 0.004
#> SRR1179134     5  0.0146      1.000 0.000 0.000  0  0 0.996 0.004
#> SRR1179135     6  0.0146      0.996 0.004 0.000  0  0 0.000 0.996
#> SRR1179136     6  0.0000      0.997 0.000 0.000  0  0 0.000 1.000
#> SRR1179137     6  0.0000      0.997 0.000 0.000  0  0 0.000 1.000
#> SRR1179138     6  0.0146      0.996 0.004 0.000  0  0 0.000 0.996
#> SRR1179139     6  0.0000      0.997 0.000 0.000  0  0 0.000 1.000
#> SRR1179140     6  0.0146      0.996 0.004 0.000  0  0 0.000 0.996
#> SRR1179141     6  0.0000      0.997 0.000 0.000  0  0 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 14036 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5084 0.492   0.492
#> 3 3 1.000           0.979       0.977         0.0285 1.000   1.000
#> 4 4 0.789           0.906       0.905         0.0855 1.000   1.000
#> 5 5 0.763           0.861       0.859         0.1621 0.797   0.587
#> 6 6 0.761           0.936       0.873         0.0380 0.969   0.896

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
#> SRR1179081     2       0          1  0  1
#> SRR1179082     2       0          1  0  1
#> SRR1179083     2       0          1  0  1
#> SRR1179084     2       0          1  0  1
#> SRR1179085     2       0          1  0  1
#> SRR1179086     2       0          1  0  1
#> SRR1179087     2       0          1  0  1
#> SRR1179088     2       0          1  0  1
#> SRR1179089     2       0          1  0  1
#> SRR1179090     2       0          1  0  1
#> SRR1179091     2       0          1  0  1
#> SRR1179092     2       0          1  0  1
#> SRR1179093     2       0          1  0  1
#> SRR1179094     2       0          1  0  1
#> SRR1179095     2       0          1  0  1
#> SRR1179096     2       0          1  0  1
#> SRR1179097     2       0          1  0  1
#> SRR1179098     2       0          1  0  1
#> SRR1179099     2       0          1  0  1
#> SRR1179100     2       0          1  0  1
#> SRR1179101     2       0          1  0  1
#> SRR1179102     2       0          1  0  1
#> SRR1179103     2       0          1  0  1
#> SRR1179104     2       0          1  0  1
#> SRR1179105     2       0          1  0  1
#> SRR1179106     2       0          1  0  1
#> SRR1179107     2       0          1  0  1
#> SRR1179108     2       0          1  0  1
#> SRR1179109     2       0          1  0  1
#> SRR1179110     2       0          1  0  1
#> SRR1179111     2       0          1  0  1
#> SRR1179112     1       0          1  1  0
#> SRR1179113     1       0          1  1  0
#> SRR1179114     1       0          1  1  0
#> SRR1179115     1       0          1  1  0
#> SRR1179116     1       0          1  1  0
#> SRR1179117     1       0          1  1  0
#> SRR1179118     1       0          1  1  0
#> SRR1179119     1       0          1  1  0
#> SRR1179120     1       0          1  1  0
#> SRR1179121     1       0          1  1  0
#> SRR1179122     1       0          1  1  0
#> SRR1179123     1       0          1  1  0
#> SRR1179124     1       0          1  1  0
#> SRR1179125     1       0          1  1  0
#> SRR1179126     1       0          1  1  0
#> SRR1179127     1       0          1  1  0
#> SRR1179128     1       0          1  1  0
#> SRR1179129     1       0          1  1  0
#> SRR1179130     1       0          1  1  0
#> SRR1179131     1       0          1  1  0
#> SRR1179132     1       0          1  1  0
#> SRR1179134     1       0          1  1  0
#> SRR1179135     1       0          1  1  0
#> SRR1179136     1       0          1  1  0
#> SRR1179137     1       0          1  1  0
#> SRR1179138     1       0          1  1  0
#> SRR1179139     1       0          1  1  0
#> SRR1179140     1       0          1  1  0
#> SRR1179141     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1179081     2  0.0000      0.981 0.000 1.000 0.000
#> SRR1179082     2  0.0000      0.981 0.000 1.000 0.000
#> SRR1179083     2  0.0000      0.981 0.000 1.000 0.000
#> SRR1179084     2  0.0000      0.981 0.000 1.000 0.000
#> SRR1179085     2  0.0000      0.981 0.000 1.000 0.000
#> SRR1179086     2  0.0000      0.981 0.000 1.000 0.000
#> SRR1179087     2  0.0000      0.981 0.000 1.000 0.000
#> SRR1179088     2  0.0000      0.981 0.000 1.000 0.000
#> SRR1179089     2  0.0237      0.979 0.000 0.996 0.004
#> SRR1179090     2  0.0000      0.981 0.000 1.000 0.000
#> SRR1179091     2  0.0000      0.981 0.000 1.000 0.000
#> SRR1179092     2  0.0000      0.981 0.000 1.000 0.000
#> SRR1179093     2  0.0000      0.981 0.000 1.000 0.000
#> SRR1179094     2  0.0000      0.981 0.000 1.000 0.000
#> SRR1179095     2  0.0000      0.981 0.000 1.000 0.000
#> SRR1179096     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179097     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179098     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179099     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179100     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179101     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179102     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179103     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179104     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179105     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179106     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179107     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179108     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179109     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179110     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179111     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1179112     1  0.0000      0.983 1.000 0.000 0.000
#> SRR1179113     1  0.0000      0.983 1.000 0.000 0.000
#> SRR1179114     1  0.0000      0.983 1.000 0.000 0.000
#> SRR1179115     1  0.0000      0.983 1.000 0.000 0.000
#> SRR1179116     1  0.0000      0.983 1.000 0.000 0.000
#> SRR1179117     1  0.0000      0.983 1.000 0.000 0.000
#> SRR1179118     1  0.0000      0.983 1.000 0.000 0.000
#> SRR1179119     1  0.0000      0.983 1.000 0.000 0.000
#> SRR1179120     1  0.2711      0.951 0.912 0.000 0.088
#> SRR1179121     1  0.2711      0.951 0.912 0.000 0.088
#> SRR1179122     1  0.2711      0.951 0.912 0.000 0.088
#> SRR1179123     1  0.2711      0.951 0.912 0.000 0.088
#> SRR1179124     1  0.2711      0.951 0.912 0.000 0.088
#> SRR1179125     1  0.2711      0.951 0.912 0.000 0.088
#> SRR1179126     1  0.2625      0.953 0.916 0.000 0.084
#> SRR1179127     1  0.0424      0.982 0.992 0.000 0.008
#> SRR1179128     1  0.0000      0.983 1.000 0.000 0.000
#> SRR1179129     1  0.0424      0.982 0.992 0.000 0.008
#> SRR1179130     1  0.0000      0.983 1.000 0.000 0.000
#> SRR1179131     1  0.0424      0.982 0.992 0.000 0.008
#> SRR1179132     1  0.0000      0.983 1.000 0.000 0.000
#> SRR1179134     1  0.0000      0.983 1.000 0.000 0.000
#> SRR1179135     1  0.0237      0.983 0.996 0.000 0.004
#> SRR1179136     1  0.0237      0.983 0.996 0.000 0.004
#> SRR1179137     1  0.0237      0.983 0.996 0.000 0.004
#> SRR1179138     1  0.0237      0.983 0.996 0.000 0.004
#> SRR1179139     1  0.0237      0.983 0.996 0.000 0.004
#> SRR1179140     1  0.0237      0.983 0.996 0.000 0.004
#> SRR1179141     1  0.0424      0.981 0.992 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2 p3    p4
#> SRR1179081     2  0.0000      0.916 0.000 1.000 NA 0.000
#> SRR1179082     2  0.0000      0.916 0.000 1.000 NA 0.000
#> SRR1179083     2  0.0000      0.916 0.000 1.000 NA 0.000
#> SRR1179084     2  0.0000      0.916 0.000 1.000 NA 0.000
#> SRR1179085     2  0.0000      0.916 0.000 1.000 NA 0.000
#> SRR1179086     2  0.0000      0.916 0.000 1.000 NA 0.000
#> SRR1179087     2  0.0000      0.916 0.000 1.000 NA 0.000
#> SRR1179088     2  0.0000      0.916 0.000 1.000 NA 0.000
#> SRR1179089     2  0.0000      0.916 0.000 1.000 NA 0.000
#> SRR1179090     2  0.0000      0.916 0.000 1.000 NA 0.000
#> SRR1179091     2  0.0000      0.916 0.000 1.000 NA 0.000
#> SRR1179092     2  0.0000      0.916 0.000 1.000 NA 0.000
#> SRR1179093     2  0.0000      0.916 0.000 1.000 NA 0.000
#> SRR1179094     2  0.0000      0.916 0.000 1.000 NA 0.000
#> SRR1179095     2  0.0000      0.916 0.000 1.000 NA 0.000
#> SRR1179096     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179097     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179098     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179099     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179100     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179101     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179102     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179103     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179104     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179105     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179106     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179107     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179108     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179109     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179110     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179111     2  0.3569      0.921 0.000 0.804 NA 0.000
#> SRR1179112     1  0.0469      0.928 0.988 0.000 NA 0.012
#> SRR1179113     1  0.0469      0.928 0.988 0.000 NA 0.012
#> SRR1179114     1  0.0469      0.928 0.988 0.000 NA 0.012
#> SRR1179115     1  0.0469      0.928 0.988 0.000 NA 0.012
#> SRR1179116     1  0.0469      0.928 0.988 0.000 NA 0.012
#> SRR1179117     1  0.0469      0.928 0.988 0.000 NA 0.012
#> SRR1179118     1  0.0469      0.928 0.988 0.000 NA 0.012
#> SRR1179119     1  0.0469      0.928 0.988 0.000 NA 0.012
#> SRR1179120     1  0.4713      0.785 0.640 0.000 NA 0.360
#> SRR1179121     1  0.4661      0.791 0.652 0.000 NA 0.348
#> SRR1179122     1  0.4679      0.789 0.648 0.000 NA 0.352
#> SRR1179123     1  0.4746      0.780 0.632 0.000 NA 0.368
#> SRR1179124     1  0.4679      0.789 0.648 0.000 NA 0.352
#> SRR1179125     1  0.4697      0.787 0.644 0.000 NA 0.356
#> SRR1179126     1  0.4624      0.795 0.660 0.000 NA 0.340
#> SRR1179127     1  0.1637      0.913 0.940 0.000 NA 0.060
#> SRR1179128     1  0.0000      0.928 1.000 0.000 NA 0.000
#> SRR1179129     1  0.1867      0.910 0.928 0.000 NA 0.072
#> SRR1179130     1  0.0000      0.928 1.000 0.000 NA 0.000
#> SRR1179131     1  0.2149      0.904 0.912 0.000 NA 0.088
#> SRR1179132     1  0.0000      0.928 1.000 0.000 NA 0.000
#> SRR1179134     1  0.0188      0.928 0.996 0.000 NA 0.004
#> SRR1179135     1  0.0000      0.928 1.000 0.000 NA 0.000
#> SRR1179136     1  0.0000      0.928 1.000 0.000 NA 0.000
#> SRR1179137     1  0.0000      0.928 1.000 0.000 NA 0.000
#> SRR1179138     1  0.0000      0.928 1.000 0.000 NA 0.000
#> SRR1179139     1  0.0000      0.928 1.000 0.000 NA 0.000
#> SRR1179140     1  0.0000      0.928 1.000 0.000 NA 0.000
#> SRR1179141     1  0.0188      0.927 0.996 0.000 NA 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
#> SRR1179081     3  0.3452      1.000 0.000 0.244 0.756 0.000  0
#> SRR1179082     3  0.3452      1.000 0.000 0.244 0.756 0.000  0
#> SRR1179083     3  0.3452      1.000 0.000 0.244 0.756 0.000  0
#> SRR1179084     3  0.3452      1.000 0.000 0.244 0.756 0.000  0
#> SRR1179085     3  0.3452      1.000 0.000 0.244 0.756 0.000  0
#> SRR1179086     3  0.3452      1.000 0.000 0.244 0.756 0.000  0
#> SRR1179087     3  0.3452      1.000 0.000 0.244 0.756 0.000  0
#> SRR1179088     3  0.3452      1.000 0.000 0.244 0.756 0.000  0
#> SRR1179089     3  0.3452      1.000 0.000 0.244 0.756 0.000  0
#> SRR1179090     3  0.3452      1.000 0.000 0.244 0.756 0.000  0
#> SRR1179091     3  0.3452      1.000 0.000 0.244 0.756 0.000  0
#> SRR1179092     3  0.3452      1.000 0.000 0.244 0.756 0.000  0
#> SRR1179093     3  0.3452      1.000 0.000 0.244 0.756 0.000  0
#> SRR1179094     3  0.3452      1.000 0.000 0.244 0.756 0.000  0
#> SRR1179095     3  0.3452      1.000 0.000 0.244 0.756 0.000  0
#> SRR1179096     2  0.0290      0.988 0.000 0.992 0.008 0.000  0
#> SRR1179097     2  0.0404      0.991 0.000 0.988 0.012 0.000  0
#> SRR1179098     2  0.0510      0.988 0.000 0.984 0.016 0.000  0
#> SRR1179099     2  0.0290      0.993 0.000 0.992 0.008 0.000  0
#> SRR1179100     2  0.0290      0.993 0.000 0.992 0.008 0.000  0
#> SRR1179101     2  0.0404      0.991 0.000 0.988 0.012 0.000  0
#> SRR1179102     2  0.0290      0.993 0.000 0.992 0.008 0.000  0
#> SRR1179103     2  0.0510      0.988 0.000 0.984 0.016 0.000  0
#> SRR1179104     2  0.0162      0.994 0.000 0.996 0.004 0.000  0
#> SRR1179105     2  0.0000      0.991 0.000 1.000 0.000 0.000  0
#> SRR1179106     2  0.0162      0.994 0.000 0.996 0.004 0.000  0
#> SRR1179107     2  0.0162      0.993 0.000 0.996 0.004 0.000  0
#> SRR1179108     2  0.0162      0.994 0.000 0.996 0.004 0.000  0
#> SRR1179109     2  0.0000      0.991 0.000 1.000 0.000 0.000  0
#> SRR1179110     2  0.0162      0.994 0.000 0.996 0.004 0.000  0
#> SRR1179111     2  0.0000      0.991 0.000 1.000 0.000 0.000  0
#> SRR1179112     1  0.0510      0.849 0.984 0.000 0.000 0.016  0
#> SRR1179113     1  0.0609      0.848 0.980 0.000 0.000 0.020  0
#> SRR1179114     1  0.0609      0.848 0.980 0.000 0.000 0.020  0
#> SRR1179115     1  0.0609      0.848 0.980 0.000 0.000 0.020  0
#> SRR1179116     1  0.0609      0.848 0.980 0.000 0.000 0.020  0
#> SRR1179117     1  0.0609      0.848 0.980 0.000 0.000 0.020  0
#> SRR1179118     1  0.0510      0.849 0.984 0.000 0.000 0.016  0
#> SRR1179119     1  0.0609      0.848 0.980 0.000 0.000 0.020  0
#> SRR1179120     4  0.4307      0.998 0.496 0.000 0.000 0.504  0
#> SRR1179121     1  0.4307     -0.993 0.500 0.000 0.000 0.500  0
#> SRR1179122     4  0.4307      0.990 0.500 0.000 0.000 0.500  0
#> SRR1179123     4  0.4307      0.998 0.496 0.000 0.000 0.504  0
#> SRR1179124     4  0.4307      0.998 0.496 0.000 0.000 0.504  0
#> SRR1179125     4  0.4307      0.998 0.496 0.000 0.000 0.504  0
#> SRR1179126     1  0.4307     -0.993 0.500 0.000 0.000 0.500  0
#> SRR1179127     1  0.2068      0.709 0.904 0.000 0.004 0.092  0
#> SRR1179128     1  0.0566      0.843 0.984 0.000 0.004 0.012  0
#> SRR1179129     1  0.2583      0.608 0.864 0.000 0.004 0.132  0
#> SRR1179130     1  0.0566      0.843 0.984 0.000 0.004 0.012  0
#> SRR1179131     1  0.3123      0.427 0.812 0.000 0.004 0.184  0
#> SRR1179132     1  0.0566      0.843 0.984 0.000 0.004 0.012  0
#> SRR1179134     1  0.0566      0.843 0.984 0.000 0.004 0.012  0
#> SRR1179135     1  0.0510      0.845 0.984 0.000 0.000 0.016  0
#> SRR1179136     1  0.0510      0.845 0.984 0.000 0.000 0.016  0
#> SRR1179137     1  0.0510      0.845 0.984 0.000 0.000 0.016  0
#> SRR1179138     1  0.0404      0.846 0.988 0.000 0.000 0.012  0
#> SRR1179139     1  0.0609      0.841 0.980 0.000 0.000 0.020  0
#> SRR1179140     1  0.0510      0.845 0.984 0.000 0.000 0.016  0
#> SRR1179141     1  0.0609      0.841 0.980 0.000 0.000 0.020  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
#> SRR1179081     3  0.0622      0.987 0.000 0.008 0.980 0.000 NA NA
#> SRR1179082     3  0.0622      0.989 0.000 0.008 0.980 0.000 NA NA
#> SRR1179083     3  0.0520      0.990 0.000 0.008 0.984 0.000 NA NA
#> SRR1179084     3  0.0508      0.988 0.000 0.004 0.984 0.000 NA NA
#> SRR1179085     3  0.0363      0.989 0.000 0.012 0.988 0.000 NA NA
#> SRR1179086     3  0.0622      0.989 0.000 0.008 0.980 0.000 NA NA
#> SRR1179087     3  0.0146      0.990 0.000 0.004 0.996 0.000 NA NA
#> SRR1179088     3  0.0692      0.984 0.000 0.004 0.976 0.000 NA NA
#> SRR1179089     3  0.0622      0.985 0.000 0.012 0.980 0.000 NA NA
#> SRR1179090     3  0.0405      0.989 0.000 0.004 0.988 0.000 NA NA
#> SRR1179091     3  0.0291      0.990 0.000 0.004 0.992 0.000 NA NA
#> SRR1179092     3  0.0405      0.989 0.000 0.008 0.988 0.000 NA NA
#> SRR1179093     3  0.0291      0.990 0.000 0.004 0.992 0.000 NA NA
#> SRR1179094     3  0.0520      0.987 0.000 0.008 0.984 0.000 NA NA
#> SRR1179095     3  0.0405      0.990 0.000 0.008 0.988 0.000 NA NA
#> SRR1179096     2  0.3493      0.928 0.000 0.796 0.148 0.000 NA NA
#> SRR1179097     2  0.2442      0.977 0.000 0.852 0.144 0.000 NA NA
#> SRR1179098     2  0.2520      0.970 0.000 0.844 0.152 0.000 NA NA
#> SRR1179099     2  0.2278      0.981 0.000 0.868 0.128 0.004 NA NA
#> SRR1179100     2  0.2320      0.981 0.000 0.864 0.132 0.000 NA NA
#> SRR1179101     2  0.2442      0.976 0.000 0.852 0.144 0.000 NA NA
#> SRR1179102     2  0.2340      0.975 0.000 0.852 0.148 0.000 NA NA
#> SRR1179103     2  0.2260      0.980 0.000 0.860 0.140 0.000 NA NA
#> SRR1179104     2  0.2581      0.975 0.000 0.860 0.120 0.000 NA NA
#> SRR1179105     2  0.2234      0.981 0.000 0.872 0.124 0.004 NA NA
#> SRR1179106     2  0.2446      0.980 0.000 0.864 0.124 0.000 NA NA
#> SRR1179107     2  0.2048      0.980 0.000 0.880 0.120 0.000 NA NA
#> SRR1179108     2  0.2581      0.975 0.000 0.860 0.120 0.000 NA NA
#> SRR1179109     2  0.2092      0.981 0.000 0.876 0.124 0.000 NA NA
#> SRR1179110     2  0.2581      0.978 0.000 0.856 0.128 0.000 NA NA
#> SRR1179111     2  0.2048      0.980 0.000 0.880 0.120 0.000 NA NA
#> SRR1179112     1  0.0972      0.895 0.964 0.000 0.000 0.028 NA NA
#> SRR1179113     1  0.0972      0.895 0.964 0.000 0.000 0.028 NA NA
#> SRR1179114     1  0.0972      0.895 0.964 0.000 0.000 0.028 NA NA
#> SRR1179115     1  0.0972      0.895 0.964 0.000 0.000 0.028 NA NA
#> SRR1179116     1  0.0972      0.895 0.964 0.000 0.000 0.028 NA NA
#> SRR1179117     1  0.0972      0.895 0.964 0.000 0.000 0.028 NA NA
#> SRR1179118     1  0.0972      0.895 0.964 0.000 0.000 0.028 NA NA
#> SRR1179119     1  0.1049      0.893 0.960 0.000 0.000 0.032 NA NA
#> SRR1179120     4  0.3838      0.993 0.448 0.000 0.000 0.552 NA NA
#> SRR1179121     4  0.3843      0.989 0.452 0.000 0.000 0.548 NA NA
#> SRR1179122     4  0.3838      0.993 0.448 0.000 0.000 0.552 NA NA
#> SRR1179123     4  0.3828      0.984 0.440 0.000 0.000 0.560 NA NA
#> SRR1179124     4  0.3838      0.993 0.448 0.000 0.000 0.552 NA NA
#> SRR1179125     4  0.3833      0.989 0.444 0.000 0.000 0.556 NA NA
#> SRR1179126     4  0.3843      0.989 0.452 0.000 0.000 0.548 NA NA
#> SRR1179127     1  0.2178      0.729 0.868 0.000 0.000 0.132 NA NA
#> SRR1179128     1  0.1075      0.872 0.952 0.000 0.000 0.048 NA NA
#> SRR1179129     1  0.2454      0.657 0.840 0.000 0.000 0.160 NA NA
#> SRR1179130     1  0.1075      0.872 0.952 0.000 0.000 0.048 NA NA
#> SRR1179131     1  0.2597      0.608 0.824 0.000 0.000 0.176 NA NA
#> SRR1179132     1  0.1141      0.868 0.948 0.000 0.000 0.052 NA NA
#> SRR1179134     1  0.1267      0.859 0.940 0.000 0.000 0.060 NA NA
#> SRR1179135     1  0.0858      0.888 0.968 0.000 0.000 0.004 NA NA
#> SRR1179136     1  0.0790      0.886 0.968 0.000 0.000 0.000 NA NA
#> SRR1179137     1  0.0790      0.886 0.968 0.000 0.000 0.000 NA NA
#> SRR1179138     1  0.0713      0.888 0.972 0.000 0.000 0.000 NA NA
#> SRR1179139     1  0.0790      0.886 0.968 0.000 0.000 0.000 NA NA
#> SRR1179140     1  0.0935      0.886 0.964 0.000 0.000 0.004 NA NA
#> SRR1179141     1  0.0865      0.882 0.964 0.000 0.000 0.000 NA 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-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