cola Report for recount2:SRP050440

Date: 2019-12-26 00:35:31 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 16435 rows and 62 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] 16435    62

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:skmeans 4 1.000 0.975 0.984 ** 2,3
SD:NMF 4 1.000 0.993 0.996 ** 2,3
CV:hclust 4 1.000 0.998 0.999 ** 2,3
CV:pam 6 1.000 0.989 0.995 ** 4,5
CV:mclust 5 1.000 0.998 0.998 ** 2,3,4
CV:NMF 3 1.000 0.986 0.987 **
MAD:skmeans 4 1.000 0.909 0.967 ** 2,3
ATC:hclust 6 1.000 0.978 0.987 ** 4
SD:mclust 5 0.995 0.983 0.986 ** 2,3,4
MAD:hclust 6 0.977 0.965 0.967 ** 2,3
ATC:NMF 6 0.976 0.949 0.961 ** 2,3,4,5
ATC:skmeans 5 0.974 0.966 0.964 ** 2,3,4
MAD:pam 6 0.972 0.894 0.964 ** 2,4,5
CV:skmeans 4 0.960 0.892 0.950 ** 2,3
ATC:mclust 4 0.956 0.931 0.960 ** 2
SD:hclust 5 0.947 0.883 0.934 * 3,4
SD:pam 6 0.939 0.895 0.957 * 2,4,5
MAD:NMF 5 0.921 0.928 0.951 * 2,4
MAD:mclust 6 0.916 0.883 0.899 * 2,3,4,5
ATC:pam 6 0.902 0.926 0.932 * 2,3,4,5
ATC:kmeans 2 0.578 0.900 0.923
CV:kmeans 3 0.437 0.847 0.826
SD:kmeans 2 0.263 0.791 0.842
MAD:kmeans 2 0.200 0.829 0.864

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

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

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

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

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

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

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

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

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

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

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

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

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

Membership heatmap

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

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

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

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

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

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

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

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

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

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

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

Signature heatmap

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

Note in following heatmaps, rows are scaled.

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

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

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

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

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

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

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

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

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

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

Statistics table

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

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 1.000           0.972       0.975          0.496 0.505   0.505
#> CV:NMF      2 0.243           0.732       0.766          0.476 0.505   0.505
#> MAD:NMF     2 1.000           1.000       1.000          0.495 0.505   0.505
#> ATC:NMF     2 1.000           0.945       0.977          0.485 0.505   0.505
#> SD:skmeans  2 1.000           1.000       1.000          0.495 0.505   0.505
#> CV:skmeans  2 1.000           0.967       0.985          0.503 0.494   0.494
#> MAD:skmeans 2 1.000           1.000       1.000          0.495 0.505   0.505
#> ATC:skmeans 2 1.000           1.000       1.000          0.495 0.505   0.505
#> SD:mclust   2 1.000           1.000       1.000          0.495 0.505   0.505
#> CV:mclust   2 1.000           1.000       1.000          0.495 0.505   0.505
#> MAD:mclust  2 1.000           1.000       1.000          0.495 0.505   0.505
#> ATC:mclust  2 1.000           1.000       1.000          0.495 0.505   0.505
#> SD:kmeans   2 0.263           0.791       0.842          0.451 0.505   0.505
#> CV:kmeans   2 0.225           0.608       0.722          0.422 0.494   0.494
#> MAD:kmeans  2 0.200           0.829       0.864          0.458 0.505   0.505
#> ATC:kmeans  2 0.578           0.900       0.923          0.478 0.505   0.505
#> SD:pam      2 0.990           0.963       0.979          0.493 0.505   0.505
#> CV:pam      2 0.626           0.878       0.921          0.441 0.505   0.505
#> MAD:pam     2 1.000           1.000       1.000          0.495 0.505   0.505
#> ATC:pam     2 1.000           0.969       0.988          0.463 0.535   0.535
#> SD:hclust   2 0.581           0.958       0.962          0.490 0.494   0.494
#> CV:hclust   2 1.000           0.999       0.999          0.419 0.581   0.581
#> MAD:hclust  2 1.000           0.970       0.987          0.498 0.505   0.505
#> ATC:hclust  2 0.663           0.936       0.962          0.412 0.611   0.611
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.916           0.978       0.986          0.345 0.829   0.661
#> CV:NMF      3 1.000           0.986       0.987          0.401 0.829   0.661
#> MAD:NMF     3 0.717           0.917       0.932          0.319 0.649   0.415
#> ATC:NMF     3 0.952           0.898       0.959          0.372 0.676   0.443
#> SD:skmeans  3 1.000           0.999       0.999          0.345 0.829   0.661
#> CV:skmeans  3 1.000           0.999       1.000          0.325 0.792   0.599
#> MAD:skmeans 3 1.000           0.991       0.995          0.347 0.829   0.661
#> ATC:skmeans 3 1.000           0.998       0.999          0.346 0.829   0.661
#> SD:mclust   3 1.000           0.993       0.996          0.344 0.829   0.661
#> CV:mclust   3 0.936           0.943       0.953          0.324 0.829   0.661
#> MAD:mclust  3 1.000           0.999       0.999          0.310 0.764   0.567
#> ATC:mclust  3 0.791           0.898       0.947          0.344 0.764   0.557
#> SD:kmeans   3 0.563           0.830       0.825          0.386 0.833   0.670
#> CV:kmeans   3 0.437           0.847       0.826          0.431 0.857   0.711
#> MAD:kmeans  3 0.608           0.836       0.812          0.379 0.829   0.661
#> ATC:kmeans  3 0.672           0.792       0.830          0.341 0.764   0.557
#> SD:pam      3 0.732           0.869       0.897          0.310 0.668   0.442
#> CV:pam      3 0.636           0.760       0.901          0.392 0.852   0.716
#> MAD:pam     3 0.865           0.896       0.947          0.332 0.764   0.561
#> ATC:pam     3 1.000           0.976       0.992          0.431 0.777   0.594
#> SD:hclust   3 1.000           0.996       0.998          0.327 0.857   0.711
#> CV:hclust   3 1.000           0.998       0.999          0.550 0.770   0.604
#> MAD:hclust  3 1.000           0.971       0.987          0.328 0.829   0.661
#> ATC:hclust  3 0.584           0.805       0.841          0.514 0.754   0.597
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 1.000           0.993       0.996         0.1144 0.924   0.772
#> CV:NMF      4 0.849           0.909       0.905         0.1086 0.924   0.772
#> MAD:NMF     4 1.000           0.948       0.979         0.1292 0.911   0.743
#> ATC:NMF     4 1.000           0.936       0.976         0.1359 0.871   0.634
#> SD:skmeans  4 1.000           0.975       0.984         0.1223 0.915   0.746
#> CV:skmeans  4 0.960           0.892       0.950         0.1231 0.895   0.695
#> MAD:skmeans 4 1.000           0.909       0.967         0.1166 0.924   0.772
#> ATC:skmeans 4 1.000           0.993       0.992         0.1240 0.915   0.746
#> SD:mclust   4 1.000           0.936       0.977         0.1015 0.876   0.658
#> CV:mclust   4 0.972           0.971       0.983         0.1181 0.876   0.658
#> MAD:mclust  4 1.000           1.000       1.000         0.1254 0.919   0.768
#> ATC:mclust  4 0.956           0.931       0.960         0.1243 0.871   0.629
#> SD:kmeans   4 0.708           0.818       0.808         0.1370 0.877   0.661
#> CV:kmeans   4 0.608           0.771       0.780         0.1421 1.000   1.000
#> MAD:kmeans  4 0.759           0.776       0.821         0.1346 0.877   0.661
#> ATC:kmeans  4 0.608           0.786       0.796         0.1306 0.882   0.660
#> SD:pam      4 1.000           0.980       0.992         0.1465 0.911   0.747
#> CV:pam      4 1.000           0.987       0.994         0.2113 0.806   0.537
#> MAD:pam     4 0.979           0.915       0.970         0.1093 0.896   0.707
#> ATC:pam     4 1.000           0.985       0.994         0.1327 0.874   0.647
#> SD:hclust   4 0.930           0.932       0.961         0.1586 0.900   0.714
#> CV:hclust   4 1.000           0.998       0.999         0.0664 0.957   0.878
#> MAD:hclust  4 0.850           0.898       0.933         0.1147 0.915   0.746
#> ATC:hclust  4 0.930           0.953       0.972         0.2143 0.876   0.661
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.842           0.733       0.870         0.0569 0.970   0.885
#> CV:NMF      5 0.896           0.909       0.931         0.0690 0.919   0.702
#> MAD:NMF     5 0.921           0.928       0.951         0.0549 0.948   0.804
#> ATC:NMF     5 0.960           0.915       0.953         0.0380 0.949   0.799
#> SD:skmeans  5 0.870           0.898       0.921         0.0418 0.976   0.904
#> CV:skmeans  5 0.858           0.835       0.875         0.0529 0.952   0.818
#> MAD:skmeans 5 0.868           0.778       0.886         0.0488 0.936   0.763
#> ATC:skmeans 5 0.974           0.966       0.964         0.0301 0.976   0.904
#> SD:mclust   5 0.995           0.983       0.986         0.0796 0.937   0.765
#> CV:mclust   5 1.000           0.998       0.998         0.0827 0.937   0.765
#> MAD:mclust  5 1.000           0.987       0.992         0.0864 0.937   0.765
#> ATC:mclust  5 0.874           0.912       0.929         0.0615 0.927   0.720
#> SD:kmeans   5 0.738           0.726       0.770         0.0729 0.911   0.707
#> CV:kmeans   5 0.707           0.681       0.736         0.0927 0.865   0.639
#> MAD:kmeans  5 0.677           0.720       0.775         0.0650 0.911   0.707
#> ATC:kmeans  5 0.754           0.773       0.803         0.0603 0.937   0.774
#> SD:pam      5 0.990           0.958       0.982         0.0739 0.943   0.782
#> CV:pam      5 1.000           0.962       0.983         0.0537 0.962   0.852
#> MAD:pam     5 1.000           0.957       0.984         0.0407 0.969   0.884
#> ATC:pam     5 0.922           0.914       0.920         0.0417 0.986   0.943
#> SD:hclust   5 0.947           0.883       0.934         0.0319 0.975   0.899
#> CV:hclust   5 1.000           0.987       0.986         0.0218 0.990   0.969
#> MAD:hclust  5 0.942           0.944       0.971         0.0416 0.989   0.955
#> ATC:hclust  5 0.891           0.950       0.943         0.0370 0.968   0.868
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.869           0.792       0.873         0.0468 0.947   0.776
#> CV:NMF      6 0.863           0.805       0.855         0.0438 0.986   0.930
#> MAD:NMF     6 0.891           0.870       0.915         0.0398 0.976   0.892
#> ATC:NMF     6 0.976           0.949       0.961         0.0274 0.983   0.918
#> SD:skmeans  6 0.884           0.795       0.861         0.0399 0.964   0.841
#> CV:skmeans  6 0.874           0.807       0.822         0.0374 0.911   0.629
#> MAD:skmeans 6 0.861           0.643       0.833         0.0378 0.967   0.851
#> ATC:skmeans 6 0.967           0.962       0.960         0.0277 0.989   0.951
#> SD:mclust   6 0.989           0.913       0.916         0.0245 1.000   1.000
#> CV:mclust   6 0.897           0.924       0.889         0.0376 0.957   0.792
#> MAD:mclust  6 0.916           0.883       0.899         0.0328 0.981   0.908
#> ATC:mclust  6 0.893           0.892       0.875         0.0340 0.981   0.908
#> SD:kmeans   6 0.693           0.636       0.732         0.0439 0.948   0.809
#> CV:kmeans   6 0.666           0.609       0.724         0.0452 0.962   0.855
#> MAD:kmeans  6 0.700           0.674       0.728         0.0436 0.912   0.694
#> ATC:kmeans  6 0.743           0.701       0.764         0.0427 0.960   0.850
#> SD:pam      6 0.939           0.895       0.957         0.0386 0.970   0.856
#> CV:pam      6 1.000           0.989       0.995         0.0162 0.986   0.935
#> MAD:pam     6 0.972           0.894       0.964         0.0699 0.948   0.783
#> ATC:pam     6 0.902           0.926       0.932         0.0422 0.943   0.757
#> SD:hclust   6 0.970           0.897       0.946         0.0265 0.989   0.951
#> CV:hclust   6 0.852           0.948       0.930         0.0388 0.990   0.968
#> MAD:hclust  6 0.977           0.965       0.967         0.0294 0.976   0.900
#> ATC:hclust  6 1.000           0.978       0.987         0.0257 0.984   0.924

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

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.581           0.958       0.962         0.4898 0.494   0.494
#> 3 3 1.000           0.996       0.998         0.3270 0.857   0.711
#> 4 4 0.930           0.932       0.961         0.1586 0.900   0.714
#> 5 5 0.947           0.883       0.934         0.0319 0.975   0.899
#> 6 6 0.970           0.897       0.946         0.0265 0.989   0.951

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1688357     2   0.000      0.995 0.000 1.000
#> SRR1688358     2   0.000      0.995 0.000 1.000
#> SRR1688359     2   0.000      0.995 0.000 1.000
#> SRR1688360     2   0.000      0.995 0.000 1.000
#> SRR1688361     2   0.000      0.995 0.000 1.000
#> SRR1688362     2   0.000      0.995 0.000 1.000
#> SRR1688363     2   0.000      0.995 0.000 1.000
#> SRR1688365     2   0.000      0.995 0.000 1.000
#> SRR1688364     2   0.000      0.995 0.000 1.000
#> SRR1688366     2   0.000      0.995 0.000 1.000
#> SRR1688367     2   0.000      0.995 0.000 1.000
#> SRR1688368     2   0.000      0.995 0.000 1.000
#> SRR1688370     2   0.000      0.995 0.000 1.000
#> SRR1688369     2   0.000      0.995 0.000 1.000
#> SRR1688371     2   0.000      0.995 0.000 1.000
#> SRR1688372     2   0.000      0.995 0.000 1.000
#> SRR1688373     2   0.000      0.995 0.000 1.000
#> SRR1688374     2   0.000      0.995 0.000 1.000
#> SRR1688375     1   0.541      0.933 0.876 0.124
#> SRR1688377     1   0.541      0.933 0.876 0.124
#> SRR1688378     1   0.541      0.933 0.876 0.124
#> SRR1688376     1   0.541      0.933 0.876 0.124
#> SRR1688380     1   0.541      0.933 0.876 0.124
#> SRR1688379     1   0.541      0.933 0.876 0.124
#> SRR1688381     1   0.541      0.933 0.876 0.124
#> SRR1688382     1   0.541      0.933 0.876 0.124
#> SRR1688383     1   0.541      0.933 0.876 0.124
#> SRR1688384     1   0.541      0.933 0.876 0.124
#> SRR1688385     1   0.541      0.933 0.876 0.124
#> SRR1688386     1   0.541      0.933 0.876 0.124
#> SRR1688387     1   0.541      0.933 0.876 0.124
#> SRR1688388     1   0.541      0.933 0.876 0.124
#> SRR1688389     1   0.541      0.933 0.876 0.124
#> SRR1688390     1   0.541      0.933 0.876 0.124
#> SRR1688391     1   0.541      0.933 0.876 0.124
#> SRR1688392     1   0.541      0.933 0.876 0.124
#> SRR1688393     1   0.000      0.925 1.000 0.000
#> SRR1688395     1   0.000      0.925 1.000 0.000
#> SRR1688394     1   0.000      0.925 1.000 0.000
#> SRR1688397     1   0.000      0.925 1.000 0.000
#> SRR1688398     1   0.000      0.925 1.000 0.000
#> SRR1688396     1   0.000      0.925 1.000 0.000
#> SRR1688399     1   0.000      0.925 1.000 0.000
#> SRR1688400     1   0.000      0.925 1.000 0.000
#> SRR1688402     1   0.000      0.925 1.000 0.000
#> SRR1688401     1   0.000      0.925 1.000 0.000
#> SRR1688403     1   0.000      0.925 1.000 0.000
#> SRR1688404     1   0.000      0.925 1.000 0.000
#> SRR1688405     2   0.278      0.950 0.048 0.952
#> SRR1688407     2   0.278      0.950 0.048 0.952
#> SRR1688408     1   0.000      0.925 1.000 0.000
#> SRR1688406     2   0.278      0.950 0.048 0.952
#> SRR1688410     1   0.000      0.925 1.000 0.000
#> SRR1688411     2   0.000      0.995 0.000 1.000
#> SRR1688409     1   0.000      0.925 1.000 0.000
#> SRR1688412     2   0.000      0.995 0.000 1.000
#> SRR1688413     2   0.000      0.995 0.000 1.000
#> SRR1688414     2   0.000      0.995 0.000 1.000
#> SRR1688415     2   0.000      0.995 0.000 1.000
#> SRR1688416     2   0.000      0.995 0.000 1.000
#> SRR1688417     2   0.000      0.995 0.000 1.000
#> SRR1688418     2   0.000      0.995 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688358     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688359     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688360     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688361     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688362     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688363     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688365     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688364     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688366     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688367     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688368     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688370     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688369     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688371     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688372     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688373     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688374     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688375     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688377     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688378     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688376     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688380     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688379     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688381     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688382     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688383     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688384     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688385     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688386     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688387     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688388     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688389     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688390     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688391     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688392     1     0.0      1.000 1.000 0.000 0.000
#> SRR1688393     3     0.0      1.000 0.000 0.000 1.000
#> SRR1688395     3     0.0      1.000 0.000 0.000 1.000
#> SRR1688394     3     0.0      1.000 0.000 0.000 1.000
#> SRR1688397     3     0.0      1.000 0.000 0.000 1.000
#> SRR1688398     3     0.0      1.000 0.000 0.000 1.000
#> SRR1688396     3     0.0      1.000 0.000 0.000 1.000
#> SRR1688399     3     0.0      1.000 0.000 0.000 1.000
#> SRR1688400     3     0.0      1.000 0.000 0.000 1.000
#> SRR1688402     3     0.0      1.000 0.000 0.000 1.000
#> SRR1688401     3     0.0      1.000 0.000 0.000 1.000
#> SRR1688403     3     0.0      1.000 0.000 0.000 1.000
#> SRR1688404     3     0.0      1.000 0.000 0.000 1.000
#> SRR1688405     2     0.2      0.956 0.012 0.952 0.036
#> SRR1688407     2     0.2      0.956 0.012 0.952 0.036
#> SRR1688408     3     0.0      1.000 0.000 0.000 1.000
#> SRR1688406     2     0.2      0.956 0.012 0.952 0.036
#> SRR1688410     3     0.0      1.000 0.000 0.000 1.000
#> SRR1688411     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688409     3     0.0      1.000 0.000 0.000 1.000
#> SRR1688412     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688413     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688414     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688415     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688416     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688417     2     0.0      0.995 0.000 1.000 0.000
#> SRR1688418     2     0.0      0.995 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1688357     2  0.0000      0.875 0.000 1.000 0.000 0.000
#> SRR1688358     2  0.0000      0.875 0.000 1.000 0.000 0.000
#> SRR1688359     2  0.0000      0.875 0.000 1.000 0.000 0.000
#> SRR1688360     2  0.2868      0.836 0.000 0.864 0.000 0.136
#> SRR1688361     2  0.2868      0.836 0.000 0.864 0.000 0.136
#> SRR1688362     2  0.2868      0.836 0.000 0.864 0.000 0.136
#> SRR1688363     2  0.3569      0.794 0.000 0.804 0.000 0.196
#> SRR1688365     2  0.3569      0.794 0.000 0.804 0.000 0.196
#> SRR1688364     2  0.3569      0.794 0.000 0.804 0.000 0.196
#> SRR1688366     2  0.4761      0.499 0.000 0.628 0.000 0.372
#> SRR1688367     2  0.4761      0.499 0.000 0.628 0.000 0.372
#> SRR1688368     2  0.4761      0.499 0.000 0.628 0.000 0.372
#> SRR1688370     2  0.0000      0.875 0.000 1.000 0.000 0.000
#> SRR1688369     2  0.0000      0.875 0.000 1.000 0.000 0.000
#> SRR1688371     2  0.0000      0.875 0.000 1.000 0.000 0.000
#> SRR1688372     4  0.0469      0.983 0.000 0.012 0.000 0.988
#> SRR1688373     4  0.0469      0.983 0.000 0.012 0.000 0.988
#> SRR1688374     4  0.0469      0.983 0.000 0.012 0.000 0.988
#> SRR1688375     1  0.0469      0.994 0.988 0.000 0.000 0.012
#> SRR1688377     1  0.0469      0.994 0.988 0.000 0.000 0.012
#> SRR1688378     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688376     1  0.0469      0.994 0.988 0.000 0.000 0.012
#> SRR1688380     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688381     1  0.0469      0.994 0.988 0.000 0.000 0.012
#> SRR1688382     1  0.0469      0.994 0.988 0.000 0.000 0.012
#> SRR1688383     1  0.0469      0.994 0.988 0.000 0.000 0.012
#> SRR1688384     1  0.0469      0.994 0.988 0.000 0.000 0.012
#> SRR1688385     1  0.0469      0.994 0.988 0.000 0.000 0.012
#> SRR1688386     1  0.0469      0.994 0.988 0.000 0.000 0.012
#> SRR1688387     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688388     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688389     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688390     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688405     4  0.1118      0.960 0.000 0.000 0.036 0.964
#> SRR1688407     4  0.1118      0.960 0.000 0.000 0.036 0.964
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688406     4  0.1118      0.960 0.000 0.000 0.036 0.964
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688411     4  0.0469      0.983 0.000 0.012 0.000 0.988
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688412     4  0.0469      0.983 0.000 0.012 0.000 0.988
#> SRR1688413     4  0.0469      0.983 0.000 0.012 0.000 0.988
#> SRR1688414     4  0.0469      0.983 0.000 0.012 0.000 0.988
#> SRR1688415     2  0.0000      0.875 0.000 1.000 0.000 0.000
#> SRR1688416     2  0.0000      0.875 0.000 1.000 0.000 0.000
#> SRR1688417     2  0.0000      0.875 0.000 1.000 0.000 0.000
#> SRR1688418     2  0.0000      0.875 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1688357     2  0.0000      0.787 0.000 1.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.787 0.000 1.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.787 0.000 1.000 0.000 0.000 0.000
#> SRR1688360     2  0.3177      0.522 0.000 0.792 0.000 0.000 0.208
#> SRR1688361     2  0.3177      0.522 0.000 0.792 0.000 0.000 0.208
#> SRR1688362     2  0.3177      0.522 0.000 0.792 0.000 0.000 0.208
#> SRR1688363     5  0.3983      1.000 0.000 0.340 0.000 0.000 0.660
#> SRR1688365     5  0.3983      1.000 0.000 0.340 0.000 0.000 0.660
#> SRR1688364     5  0.3983      1.000 0.000 0.340 0.000 0.000 0.660
#> SRR1688366     2  0.4886      0.350 0.000 0.596 0.000 0.372 0.032
#> SRR1688367     2  0.4886      0.350 0.000 0.596 0.000 0.372 0.032
#> SRR1688368     2  0.4886      0.350 0.000 0.596 0.000 0.372 0.032
#> SRR1688370     2  0.0000      0.787 0.000 1.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000      0.787 0.000 1.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000      0.787 0.000 1.000 0.000 0.000 0.000
#> SRR1688372     4  0.0000      0.888 0.000 0.000 0.000 1.000 0.000
#> SRR1688373     4  0.0000      0.888 0.000 0.000 0.000 1.000 0.000
#> SRR1688374     4  0.0000      0.888 0.000 0.000 0.000 1.000 0.000
#> SRR1688375     1  0.0404      0.994 0.988 0.000 0.000 0.000 0.012
#> SRR1688377     1  0.0404      0.994 0.988 0.000 0.000 0.000 0.012
#> SRR1688378     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688376     1  0.0404      0.994 0.988 0.000 0.000 0.000 0.012
#> SRR1688380     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688381     1  0.0404      0.994 0.988 0.000 0.000 0.000 0.012
#> SRR1688382     1  0.0404      0.994 0.988 0.000 0.000 0.000 0.012
#> SRR1688383     1  0.0404      0.994 0.988 0.000 0.000 0.000 0.012
#> SRR1688384     1  0.0404      0.994 0.988 0.000 0.000 0.000 0.012
#> SRR1688385     1  0.0404      0.994 0.988 0.000 0.000 0.000 0.012
#> SRR1688386     1  0.0404      0.994 0.988 0.000 0.000 0.000 0.012
#> SRR1688387     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688388     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688389     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688390     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688405     4  0.4703      0.709 0.000 0.000 0.028 0.632 0.340
#> SRR1688407     4  0.4703      0.709 0.000 0.000 0.028 0.632 0.340
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688406     4  0.4703      0.709 0.000 0.000 0.028 0.632 0.340
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688411     4  0.0000      0.888 0.000 0.000 0.000 1.000 0.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688412     4  0.0000      0.888 0.000 0.000 0.000 1.000 0.000
#> SRR1688413     4  0.0000      0.888 0.000 0.000 0.000 1.000 0.000
#> SRR1688414     4  0.0000      0.888 0.000 0.000 0.000 1.000 0.000
#> SRR1688415     2  0.0000      0.787 0.000 1.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.787 0.000 1.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.787 0.000 1.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.787 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3    p4    p5    p6
#> SRR1688357     2  0.0000      0.795 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.795 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.795 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688360     2  0.3857      0.300 0.000 0.532  0 0.000 0.468 0.000
#> SRR1688361     2  0.3857      0.300 0.000 0.532  0 0.000 0.468 0.000
#> SRR1688362     2  0.3857      0.300 0.000 0.532  0 0.000 0.468 0.000
#> SRR1688363     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1688365     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1688364     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1688366     2  0.5063      0.420 0.000 0.544  0 0.372 0.084 0.000
#> SRR1688367     2  0.5063      0.420 0.000 0.544  0 0.372 0.084 0.000
#> SRR1688368     2  0.5063      0.420 0.000 0.544  0 0.372 0.084 0.000
#> SRR1688370     2  0.0000      0.795 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688369     2  0.0000      0.795 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688371     2  0.0000      0.795 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688372     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688373     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688374     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688375     1  0.0547      0.979 0.980 0.000  0 0.000 0.000 0.020
#> SRR1688377     1  0.0547      0.979 0.980 0.000  0 0.000 0.000 0.020
#> SRR1688378     1  0.0000      0.978 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688376     1  0.0547      0.979 0.980 0.000  0 0.000 0.000 0.020
#> SRR1688380     1  0.0000      0.978 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688379     1  0.0000      0.978 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688381     1  0.0363      0.978 0.988 0.000  0 0.000 0.000 0.012
#> SRR1688382     1  0.0363      0.978 0.988 0.000  0 0.000 0.000 0.012
#> SRR1688383     1  0.0363      0.978 0.988 0.000  0 0.000 0.000 0.012
#> SRR1688384     1  0.0363      0.978 0.988 0.000  0 0.000 0.000 0.012
#> SRR1688385     1  0.0363      0.978 0.988 0.000  0 0.000 0.000 0.012
#> SRR1688386     1  0.0363      0.978 0.988 0.000  0 0.000 0.000 0.012
#> SRR1688387     1  0.1075      0.965 0.952 0.000  0 0.000 0.000 0.048
#> SRR1688388     1  0.1075      0.965 0.952 0.000  0 0.000 0.000 0.048
#> SRR1688389     1  0.1075      0.965 0.952 0.000  0 0.000 0.000 0.048
#> SRR1688390     1  0.1075      0.965 0.952 0.000  0 0.000 0.000 0.048
#> SRR1688391     1  0.1075      0.965 0.952 0.000  0 0.000 0.000 0.048
#> SRR1688392     1  0.1075      0.965 0.952 0.000  0 0.000 0.000 0.048
#> SRR1688393     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688405     6  0.1075      1.000 0.000 0.000  0 0.048 0.000 0.952
#> SRR1688407     6  0.1075      1.000 0.000 0.000  0 0.048 0.000 0.952
#> SRR1688408     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688406     6  0.1075      1.000 0.000 0.000  0 0.048 0.000 0.952
#> SRR1688410     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688411     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688412     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688413     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688414     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688415     2  0.0000      0.795 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.795 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.795 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.795 0.000 1.000  0 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-hclust-collect-classes

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

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

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.263           0.791       0.842         0.4512 0.505   0.505
#> 3 3 0.563           0.830       0.825         0.3861 0.833   0.670
#> 4 4 0.708           0.818       0.808         0.1370 0.877   0.661
#> 5 5 0.738           0.726       0.770         0.0729 0.911   0.707
#> 6 6 0.693           0.636       0.732         0.0439 0.948   0.809

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
#> SRR1688357     2  0.1633      0.924 0.024 0.976
#> SRR1688358     2  0.1633      0.924 0.024 0.976
#> SRR1688359     2  0.1633      0.924 0.024 0.976
#> SRR1688360     2  0.0938      0.925 0.012 0.988
#> SRR1688361     2  0.0938      0.925 0.012 0.988
#> SRR1688362     2  0.0938      0.925 0.012 0.988
#> SRR1688363     2  0.2043      0.919 0.032 0.968
#> SRR1688365     2  0.2043      0.919 0.032 0.968
#> SRR1688364     2  0.2043      0.919 0.032 0.968
#> SRR1688366     2  0.2236      0.917 0.036 0.964
#> SRR1688367     2  0.2236      0.917 0.036 0.964
#> SRR1688368     2  0.2236      0.917 0.036 0.964
#> SRR1688370     2  0.1633      0.924 0.024 0.976
#> SRR1688369     2  0.1633      0.924 0.024 0.976
#> SRR1688371     2  0.1633      0.924 0.024 0.976
#> SRR1688372     2  0.6247      0.812 0.156 0.844
#> SRR1688373     2  0.6247      0.812 0.156 0.844
#> SRR1688374     2  0.6247      0.812 0.156 0.844
#> SRR1688375     1  0.7139      0.739 0.804 0.196
#> SRR1688377     1  0.7139      0.739 0.804 0.196
#> SRR1688378     1  0.8443      0.709 0.728 0.272
#> SRR1688376     1  0.7139      0.739 0.804 0.196
#> SRR1688380     1  0.8443      0.709 0.728 0.272
#> SRR1688379     1  0.8443      0.709 0.728 0.272
#> SRR1688381     1  0.8443      0.709 0.728 0.272
#> SRR1688382     1  0.8443      0.709 0.728 0.272
#> SRR1688383     1  0.8443      0.709 0.728 0.272
#> SRR1688384     1  0.8443      0.709 0.728 0.272
#> SRR1688385     1  0.8443      0.709 0.728 0.272
#> SRR1688386     1  0.8443      0.709 0.728 0.272
#> SRR1688387     1  0.6712      0.741 0.824 0.176
#> SRR1688388     1  0.6712      0.741 0.824 0.176
#> SRR1688389     1  0.6712      0.741 0.824 0.176
#> SRR1688390     1  0.8443      0.709 0.728 0.272
#> SRR1688391     1  0.8443      0.709 0.728 0.272
#> SRR1688392     1  0.8443      0.709 0.728 0.272
#> SRR1688393     1  0.6801      0.728 0.820 0.180
#> SRR1688395     1  0.6801      0.728 0.820 0.180
#> SRR1688394     1  0.6801      0.728 0.820 0.180
#> SRR1688397     1  0.6801      0.728 0.820 0.180
#> SRR1688398     1  0.6801      0.728 0.820 0.180
#> SRR1688396     1  0.6801      0.728 0.820 0.180
#> SRR1688399     1  0.6801      0.728 0.820 0.180
#> SRR1688400     1  0.6801      0.728 0.820 0.180
#> SRR1688402     1  0.6801      0.728 0.820 0.180
#> SRR1688401     1  0.6801      0.728 0.820 0.180
#> SRR1688403     1  0.6801      0.728 0.820 0.180
#> SRR1688404     1  0.6801      0.728 0.820 0.180
#> SRR1688405     1  0.9552      0.658 0.624 0.376
#> SRR1688407     1  0.9552      0.658 0.624 0.376
#> SRR1688408     1  0.6801      0.728 0.820 0.180
#> SRR1688406     1  0.9552      0.658 0.624 0.376
#> SRR1688410     1  0.6801      0.728 0.820 0.180
#> SRR1688411     2  0.6247      0.812 0.156 0.844
#> SRR1688409     1  0.6801      0.728 0.820 0.180
#> SRR1688412     2  0.6247      0.812 0.156 0.844
#> SRR1688413     2  0.6247      0.812 0.156 0.844
#> SRR1688414     2  0.6247      0.812 0.156 0.844
#> SRR1688415     2  0.1633      0.924 0.024 0.976
#> SRR1688416     2  0.1633      0.924 0.024 0.976
#> SRR1688417     2  0.1633      0.924 0.024 0.976
#> SRR1688418     2  0.1633      0.924 0.024 0.976

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2  0.2446     0.8556 0.012 0.936 0.052
#> SRR1688358     2  0.2446     0.8556 0.012 0.936 0.052
#> SRR1688359     2  0.2446     0.8556 0.012 0.936 0.052
#> SRR1688360     2  0.0829     0.8570 0.012 0.984 0.004
#> SRR1688361     2  0.0829     0.8570 0.012 0.984 0.004
#> SRR1688362     2  0.0829     0.8570 0.012 0.984 0.004
#> SRR1688363     2  0.3009     0.8475 0.052 0.920 0.028
#> SRR1688365     2  0.3009     0.8475 0.052 0.920 0.028
#> SRR1688364     2  0.3009     0.8475 0.052 0.920 0.028
#> SRR1688366     2  0.3780     0.8396 0.044 0.892 0.064
#> SRR1688367     2  0.3780     0.8396 0.044 0.892 0.064
#> SRR1688368     2  0.3780     0.8396 0.044 0.892 0.064
#> SRR1688370     2  0.2446     0.8556 0.012 0.936 0.052
#> SRR1688369     2  0.2446     0.8556 0.012 0.936 0.052
#> SRR1688371     2  0.2446     0.8556 0.012 0.936 0.052
#> SRR1688372     2  0.8683     0.6568 0.172 0.592 0.236
#> SRR1688373     2  0.8683     0.6568 0.172 0.592 0.236
#> SRR1688374     2  0.8683     0.6568 0.172 0.592 0.236
#> SRR1688375     1  0.3456     0.8709 0.904 0.036 0.060
#> SRR1688377     1  0.3456     0.8709 0.904 0.036 0.060
#> SRR1688378     1  0.2773     0.8834 0.928 0.048 0.024
#> SRR1688376     1  0.3456     0.8709 0.904 0.036 0.060
#> SRR1688380     1  0.2773     0.8834 0.928 0.048 0.024
#> SRR1688379     1  0.2773     0.8834 0.928 0.048 0.024
#> SRR1688381     1  0.2096     0.8785 0.944 0.052 0.004
#> SRR1688382     1  0.2096     0.8785 0.944 0.052 0.004
#> SRR1688383     1  0.2096     0.8785 0.944 0.052 0.004
#> SRR1688384     1  0.2599     0.8840 0.932 0.052 0.016
#> SRR1688385     1  0.2599     0.8840 0.932 0.052 0.016
#> SRR1688386     1  0.2599     0.8840 0.932 0.052 0.016
#> SRR1688387     1  0.3623     0.8693 0.896 0.032 0.072
#> SRR1688388     1  0.3623     0.8693 0.896 0.032 0.072
#> SRR1688389     1  0.3623     0.8693 0.896 0.032 0.072
#> SRR1688390     1  0.2773     0.8809 0.928 0.048 0.024
#> SRR1688391     1  0.2773     0.8809 0.928 0.048 0.024
#> SRR1688392     1  0.2773     0.8809 0.928 0.048 0.024
#> SRR1688393     3  0.6096     0.9839 0.208 0.040 0.752
#> SRR1688395     3  0.6096     0.9839 0.208 0.040 0.752
#> SRR1688394     3  0.6096     0.9839 0.208 0.040 0.752
#> SRR1688397     3  0.6049     0.9840 0.204 0.040 0.756
#> SRR1688398     3  0.6049     0.9840 0.204 0.040 0.756
#> SRR1688396     3  0.6049     0.9840 0.204 0.040 0.756
#> SRR1688399     3  0.6000     0.9867 0.200 0.040 0.760
#> SRR1688400     3  0.6000     0.9867 0.200 0.040 0.760
#> SRR1688402     3  0.6000     0.9867 0.200 0.040 0.760
#> SRR1688401     3  0.6000     0.9867 0.200 0.040 0.760
#> SRR1688403     3  0.6000     0.9867 0.200 0.040 0.760
#> SRR1688404     3  0.6000     0.9867 0.200 0.040 0.760
#> SRR1688405     1  0.9343     0.0262 0.476 0.176 0.348
#> SRR1688407     1  0.9343     0.0262 0.476 0.176 0.348
#> SRR1688408     3  0.6000     0.9867 0.200 0.040 0.760
#> SRR1688406     1  0.9343     0.0262 0.476 0.176 0.348
#> SRR1688410     3  0.6000     0.9867 0.200 0.040 0.760
#> SRR1688411     2  0.8683     0.6568 0.172 0.592 0.236
#> SRR1688409     3  0.6000     0.9867 0.200 0.040 0.760
#> SRR1688412     2  0.8683     0.6568 0.172 0.592 0.236
#> SRR1688413     2  0.8683     0.6568 0.172 0.592 0.236
#> SRR1688414     2  0.8683     0.6568 0.172 0.592 0.236
#> SRR1688415     2  0.2446     0.8556 0.012 0.936 0.052
#> SRR1688416     2  0.2446     0.8556 0.012 0.936 0.052
#> SRR1688417     2  0.2446     0.8556 0.012 0.936 0.052
#> SRR1688418     2  0.2446     0.8556 0.012 0.936 0.052

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1688357     2  0.0376      0.820 0.000 0.992 0.004 0.004
#> SRR1688358     2  0.0376      0.820 0.000 0.992 0.004 0.004
#> SRR1688359     2  0.0376      0.820 0.000 0.992 0.004 0.004
#> SRR1688360     2  0.4184      0.769 0.056 0.836 0.008 0.100
#> SRR1688361     2  0.4184      0.769 0.056 0.836 0.008 0.100
#> SRR1688362     2  0.4184      0.769 0.056 0.836 0.008 0.100
#> SRR1688363     2  0.5673      0.665 0.072 0.720 0.008 0.200
#> SRR1688365     2  0.5673      0.665 0.072 0.720 0.008 0.200
#> SRR1688364     2  0.5673      0.665 0.072 0.720 0.008 0.200
#> SRR1688366     2  0.5889      0.318 0.040 0.640 0.008 0.312
#> SRR1688367     2  0.5889      0.318 0.040 0.640 0.008 0.312
#> SRR1688368     2  0.5910      0.302 0.040 0.636 0.008 0.316
#> SRR1688370     2  0.0524      0.818 0.008 0.988 0.004 0.000
#> SRR1688369     2  0.0524      0.818 0.008 0.988 0.004 0.000
#> SRR1688371     2  0.0524      0.818 0.008 0.988 0.004 0.000
#> SRR1688372     4  0.7347      0.997 0.100 0.312 0.028 0.560
#> SRR1688373     4  0.7347      0.997 0.100 0.312 0.028 0.560
#> SRR1688374     4  0.7347      0.997 0.100 0.312 0.028 0.560
#> SRR1688375     1  0.4364      0.924 0.828 0.008 0.080 0.084
#> SRR1688377     1  0.4364      0.924 0.828 0.008 0.080 0.084
#> SRR1688378     1  0.3471      0.937 0.876 0.012 0.080 0.032
#> SRR1688376     1  0.4364      0.924 0.828 0.008 0.080 0.084
#> SRR1688380     1  0.3471      0.937 0.876 0.012 0.080 0.032
#> SRR1688379     1  0.3471      0.937 0.876 0.012 0.080 0.032
#> SRR1688381     1  0.4077      0.928 0.848 0.012 0.072 0.068
#> SRR1688382     1  0.4077      0.928 0.848 0.012 0.072 0.068
#> SRR1688383     1  0.4077      0.928 0.848 0.012 0.072 0.068
#> SRR1688384     1  0.3840      0.931 0.860 0.012 0.076 0.052
#> SRR1688385     1  0.3840      0.931 0.860 0.012 0.076 0.052
#> SRR1688386     1  0.3840      0.931 0.860 0.012 0.076 0.052
#> SRR1688387     1  0.4870      0.916 0.796 0.008 0.092 0.104
#> SRR1688388     1  0.4870      0.916 0.796 0.008 0.092 0.104
#> SRR1688389     1  0.4870      0.916 0.796 0.008 0.092 0.104
#> SRR1688390     1  0.4287      0.929 0.836 0.012 0.080 0.072
#> SRR1688391     1  0.4287      0.929 0.836 0.012 0.080 0.072
#> SRR1688392     1  0.4287      0.929 0.836 0.012 0.080 0.072
#> SRR1688393     3  0.3504      0.841 0.012 0.012 0.860 0.116
#> SRR1688395     3  0.3504      0.841 0.012 0.012 0.860 0.116
#> SRR1688394     3  0.3504      0.841 0.012 0.012 0.860 0.116
#> SRR1688397     3  0.3122      0.849 0.016 0.012 0.888 0.084
#> SRR1688398     3  0.3122      0.849 0.016 0.012 0.888 0.084
#> SRR1688396     3  0.3122      0.849 0.016 0.012 0.888 0.084
#> SRR1688399     3  0.1526      0.862 0.016 0.012 0.960 0.012
#> SRR1688400     3  0.1526      0.862 0.016 0.012 0.960 0.012
#> SRR1688402     3  0.2188      0.861 0.020 0.012 0.936 0.032
#> SRR1688401     3  0.1526      0.862 0.016 0.012 0.960 0.012
#> SRR1688403     3  0.2188      0.861 0.020 0.012 0.936 0.032
#> SRR1688404     3  0.2188      0.861 0.020 0.012 0.936 0.032
#> SRR1688405     3  0.8968      0.265 0.276 0.084 0.444 0.196
#> SRR1688407     3  0.8968      0.265 0.276 0.084 0.444 0.196
#> SRR1688408     3  0.2352      0.858 0.016 0.012 0.928 0.044
#> SRR1688406     3  0.8968      0.265 0.276 0.084 0.444 0.196
#> SRR1688410     3  0.2352      0.858 0.016 0.012 0.928 0.044
#> SRR1688411     4  0.7296      0.998 0.096 0.312 0.028 0.564
#> SRR1688409     3  0.2352      0.858 0.016 0.012 0.928 0.044
#> SRR1688412     4  0.7296      0.998 0.096 0.312 0.028 0.564
#> SRR1688413     4  0.7296      0.998 0.096 0.312 0.028 0.564
#> SRR1688414     4  0.7296      0.998 0.096 0.312 0.028 0.564
#> SRR1688415     2  0.0376      0.820 0.000 0.992 0.004 0.004
#> SRR1688416     2  0.0376      0.820 0.000 0.992 0.004 0.004
#> SRR1688417     2  0.0376      0.820 0.000 0.992 0.004 0.004
#> SRR1688418     2  0.0376      0.820 0.000 0.992 0.004 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
#> SRR1688357     2   0.340      0.816 0.000 0.764 0.000 0.236 NA
#> SRR1688358     2   0.340      0.816 0.000 0.764 0.000 0.236 NA
#> SRR1688359     2   0.340      0.816 0.000 0.764 0.000 0.236 NA
#> SRR1688360     2   0.637      0.684 0.000 0.536 0.004 0.272 NA
#> SRR1688361     2   0.637      0.684 0.000 0.536 0.004 0.272 NA
#> SRR1688362     2   0.637      0.684 0.000 0.536 0.004 0.272 NA
#> SRR1688363     2   0.719      0.483 0.016 0.436 0.004 0.292 NA
#> SRR1688365     2   0.719      0.483 0.016 0.436 0.004 0.292 NA
#> SRR1688364     2   0.719      0.483 0.016 0.436 0.004 0.292 NA
#> SRR1688366     4   0.645      0.200 0.004 0.276 0.012 0.560 NA
#> SRR1688367     4   0.645      0.200 0.004 0.276 0.012 0.560 NA
#> SRR1688368     4   0.645      0.200 0.004 0.276 0.012 0.560 NA
#> SRR1688370     2   0.368      0.813 0.000 0.760 0.004 0.232 NA
#> SRR1688369     2   0.368      0.813 0.000 0.760 0.004 0.232 NA
#> SRR1688371     2   0.368      0.813 0.000 0.760 0.004 0.232 NA
#> SRR1688372     4   0.183      0.800 0.032 0.000 0.028 0.936 NA
#> SRR1688373     4   0.183      0.800 0.032 0.000 0.028 0.936 NA
#> SRR1688374     4   0.212      0.797 0.032 0.000 0.036 0.924 NA
#> SRR1688375     1   0.409      0.762 0.812 0.016 0.016 0.024 NA
#> SRR1688377     1   0.409      0.762 0.812 0.016 0.016 0.024 NA
#> SRR1688378     1   0.311      0.774 0.852 0.036 0.000 0.000 NA
#> SRR1688376     1   0.409      0.762 0.812 0.016 0.016 0.024 NA
#> SRR1688380     1   0.311      0.774 0.852 0.036 0.000 0.000 NA
#> SRR1688379     1   0.311      0.774 0.852 0.036 0.000 0.000 NA
#> SRR1688381     1   0.218      0.771 0.924 0.028 0.000 0.028 NA
#> SRR1688382     1   0.218      0.771 0.924 0.028 0.000 0.028 NA
#> SRR1688383     1   0.218      0.771 0.924 0.028 0.000 0.028 NA
#> SRR1688384     1   0.198      0.769 0.932 0.012 0.000 0.032 NA
#> SRR1688385     1   0.198      0.769 0.932 0.012 0.000 0.032 NA
#> SRR1688386     1   0.198      0.769 0.932 0.012 0.000 0.032 NA
#> SRR1688387     1   0.452      0.736 0.644 0.000 0.020 0.000 NA
#> SRR1688388     1   0.452      0.736 0.644 0.000 0.020 0.000 NA
#> SRR1688389     1   0.452      0.736 0.644 0.000 0.020 0.000 NA
#> SRR1688390     1   0.407      0.750 0.728 0.012 0.000 0.004 NA
#> SRR1688391     1   0.407      0.750 0.728 0.012 0.000 0.004 NA
#> SRR1688392     1   0.407      0.750 0.728 0.012 0.000 0.004 NA
#> SRR1688393     3   0.430      0.861 0.036 0.012 0.764 0.000 NA
#> SRR1688395     3   0.430      0.861 0.036 0.012 0.764 0.000 NA
#> SRR1688394     3   0.430      0.861 0.036 0.012 0.764 0.000 NA
#> SRR1688397     3   0.371      0.884 0.036 0.016 0.828 0.000 NA
#> SRR1688398     3   0.371      0.884 0.036 0.016 0.828 0.000 NA
#> SRR1688396     3   0.371      0.884 0.036 0.016 0.828 0.000 NA
#> SRR1688399     3   0.216      0.900 0.036 0.016 0.924 0.000 NA
#> SRR1688400     3   0.216      0.900 0.036 0.016 0.924 0.000 NA
#> SRR1688402     3   0.360      0.892 0.036 0.064 0.856 0.004 NA
#> SRR1688401     3   0.216      0.900 0.036 0.016 0.924 0.000 NA
#> SRR1688403     3   0.360      0.892 0.036 0.064 0.856 0.004 NA
#> SRR1688404     3   0.360      0.892 0.036 0.064 0.856 0.004 NA
#> SRR1688405     1   0.942      0.066 0.296 0.064 0.264 0.184 NA
#> SRR1688407     1   0.942      0.066 0.296 0.064 0.264 0.184 NA
#> SRR1688408     3   0.365      0.887 0.036 0.048 0.848 0.000 NA
#> SRR1688406     1   0.942      0.066 0.296 0.064 0.264 0.184 NA
#> SRR1688410     3   0.365      0.887 0.036 0.048 0.848 0.000 NA
#> SRR1688411     4   0.149      0.800 0.032 0.000 0.020 0.948 NA
#> SRR1688409     3   0.365      0.887 0.036 0.048 0.848 0.000 NA
#> SRR1688412     4   0.149      0.800 0.032 0.000 0.020 0.948 NA
#> SRR1688413     4   0.149      0.800 0.032 0.000 0.020 0.948 NA
#> SRR1688414     4   0.183      0.798 0.032 0.000 0.028 0.936 NA
#> SRR1688415     2   0.340      0.816 0.000 0.764 0.000 0.236 NA
#> SRR1688416     2   0.340      0.816 0.000 0.764 0.000 0.236 NA
#> SRR1688417     2   0.340      0.816 0.000 0.764 0.000 0.236 NA
#> SRR1688418     2   0.340      0.816 0.000 0.764 0.000 0.236 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
#> SRR1688357     2   0.000    0.60936 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1688358     2   0.000    0.60936 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1688359     2   0.000    0.60936 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1688360     2   0.550   -0.30434 0.000 0.604 0.004 0.044 0.292 NA
#> SRR1688361     2   0.550   -0.30434 0.000 0.604 0.004 0.044 0.292 NA
#> SRR1688362     2   0.550   -0.30434 0.000 0.604 0.004 0.044 0.292 NA
#> SRR1688363     5   0.570    1.00000 0.024 0.408 0.000 0.088 0.480 NA
#> SRR1688365     5   0.570    1.00000 0.024 0.408 0.000 0.088 0.480 NA
#> SRR1688364     5   0.570    1.00000 0.024 0.408 0.000 0.088 0.480 NA
#> SRR1688366     2   0.749   -0.17510 0.008 0.372 0.000 0.304 0.196 NA
#> SRR1688367     2   0.749   -0.17510 0.008 0.372 0.000 0.304 0.196 NA
#> SRR1688368     2   0.749   -0.17510 0.008 0.372 0.000 0.304 0.196 NA
#> SRR1688370     2   0.185    0.57689 0.000 0.924 0.012 0.004 0.004 NA
#> SRR1688369     2   0.185    0.57689 0.000 0.924 0.012 0.004 0.004 NA
#> SRR1688371     2   0.185    0.57689 0.000 0.924 0.012 0.004 0.004 NA
#> SRR1688372     4   0.329    0.99005 0.016 0.148 0.008 0.820 0.008 NA
#> SRR1688373     4   0.329    0.99005 0.016 0.148 0.008 0.820 0.008 NA
#> SRR1688374     4   0.364    0.98583 0.016 0.148 0.008 0.808 0.012 NA
#> SRR1688375     1   0.381    0.69974 0.776 0.000 0.004 0.016 0.024 NA
#> SRR1688377     1   0.381    0.69974 0.776 0.000 0.004 0.016 0.024 NA
#> SRR1688378     1   0.467    0.71429 0.716 0.000 0.000 0.024 0.076 NA
#> SRR1688376     1   0.381    0.69974 0.776 0.000 0.004 0.016 0.024 NA
#> SRR1688380     1   0.467    0.71429 0.716 0.000 0.000 0.024 0.076 NA
#> SRR1688379     1   0.467    0.71429 0.716 0.000 0.000 0.024 0.076 NA
#> SRR1688381     1   0.178    0.71679 0.932 0.000 0.000 0.012 0.032 NA
#> SRR1688382     1   0.178    0.71679 0.932 0.000 0.000 0.012 0.032 NA
#> SRR1688383     1   0.178    0.71679 0.932 0.000 0.000 0.012 0.032 NA
#> SRR1688384     1   0.123    0.71464 0.952 0.000 0.000 0.000 0.012 NA
#> SRR1688385     1   0.123    0.71464 0.952 0.000 0.000 0.000 0.012 NA
#> SRR1688386     1   0.123    0.71464 0.952 0.000 0.000 0.000 0.012 NA
#> SRR1688387     1   0.399    0.67187 0.524 0.000 0.004 0.000 0.000 NA
#> SRR1688388     1   0.399    0.67187 0.524 0.000 0.004 0.000 0.000 NA
#> SRR1688389     1   0.399    0.67187 0.524 0.000 0.004 0.000 0.000 NA
#> SRR1688390     1   0.468    0.69783 0.628 0.000 0.000 0.012 0.040 NA
#> SRR1688391     1   0.468    0.69783 0.628 0.000 0.000 0.012 0.040 NA
#> SRR1688392     1   0.468    0.69783 0.628 0.000 0.000 0.012 0.040 NA
#> SRR1688393     3   0.566    0.77918 0.024 0.000 0.664 0.028 0.160 NA
#> SRR1688395     3   0.566    0.77918 0.024 0.000 0.664 0.028 0.160 NA
#> SRR1688394     3   0.566    0.77918 0.024 0.000 0.664 0.028 0.160 NA
#> SRR1688397     3   0.502    0.81796 0.024 0.000 0.740 0.052 0.068 NA
#> SRR1688398     3   0.502    0.81796 0.024 0.000 0.740 0.052 0.068 NA
#> SRR1688396     3   0.502    0.81796 0.024 0.000 0.740 0.052 0.068 NA
#> SRR1688399     3   0.270    0.84655 0.024 0.000 0.892 0.012 0.032 NA
#> SRR1688400     3   0.270    0.84655 0.024 0.000 0.892 0.012 0.032 NA
#> SRR1688402     3   0.337    0.84151 0.024 0.000 0.848 0.048 0.008 NA
#> SRR1688401     3   0.270    0.84655 0.024 0.000 0.892 0.012 0.032 NA
#> SRR1688403     3   0.337    0.84151 0.024 0.000 0.848 0.048 0.008 NA
#> SRR1688404     3   0.337    0.84151 0.024 0.000 0.848 0.048 0.008 NA
#> SRR1688405     1   0.876   -0.00987 0.268 0.008 0.244 0.096 0.260 NA
#> SRR1688407     1   0.878   -0.01006 0.268 0.008 0.244 0.096 0.256 NA
#> SRR1688408     3   0.341    0.83487 0.024 0.000 0.852 0.024 0.036 NA
#> SRR1688406     1   0.876   -0.00987 0.268 0.008 0.244 0.096 0.260 NA
#> SRR1688410     3   0.341    0.83487 0.024 0.000 0.852 0.024 0.036 NA
#> SRR1688411     4   0.292    0.99155 0.016 0.148 0.004 0.832 0.000 NA
#> SRR1688409     3   0.341    0.83487 0.024 0.000 0.852 0.024 0.036 NA
#> SRR1688412     4   0.292    0.99155 0.016 0.148 0.004 0.832 0.000 NA
#> SRR1688413     4   0.292    0.99155 0.016 0.148 0.004 0.832 0.000 NA
#> SRR1688414     4   0.332    0.98757 0.016 0.148 0.004 0.820 0.004 NA
#> SRR1688415     2   0.000    0.60936 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1688416     2   0.000    0.60936 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1688417     2   0.000    0.60936 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1688418     2   0.000    0.60936 0.000 1.000 0.000 0.000 0.000 NA

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4955 0.505   0.505
#> 3 3 1.000           0.999       0.999         0.3451 0.829   0.661
#> 4 4 1.000           0.975       0.984         0.1223 0.915   0.746
#> 5 5 0.870           0.898       0.921         0.0418 0.976   0.904
#> 6 6 0.884           0.795       0.861         0.0399 0.964   0.841

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1688357     2       0          1  0  1
#> SRR1688358     2       0          1  0  1
#> SRR1688359     2       0          1  0  1
#> SRR1688360     2       0          1  0  1
#> SRR1688361     2       0          1  0  1
#> SRR1688362     2       0          1  0  1
#> SRR1688363     2       0          1  0  1
#> SRR1688365     2       0          1  0  1
#> SRR1688364     2       0          1  0  1
#> SRR1688366     2       0          1  0  1
#> SRR1688367     2       0          1  0  1
#> SRR1688368     2       0          1  0  1
#> SRR1688370     2       0          1  0  1
#> SRR1688369     2       0          1  0  1
#> SRR1688371     2       0          1  0  1
#> SRR1688372     2       0          1  0  1
#> SRR1688373     2       0          1  0  1
#> SRR1688374     2       0          1  0  1
#> SRR1688375     1       0          1  1  0
#> SRR1688377     1       0          1  1  0
#> SRR1688378     1       0          1  1  0
#> SRR1688376     1       0          1  1  0
#> SRR1688380     1       0          1  1  0
#> SRR1688379     1       0          1  1  0
#> SRR1688381     1       0          1  1  0
#> SRR1688382     1       0          1  1  0
#> SRR1688383     1       0          1  1  0
#> SRR1688384     1       0          1  1  0
#> SRR1688385     1       0          1  1  0
#> SRR1688386     1       0          1  1  0
#> SRR1688387     1       0          1  1  0
#> SRR1688388     1       0          1  1  0
#> SRR1688389     1       0          1  1  0
#> SRR1688390     1       0          1  1  0
#> SRR1688391     1       0          1  1  0
#> SRR1688392     1       0          1  1  0
#> SRR1688393     1       0          1  1  0
#> SRR1688395     1       0          1  1  0
#> SRR1688394     1       0          1  1  0
#> SRR1688397     1       0          1  1  0
#> SRR1688398     1       0          1  1  0
#> SRR1688396     1       0          1  1  0
#> SRR1688399     1       0          1  1  0
#> SRR1688400     1       0          1  1  0
#> SRR1688402     1       0          1  1  0
#> SRR1688401     1       0          1  1  0
#> SRR1688403     1       0          1  1  0
#> SRR1688404     1       0          1  1  0
#> SRR1688405     1       0          1  1  0
#> SRR1688407     1       0          1  1  0
#> SRR1688408     1       0          1  1  0
#> SRR1688406     1       0          1  1  0
#> SRR1688410     1       0          1  1  0
#> SRR1688411     2       0          1  0  1
#> SRR1688409     1       0          1  1  0
#> SRR1688412     2       0          1  0  1
#> SRR1688413     2       0          1  0  1
#> SRR1688414     2       0          1  0  1
#> SRR1688415     2       0          1  0  1
#> SRR1688416     2       0          1  0  1
#> SRR1688417     2       0          1  0  1
#> SRR1688418     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688358     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688359     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688360     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688361     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688362     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688363     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688365     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688364     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688366     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688367     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688368     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688370     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688369     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688371     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688372     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1688373     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1688374     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1688375     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688377     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688378     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688376     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688380     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688379     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688381     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688382     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688383     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688384     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688385     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688386     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688387     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688388     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688389     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688390     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688391     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688392     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1688393     3  0.0237      0.999 0.004 0.000 0.996
#> SRR1688395     3  0.0237      0.999 0.004 0.000 0.996
#> SRR1688394     3  0.0237      0.999 0.004 0.000 0.996
#> SRR1688397     3  0.0237      0.999 0.004 0.000 0.996
#> SRR1688398     3  0.0237      0.999 0.004 0.000 0.996
#> SRR1688396     3  0.0237      0.999 0.004 0.000 0.996
#> SRR1688399     3  0.0237      0.999 0.004 0.000 0.996
#> SRR1688400     3  0.0237      0.999 0.004 0.000 0.996
#> SRR1688402     3  0.0237      0.999 0.004 0.000 0.996
#> SRR1688401     3  0.0237      0.999 0.004 0.000 0.996
#> SRR1688403     3  0.0237      0.999 0.004 0.000 0.996
#> SRR1688404     3  0.0237      0.999 0.004 0.000 0.996
#> SRR1688405     3  0.0000      0.996 0.000 0.000 1.000
#> SRR1688407     3  0.0000      0.996 0.000 0.000 1.000
#> SRR1688408     3  0.0237      0.999 0.004 0.000 0.996
#> SRR1688406     3  0.0000      0.996 0.000 0.000 1.000
#> SRR1688410     3  0.0237      0.999 0.004 0.000 0.996
#> SRR1688411     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1688409     3  0.0237      0.999 0.004 0.000 0.996
#> SRR1688412     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1688413     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1688414     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1688415     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688416     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688417     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688418     2  0.0000      0.999 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1688357     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1688358     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1688359     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1688360     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1688361     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1688362     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1688363     2  0.0336      0.993 0.000 0.992 0.000 0.008
#> SRR1688365     2  0.0336      0.993 0.000 0.992 0.000 0.008
#> SRR1688364     2  0.0336      0.993 0.000 0.992 0.000 0.008
#> SRR1688366     4  0.3907      0.777 0.000 0.232 0.000 0.768
#> SRR1688367     4  0.3907      0.777 0.000 0.232 0.000 0.768
#> SRR1688368     4  0.3907      0.777 0.000 0.232 0.000 0.768
#> SRR1688370     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1688369     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1688371     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1688372     4  0.0469      0.923 0.000 0.012 0.000 0.988
#> SRR1688373     4  0.0469      0.923 0.000 0.012 0.000 0.988
#> SRR1688374     4  0.0469      0.923 0.000 0.012 0.000 0.988
#> SRR1688375     1  0.0188      0.998 0.996 0.000 0.000 0.004
#> SRR1688377     1  0.0188      0.998 0.996 0.000 0.000 0.004
#> SRR1688378     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> SRR1688376     1  0.0188      0.998 0.996 0.000 0.000 0.004
#> SRR1688380     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> SRR1688381     1  0.0188      0.998 0.996 0.000 0.000 0.004
#> SRR1688382     1  0.0188      0.998 0.996 0.000 0.000 0.004
#> SRR1688383     1  0.0188      0.998 0.996 0.000 0.000 0.004
#> SRR1688384     1  0.0188      0.998 0.996 0.000 0.000 0.004
#> SRR1688385     1  0.0188      0.998 0.996 0.000 0.000 0.004
#> SRR1688386     1  0.0188      0.998 0.996 0.000 0.000 0.004
#> SRR1688387     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> SRR1688388     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> SRR1688389     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> SRR1688390     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> SRR1688395     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> SRR1688394     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> SRR1688397     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> SRR1688398     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> SRR1688396     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> SRR1688399     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> SRR1688400     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> SRR1688402     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> SRR1688401     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> SRR1688403     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> SRR1688404     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> SRR1688405     3  0.1389      0.959 0.000 0.000 0.952 0.048
#> SRR1688407     3  0.1389      0.959 0.000 0.000 0.952 0.048
#> SRR1688408     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> SRR1688406     3  0.1389      0.959 0.000 0.000 0.952 0.048
#> SRR1688410     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> SRR1688411     4  0.0469      0.923 0.000 0.012 0.000 0.988
#> SRR1688409     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> SRR1688412     4  0.0469      0.923 0.000 0.012 0.000 0.988
#> SRR1688413     4  0.0469      0.923 0.000 0.012 0.000 0.988
#> SRR1688414     4  0.0469      0.923 0.000 0.012 0.000 0.988
#> SRR1688415     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1688416     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1688417     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR1688418     2  0.0000      0.998 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1688357     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1688360     2  0.2605      0.880 0.000 0.852 0.000 0.000 0.148
#> SRR1688361     2  0.2605      0.880 0.000 0.852 0.000 0.000 0.148
#> SRR1688362     2  0.2605      0.880 0.000 0.852 0.000 0.000 0.148
#> SRR1688363     2  0.3424      0.824 0.000 0.760 0.000 0.000 0.240
#> SRR1688365     2  0.3424      0.824 0.000 0.760 0.000 0.000 0.240
#> SRR1688364     2  0.3424      0.824 0.000 0.760 0.000 0.000 0.240
#> SRR1688366     4  0.6056      0.509 0.000 0.288 0.000 0.556 0.156
#> SRR1688367     4  0.6056      0.509 0.000 0.288 0.000 0.556 0.156
#> SRR1688368     4  0.6022      0.522 0.000 0.280 0.000 0.564 0.156
#> SRR1688370     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1688372     4  0.0000      0.814 0.000 0.000 0.000 1.000 0.000
#> SRR1688373     4  0.0000      0.814 0.000 0.000 0.000 1.000 0.000
#> SRR1688374     4  0.0000      0.814 0.000 0.000 0.000 1.000 0.000
#> SRR1688375     1  0.2280      0.899 0.880 0.000 0.000 0.000 0.120
#> SRR1688377     1  0.2280      0.899 0.880 0.000 0.000 0.000 0.120
#> SRR1688378     1  0.0000      0.907 1.000 0.000 0.000 0.000 0.000
#> SRR1688376     1  0.2280      0.899 0.880 0.000 0.000 0.000 0.120
#> SRR1688380     1  0.0000      0.907 1.000 0.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000      0.907 1.000 0.000 0.000 0.000 0.000
#> SRR1688381     1  0.3143      0.868 0.796 0.000 0.000 0.000 0.204
#> SRR1688382     1  0.3143      0.868 0.796 0.000 0.000 0.000 0.204
#> SRR1688383     1  0.3143      0.868 0.796 0.000 0.000 0.000 0.204
#> SRR1688384     1  0.3177      0.866 0.792 0.000 0.000 0.000 0.208
#> SRR1688385     1  0.3177      0.866 0.792 0.000 0.000 0.000 0.208
#> SRR1688386     1  0.3177      0.866 0.792 0.000 0.000 0.000 0.208
#> SRR1688387     1  0.0404      0.905 0.988 0.000 0.000 0.000 0.012
#> SRR1688388     1  0.0404      0.905 0.988 0.000 0.000 0.000 0.012
#> SRR1688389     1  0.0404      0.905 0.988 0.000 0.000 0.000 0.012
#> SRR1688390     1  0.0162      0.907 0.996 0.000 0.000 0.000 0.004
#> SRR1688391     1  0.0162      0.907 0.996 0.000 0.000 0.000 0.004
#> SRR1688392     1  0.0162      0.907 0.996 0.000 0.000 0.000 0.004
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688405     5  0.3961      1.000 0.000 0.000 0.248 0.016 0.736
#> SRR1688407     5  0.3961      1.000 0.000 0.000 0.248 0.016 0.736
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688406     5  0.3961      1.000 0.000 0.000 0.248 0.016 0.736
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688411     4  0.0000      0.814 0.000 0.000 0.000 1.000 0.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688412     4  0.0000      0.814 0.000 0.000 0.000 1.000 0.000
#> SRR1688413     4  0.0000      0.814 0.000 0.000 0.000 1.000 0.000
#> SRR1688414     4  0.0000      0.814 0.000 0.000 0.000 1.000 0.000
#> SRR1688415     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1688357     2  0.0000      0.835 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.835 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.835 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688360     2  0.3817      0.021 0.000 0.568 0.000 0.000 0.432 0.000
#> SRR1688361     2  0.3817      0.021 0.000 0.568 0.000 0.000 0.432 0.000
#> SRR1688362     2  0.3817      0.021 0.000 0.568 0.000 0.000 0.432 0.000
#> SRR1688363     5  0.4569      0.401 0.000 0.396 0.000 0.000 0.564 0.040
#> SRR1688365     5  0.4569      0.401 0.000 0.396 0.000 0.000 0.564 0.040
#> SRR1688364     5  0.4569      0.401 0.000 0.396 0.000 0.000 0.564 0.040
#> SRR1688366     5  0.6521      0.512 0.000 0.220 0.000 0.364 0.388 0.028
#> SRR1688367     5  0.6521      0.512 0.000 0.220 0.000 0.364 0.388 0.028
#> SRR1688368     5  0.6484      0.493 0.000 0.208 0.000 0.376 0.388 0.028
#> SRR1688370     2  0.0000      0.835 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000      0.835 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000      0.835 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688372     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688373     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688374     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688375     1  0.2376      0.741 0.888 0.000 0.000 0.000 0.044 0.068
#> SRR1688377     1  0.2376      0.741 0.888 0.000 0.000 0.000 0.044 0.068
#> SRR1688378     1  0.3481      0.769 0.776 0.000 0.000 0.000 0.192 0.032
#> SRR1688376     1  0.2376      0.741 0.888 0.000 0.000 0.000 0.044 0.068
#> SRR1688380     1  0.3481      0.769 0.776 0.000 0.000 0.000 0.192 0.032
#> SRR1688379     1  0.3481      0.769 0.776 0.000 0.000 0.000 0.192 0.032
#> SRR1688381     1  0.3172      0.709 0.832 0.000 0.000 0.000 0.092 0.076
#> SRR1688382     1  0.3172      0.709 0.832 0.000 0.000 0.000 0.092 0.076
#> SRR1688383     1  0.3172      0.709 0.832 0.000 0.000 0.000 0.092 0.076
#> SRR1688384     1  0.3172      0.710 0.832 0.000 0.000 0.000 0.092 0.076
#> SRR1688385     1  0.3172      0.710 0.832 0.000 0.000 0.000 0.092 0.076
#> SRR1688386     1  0.3172      0.710 0.832 0.000 0.000 0.000 0.092 0.076
#> SRR1688387     1  0.4515      0.740 0.656 0.000 0.000 0.000 0.280 0.064
#> SRR1688388     1  0.4515      0.740 0.656 0.000 0.000 0.000 0.280 0.064
#> SRR1688389     1  0.4515      0.740 0.656 0.000 0.000 0.000 0.280 0.064
#> SRR1688390     1  0.4239      0.751 0.696 0.000 0.000 0.000 0.248 0.056
#> SRR1688391     1  0.4239      0.751 0.696 0.000 0.000 0.000 0.248 0.056
#> SRR1688392     1  0.4239      0.751 0.696 0.000 0.000 0.000 0.248 0.056
#> SRR1688393     3  0.0405      0.992 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1688395     3  0.0405      0.992 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1688394     3  0.0405      0.992 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1688397     3  0.0291      0.994 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR1688398     3  0.0291      0.994 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR1688396     3  0.0291      0.994 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR1688399     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688400     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688402     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688401     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688403     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688404     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688405     6  0.1444      1.000 0.000 0.000 0.072 0.000 0.000 0.928
#> SRR1688407     6  0.1444      1.000 0.000 0.000 0.072 0.000 0.000 0.928
#> SRR1688408     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688406     6  0.1444      1.000 0.000 0.000 0.072 0.000 0.000 0.928
#> SRR1688410     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688411     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688409     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688412     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688413     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688414     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688415     2  0.0000      0.835 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.835 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.835 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.835 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-skmeans-collect-classes

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 16435 rows and 62 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 0.990           0.963       0.979         0.4928 0.505   0.505
#> 3 3 0.732           0.869       0.897         0.3098 0.668   0.442
#> 4 4 1.000           0.980       0.992         0.1465 0.911   0.747
#> 5 5 0.990           0.958       0.982         0.0739 0.943   0.782
#> 6 6 0.939           0.895       0.957         0.0386 0.970   0.856

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
#> SRR1688357     2  0.0000      0.979 0.000 1.000
#> SRR1688358     2  0.0000      0.979 0.000 1.000
#> SRR1688359     2  0.0000      0.979 0.000 1.000
#> SRR1688360     2  0.0000      0.979 0.000 1.000
#> SRR1688361     2  0.0000      0.979 0.000 1.000
#> SRR1688362     2  0.0000      0.979 0.000 1.000
#> SRR1688363     2  0.0000      0.979 0.000 1.000
#> SRR1688365     2  0.0000      0.979 0.000 1.000
#> SRR1688364     2  0.0000      0.979 0.000 1.000
#> SRR1688366     2  0.0000      0.979 0.000 1.000
#> SRR1688367     2  0.0672      0.976 0.008 0.992
#> SRR1688368     2  0.3274      0.952 0.060 0.940
#> SRR1688370     2  0.0000      0.979 0.000 1.000
#> SRR1688369     2  0.0000      0.979 0.000 1.000
#> SRR1688371     2  0.0000      0.979 0.000 1.000
#> SRR1688372     2  0.3274      0.952 0.060 0.940
#> SRR1688373     2  0.3274      0.952 0.060 0.940
#> SRR1688374     2  0.3274      0.952 0.060 0.940
#> SRR1688375     1  0.0000      0.977 1.000 0.000
#> SRR1688377     1  0.0000      0.977 1.000 0.000
#> SRR1688378     1  0.0000      0.977 1.000 0.000
#> SRR1688376     1  0.0000      0.977 1.000 0.000
#> SRR1688380     1  0.0376      0.975 0.996 0.004
#> SRR1688379     1  0.0000      0.977 1.000 0.000
#> SRR1688381     1  0.6887      0.793 0.816 0.184
#> SRR1688382     1  0.6887      0.793 0.816 0.184
#> SRR1688383     1  0.6887      0.793 0.816 0.184
#> SRR1688384     1  0.3431      0.930 0.936 0.064
#> SRR1688385     1  0.2043      0.956 0.968 0.032
#> SRR1688386     1  0.1184      0.967 0.984 0.016
#> SRR1688387     1  0.0000      0.977 1.000 0.000
#> SRR1688388     1  0.0000      0.977 1.000 0.000
#> SRR1688389     1  0.0000      0.977 1.000 0.000
#> SRR1688390     1  0.0000      0.977 1.000 0.000
#> SRR1688391     1  0.3114      0.937 0.944 0.056
#> SRR1688392     1  0.3114      0.937 0.944 0.056
#> SRR1688393     1  0.0000      0.977 1.000 0.000
#> SRR1688395     1  0.0000      0.977 1.000 0.000
#> SRR1688394     1  0.0000      0.977 1.000 0.000
#> SRR1688397     1  0.0000      0.977 1.000 0.000
#> SRR1688398     1  0.0000      0.977 1.000 0.000
#> SRR1688396     1  0.0000      0.977 1.000 0.000
#> SRR1688399     1  0.0000      0.977 1.000 0.000
#> SRR1688400     1  0.0000      0.977 1.000 0.000
#> SRR1688402     1  0.0000      0.977 1.000 0.000
#> SRR1688401     1  0.0000      0.977 1.000 0.000
#> SRR1688403     1  0.0000      0.977 1.000 0.000
#> SRR1688404     1  0.0000      0.977 1.000 0.000
#> SRR1688405     1  0.0000      0.977 1.000 0.000
#> SRR1688407     1  0.0000      0.977 1.000 0.000
#> SRR1688408     1  0.0000      0.977 1.000 0.000
#> SRR1688406     1  0.0000      0.977 1.000 0.000
#> SRR1688410     1  0.0000      0.977 1.000 0.000
#> SRR1688411     2  0.3274      0.952 0.060 0.940
#> SRR1688409     1  0.0000      0.977 1.000 0.000
#> SRR1688412     2  0.3274      0.952 0.060 0.940
#> SRR1688413     2  0.3274      0.952 0.060 0.940
#> SRR1688414     2  0.3879      0.936 0.076 0.924
#> SRR1688415     2  0.0000      0.979 0.000 1.000
#> SRR1688416     2  0.0000      0.979 0.000 1.000
#> SRR1688417     2  0.0000      0.979 0.000 1.000
#> SRR1688418     2  0.0000      0.979 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688358     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688359     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688360     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688361     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688362     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688363     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688365     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688364     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688366     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688367     2  0.0592      0.986 0.012 0.988 0.000
#> SRR1688368     1  0.9783      0.319 0.404 0.360 0.236
#> SRR1688370     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688369     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688371     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688372     1  0.9773      0.336 0.412 0.352 0.236
#> SRR1688373     1  0.9081      0.585 0.552 0.212 0.236
#> SRR1688374     1  0.5536      0.726 0.752 0.012 0.236
#> SRR1688375     1  0.0000      0.808 1.000 0.000 0.000
#> SRR1688377     1  0.0000      0.808 1.000 0.000 0.000
#> SRR1688378     1  0.0000      0.808 1.000 0.000 0.000
#> SRR1688376     1  0.0000      0.808 1.000 0.000 0.000
#> SRR1688380     1  0.0000      0.808 1.000 0.000 0.000
#> SRR1688379     1  0.0000      0.808 1.000 0.000 0.000
#> SRR1688381     1  0.4974      0.729 0.764 0.000 0.236
#> SRR1688382     1  0.4974      0.729 0.764 0.000 0.236
#> SRR1688383     1  0.4974      0.729 0.764 0.000 0.236
#> SRR1688384     1  0.0000      0.808 1.000 0.000 0.000
#> SRR1688385     1  0.0000      0.808 1.000 0.000 0.000
#> SRR1688386     1  0.0000      0.808 1.000 0.000 0.000
#> SRR1688387     1  0.0000      0.808 1.000 0.000 0.000
#> SRR1688388     1  0.0000      0.808 1.000 0.000 0.000
#> SRR1688389     1  0.0000      0.808 1.000 0.000 0.000
#> SRR1688390     1  0.0000      0.808 1.000 0.000 0.000
#> SRR1688391     1  0.0000      0.808 1.000 0.000 0.000
#> SRR1688392     1  0.0000      0.808 1.000 0.000 0.000
#> SRR1688393     3  0.4974      1.000 0.236 0.000 0.764
#> SRR1688395     3  0.4974      1.000 0.236 0.000 0.764
#> SRR1688394     3  0.4974      1.000 0.236 0.000 0.764
#> SRR1688397     3  0.4974      1.000 0.236 0.000 0.764
#> SRR1688398     3  0.4974      1.000 0.236 0.000 0.764
#> SRR1688396     3  0.4974      1.000 0.236 0.000 0.764
#> SRR1688399     3  0.4974      1.000 0.236 0.000 0.764
#> SRR1688400     3  0.4974      1.000 0.236 0.000 0.764
#> SRR1688402     3  0.4974      1.000 0.236 0.000 0.764
#> SRR1688401     3  0.4974      1.000 0.236 0.000 0.764
#> SRR1688403     3  0.4974      1.000 0.236 0.000 0.764
#> SRR1688404     3  0.4974      1.000 0.236 0.000 0.764
#> SRR1688405     1  0.1753      0.763 0.952 0.000 0.048
#> SRR1688407     1  0.0592      0.797 0.988 0.000 0.012
#> SRR1688408     3  0.4974      1.000 0.236 0.000 0.764
#> SRR1688406     1  0.0892      0.790 0.980 0.000 0.020
#> SRR1688410     3  0.4974      1.000 0.236 0.000 0.764
#> SRR1688411     1  0.9213      0.564 0.536 0.228 0.236
#> SRR1688409     3  0.4974      1.000 0.236 0.000 0.764
#> SRR1688412     1  0.9543      0.483 0.484 0.280 0.236
#> SRR1688413     1  0.9273      0.553 0.528 0.236 0.236
#> SRR1688414     1  0.7458      0.693 0.676 0.088 0.236
#> SRR1688415     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688416     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688417     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688418     2  0.0000      0.999 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1688357     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR1688358     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR1688359     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR1688360     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR1688361     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR1688362     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR1688363     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR1688365     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR1688364     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR1688366     2  0.0921      0.954 0.000 0.972 0.000 0.028
#> SRR1688367     2  0.4543      0.526 0.000 0.676 0.000 0.324
#> SRR1688368     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688370     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR1688369     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR1688371     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR1688372     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688373     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688374     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688375     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688377     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688378     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688376     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688380     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688381     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688382     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688383     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688384     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688385     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688386     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688387     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688388     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688389     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688390     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688405     1  0.3123      0.809 0.844 0.000 0.156 0.000
#> SRR1688407     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688406     1  0.0469      0.979 0.988 0.000 0.012 0.000
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688411     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688412     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688413     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688414     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688415     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR1688416     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR1688417     2  0.0000      0.979 0.000 1.000 0.000 0.000
#> SRR1688418     2  0.0000      0.979 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1688357     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR1688360     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR1688361     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR1688362     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR1688363     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR1688365     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR1688364     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR1688366     2  0.0794      0.954 0.000 0.972 0.000 0.028 0.000
#> SRR1688367     2  0.3913      0.526 0.000 0.676 0.000 0.324 0.000
#> SRR1688368     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1688370     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR1688372     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1688373     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1688374     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1688375     5  0.0000      0.980 0.000 0.000 0.000 0.000 1.000
#> SRR1688377     5  0.0000      0.980 0.000 0.000 0.000 0.000 1.000
#> SRR1688378     1  0.2516      0.839 0.860 0.000 0.000 0.000 0.140
#> SRR1688376     5  0.0000      0.980 0.000 0.000 0.000 0.000 1.000
#> SRR1688380     1  0.4101      0.482 0.628 0.000 0.000 0.000 0.372
#> SRR1688379     1  0.2127      0.865 0.892 0.000 0.000 0.000 0.108
#> SRR1688381     5  0.0000      0.980 0.000 0.000 0.000 0.000 1.000
#> SRR1688382     5  0.0000      0.980 0.000 0.000 0.000 0.000 1.000
#> SRR1688383     5  0.0000      0.980 0.000 0.000 0.000 0.000 1.000
#> SRR1688384     5  0.0000      0.980 0.000 0.000 0.000 0.000 1.000
#> SRR1688385     5  0.0000      0.980 0.000 0.000 0.000 0.000 1.000
#> SRR1688386     5  0.0000      0.980 0.000 0.000 0.000 0.000 1.000
#> SRR1688387     1  0.0000      0.915 1.000 0.000 0.000 0.000 0.000
#> SRR1688388     1  0.0000      0.915 1.000 0.000 0.000 0.000 0.000
#> SRR1688389     1  0.0000      0.915 1.000 0.000 0.000 0.000 0.000
#> SRR1688390     1  0.0000      0.915 1.000 0.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.915 1.000 0.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.915 1.000 0.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688405     5  0.2690      0.788 0.000 0.000 0.156 0.000 0.844
#> SRR1688407     5  0.0000      0.980 0.000 0.000 0.000 0.000 1.000
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688406     5  0.0404      0.969 0.000 0.000 0.012 0.000 0.988
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688411     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688412     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1688413     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1688414     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1688415     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1688357     2  0.0000      0.875 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.875 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.875 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688360     2  0.3464      0.581 0.000 0.688 0.000 0.000 0.312 0.000
#> SRR1688361     2  0.3464      0.581 0.000 0.688 0.000 0.000 0.312 0.000
#> SRR1688362     5  0.3076      0.613 0.000 0.240 0.000 0.000 0.760 0.000
#> SRR1688363     5  0.0000      0.896 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1688365     5  0.0000      0.896 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1688364     5  0.0000      0.896 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1688366     2  0.3888      0.564 0.000 0.672 0.000 0.016 0.312 0.000
#> SRR1688367     2  0.5016      0.437 0.000 0.592 0.000 0.096 0.312 0.000
#> SRR1688368     4  0.3371      0.515 0.000 0.000 0.000 0.708 0.292 0.000
#> SRR1688370     2  0.0000      0.875 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000      0.875 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000      0.875 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688372     4  0.0000      0.950 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688373     4  0.0000      0.950 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688374     4  0.0000      0.950 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688375     6  0.0000      0.980 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688377     6  0.0000      0.980 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688378     1  0.2260      0.817 0.860 0.000 0.000 0.000 0.000 0.140
#> SRR1688376     6  0.0000      0.980 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688380     1  0.3684      0.482 0.628 0.000 0.000 0.000 0.000 0.372
#> SRR1688379     1  0.1910      0.844 0.892 0.000 0.000 0.000 0.000 0.108
#> SRR1688381     6  0.0000      0.980 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688382     6  0.0000      0.980 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688383     6  0.0000      0.980 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688384     6  0.0000      0.980 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688385     6  0.0000      0.980 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688386     6  0.0000      0.980 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688387     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1688388     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1688389     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1688390     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688405     6  0.2416      0.778 0.000 0.000 0.156 0.000 0.000 0.844
#> SRR1688407     6  0.0000      0.980 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688406     6  0.0363      0.968 0.000 0.000 0.012 0.000 0.000 0.988
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688411     4  0.0000      0.950 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688412     4  0.0000      0.950 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688413     4  0.0000      0.950 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688414     4  0.0000      0.950 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688415     2  0.0000      0.875 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.875 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.875 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.875 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-pam-collect-classes

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

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4955 0.505   0.505
#> 3 3 1.000           0.993       0.996         0.3442 0.829   0.661
#> 4 4 1.000           0.936       0.977         0.1015 0.876   0.658
#> 5 5 0.995           0.983       0.986         0.0796 0.937   0.765
#> 6 6 0.989           0.913       0.916         0.0245 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 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
#> SRR1688357     2       0          1  0  1
#> SRR1688358     2       0          1  0  1
#> SRR1688359     2       0          1  0  1
#> SRR1688360     2       0          1  0  1
#> SRR1688361     2       0          1  0  1
#> SRR1688362     2       0          1  0  1
#> SRR1688363     2       0          1  0  1
#> SRR1688365     2       0          1  0  1
#> SRR1688364     2       0          1  0  1
#> SRR1688366     2       0          1  0  1
#> SRR1688367     2       0          1  0  1
#> SRR1688368     2       0          1  0  1
#> SRR1688370     2       0          1  0  1
#> SRR1688369     2       0          1  0  1
#> SRR1688371     2       0          1  0  1
#> SRR1688372     2       0          1  0  1
#> SRR1688373     2       0          1  0  1
#> SRR1688374     2       0          1  0  1
#> SRR1688375     1       0          1  1  0
#> SRR1688377     1       0          1  1  0
#> SRR1688378     1       0          1  1  0
#> SRR1688376     1       0          1  1  0
#> SRR1688380     1       0          1  1  0
#> SRR1688379     1       0          1  1  0
#> SRR1688381     1       0          1  1  0
#> SRR1688382     1       0          1  1  0
#> SRR1688383     1       0          1  1  0
#> SRR1688384     1       0          1  1  0
#> SRR1688385     1       0          1  1  0
#> SRR1688386     1       0          1  1  0
#> SRR1688387     1       0          1  1  0
#> SRR1688388     1       0          1  1  0
#> SRR1688389     1       0          1  1  0
#> SRR1688390     1       0          1  1  0
#> SRR1688391     1       0          1  1  0
#> SRR1688392     1       0          1  1  0
#> SRR1688393     1       0          1  1  0
#> SRR1688395     1       0          1  1  0
#> SRR1688394     1       0          1  1  0
#> SRR1688397     1       0          1  1  0
#> SRR1688398     1       0          1  1  0
#> SRR1688396     1       0          1  1  0
#> SRR1688399     1       0          1  1  0
#> SRR1688400     1       0          1  1  0
#> SRR1688402     1       0          1  1  0
#> SRR1688401     1       0          1  1  0
#> SRR1688403     1       0          1  1  0
#> SRR1688404     1       0          1  1  0
#> SRR1688405     1       0          1  1  0
#> SRR1688407     1       0          1  1  0
#> SRR1688408     1       0          1  1  0
#> SRR1688406     1       0          1  1  0
#> SRR1688410     1       0          1  1  0
#> SRR1688411     2       0          1  0  1
#> SRR1688409     1       0          1  1  0
#> SRR1688412     2       0          1  0  1
#> SRR1688413     2       0          1  0  1
#> SRR1688414     2       0          1  0  1
#> SRR1688415     2       0          1  0  1
#> SRR1688416     2       0          1  0  1
#> SRR1688417     2       0          1  0  1
#> SRR1688418     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1   p2    p3
#> SRR1688357     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688358     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688359     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688360     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688361     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688362     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688363     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688365     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688364     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688366     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688367     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688368     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688370     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688369     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688371     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688372     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688373     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688374     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688375     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688377     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688378     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688376     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688380     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688379     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688381     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688382     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688383     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688384     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688385     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688386     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688387     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688388     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688389     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688390     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688391     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688392     1   0.000      1.000 1.000 0.00 0.000
#> SRR1688393     3   0.000      0.986 0.000 0.00 1.000
#> SRR1688395     3   0.000      0.986 0.000 0.00 1.000
#> SRR1688394     3   0.000      0.986 0.000 0.00 1.000
#> SRR1688397     3   0.000      0.986 0.000 0.00 1.000
#> SRR1688398     3   0.000      0.986 0.000 0.00 1.000
#> SRR1688396     3   0.000      0.986 0.000 0.00 1.000
#> SRR1688399     3   0.000      0.986 0.000 0.00 1.000
#> SRR1688400     3   0.000      0.986 0.000 0.00 1.000
#> SRR1688402     3   0.000      0.986 0.000 0.00 1.000
#> SRR1688401     3   0.000      0.986 0.000 0.00 1.000
#> SRR1688403     3   0.000      0.986 0.000 0.00 1.000
#> SRR1688404     3   0.000      0.986 0.000 0.00 1.000
#> SRR1688405     3   0.305      0.927 0.064 0.02 0.916
#> SRR1688407     3   0.305      0.927 0.064 0.02 0.916
#> SRR1688408     3   0.000      0.986 0.000 0.00 1.000
#> SRR1688406     3   0.305      0.927 0.064 0.02 0.916
#> SRR1688410     3   0.000      0.986 0.000 0.00 1.000
#> SRR1688411     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688409     3   0.000      0.986 0.000 0.00 1.000
#> SRR1688412     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688413     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688414     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688415     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688416     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688417     2   0.000      1.000 0.000 1.00 0.000
#> SRR1688418     2   0.000      1.000 0.000 1.00 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2    p3    p4
#> SRR1688357     2  0.0000      0.920  0 1.000 0.000 0.000
#> SRR1688358     2  0.0000      0.920  0 1.000 0.000 0.000
#> SRR1688359     2  0.0000      0.920  0 1.000 0.000 0.000
#> SRR1688360     2  0.0000      0.920  0 1.000 0.000 0.000
#> SRR1688361     2  0.0000      0.920  0 1.000 0.000 0.000
#> SRR1688362     2  0.0000      0.920  0 1.000 0.000 0.000
#> SRR1688363     2  0.0000      0.920  0 1.000 0.000 0.000
#> SRR1688365     2  0.0000      0.920  0 1.000 0.000 0.000
#> SRR1688364     2  0.0000      0.920  0 1.000 0.000 0.000
#> SRR1688366     2  0.0188      0.917  0 0.996 0.000 0.004
#> SRR1688367     2  0.0188      0.917  0 0.996 0.000 0.004
#> SRR1688368     2  0.0188      0.917  0 0.996 0.000 0.004
#> SRR1688370     2  0.0000      0.920  0 1.000 0.000 0.000
#> SRR1688369     2  0.0000      0.920  0 1.000 0.000 0.000
#> SRR1688371     2  0.0000      0.920  0 1.000 0.000 0.000
#> SRR1688372     4  0.0000      1.000  0 0.000 0.000 1.000
#> SRR1688373     4  0.0000      1.000  0 0.000 0.000 1.000
#> SRR1688374     4  0.0000      1.000  0 0.000 0.000 1.000
#> SRR1688375     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688377     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688378     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688376     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688380     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688379     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688381     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688382     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688383     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688384     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688385     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688386     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688387     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688388     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688389     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688390     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688391     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688392     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1688395     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1688394     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1688397     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1688398     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1688396     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1688399     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1688400     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1688402     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1688401     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1688403     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1688404     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1688405     2  0.4992      0.179  0 0.524 0.476 0.000
#> SRR1688407     2  0.4992      0.179  0 0.524 0.476 0.000
#> SRR1688408     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1688406     2  0.4992      0.179  0 0.524 0.476 0.000
#> SRR1688410     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1688411     4  0.0000      1.000  0 0.000 0.000 1.000
#> SRR1688409     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1688412     4  0.0000      1.000  0 0.000 0.000 1.000
#> SRR1688413     4  0.0000      1.000  0 0.000 0.000 1.000
#> SRR1688414     4  0.0000      1.000  0 0.000 0.000 1.000
#> SRR1688415     2  0.0000      0.920  0 1.000 0.000 0.000
#> SRR1688416     2  0.0000      0.920  0 1.000 0.000 0.000
#> SRR1688417     2  0.0000      0.920  0 1.000 0.000 0.000
#> SRR1688418     2  0.0000      0.920  0 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3 p4    p5
#> SRR1688357     2   0.000      1.000 0.000 1.000 0.000  0 0.000
#> SRR1688358     2   0.000      1.000 0.000 1.000 0.000  0 0.000
#> SRR1688359     2   0.000      1.000 0.000 1.000 0.000  0 0.000
#> SRR1688360     5   0.247      0.905 0.000 0.136 0.000  0 0.864
#> SRR1688361     5   0.247      0.905 0.000 0.136 0.000  0 0.864
#> SRR1688362     5   0.247      0.905 0.000 0.136 0.000  0 0.864
#> SRR1688363     5   0.185      0.926 0.000 0.088 0.000  0 0.912
#> SRR1688365     5   0.185      0.926 0.000 0.088 0.000  0 0.912
#> SRR1688364     5   0.185      0.926 0.000 0.088 0.000  0 0.912
#> SRR1688366     5   0.000      0.919 0.000 0.000 0.000  0 1.000
#> SRR1688367     5   0.000      0.919 0.000 0.000 0.000  0 1.000
#> SRR1688368     5   0.000      0.919 0.000 0.000 0.000  0 1.000
#> SRR1688370     2   0.000      1.000 0.000 1.000 0.000  0 0.000
#> SRR1688369     2   0.000      1.000 0.000 1.000 0.000  0 0.000
#> SRR1688371     2   0.000      1.000 0.000 1.000 0.000  0 0.000
#> SRR1688372     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> SRR1688373     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> SRR1688374     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> SRR1688375     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688377     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688378     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688376     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688380     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688379     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688381     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688382     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688383     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688384     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688385     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688386     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688387     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688388     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688389     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688390     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688391     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688392     1   0.000      1.000 1.000 0.000 0.000  0 0.000
#> SRR1688393     3   0.000      1.000 0.000 0.000 1.000  0 0.000
#> SRR1688395     3   0.000      1.000 0.000 0.000 1.000  0 0.000
#> SRR1688394     3   0.000      1.000 0.000 0.000 1.000  0 0.000
#> SRR1688397     3   0.000      1.000 0.000 0.000 1.000  0 0.000
#> SRR1688398     3   0.000      1.000 0.000 0.000 1.000  0 0.000
#> SRR1688396     3   0.000      1.000 0.000 0.000 1.000  0 0.000
#> SRR1688399     3   0.000      1.000 0.000 0.000 1.000  0 0.000
#> SRR1688400     3   0.000      1.000 0.000 0.000 1.000  0 0.000
#> SRR1688402     3   0.000      1.000 0.000 0.000 1.000  0 0.000
#> SRR1688401     3   0.000      1.000 0.000 0.000 1.000  0 0.000
#> SRR1688403     3   0.000      1.000 0.000 0.000 1.000  0 0.000
#> SRR1688404     3   0.000      1.000 0.000 0.000 1.000  0 0.000
#> SRR1688405     5   0.148      0.908 0.008 0.000 0.048  0 0.944
#> SRR1688407     5   0.148      0.908 0.008 0.000 0.048  0 0.944
#> SRR1688408     3   0.000      1.000 0.000 0.000 1.000  0 0.000
#> SRR1688406     5   0.148      0.908 0.008 0.000 0.048  0 0.944
#> SRR1688410     3   0.000      1.000 0.000 0.000 1.000  0 0.000
#> SRR1688411     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> SRR1688409     3   0.000      1.000 0.000 0.000 1.000  0 0.000
#> SRR1688412     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> SRR1688413     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> SRR1688414     4   0.000      1.000 0.000 0.000 0.000  1 0.000
#> SRR1688415     2   0.000      1.000 0.000 1.000 0.000  0 0.000
#> SRR1688416     2   0.000      1.000 0.000 1.000 0.000  0 0.000
#> SRR1688417     2   0.000      1.000 0.000 1.000 0.000  0 0.000
#> SRR1688418     2   0.000      1.000 0.000 1.000 0.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette   p1    p2 p3 p4 p5   p6
#> SRR1688357     2  0.0000      0.994 0.00 1.000  0  0 NA 0.00
#> SRR1688358     2  0.0000      0.994 0.00 1.000  0  0 NA 0.00
#> SRR1688359     2  0.1204      0.941 0.00 0.944  0  0 NA 0.00
#> SRR1688360     6  0.3851      0.672 0.00 0.000  0  0 NA 0.54
#> SRR1688361     6  0.3851      0.672 0.00 0.000  0  0 NA 0.54
#> SRR1688362     6  0.3851      0.672 0.00 0.000  0  0 NA 0.54
#> SRR1688363     6  0.3851      0.672 0.00 0.000  0  0 NA 0.54
#> SRR1688365     6  0.3851      0.672 0.00 0.000  0  0 NA 0.54
#> SRR1688364     6  0.3851      0.672 0.00 0.000  0  0 NA 0.54
#> SRR1688366     6  0.0000      0.620 0.00 0.000  0  0 NA 1.00
#> SRR1688367     6  0.0000      0.620 0.00 0.000  0  0 NA 1.00
#> SRR1688368     6  0.0000      0.620 0.00 0.000  0  0 NA 1.00
#> SRR1688370     2  0.0000      0.994 0.00 1.000  0  0 NA 0.00
#> SRR1688369     2  0.0000      0.994 0.00 1.000  0  0 NA 0.00
#> SRR1688371     2  0.0000      0.994 0.00 1.000  0  0 NA 0.00
#> SRR1688372     4  0.0000      1.000 0.00 0.000  0  1 NA 0.00
#> SRR1688373     4  0.0000      1.000 0.00 0.000  0  1 NA 0.00
#> SRR1688374     4  0.0000      1.000 0.00 0.000  0  1 NA 0.00
#> SRR1688375     1  0.0937      0.975 0.96 0.000  0  0 NA 0.00
#> SRR1688377     1  0.0937      0.975 0.96 0.000  0  0 NA 0.00
#> SRR1688378     1  0.0000      0.988 1.00 0.000  0  0 NA 0.00
#> SRR1688376     1  0.0937      0.975 0.96 0.000  0  0 NA 0.00
#> SRR1688380     1  0.0000      0.988 1.00 0.000  0  0 NA 0.00
#> SRR1688379     1  0.0000      0.988 1.00 0.000  0  0 NA 0.00
#> SRR1688381     1  0.0000      0.988 1.00 0.000  0  0 NA 0.00
#> SRR1688382     1  0.0000      0.988 1.00 0.000  0  0 NA 0.00
#> SRR1688383     1  0.0000      0.988 1.00 0.000  0  0 NA 0.00
#> SRR1688384     1  0.0000      0.988 1.00 0.000  0  0 NA 0.00
#> SRR1688385     1  0.0000      0.988 1.00 0.000  0  0 NA 0.00
#> SRR1688386     1  0.0000      0.988 1.00 0.000  0  0 NA 0.00
#> SRR1688387     1  0.0937      0.975 0.96 0.000  0  0 NA 0.00
#> SRR1688388     1  0.0937      0.975 0.96 0.000  0  0 NA 0.00
#> SRR1688389     1  0.0937      0.975 0.96 0.000  0  0 NA 0.00
#> SRR1688390     1  0.0000      0.988 1.00 0.000  0  0 NA 0.00
#> SRR1688391     1  0.0000      0.988 1.00 0.000  0  0 NA 0.00
#> SRR1688392     1  0.0000      0.988 1.00 0.000  0  0 NA 0.00
#> SRR1688393     3  0.0000      1.000 0.00 0.000  1  0 NA 0.00
#> SRR1688395     3  0.0000      1.000 0.00 0.000  1  0 NA 0.00
#> SRR1688394     3  0.0000      1.000 0.00 0.000  1  0 NA 0.00
#> SRR1688397     3  0.0000      1.000 0.00 0.000  1  0 NA 0.00
#> SRR1688398     3  0.0000      1.000 0.00 0.000  1  0 NA 0.00
#> SRR1688396     3  0.0000      1.000 0.00 0.000  1  0 NA 0.00
#> SRR1688399     3  0.0000      1.000 0.00 0.000  1  0 NA 0.00
#> SRR1688400     3  0.0000      1.000 0.00 0.000  1  0 NA 0.00
#> SRR1688402     3  0.0000      1.000 0.00 0.000  1  0 NA 0.00
#> SRR1688401     3  0.0000      1.000 0.00 0.000  1  0 NA 0.00
#> SRR1688403     3  0.0000      1.000 0.00 0.000  1  0 NA 0.00
#> SRR1688404     3  0.0000      1.000 0.00 0.000  1  0 NA 0.00
#> SRR1688405     6  0.3869      0.377 0.00 0.000  0  0 NA 0.50
#> SRR1688407     6  0.3869      0.377 0.00 0.000  0  0 NA 0.50
#> SRR1688408     3  0.0000      1.000 0.00 0.000  1  0 NA 0.00
#> SRR1688406     6  0.3869      0.377 0.00 0.000  0  0 NA 0.50
#> SRR1688410     3  0.0000      1.000 0.00 0.000  1  0 NA 0.00
#> SRR1688411     4  0.0000      1.000 0.00 0.000  0  1 NA 0.00
#> SRR1688409     3  0.0000      1.000 0.00 0.000  1  0 NA 0.00
#> SRR1688412     4  0.0000      1.000 0.00 0.000  0  1 NA 0.00
#> SRR1688413     4  0.0000      1.000 0.00 0.000  0  1 NA 0.00
#> SRR1688414     4  0.0000      1.000 0.00 0.000  0  1 NA 0.00
#> SRR1688415     2  0.0000      0.994 0.00 1.000  0  0 NA 0.00
#> SRR1688416     2  0.0000      0.994 0.00 1.000  0  0 NA 0.00
#> SRR1688417     2  0.0000      0.994 0.00 1.000  0  0 NA 0.00
#> SRR1688418     2  0.0000      0.994 0.00 1.000  0  0 NA 0.00

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

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.972       0.975         0.4960 0.505   0.505
#> 3 3 0.916           0.978       0.986         0.3450 0.829   0.661
#> 4 4 1.000           0.993       0.996         0.1144 0.924   0.772
#> 5 5 0.842           0.733       0.870         0.0569 0.970   0.885
#> 6 6 0.869           0.792       0.873         0.0468 0.947   0.776

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1688357     2  0.0000      0.977 0.000 1.000
#> SRR1688358     2  0.0000      0.977 0.000 1.000
#> SRR1688359     2  0.0000      0.977 0.000 1.000
#> SRR1688360     2  0.0000      0.977 0.000 1.000
#> SRR1688361     2  0.0000      0.977 0.000 1.000
#> SRR1688362     2  0.0000      0.977 0.000 1.000
#> SRR1688363     2  0.0938      0.976 0.012 0.988
#> SRR1688365     2  0.2236      0.973 0.036 0.964
#> SRR1688364     2  0.2043      0.974 0.032 0.968
#> SRR1688366     2  0.1843      0.975 0.028 0.972
#> SRR1688367     2  0.2236      0.973 0.036 0.964
#> SRR1688368     2  0.2778      0.968 0.048 0.952
#> SRR1688370     2  0.0000      0.977 0.000 1.000
#> SRR1688369     2  0.0000      0.977 0.000 1.000
#> SRR1688371     2  0.0000      0.977 0.000 1.000
#> SRR1688372     2  0.3114      0.965 0.056 0.944
#> SRR1688373     2  0.3114      0.965 0.056 0.944
#> SRR1688374     2  0.3114      0.965 0.056 0.944
#> SRR1688375     1  0.0000      0.972 1.000 0.000
#> SRR1688377     1  0.0000      0.972 1.000 0.000
#> SRR1688378     1  0.0000      0.972 1.000 0.000
#> SRR1688376     1  0.0000      0.972 1.000 0.000
#> SRR1688380     1  0.0000      0.972 1.000 0.000
#> SRR1688379     1  0.0000      0.972 1.000 0.000
#> SRR1688381     1  0.0000      0.972 1.000 0.000
#> SRR1688382     1  0.0000      0.972 1.000 0.000
#> SRR1688383     1  0.0000      0.972 1.000 0.000
#> SRR1688384     1  0.0000      0.972 1.000 0.000
#> SRR1688385     1  0.0000      0.972 1.000 0.000
#> SRR1688386     1  0.0000      0.972 1.000 0.000
#> SRR1688387     1  0.0000      0.972 1.000 0.000
#> SRR1688388     1  0.0000      0.972 1.000 0.000
#> SRR1688389     1  0.0000      0.972 1.000 0.000
#> SRR1688390     1  0.0000      0.972 1.000 0.000
#> SRR1688391     1  0.0000      0.972 1.000 0.000
#> SRR1688392     1  0.0000      0.972 1.000 0.000
#> SRR1688393     1  0.3114      0.970 0.944 0.056
#> SRR1688395     1  0.3114      0.970 0.944 0.056
#> SRR1688394     1  0.3114      0.970 0.944 0.056
#> SRR1688397     1  0.3114      0.970 0.944 0.056
#> SRR1688398     1  0.3114      0.970 0.944 0.056
#> SRR1688396     1  0.3114      0.970 0.944 0.056
#> SRR1688399     1  0.3114      0.970 0.944 0.056
#> SRR1688400     1  0.3114      0.970 0.944 0.056
#> SRR1688402     1  0.3114      0.970 0.944 0.056
#> SRR1688401     1  0.3114      0.970 0.944 0.056
#> SRR1688403     1  0.3114      0.970 0.944 0.056
#> SRR1688404     1  0.3114      0.970 0.944 0.056
#> SRR1688405     1  0.2948      0.971 0.948 0.052
#> SRR1688407     1  0.2423      0.971 0.960 0.040
#> SRR1688408     1  0.3114      0.970 0.944 0.056
#> SRR1688406     1  0.2948      0.971 0.948 0.052
#> SRR1688410     1  0.3114      0.970 0.944 0.056
#> SRR1688411     2  0.3114      0.965 0.056 0.944
#> SRR1688409     1  0.3114      0.970 0.944 0.056
#> SRR1688412     2  0.3114      0.965 0.056 0.944
#> SRR1688413     2  0.3114      0.965 0.056 0.944
#> SRR1688414     2  0.3114      0.965 0.056 0.944
#> SRR1688415     2  0.0000      0.977 0.000 1.000
#> SRR1688416     2  0.0000      0.977 0.000 1.000
#> SRR1688417     2  0.0000      0.977 0.000 1.000
#> SRR1688418     2  0.0000      0.977 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2 p3
#> SRR1688357     2  0.0000      0.966 0.000 1.000  0
#> SRR1688358     2  0.0000      0.966 0.000 1.000  0
#> SRR1688359     2  0.0000      0.966 0.000 1.000  0
#> SRR1688360     2  0.0000      0.966 0.000 1.000  0
#> SRR1688361     2  0.0000      0.966 0.000 1.000  0
#> SRR1688362     2  0.0000      0.966 0.000 1.000  0
#> SRR1688363     2  0.0000      0.966 0.000 1.000  0
#> SRR1688365     2  0.0000      0.966 0.000 1.000  0
#> SRR1688364     2  0.0000      0.966 0.000 1.000  0
#> SRR1688366     2  0.0237      0.965 0.004 0.996  0
#> SRR1688367     2  0.0237      0.965 0.004 0.996  0
#> SRR1688368     2  0.1163      0.954 0.028 0.972  0
#> SRR1688370     2  0.0000      0.966 0.000 1.000  0
#> SRR1688369     2  0.0000      0.966 0.000 1.000  0
#> SRR1688371     2  0.0000      0.966 0.000 1.000  0
#> SRR1688372     2  0.3116      0.908 0.108 0.892  0
#> SRR1688373     2  0.3192      0.905 0.112 0.888  0
#> SRR1688374     2  0.3816      0.867 0.148 0.852  0
#> SRR1688375     1  0.0000      1.000 1.000 0.000  0
#> SRR1688377     1  0.0000      1.000 1.000 0.000  0
#> SRR1688378     1  0.0000      1.000 1.000 0.000  0
#> SRR1688376     1  0.0000      1.000 1.000 0.000  0
#> SRR1688380     1  0.0000      1.000 1.000 0.000  0
#> SRR1688379     1  0.0000      1.000 1.000 0.000  0
#> SRR1688381     1  0.0000      1.000 1.000 0.000  0
#> SRR1688382     1  0.0000      1.000 1.000 0.000  0
#> SRR1688383     1  0.0000      1.000 1.000 0.000  0
#> SRR1688384     1  0.0000      1.000 1.000 0.000  0
#> SRR1688385     1  0.0000      1.000 1.000 0.000  0
#> SRR1688386     1  0.0000      1.000 1.000 0.000  0
#> SRR1688387     1  0.0000      1.000 1.000 0.000  0
#> SRR1688388     1  0.0000      1.000 1.000 0.000  0
#> SRR1688389     1  0.0000      1.000 1.000 0.000  0
#> SRR1688390     1  0.0000      1.000 1.000 0.000  0
#> SRR1688391     1  0.0000      1.000 1.000 0.000  0
#> SRR1688392     1  0.0000      1.000 1.000 0.000  0
#> SRR1688393     3  0.0000      1.000 0.000 0.000  1
#> SRR1688395     3  0.0000      1.000 0.000 0.000  1
#> SRR1688394     3  0.0000      1.000 0.000 0.000  1
#> SRR1688397     3  0.0000      1.000 0.000 0.000  1
#> SRR1688398     3  0.0000      1.000 0.000 0.000  1
#> SRR1688396     3  0.0000      1.000 0.000 0.000  1
#> SRR1688399     3  0.0000      1.000 0.000 0.000  1
#> SRR1688400     3  0.0000      1.000 0.000 0.000  1
#> SRR1688402     3  0.0000      1.000 0.000 0.000  1
#> SRR1688401     3  0.0000      1.000 0.000 0.000  1
#> SRR1688403     3  0.0000      1.000 0.000 0.000  1
#> SRR1688404     3  0.0000      1.000 0.000 0.000  1
#> SRR1688405     3  0.0000      1.000 0.000 0.000  1
#> SRR1688407     3  0.0000      1.000 0.000 0.000  1
#> SRR1688408     3  0.0000      1.000 0.000 0.000  1
#> SRR1688406     3  0.0000      1.000 0.000 0.000  1
#> SRR1688410     3  0.0000      1.000 0.000 0.000  1
#> SRR1688411     2  0.3116      0.908 0.108 0.892  0
#> SRR1688409     3  0.0000      1.000 0.000 0.000  1
#> SRR1688412     2  0.3116      0.908 0.108 0.892  0
#> SRR1688413     2  0.3116      0.908 0.108 0.892  0
#> SRR1688414     2  0.3192      0.905 0.112 0.888  0
#> SRR1688415     2  0.0000      0.966 0.000 1.000  0
#> SRR1688416     2  0.0000      0.966 0.000 1.000  0
#> SRR1688417     2  0.0000      0.966 0.000 1.000  0
#> SRR1688418     2  0.0000      0.966 0.000 1.000  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2 p3    p4
#> SRR1688357     2  0.0188      0.988  0 0.996  0 0.004
#> SRR1688358     2  0.0188      0.988  0 0.996  0 0.004
#> SRR1688359     2  0.0188      0.988  0 0.996  0 0.004
#> SRR1688360     2  0.0000      0.987  0 1.000  0 0.000
#> SRR1688361     2  0.0000      0.987  0 1.000  0 0.000
#> SRR1688362     2  0.0000      0.987  0 1.000  0 0.000
#> SRR1688363     2  0.0000      0.987  0 1.000  0 0.000
#> SRR1688365     2  0.0000      0.987  0 1.000  0 0.000
#> SRR1688364     2  0.0000      0.987  0 1.000  0 0.000
#> SRR1688366     2  0.1389      0.950  0 0.952  0 0.048
#> SRR1688367     2  0.2868      0.852  0 0.864  0 0.136
#> SRR1688368     4  0.0469      0.988  0 0.012  0 0.988
#> SRR1688370     2  0.0188      0.988  0 0.996  0 0.004
#> SRR1688369     2  0.0188      0.988  0 0.996  0 0.004
#> SRR1688371     2  0.0188      0.988  0 0.996  0 0.004
#> SRR1688372     4  0.0000      0.998  0 0.000  0 1.000
#> SRR1688373     4  0.0000      0.998  0 0.000  0 1.000
#> SRR1688374     4  0.0000      0.998  0 0.000  0 1.000
#> SRR1688375     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688377     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688378     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688376     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688380     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688379     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688381     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688382     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688383     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688384     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688385     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688386     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688387     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688388     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688389     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688390     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688391     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688392     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1688393     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688395     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688394     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688397     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688398     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688396     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688399     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688400     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688402     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688401     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688403     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688404     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688405     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688407     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688408     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688406     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688410     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688411     4  0.0000      0.998  0 0.000  0 1.000
#> SRR1688409     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1688412     4  0.0000      0.998  0 0.000  0 1.000
#> SRR1688413     4  0.0000      0.998  0 0.000  0 1.000
#> SRR1688414     4  0.0000      0.998  0 0.000  0 1.000
#> SRR1688415     2  0.0188      0.988  0 0.996  0 0.004
#> SRR1688416     2  0.0188      0.988  0 0.996  0 0.004
#> SRR1688417     2  0.0188      0.988  0 0.996  0 0.004
#> SRR1688418     2  0.0188      0.988  0 0.996  0 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
#> SRR1688357     2  0.0000     0.8132 0.000 1.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000     0.8132 0.000 1.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000     0.8132 0.000 1.000 0.000 0.000 0.000
#> SRR1688360     2  0.4171     0.3207 0.000 0.604 0.000 0.000 0.396
#> SRR1688361     2  0.4182     0.3121 0.000 0.600 0.000 0.000 0.400
#> SRR1688362     2  0.4201     0.2930 0.000 0.592 0.000 0.000 0.408
#> SRR1688363     5  0.6033     0.8954 0.200 0.220 0.000 0.000 0.580
#> SRR1688365     5  0.6036     0.8924 0.208 0.212 0.000 0.000 0.580
#> SRR1688364     5  0.6033     0.8954 0.200 0.220 0.000 0.000 0.580
#> SRR1688366     2  0.7628    -0.6840 0.220 0.392 0.000 0.056 0.332
#> SRR1688367     5  0.8141     0.6877 0.220 0.292 0.000 0.116 0.372
#> SRR1688368     4  0.6255     0.0443 0.208 0.000 0.000 0.540 0.252
#> SRR1688370     2  0.0000     0.8132 0.000 1.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000     0.8132 0.000 1.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000     0.8132 0.000 1.000 0.000 0.000 0.000
#> SRR1688372     4  0.0000     0.9222 0.000 0.000 0.000 1.000 0.000
#> SRR1688373     4  0.0000     0.9222 0.000 0.000 0.000 1.000 0.000
#> SRR1688374     4  0.0000     0.9222 0.000 0.000 0.000 1.000 0.000
#> SRR1688375     1  0.1851     0.7275 0.912 0.000 0.000 0.000 0.088
#> SRR1688377     1  0.0794     0.7618 0.972 0.000 0.000 0.000 0.028
#> SRR1688378     1  0.3366     0.8010 0.768 0.000 0.000 0.000 0.232
#> SRR1688376     1  0.1908     0.7238 0.908 0.000 0.000 0.000 0.092
#> SRR1688380     1  0.3366     0.8010 0.768 0.000 0.000 0.000 0.232
#> SRR1688379     1  0.3366     0.8010 0.768 0.000 0.000 0.000 0.232
#> SRR1688381     1  0.1197     0.7554 0.952 0.000 0.000 0.000 0.048
#> SRR1688382     1  0.1270     0.7536 0.948 0.000 0.000 0.000 0.052
#> SRR1688383     1  0.1270     0.7536 0.948 0.000 0.000 0.000 0.052
#> SRR1688384     1  0.2471     0.6789 0.864 0.000 0.000 0.000 0.136
#> SRR1688385     1  0.2648     0.6581 0.848 0.000 0.000 0.000 0.152
#> SRR1688386     1  0.2471     0.6789 0.864 0.000 0.000 0.000 0.136
#> SRR1688387     1  0.3366     0.8010 0.768 0.000 0.000 0.000 0.232
#> SRR1688388     1  0.3366     0.8010 0.768 0.000 0.000 0.000 0.232
#> SRR1688389     1  0.3366     0.8010 0.768 0.000 0.000 0.000 0.232
#> SRR1688390     1  0.3366     0.8010 0.768 0.000 0.000 0.000 0.232
#> SRR1688391     1  0.3366     0.8010 0.768 0.000 0.000 0.000 0.232
#> SRR1688392     1  0.3366     0.8010 0.768 0.000 0.000 0.000 0.232
#> SRR1688393     3  0.0609     0.8850 0.000 0.000 0.980 0.000 0.020
#> SRR1688395     3  0.0609     0.8850 0.000 0.000 0.980 0.000 0.020
#> SRR1688394     3  0.0609     0.8850 0.000 0.000 0.980 0.000 0.020
#> SRR1688397     3  0.0510     0.8863 0.000 0.000 0.984 0.000 0.016
#> SRR1688398     3  0.0290     0.8881 0.000 0.000 0.992 0.000 0.008
#> SRR1688396     3  0.0510     0.8863 0.000 0.000 0.984 0.000 0.016
#> SRR1688399     3  0.0000     0.8892 0.000 0.000 1.000 0.000 0.000
#> SRR1688400     3  0.0000     0.8892 0.000 0.000 1.000 0.000 0.000
#> SRR1688402     3  0.0000     0.8892 0.000 0.000 1.000 0.000 0.000
#> SRR1688401     3  0.0000     0.8892 0.000 0.000 1.000 0.000 0.000
#> SRR1688403     3  0.0000     0.8892 0.000 0.000 1.000 0.000 0.000
#> SRR1688404     3  0.0000     0.8892 0.000 0.000 1.000 0.000 0.000
#> SRR1688405     3  0.6582     0.0557 0.208 0.000 0.416 0.000 0.376
#> SRR1688407     3  0.6584     0.0448 0.208 0.000 0.412 0.000 0.380
#> SRR1688408     3  0.0000     0.8892 0.000 0.000 1.000 0.000 0.000
#> SRR1688406     3  0.6582     0.0557 0.208 0.000 0.416 0.000 0.376
#> SRR1688410     3  0.0000     0.8892 0.000 0.000 1.000 0.000 0.000
#> SRR1688411     4  0.0000     0.9222 0.000 0.000 0.000 1.000 0.000
#> SRR1688409     3  0.0000     0.8892 0.000 0.000 1.000 0.000 0.000
#> SRR1688412     4  0.0000     0.9222 0.000 0.000 0.000 1.000 0.000
#> SRR1688413     4  0.0000     0.9222 0.000 0.000 0.000 1.000 0.000
#> SRR1688414     4  0.0000     0.9222 0.000 0.000 0.000 1.000 0.000
#> SRR1688415     2  0.0000     0.8132 0.000 1.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000     0.8132 0.000 1.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000     0.8132 0.000 1.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000     0.8132 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1688357     2  0.0000     0.8858 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000     0.8858 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000     0.8858 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688360     5  0.2597     0.9294 0.000 0.176 0.000 0.000 0.824 0.000
#> SRR1688361     5  0.2597     0.9294 0.000 0.176 0.000 0.000 0.824 0.000
#> SRR1688362     5  0.2562     0.9311 0.000 0.172 0.000 0.000 0.828 0.000
#> SRR1688363     5  0.3049     0.9321 0.048 0.104 0.000 0.000 0.844 0.004
#> SRR1688365     5  0.3065     0.9272 0.052 0.100 0.000 0.000 0.844 0.004
#> SRR1688364     5  0.3049     0.9321 0.048 0.104 0.000 0.000 0.844 0.004
#> SRR1688366     2  0.6623     0.1842 0.056 0.528 0.000 0.120 0.276 0.020
#> SRR1688367     2  0.7972    -0.1459 0.080 0.328 0.000 0.264 0.276 0.052
#> SRR1688368     4  0.3031     0.8120 0.044 0.000 0.000 0.844 0.108 0.004
#> SRR1688370     2  0.0000     0.8858 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000     0.8858 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000     0.8858 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688372     4  0.0000     0.9754 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688373     4  0.0000     0.9754 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688374     4  0.0000     0.9754 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688375     1  0.1341     0.5638 0.948 0.000 0.000 0.000 0.028 0.024
#> SRR1688377     1  0.1168     0.5662 0.956 0.000 0.000 0.000 0.016 0.028
#> SRR1688378     1  0.3756     0.6904 0.600 0.000 0.000 0.000 0.000 0.400
#> SRR1688376     1  0.1408     0.5575 0.944 0.000 0.000 0.000 0.020 0.036
#> SRR1688380     1  0.3756     0.6904 0.600 0.000 0.000 0.000 0.000 0.400
#> SRR1688379     1  0.3756     0.6904 0.600 0.000 0.000 0.000 0.000 0.400
#> SRR1688381     1  0.0146     0.5903 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1688382     1  0.0291     0.5877 0.992 0.000 0.000 0.000 0.004 0.004
#> SRR1688383     1  0.0146     0.5903 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1688384     1  0.3445     0.1340 0.732 0.000 0.000 0.000 0.008 0.260
#> SRR1688385     1  0.3575     0.0617 0.708 0.000 0.000 0.000 0.008 0.284
#> SRR1688386     1  0.3555     0.0751 0.712 0.000 0.000 0.000 0.008 0.280
#> SRR1688387     1  0.4326     0.6813 0.572 0.000 0.000 0.000 0.024 0.404
#> SRR1688388     1  0.4326     0.6813 0.572 0.000 0.000 0.000 0.024 0.404
#> SRR1688389     1  0.4326     0.6813 0.572 0.000 0.000 0.000 0.024 0.404
#> SRR1688390     1  0.3765     0.6896 0.596 0.000 0.000 0.000 0.000 0.404
#> SRR1688391     1  0.3765     0.6896 0.596 0.000 0.000 0.000 0.000 0.404
#> SRR1688392     1  0.3765     0.6896 0.596 0.000 0.000 0.000 0.000 0.404
#> SRR1688393     3  0.2277     0.9147 0.000 0.000 0.892 0.000 0.032 0.076
#> SRR1688395     3  0.2277     0.9147 0.000 0.000 0.892 0.000 0.032 0.076
#> SRR1688394     3  0.2277     0.9147 0.000 0.000 0.892 0.000 0.032 0.076
#> SRR1688397     3  0.1845     0.9307 0.000 0.000 0.920 0.000 0.028 0.052
#> SRR1688398     3  0.1176     0.9445 0.000 0.000 0.956 0.000 0.024 0.020
#> SRR1688396     3  0.2046     0.9246 0.000 0.000 0.908 0.000 0.032 0.060
#> SRR1688399     3  0.0146     0.9537 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1688400     3  0.0000     0.9540 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688402     3  0.0146     0.9537 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1688401     3  0.0000     0.9540 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688403     3  0.0146     0.9537 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1688404     3  0.0146     0.9537 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1688405     6  0.6018     0.9832 0.220 0.000 0.064 0.000 0.124 0.592
#> SRR1688407     6  0.5892     0.9762 0.236 0.000 0.048 0.000 0.124 0.592
#> SRR1688408     3  0.0632     0.9468 0.000 0.000 0.976 0.000 0.024 0.000
#> SRR1688406     6  0.5989     0.9864 0.224 0.000 0.060 0.000 0.124 0.592
#> SRR1688410     3  0.0632     0.9468 0.000 0.000 0.976 0.000 0.024 0.000
#> SRR1688411     4  0.0000     0.9754 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688409     3  0.0632     0.9468 0.000 0.000 0.976 0.000 0.024 0.000
#> SRR1688412     4  0.0000     0.9754 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688413     4  0.0000     0.9754 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688414     4  0.0000     0.9754 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688415     2  0.0000     0.8858 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000     0.8858 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000     0.8858 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000     0.8858 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-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 16435 rows and 62 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           0.999       0.999         0.4189 0.581   0.581
#> 3 3 1.000           0.998       0.999         0.5497 0.770   0.604
#> 4 4 1.000           0.998       0.999         0.0664 0.957   0.878
#> 5 5 1.000           0.987       0.986         0.0218 0.990   0.969
#> 6 6 0.852           0.948       0.930         0.0388 0.990   0.968

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1688357     2  0.0000      1.000 0.000 1.000
#> SRR1688358     2  0.0000      1.000 0.000 1.000
#> SRR1688359     2  0.0000      1.000 0.000 1.000
#> SRR1688360     2  0.0000      1.000 0.000 1.000
#> SRR1688361     2  0.0000      1.000 0.000 1.000
#> SRR1688362     2  0.0000      1.000 0.000 1.000
#> SRR1688363     2  0.0000      1.000 0.000 1.000
#> SRR1688365     2  0.0000      1.000 0.000 1.000
#> SRR1688364     2  0.0000      1.000 0.000 1.000
#> SRR1688366     2  0.0000      1.000 0.000 1.000
#> SRR1688367     2  0.0000      1.000 0.000 1.000
#> SRR1688368     2  0.0000      1.000 0.000 1.000
#> SRR1688370     2  0.0000      1.000 0.000 1.000
#> SRR1688369     2  0.0000      1.000 0.000 1.000
#> SRR1688371     2  0.0000      1.000 0.000 1.000
#> SRR1688372     2  0.0000      1.000 0.000 1.000
#> SRR1688373     2  0.0000      1.000 0.000 1.000
#> SRR1688374     2  0.0000      1.000 0.000 1.000
#> SRR1688375     1  0.0376      0.998 0.996 0.004
#> SRR1688377     1  0.0376      0.998 0.996 0.004
#> SRR1688378     1  0.0000      0.998 1.000 0.000
#> SRR1688376     1  0.0376      0.998 0.996 0.004
#> SRR1688380     1  0.0000      0.998 1.000 0.000
#> SRR1688379     1  0.0000      0.998 1.000 0.000
#> SRR1688381     1  0.0376      0.998 0.996 0.004
#> SRR1688382     1  0.0376      0.998 0.996 0.004
#> SRR1688383     1  0.0376      0.998 0.996 0.004
#> SRR1688384     1  0.0376      0.998 0.996 0.004
#> SRR1688385     1  0.0376      0.998 0.996 0.004
#> SRR1688386     1  0.0376      0.998 0.996 0.004
#> SRR1688387     1  0.0000      0.998 1.000 0.000
#> SRR1688388     1  0.0000      0.998 1.000 0.000
#> SRR1688389     1  0.0000      0.998 1.000 0.000
#> SRR1688390     1  0.0000      0.998 1.000 0.000
#> SRR1688391     1  0.0000      0.998 1.000 0.000
#> SRR1688392     1  0.0000      0.998 1.000 0.000
#> SRR1688393     2  0.0000      1.000 0.000 1.000
#> SRR1688395     2  0.0000      1.000 0.000 1.000
#> SRR1688394     2  0.0000      1.000 0.000 1.000
#> SRR1688397     2  0.0000      1.000 0.000 1.000
#> SRR1688398     2  0.0000      1.000 0.000 1.000
#> SRR1688396     2  0.0000      1.000 0.000 1.000
#> SRR1688399     2  0.0000      1.000 0.000 1.000
#> SRR1688400     2  0.0000      1.000 0.000 1.000
#> SRR1688402     2  0.0000      1.000 0.000 1.000
#> SRR1688401     2  0.0000      1.000 0.000 1.000
#> SRR1688403     2  0.0000      1.000 0.000 1.000
#> SRR1688404     2  0.0000      1.000 0.000 1.000
#> SRR1688405     2  0.0000      1.000 0.000 1.000
#> SRR1688407     2  0.0000      1.000 0.000 1.000
#> SRR1688408     2  0.0000      1.000 0.000 1.000
#> SRR1688406     2  0.0000      1.000 0.000 1.000
#> SRR1688410     2  0.0000      1.000 0.000 1.000
#> SRR1688411     2  0.0000      1.000 0.000 1.000
#> SRR1688409     2  0.0000      1.000 0.000 1.000
#> SRR1688412     2  0.0000      1.000 0.000 1.000
#> SRR1688413     2  0.0000      1.000 0.000 1.000
#> SRR1688414     2  0.0000      1.000 0.000 1.000
#> SRR1688415     2  0.0000      1.000 0.000 1.000
#> SRR1688416     2  0.0000      1.000 0.000 1.000
#> SRR1688417     2  0.0000      1.000 0.000 1.000
#> SRR1688418     2  0.0000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688358     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688359     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688360     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688361     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688362     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688363     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688365     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688364     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688366     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688367     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688368     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688370     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688369     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688371     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688372     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688373     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688374     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688375     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1688377     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1688378     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1688376     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1688380     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1688379     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1688381     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1688382     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1688383     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1688384     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1688385     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1688386     1  0.0237      0.997 0.996 0.004 0.000
#> SRR1688387     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1688388     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1688389     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1688390     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1688391     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1688392     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688405     2  0.0747      0.985 0.000 0.984 0.016
#> SRR1688407     2  0.0747      0.985 0.000 0.984 0.016
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688406     2  0.0747      0.985 0.000 0.984 0.016
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688411     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688412     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688413     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688414     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688415     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688416     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688417     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1688418     2  0.0000      0.998 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2    p3 p4
#> SRR1688357     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688358     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688359     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688360     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688361     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688362     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688363     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688365     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688364     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688366     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688367     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688368     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688370     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688369     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688371     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688372     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688373     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688374     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688375     1  0.0000      1.000  1 0.000 0.000  0
#> SRR1688377     1  0.0000      1.000  1 0.000 0.000  0
#> SRR1688378     4  0.0000      1.000  0 0.000 0.000  1
#> SRR1688376     1  0.0000      1.000  1 0.000 0.000  0
#> SRR1688380     4  0.0000      1.000  0 0.000 0.000  1
#> SRR1688379     4  0.0000      1.000  0 0.000 0.000  1
#> SRR1688381     1  0.0000      1.000  1 0.000 0.000  0
#> SRR1688382     1  0.0000      1.000  1 0.000 0.000  0
#> SRR1688383     1  0.0000      1.000  1 0.000 0.000  0
#> SRR1688384     1  0.0000      1.000  1 0.000 0.000  0
#> SRR1688385     1  0.0000      1.000  1 0.000 0.000  0
#> SRR1688386     1  0.0000      1.000  1 0.000 0.000  0
#> SRR1688387     4  0.0000      1.000  0 0.000 0.000  1
#> SRR1688388     4  0.0000      1.000  0 0.000 0.000  1
#> SRR1688389     4  0.0000      1.000  0 0.000 0.000  1
#> SRR1688390     4  0.0000      1.000  0 0.000 0.000  1
#> SRR1688391     4  0.0000      1.000  0 0.000 0.000  1
#> SRR1688392     4  0.0000      1.000  0 0.000 0.000  1
#> SRR1688393     3  0.0000      1.000  0 0.000 1.000  0
#> SRR1688395     3  0.0000      1.000  0 0.000 1.000  0
#> SRR1688394     3  0.0000      1.000  0 0.000 1.000  0
#> SRR1688397     3  0.0000      1.000  0 0.000 1.000  0
#> SRR1688398     3  0.0000      1.000  0 0.000 1.000  0
#> SRR1688396     3  0.0000      1.000  0 0.000 1.000  0
#> SRR1688399     3  0.0000      1.000  0 0.000 1.000  0
#> SRR1688400     3  0.0000      1.000  0 0.000 1.000  0
#> SRR1688402     3  0.0000      1.000  0 0.000 1.000  0
#> SRR1688401     3  0.0000      1.000  0 0.000 1.000  0
#> SRR1688403     3  0.0000      1.000  0 0.000 1.000  0
#> SRR1688404     3  0.0000      1.000  0 0.000 1.000  0
#> SRR1688405     2  0.0592      0.984  0 0.984 0.016  0
#> SRR1688407     2  0.0592      0.984  0 0.984 0.016  0
#> SRR1688408     3  0.0000      1.000  0 0.000 1.000  0
#> SRR1688406     2  0.0592      0.984  0 0.984 0.016  0
#> SRR1688410     3  0.0000      1.000  0 0.000 1.000  0
#> SRR1688411     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688409     3  0.0000      1.000  0 0.000 1.000  0
#> SRR1688412     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688413     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688414     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688415     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688416     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688417     2  0.0000      0.998  0 1.000 0.000  0
#> SRR1688418     2  0.0000      0.998  0 1.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2    p3    p4    p5
#> SRR1688357     2  0.1121      0.971  0 0.956 0.000 0.000 0.044
#> SRR1688358     2  0.1121      0.971  0 0.956 0.000 0.000 0.044
#> SRR1688359     2  0.1121      0.971  0 0.956 0.000 0.000 0.044
#> SRR1688360     2  0.0000      0.977  0 1.000 0.000 0.000 0.000
#> SRR1688361     2  0.0000      0.977  0 1.000 0.000 0.000 0.000
#> SRR1688362     2  0.0000      0.977  0 1.000 0.000 0.000 0.000
#> SRR1688363     2  0.0000      0.977  0 1.000 0.000 0.000 0.000
#> SRR1688365     2  0.0000      0.977  0 1.000 0.000 0.000 0.000
#> SRR1688364     2  0.0000      0.977  0 1.000 0.000 0.000 0.000
#> SRR1688366     2  0.0703      0.977  0 0.976 0.000 0.000 0.024
#> SRR1688367     2  0.0703      0.977  0 0.976 0.000 0.000 0.024
#> SRR1688368     2  0.0703      0.977  0 0.976 0.000 0.000 0.024
#> SRR1688370     2  0.1121      0.971  0 0.956 0.000 0.000 0.044
#> SRR1688369     2  0.1121      0.971  0 0.956 0.000 0.000 0.044
#> SRR1688371     2  0.1121      0.971  0 0.956 0.000 0.000 0.044
#> SRR1688372     2  0.0609      0.972  0 0.980 0.000 0.000 0.020
#> SRR1688373     2  0.0609      0.972  0 0.980 0.000 0.000 0.020
#> SRR1688374     2  0.0609      0.972  0 0.980 0.000 0.000 0.020
#> SRR1688375     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688377     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688378     5  0.1478      1.000  0 0.000 0.000 0.064 0.936
#> SRR1688376     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688380     5  0.1478      1.000  0 0.000 0.000 0.064 0.936
#> SRR1688379     5  0.1478      1.000  0 0.000 0.000 0.064 0.936
#> SRR1688381     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688382     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688383     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688384     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688385     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688386     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688387     4  0.0000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1688388     4  0.0000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1688389     4  0.0000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1688390     4  0.0000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1688391     4  0.0000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1688392     4  0.0000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1688393     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1688395     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1688394     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1688397     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1688398     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1688396     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1688399     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1688400     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1688402     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1688401     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1688403     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1688404     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1688405     2  0.0510      0.971  0 0.984 0.016 0.000 0.000
#> SRR1688407     2  0.0510      0.971  0 0.984 0.016 0.000 0.000
#> SRR1688408     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1688406     2  0.0510      0.971  0 0.984 0.016 0.000 0.000
#> SRR1688410     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1688411     2  0.0609      0.972  0 0.980 0.000 0.000 0.020
#> SRR1688409     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1688412     2  0.0609      0.972  0 0.980 0.000 0.000 0.020
#> SRR1688413     2  0.0609      0.972  0 0.980 0.000 0.000 0.020
#> SRR1688414     2  0.0609      0.972  0 0.980 0.000 0.000 0.020
#> SRR1688415     2  0.1121      0.971  0 0.956 0.000 0.000 0.044
#> SRR1688416     2  0.1121      0.971  0 0.956 0.000 0.000 0.044
#> SRR1688417     2  0.1121      0.971  0 0.956 0.000 0.000 0.044
#> SRR1688418     2  0.1121      0.971  0 0.956 0.000 0.000 0.044

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3 p4 p5    p6
#> SRR1688357     2   0.222      0.880 0.000 0.864 0.000  0  0 0.136
#> SRR1688358     2   0.222      0.880 0.000 0.864 0.000  0  0 0.136
#> SRR1688359     2   0.222      0.880 0.000 0.864 0.000  0  0 0.136
#> SRR1688360     2   0.000      0.908 0.000 1.000 0.000  0  0 0.000
#> SRR1688361     2   0.000      0.908 0.000 1.000 0.000  0  0 0.000
#> SRR1688362     2   0.000      0.908 0.000 1.000 0.000  0  0 0.000
#> SRR1688363     2   0.026      0.908 0.000 0.992 0.000  0  0 0.008
#> SRR1688365     2   0.026      0.908 0.000 0.992 0.000  0  0 0.008
#> SRR1688364     2   0.026      0.908 0.000 0.992 0.000  0  0 0.008
#> SRR1688366     2   0.120      0.908 0.000 0.944 0.000  0  0 0.056
#> SRR1688367     2   0.120      0.908 0.000 0.944 0.000  0  0 0.056
#> SRR1688368     2   0.120      0.908 0.000 0.944 0.000  0  0 0.056
#> SRR1688370     2   0.222      0.880 0.000 0.864 0.000  0  0 0.136
#> SRR1688369     2   0.222      0.880 0.000 0.864 0.000  0  0 0.136
#> SRR1688371     2   0.222      0.880 0.000 0.864 0.000  0  0 0.136
#> SRR1688372     2   0.214      0.874 0.000 0.872 0.000  0  0 0.128
#> SRR1688373     2   0.214      0.874 0.000 0.872 0.000  0  0 0.128
#> SRR1688374     2   0.214      0.874 0.000 0.872 0.000  0  0 0.128
#> SRR1688375     6   0.322      1.000 0.264 0.000 0.000  0  0 0.736
#> SRR1688377     6   0.322      1.000 0.264 0.000 0.000  0  0 0.736
#> SRR1688378     5   0.000      1.000 0.000 0.000 0.000  0  1 0.000
#> SRR1688376     6   0.322      1.000 0.264 0.000 0.000  0  0 0.736
#> SRR1688380     5   0.000      1.000 0.000 0.000 0.000  0  1 0.000
#> SRR1688379     5   0.000      1.000 0.000 0.000 0.000  0  1 0.000
#> SRR1688381     1   0.000      1.000 1.000 0.000 0.000  0  0 0.000
#> SRR1688382     1   0.000      1.000 1.000 0.000 0.000  0  0 0.000
#> SRR1688383     1   0.000      1.000 1.000 0.000 0.000  0  0 0.000
#> SRR1688384     1   0.000      1.000 1.000 0.000 0.000  0  0 0.000
#> SRR1688385     1   0.000      1.000 1.000 0.000 0.000  0  0 0.000
#> SRR1688386     1   0.000      1.000 1.000 0.000 0.000  0  0 0.000
#> SRR1688387     4   0.000      1.000 0.000 0.000 0.000  1  0 0.000
#> SRR1688388     4   0.000      1.000 0.000 0.000 0.000  1  0 0.000
#> SRR1688389     4   0.000      1.000 0.000 0.000 0.000  1  0 0.000
#> SRR1688390     4   0.000      1.000 0.000 0.000 0.000  1  0 0.000
#> SRR1688391     4   0.000      1.000 0.000 0.000 0.000  1  0 0.000
#> SRR1688392     4   0.000      1.000 0.000 0.000 0.000  1  0 0.000
#> SRR1688393     3   0.000      1.000 0.000 0.000 1.000  0  0 0.000
#> SRR1688395     3   0.000      1.000 0.000 0.000 1.000  0  0 0.000
#> SRR1688394     3   0.000      1.000 0.000 0.000 1.000  0  0 0.000
#> SRR1688397     3   0.000      1.000 0.000 0.000 1.000  0  0 0.000
#> SRR1688398     3   0.000      1.000 0.000 0.000 1.000  0  0 0.000
#> SRR1688396     3   0.000      1.000 0.000 0.000 1.000  0  0 0.000
#> SRR1688399     3   0.000      1.000 0.000 0.000 1.000  0  0 0.000
#> SRR1688400     3   0.000      1.000 0.000 0.000 1.000  0  0 0.000
#> SRR1688402     3   0.000      1.000 0.000 0.000 1.000  0  0 0.000
#> SRR1688401     3   0.000      1.000 0.000 0.000 1.000  0  0 0.000
#> SRR1688403     3   0.000      1.000 0.000 0.000 1.000  0  0 0.000
#> SRR1688404     3   0.000      1.000 0.000 0.000 1.000  0  0 0.000
#> SRR1688405     2   0.190      0.891 0.000 0.912 0.016  0  0 0.072
#> SRR1688407     2   0.190      0.891 0.000 0.912 0.016  0  0 0.072
#> SRR1688408     3   0.000      1.000 0.000 0.000 1.000  0  0 0.000
#> SRR1688406     2   0.190      0.891 0.000 0.912 0.016  0  0 0.072
#> SRR1688410     3   0.000      1.000 0.000 0.000 1.000  0  0 0.000
#> SRR1688411     2   0.214      0.874 0.000 0.872 0.000  0  0 0.128
#> SRR1688409     3   0.000      1.000 0.000 0.000 1.000  0  0 0.000
#> SRR1688412     2   0.214      0.874 0.000 0.872 0.000  0  0 0.128
#> SRR1688413     2   0.214      0.874 0.000 0.872 0.000  0  0 0.128
#> SRR1688414     2   0.214      0.874 0.000 0.872 0.000  0  0 0.128
#> SRR1688415     2   0.222      0.880 0.000 0.864 0.000  0  0 0.136
#> SRR1688416     2   0.222      0.880 0.000 0.864 0.000  0  0 0.136
#> SRR1688417     2   0.222      0.880 0.000 0.864 0.000  0  0 0.136
#> SRR1688418     2   0.222      0.880 0.000 0.864 0.000  0  0 0.136

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

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.225           0.608       0.722         0.4217 0.494   0.494
#> 3 3 0.437           0.847       0.826         0.4306 0.857   0.711
#> 4 4 0.608           0.771       0.780         0.1421 1.000   1.000
#> 5 5 0.707           0.681       0.736         0.0927 0.865   0.639
#> 6 6 0.666           0.609       0.724         0.0452 0.962   0.855

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

suggest_best_k(res)
#> [1] 3

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1688357     2   0.000      0.877 0.000 1.000
#> SRR1688358     2   0.000      0.877 0.000 1.000
#> SRR1688359     2   0.000      0.877 0.000 1.000
#> SRR1688360     2   0.000      0.877 0.000 1.000
#> SRR1688361     2   0.000      0.877 0.000 1.000
#> SRR1688362     2   0.000      0.877 0.000 1.000
#> SRR1688363     2   0.000      0.877 0.000 1.000
#> SRR1688365     2   0.000      0.877 0.000 1.000
#> SRR1688364     2   0.000      0.877 0.000 1.000
#> SRR1688366     2   0.224      0.852 0.036 0.964
#> SRR1688367     2   0.224      0.852 0.036 0.964
#> SRR1688368     2   0.224      0.852 0.036 0.964
#> SRR1688370     2   0.000      0.877 0.000 1.000
#> SRR1688369     2   0.000      0.877 0.000 1.000
#> SRR1688371     2   0.000      0.877 0.000 1.000
#> SRR1688372     2   0.706      0.747 0.192 0.808
#> SRR1688373     2   0.706      0.747 0.192 0.808
#> SRR1688374     2   0.706      0.747 0.192 0.808
#> SRR1688375     1   0.833      0.564 0.736 0.264
#> SRR1688377     1   0.833      0.564 0.736 0.264
#> SRR1688378     1   0.814      0.556 0.748 0.252
#> SRR1688376     1   0.833      0.564 0.736 0.264
#> SRR1688380     1   0.814      0.556 0.748 0.252
#> SRR1688379     1   0.814      0.556 0.748 0.252
#> SRR1688381     1   0.855      0.555 0.720 0.280
#> SRR1688382     1   0.855      0.555 0.720 0.280
#> SRR1688383     1   0.855      0.555 0.720 0.280
#> SRR1688384     1   0.861      0.555 0.716 0.284
#> SRR1688385     1   0.861      0.555 0.716 0.284
#> SRR1688386     1   0.861      0.555 0.716 0.284
#> SRR1688387     1   0.625      0.555 0.844 0.156
#> SRR1688388     1   0.625      0.555 0.844 0.156
#> SRR1688389     1   0.625      0.555 0.844 0.156
#> SRR1688390     1   0.814      0.556 0.748 0.252
#> SRR1688391     1   0.814      0.556 0.748 0.252
#> SRR1688392     1   0.814      0.556 0.748 0.252
#> SRR1688393     1   0.999      0.287 0.516 0.484
#> SRR1688395     1   0.999      0.287 0.516 0.484
#> SRR1688394     1   0.999      0.287 0.516 0.484
#> SRR1688397     1   0.999      0.287 0.516 0.484
#> SRR1688398     1   0.999      0.287 0.516 0.484
#> SRR1688396     1   0.999      0.287 0.516 0.484
#> SRR1688399     1   0.999      0.287 0.516 0.484
#> SRR1688400     1   0.999      0.287 0.516 0.484
#> SRR1688402     1   0.999      0.287 0.516 0.484
#> SRR1688401     1   0.999      0.287 0.516 0.484
#> SRR1688403     1   0.999      0.287 0.516 0.484
#> SRR1688404     1   0.999      0.287 0.516 0.484
#> SRR1688405     2   0.781      0.513 0.232 0.768
#> SRR1688407     2   0.781      0.513 0.232 0.768
#> SRR1688408     1   0.999      0.287 0.516 0.484
#> SRR1688406     2   0.781      0.513 0.232 0.768
#> SRR1688410     1   0.999      0.287 0.516 0.484
#> SRR1688411     2   0.706      0.747 0.192 0.808
#> SRR1688409     1   0.999      0.287 0.516 0.484
#> SRR1688412     2   0.706      0.747 0.192 0.808
#> SRR1688413     2   0.706      0.747 0.192 0.808
#> SRR1688414     2   0.706      0.747 0.192 0.808
#> SRR1688415     2   0.000      0.877 0.000 1.000
#> SRR1688416     2   0.000      0.877 0.000 1.000
#> SRR1688417     2   0.000      0.877 0.000 1.000
#> SRR1688418     2   0.000      0.877 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2  0.1774      0.831 0.024 0.960 0.016
#> SRR1688358     2  0.1774      0.831 0.024 0.960 0.016
#> SRR1688359     2  0.1774      0.831 0.024 0.960 0.016
#> SRR1688360     2  0.0848      0.830 0.008 0.984 0.008
#> SRR1688361     2  0.0848      0.830 0.008 0.984 0.008
#> SRR1688362     2  0.0848      0.830 0.008 0.984 0.008
#> SRR1688363     2  0.1170      0.829 0.008 0.976 0.016
#> SRR1688365     2  0.1170      0.829 0.008 0.976 0.016
#> SRR1688364     2  0.1170      0.829 0.008 0.976 0.016
#> SRR1688366     2  0.1781      0.816 0.020 0.960 0.020
#> SRR1688367     2  0.1781      0.816 0.020 0.960 0.020
#> SRR1688368     2  0.1781      0.816 0.020 0.960 0.020
#> SRR1688370     2  0.1774      0.831 0.024 0.960 0.016
#> SRR1688369     2  0.1774      0.831 0.024 0.960 0.016
#> SRR1688371     2  0.1774      0.831 0.024 0.960 0.016
#> SRR1688372     2  0.8206      0.636 0.196 0.640 0.164
#> SRR1688373     2  0.8206      0.636 0.196 0.640 0.164
#> SRR1688374     2  0.8206      0.636 0.196 0.640 0.164
#> SRR1688375     1  0.7165      0.899 0.716 0.112 0.172
#> SRR1688377     1  0.7165      0.899 0.716 0.112 0.172
#> SRR1688378     1  0.4995      0.915 0.840 0.068 0.092
#> SRR1688376     1  0.7165      0.899 0.716 0.112 0.172
#> SRR1688380     1  0.4995      0.915 0.840 0.068 0.092
#> SRR1688379     1  0.4995      0.915 0.840 0.068 0.092
#> SRR1688381     1  0.6529      0.912 0.760 0.116 0.124
#> SRR1688382     1  0.6529      0.912 0.760 0.116 0.124
#> SRR1688383     1  0.6529      0.912 0.760 0.116 0.124
#> SRR1688384     1  0.6659      0.913 0.752 0.116 0.132
#> SRR1688385     1  0.6659      0.913 0.752 0.116 0.132
#> SRR1688386     1  0.6659      0.913 0.752 0.116 0.132
#> SRR1688387     1  0.5094      0.897 0.824 0.040 0.136
#> SRR1688388     1  0.5094      0.897 0.824 0.040 0.136
#> SRR1688389     1  0.5094      0.897 0.824 0.040 0.136
#> SRR1688390     1  0.5137      0.910 0.832 0.064 0.104
#> SRR1688391     1  0.5137      0.910 0.832 0.064 0.104
#> SRR1688392     1  0.5137      0.910 0.832 0.064 0.104
#> SRR1688393     3  0.5167      0.981 0.016 0.192 0.792
#> SRR1688395     3  0.5167      0.981 0.016 0.192 0.792
#> SRR1688394     3  0.5167      0.981 0.016 0.192 0.792
#> SRR1688397     3  0.5020      0.982 0.012 0.192 0.796
#> SRR1688398     3  0.5020      0.982 0.012 0.192 0.796
#> SRR1688396     3  0.5020      0.982 0.012 0.192 0.796
#> SRR1688399     3  0.4682      0.983 0.004 0.192 0.804
#> SRR1688400     3  0.4682      0.983 0.004 0.192 0.804
#> SRR1688402     3  0.4682      0.983 0.004 0.192 0.804
#> SRR1688401     3  0.4682      0.983 0.004 0.192 0.804
#> SRR1688403     3  0.4682      0.983 0.004 0.192 0.804
#> SRR1688404     3  0.4682      0.983 0.004 0.192 0.804
#> SRR1688405     2  0.8223      0.447 0.108 0.604 0.288
#> SRR1688407     2  0.8223      0.447 0.108 0.604 0.288
#> SRR1688408     3  0.4473      0.958 0.008 0.164 0.828
#> SRR1688406     2  0.8223      0.447 0.108 0.604 0.288
#> SRR1688410     3  0.4473      0.958 0.008 0.164 0.828
#> SRR1688411     2  0.8206      0.636 0.196 0.640 0.164
#> SRR1688409     3  0.4473      0.958 0.008 0.164 0.828
#> SRR1688412     2  0.8206      0.636 0.196 0.640 0.164
#> SRR1688413     2  0.8206      0.636 0.196 0.640 0.164
#> SRR1688414     2  0.8206      0.636 0.196 0.640 0.164
#> SRR1688415     2  0.1774      0.831 0.024 0.960 0.016
#> SRR1688416     2  0.1774      0.831 0.024 0.960 0.016
#> SRR1688417     2  0.1774      0.831 0.024 0.960 0.016
#> SRR1688418     2  0.1774      0.831 0.024 0.960 0.016

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3 p4
#> SRR1688357     2   0.000      0.763 0.000 1.000 0.000 NA
#> SRR1688358     2   0.000      0.763 0.000 1.000 0.000 NA
#> SRR1688359     2   0.000      0.763 0.000 1.000 0.000 NA
#> SRR1688360     2   0.292      0.766 0.008 0.876 0.000 NA
#> SRR1688361     2   0.292      0.766 0.008 0.876 0.000 NA
#> SRR1688362     2   0.292      0.766 0.008 0.876 0.000 NA
#> SRR1688363     2   0.436      0.758 0.028 0.784 0.000 NA
#> SRR1688365     2   0.436      0.758 0.028 0.784 0.000 NA
#> SRR1688364     2   0.436      0.758 0.028 0.784 0.000 NA
#> SRR1688366     2   0.552      0.736 0.028 0.688 0.012 NA
#> SRR1688367     2   0.552      0.736 0.028 0.688 0.012 NA
#> SRR1688368     2   0.552      0.736 0.028 0.688 0.012 NA
#> SRR1688370     2   0.000      0.763 0.000 1.000 0.000 NA
#> SRR1688369     2   0.000      0.763 0.000 1.000 0.000 NA
#> SRR1688371     2   0.000      0.763 0.000 1.000 0.000 NA
#> SRR1688372     2   0.833      0.620 0.076 0.468 0.104 NA
#> SRR1688373     2   0.833      0.620 0.076 0.468 0.104 NA
#> SRR1688374     2   0.833      0.620 0.076 0.468 0.104 NA
#> SRR1688375     1   0.797      0.764 0.516 0.040 0.136 NA
#> SRR1688377     1   0.797      0.764 0.516 0.040 0.136 NA
#> SRR1688378     1   0.383      0.800 0.856 0.008 0.048 NA
#> SRR1688376     1   0.797      0.764 0.516 0.040 0.136 NA
#> SRR1688380     1   0.383      0.800 0.856 0.008 0.048 NA
#> SRR1688379     1   0.383      0.800 0.856 0.008 0.048 NA
#> SRR1688381     1   0.744      0.789 0.568 0.048 0.080 NA
#> SRR1688382     1   0.744      0.789 0.568 0.048 0.080 NA
#> SRR1688383     1   0.744      0.789 0.568 0.048 0.080 NA
#> SRR1688384     1   0.748      0.782 0.536 0.048 0.072 NA
#> SRR1688385     1   0.748      0.782 0.536 0.048 0.072 NA
#> SRR1688386     1   0.748      0.782 0.536 0.048 0.072 NA
#> SRR1688387     1   0.358      0.782 0.868 0.004 0.072 NA
#> SRR1688388     1   0.358      0.782 0.868 0.004 0.072 NA
#> SRR1688389     1   0.358      0.782 0.868 0.004 0.072 NA
#> SRR1688390     1   0.222      0.791 0.932 0.008 0.044 NA
#> SRR1688391     1   0.222      0.791 0.932 0.008 0.044 NA
#> SRR1688392     1   0.222      0.791 0.932 0.008 0.044 NA
#> SRR1688393     3   0.450      0.920 0.000 0.072 0.804 NA
#> SRR1688395     3   0.450      0.920 0.000 0.072 0.804 NA
#> SRR1688394     3   0.450      0.920 0.000 0.072 0.804 NA
#> SRR1688397     3   0.434      0.927 0.004 0.072 0.824 NA
#> SRR1688398     3   0.434      0.927 0.004 0.072 0.824 NA
#> SRR1688396     3   0.434      0.927 0.004 0.072 0.824 NA
#> SRR1688399     3   0.233      0.942 0.000 0.072 0.916 NA
#> SRR1688400     3   0.233      0.942 0.000 0.072 0.916 NA
#> SRR1688402     3   0.277      0.940 0.000 0.072 0.900 NA
#> SRR1688401     3   0.233      0.942 0.000 0.072 0.916 NA
#> SRR1688403     3   0.277      0.940 0.000 0.072 0.900 NA
#> SRR1688404     3   0.277      0.940 0.000 0.072 0.900 NA
#> SRR1688405     2   0.882      0.329 0.052 0.404 0.312 NA
#> SRR1688407     2   0.882      0.329 0.052 0.404 0.312 NA
#> SRR1688408     3   0.332      0.927 0.000 0.064 0.876 NA
#> SRR1688406     2   0.882      0.329 0.052 0.404 0.312 NA
#> SRR1688410     3   0.332      0.927 0.000 0.064 0.876 NA
#> SRR1688411     2   0.828      0.620 0.072 0.468 0.104 NA
#> SRR1688409     3   0.332      0.927 0.000 0.064 0.876 NA
#> SRR1688412     2   0.828      0.620 0.072 0.468 0.104 NA
#> SRR1688413     2   0.828      0.620 0.072 0.468 0.104 NA
#> SRR1688414     2   0.828      0.620 0.072 0.468 0.104 NA
#> SRR1688415     2   0.000      0.763 0.000 1.000 0.000 NA
#> SRR1688416     2   0.000      0.763 0.000 1.000 0.000 NA
#> SRR1688417     2   0.000      0.763 0.000 1.000 0.000 NA
#> SRR1688418     2   0.000      0.763 0.000 1.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
#> SRR1688357     2  0.0566      0.756 0.000 0.984 0.012 0.004 0.000
#> SRR1688358     2  0.0566      0.756 0.000 0.984 0.012 0.004 0.000
#> SRR1688359     2  0.0566      0.756 0.000 0.984 0.012 0.004 0.000
#> SRR1688360     2  0.4999      0.675 0.000 0.732 0.012 0.108 0.148
#> SRR1688361     2  0.4999      0.675 0.000 0.732 0.012 0.108 0.148
#> SRR1688362     2  0.4999      0.675 0.000 0.732 0.012 0.108 0.148
#> SRR1688363     2  0.5969      0.558 0.000 0.608 0.004 0.188 0.200
#> SRR1688365     2  0.5969      0.558 0.000 0.608 0.004 0.188 0.200
#> SRR1688364     2  0.5969      0.558 0.000 0.608 0.004 0.188 0.200
#> SRR1688366     2  0.6153      0.156 0.000 0.484 0.000 0.380 0.136
#> SRR1688367     2  0.6153      0.156 0.000 0.484 0.000 0.380 0.136
#> SRR1688368     2  0.6153      0.156 0.000 0.484 0.000 0.380 0.136
#> SRR1688370     2  0.1016      0.755 0.004 0.972 0.012 0.004 0.008
#> SRR1688369     2  0.1016      0.755 0.004 0.972 0.012 0.004 0.008
#> SRR1688371     2  0.1016      0.755 0.004 0.972 0.012 0.004 0.008
#> SRR1688372     4  0.6260      0.997 0.044 0.264 0.076 0.612 0.004
#> SRR1688373     4  0.6260      0.997 0.044 0.264 0.076 0.612 0.004
#> SRR1688374     4  0.6260      0.997 0.044 0.264 0.076 0.612 0.004
#> SRR1688375     1  0.7235      0.669 0.460 0.012 0.096 0.056 0.376
#> SRR1688377     1  0.7235      0.669 0.460 0.012 0.096 0.056 0.376
#> SRR1688378     1  0.2791      0.736 0.888 0.004 0.004 0.072 0.032
#> SRR1688376     1  0.7235      0.669 0.460 0.012 0.096 0.056 0.376
#> SRR1688380     1  0.2791      0.736 0.888 0.004 0.004 0.072 0.032
#> SRR1688379     1  0.2791      0.736 0.888 0.004 0.004 0.072 0.032
#> SRR1688381     1  0.6765      0.709 0.588 0.016 0.028 0.136 0.232
#> SRR1688382     1  0.6765      0.709 0.588 0.016 0.028 0.136 0.232
#> SRR1688383     1  0.6765      0.709 0.588 0.016 0.028 0.136 0.232
#> SRR1688384     1  0.6908      0.706 0.568 0.016 0.036 0.120 0.260
#> SRR1688385     1  0.6908      0.706 0.568 0.016 0.036 0.120 0.260
#> SRR1688386     1  0.6908      0.706 0.568 0.016 0.036 0.120 0.260
#> SRR1688387     1  0.4183      0.708 0.776 0.000 0.024 0.020 0.180
#> SRR1688388     1  0.4183      0.708 0.776 0.000 0.024 0.020 0.180
#> SRR1688389     1  0.4183      0.708 0.776 0.000 0.024 0.020 0.180
#> SRR1688390     1  0.2866      0.718 0.884 0.004 0.008 0.024 0.080
#> SRR1688391     1  0.2866      0.718 0.884 0.004 0.008 0.024 0.080
#> SRR1688392     1  0.2866      0.718 0.884 0.004 0.008 0.024 0.080
#> SRR1688393     3  0.4506      0.754 0.000 0.016 0.764 0.052 0.168
#> SRR1688395     3  0.4506      0.754 0.000 0.016 0.764 0.052 0.168
#> SRR1688394     3  0.4506      0.754 0.000 0.016 0.764 0.052 0.168
#> SRR1688397     3  0.4112      0.766 0.000 0.016 0.800 0.048 0.136
#> SRR1688398     3  0.4112      0.766 0.000 0.016 0.800 0.048 0.136
#> SRR1688396     3  0.4112      0.766 0.000 0.016 0.800 0.048 0.136
#> SRR1688399     3  0.1362      0.792 0.004 0.016 0.960 0.012 0.008
#> SRR1688400     3  0.1362      0.792 0.004 0.016 0.960 0.012 0.008
#> SRR1688402     3  0.2290      0.787 0.004 0.016 0.920 0.016 0.044
#> SRR1688401     3  0.1362      0.792 0.004 0.016 0.960 0.012 0.008
#> SRR1688403     3  0.2290      0.787 0.004 0.016 0.920 0.016 0.044
#> SRR1688404     3  0.2290      0.787 0.004 0.016 0.920 0.016 0.044
#> SRR1688405     3  0.8628     -0.278 0.040 0.220 0.352 0.312 0.076
#> SRR1688407     3  0.8628     -0.278 0.040 0.220 0.352 0.312 0.076
#> SRR1688408     3  0.2549      0.778 0.004 0.008 0.904 0.024 0.060
#> SRR1688406     3  0.8628     -0.278 0.040 0.220 0.352 0.312 0.076
#> SRR1688410     3  0.2549      0.778 0.004 0.008 0.904 0.024 0.060
#> SRR1688411     4  0.6110      0.998 0.044 0.264 0.076 0.616 0.000
#> SRR1688409     3  0.2549      0.778 0.004 0.008 0.904 0.024 0.060
#> SRR1688412     4  0.6110      0.998 0.044 0.264 0.076 0.616 0.000
#> SRR1688413     4  0.6110      0.998 0.044 0.264 0.076 0.616 0.000
#> SRR1688414     4  0.6110      0.998 0.044 0.264 0.076 0.616 0.000
#> SRR1688415     2  0.0566      0.756 0.000 0.984 0.012 0.004 0.000
#> SRR1688416     2  0.0566      0.756 0.000 0.984 0.012 0.004 0.000
#> SRR1688417     2  0.0566      0.756 0.000 0.984 0.012 0.004 0.000
#> SRR1688418     2  0.0566      0.756 0.000 0.984 0.012 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4 p5    p6
#> SRR1688357     2  0.0146      0.746 0.000 0.996 0.004 0.000 NA 0.000
#> SRR1688358     2  0.0146      0.746 0.000 0.996 0.004 0.000 NA 0.000
#> SRR1688359     2  0.0146      0.746 0.000 0.996 0.004 0.000 NA 0.000
#> SRR1688360     2  0.4900      0.655 0.008 0.696 0.004 0.080 NA 0.008
#> SRR1688361     2  0.4900      0.655 0.008 0.696 0.004 0.080 NA 0.008
#> SRR1688362     2  0.4900      0.655 0.008 0.696 0.004 0.080 NA 0.008
#> SRR1688363     2  0.6324      0.516 0.024 0.552 0.000 0.160 NA 0.020
#> SRR1688365     2  0.6324      0.516 0.024 0.552 0.000 0.160 NA 0.020
#> SRR1688364     2  0.6324      0.516 0.024 0.552 0.000 0.160 NA 0.020
#> SRR1688366     2  0.7052      0.216 0.028 0.436 0.000 0.316 NA 0.040
#> SRR1688367     2  0.7052      0.216 0.028 0.436 0.000 0.316 NA 0.040
#> SRR1688368     2  0.7059      0.205 0.028 0.432 0.000 0.320 NA 0.040
#> SRR1688370     2  0.1325      0.741 0.004 0.956 0.004 0.004 NA 0.024
#> SRR1688369     2  0.1325      0.741 0.004 0.956 0.004 0.004 NA 0.024
#> SRR1688371     2  0.1325      0.741 0.004 0.956 0.004 0.004 NA 0.024
#> SRR1688372     4  0.4797      0.993 0.036 0.200 0.044 0.712 NA 0.008
#> SRR1688373     4  0.4797      0.993 0.036 0.200 0.044 0.712 NA 0.008
#> SRR1688374     4  0.4797      0.993 0.036 0.200 0.044 0.712 NA 0.008
#> SRR1688375     1  0.6242      0.495 0.656 0.012 0.072 0.032 NA 0.088
#> SRR1688377     1  0.6273      0.495 0.656 0.012 0.072 0.036 NA 0.088
#> SRR1688378     1  0.6280     -0.329 0.460 0.000 0.004 0.072 NA 0.392
#> SRR1688376     1  0.6242      0.495 0.656 0.012 0.072 0.032 NA 0.088
#> SRR1688380     1  0.6275     -0.331 0.460 0.000 0.004 0.064 NA 0.392
#> SRR1688379     1  0.6280     -0.329 0.460 0.000 0.004 0.072 NA 0.392
#> SRR1688381     1  0.3841      0.570 0.836 0.012 0.016 0.036 NA 0.052
#> SRR1688382     1  0.3841      0.570 0.836 0.012 0.016 0.036 NA 0.052
#> SRR1688383     1  0.3841      0.570 0.836 0.012 0.016 0.036 NA 0.052
#> SRR1688384     1  0.1837      0.600 0.932 0.012 0.020 0.032 NA 0.000
#> SRR1688385     1  0.1837      0.600 0.932 0.012 0.020 0.032 NA 0.000
#> SRR1688386     1  0.1837      0.600 0.932 0.012 0.020 0.032 NA 0.000
#> SRR1688387     6  0.5155      0.792 0.288 0.000 0.004 0.024 NA 0.628
#> SRR1688388     6  0.5155      0.792 0.288 0.000 0.004 0.024 NA 0.628
#> SRR1688389     6  0.5171      0.791 0.288 0.000 0.004 0.028 NA 0.628
#> SRR1688390     6  0.4184      0.786 0.340 0.000 0.004 0.012 NA 0.640
#> SRR1688391     6  0.4184      0.786 0.340 0.000 0.004 0.012 NA 0.640
#> SRR1688392     6  0.4184      0.786 0.340 0.000 0.004 0.012 NA 0.640
#> SRR1688393     3  0.3828      0.713 0.000 0.000 0.724 0.008 NA 0.016
#> SRR1688395     3  0.3828      0.713 0.000 0.000 0.724 0.008 NA 0.016
#> SRR1688394     3  0.3828      0.713 0.000 0.000 0.724 0.008 NA 0.016
#> SRR1688397     3  0.3897      0.724 0.000 0.000 0.760 0.012 NA 0.036
#> SRR1688398     3  0.3897      0.724 0.000 0.000 0.760 0.012 NA 0.036
#> SRR1688396     3  0.3897      0.724 0.000 0.000 0.760 0.012 NA 0.036
#> SRR1688399     3  0.1346      0.751 0.000 0.000 0.952 0.016 NA 0.008
#> SRR1688400     3  0.1346      0.751 0.000 0.000 0.952 0.016 NA 0.008
#> SRR1688402     3  0.2307      0.745 0.004 0.000 0.908 0.016 NA 0.028
#> SRR1688401     3  0.1346      0.751 0.000 0.000 0.952 0.016 NA 0.008
#> SRR1688403     3  0.2307      0.745 0.004 0.000 0.908 0.016 NA 0.028
#> SRR1688404     3  0.2307      0.745 0.004 0.000 0.908 0.016 NA 0.028
#> SRR1688405     3  0.9068     -0.164 0.120 0.188 0.284 0.260 NA 0.024
#> SRR1688407     3  0.9068     -0.164 0.120 0.188 0.284 0.260 NA 0.024
#> SRR1688408     3  0.3200      0.723 0.000 0.000 0.840 0.008 NA 0.060
#> SRR1688406     3  0.9068     -0.164 0.120 0.188 0.284 0.260 NA 0.024
#> SRR1688410     3  0.3200      0.723 0.000 0.000 0.840 0.008 NA 0.060
#> SRR1688411     4  0.4483      0.995 0.032 0.200 0.044 0.724 NA 0.000
#> SRR1688409     3  0.3200      0.723 0.000 0.000 0.840 0.008 NA 0.060
#> SRR1688412     4  0.4483      0.995 0.032 0.200 0.044 0.724 NA 0.000
#> SRR1688413     4  0.4483      0.995 0.032 0.200 0.044 0.724 NA 0.000
#> SRR1688414     4  0.4483      0.995 0.032 0.200 0.044 0.724 NA 0.000
#> SRR1688415     2  0.0146      0.746 0.000 0.996 0.004 0.000 NA 0.000
#> SRR1688416     2  0.0146      0.746 0.000 0.996 0.004 0.000 NA 0.000
#> SRR1688417     2  0.0146      0.746 0.000 0.996 0.004 0.000 NA 0.000
#> SRR1688418     2  0.0146      0.746 0.000 0.996 0.004 0.000 NA 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.967       0.985         0.5033 0.494   0.494
#> 3 3 1.000           0.999       1.000         0.3247 0.792   0.599
#> 4 4 0.960           0.892       0.950         0.1231 0.895   0.695
#> 5 5 0.858           0.835       0.875         0.0529 0.952   0.818
#> 6 6 0.874           0.807       0.822         0.0374 0.911   0.629

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette  p1  p2
#> SRR1688357     2   0.000      0.967 0.0 1.0
#> SRR1688358     2   0.000      0.967 0.0 1.0
#> SRR1688359     2   0.000      0.967 0.0 1.0
#> SRR1688360     2   0.000      0.967 0.0 1.0
#> SRR1688361     2   0.000      0.967 0.0 1.0
#> SRR1688362     2   0.000      0.967 0.0 1.0
#> SRR1688363     2   0.000      0.967 0.0 1.0
#> SRR1688365     2   0.000      0.967 0.0 1.0
#> SRR1688364     2   0.000      0.967 0.0 1.0
#> SRR1688366     2   0.000      0.967 0.0 1.0
#> SRR1688367     2   0.000      0.967 0.0 1.0
#> SRR1688368     2   0.000      0.967 0.0 1.0
#> SRR1688370     2   0.000      0.967 0.0 1.0
#> SRR1688369     2   0.000      0.967 0.0 1.0
#> SRR1688371     2   0.000      0.967 0.0 1.0
#> SRR1688372     2   0.000      0.967 0.0 1.0
#> SRR1688373     2   0.000      0.967 0.0 1.0
#> SRR1688374     2   0.000      0.967 0.0 1.0
#> SRR1688375     1   0.000      1.000 1.0 0.0
#> SRR1688377     1   0.000      1.000 1.0 0.0
#> SRR1688378     1   0.000      1.000 1.0 0.0
#> SRR1688376     1   0.000      1.000 1.0 0.0
#> SRR1688380     1   0.000      1.000 1.0 0.0
#> SRR1688379     1   0.000      1.000 1.0 0.0
#> SRR1688381     1   0.000      1.000 1.0 0.0
#> SRR1688382     1   0.000      1.000 1.0 0.0
#> SRR1688383     1   0.000      1.000 1.0 0.0
#> SRR1688384     1   0.000      1.000 1.0 0.0
#> SRR1688385     1   0.000      1.000 1.0 0.0
#> SRR1688386     1   0.000      1.000 1.0 0.0
#> SRR1688387     1   0.000      1.000 1.0 0.0
#> SRR1688388     1   0.000      1.000 1.0 0.0
#> SRR1688389     1   0.000      1.000 1.0 0.0
#> SRR1688390     1   0.000      1.000 1.0 0.0
#> SRR1688391     1   0.000      1.000 1.0 0.0
#> SRR1688392     1   0.000      1.000 1.0 0.0
#> SRR1688393     1   0.000      1.000 1.0 0.0
#> SRR1688395     1   0.000      1.000 1.0 0.0
#> SRR1688394     1   0.000      1.000 1.0 0.0
#> SRR1688397     1   0.000      1.000 1.0 0.0
#> SRR1688398     1   0.000      1.000 1.0 0.0
#> SRR1688396     1   0.000      1.000 1.0 0.0
#> SRR1688399     1   0.000      1.000 1.0 0.0
#> SRR1688400     1   0.000      1.000 1.0 0.0
#> SRR1688402     1   0.000      1.000 1.0 0.0
#> SRR1688401     1   0.000      1.000 1.0 0.0
#> SRR1688403     1   0.000      1.000 1.0 0.0
#> SRR1688404     1   0.000      1.000 1.0 0.0
#> SRR1688405     2   0.881      0.602 0.3 0.7
#> SRR1688407     2   0.881      0.602 0.3 0.7
#> SRR1688408     1   0.000      1.000 1.0 0.0
#> SRR1688406     2   0.881      0.602 0.3 0.7
#> SRR1688410     1   0.000      1.000 1.0 0.0
#> SRR1688411     2   0.000      0.967 0.0 1.0
#> SRR1688409     1   0.000      1.000 1.0 0.0
#> SRR1688412     2   0.000      0.967 0.0 1.0
#> SRR1688413     2   0.000      0.967 0.0 1.0
#> SRR1688414     2   0.000      0.967 0.0 1.0
#> SRR1688415     2   0.000      0.967 0.0 1.0
#> SRR1688416     2   0.000      0.967 0.0 1.0
#> SRR1688417     2   0.000      0.967 0.0 1.0
#> SRR1688418     2   0.000      0.967 0.0 1.0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2 p3
#> SRR1688357     2  0.0000      0.999 0.000 1.000  0
#> SRR1688358     2  0.0000      0.999 0.000 1.000  0
#> SRR1688359     2  0.0000      0.999 0.000 1.000  0
#> SRR1688360     2  0.0000      0.999 0.000 1.000  0
#> SRR1688361     2  0.0000      0.999 0.000 1.000  0
#> SRR1688362     2  0.0000      0.999 0.000 1.000  0
#> SRR1688363     2  0.0000      0.999 0.000 1.000  0
#> SRR1688365     2  0.0000      0.999 0.000 1.000  0
#> SRR1688364     2  0.0000      0.999 0.000 1.000  0
#> SRR1688366     2  0.0000      0.999 0.000 1.000  0
#> SRR1688367     2  0.0000      0.999 0.000 1.000  0
#> SRR1688368     2  0.0000      0.999 0.000 1.000  0
#> SRR1688370     2  0.0000      0.999 0.000 1.000  0
#> SRR1688369     2  0.0000      0.999 0.000 1.000  0
#> SRR1688371     2  0.0000      0.999 0.000 1.000  0
#> SRR1688372     2  0.0237      0.997 0.004 0.996  0
#> SRR1688373     2  0.0237      0.997 0.004 0.996  0
#> SRR1688374     2  0.0237      0.997 0.004 0.996  0
#> SRR1688375     1  0.0000      1.000 1.000 0.000  0
#> SRR1688377     1  0.0000      1.000 1.000 0.000  0
#> SRR1688378     1  0.0000      1.000 1.000 0.000  0
#> SRR1688376     1  0.0000      1.000 1.000 0.000  0
#> SRR1688380     1  0.0000      1.000 1.000 0.000  0
#> SRR1688379     1  0.0000      1.000 1.000 0.000  0
#> SRR1688381     1  0.0000      1.000 1.000 0.000  0
#> SRR1688382     1  0.0000      1.000 1.000 0.000  0
#> SRR1688383     1  0.0000      1.000 1.000 0.000  0
#> SRR1688384     1  0.0000      1.000 1.000 0.000  0
#> SRR1688385     1  0.0000      1.000 1.000 0.000  0
#> SRR1688386     1  0.0000      1.000 1.000 0.000  0
#> SRR1688387     1  0.0000      1.000 1.000 0.000  0
#> SRR1688388     1  0.0000      1.000 1.000 0.000  0
#> SRR1688389     1  0.0000      1.000 1.000 0.000  0
#> SRR1688390     1  0.0000      1.000 1.000 0.000  0
#> SRR1688391     1  0.0000      1.000 1.000 0.000  0
#> SRR1688392     1  0.0000      1.000 1.000 0.000  0
#> SRR1688393     3  0.0000      1.000 0.000 0.000  1
#> SRR1688395     3  0.0000      1.000 0.000 0.000  1
#> SRR1688394     3  0.0000      1.000 0.000 0.000  1
#> SRR1688397     3  0.0000      1.000 0.000 0.000  1
#> SRR1688398     3  0.0000      1.000 0.000 0.000  1
#> SRR1688396     3  0.0000      1.000 0.000 0.000  1
#> SRR1688399     3  0.0000      1.000 0.000 0.000  1
#> SRR1688400     3  0.0000      1.000 0.000 0.000  1
#> SRR1688402     3  0.0000      1.000 0.000 0.000  1
#> SRR1688401     3  0.0000      1.000 0.000 0.000  1
#> SRR1688403     3  0.0000      1.000 0.000 0.000  1
#> SRR1688404     3  0.0000      1.000 0.000 0.000  1
#> SRR1688405     3  0.0000      1.000 0.000 0.000  1
#> SRR1688407     3  0.0000      1.000 0.000 0.000  1
#> SRR1688408     3  0.0000      1.000 0.000 0.000  1
#> SRR1688406     3  0.0000      1.000 0.000 0.000  1
#> SRR1688410     3  0.0000      1.000 0.000 0.000  1
#> SRR1688411     2  0.0237      0.997 0.004 0.996  0
#> SRR1688409     3  0.0000      1.000 0.000 0.000  1
#> SRR1688412     2  0.0237      0.997 0.004 0.996  0
#> SRR1688413     2  0.0237      0.997 0.004 0.996  0
#> SRR1688414     2  0.0237      0.997 0.004 0.996  0
#> SRR1688415     2  0.0000      0.999 0.000 1.000  0
#> SRR1688416     2  0.0000      0.999 0.000 1.000  0
#> SRR1688417     2  0.0000      0.999 0.000 1.000  0
#> SRR1688418     2  0.0000      0.999 0.000 1.000  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1688357     2  0.0336      0.920 0.000 0.992 0.000 0.008
#> SRR1688358     2  0.0336      0.920 0.000 0.992 0.000 0.008
#> SRR1688359     2  0.0336      0.920 0.000 0.992 0.000 0.008
#> SRR1688360     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> SRR1688361     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> SRR1688362     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> SRR1688363     2  0.0336      0.914 0.000 0.992 0.000 0.008
#> SRR1688365     2  0.0336      0.914 0.000 0.992 0.000 0.008
#> SRR1688364     2  0.0336      0.914 0.000 0.992 0.000 0.008
#> SRR1688366     2  0.4925      0.374 0.000 0.572 0.000 0.428
#> SRR1688367     2  0.4925      0.374 0.000 0.572 0.000 0.428
#> SRR1688368     2  0.4925      0.374 0.000 0.572 0.000 0.428
#> SRR1688370     2  0.0336      0.920 0.000 0.992 0.000 0.008
#> SRR1688369     2  0.0336      0.920 0.000 0.992 0.000 0.008
#> SRR1688371     2  0.0336      0.920 0.000 0.992 0.000 0.008
#> SRR1688372     4  0.0817      0.816 0.000 0.024 0.000 0.976
#> SRR1688373     4  0.0817      0.816 0.000 0.024 0.000 0.976
#> SRR1688374     4  0.0817      0.816 0.000 0.024 0.000 0.976
#> SRR1688375     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1688377     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1688378     1  0.0336      0.996 0.992 0.000 0.000 0.008
#> SRR1688376     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1688380     1  0.0336      0.996 0.992 0.000 0.000 0.008
#> SRR1688379     1  0.0336      0.996 0.992 0.000 0.000 0.008
#> SRR1688381     1  0.0188      0.994 0.996 0.000 0.000 0.004
#> SRR1688382     1  0.0188      0.994 0.996 0.000 0.000 0.004
#> SRR1688383     1  0.0188      0.994 0.996 0.000 0.000 0.004
#> SRR1688384     1  0.0188      0.994 0.996 0.000 0.000 0.004
#> SRR1688385     1  0.0188      0.994 0.996 0.000 0.000 0.004
#> SRR1688386     1  0.0188      0.994 0.996 0.000 0.000 0.004
#> SRR1688387     1  0.0336      0.996 0.992 0.000 0.000 0.008
#> SRR1688388     1  0.0336      0.996 0.992 0.000 0.000 0.008
#> SRR1688389     1  0.0336      0.996 0.992 0.000 0.000 0.008
#> SRR1688390     1  0.0336      0.996 0.992 0.000 0.000 0.008
#> SRR1688391     1  0.0336      0.996 0.992 0.000 0.000 0.008
#> SRR1688392     1  0.0336      0.996 0.992 0.000 0.000 0.008
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688405     4  0.5151      0.282 0.000 0.004 0.464 0.532
#> SRR1688407     4  0.5151      0.282 0.000 0.004 0.464 0.532
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688406     4  0.5151      0.282 0.000 0.004 0.464 0.532
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688411     4  0.0817      0.816 0.000 0.024 0.000 0.976
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688412     4  0.0817      0.816 0.000 0.024 0.000 0.976
#> SRR1688413     4  0.0817      0.816 0.000 0.024 0.000 0.976
#> SRR1688414     4  0.0817      0.816 0.000 0.024 0.000 0.976
#> SRR1688415     2  0.0336      0.920 0.000 0.992 0.000 0.008
#> SRR1688416     2  0.0336      0.920 0.000 0.992 0.000 0.008
#> SRR1688417     2  0.0336      0.920 0.000 0.992 0.000 0.008
#> SRR1688418     2  0.0336      0.920 0.000 0.992 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1688357     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000
#> SRR1688360     2  0.3336      0.778 0.000 0.772 0.000 0.000 0.228
#> SRR1688361     2  0.3336      0.778 0.000 0.772 0.000 0.000 0.228
#> SRR1688362     2  0.3336      0.778 0.000 0.772 0.000 0.000 0.228
#> SRR1688363     2  0.4242      0.610 0.000 0.572 0.000 0.000 0.428
#> SRR1688365     2  0.4242      0.610 0.000 0.572 0.000 0.000 0.428
#> SRR1688364     2  0.4242      0.610 0.000 0.572 0.000 0.000 0.428
#> SRR1688366     4  0.6657      0.293 0.000 0.236 0.000 0.424 0.340
#> SRR1688367     4  0.6657      0.293 0.000 0.236 0.000 0.424 0.340
#> SRR1688368     4  0.6610      0.300 0.000 0.224 0.000 0.436 0.340
#> SRR1688370     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000
#> SRR1688372     4  0.0000      0.686 0.000 0.000 0.000 1.000 0.000
#> SRR1688373     4  0.0000      0.686 0.000 0.000 0.000 1.000 0.000
#> SRR1688374     4  0.0000      0.686 0.000 0.000 0.000 1.000 0.000
#> SRR1688375     1  0.1121      0.845 0.956 0.000 0.000 0.000 0.044
#> SRR1688377     1  0.1121      0.845 0.956 0.000 0.000 0.000 0.044
#> SRR1688378     1  0.3143      0.859 0.796 0.000 0.000 0.000 0.204
#> SRR1688376     1  0.1121      0.845 0.956 0.000 0.000 0.000 0.044
#> SRR1688380     1  0.3143      0.859 0.796 0.000 0.000 0.000 0.204
#> SRR1688379     1  0.3143      0.859 0.796 0.000 0.000 0.000 0.204
#> SRR1688381     1  0.1410      0.838 0.940 0.000 0.000 0.000 0.060
#> SRR1688382     1  0.1410      0.838 0.940 0.000 0.000 0.000 0.060
#> SRR1688383     1  0.1410      0.838 0.940 0.000 0.000 0.000 0.060
#> SRR1688384     1  0.1478      0.836 0.936 0.000 0.000 0.000 0.064
#> SRR1688385     1  0.1478      0.836 0.936 0.000 0.000 0.000 0.064
#> SRR1688386     1  0.1478      0.836 0.936 0.000 0.000 0.000 0.064
#> SRR1688387     1  0.3452      0.852 0.756 0.000 0.000 0.000 0.244
#> SRR1688388     1  0.3452      0.852 0.756 0.000 0.000 0.000 0.244
#> SRR1688389     1  0.3452      0.852 0.756 0.000 0.000 0.000 0.244
#> SRR1688390     1  0.3395      0.853 0.764 0.000 0.000 0.000 0.236
#> SRR1688391     1  0.3395      0.853 0.764 0.000 0.000 0.000 0.236
#> SRR1688392     1  0.3395      0.853 0.764 0.000 0.000 0.000 0.236
#> SRR1688393     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR1688395     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR1688394     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR1688397     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR1688398     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR1688396     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR1688399     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000
#> SRR1688400     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000
#> SRR1688402     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR1688401     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000
#> SRR1688403     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR1688404     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR1688405     5  0.6504      1.000 0.008 0.000 0.172 0.308 0.512
#> SRR1688407     5  0.6504      1.000 0.008 0.000 0.172 0.308 0.512
#> SRR1688408     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR1688406     5  0.6504      1.000 0.008 0.000 0.172 0.308 0.512
#> SRR1688410     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR1688411     4  0.0000      0.686 0.000 0.000 0.000 1.000 0.000
#> SRR1688409     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR1688412     4  0.0000      0.686 0.000 0.000 0.000 1.000 0.000
#> SRR1688413     4  0.0000      0.686 0.000 0.000 0.000 1.000 0.000
#> SRR1688414     4  0.0000      0.686 0.000 0.000 0.000 1.000 0.000
#> SRR1688415     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1688357     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688360     2  0.3782      0.312 0.000 0.588 0.000 0.000 0.412 0.000
#> SRR1688361     2  0.3782      0.312 0.000 0.588 0.000 0.000 0.412 0.000
#> SRR1688362     2  0.3782      0.312 0.000 0.588 0.000 0.000 0.412 0.000
#> SRR1688363     5  0.4088      0.199 0.016 0.368 0.000 0.000 0.616 0.000
#> SRR1688365     5  0.4088      0.199 0.016 0.368 0.000 0.000 0.616 0.000
#> SRR1688364     5  0.4088      0.199 0.016 0.368 0.000 0.000 0.616 0.000
#> SRR1688366     5  0.6452      0.414 0.056 0.164 0.000 0.272 0.508 0.000
#> SRR1688367     5  0.6452      0.414 0.056 0.164 0.000 0.272 0.508 0.000
#> SRR1688368     5  0.6385      0.388 0.056 0.144 0.000 0.292 0.508 0.000
#> SRR1688370     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688372     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688373     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688374     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688375     1  0.4654      0.754 0.544 0.000 0.000 0.000 0.044 0.412
#> SRR1688377     1  0.4654      0.754 0.544 0.000 0.000 0.000 0.044 0.412
#> SRR1688378     6  0.1524      0.901 0.060 0.000 0.000 0.000 0.008 0.932
#> SRR1688376     1  0.4654      0.754 0.544 0.000 0.000 0.000 0.044 0.412
#> SRR1688380     6  0.1524      0.901 0.060 0.000 0.000 0.000 0.008 0.932
#> SRR1688379     6  0.1524      0.901 0.060 0.000 0.000 0.000 0.008 0.932
#> SRR1688381     1  0.3747      0.874 0.604 0.000 0.000 0.000 0.000 0.396
#> SRR1688382     1  0.3747      0.874 0.604 0.000 0.000 0.000 0.000 0.396
#> SRR1688383     1  0.3747      0.874 0.604 0.000 0.000 0.000 0.000 0.396
#> SRR1688384     1  0.3706      0.879 0.620 0.000 0.000 0.000 0.000 0.380
#> SRR1688385     1  0.3706      0.879 0.620 0.000 0.000 0.000 0.000 0.380
#> SRR1688386     1  0.3706      0.879 0.620 0.000 0.000 0.000 0.000 0.380
#> SRR1688387     6  0.0260      0.948 0.008 0.000 0.000 0.000 0.000 0.992
#> SRR1688388     6  0.0260      0.948 0.008 0.000 0.000 0.000 0.000 0.992
#> SRR1688389     6  0.0260      0.948 0.008 0.000 0.000 0.000 0.000 0.992
#> SRR1688390     6  0.0000      0.950 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688391     6  0.0000      0.950 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688392     6  0.0000      0.950 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688393     3  0.0891      0.974 0.008 0.000 0.968 0.000 0.024 0.000
#> SRR1688395     3  0.0891      0.974 0.008 0.000 0.968 0.000 0.024 0.000
#> SRR1688394     3  0.0891      0.974 0.008 0.000 0.968 0.000 0.024 0.000
#> SRR1688397     3  0.0405      0.983 0.004 0.000 0.988 0.000 0.008 0.000
#> SRR1688398     3  0.0405      0.983 0.004 0.000 0.988 0.000 0.008 0.000
#> SRR1688396     3  0.0405      0.983 0.004 0.000 0.988 0.000 0.008 0.000
#> SRR1688399     3  0.0146      0.985 0.004 0.000 0.996 0.000 0.000 0.000
#> SRR1688400     3  0.0146      0.985 0.004 0.000 0.996 0.000 0.000 0.000
#> SRR1688402     3  0.0458      0.983 0.016 0.000 0.984 0.000 0.000 0.000
#> SRR1688401     3  0.0146      0.985 0.004 0.000 0.996 0.000 0.000 0.000
#> SRR1688403     3  0.0458      0.983 0.016 0.000 0.984 0.000 0.000 0.000
#> SRR1688404     3  0.0458      0.983 0.016 0.000 0.984 0.000 0.000 0.000
#> SRR1688405     5  0.5974      0.355 0.364 0.000 0.076 0.056 0.504 0.000
#> SRR1688407     5  0.5974      0.355 0.364 0.000 0.076 0.056 0.504 0.000
#> SRR1688408     3  0.0547      0.983 0.020 0.000 0.980 0.000 0.000 0.000
#> SRR1688406     5  0.5974      0.355 0.364 0.000 0.076 0.056 0.504 0.000
#> SRR1688410     3  0.0547      0.983 0.020 0.000 0.980 0.000 0.000 0.000
#> SRR1688411     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688409     3  0.0547      0.983 0.020 0.000 0.980 0.000 0.000 0.000
#> SRR1688412     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688413     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688414     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688415     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-skmeans-collect-classes

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 16435 rows and 62 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 0.626           0.878       0.921         0.4408 0.505   0.505
#> 3 3 0.636           0.760       0.901         0.3923 0.852   0.716
#> 4 4 1.000           0.987       0.994         0.2113 0.806   0.537
#> 5 5 1.000           0.962       0.983         0.0537 0.962   0.852
#> 6 6 1.000           0.989       0.995         0.0162 0.986   0.935

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

There is also optional best \(k\) = 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
#> SRR1688357     2  0.0000      0.791 0.000 1.000
#> SRR1688358     2  0.0000      0.791 0.000 1.000
#> SRR1688359     2  0.0000      0.791 0.000 1.000
#> SRR1688360     2  0.0000      0.791 0.000 1.000
#> SRR1688361     2  0.2423      0.788 0.040 0.960
#> SRR1688362     2  0.6048      0.763 0.148 0.852
#> SRR1688363     2  0.9608      0.644 0.384 0.616
#> SRR1688365     2  0.9686      0.635 0.396 0.604
#> SRR1688364     2  0.9686      0.635 0.396 0.604
#> SRR1688366     2  0.0938      0.791 0.012 0.988
#> SRR1688367     2  0.7219      0.745 0.200 0.800
#> SRR1688368     2  0.9686      0.635 0.396 0.604
#> SRR1688370     2  0.0000      0.791 0.000 1.000
#> SRR1688369     2  0.0000      0.791 0.000 1.000
#> SRR1688371     2  0.0000      0.791 0.000 1.000
#> SRR1688372     2  0.9686      0.635 0.396 0.604
#> SRR1688373     2  0.9686      0.635 0.396 0.604
#> SRR1688374     2  0.9686      0.635 0.396 0.604
#> SRR1688375     1  0.0000      0.995 1.000 0.000
#> SRR1688377     1  0.0000      0.995 1.000 0.000
#> SRR1688378     1  0.0000      0.995 1.000 0.000
#> SRR1688376     1  0.0000      0.995 1.000 0.000
#> SRR1688380     1  0.0000      0.995 1.000 0.000
#> SRR1688379     1  0.0000      0.995 1.000 0.000
#> SRR1688381     1  0.0376      0.990 0.996 0.004
#> SRR1688382     1  0.0000      0.995 1.000 0.000
#> SRR1688383     1  0.5519      0.800 0.872 0.128
#> SRR1688384     1  0.0000      0.995 1.000 0.000
#> SRR1688385     1  0.0000      0.995 1.000 0.000
#> SRR1688386     1  0.0000      0.995 1.000 0.000
#> SRR1688387     1  0.0000      0.995 1.000 0.000
#> SRR1688388     1  0.0000      0.995 1.000 0.000
#> SRR1688389     1  0.0000      0.995 1.000 0.000
#> SRR1688390     1  0.0000      0.995 1.000 0.000
#> SRR1688391     1  0.0000      0.995 1.000 0.000
#> SRR1688392     1  0.0000      0.995 1.000 0.000
#> SRR1688393     1  0.0000      0.995 1.000 0.000
#> SRR1688395     1  0.0000      0.995 1.000 0.000
#> SRR1688394     1  0.0000      0.995 1.000 0.000
#> SRR1688397     1  0.0000      0.995 1.000 0.000
#> SRR1688398     1  0.0000      0.995 1.000 0.000
#> SRR1688396     1  0.0000      0.995 1.000 0.000
#> SRR1688399     1  0.0000      0.995 1.000 0.000
#> SRR1688400     1  0.0000      0.995 1.000 0.000
#> SRR1688402     1  0.0000      0.995 1.000 0.000
#> SRR1688401     1  0.0000      0.995 1.000 0.000
#> SRR1688403     1  0.0000      0.995 1.000 0.000
#> SRR1688404     1  0.0000      0.995 1.000 0.000
#> SRR1688405     1  0.0000      0.995 1.000 0.000
#> SRR1688407     1  0.0000      0.995 1.000 0.000
#> SRR1688408     1  0.0000      0.995 1.000 0.000
#> SRR1688406     1  0.0000      0.995 1.000 0.000
#> SRR1688410     1  0.0000      0.995 1.000 0.000
#> SRR1688411     2  0.9686      0.635 0.396 0.604
#> SRR1688409     1  0.0000      0.995 1.000 0.000
#> SRR1688412     2  0.9686      0.635 0.396 0.604
#> SRR1688413     2  0.9686      0.635 0.396 0.604
#> SRR1688414     2  0.9686      0.635 0.396 0.604
#> SRR1688415     2  0.0000      0.791 0.000 1.000
#> SRR1688416     2  0.0000      0.791 0.000 1.000
#> SRR1688417     2  0.0000      0.791 0.000 1.000
#> SRR1688418     2  0.0000      0.791 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2  0.0000     0.8942 0.000 1.000 0.000
#> SRR1688358     2  0.0000     0.8942 0.000 1.000 0.000
#> SRR1688359     2  0.0000     0.8942 0.000 1.000 0.000
#> SRR1688360     2  0.0000     0.8942 0.000 1.000 0.000
#> SRR1688361     2  0.1529     0.8693 0.000 0.960 0.040
#> SRR1688362     2  0.3752     0.7789 0.000 0.856 0.144
#> SRR1688363     2  0.4399     0.7286 0.000 0.812 0.188
#> SRR1688365     2  0.6527     0.6545 0.068 0.744 0.188
#> SRR1688364     2  0.5115     0.7145 0.016 0.796 0.188
#> SRR1688366     2  0.6754     0.0584 0.432 0.556 0.012
#> SRR1688367     1  0.9062     0.1494 0.452 0.412 0.136
#> SRR1688368     1  0.0237     0.8511 0.996 0.000 0.004
#> SRR1688370     2  0.0000     0.8942 0.000 1.000 0.000
#> SRR1688369     2  0.0000     0.8942 0.000 1.000 0.000
#> SRR1688371     2  0.0000     0.8942 0.000 1.000 0.000
#> SRR1688372     1  0.0000     0.8527 1.000 0.000 0.000
#> SRR1688373     1  0.0000     0.8527 1.000 0.000 0.000
#> SRR1688374     1  0.0000     0.8527 1.000 0.000 0.000
#> SRR1688375     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688377     3  0.0592     0.8615 0.012 0.000 0.988
#> SRR1688378     3  0.3686     0.7734 0.140 0.000 0.860
#> SRR1688376     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688380     3  0.5291     0.6315 0.268 0.000 0.732
#> SRR1688379     3  0.3941     0.7589 0.156 0.000 0.844
#> SRR1688381     1  0.5098     0.6159 0.752 0.000 0.248
#> SRR1688382     1  0.5678     0.4719 0.684 0.000 0.316
#> SRR1688383     1  0.4555     0.6868 0.800 0.000 0.200
#> SRR1688384     3  0.6140     0.3998 0.404 0.000 0.596
#> SRR1688385     3  0.6154     0.3906 0.408 0.000 0.592
#> SRR1688386     3  0.6140     0.3998 0.404 0.000 0.596
#> SRR1688387     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688388     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688389     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688390     3  0.6192     0.3612 0.420 0.000 0.580
#> SRR1688391     3  0.6252     0.2953 0.444 0.000 0.556
#> SRR1688392     3  0.6252     0.2953 0.444 0.000 0.556
#> SRR1688393     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688395     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688394     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688397     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688398     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688396     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688399     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688400     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688402     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688401     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688403     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688404     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688405     3  0.1163     0.8533 0.028 0.000 0.972
#> SRR1688407     3  0.5529     0.5859 0.296 0.000 0.704
#> SRR1688408     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688406     3  0.3192     0.7962 0.112 0.000 0.888
#> SRR1688410     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688411     1  0.0000     0.8527 1.000 0.000 0.000
#> SRR1688409     3  0.0000     0.8669 0.000 0.000 1.000
#> SRR1688412     1  0.0000     0.8527 1.000 0.000 0.000
#> SRR1688413     1  0.0000     0.8527 1.000 0.000 0.000
#> SRR1688414     1  0.0000     0.8527 1.000 0.000 0.000
#> SRR1688415     2  0.0000     0.8942 0.000 1.000 0.000
#> SRR1688416     2  0.0000     0.8942 0.000 1.000 0.000
#> SRR1688417     2  0.0000     0.8942 0.000 1.000 0.000
#> SRR1688418     2  0.0000     0.8942 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1688357     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> SRR1688358     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> SRR1688359     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> SRR1688360     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> SRR1688361     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> SRR1688362     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> SRR1688363     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> SRR1688365     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> SRR1688364     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> SRR1688366     2  0.0921      0.964 0.000 0.972 0.000 0.028
#> SRR1688367     2  0.3219      0.808 0.000 0.836 0.000 0.164
#> SRR1688368     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688370     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> SRR1688369     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> SRR1688371     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> SRR1688372     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688373     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688374     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688375     1  0.0817      0.971 0.976 0.000 0.024 0.000
#> SRR1688377     1  0.0707      0.974 0.980 0.000 0.020 0.000
#> SRR1688378     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR1688376     1  0.0707      0.974 0.980 0.000 0.020 0.000
#> SRR1688380     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR1688381     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR1688382     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR1688383     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR1688384     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR1688385     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR1688386     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR1688387     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR1688388     1  0.1211      0.954 0.960 0.000 0.040 0.000
#> SRR1688389     1  0.2149      0.898 0.912 0.000 0.088 0.000
#> SRR1688390     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688395     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688394     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688397     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688398     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688396     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688399     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688400     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688402     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688401     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688403     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688404     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688405     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688407     3  0.0188      0.996 0.004 0.000 0.996 0.000
#> SRR1688408     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688406     3  0.0188      0.996 0.004 0.000 0.996 0.000
#> SRR1688410     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688411     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688409     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1688412     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688413     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688414     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688415     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> SRR1688416     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> SRR1688417     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> SRR1688418     2  0.0000      0.989 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1688357     2  0.0000      0.985 0.000 1.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.985 0.000 1.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.985 0.000 1.000 0.000 0.000 0.000
#> SRR1688360     2  0.0000      0.985 0.000 1.000 0.000 0.000 0.000
#> SRR1688361     2  0.0290      0.982 0.008 0.992 0.000 0.000 0.000
#> SRR1688362     2  0.0290      0.982 0.008 0.992 0.000 0.000 0.000
#> SRR1688363     2  0.0290      0.982 0.008 0.992 0.000 0.000 0.000
#> SRR1688365     2  0.0290      0.982 0.008 0.992 0.000 0.000 0.000
#> SRR1688364     2  0.0290      0.982 0.008 0.992 0.000 0.000 0.000
#> SRR1688366     2  0.0955      0.963 0.004 0.968 0.000 0.028 0.000
#> SRR1688367     2  0.3053      0.805 0.008 0.828 0.000 0.164 0.000
#> SRR1688368     4  0.0162      0.994 0.004 0.000 0.000 0.996 0.000
#> SRR1688370     2  0.0000      0.985 0.000 1.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000      0.985 0.000 1.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000      0.985 0.000 1.000 0.000 0.000 0.000
#> SRR1688372     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> SRR1688373     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> SRR1688374     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> SRR1688375     1  0.0000      0.929 1.000 0.000 0.000 0.000 0.000
#> SRR1688377     1  0.0000      0.929 1.000 0.000 0.000 0.000 0.000
#> SRR1688378     1  0.4201      0.381 0.592 0.000 0.000 0.000 0.408
#> SRR1688376     1  0.0000      0.929 1.000 0.000 0.000 0.000 0.000
#> SRR1688380     1  0.0880      0.906 0.968 0.000 0.000 0.000 0.032
#> SRR1688379     1  0.3876      0.570 0.684 0.000 0.000 0.000 0.316
#> SRR1688381     1  0.0000      0.929 1.000 0.000 0.000 0.000 0.000
#> SRR1688382     1  0.0000      0.929 1.000 0.000 0.000 0.000 0.000
#> SRR1688383     1  0.0000      0.929 1.000 0.000 0.000 0.000 0.000
#> SRR1688384     1  0.0000      0.929 1.000 0.000 0.000 0.000 0.000
#> SRR1688385     1  0.0000      0.929 1.000 0.000 0.000 0.000 0.000
#> SRR1688386     1  0.0000      0.929 1.000 0.000 0.000 0.000 0.000
#> SRR1688387     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688388     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688389     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688390     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688391     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688392     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688393     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR1688395     3  0.0290      0.992 0.008 0.000 0.992 0.000 0.000
#> SRR1688394     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR1688397     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR1688398     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR1688396     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR1688399     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR1688400     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR1688402     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR1688401     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR1688403     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR1688404     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR1688405     3  0.0290      0.992 0.008 0.000 0.992 0.000 0.000
#> SRR1688407     3  0.0404      0.989 0.012 0.000 0.988 0.000 0.000
#> SRR1688408     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR1688406     3  0.0404      0.989 0.012 0.000 0.988 0.000 0.000
#> SRR1688410     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR1688411     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> SRR1688409     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR1688412     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> SRR1688413     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> SRR1688414     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> SRR1688415     2  0.0000      0.985 0.000 1.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.985 0.000 1.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.985 0.000 1.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.985 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4 p5 p6
#> SRR1688357     2  0.0000      0.983 0.000 1.000 0.000 0.000  0  0
#> SRR1688358     2  0.0000      0.983 0.000 1.000 0.000 0.000  0  0
#> SRR1688359     2  0.0000      0.983 0.000 1.000 0.000 0.000  0  0
#> SRR1688360     2  0.0000      0.983 0.000 1.000 0.000 0.000  0  0
#> SRR1688361     2  0.0363      0.978 0.012 0.988 0.000 0.000  0  0
#> SRR1688362     2  0.0363      0.978 0.012 0.988 0.000 0.000  0  0
#> SRR1688363     2  0.0363      0.978 0.012 0.988 0.000 0.000  0  0
#> SRR1688365     2  0.0363      0.978 0.012 0.988 0.000 0.000  0  0
#> SRR1688364     2  0.0363      0.978 0.012 0.988 0.000 0.000  0  0
#> SRR1688366     2  0.0858      0.960 0.004 0.968 0.000 0.028  0  0
#> SRR1688367     2  0.2805      0.797 0.012 0.828 0.000 0.160  0  0
#> SRR1688368     4  0.0146      0.994 0.004 0.000 0.000 0.996  0  0
#> SRR1688370     2  0.0000      0.983 0.000 1.000 0.000 0.000  0  0
#> SRR1688369     2  0.0000      0.983 0.000 1.000 0.000 0.000  0  0
#> SRR1688371     2  0.0000      0.983 0.000 1.000 0.000 0.000  0  0
#> SRR1688372     4  0.0000      0.999 0.000 0.000 0.000 1.000  0  0
#> SRR1688373     4  0.0000      0.999 0.000 0.000 0.000 1.000  0  0
#> SRR1688374     4  0.0000      0.999 0.000 0.000 0.000 1.000  0  0
#> SRR1688375     1  0.0000      1.000 1.000 0.000 0.000 0.000  0  0
#> SRR1688377     1  0.0000      1.000 1.000 0.000 0.000 0.000  0  0
#> SRR1688378     6  0.0000      1.000 0.000 0.000 0.000 0.000  0  1
#> SRR1688376     1  0.0000      1.000 1.000 0.000 0.000 0.000  0  0
#> SRR1688380     6  0.0000      1.000 0.000 0.000 0.000 0.000  0  1
#> SRR1688379     6  0.0000      1.000 0.000 0.000 0.000 0.000  0  1
#> SRR1688381     1  0.0000      1.000 1.000 0.000 0.000 0.000  0  0
#> SRR1688382     1  0.0000      1.000 1.000 0.000 0.000 0.000  0  0
#> SRR1688383     1  0.0000      1.000 1.000 0.000 0.000 0.000  0  0
#> SRR1688384     1  0.0000      1.000 1.000 0.000 0.000 0.000  0  0
#> SRR1688385     1  0.0000      1.000 1.000 0.000 0.000 0.000  0  0
#> SRR1688386     1  0.0000      1.000 1.000 0.000 0.000 0.000  0  0
#> SRR1688387     5  0.0000      1.000 0.000 0.000 0.000 0.000  1  0
#> SRR1688388     5  0.0000      1.000 0.000 0.000 0.000 0.000  1  0
#> SRR1688389     5  0.0000      1.000 0.000 0.000 0.000 0.000  1  0
#> SRR1688390     5  0.0000      1.000 0.000 0.000 0.000 0.000  1  0
#> SRR1688391     5  0.0000      1.000 0.000 0.000 0.000 0.000  1  0
#> SRR1688392     5  0.0000      1.000 0.000 0.000 0.000 0.000  1  0
#> SRR1688393     3  0.0000      0.996 0.000 0.000 1.000 0.000  0  0
#> SRR1688395     3  0.0363      0.987 0.012 0.000 0.988 0.000  0  0
#> SRR1688394     3  0.0000      0.996 0.000 0.000 1.000 0.000  0  0
#> SRR1688397     3  0.0000      0.996 0.000 0.000 1.000 0.000  0  0
#> SRR1688398     3  0.0000      0.996 0.000 0.000 1.000 0.000  0  0
#> SRR1688396     3  0.0000      0.996 0.000 0.000 1.000 0.000  0  0
#> SRR1688399     3  0.0000      0.996 0.000 0.000 1.000 0.000  0  0
#> SRR1688400     3  0.0000      0.996 0.000 0.000 1.000 0.000  0  0
#> SRR1688402     3  0.0000      0.996 0.000 0.000 1.000 0.000  0  0
#> SRR1688401     3  0.0000      0.996 0.000 0.000 1.000 0.000  0  0
#> SRR1688403     3  0.0000      0.996 0.000 0.000 1.000 0.000  0  0
#> SRR1688404     3  0.0000      0.996 0.000 0.000 1.000 0.000  0  0
#> SRR1688405     3  0.0363      0.987 0.012 0.000 0.988 0.000  0  0
#> SRR1688407     3  0.0458      0.984 0.016 0.000 0.984 0.000  0  0
#> SRR1688408     3  0.0000      0.996 0.000 0.000 1.000 0.000  0  0
#> SRR1688406     3  0.0458      0.984 0.016 0.000 0.984 0.000  0  0
#> SRR1688410     3  0.0000      0.996 0.000 0.000 1.000 0.000  0  0
#> SRR1688411     4  0.0000      0.999 0.000 0.000 0.000 1.000  0  0
#> SRR1688409     3  0.0000      0.996 0.000 0.000 1.000 0.000  0  0
#> SRR1688412     4  0.0000      0.999 0.000 0.000 0.000 1.000  0  0
#> SRR1688413     4  0.0000      0.999 0.000 0.000 0.000 1.000  0  0
#> SRR1688414     4  0.0000      0.999 0.000 0.000 0.000 1.000  0  0
#> SRR1688415     2  0.0000      0.983 0.000 1.000 0.000 0.000  0  0
#> SRR1688416     2  0.0000      0.983 0.000 1.000 0.000 0.000  0  0
#> SRR1688417     2  0.0000      0.983 0.000 1.000 0.000 0.000  0  0
#> SRR1688418     2  0.0000      0.983 0.000 1.000 0.000 0.000  0  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 16435 rows and 62 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           1.000       1.000         0.4955 0.505   0.505
#> 3 3 0.936           0.943       0.953         0.3237 0.829   0.661
#> 4 4 0.972           0.971       0.983         0.1181 0.876   0.658
#> 5 5 1.000           0.998       0.998         0.0827 0.937   0.765
#> 6 6 0.897           0.924       0.889         0.0376 0.957   0.792

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
#> SRR1688357     2       0          1  0  1
#> SRR1688358     2       0          1  0  1
#> SRR1688359     2       0          1  0  1
#> SRR1688360     2       0          1  0  1
#> SRR1688361     2       0          1  0  1
#> SRR1688362     2       0          1  0  1
#> SRR1688363     2       0          1  0  1
#> SRR1688365     2       0          1  0  1
#> SRR1688364     2       0          1  0  1
#> SRR1688366     2       0          1  0  1
#> SRR1688367     2       0          1  0  1
#> SRR1688368     2       0          1  0  1
#> SRR1688370     2       0          1  0  1
#> SRR1688369     2       0          1  0  1
#> SRR1688371     2       0          1  0  1
#> SRR1688372     2       0          1  0  1
#> SRR1688373     2       0          1  0  1
#> SRR1688374     2       0          1  0  1
#> SRR1688375     1       0          1  1  0
#> SRR1688377     1       0          1  1  0
#> SRR1688378     1       0          1  1  0
#> SRR1688376     1       0          1  1  0
#> SRR1688380     1       0          1  1  0
#> SRR1688379     1       0          1  1  0
#> SRR1688381     1       0          1  1  0
#> SRR1688382     1       0          1  1  0
#> SRR1688383     1       0          1  1  0
#> SRR1688384     1       0          1  1  0
#> SRR1688385     1       0          1  1  0
#> SRR1688386     1       0          1  1  0
#> SRR1688387     1       0          1  1  0
#> SRR1688388     1       0          1  1  0
#> SRR1688389     1       0          1  1  0
#> SRR1688390     1       0          1  1  0
#> SRR1688391     1       0          1  1  0
#> SRR1688392     1       0          1  1  0
#> SRR1688393     1       0          1  1  0
#> SRR1688395     1       0          1  1  0
#> SRR1688394     1       0          1  1  0
#> SRR1688397     1       0          1  1  0
#> SRR1688398     1       0          1  1  0
#> SRR1688396     1       0          1  1  0
#> SRR1688399     1       0          1  1  0
#> SRR1688400     1       0          1  1  0
#> SRR1688402     1       0          1  1  0
#> SRR1688401     1       0          1  1  0
#> SRR1688403     1       0          1  1  0
#> SRR1688404     1       0          1  1  0
#> SRR1688405     1       0          1  1  0
#> SRR1688407     1       0          1  1  0
#> SRR1688408     1       0          1  1  0
#> SRR1688406     1       0          1  1  0
#> SRR1688410     1       0          1  1  0
#> SRR1688411     2       0          1  0  1
#> SRR1688409     1       0          1  1  0
#> SRR1688412     2       0          1  0  1
#> SRR1688413     2       0          1  0  1
#> SRR1688414     2       0          1  0  1
#> SRR1688415     2       0          1  0  1
#> SRR1688416     2       0          1  0  1
#> SRR1688417     2       0          1  0  1
#> SRR1688418     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2   0.245      0.960 0.076 0.924 0.000
#> SRR1688358     2   0.245      0.960 0.076 0.924 0.000
#> SRR1688359     2   0.245      0.960 0.076 0.924 0.000
#> SRR1688360     2   0.245      0.960 0.076 0.924 0.000
#> SRR1688361     2   0.245      0.960 0.076 0.924 0.000
#> SRR1688362     2   0.245      0.960 0.076 0.924 0.000
#> SRR1688363     2   0.254      0.959 0.080 0.920 0.000
#> SRR1688365     2   0.254      0.959 0.080 0.920 0.000
#> SRR1688364     2   0.254      0.959 0.080 0.920 0.000
#> SRR1688366     2   0.475      0.912 0.080 0.852 0.068
#> SRR1688367     2   0.475      0.912 0.080 0.852 0.068
#> SRR1688368     2   0.637      0.812 0.084 0.764 0.152
#> SRR1688370     2   0.245      0.960 0.076 0.924 0.000
#> SRR1688369     2   0.245      0.960 0.076 0.924 0.000
#> SRR1688371     2   0.245      0.960 0.076 0.924 0.000
#> SRR1688372     2   0.103      0.923 0.024 0.976 0.000
#> SRR1688373     2   0.103      0.923 0.024 0.976 0.000
#> SRR1688374     2   0.103      0.923 0.024 0.976 0.000
#> SRR1688375     1   0.000      0.982 1.000 0.000 0.000
#> SRR1688377     1   0.000      0.982 1.000 0.000 0.000
#> SRR1688378     1   0.000      0.982 1.000 0.000 0.000
#> SRR1688376     1   0.000      0.982 1.000 0.000 0.000
#> SRR1688380     1   0.000      0.982 1.000 0.000 0.000
#> SRR1688379     1   0.000      0.982 1.000 0.000 0.000
#> SRR1688381     1   0.000      0.982 1.000 0.000 0.000
#> SRR1688382     1   0.000      0.982 1.000 0.000 0.000
#> SRR1688383     1   0.000      0.982 1.000 0.000 0.000
#> SRR1688384     1   0.000      0.982 1.000 0.000 0.000
#> SRR1688385     1   0.000      0.982 1.000 0.000 0.000
#> SRR1688386     1   0.000      0.982 1.000 0.000 0.000
#> SRR1688387     1   0.288      0.902 0.904 0.000 0.096
#> SRR1688388     1   0.288      0.902 0.904 0.000 0.096
#> SRR1688389     1   0.288      0.902 0.904 0.000 0.096
#> SRR1688390     1   0.000      0.982 1.000 0.000 0.000
#> SRR1688391     1   0.000      0.982 1.000 0.000 0.000
#> SRR1688392     1   0.000      0.982 1.000 0.000 0.000
#> SRR1688393     3   0.000      0.958 0.000 0.000 1.000
#> SRR1688395     3   0.000      0.958 0.000 0.000 1.000
#> SRR1688394     3   0.000      0.958 0.000 0.000 1.000
#> SRR1688397     3   0.000      0.958 0.000 0.000 1.000
#> SRR1688398     3   0.000      0.958 0.000 0.000 1.000
#> SRR1688396     3   0.000      0.958 0.000 0.000 1.000
#> SRR1688399     3   0.000      0.958 0.000 0.000 1.000
#> SRR1688400     3   0.000      0.958 0.000 0.000 1.000
#> SRR1688402     3   0.000      0.958 0.000 0.000 1.000
#> SRR1688401     3   0.000      0.958 0.000 0.000 1.000
#> SRR1688403     3   0.000      0.958 0.000 0.000 1.000
#> SRR1688404     3   0.000      0.958 0.000 0.000 1.000
#> SRR1688405     3   0.571      0.745 0.204 0.028 0.768
#> SRR1688407     3   0.571      0.745 0.204 0.028 0.768
#> SRR1688408     3   0.000      0.958 0.000 0.000 1.000
#> SRR1688406     3   0.571      0.745 0.204 0.028 0.768
#> SRR1688410     3   0.000      0.958 0.000 0.000 1.000
#> SRR1688411     2   0.103      0.923 0.024 0.976 0.000
#> SRR1688409     3   0.000      0.958 0.000 0.000 1.000
#> SRR1688412     2   0.103      0.923 0.024 0.976 0.000
#> SRR1688413     2   0.103      0.923 0.024 0.976 0.000
#> SRR1688414     2   0.103      0.923 0.024 0.976 0.000
#> SRR1688415     2   0.245      0.960 0.076 0.924 0.000
#> SRR1688416     2   0.245      0.960 0.076 0.924 0.000
#> SRR1688417     2   0.245      0.960 0.076 0.924 0.000
#> SRR1688418     2   0.245      0.960 0.076 0.924 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1688357     2  0.0000      0.955 0.000 1.000 0.000 0.000
#> SRR1688358     2  0.0000      0.955 0.000 1.000 0.000 0.000
#> SRR1688359     2  0.0000      0.955 0.000 1.000 0.000 0.000
#> SRR1688360     2  0.0188      0.954 0.004 0.996 0.000 0.000
#> SRR1688361     2  0.0188      0.954 0.004 0.996 0.000 0.000
#> SRR1688362     2  0.0188      0.954 0.004 0.996 0.000 0.000
#> SRR1688363     2  0.0672      0.951 0.008 0.984 0.000 0.008
#> SRR1688365     2  0.0672      0.951 0.008 0.984 0.000 0.008
#> SRR1688364     2  0.0672      0.951 0.008 0.984 0.000 0.008
#> SRR1688366     2  0.2675      0.893 0.008 0.892 0.000 0.100
#> SRR1688367     2  0.2675      0.893 0.008 0.892 0.000 0.100
#> SRR1688368     2  0.2799      0.886 0.008 0.884 0.000 0.108
#> SRR1688370     2  0.0000      0.955 0.000 1.000 0.000 0.000
#> SRR1688369     2  0.0000      0.955 0.000 1.000 0.000 0.000
#> SRR1688371     2  0.0000      0.955 0.000 1.000 0.000 0.000
#> SRR1688372     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688373     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688374     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688375     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688377     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688378     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688376     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688380     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688381     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688382     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688383     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688384     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688385     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688386     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688387     1  0.0921      0.970 0.972 0.000 0.028 0.000
#> SRR1688388     1  0.0921      0.970 0.972 0.000 0.028 0.000
#> SRR1688389     1  0.0921      0.970 0.972 0.000 0.028 0.000
#> SRR1688390     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.994 1.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688405     2  0.4569      0.813 0.036 0.808 0.140 0.016
#> SRR1688407     2  0.4569      0.813 0.036 0.808 0.140 0.016
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688406     2  0.4569      0.813 0.036 0.808 0.140 0.016
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688411     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688412     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688413     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688414     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688415     2  0.0000      0.955 0.000 1.000 0.000 0.000
#> SRR1688416     2  0.0000      0.955 0.000 1.000 0.000 0.000
#> SRR1688417     2  0.0000      0.955 0.000 1.000 0.000 0.000
#> SRR1688418     2  0.0000      0.955 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1   p2 p3 p4    p5
#> SRR1688357     2  0.0000      1.000 0.000 1.00  0  0 0.000
#> SRR1688358     2  0.0000      1.000 0.000 1.00  0  0 0.000
#> SRR1688359     2  0.0000      1.000 0.000 1.00  0  0 0.000
#> SRR1688360     5  0.0609      0.982 0.000 0.02  0  0 0.980
#> SRR1688361     5  0.0609      0.982 0.000 0.02  0  0 0.980
#> SRR1688362     5  0.0609      0.982 0.000 0.02  0  0 0.980
#> SRR1688363     5  0.0000      0.994 0.000 0.00  0  0 1.000
#> SRR1688365     5  0.0000      0.994 0.000 0.00  0  0 1.000
#> SRR1688364     5  0.0000      0.994 0.000 0.00  0  0 1.000
#> SRR1688366     5  0.0000      0.994 0.000 0.00  0  0 1.000
#> SRR1688367     5  0.0000      0.994 0.000 0.00  0  0 1.000
#> SRR1688368     5  0.0000      0.994 0.000 0.00  0  0 1.000
#> SRR1688370     2  0.0000      1.000 0.000 1.00  0  0 0.000
#> SRR1688369     2  0.0000      1.000 0.000 1.00  0  0 0.000
#> SRR1688371     2  0.0000      1.000 0.000 1.00  0  0 0.000
#> SRR1688372     4  0.0000      1.000 0.000 0.00  0  1 0.000
#> SRR1688373     4  0.0000      1.000 0.000 0.00  0  1 0.000
#> SRR1688374     4  0.0000      1.000 0.000 0.00  0  1 0.000
#> SRR1688375     1  0.0162      0.998 0.996 0.00  0  0 0.004
#> SRR1688377     1  0.0162      0.998 0.996 0.00  0  0 0.004
#> SRR1688378     1  0.0000      0.998 1.000 0.00  0  0 0.000
#> SRR1688376     1  0.0162      0.998 0.996 0.00  0  0 0.004
#> SRR1688380     1  0.0000      0.998 1.000 0.00  0  0 0.000
#> SRR1688379     1  0.0000      0.998 1.000 0.00  0  0 0.000
#> SRR1688381     1  0.0162      0.998 0.996 0.00  0  0 0.004
#> SRR1688382     1  0.0162      0.998 0.996 0.00  0  0 0.004
#> SRR1688383     1  0.0162      0.998 0.996 0.00  0  0 0.004
#> SRR1688384     1  0.0162      0.998 0.996 0.00  0  0 0.004
#> SRR1688385     1  0.0162      0.998 0.996 0.00  0  0 0.004
#> SRR1688386     1  0.0162      0.998 0.996 0.00  0  0 0.004
#> SRR1688387     1  0.0000      0.998 1.000 0.00  0  0 0.000
#> SRR1688388     1  0.0000      0.998 1.000 0.00  0  0 0.000
#> SRR1688389     1  0.0000      0.998 1.000 0.00  0  0 0.000
#> SRR1688390     1  0.0000      0.998 1.000 0.00  0  0 0.000
#> SRR1688391     1  0.0000      0.998 1.000 0.00  0  0 0.000
#> SRR1688392     1  0.0000      0.998 1.000 0.00  0  0 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.00  1  0 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.00  1  0 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.00  1  0 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.00  1  0 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.00  1  0 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.00  1  0 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.00  1  0 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.00  1  0 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.00  1  0 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.00  1  0 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.00  1  0 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.00  1  0 0.000
#> SRR1688405     5  0.0000      0.994 0.000 0.00  0  0 1.000
#> SRR1688407     5  0.0000      0.994 0.000 0.00  0  0 1.000
#> SRR1688408     3  0.0000      1.000 0.000 0.00  1  0 0.000
#> SRR1688406     5  0.0000      0.994 0.000 0.00  0  0 1.000
#> SRR1688410     3  0.0000      1.000 0.000 0.00  1  0 0.000
#> SRR1688411     4  0.0000      1.000 0.000 0.00  0  1 0.000
#> SRR1688409     3  0.0000      1.000 0.000 0.00  1  0 0.000
#> SRR1688412     4  0.0000      1.000 0.000 0.00  0  1 0.000
#> SRR1688413     4  0.0000      1.000 0.000 0.00  0  1 0.000
#> SRR1688414     4  0.0000      1.000 0.000 0.00  0  1 0.000
#> SRR1688415     2  0.0000      1.000 0.000 1.00  0  0 0.000
#> SRR1688416     2  0.0000      1.000 0.000 1.00  0  0 0.000
#> SRR1688417     2  0.0000      1.000 0.000 1.00  0  0 0.000
#> SRR1688418     2  0.0000      1.000 0.000 1.00  0  0 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3 p4    p5    p6
#> SRR1688357     2  0.0000      0.998 0.000 1.000  0  0 0.000 0.000
#> SRR1688358     2  0.0000      0.998 0.000 1.000  0  0 0.000 0.000
#> SRR1688359     2  0.0000      0.998 0.000 1.000  0  0 0.000 0.000
#> SRR1688360     5  0.2527      0.771 0.000 0.168  0  0 0.832 0.000
#> SRR1688361     5  0.2527      0.771 0.000 0.168  0  0 0.832 0.000
#> SRR1688362     5  0.2527      0.771 0.000 0.168  0  0 0.832 0.000
#> SRR1688363     5  0.2003      0.800 0.000 0.116  0  0 0.884 0.000
#> SRR1688365     5  0.2003      0.800 0.000 0.116  0  0 0.884 0.000
#> SRR1688364     5  0.2003      0.800 0.000 0.116  0  0 0.884 0.000
#> SRR1688366     5  0.2178      0.790 0.000 0.000  0  0 0.868 0.132
#> SRR1688367     5  0.2178      0.790 0.000 0.000  0  0 0.868 0.132
#> SRR1688368     5  0.2178      0.790 0.000 0.000  0  0 0.868 0.132
#> SRR1688370     2  0.0146      0.995 0.000 0.996  0  0 0.004 0.000
#> SRR1688369     2  0.0000      0.998 0.000 1.000  0  0 0.000 0.000
#> SRR1688371     2  0.0458      0.984 0.000 0.984  0  0 0.016 0.000
#> SRR1688372     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1688373     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1688374     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1688375     1  0.2416      0.763 0.844 0.000  0  0 0.000 0.156
#> SRR1688377     1  0.2416      0.763 0.844 0.000  0  0 0.000 0.156
#> SRR1688378     6  0.3774      0.946 0.408 0.000  0  0 0.000 0.592
#> SRR1688376     1  0.2416      0.763 0.844 0.000  0  0 0.000 0.156
#> SRR1688380     6  0.3774      0.946 0.408 0.000  0  0 0.000 0.592
#> SRR1688379     6  0.3774      0.946 0.408 0.000  0  0 0.000 0.592
#> SRR1688381     1  0.0000      0.902 1.000 0.000  0  0 0.000 0.000
#> SRR1688382     1  0.0000      0.902 1.000 0.000  0  0 0.000 0.000
#> SRR1688383     1  0.0000      0.902 1.000 0.000  0  0 0.000 0.000
#> SRR1688384     1  0.0000      0.902 1.000 0.000  0  0 0.000 0.000
#> SRR1688385     1  0.0000      0.902 1.000 0.000  0  0 0.000 0.000
#> SRR1688386     1  0.0000      0.902 1.000 0.000  0  0 0.000 0.000
#> SRR1688387     6  0.3833      0.936 0.444 0.000  0  0 0.000 0.556
#> SRR1688388     6  0.3833      0.936 0.444 0.000  0  0 0.000 0.556
#> SRR1688389     6  0.3833      0.936 0.444 0.000  0  0 0.000 0.556
#> SRR1688390     6  0.3833      0.942 0.444 0.000  0  0 0.000 0.556
#> SRR1688391     6  0.3833      0.942 0.444 0.000  0  0 0.000 0.556
#> SRR1688392     6  0.3833      0.942 0.444 0.000  0  0 0.000 0.556
#> SRR1688393     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688405     5  0.3756      0.681 0.000 0.000  0  0 0.600 0.400
#> SRR1688407     5  0.3756      0.681 0.000 0.000  0  0 0.600 0.400
#> SRR1688408     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688406     5  0.3756      0.681 0.000 0.000  0  0 0.600 0.400
#> SRR1688410     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688411     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688412     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1688413     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1688414     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1688415     2  0.0000      0.998 0.000 1.000  0  0 0.000 0.000
#> SRR1688416     2  0.0000      0.998 0.000 1.000  0  0 0.000 0.000
#> SRR1688417     2  0.0000      0.998 0.000 1.000  0  0 0.000 0.000
#> SRR1688418     2  0.0000      0.998 0.000 1.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-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 16435 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.243           0.732       0.766         0.4756 0.505   0.505
#> 3 3 1.000           0.986       0.987         0.4008 0.829   0.661
#> 4 4 0.849           0.909       0.905         0.1086 0.924   0.772
#> 5 5 0.896           0.909       0.931         0.0690 0.919   0.702
#> 6 6 0.863           0.805       0.855         0.0438 0.986   0.930

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

suggest_best_k(res)
#> [1] 3

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1688357     2   0.697      0.879 0.188 0.812
#> SRR1688358     2   0.697      0.879 0.188 0.812
#> SRR1688359     2   0.697      0.879 0.188 0.812
#> SRR1688360     2   0.697      0.879 0.188 0.812
#> SRR1688361     2   0.697      0.879 0.188 0.812
#> SRR1688362     2   0.697      0.879 0.188 0.812
#> SRR1688363     2   0.671      0.878 0.176 0.824
#> SRR1688365     2   0.574      0.869 0.136 0.864
#> SRR1688364     2   0.605      0.873 0.148 0.852
#> SRR1688366     2   0.278      0.831 0.048 0.952
#> SRR1688367     2   0.163      0.816 0.024 0.976
#> SRR1688368     2   0.000      0.793 0.000 1.000
#> SRR1688370     2   0.697      0.879 0.188 0.812
#> SRR1688369     2   0.697      0.879 0.188 0.812
#> SRR1688371     2   0.697      0.879 0.188 0.812
#> SRR1688372     2   0.163      0.805 0.024 0.976
#> SRR1688373     2   0.163      0.805 0.024 0.976
#> SRR1688374     2   0.163      0.805 0.024 0.976
#> SRR1688375     1   0.971      0.645 0.600 0.400
#> SRR1688377     1   0.973      0.644 0.596 0.404
#> SRR1688378     1   0.978      0.640 0.588 0.412
#> SRR1688376     1   0.975      0.642 0.592 0.408
#> SRR1688380     1   0.978      0.640 0.588 0.412
#> SRR1688379     1   0.978      0.640 0.588 0.412
#> SRR1688381     1   0.978      0.640 0.588 0.412
#> SRR1688382     1   0.978      0.640 0.588 0.412
#> SRR1688383     1   0.978      0.640 0.588 0.412
#> SRR1688384     1   0.978      0.640 0.588 0.412
#> SRR1688385     1   0.978      0.640 0.588 0.412
#> SRR1688386     1   0.978      0.640 0.588 0.412
#> SRR1688387     1   0.971      0.645 0.600 0.400
#> SRR1688388     1   0.966      0.646 0.608 0.392
#> SRR1688389     1   0.963      0.647 0.612 0.388
#> SRR1688390     1   0.978      0.640 0.588 0.412
#> SRR1688391     1   0.978      0.640 0.588 0.412
#> SRR1688392     1   0.978      0.640 0.588 0.412
#> SRR1688393     1   0.518      0.651 0.884 0.116
#> SRR1688395     1   0.518      0.651 0.884 0.116
#> SRR1688394     1   0.518      0.651 0.884 0.116
#> SRR1688397     1   0.518      0.651 0.884 0.116
#> SRR1688398     1   0.518      0.651 0.884 0.116
#> SRR1688396     1   0.518      0.651 0.884 0.116
#> SRR1688399     1   0.518      0.651 0.884 0.116
#> SRR1688400     1   0.518      0.651 0.884 0.116
#> SRR1688402     1   0.518      0.651 0.884 0.116
#> SRR1688401     1   0.518      0.651 0.884 0.116
#> SRR1688403     1   0.518      0.651 0.884 0.116
#> SRR1688404     1   0.518      0.651 0.884 0.116
#> SRR1688405     1   0.469      0.655 0.900 0.100
#> SRR1688407     1   0.443      0.656 0.908 0.092
#> SRR1688408     1   0.518      0.651 0.884 0.116
#> SRR1688406     1   0.443      0.657 0.908 0.092
#> SRR1688410     1   0.518      0.651 0.884 0.116
#> SRR1688411     2   0.163      0.805 0.024 0.976
#> SRR1688409     1   0.518      0.651 0.884 0.116
#> SRR1688412     2   0.163      0.805 0.024 0.976
#> SRR1688413     2   0.163      0.805 0.024 0.976
#> SRR1688414     2   0.163      0.805 0.024 0.976
#> SRR1688415     2   0.697      0.879 0.188 0.812
#> SRR1688416     2   0.697      0.879 0.188 0.812
#> SRR1688417     2   0.697      0.879 0.188 0.812
#> SRR1688418     2   0.697      0.879 0.188 0.812

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2  0.0237      0.977 0.004 0.996 0.000
#> SRR1688358     2  0.0237      0.977 0.004 0.996 0.000
#> SRR1688359     2  0.0237      0.977 0.004 0.996 0.000
#> SRR1688360     2  0.0237      0.977 0.004 0.996 0.000
#> SRR1688361     2  0.0237      0.977 0.004 0.996 0.000
#> SRR1688362     2  0.0237      0.977 0.004 0.996 0.000
#> SRR1688363     2  0.0237      0.977 0.004 0.996 0.000
#> SRR1688365     2  0.0237      0.977 0.004 0.996 0.000
#> SRR1688364     2  0.0237      0.977 0.004 0.996 0.000
#> SRR1688366     2  0.0237      0.974 0.004 0.996 0.000
#> SRR1688367     2  0.0237      0.974 0.004 0.996 0.000
#> SRR1688368     2  0.0424      0.973 0.008 0.992 0.000
#> SRR1688370     2  0.0237      0.977 0.004 0.996 0.000
#> SRR1688369     2  0.0237      0.977 0.004 0.996 0.000
#> SRR1688371     2  0.0237      0.977 0.004 0.996 0.000
#> SRR1688372     2  0.2939      0.937 0.072 0.916 0.012
#> SRR1688373     2  0.2939      0.937 0.072 0.916 0.012
#> SRR1688374     2  0.2939      0.937 0.072 0.916 0.012
#> SRR1688375     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688377     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688378     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688376     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688380     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688379     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688381     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688382     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688383     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688384     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688385     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688386     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688387     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688388     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688389     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688390     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688391     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688392     1  0.0424      1.000 0.992 0.000 0.008
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688405     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688407     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688406     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688411     2  0.2939      0.937 0.072 0.916 0.012
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688412     2  0.2939      0.937 0.072 0.916 0.012
#> SRR1688413     2  0.2939      0.937 0.072 0.916 0.012
#> SRR1688414     2  0.2939      0.937 0.072 0.916 0.012
#> SRR1688415     2  0.0237      0.977 0.004 0.996 0.000
#> SRR1688416     2  0.0237      0.977 0.004 0.996 0.000
#> SRR1688417     2  0.0237      0.977 0.004 0.996 0.000
#> SRR1688418     2  0.0237      0.977 0.004 0.996 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1688357     2  0.0000      0.933 0.000 1.000 0.000 0.000
#> SRR1688358     2  0.0000      0.933 0.000 1.000 0.000 0.000
#> SRR1688359     2  0.0000      0.933 0.000 1.000 0.000 0.000
#> SRR1688360     2  0.0592      0.926 0.000 0.984 0.000 0.016
#> SRR1688361     2  0.0707      0.924 0.000 0.980 0.000 0.020
#> SRR1688362     2  0.0707      0.924 0.000 0.980 0.000 0.020
#> SRR1688363     2  0.2413      0.863 0.064 0.916 0.000 0.020
#> SRR1688365     2  0.2775      0.838 0.084 0.896 0.000 0.020
#> SRR1688364     2  0.2635      0.849 0.076 0.904 0.000 0.020
#> SRR1688366     2  0.3945      0.629 0.004 0.780 0.000 0.216
#> SRR1688367     2  0.4295      0.569 0.008 0.752 0.000 0.240
#> SRR1688368     4  0.5184      0.866 0.024 0.304 0.000 0.672
#> SRR1688370     2  0.0000      0.933 0.000 1.000 0.000 0.000
#> SRR1688369     2  0.0000      0.933 0.000 1.000 0.000 0.000
#> SRR1688371     2  0.0000      0.933 0.000 1.000 0.000 0.000
#> SRR1688372     4  0.4277      0.983 0.000 0.280 0.000 0.720
#> SRR1688373     4  0.4277      0.983 0.000 0.280 0.000 0.720
#> SRR1688374     4  0.4277      0.983 0.000 0.280 0.000 0.720
#> SRR1688375     1  0.0188      0.884 0.996 0.000 0.000 0.004
#> SRR1688377     1  0.0188      0.884 0.996 0.000 0.000 0.004
#> SRR1688378     1  0.3907      0.886 0.768 0.000 0.000 0.232
#> SRR1688376     1  0.0188      0.884 0.996 0.000 0.000 0.004
#> SRR1688380     1  0.3907      0.886 0.768 0.000 0.000 0.232
#> SRR1688379     1  0.3907      0.886 0.768 0.000 0.000 0.232
#> SRR1688381     1  0.0000      0.885 1.000 0.000 0.000 0.000
#> SRR1688382     1  0.0000      0.885 1.000 0.000 0.000 0.000
#> SRR1688383     1  0.0000      0.885 1.000 0.000 0.000 0.000
#> SRR1688384     1  0.0188      0.884 0.996 0.000 0.000 0.004
#> SRR1688385     1  0.0188      0.884 0.996 0.000 0.000 0.004
#> SRR1688386     1  0.0188      0.884 0.996 0.000 0.000 0.004
#> SRR1688387     1  0.3907      0.886 0.768 0.000 0.000 0.232
#> SRR1688388     1  0.3907      0.886 0.768 0.000 0.000 0.232
#> SRR1688389     1  0.3907      0.886 0.768 0.000 0.000 0.232
#> SRR1688390     1  0.3907      0.886 0.768 0.000 0.000 0.232
#> SRR1688391     1  0.3907      0.886 0.768 0.000 0.000 0.232
#> SRR1688392     1  0.3907      0.886 0.768 0.000 0.000 0.232
#> SRR1688393     3  0.0921      0.956 0.000 0.000 0.972 0.028
#> SRR1688395     3  0.0921      0.956 0.000 0.000 0.972 0.028
#> SRR1688394     3  0.0921      0.956 0.000 0.000 0.972 0.028
#> SRR1688397     3  0.0921      0.956 0.000 0.000 0.972 0.028
#> SRR1688398     3  0.0817      0.957 0.000 0.000 0.976 0.024
#> SRR1688396     3  0.0921      0.956 0.000 0.000 0.972 0.028
#> SRR1688399     3  0.0000      0.959 0.000 0.000 1.000 0.000
#> SRR1688400     3  0.0000      0.959 0.000 0.000 1.000 0.000
#> SRR1688402     3  0.0000      0.959 0.000 0.000 1.000 0.000
#> SRR1688401     3  0.0000      0.959 0.000 0.000 1.000 0.000
#> SRR1688403     3  0.0000      0.959 0.000 0.000 1.000 0.000
#> SRR1688404     3  0.0000      0.959 0.000 0.000 1.000 0.000
#> SRR1688405     3  0.3948      0.850 0.136 0.000 0.828 0.036
#> SRR1688407     3  0.4549      0.801 0.188 0.000 0.776 0.036
#> SRR1688408     3  0.0000      0.959 0.000 0.000 1.000 0.000
#> SRR1688406     3  0.4423      0.813 0.176 0.000 0.788 0.036
#> SRR1688410     3  0.0000      0.959 0.000 0.000 1.000 0.000
#> SRR1688411     4  0.4277      0.983 0.000 0.280 0.000 0.720
#> SRR1688409     3  0.0000      0.959 0.000 0.000 1.000 0.000
#> SRR1688412     4  0.4277      0.983 0.000 0.280 0.000 0.720
#> SRR1688413     4  0.4277      0.983 0.000 0.280 0.000 0.720
#> SRR1688414     4  0.4277      0.983 0.000 0.280 0.000 0.720
#> SRR1688415     2  0.0000      0.933 0.000 1.000 0.000 0.000
#> SRR1688416     2  0.0000      0.933 0.000 1.000 0.000 0.000
#> SRR1688417     2  0.0000      0.933 0.000 1.000 0.000 0.000
#> SRR1688418     2  0.0000      0.933 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1688357     2  0.0162      0.957 0.000 0.996 0.000 0.004 0.000
#> SRR1688358     2  0.0162      0.957 0.000 0.996 0.000 0.004 0.000
#> SRR1688359     2  0.0162      0.957 0.000 0.996 0.000 0.004 0.000
#> SRR1688360     2  0.0963      0.947 0.000 0.964 0.000 0.000 0.036
#> SRR1688361     2  0.0963      0.947 0.000 0.964 0.000 0.000 0.036
#> SRR1688362     2  0.0963      0.947 0.000 0.964 0.000 0.000 0.036
#> SRR1688363     2  0.1557      0.938 0.000 0.940 0.000 0.008 0.052
#> SRR1688365     2  0.1956      0.922 0.000 0.916 0.000 0.008 0.076
#> SRR1688364     2  0.1764      0.931 0.000 0.928 0.000 0.008 0.064
#> SRR1688366     2  0.3639      0.827 0.000 0.824 0.000 0.076 0.100
#> SRR1688367     2  0.4593      0.710 0.000 0.736 0.000 0.080 0.184
#> SRR1688368     4  0.5144      0.559 0.000 0.064 0.000 0.632 0.304
#> SRR1688370     2  0.0162      0.957 0.000 0.996 0.000 0.004 0.000
#> SRR1688369     2  0.0162      0.957 0.000 0.996 0.000 0.004 0.000
#> SRR1688371     2  0.0000      0.956 0.000 1.000 0.000 0.000 0.000
#> SRR1688372     4  0.1410      0.954 0.000 0.060 0.000 0.940 0.000
#> SRR1688373     4  0.1410      0.954 0.000 0.060 0.000 0.940 0.000
#> SRR1688374     4  0.1410      0.954 0.000 0.060 0.000 0.940 0.000
#> SRR1688375     5  0.3035      0.855 0.112 0.000 0.000 0.032 0.856
#> SRR1688377     5  0.3035      0.855 0.112 0.000 0.000 0.032 0.856
#> SRR1688378     1  0.0162      0.997 0.996 0.000 0.000 0.000 0.004
#> SRR1688376     5  0.3035      0.855 0.112 0.000 0.000 0.032 0.856
#> SRR1688380     1  0.0162      0.997 0.996 0.000 0.000 0.000 0.004
#> SRR1688379     1  0.0162      0.997 0.996 0.000 0.000 0.000 0.004
#> SRR1688381     5  0.2179      0.861 0.112 0.000 0.000 0.000 0.888
#> SRR1688382     5  0.2179      0.861 0.112 0.000 0.000 0.000 0.888
#> SRR1688383     5  0.2179      0.861 0.112 0.000 0.000 0.000 0.888
#> SRR1688384     5  0.2179      0.861 0.112 0.000 0.000 0.000 0.888
#> SRR1688385     5  0.2179      0.861 0.112 0.000 0.000 0.000 0.888
#> SRR1688386     5  0.2179      0.861 0.112 0.000 0.000 0.000 0.888
#> SRR1688387     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> SRR1688388     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> SRR1688389     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> SRR1688390     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> SRR1688393     3  0.2362      0.937 0.000 0.000 0.900 0.024 0.076
#> SRR1688395     3  0.2362      0.937 0.000 0.000 0.900 0.024 0.076
#> SRR1688394     3  0.2362      0.937 0.000 0.000 0.900 0.024 0.076
#> SRR1688397     3  0.2300      0.938 0.000 0.000 0.904 0.024 0.072
#> SRR1688398     3  0.1661      0.950 0.000 0.000 0.940 0.024 0.036
#> SRR1688396     3  0.2362      0.937 0.000 0.000 0.900 0.024 0.076
#> SRR1688399     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000
#> SRR1688400     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000
#> SRR1688402     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000
#> SRR1688401     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000
#> SRR1688403     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000
#> SRR1688404     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000
#> SRR1688405     5  0.5151      0.242 0.000 0.000 0.396 0.044 0.560
#> SRR1688407     5  0.4066      0.653 0.000 0.000 0.188 0.044 0.768
#> SRR1688408     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000
#> SRR1688406     5  0.4817      0.478 0.000 0.000 0.300 0.044 0.656
#> SRR1688410     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000
#> SRR1688411     4  0.1410      0.954 0.000 0.060 0.000 0.940 0.000
#> SRR1688409     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000
#> SRR1688412     4  0.1410      0.954 0.000 0.060 0.000 0.940 0.000
#> SRR1688413     4  0.1410      0.954 0.000 0.060 0.000 0.940 0.000
#> SRR1688414     4  0.1410      0.954 0.000 0.060 0.000 0.940 0.000
#> SRR1688415     2  0.0162      0.957 0.000 0.996 0.000 0.004 0.000
#> SRR1688416     2  0.0162      0.957 0.000 0.996 0.000 0.004 0.000
#> SRR1688417     2  0.0162      0.957 0.000 0.996 0.000 0.004 0.000
#> SRR1688418     2  0.0162      0.957 0.000 0.996 0.000 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1688357     2  0.0363      0.803 0.000 0.988 0.000 0.012 0.000 0.000
#> SRR1688358     2  0.0363      0.803 0.000 0.988 0.000 0.012 0.000 0.000
#> SRR1688359     2  0.0363      0.803 0.000 0.988 0.000 0.012 0.000 0.000
#> SRR1688360     2  0.3607      0.734 0.000 0.652 0.000 0.000 0.000 0.348
#> SRR1688361     2  0.3607      0.734 0.000 0.652 0.000 0.000 0.000 0.348
#> SRR1688362     2  0.3607      0.734 0.000 0.652 0.000 0.000 0.000 0.348
#> SRR1688363     2  0.4144      0.697 0.008 0.580 0.000 0.004 0.000 0.408
#> SRR1688365     2  0.4262      0.681 0.012 0.560 0.000 0.004 0.000 0.424
#> SRR1688364     2  0.4158      0.691 0.008 0.572 0.000 0.004 0.000 0.416
#> SRR1688366     2  0.4850      0.646 0.020 0.524 0.000 0.024 0.000 0.432
#> SRR1688367     2  0.4991      0.634 0.024 0.512 0.000 0.028 0.000 0.436
#> SRR1688368     4  0.5508      0.322 0.056 0.032 0.000 0.476 0.000 0.436
#> SRR1688370     2  0.0260      0.803 0.000 0.992 0.000 0.008 0.000 0.000
#> SRR1688369     2  0.0260      0.803 0.000 0.992 0.000 0.008 0.000 0.000
#> SRR1688371     2  0.0260      0.803 0.000 0.992 0.000 0.008 0.000 0.000
#> SRR1688372     4  0.0547      0.923 0.000 0.020 0.000 0.980 0.000 0.000
#> SRR1688373     4  0.0547      0.923 0.000 0.020 0.000 0.980 0.000 0.000
#> SRR1688374     4  0.0547      0.923 0.000 0.020 0.000 0.980 0.000 0.000
#> SRR1688375     1  0.4286      0.566 0.624 0.000 0.000 0.012 0.012 0.352
#> SRR1688377     1  0.4286      0.566 0.624 0.000 0.000 0.012 0.012 0.352
#> SRR1688378     5  0.2400      0.902 0.116 0.000 0.000 0.004 0.872 0.008
#> SRR1688376     1  0.4286      0.566 0.624 0.000 0.000 0.012 0.012 0.352
#> SRR1688380     5  0.2445      0.899 0.120 0.000 0.000 0.004 0.868 0.008
#> SRR1688379     5  0.2445      0.899 0.120 0.000 0.000 0.004 0.868 0.008
#> SRR1688381     1  0.0363      0.789 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR1688382     1  0.0363      0.789 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR1688383     1  0.0363      0.789 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR1688384     1  0.1297      0.799 0.948 0.000 0.000 0.000 0.012 0.040
#> SRR1688385     1  0.1367      0.799 0.944 0.000 0.000 0.000 0.012 0.044
#> SRR1688386     1  0.1367      0.799 0.944 0.000 0.000 0.000 0.012 0.044
#> SRR1688387     5  0.0000      0.951 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1688388     5  0.0000      0.951 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1688389     5  0.0000      0.951 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1688390     5  0.0146      0.951 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1688391     5  0.0146      0.951 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1688392     5  0.0146      0.951 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1688393     3  0.3584      0.750 0.012 0.000 0.740 0.004 0.000 0.244
#> SRR1688395     3  0.3584      0.750 0.012 0.000 0.740 0.004 0.000 0.244
#> SRR1688394     3  0.3584      0.750 0.012 0.000 0.740 0.004 0.000 0.244
#> SRR1688397     3  0.3584      0.750 0.012 0.000 0.740 0.004 0.000 0.244
#> SRR1688398     3  0.3488      0.753 0.008 0.000 0.744 0.004 0.000 0.244
#> SRR1688396     3  0.3584      0.750 0.012 0.000 0.740 0.004 0.000 0.244
#> SRR1688399     3  0.0000      0.858 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688400     3  0.0000      0.858 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688402     3  0.0000      0.858 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688401     3  0.0000      0.858 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688403     3  0.0000      0.858 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688404     3  0.0000      0.858 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688405     6  0.5539      0.801 0.244 0.000 0.200 0.000 0.000 0.556
#> SRR1688407     6  0.5067      0.791 0.356 0.000 0.088 0.000 0.000 0.556
#> SRR1688408     3  0.0000      0.858 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688406     6  0.5341      0.860 0.312 0.000 0.132 0.000 0.000 0.556
#> SRR1688410     3  0.0000      0.858 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688411     4  0.0547      0.923 0.000 0.020 0.000 0.980 0.000 0.000
#> SRR1688409     3  0.0000      0.858 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688412     4  0.0547      0.923 0.000 0.020 0.000 0.980 0.000 0.000
#> SRR1688413     4  0.0547      0.923 0.000 0.020 0.000 0.980 0.000 0.000
#> SRR1688414     4  0.0547      0.923 0.000 0.020 0.000 0.980 0.000 0.000
#> SRR1688415     2  0.0363      0.803 0.000 0.988 0.000 0.012 0.000 0.000
#> SRR1688416     2  0.0363      0.803 0.000 0.988 0.000 0.012 0.000 0.000
#> SRR1688417     2  0.0363      0.803 0.000 0.988 0.000 0.012 0.000 0.000
#> SRR1688418     2  0.0363      0.803 0.000 0.988 0.000 0.012 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-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 16435 rows and 62 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           0.970       0.987         0.4985 0.505   0.505
#> 3 3 1.000           0.971       0.987         0.3278 0.829   0.661
#> 4 4 0.850           0.898       0.933         0.1147 0.915   0.746
#> 5 5 0.942           0.944       0.971         0.0416 0.989   0.955
#> 6 6 0.977           0.965       0.967         0.0294 0.976   0.900

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
#> SRR1688357     2   0.000      1.000 0.000 1.000
#> SRR1688358     2   0.000      1.000 0.000 1.000
#> SRR1688359     2   0.000      1.000 0.000 1.000
#> SRR1688360     2   0.000      1.000 0.000 1.000
#> SRR1688361     2   0.000      1.000 0.000 1.000
#> SRR1688362     2   0.000      1.000 0.000 1.000
#> SRR1688363     2   0.000      1.000 0.000 1.000
#> SRR1688365     2   0.000      1.000 0.000 1.000
#> SRR1688364     2   0.000      1.000 0.000 1.000
#> SRR1688366     2   0.000      1.000 0.000 1.000
#> SRR1688367     2   0.000      1.000 0.000 1.000
#> SRR1688368     2   0.000      1.000 0.000 1.000
#> SRR1688370     2   0.000      1.000 0.000 1.000
#> SRR1688369     2   0.000      1.000 0.000 1.000
#> SRR1688371     2   0.000      1.000 0.000 1.000
#> SRR1688372     2   0.000      1.000 0.000 1.000
#> SRR1688373     2   0.000      1.000 0.000 1.000
#> SRR1688374     2   0.000      1.000 0.000 1.000
#> SRR1688375     1   0.000      0.976 1.000 0.000
#> SRR1688377     1   0.000      0.976 1.000 0.000
#> SRR1688378     1   0.000      0.976 1.000 0.000
#> SRR1688376     1   0.000      0.976 1.000 0.000
#> SRR1688380     1   0.000      0.976 1.000 0.000
#> SRR1688379     1   0.000      0.976 1.000 0.000
#> SRR1688381     1   0.000      0.976 1.000 0.000
#> SRR1688382     1   0.000      0.976 1.000 0.000
#> SRR1688383     1   0.000      0.976 1.000 0.000
#> SRR1688384     1   0.000      0.976 1.000 0.000
#> SRR1688385     1   0.000      0.976 1.000 0.000
#> SRR1688386     1   0.000      0.976 1.000 0.000
#> SRR1688387     1   0.000      0.976 1.000 0.000
#> SRR1688388     1   0.000      0.976 1.000 0.000
#> SRR1688389     1   0.000      0.976 1.000 0.000
#> SRR1688390     1   0.000      0.976 1.000 0.000
#> SRR1688391     1   0.000      0.976 1.000 0.000
#> SRR1688392     1   0.000      0.976 1.000 0.000
#> SRR1688393     1   0.000      0.976 1.000 0.000
#> SRR1688395     1   0.000      0.976 1.000 0.000
#> SRR1688394     1   0.000      0.976 1.000 0.000
#> SRR1688397     1   0.000      0.976 1.000 0.000
#> SRR1688398     1   0.000      0.976 1.000 0.000
#> SRR1688396     1   0.000      0.976 1.000 0.000
#> SRR1688399     1   0.000      0.976 1.000 0.000
#> SRR1688400     1   0.000      0.976 1.000 0.000
#> SRR1688402     1   0.000      0.976 1.000 0.000
#> SRR1688401     1   0.000      0.976 1.000 0.000
#> SRR1688403     1   0.000      0.976 1.000 0.000
#> SRR1688404     1   0.000      0.976 1.000 0.000
#> SRR1688405     1   0.844      0.648 0.728 0.272
#> SRR1688407     1   0.844      0.648 0.728 0.272
#> SRR1688408     1   0.000      0.976 1.000 0.000
#> SRR1688406     1   0.844      0.648 0.728 0.272
#> SRR1688410     1   0.000      0.976 1.000 0.000
#> SRR1688411     2   0.000      1.000 0.000 1.000
#> SRR1688409     1   0.000      0.976 1.000 0.000
#> SRR1688412     2   0.000      1.000 0.000 1.000
#> SRR1688413     2   0.000      1.000 0.000 1.000
#> SRR1688414     2   0.000      1.000 0.000 1.000
#> SRR1688415     2   0.000      1.000 0.000 1.000
#> SRR1688416     2   0.000      1.000 0.000 1.000
#> SRR1688417     2   0.000      1.000 0.000 1.000
#> SRR1688418     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1    p2    p3
#> SRR1688357     2   0.000      1.000  0 1.000 0.000
#> SRR1688358     2   0.000      1.000  0 1.000 0.000
#> SRR1688359     2   0.000      1.000  0 1.000 0.000
#> SRR1688360     2   0.000      1.000  0 1.000 0.000
#> SRR1688361     2   0.000      1.000  0 1.000 0.000
#> SRR1688362     2   0.000      1.000  0 1.000 0.000
#> SRR1688363     2   0.000      1.000  0 1.000 0.000
#> SRR1688365     2   0.000      1.000  0 1.000 0.000
#> SRR1688364     2   0.000      1.000  0 1.000 0.000
#> SRR1688366     2   0.000      1.000  0 1.000 0.000
#> SRR1688367     2   0.000      1.000  0 1.000 0.000
#> SRR1688368     2   0.000      1.000  0 1.000 0.000
#> SRR1688370     2   0.000      1.000  0 1.000 0.000
#> SRR1688369     2   0.000      1.000  0 1.000 0.000
#> SRR1688371     2   0.000      1.000  0 1.000 0.000
#> SRR1688372     2   0.000      1.000  0 1.000 0.000
#> SRR1688373     2   0.000      1.000  0 1.000 0.000
#> SRR1688374     2   0.000      1.000  0 1.000 0.000
#> SRR1688375     1   0.000      1.000  1 0.000 0.000
#> SRR1688377     1   0.000      1.000  1 0.000 0.000
#> SRR1688378     1   0.000      1.000  1 0.000 0.000
#> SRR1688376     1   0.000      1.000  1 0.000 0.000
#> SRR1688380     1   0.000      1.000  1 0.000 0.000
#> SRR1688379     1   0.000      1.000  1 0.000 0.000
#> SRR1688381     1   0.000      1.000  1 0.000 0.000
#> SRR1688382     1   0.000      1.000  1 0.000 0.000
#> SRR1688383     1   0.000      1.000  1 0.000 0.000
#> SRR1688384     1   0.000      1.000  1 0.000 0.000
#> SRR1688385     1   0.000      1.000  1 0.000 0.000
#> SRR1688386     1   0.000      1.000  1 0.000 0.000
#> SRR1688387     1   0.000      1.000  1 0.000 0.000
#> SRR1688388     1   0.000      1.000  1 0.000 0.000
#> SRR1688389     1   0.000      1.000  1 0.000 0.000
#> SRR1688390     1   0.000      1.000  1 0.000 0.000
#> SRR1688391     1   0.000      1.000  1 0.000 0.000
#> SRR1688392     1   0.000      1.000  1 0.000 0.000
#> SRR1688393     3   0.000      0.946  0 0.000 1.000
#> SRR1688395     3   0.000      0.946  0 0.000 1.000
#> SRR1688394     3   0.000      0.946  0 0.000 1.000
#> SRR1688397     3   0.000      0.946  0 0.000 1.000
#> SRR1688398     3   0.000      0.946  0 0.000 1.000
#> SRR1688396     3   0.000      0.946  0 0.000 1.000
#> SRR1688399     3   0.000      0.946  0 0.000 1.000
#> SRR1688400     3   0.000      0.946  0 0.000 1.000
#> SRR1688402     3   0.000      0.946  0 0.000 1.000
#> SRR1688401     3   0.000      0.946  0 0.000 1.000
#> SRR1688403     3   0.000      0.946  0 0.000 1.000
#> SRR1688404     3   0.000      0.946  0 0.000 1.000
#> SRR1688405     3   0.533      0.670  0 0.272 0.728
#> SRR1688407     3   0.533      0.670  0 0.272 0.728
#> SRR1688408     3   0.000      0.946  0 0.000 1.000
#> SRR1688406     3   0.533      0.670  0 0.272 0.728
#> SRR1688410     3   0.000      0.946  0 0.000 1.000
#> SRR1688411     2   0.000      1.000  0 1.000 0.000
#> SRR1688409     3   0.000      0.946  0 0.000 1.000
#> SRR1688412     2   0.000      1.000  0 1.000 0.000
#> SRR1688413     2   0.000      1.000  0 1.000 0.000
#> SRR1688414     2   0.000      1.000  0 1.000 0.000
#> SRR1688415     2   0.000      1.000  0 1.000 0.000
#> SRR1688416     2   0.000      1.000  0 1.000 0.000
#> SRR1688417     2   0.000      1.000  0 1.000 0.000
#> SRR1688418     2   0.000      1.000  0 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2    p3    p4
#> SRR1688357     2   0.000      0.907  0 1.000 0.000 0.000
#> SRR1688358     2   0.000      0.907  0 1.000 0.000 0.000
#> SRR1688359     2   0.000      0.907  0 1.000 0.000 0.000
#> SRR1688360     2   0.281      0.826  0 0.868 0.000 0.132
#> SRR1688361     2   0.281      0.826  0 0.868 0.000 0.132
#> SRR1688362     2   0.281      0.826  0 0.868 0.000 0.132
#> SRR1688363     4   0.410      0.581  0 0.256 0.000 0.744
#> SRR1688365     4   0.410      0.581  0 0.256 0.000 0.744
#> SRR1688364     4   0.410      0.581  0 0.256 0.000 0.744
#> SRR1688366     2   0.336      0.783  0 0.824 0.000 0.176
#> SRR1688367     2   0.336      0.783  0 0.824 0.000 0.176
#> SRR1688368     2   0.336      0.783  0 0.824 0.000 0.176
#> SRR1688370     2   0.000      0.907  0 1.000 0.000 0.000
#> SRR1688369     2   0.000      0.907  0 1.000 0.000 0.000
#> SRR1688371     2   0.000      0.907  0 1.000 0.000 0.000
#> SRR1688372     4   0.394      0.839  0 0.236 0.000 0.764
#> SRR1688373     4   0.394      0.839  0 0.236 0.000 0.764
#> SRR1688374     4   0.394      0.839  0 0.236 0.000 0.764
#> SRR1688375     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688377     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688378     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688376     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688380     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688379     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688381     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688382     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688383     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688384     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688385     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688386     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688387     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688388     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688389     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688390     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688391     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688392     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688393     3   0.000      0.947  0 0.000 1.000 0.000
#> SRR1688395     3   0.000      0.947  0 0.000 1.000 0.000
#> SRR1688394     3   0.000      0.947  0 0.000 1.000 0.000
#> SRR1688397     3   0.000      0.947  0 0.000 1.000 0.000
#> SRR1688398     3   0.000      0.947  0 0.000 1.000 0.000
#> SRR1688396     3   0.000      0.947  0 0.000 1.000 0.000
#> SRR1688399     3   0.000      0.947  0 0.000 1.000 0.000
#> SRR1688400     3   0.000      0.947  0 0.000 1.000 0.000
#> SRR1688402     3   0.000      0.947  0 0.000 1.000 0.000
#> SRR1688401     3   0.000      0.947  0 0.000 1.000 0.000
#> SRR1688403     3   0.000      0.947  0 0.000 1.000 0.000
#> SRR1688404     3   0.000      0.947  0 0.000 1.000 0.000
#> SRR1688405     3   0.448      0.654  0 0.008 0.728 0.264
#> SRR1688407     3   0.448      0.654  0 0.008 0.728 0.264
#> SRR1688408     3   0.000      0.947  0 0.000 1.000 0.000
#> SRR1688406     3   0.448      0.654  0 0.008 0.728 0.264
#> SRR1688410     3   0.000      0.947  0 0.000 1.000 0.000
#> SRR1688411     4   0.394      0.839  0 0.236 0.000 0.764
#> SRR1688409     3   0.000      0.947  0 0.000 1.000 0.000
#> SRR1688412     4   0.394      0.839  0 0.236 0.000 0.764
#> SRR1688413     4   0.394      0.839  0 0.236 0.000 0.764
#> SRR1688414     4   0.394      0.839  0 0.236 0.000 0.764
#> SRR1688415     2   0.000      0.907  0 1.000 0.000 0.000
#> SRR1688416     2   0.000      0.907  0 1.000 0.000 0.000
#> SRR1688417     2   0.000      0.907  0 1.000 0.000 0.000
#> SRR1688418     2   0.000      0.907  0 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2    p3    p4    p5
#> SRR1688357     2   0.000      0.932  0 1.000 0.000 0.000 0.000
#> SRR1688358     2   0.000      0.932  0 1.000 0.000 0.000 0.000
#> SRR1688359     2   0.000      0.932  0 1.000 0.000 0.000 0.000
#> SRR1688360     2   0.247      0.864  0 0.864 0.000 0.000 0.136
#> SRR1688361     2   0.247      0.864  0 0.864 0.000 0.000 0.136
#> SRR1688362     2   0.247      0.864  0 0.864 0.000 0.000 0.136
#> SRR1688363     5   0.000      1.000  0 0.000 0.000 0.000 1.000
#> SRR1688365     5   0.000      1.000  0 0.000 0.000 0.000 1.000
#> SRR1688364     5   0.000      1.000  0 0.000 0.000 0.000 1.000
#> SRR1688366     2   0.309      0.814  0 0.816 0.000 0.180 0.004
#> SRR1688367     2   0.309      0.814  0 0.816 0.000 0.180 0.004
#> SRR1688368     2   0.309      0.814  0 0.816 0.000 0.180 0.004
#> SRR1688370     2   0.000      0.932  0 1.000 0.000 0.000 0.000
#> SRR1688369     2   0.000      0.932  0 1.000 0.000 0.000 0.000
#> SRR1688371     2   0.000      0.932  0 1.000 0.000 0.000 0.000
#> SRR1688372     4   0.000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1688373     4   0.000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1688374     4   0.000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1688375     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688377     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688378     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688376     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688380     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688379     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688381     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688382     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688383     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688384     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688385     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688386     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688387     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688388     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688389     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688390     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688391     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688392     1   0.000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1688393     3   0.000      0.945  0 0.000 1.000 0.000 0.000
#> SRR1688395     3   0.000      0.945  0 0.000 1.000 0.000 0.000
#> SRR1688394     3   0.000      0.945  0 0.000 1.000 0.000 0.000
#> SRR1688397     3   0.000      0.945  0 0.000 1.000 0.000 0.000
#> SRR1688398     3   0.000      0.945  0 0.000 1.000 0.000 0.000
#> SRR1688396     3   0.000      0.945  0 0.000 1.000 0.000 0.000
#> SRR1688399     3   0.000      0.945  0 0.000 1.000 0.000 0.000
#> SRR1688400     3   0.000      0.945  0 0.000 1.000 0.000 0.000
#> SRR1688402     3   0.000      0.945  0 0.000 1.000 0.000 0.000
#> SRR1688401     3   0.000      0.945  0 0.000 1.000 0.000 0.000
#> SRR1688403     3   0.000      0.945  0 0.000 1.000 0.000 0.000
#> SRR1688404     3   0.000      0.945  0 0.000 1.000 0.000 0.000
#> SRR1688405     3   0.364      0.668  0 0.000 0.728 0.272 0.000
#> SRR1688407     3   0.364      0.668  0 0.000 0.728 0.272 0.000
#> SRR1688408     3   0.000      0.945  0 0.000 1.000 0.000 0.000
#> SRR1688406     3   0.364      0.668  0 0.000 0.728 0.272 0.000
#> SRR1688410     3   0.000      0.945  0 0.000 1.000 0.000 0.000
#> SRR1688411     4   0.000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1688409     3   0.000      0.945  0 0.000 1.000 0.000 0.000
#> SRR1688412     4   0.000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1688413     4   0.000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1688414     4   0.000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1688415     2   0.000      0.932  0 1.000 0.000 0.000 0.000
#> SRR1688416     2   0.000      0.932  0 1.000 0.000 0.000 0.000
#> SRR1688417     2   0.000      0.932  0 1.000 0.000 0.000 0.000
#> SRR1688418     2   0.000      0.932  0 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2    p3    p4    p5    p6
#> SRR1688357     2   0.000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR1688358     2   0.000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR1688359     2   0.000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR1688360     2   0.381      0.819  0 0.776 0.000 0.000 0.136 0.088
#> SRR1688361     2   0.381      0.819  0 0.776 0.000 0.000 0.136 0.088
#> SRR1688362     2   0.381      0.819  0 0.776 0.000 0.000 0.136 0.088
#> SRR1688363     5   0.000      1.000  0 0.000 0.000 0.000 1.000 0.000
#> SRR1688365     5   0.000      1.000  0 0.000 0.000 0.000 1.000 0.000
#> SRR1688364     5   0.000      1.000  0 0.000 0.000 0.000 1.000 0.000
#> SRR1688366     2   0.277      0.800  0 0.816 0.000 0.180 0.004 0.000
#> SRR1688367     2   0.277      0.800  0 0.816 0.000 0.180 0.004 0.000
#> SRR1688368     2   0.277      0.800  0 0.816 0.000 0.180 0.004 0.000
#> SRR1688370     2   0.166      0.884  0 0.912 0.000 0.000 0.000 0.088
#> SRR1688369     2   0.166      0.884  0 0.912 0.000 0.000 0.000 0.088
#> SRR1688371     2   0.166      0.884  0 0.912 0.000 0.000 0.000 0.088
#> SRR1688372     4   0.000      1.000  0 0.000 0.000 1.000 0.000 0.000
#> SRR1688373     4   0.000      1.000  0 0.000 0.000 1.000 0.000 0.000
#> SRR1688374     4   0.000      1.000  0 0.000 0.000 1.000 0.000 0.000
#> SRR1688375     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688377     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688378     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688376     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688380     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688379     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688381     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688382     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688383     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688384     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688385     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688386     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688387     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688388     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688389     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688390     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688391     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688392     1   0.000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1688393     3   0.000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1688395     3   0.000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1688394     3   0.000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1688397     3   0.000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1688398     3   0.000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1688396     3   0.000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1688399     3   0.000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1688400     3   0.000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1688402     3   0.000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1688401     3   0.000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1688403     3   0.000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1688404     3   0.000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1688405     6   0.175      1.000  0 0.000 0.004 0.084 0.000 0.912
#> SRR1688407     6   0.175      1.000  0 0.000 0.004 0.084 0.000 0.912
#> SRR1688408     3   0.000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1688406     6   0.175      1.000  0 0.000 0.004 0.084 0.000 0.912
#> SRR1688410     3   0.000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1688411     4   0.000      1.000  0 0.000 0.000 1.000 0.000 0.000
#> SRR1688409     3   0.000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1688412     4   0.000      1.000  0 0.000 0.000 1.000 0.000 0.000
#> SRR1688413     4   0.000      1.000  0 0.000 0.000 1.000 0.000 0.000
#> SRR1688414     4   0.000      1.000  0 0.000 0.000 1.000 0.000 0.000
#> SRR1688415     2   0.000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR1688416     2   0.000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR1688417     2   0.000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR1688418     2   0.000      0.902  0 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-hclust-collect-classes

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 16435 rows and 62 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 0.200           0.829       0.864         0.4583 0.505   0.505
#> 3 3 0.608           0.836       0.812         0.3790 0.829   0.661
#> 4 4 0.759           0.776       0.821         0.1346 0.877   0.661
#> 5 5 0.677           0.720       0.775         0.0650 0.911   0.707
#> 6 6 0.700           0.674       0.728         0.0436 0.912   0.694

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
#> SRR1688357     2   0.184      0.930 0.028 0.972
#> SRR1688358     2   0.184      0.930 0.028 0.972
#> SRR1688359     2   0.184      0.930 0.028 0.972
#> SRR1688360     2   0.163      0.930 0.024 0.976
#> SRR1688361     2   0.163      0.930 0.024 0.976
#> SRR1688362     2   0.163      0.930 0.024 0.976
#> SRR1688363     2   0.595      0.844 0.144 0.856
#> SRR1688365     2   0.595      0.844 0.144 0.856
#> SRR1688364     2   0.595      0.844 0.144 0.856
#> SRR1688366     2   0.204      0.928 0.032 0.968
#> SRR1688367     2   0.204      0.928 0.032 0.968
#> SRR1688368     2   0.204      0.928 0.032 0.968
#> SRR1688370     2   0.184      0.930 0.028 0.972
#> SRR1688369     2   0.184      0.930 0.028 0.972
#> SRR1688371     2   0.184      0.930 0.028 0.972
#> SRR1688372     2   0.563      0.858 0.132 0.868
#> SRR1688373     2   0.563      0.858 0.132 0.868
#> SRR1688374     2   0.563      0.858 0.132 0.868
#> SRR1688375     1   0.552      0.793 0.872 0.128
#> SRR1688377     1   0.552      0.793 0.872 0.128
#> SRR1688378     1   0.775      0.755 0.772 0.228
#> SRR1688376     1   0.552      0.793 0.872 0.128
#> SRR1688380     1   0.775      0.755 0.772 0.228
#> SRR1688379     1   0.775      0.755 0.772 0.228
#> SRR1688381     1   0.775      0.755 0.772 0.228
#> SRR1688382     1   0.775      0.755 0.772 0.228
#> SRR1688383     1   0.775      0.755 0.772 0.228
#> SRR1688384     1   0.775      0.755 0.772 0.228
#> SRR1688385     1   0.775      0.755 0.772 0.228
#> SRR1688386     1   0.775      0.755 0.772 0.228
#> SRR1688387     1   0.541      0.793 0.876 0.124
#> SRR1688388     1   0.541      0.793 0.876 0.124
#> SRR1688389     1   0.541      0.793 0.876 0.124
#> SRR1688390     1   0.775      0.755 0.772 0.228
#> SRR1688391     1   0.775      0.755 0.772 0.228
#> SRR1688392     1   0.775      0.755 0.772 0.228
#> SRR1688393     1   0.615      0.793 0.848 0.152
#> SRR1688395     1   0.615      0.793 0.848 0.152
#> SRR1688394     1   0.615      0.793 0.848 0.152
#> SRR1688397     1   0.615      0.793 0.848 0.152
#> SRR1688398     1   0.615      0.793 0.848 0.152
#> SRR1688396     1   0.615      0.793 0.848 0.152
#> SRR1688399     1   0.615      0.793 0.848 0.152
#> SRR1688400     1   0.615      0.793 0.848 0.152
#> SRR1688402     1   0.615      0.793 0.848 0.152
#> SRR1688401     1   0.615      0.793 0.848 0.152
#> SRR1688403     1   0.615      0.793 0.848 0.152
#> SRR1688404     1   0.615      0.793 0.848 0.152
#> SRR1688405     1   0.855      0.762 0.720 0.280
#> SRR1688407     1   0.855      0.762 0.720 0.280
#> SRR1688408     1   0.615      0.793 0.848 0.152
#> SRR1688406     1   0.855      0.762 0.720 0.280
#> SRR1688410     1   0.615      0.793 0.848 0.152
#> SRR1688411     2   0.563      0.858 0.132 0.868
#> SRR1688409     1   0.615      0.793 0.848 0.152
#> SRR1688412     2   0.563      0.858 0.132 0.868
#> SRR1688413     2   0.563      0.858 0.132 0.868
#> SRR1688414     2   0.563      0.858 0.132 0.868
#> SRR1688415     2   0.184      0.930 0.028 0.972
#> SRR1688416     2   0.184      0.930 0.028 0.972
#> SRR1688417     2   0.184      0.930 0.028 0.972
#> SRR1688418     2   0.184      0.930 0.028 0.972

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2  0.0237      0.847 0.000 0.996 0.004
#> SRR1688358     2  0.0237      0.847 0.000 0.996 0.004
#> SRR1688359     2  0.0237      0.847 0.000 0.996 0.004
#> SRR1688360     2  0.2200      0.846 0.056 0.940 0.004
#> SRR1688361     2  0.2200      0.846 0.056 0.940 0.004
#> SRR1688362     2  0.2200      0.846 0.056 0.940 0.004
#> SRR1688363     2  0.6579      0.707 0.328 0.652 0.020
#> SRR1688365     2  0.6579      0.707 0.328 0.652 0.020
#> SRR1688364     2  0.6579      0.707 0.328 0.652 0.020
#> SRR1688366     2  0.4235      0.830 0.176 0.824 0.000
#> SRR1688367     2  0.4235      0.830 0.176 0.824 0.000
#> SRR1688368     2  0.4235      0.830 0.176 0.824 0.000
#> SRR1688370     2  0.0829      0.845 0.012 0.984 0.004
#> SRR1688369     2  0.0829      0.845 0.012 0.984 0.004
#> SRR1688371     2  0.0829      0.845 0.012 0.984 0.004
#> SRR1688372     2  0.7858      0.728 0.364 0.572 0.064
#> SRR1688373     2  0.7858      0.728 0.364 0.572 0.064
#> SRR1688374     2  0.7858      0.728 0.364 0.572 0.064
#> SRR1688375     1  0.6282      0.938 0.664 0.012 0.324
#> SRR1688377     1  0.6282      0.938 0.664 0.012 0.324
#> SRR1688378     1  0.6475      0.959 0.692 0.028 0.280
#> SRR1688376     1  0.6282      0.938 0.664 0.012 0.324
#> SRR1688380     1  0.6475      0.959 0.692 0.028 0.280
#> SRR1688379     1  0.6475      0.959 0.692 0.028 0.280
#> SRR1688381     1  0.6187      0.913 0.724 0.028 0.248
#> SRR1688382     1  0.6187      0.913 0.724 0.028 0.248
#> SRR1688383     1  0.6187      0.913 0.724 0.028 0.248
#> SRR1688384     1  0.6475      0.958 0.692 0.028 0.280
#> SRR1688385     1  0.6475      0.958 0.692 0.028 0.280
#> SRR1688386     1  0.6475      0.958 0.692 0.028 0.280
#> SRR1688387     1  0.6282      0.938 0.664 0.012 0.324
#> SRR1688388     1  0.6282      0.938 0.664 0.012 0.324
#> SRR1688389     1  0.6282      0.938 0.664 0.012 0.324
#> SRR1688390     1  0.6475      0.959 0.692 0.028 0.280
#> SRR1688391     1  0.6475      0.959 0.692 0.028 0.280
#> SRR1688392     1  0.6475      0.959 0.692 0.028 0.280
#> SRR1688393     3  0.1182      0.903 0.012 0.012 0.976
#> SRR1688395     3  0.1182      0.903 0.012 0.012 0.976
#> SRR1688394     3  0.1182      0.903 0.012 0.012 0.976
#> SRR1688397     3  0.1015      0.905 0.008 0.012 0.980
#> SRR1688398     3  0.1015      0.905 0.008 0.012 0.980
#> SRR1688396     3  0.1015      0.905 0.008 0.012 0.980
#> SRR1688399     3  0.0592      0.907 0.000 0.012 0.988
#> SRR1688400     3  0.0592      0.907 0.000 0.012 0.988
#> SRR1688402     3  0.0592      0.907 0.000 0.012 0.988
#> SRR1688401     3  0.0592      0.907 0.000 0.012 0.988
#> SRR1688403     3  0.0592      0.907 0.000 0.012 0.988
#> SRR1688404     3  0.0592      0.907 0.000 0.012 0.988
#> SRR1688405     3  0.7353      0.189 0.316 0.052 0.632
#> SRR1688407     3  0.7353      0.189 0.316 0.052 0.632
#> SRR1688408     3  0.0592      0.907 0.000 0.012 0.988
#> SRR1688406     3  0.7353      0.189 0.316 0.052 0.632
#> SRR1688410     3  0.0592      0.907 0.000 0.012 0.988
#> SRR1688411     2  0.7858      0.728 0.364 0.572 0.064
#> SRR1688409     3  0.0592      0.907 0.000 0.012 0.988
#> SRR1688412     2  0.7858      0.728 0.364 0.572 0.064
#> SRR1688413     2  0.7858      0.728 0.364 0.572 0.064
#> SRR1688414     2  0.7858      0.728 0.364 0.572 0.064
#> SRR1688415     2  0.0237      0.847 0.000 0.996 0.004
#> SRR1688416     2  0.0237      0.847 0.000 0.996 0.004
#> SRR1688417     2  0.0237      0.847 0.000 0.996 0.004
#> SRR1688418     2  0.0237      0.847 0.000 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1688357     2   0.000    0.75985 0.000 1.000 0.000 0.000
#> SRR1688358     2   0.000    0.75985 0.000 1.000 0.000 0.000
#> SRR1688359     2   0.000    0.75985 0.000 1.000 0.000 0.000
#> SRR1688360     2   0.342    0.72338 0.000 0.868 0.044 0.088
#> SRR1688361     2   0.342    0.72338 0.000 0.868 0.044 0.088
#> SRR1688362     2   0.342    0.72338 0.000 0.868 0.044 0.088
#> SRR1688363     2   0.836    0.23736 0.176 0.512 0.056 0.256
#> SRR1688365     2   0.836    0.23736 0.176 0.512 0.056 0.256
#> SRR1688364     2   0.836    0.23736 0.176 0.512 0.056 0.256
#> SRR1688366     2   0.490    0.32528 0.008 0.740 0.020 0.232
#> SRR1688367     2   0.490    0.32528 0.008 0.740 0.020 0.232
#> SRR1688368     2   0.490    0.32528 0.008 0.740 0.020 0.232
#> SRR1688370     2   0.155    0.75492 0.000 0.952 0.008 0.040
#> SRR1688369     2   0.155    0.75492 0.000 0.952 0.008 0.040
#> SRR1688371     2   0.155    0.75492 0.000 0.952 0.008 0.040
#> SRR1688372     4   0.677    0.99711 0.060 0.396 0.016 0.528
#> SRR1688373     4   0.677    0.99711 0.060 0.396 0.016 0.528
#> SRR1688374     4   0.677    0.99711 0.060 0.396 0.016 0.528
#> SRR1688375     1   0.238    0.85863 0.916 0.000 0.016 0.068
#> SRR1688377     1   0.238    0.85863 0.916 0.000 0.016 0.068
#> SRR1688378     1   0.182    0.85767 0.936 0.000 0.004 0.060
#> SRR1688376     1   0.238    0.85863 0.916 0.000 0.016 0.068
#> SRR1688380     1   0.182    0.85767 0.936 0.000 0.004 0.060
#> SRR1688379     1   0.182    0.85767 0.936 0.000 0.004 0.060
#> SRR1688381     1   0.130    0.85623 0.956 0.000 0.000 0.044
#> SRR1688382     1   0.130    0.85623 0.956 0.000 0.000 0.044
#> SRR1688383     1   0.130    0.85623 0.956 0.000 0.000 0.044
#> SRR1688384     1   0.158    0.85787 0.948 0.000 0.004 0.048
#> SRR1688385     1   0.158    0.85787 0.948 0.000 0.004 0.048
#> SRR1688386     1   0.158    0.85787 0.948 0.000 0.004 0.048
#> SRR1688387     1   0.317    0.84494 0.868 0.000 0.016 0.116
#> SRR1688388     1   0.317    0.84494 0.868 0.000 0.016 0.116
#> SRR1688389     1   0.317    0.84494 0.868 0.000 0.016 0.116
#> SRR1688390     1   0.198    0.85973 0.928 0.000 0.004 0.068
#> SRR1688391     1   0.198    0.85973 0.928 0.000 0.004 0.068
#> SRR1688392     1   0.198    0.85973 0.928 0.000 0.004 0.068
#> SRR1688393     3   0.362    0.94179 0.072 0.000 0.860 0.068
#> SRR1688395     3   0.362    0.94179 0.072 0.000 0.860 0.068
#> SRR1688394     3   0.362    0.94179 0.072 0.000 0.860 0.068
#> SRR1688397     3   0.256    0.95900 0.072 0.000 0.908 0.020
#> SRR1688398     3   0.256    0.95900 0.072 0.000 0.908 0.020
#> SRR1688396     3   0.256    0.95900 0.072 0.000 0.908 0.020
#> SRR1688399     3   0.297    0.95952 0.072 0.000 0.892 0.036
#> SRR1688400     3   0.297    0.95952 0.072 0.000 0.892 0.036
#> SRR1688402     3   0.323    0.95683 0.072 0.000 0.880 0.048
#> SRR1688401     3   0.297    0.95952 0.072 0.000 0.892 0.036
#> SRR1688403     3   0.323    0.95683 0.072 0.000 0.880 0.048
#> SRR1688404     3   0.323    0.95683 0.072 0.000 0.880 0.048
#> SRR1688405     1   0.758   -0.00307 0.428 0.004 0.400 0.168
#> SRR1688407     1   0.758   -0.00307 0.428 0.004 0.400 0.168
#> SRR1688408     3   0.369    0.95369 0.072 0.000 0.856 0.072
#> SRR1688406     1   0.758   -0.00307 0.428 0.004 0.400 0.168
#> SRR1688410     3   0.369    0.95369 0.072 0.000 0.856 0.072
#> SRR1688411     4   0.667    0.99783 0.060 0.396 0.012 0.532
#> SRR1688409     3   0.369    0.95369 0.072 0.000 0.856 0.072
#> SRR1688412     4   0.667    0.99783 0.060 0.396 0.012 0.532
#> SRR1688413     4   0.667    0.99783 0.060 0.396 0.012 0.532
#> SRR1688414     4   0.667    0.99783 0.060 0.396 0.012 0.532
#> SRR1688415     2   0.000    0.75985 0.000 1.000 0.000 0.000
#> SRR1688416     2   0.000    0.75985 0.000 1.000 0.000 0.000
#> SRR1688417     2   0.000    0.75985 0.000 1.000 0.000 0.000
#> SRR1688418     2   0.000    0.75985 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1688357     2  0.3336      0.751 0.000 0.772 0.000 0.228 0.000
#> SRR1688358     2  0.3336      0.751 0.000 0.772 0.000 0.228 0.000
#> SRR1688359     2  0.3336      0.751 0.000 0.772 0.000 0.228 0.000
#> SRR1688360     2  0.6084      0.670 0.000 0.604 0.012 0.240 0.144
#> SRR1688361     2  0.6084      0.670 0.000 0.604 0.012 0.240 0.144
#> SRR1688362     2  0.6084      0.670 0.000 0.604 0.012 0.240 0.144
#> SRR1688363     2  0.8397      0.186 0.156 0.324 0.000 0.228 0.292
#> SRR1688365     2  0.8397      0.186 0.156 0.324 0.000 0.228 0.292
#> SRR1688364     2  0.8397      0.186 0.156 0.324 0.000 0.228 0.292
#> SRR1688366     4  0.6168      0.183 0.008 0.356 0.012 0.544 0.080
#> SRR1688367     4  0.6168      0.183 0.008 0.356 0.012 0.544 0.080
#> SRR1688368     4  0.6168      0.183 0.008 0.356 0.012 0.544 0.080
#> SRR1688370     2  0.4570      0.741 0.000 0.732 0.008 0.216 0.044
#> SRR1688369     2  0.4570      0.741 0.000 0.732 0.008 0.216 0.044
#> SRR1688371     2  0.4570      0.741 0.000 0.732 0.008 0.216 0.044
#> SRR1688372     4  0.1211      0.792 0.024 0.000 0.016 0.960 0.000
#> SRR1688373     4  0.1211      0.792 0.024 0.000 0.016 0.960 0.000
#> SRR1688374     4  0.1372      0.791 0.024 0.000 0.016 0.956 0.004
#> SRR1688375     1  0.3152      0.855 0.868 0.032 0.016 0.000 0.084
#> SRR1688377     1  0.3152      0.855 0.868 0.032 0.016 0.000 0.084
#> SRR1688378     1  0.3053      0.862 0.872 0.036 0.004 0.004 0.084
#> SRR1688376     1  0.3152      0.855 0.868 0.032 0.016 0.000 0.084
#> SRR1688380     1  0.3053      0.862 0.872 0.036 0.004 0.004 0.084
#> SRR1688379     1  0.3053      0.862 0.872 0.036 0.004 0.004 0.084
#> SRR1688381     1  0.4078      0.834 0.792 0.028 0.000 0.020 0.160
#> SRR1688382     1  0.4078      0.834 0.792 0.028 0.000 0.020 0.160
#> SRR1688383     1  0.4078      0.834 0.792 0.028 0.000 0.020 0.160
#> SRR1688384     1  0.4099      0.842 0.792 0.020 0.004 0.020 0.164
#> SRR1688385     1  0.4099      0.842 0.792 0.020 0.004 0.020 0.164
#> SRR1688386     1  0.4099      0.842 0.792 0.020 0.004 0.020 0.164
#> SRR1688387     1  0.3511      0.835 0.836 0.020 0.020 0.000 0.124
#> SRR1688388     1  0.3511      0.835 0.836 0.020 0.020 0.000 0.124
#> SRR1688389     1  0.3511      0.835 0.836 0.020 0.020 0.000 0.124
#> SRR1688390     1  0.2289      0.862 0.904 0.012 0.004 0.000 0.080
#> SRR1688391     1  0.2289      0.862 0.904 0.012 0.004 0.000 0.080
#> SRR1688392     1  0.2289      0.862 0.904 0.012 0.004 0.000 0.080
#> SRR1688393     3  0.4251      0.802 0.044 0.016 0.784 0.000 0.156
#> SRR1688395     3  0.4251      0.802 0.044 0.016 0.784 0.000 0.156
#> SRR1688394     3  0.4251      0.802 0.044 0.016 0.784 0.000 0.156
#> SRR1688397     3  0.2701      0.820 0.044 0.012 0.896 0.000 0.048
#> SRR1688398     3  0.2701      0.820 0.044 0.012 0.896 0.000 0.048
#> SRR1688396     3  0.2701      0.820 0.044 0.012 0.896 0.000 0.048
#> SRR1688399     3  0.3285      0.823 0.044 0.008 0.856 0.000 0.092
#> SRR1688400     3  0.3285      0.823 0.044 0.008 0.856 0.000 0.092
#> SRR1688402     3  0.4587      0.805 0.044 0.052 0.792 0.004 0.108
#> SRR1688401     3  0.3285      0.823 0.044 0.008 0.856 0.000 0.092
#> SRR1688403     3  0.4587      0.805 0.044 0.052 0.792 0.004 0.108
#> SRR1688404     3  0.4587      0.805 0.044 0.052 0.792 0.004 0.108
#> SRR1688405     3  0.8340      0.340 0.252 0.008 0.352 0.100 0.288
#> SRR1688407     3  0.8340      0.340 0.252 0.008 0.352 0.100 0.288
#> SRR1688408     3  0.4639      0.810 0.044 0.044 0.784 0.004 0.124
#> SRR1688406     3  0.8340      0.340 0.252 0.008 0.352 0.100 0.288
#> SRR1688410     3  0.4639      0.810 0.044 0.044 0.784 0.004 0.124
#> SRR1688411     4  0.0703      0.793 0.024 0.000 0.000 0.976 0.000
#> SRR1688409     3  0.4639      0.810 0.044 0.044 0.784 0.004 0.124
#> SRR1688412     4  0.0703      0.793 0.024 0.000 0.000 0.976 0.000
#> SRR1688413     4  0.0703      0.793 0.024 0.000 0.000 0.976 0.000
#> SRR1688414     4  0.0865      0.793 0.024 0.000 0.000 0.972 0.004
#> SRR1688415     2  0.3336      0.751 0.000 0.772 0.000 0.228 0.000
#> SRR1688416     2  0.3336      0.751 0.000 0.772 0.000 0.228 0.000
#> SRR1688417     2  0.3336      0.751 0.000 0.772 0.000 0.228 0.000
#> SRR1688418     2  0.3336      0.751 0.000 0.772 0.000 0.228 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
#> SRR1688357     2  0.0520     0.6858 0.000 0.984 0.000 0.008 0.000 NA
#> SRR1688358     2  0.0520     0.6858 0.000 0.984 0.000 0.008 0.000 NA
#> SRR1688359     2  0.0520     0.6858 0.000 0.984 0.000 0.008 0.000 NA
#> SRR1688360     2  0.5366     0.3453 0.000 0.624 0.000 0.036 0.264 NA
#> SRR1688361     2  0.5366     0.3453 0.000 0.624 0.000 0.036 0.264 NA
#> SRR1688362     2  0.5366     0.3453 0.000 0.624 0.000 0.036 0.264 NA
#> SRR1688363     5  0.6456     1.0000 0.096 0.280 0.000 0.104 0.520 NA
#> SRR1688365     5  0.6456     1.0000 0.096 0.280 0.000 0.104 0.520 NA
#> SRR1688364     5  0.6456     1.0000 0.096 0.280 0.000 0.104 0.520 NA
#> SRR1688366     2  0.6895     0.0680 0.004 0.440 0.008 0.356 0.076 NA
#> SRR1688367     2  0.6895     0.0680 0.004 0.440 0.008 0.356 0.076 NA
#> SRR1688368     2  0.6895     0.0680 0.004 0.440 0.008 0.356 0.076 NA
#> SRR1688370     2  0.2625     0.6459 0.000 0.872 0.000 0.000 0.056 NA
#> SRR1688369     2  0.2625     0.6459 0.000 0.872 0.000 0.000 0.056 NA
#> SRR1688371     2  0.2625     0.6459 0.000 0.872 0.000 0.000 0.056 NA
#> SRR1688372     4  0.3369     0.9816 0.008 0.140 0.008 0.824 0.008 NA
#> SRR1688373     4  0.3369     0.9816 0.008 0.140 0.008 0.824 0.008 NA
#> SRR1688374     4  0.3468     0.9805 0.008 0.140 0.012 0.820 0.008 NA
#> SRR1688375     1  0.4075     0.6859 0.744 0.000 0.000 0.016 0.036 NA
#> SRR1688377     1  0.4075     0.6859 0.744 0.000 0.000 0.016 0.036 NA
#> SRR1688378     1  0.3566     0.6830 0.812 0.000 0.000 0.008 0.104 NA
#> SRR1688376     1  0.4075     0.6859 0.744 0.000 0.000 0.016 0.036 NA
#> SRR1688380     1  0.3566     0.6830 0.812 0.000 0.000 0.008 0.104 NA
#> SRR1688379     1  0.3566     0.6830 0.812 0.000 0.000 0.008 0.104 NA
#> SRR1688381     1  0.3668     0.6511 0.800 0.000 0.000 0.024 0.144 NA
#> SRR1688382     1  0.3668     0.6511 0.800 0.000 0.000 0.024 0.144 NA
#> SRR1688383     1  0.3668     0.6511 0.800 0.000 0.000 0.024 0.144 NA
#> SRR1688384     1  0.3270     0.6694 0.840 0.000 0.000 0.024 0.100 NA
#> SRR1688385     1  0.3270     0.6694 0.840 0.000 0.000 0.024 0.100 NA
#> SRR1688386     1  0.3270     0.6694 0.840 0.000 0.000 0.024 0.100 NA
#> SRR1688387     1  0.4018     0.6322 0.580 0.000 0.008 0.000 0.000 NA
#> SRR1688388     1  0.4018     0.6322 0.580 0.000 0.008 0.000 0.000 NA
#> SRR1688389     1  0.4018     0.6322 0.580 0.000 0.008 0.000 0.000 NA
#> SRR1688390     1  0.3648     0.6858 0.740 0.000 0.000 0.004 0.016 NA
#> SRR1688391     1  0.3648     0.6858 0.740 0.000 0.000 0.004 0.016 NA
#> SRR1688392     1  0.3648     0.6858 0.740 0.000 0.000 0.004 0.016 NA
#> SRR1688393     3  0.3713     0.7933 0.020 0.000 0.828 0.016 0.076 NA
#> SRR1688395     3  0.3713     0.7933 0.020 0.000 0.828 0.016 0.076 NA
#> SRR1688394     3  0.3713     0.7933 0.020 0.000 0.828 0.016 0.076 NA
#> SRR1688397     3  0.2725     0.8146 0.020 0.000 0.884 0.004 0.060 NA
#> SRR1688398     3  0.2725     0.8146 0.020 0.000 0.884 0.004 0.060 NA
#> SRR1688396     3  0.2725     0.8146 0.020 0.000 0.884 0.004 0.060 NA
#> SRR1688399     3  0.3329     0.8150 0.020 0.000 0.856 0.036 0.024 NA
#> SRR1688400     3  0.3329     0.8150 0.020 0.000 0.856 0.036 0.024 NA
#> SRR1688402     3  0.4655     0.7910 0.020 0.000 0.744 0.036 0.036 NA
#> SRR1688401     3  0.3329     0.8150 0.020 0.000 0.856 0.036 0.024 NA
#> SRR1688403     3  0.4655     0.7910 0.020 0.000 0.744 0.036 0.036 NA
#> SRR1688404     3  0.4655     0.7910 0.020 0.000 0.744 0.036 0.036 NA
#> SRR1688405     1  0.8615    -0.0619 0.288 0.000 0.288 0.124 0.136 NA
#> SRR1688407     3  0.8615    -0.0506 0.288 0.000 0.288 0.124 0.136 NA
#> SRR1688408     3  0.4750     0.7989 0.020 0.000 0.736 0.044 0.032 NA
#> SRR1688406     1  0.8615    -0.0619 0.288 0.000 0.288 0.124 0.136 NA
#> SRR1688410     3  0.4750     0.7989 0.020 0.000 0.736 0.044 0.032 NA
#> SRR1688411     4  0.2513     0.9859 0.008 0.140 0.000 0.852 0.000 NA
#> SRR1688409     3  0.4750     0.7989 0.020 0.000 0.736 0.044 0.032 NA
#> SRR1688412     4  0.2513     0.9859 0.008 0.140 0.000 0.852 0.000 NA
#> SRR1688413     4  0.2513     0.9859 0.008 0.140 0.000 0.852 0.000 NA
#> SRR1688414     4  0.2655     0.9849 0.008 0.140 0.004 0.848 0.000 NA
#> SRR1688415     2  0.0717     0.6877 0.000 0.976 0.000 0.008 0.016 NA
#> SRR1688416     2  0.0717     0.6877 0.000 0.976 0.000 0.008 0.016 NA
#> SRR1688417     2  0.0717     0.6877 0.000 0.976 0.000 0.008 0.016 NA
#> SRR1688418     2  0.0717     0.6877 0.000 0.976 0.000 0.008 0.016 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 16435 rows and 62 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 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-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.4955 0.505   0.505
#> 3 3 1.000           0.991       0.995         0.3470 0.829   0.661
#> 4 4 1.000           0.909       0.967         0.1166 0.924   0.772
#> 5 5 0.868           0.778       0.886         0.0488 0.936   0.763
#> 6 6 0.861           0.643       0.833         0.0378 0.967   0.851

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1688357     2       0          1  0  1
#> SRR1688358     2       0          1  0  1
#> SRR1688359     2       0          1  0  1
#> SRR1688360     2       0          1  0  1
#> SRR1688361     2       0          1  0  1
#> SRR1688362     2       0          1  0  1
#> SRR1688363     2       0          1  0  1
#> SRR1688365     2       0          1  0  1
#> SRR1688364     2       0          1  0  1
#> SRR1688366     2       0          1  0  1
#> SRR1688367     2       0          1  0  1
#> SRR1688368     2       0          1  0  1
#> SRR1688370     2       0          1  0  1
#> SRR1688369     2       0          1  0  1
#> SRR1688371     2       0          1  0  1
#> SRR1688372     2       0          1  0  1
#> SRR1688373     2       0          1  0  1
#> SRR1688374     2       0          1  0  1
#> SRR1688375     1       0          1  1  0
#> SRR1688377     1       0          1  1  0
#> SRR1688378     1       0          1  1  0
#> SRR1688376     1       0          1  1  0
#> SRR1688380     1       0          1  1  0
#> SRR1688379     1       0          1  1  0
#> SRR1688381     1       0          1  1  0
#> SRR1688382     1       0          1  1  0
#> SRR1688383     1       0          1  1  0
#> SRR1688384     1       0          1  1  0
#> SRR1688385     1       0          1  1  0
#> SRR1688386     1       0          1  1  0
#> SRR1688387     1       0          1  1  0
#> SRR1688388     1       0          1  1  0
#> SRR1688389     1       0          1  1  0
#> SRR1688390     1       0          1  1  0
#> SRR1688391     1       0          1  1  0
#> SRR1688392     1       0          1  1  0
#> SRR1688393     1       0          1  1  0
#> SRR1688395     1       0          1  1  0
#> SRR1688394     1       0          1  1  0
#> SRR1688397     1       0          1  1  0
#> SRR1688398     1       0          1  1  0
#> SRR1688396     1       0          1  1  0
#> SRR1688399     1       0          1  1  0
#> SRR1688400     1       0          1  1  0
#> SRR1688402     1       0          1  1  0
#> SRR1688401     1       0          1  1  0
#> SRR1688403     1       0          1  1  0
#> SRR1688404     1       0          1  1  0
#> SRR1688405     1       0          1  1  0
#> SRR1688407     1       0          1  1  0
#> SRR1688408     1       0          1  1  0
#> SRR1688406     1       0          1  1  0
#> SRR1688410     1       0          1  1  0
#> SRR1688411     2       0          1  0  1
#> SRR1688409     1       0          1  1  0
#> SRR1688412     2       0          1  0  1
#> SRR1688413     2       0          1  0  1
#> SRR1688414     2       0          1  0  1
#> SRR1688415     2       0          1  0  1
#> SRR1688416     2       0          1  0  1
#> SRR1688417     2       0          1  0  1
#> SRR1688418     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette  p1  p2 p3
#> SRR1688357     2   0.000      0.988 0.0 1.0  0
#> SRR1688358     2   0.000      0.988 0.0 1.0  0
#> SRR1688359     2   0.000      0.988 0.0 1.0  0
#> SRR1688360     2   0.000      0.988 0.0 1.0  0
#> SRR1688361     2   0.000      0.988 0.0 1.0  0
#> SRR1688362     2   0.000      0.988 0.0 1.0  0
#> SRR1688363     2   0.296      0.898 0.1 0.9  0
#> SRR1688365     2   0.296      0.898 0.1 0.9  0
#> SRR1688364     2   0.296      0.898 0.1 0.9  0
#> SRR1688366     2   0.000      0.988 0.0 1.0  0
#> SRR1688367     2   0.000      0.988 0.0 1.0  0
#> SRR1688368     2   0.000      0.988 0.0 1.0  0
#> SRR1688370     2   0.000      0.988 0.0 1.0  0
#> SRR1688369     2   0.000      0.988 0.0 1.0  0
#> SRR1688371     2   0.000      0.988 0.0 1.0  0
#> SRR1688372     2   0.000      0.988 0.0 1.0  0
#> SRR1688373     2   0.000      0.988 0.0 1.0  0
#> SRR1688374     2   0.000      0.988 0.0 1.0  0
#> SRR1688375     1   0.000      1.000 1.0 0.0  0
#> SRR1688377     1   0.000      1.000 1.0 0.0  0
#> SRR1688378     1   0.000      1.000 1.0 0.0  0
#> SRR1688376     1   0.000      1.000 1.0 0.0  0
#> SRR1688380     1   0.000      1.000 1.0 0.0  0
#> SRR1688379     1   0.000      1.000 1.0 0.0  0
#> SRR1688381     1   0.000      1.000 1.0 0.0  0
#> SRR1688382     1   0.000      1.000 1.0 0.0  0
#> SRR1688383     1   0.000      1.000 1.0 0.0  0
#> SRR1688384     1   0.000      1.000 1.0 0.0  0
#> SRR1688385     1   0.000      1.000 1.0 0.0  0
#> SRR1688386     1   0.000      1.000 1.0 0.0  0
#> SRR1688387     1   0.000      1.000 1.0 0.0  0
#> SRR1688388     1   0.000      1.000 1.0 0.0  0
#> SRR1688389     1   0.000      1.000 1.0 0.0  0
#> SRR1688390     1   0.000      1.000 1.0 0.0  0
#> SRR1688391     1   0.000      1.000 1.0 0.0  0
#> SRR1688392     1   0.000      1.000 1.0 0.0  0
#> SRR1688393     3   0.000      1.000 0.0 0.0  1
#> SRR1688395     3   0.000      1.000 0.0 0.0  1
#> SRR1688394     3   0.000      1.000 0.0 0.0  1
#> SRR1688397     3   0.000      1.000 0.0 0.0  1
#> SRR1688398     3   0.000      1.000 0.0 0.0  1
#> SRR1688396     3   0.000      1.000 0.0 0.0  1
#> SRR1688399     3   0.000      1.000 0.0 0.0  1
#> SRR1688400     3   0.000      1.000 0.0 0.0  1
#> SRR1688402     3   0.000      1.000 0.0 0.0  1
#> SRR1688401     3   0.000      1.000 0.0 0.0  1
#> SRR1688403     3   0.000      1.000 0.0 0.0  1
#> SRR1688404     3   0.000      1.000 0.0 0.0  1
#> SRR1688405     3   0.000      1.000 0.0 0.0  1
#> SRR1688407     3   0.000      1.000 0.0 0.0  1
#> SRR1688408     3   0.000      1.000 0.0 0.0  1
#> SRR1688406     3   0.000      1.000 0.0 0.0  1
#> SRR1688410     3   0.000      1.000 0.0 0.0  1
#> SRR1688411     2   0.000      0.988 0.0 1.0  0
#> SRR1688409     3   0.000      1.000 0.0 0.0  1
#> SRR1688412     2   0.000      0.988 0.0 1.0  0
#> SRR1688413     2   0.000      0.988 0.0 1.0  0
#> SRR1688414     2   0.000      0.988 0.0 1.0  0
#> SRR1688415     2   0.000      0.988 0.0 1.0  0
#> SRR1688416     2   0.000      0.988 0.0 1.0  0
#> SRR1688417     2   0.000      0.988 0.0 1.0  0
#> SRR1688418     2   0.000      0.988 0.0 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
#> SRR1688357     2  0.0000     0.9169 0.000 1.000 0.000 0.000
#> SRR1688358     2  0.0000     0.9169 0.000 1.000 0.000 0.000
#> SRR1688359     2  0.0000     0.9169 0.000 1.000 0.000 0.000
#> SRR1688360     2  0.0000     0.9169 0.000 1.000 0.000 0.000
#> SRR1688361     2  0.0000     0.9169 0.000 1.000 0.000 0.000
#> SRR1688362     2  0.0000     0.9169 0.000 1.000 0.000 0.000
#> SRR1688363     2  0.2124     0.8645 0.008 0.924 0.000 0.068
#> SRR1688365     2  0.2124     0.8645 0.008 0.924 0.000 0.068
#> SRR1688364     2  0.2124     0.8645 0.008 0.924 0.000 0.068
#> SRR1688366     4  0.5000    -0.0746 0.000 0.500 0.000 0.500
#> SRR1688367     2  0.5000    -0.1070 0.000 0.500 0.000 0.500
#> SRR1688368     2  0.5000    -0.1070 0.000 0.500 0.000 0.500
#> SRR1688370     2  0.0000     0.9169 0.000 1.000 0.000 0.000
#> SRR1688369     2  0.0000     0.9169 0.000 1.000 0.000 0.000
#> SRR1688371     2  0.0000     0.9169 0.000 1.000 0.000 0.000
#> SRR1688372     4  0.0469     0.9209 0.000 0.012 0.000 0.988
#> SRR1688373     4  0.0469     0.9209 0.000 0.012 0.000 0.988
#> SRR1688374     4  0.0469     0.9209 0.000 0.012 0.000 0.988
#> SRR1688375     1  0.0000     0.9961 1.000 0.000 0.000 0.000
#> SRR1688377     1  0.0000     0.9961 1.000 0.000 0.000 0.000
#> SRR1688378     1  0.0000     0.9961 1.000 0.000 0.000 0.000
#> SRR1688376     1  0.0000     0.9961 1.000 0.000 0.000 0.000
#> SRR1688380     1  0.0000     0.9961 1.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000     0.9961 1.000 0.000 0.000 0.000
#> SRR1688381     1  0.0469     0.9923 0.988 0.000 0.000 0.012
#> SRR1688382     1  0.0469     0.9923 0.988 0.000 0.000 0.012
#> SRR1688383     1  0.0469     0.9923 0.988 0.000 0.000 0.012
#> SRR1688384     1  0.0469     0.9923 0.988 0.000 0.000 0.012
#> SRR1688385     1  0.0469     0.9923 0.988 0.000 0.000 0.012
#> SRR1688386     1  0.0469     0.9923 0.988 0.000 0.000 0.012
#> SRR1688387     1  0.0000     0.9961 1.000 0.000 0.000 0.000
#> SRR1688388     1  0.0000     0.9961 1.000 0.000 0.000 0.000
#> SRR1688389     1  0.0000     0.9961 1.000 0.000 0.000 0.000
#> SRR1688390     1  0.0000     0.9961 1.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000     0.9961 1.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000     0.9961 1.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000     0.9928 0.000 0.000 1.000 0.000
#> SRR1688395     3  0.0000     0.9928 0.000 0.000 1.000 0.000
#> SRR1688394     3  0.0000     0.9928 0.000 0.000 1.000 0.000
#> SRR1688397     3  0.0000     0.9928 0.000 0.000 1.000 0.000
#> SRR1688398     3  0.0000     0.9928 0.000 0.000 1.000 0.000
#> SRR1688396     3  0.0000     0.9928 0.000 0.000 1.000 0.000
#> SRR1688399     3  0.0000     0.9928 0.000 0.000 1.000 0.000
#> SRR1688400     3  0.0000     0.9928 0.000 0.000 1.000 0.000
#> SRR1688402     3  0.0000     0.9928 0.000 0.000 1.000 0.000
#> SRR1688401     3  0.0000     0.9928 0.000 0.000 1.000 0.000
#> SRR1688403     3  0.0000     0.9928 0.000 0.000 1.000 0.000
#> SRR1688404     3  0.0000     0.9928 0.000 0.000 1.000 0.000
#> SRR1688405     3  0.1302     0.9627 0.000 0.000 0.956 0.044
#> SRR1688407     3  0.1302     0.9627 0.000 0.000 0.956 0.044
#> SRR1688408     3  0.0000     0.9928 0.000 0.000 1.000 0.000
#> SRR1688406     3  0.1302     0.9627 0.000 0.000 0.956 0.044
#> SRR1688410     3  0.0000     0.9928 0.000 0.000 1.000 0.000
#> SRR1688411     4  0.0469     0.9209 0.000 0.012 0.000 0.988
#> SRR1688409     3  0.0000     0.9928 0.000 0.000 1.000 0.000
#> SRR1688412     4  0.0469     0.9209 0.000 0.012 0.000 0.988
#> SRR1688413     4  0.0469     0.9209 0.000 0.012 0.000 0.988
#> SRR1688414     4  0.0469     0.9209 0.000 0.012 0.000 0.988
#> SRR1688415     2  0.0000     0.9169 0.000 1.000 0.000 0.000
#> SRR1688416     2  0.0000     0.9169 0.000 1.000 0.000 0.000
#> SRR1688417     2  0.0000     0.9169 0.000 1.000 0.000 0.000
#> SRR1688418     2  0.0000     0.9169 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1688357     2  0.0000      0.795 0.000 1.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.795 0.000 1.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.795 0.000 1.000 0.000 0.000 0.000
#> SRR1688360     2  0.3752      0.539 0.000 0.708 0.000 0.000 0.292
#> SRR1688361     2  0.3752      0.539 0.000 0.708 0.000 0.000 0.292
#> SRR1688362     2  0.3752      0.539 0.000 0.708 0.000 0.000 0.292
#> SRR1688363     5  0.4891     -0.171 0.004 0.480 0.000 0.016 0.500
#> SRR1688365     5  0.4891     -0.171 0.004 0.480 0.000 0.016 0.500
#> SRR1688364     5  0.4891     -0.171 0.004 0.480 0.000 0.016 0.500
#> SRR1688366     2  0.6164      0.386 0.000 0.520 0.000 0.328 0.152
#> SRR1688367     2  0.6164      0.386 0.000 0.520 0.000 0.328 0.152
#> SRR1688368     2  0.6164      0.386 0.000 0.520 0.000 0.328 0.152
#> SRR1688370     2  0.0290      0.792 0.000 0.992 0.000 0.000 0.008
#> SRR1688369     2  0.0290      0.792 0.000 0.992 0.000 0.000 0.008
#> SRR1688371     2  0.0290      0.792 0.000 0.992 0.000 0.000 0.008
#> SRR1688372     4  0.0162      1.000 0.000 0.004 0.000 0.996 0.000
#> SRR1688373     4  0.0162      1.000 0.000 0.004 0.000 0.996 0.000
#> SRR1688374     4  0.0162      1.000 0.000 0.004 0.000 0.996 0.000
#> SRR1688375     1  0.0404      0.899 0.988 0.000 0.000 0.000 0.012
#> SRR1688377     1  0.0404      0.899 0.988 0.000 0.000 0.000 0.012
#> SRR1688378     1  0.1041      0.897 0.964 0.000 0.000 0.004 0.032
#> SRR1688376     1  0.0404      0.899 0.988 0.000 0.000 0.000 0.012
#> SRR1688380     1  0.1041      0.897 0.964 0.000 0.000 0.004 0.032
#> SRR1688379     1  0.1041      0.897 0.964 0.000 0.000 0.004 0.032
#> SRR1688381     1  0.3715      0.810 0.736 0.000 0.000 0.004 0.260
#> SRR1688382     1  0.3715      0.810 0.736 0.000 0.000 0.004 0.260
#> SRR1688383     1  0.3715      0.810 0.736 0.000 0.000 0.004 0.260
#> SRR1688384     1  0.3715      0.810 0.736 0.000 0.000 0.004 0.260
#> SRR1688385     1  0.3715      0.810 0.736 0.000 0.000 0.004 0.260
#> SRR1688386     1  0.3715      0.810 0.736 0.000 0.000 0.004 0.260
#> SRR1688387     1  0.0609      0.897 0.980 0.000 0.000 0.000 0.020
#> SRR1688388     1  0.0609      0.897 0.980 0.000 0.000 0.000 0.020
#> SRR1688389     1  0.0609      0.897 0.980 0.000 0.000 0.000 0.020
#> SRR1688390     1  0.0510      0.898 0.984 0.000 0.000 0.000 0.016
#> SRR1688391     1  0.0510      0.898 0.984 0.000 0.000 0.000 0.016
#> SRR1688392     1  0.0510      0.898 0.984 0.000 0.000 0.000 0.016
#> SRR1688393     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR1688395     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR1688394     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR1688397     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR1688398     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR1688396     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR1688399     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR1688400     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR1688402     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR1688401     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR1688403     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR1688404     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR1688405     5  0.4517      0.138 0.000 0.000 0.436 0.008 0.556
#> SRR1688407     5  0.4517      0.138 0.000 0.000 0.436 0.008 0.556
#> SRR1688408     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR1688406     5  0.4517      0.138 0.000 0.000 0.436 0.008 0.556
#> SRR1688410     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR1688411     4  0.0162      1.000 0.000 0.004 0.000 0.996 0.000
#> SRR1688409     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR1688412     4  0.0162      1.000 0.000 0.004 0.000 0.996 0.000
#> SRR1688413     4  0.0162      1.000 0.000 0.004 0.000 0.996 0.000
#> SRR1688414     4  0.0162      1.000 0.000 0.004 0.000 0.996 0.000
#> SRR1688415     2  0.0000      0.795 0.000 1.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.795 0.000 1.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.795 0.000 1.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.795 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1688357     2  0.0000     0.7305 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000     0.7305 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000     0.7305 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688360     2  0.4076    -0.0824 0.000 0.540 0.000 0.000 0.452 0.008
#> SRR1688361     2  0.4076    -0.0824 0.000 0.540 0.000 0.000 0.452 0.008
#> SRR1688362     2  0.4076    -0.0824 0.000 0.540 0.000 0.000 0.452 0.008
#> SRR1688363     5  0.3705     1.0000 0.036 0.180 0.000 0.008 0.776 0.000
#> SRR1688365     5  0.3705     1.0000 0.036 0.180 0.000 0.008 0.776 0.000
#> SRR1688364     5  0.3705     1.0000 0.036 0.180 0.000 0.008 0.776 0.000
#> SRR1688366     2  0.6407     0.1679 0.000 0.456 0.000 0.264 0.256 0.024
#> SRR1688367     2  0.6407     0.1679 0.000 0.456 0.000 0.264 0.256 0.024
#> SRR1688368     2  0.6407     0.1679 0.000 0.456 0.000 0.264 0.256 0.024
#> SRR1688370     2  0.0405     0.7260 0.000 0.988 0.000 0.000 0.004 0.008
#> SRR1688369     2  0.0405     0.7260 0.000 0.988 0.000 0.000 0.004 0.008
#> SRR1688371     2  0.0405     0.7260 0.000 0.988 0.000 0.000 0.004 0.008
#> SRR1688372     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688373     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688374     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688375     1  0.3817     0.5551 0.568 0.000 0.000 0.000 0.000 0.432
#> SRR1688377     1  0.3817     0.5551 0.568 0.000 0.000 0.000 0.000 0.432
#> SRR1688378     1  0.3728     0.6096 0.652 0.000 0.000 0.000 0.004 0.344
#> SRR1688376     1  0.3817     0.5551 0.568 0.000 0.000 0.000 0.000 0.432
#> SRR1688380     1  0.3728     0.6096 0.652 0.000 0.000 0.000 0.004 0.344
#> SRR1688379     1  0.3728     0.6096 0.652 0.000 0.000 0.000 0.004 0.344
#> SRR1688381     1  0.0260     0.5619 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR1688382     1  0.0260     0.5619 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR1688383     1  0.0260     0.5619 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR1688384     1  0.0405     0.5524 0.988 0.000 0.000 0.000 0.004 0.008
#> SRR1688385     1  0.0405     0.5524 0.988 0.000 0.000 0.000 0.004 0.008
#> SRR1688386     1  0.0405     0.5524 0.988 0.000 0.000 0.000 0.004 0.008
#> SRR1688387     6  0.3860    -0.5419 0.472 0.000 0.000 0.000 0.000 0.528
#> SRR1688388     6  0.3860    -0.5419 0.472 0.000 0.000 0.000 0.000 0.528
#> SRR1688389     6  0.3860    -0.5419 0.472 0.000 0.000 0.000 0.000 0.528
#> SRR1688390     1  0.3862     0.5040 0.524 0.000 0.000 0.000 0.000 0.476
#> SRR1688391     1  0.3862     0.5040 0.524 0.000 0.000 0.000 0.000 0.476
#> SRR1688392     1  0.3862     0.5040 0.524 0.000 0.000 0.000 0.000 0.476
#> SRR1688393     3  0.0146     0.9957 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1688395     3  0.0146     0.9957 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1688394     3  0.0146     0.9957 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1688397     3  0.0000     0.9975 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688398     3  0.0000     0.9975 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688396     3  0.0000     0.9975 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688399     3  0.0000     0.9975 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688400     3  0.0000     0.9975 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688402     3  0.0146     0.9970 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1688401     3  0.0000     0.9975 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688403     3  0.0146     0.9970 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1688404     3  0.0146     0.9970 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1688405     6  0.6955     0.2040 0.228 0.000 0.088 0.000 0.228 0.456
#> SRR1688407     6  0.6955     0.2040 0.228 0.000 0.088 0.000 0.228 0.456
#> SRR1688408     3  0.0146     0.9970 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1688406     6  0.6955     0.2040 0.228 0.000 0.088 0.000 0.228 0.456
#> SRR1688410     3  0.0146     0.9970 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1688411     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688409     3  0.0146     0.9970 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1688412     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688413     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688414     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688415     2  0.0000     0.7305 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000     0.7305 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000     0.7305 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000     0.7305 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-skmeans-collect-classes

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

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4954 0.505   0.505
#> 3 3 0.865           0.896       0.947         0.3319 0.764   0.561
#> 4 4 0.979           0.915       0.970         0.1093 0.896   0.707
#> 5 5 1.000           0.957       0.984         0.0407 0.969   0.884
#> 6 6 0.972           0.894       0.964         0.0699 0.948   0.783

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1688357     2  0.0000      1.000 0.000 1.000
#> SRR1688358     2  0.0000      1.000 0.000 1.000
#> SRR1688359     2  0.0000      1.000 0.000 1.000
#> SRR1688360     2  0.0000      1.000 0.000 1.000
#> SRR1688361     2  0.0000      1.000 0.000 1.000
#> SRR1688362     2  0.0000      1.000 0.000 1.000
#> SRR1688363     2  0.0000      1.000 0.000 1.000
#> SRR1688365     2  0.0000      1.000 0.000 1.000
#> SRR1688364     2  0.0000      1.000 0.000 1.000
#> SRR1688366     2  0.0000      1.000 0.000 1.000
#> SRR1688367     2  0.0000      1.000 0.000 1.000
#> SRR1688368     2  0.0000      1.000 0.000 1.000
#> SRR1688370     2  0.0000      1.000 0.000 1.000
#> SRR1688369     2  0.0000      1.000 0.000 1.000
#> SRR1688371     2  0.0000      1.000 0.000 1.000
#> SRR1688372     2  0.0000      1.000 0.000 1.000
#> SRR1688373     2  0.0000      1.000 0.000 1.000
#> SRR1688374     2  0.0000      1.000 0.000 1.000
#> SRR1688375     1  0.0000      1.000 1.000 0.000
#> SRR1688377     1  0.0000      1.000 1.000 0.000
#> SRR1688378     1  0.0000      1.000 1.000 0.000
#> SRR1688376     1  0.0000      1.000 1.000 0.000
#> SRR1688380     1  0.0000      1.000 1.000 0.000
#> SRR1688379     1  0.0000      1.000 1.000 0.000
#> SRR1688381     1  0.0000      1.000 1.000 0.000
#> SRR1688382     1  0.0000      1.000 1.000 0.000
#> SRR1688383     1  0.0000      1.000 1.000 0.000
#> SRR1688384     1  0.0000      1.000 1.000 0.000
#> SRR1688385     1  0.0000      1.000 1.000 0.000
#> SRR1688386     1  0.0000      1.000 1.000 0.000
#> SRR1688387     1  0.0000      1.000 1.000 0.000
#> SRR1688388     1  0.0000      1.000 1.000 0.000
#> SRR1688389     1  0.0000      1.000 1.000 0.000
#> SRR1688390     1  0.0000      1.000 1.000 0.000
#> SRR1688391     1  0.0000      1.000 1.000 0.000
#> SRR1688392     1  0.0000      1.000 1.000 0.000
#> SRR1688393     1  0.0000      1.000 1.000 0.000
#> SRR1688395     1  0.0000      1.000 1.000 0.000
#> SRR1688394     1  0.0000      1.000 1.000 0.000
#> SRR1688397     1  0.0000      1.000 1.000 0.000
#> SRR1688398     1  0.0000      1.000 1.000 0.000
#> SRR1688396     1  0.0000      1.000 1.000 0.000
#> SRR1688399     1  0.0000      1.000 1.000 0.000
#> SRR1688400     1  0.0000      1.000 1.000 0.000
#> SRR1688402     1  0.0000      1.000 1.000 0.000
#> SRR1688401     1  0.0000      1.000 1.000 0.000
#> SRR1688403     1  0.0000      1.000 1.000 0.000
#> SRR1688404     1  0.0000      1.000 1.000 0.000
#> SRR1688405     1  0.0000      1.000 1.000 0.000
#> SRR1688407     1  0.0000      1.000 1.000 0.000
#> SRR1688408     1  0.0000      1.000 1.000 0.000
#> SRR1688406     1  0.0000      1.000 1.000 0.000
#> SRR1688410     1  0.0000      1.000 1.000 0.000
#> SRR1688411     2  0.0000      1.000 0.000 1.000
#> SRR1688409     1  0.0000      1.000 1.000 0.000
#> SRR1688412     2  0.0000      1.000 0.000 1.000
#> SRR1688413     2  0.0000      1.000 0.000 1.000
#> SRR1688414     2  0.0672      0.992 0.008 0.992
#> SRR1688415     2  0.0000      1.000 0.000 1.000
#> SRR1688416     2  0.0000      1.000 0.000 1.000
#> SRR1688417     2  0.0000      1.000 0.000 1.000
#> SRR1688418     2  0.0000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2  0.0000     0.9034 0.000 1.000 0.000
#> SRR1688358     2  0.0000     0.9034 0.000 1.000 0.000
#> SRR1688359     2  0.0000     0.9034 0.000 1.000 0.000
#> SRR1688360     2  0.0000     0.9034 0.000 1.000 0.000
#> SRR1688361     2  0.0000     0.9034 0.000 1.000 0.000
#> SRR1688362     2  0.0000     0.9034 0.000 1.000 0.000
#> SRR1688363     2  0.5465     0.5763 0.288 0.712 0.000
#> SRR1688365     2  0.6309    -0.0350 0.496 0.504 0.000
#> SRR1688364     1  0.6309    -0.0332 0.500 0.500 0.000
#> SRR1688366     2  0.0592     0.9005 0.012 0.988 0.000
#> SRR1688367     2  0.3879     0.8253 0.152 0.848 0.000
#> SRR1688368     2  0.4931     0.7563 0.232 0.768 0.000
#> SRR1688370     2  0.0000     0.9034 0.000 1.000 0.000
#> SRR1688369     2  0.0000     0.9034 0.000 1.000 0.000
#> SRR1688371     2  0.0000     0.9034 0.000 1.000 0.000
#> SRR1688372     2  0.3412     0.8570 0.124 0.876 0.000
#> SRR1688373     2  0.4702     0.7802 0.212 0.788 0.000
#> SRR1688374     1  0.1643     0.8989 0.956 0.044 0.000
#> SRR1688375     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688377     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688378     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688376     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688380     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688379     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688381     1  0.0000     0.9362 1.000 0.000 0.000
#> SRR1688382     1  0.0000     0.9362 1.000 0.000 0.000
#> SRR1688383     1  0.0000     0.9362 1.000 0.000 0.000
#> SRR1688384     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688385     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688386     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688387     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688388     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688389     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688390     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688391     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688392     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688393     3  0.0000     1.0000 0.000 0.000 1.000
#> SRR1688395     3  0.0000     1.0000 0.000 0.000 1.000
#> SRR1688394     3  0.0000     1.0000 0.000 0.000 1.000
#> SRR1688397     3  0.0000     1.0000 0.000 0.000 1.000
#> SRR1688398     3  0.0000     1.0000 0.000 0.000 1.000
#> SRR1688396     3  0.0000     1.0000 0.000 0.000 1.000
#> SRR1688399     3  0.0000     1.0000 0.000 0.000 1.000
#> SRR1688400     3  0.0000     1.0000 0.000 0.000 1.000
#> SRR1688402     3  0.0000     1.0000 0.000 0.000 1.000
#> SRR1688401     3  0.0000     1.0000 0.000 0.000 1.000
#> SRR1688403     3  0.0000     1.0000 0.000 0.000 1.000
#> SRR1688404     3  0.0000     1.0000 0.000 0.000 1.000
#> SRR1688405     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688407     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688408     3  0.0000     1.0000 0.000 0.000 1.000
#> SRR1688406     1  0.1289     0.9584 0.968 0.000 0.032
#> SRR1688410     3  0.0000     1.0000 0.000 0.000 1.000
#> SRR1688411     2  0.4605     0.7906 0.204 0.796 0.000
#> SRR1688409     3  0.0000     1.0000 0.000 0.000 1.000
#> SRR1688412     2  0.3116     0.8657 0.108 0.892 0.000
#> SRR1688413     2  0.3619     0.8488 0.136 0.864 0.000
#> SRR1688414     1  0.4399     0.7061 0.812 0.188 0.000
#> SRR1688415     2  0.0000     0.9034 0.000 1.000 0.000
#> SRR1688416     2  0.0000     0.9034 0.000 1.000 0.000
#> SRR1688417     2  0.0000     0.9034 0.000 1.000 0.000
#> SRR1688418     2  0.0000     0.9034 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1688357     2  0.0000     0.9602 0.000 1.000 0.000 0.000
#> SRR1688358     2  0.0000     0.9602 0.000 1.000 0.000 0.000
#> SRR1688359     2  0.0000     0.9602 0.000 1.000 0.000 0.000
#> SRR1688360     2  0.0000     0.9602 0.000 1.000 0.000 0.000
#> SRR1688361     2  0.0000     0.9602 0.000 1.000 0.000 0.000
#> SRR1688362     2  0.0000     0.9602 0.000 1.000 0.000 0.000
#> SRR1688363     2  0.4222     0.5934 0.272 0.728 0.000 0.000
#> SRR1688365     1  0.5000     0.0032 0.500 0.500 0.000 0.000
#> SRR1688364     1  0.4999     0.0336 0.508 0.492 0.000 0.000
#> SRR1688366     2  0.0469     0.9483 0.012 0.988 0.000 0.000
#> SRR1688367     2  0.3931     0.7652 0.128 0.832 0.000 0.040
#> SRR1688368     4  0.6280     0.4105 0.072 0.344 0.000 0.584
#> SRR1688370     2  0.0000     0.9602 0.000 1.000 0.000 0.000
#> SRR1688369     2  0.0000     0.9602 0.000 1.000 0.000 0.000
#> SRR1688371     2  0.0000     0.9602 0.000 1.000 0.000 0.000
#> SRR1688372     4  0.0000     0.9445 0.000 0.000 0.000 1.000
#> SRR1688373     4  0.0000     0.9445 0.000 0.000 0.000 1.000
#> SRR1688374     4  0.0000     0.9445 0.000 0.000 0.000 1.000
#> SRR1688375     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688377     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688378     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688376     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688380     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688381     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688382     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688383     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688384     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688385     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688386     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688387     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688388     1  0.0188     0.9438 0.996 0.000 0.004 0.000
#> SRR1688389     1  0.0188     0.9438 0.996 0.000 0.004 0.000
#> SRR1688390     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1688395     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1688394     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1688397     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1688398     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1688396     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1688399     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1688400     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1688402     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1688401     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1688403     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1688404     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1688405     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688407     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688408     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1688406     1  0.0000     0.9472 1.000 0.000 0.000 0.000
#> SRR1688410     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1688411     4  0.0000     0.9445 0.000 0.000 0.000 1.000
#> SRR1688409     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1688412     4  0.0000     0.9445 0.000 0.000 0.000 1.000
#> SRR1688413     4  0.0000     0.9445 0.000 0.000 0.000 1.000
#> SRR1688414     4  0.0000     0.9445 0.000 0.000 0.000 1.000
#> SRR1688415     2  0.0000     0.9602 0.000 1.000 0.000 0.000
#> SRR1688416     2  0.0000     0.9602 0.000 1.000 0.000 0.000
#> SRR1688417     2  0.0000     0.9602 0.000 1.000 0.000 0.000
#> SRR1688418     2  0.0000     0.9602 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1688357     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> SRR1688360     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> SRR1688361     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> SRR1688362     2  0.4161      0.339 0.000 0.608 0.000 0.000 0.392
#> SRR1688363     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688365     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688364     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688366     2  0.0404      0.942 0.012 0.988 0.000 0.000 0.000
#> SRR1688367     2  0.3214      0.766 0.120 0.844 0.000 0.036 0.000
#> SRR1688368     4  0.5422      0.376 0.072 0.348 0.000 0.580 0.000
#> SRR1688370     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> SRR1688372     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000
#> SRR1688373     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000
#> SRR1688374     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000
#> SRR1688375     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688377     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688378     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688376     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688380     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688381     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688382     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688383     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688384     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688385     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688386     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688387     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688388     1  0.0162      0.995 0.996 0.000 0.004 0.000 0.000
#> SRR1688389     1  0.0162      0.995 0.996 0.000 0.004 0.000 0.000
#> SRR1688390     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688405     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688407     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688406     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688411     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688412     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000
#> SRR1688413     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000
#> SRR1688414     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000
#> SRR1688415     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3    p4    p5    p6
#> SRR1688357     2  0.0000     0.9564 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688358     2  0.0000     0.9564 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688359     2  0.0000     0.9564 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688360     2  0.0000     0.9564 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688361     2  0.0000     0.9564 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688362     2  0.3737     0.3397 0.000 0.608  0 0.000 0.392 0.000
#> SRR1688363     5  0.0000     1.0000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1688365     5  0.0000     1.0000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1688364     5  0.0000     1.0000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1688366     2  0.0363     0.9453 0.012 0.988  0 0.000 0.000 0.000
#> SRR1688367     2  0.2887     0.7860 0.120 0.844  0 0.036 0.000 0.000
#> SRR1688368     4  0.4871     0.3783 0.072 0.348  0 0.580 0.000 0.000
#> SRR1688370     2  0.0000     0.9564 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688369     2  0.0000     0.9564 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688371     2  0.0000     0.9564 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688372     4  0.0000     0.9208 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688373     4  0.0000     0.9208 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688374     4  0.0000     0.9208 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688375     1  0.0000     0.9264 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688377     1  0.0000     0.9264 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688378     1  0.3857     0.0632 0.532 0.000  0 0.000 0.000 0.468
#> SRR1688376     1  0.0000     0.9264 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688380     1  0.3717     0.3320 0.616 0.000  0 0.000 0.000 0.384
#> SRR1688379     6  0.3810     0.1389 0.428 0.000  0 0.000 0.000 0.572
#> SRR1688381     1  0.0000     0.9264 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688382     1  0.0000     0.9264 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688383     1  0.0000     0.9264 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688384     1  0.0000     0.9264 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688385     1  0.0000     0.9264 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688386     1  0.0000     0.9264 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688387     6  0.0000     0.8967 0.000 0.000  0 0.000 0.000 1.000
#> SRR1688388     6  0.0000     0.8967 0.000 0.000  0 0.000 0.000 1.000
#> SRR1688389     6  0.0000     0.8967 0.000 0.000  0 0.000 0.000 1.000
#> SRR1688390     6  0.0000     0.8967 0.000 0.000  0 0.000 0.000 1.000
#> SRR1688391     6  0.0000     0.8967 0.000 0.000  0 0.000 0.000 1.000
#> SRR1688392     6  0.0000     0.8967 0.000 0.000  0 0.000 0.000 1.000
#> SRR1688393     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688395     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688394     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688397     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688398     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688396     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688399     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688400     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688402     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688401     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688403     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688404     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688405     1  0.0000     0.9264 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688407     1  0.0000     0.9264 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688408     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688406     1  0.0000     0.9264 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688410     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688411     4  0.0000     0.9208 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688409     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688412     4  0.0000     0.9208 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688413     4  0.0000     0.9208 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688414     4  0.0000     0.9208 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688415     2  0.0000     0.9564 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688416     2  0.0000     0.9564 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688417     2  0.0000     0.9564 0.000 1.000  0 0.000 0.000 0.000
#> SRR1688418     2  0.0000     0.9564 0.000 1.000  0 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-pam-collect-classes

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

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4955 0.505   0.505
#> 3 3 1.000           0.999       0.999         0.3101 0.764   0.567
#> 4 4 1.000           1.000       1.000         0.1254 0.919   0.768
#> 5 5 1.000           0.987       0.992         0.0864 0.937   0.765
#> 6 6 0.916           0.883       0.899         0.0328 0.981   0.908

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
#> SRR1688357     2       0          1  0  1
#> SRR1688358     2       0          1  0  1
#> SRR1688359     2       0          1  0  1
#> SRR1688360     2       0          1  0  1
#> SRR1688361     2       0          1  0  1
#> SRR1688362     2       0          1  0  1
#> SRR1688363     2       0          1  0  1
#> SRR1688365     2       0          1  0  1
#> SRR1688364     2       0          1  0  1
#> SRR1688366     2       0          1  0  1
#> SRR1688367     2       0          1  0  1
#> SRR1688368     2       0          1  0  1
#> SRR1688370     2       0          1  0  1
#> SRR1688369     2       0          1  0  1
#> SRR1688371     2       0          1  0  1
#> SRR1688372     2       0          1  0  1
#> SRR1688373     2       0          1  0  1
#> SRR1688374     2       0          1  0  1
#> SRR1688375     1       0          1  1  0
#> SRR1688377     1       0          1  1  0
#> SRR1688378     1       0          1  1  0
#> SRR1688376     1       0          1  1  0
#> SRR1688380     1       0          1  1  0
#> SRR1688379     1       0          1  1  0
#> SRR1688381     1       0          1  1  0
#> SRR1688382     1       0          1  1  0
#> SRR1688383     1       0          1  1  0
#> SRR1688384     1       0          1  1  0
#> SRR1688385     1       0          1  1  0
#> SRR1688386     1       0          1  1  0
#> SRR1688387     1       0          1  1  0
#> SRR1688388     1       0          1  1  0
#> SRR1688389     1       0          1  1  0
#> SRR1688390     1       0          1  1  0
#> SRR1688391     1       0          1  1  0
#> SRR1688392     1       0          1  1  0
#> SRR1688393     1       0          1  1  0
#> SRR1688395     1       0          1  1  0
#> SRR1688394     1       0          1  1  0
#> SRR1688397     1       0          1  1  0
#> SRR1688398     1       0          1  1  0
#> SRR1688396     1       0          1  1  0
#> SRR1688399     1       0          1  1  0
#> SRR1688400     1       0          1  1  0
#> SRR1688402     1       0          1  1  0
#> SRR1688401     1       0          1  1  0
#> SRR1688403     1       0          1  1  0
#> SRR1688404     1       0          1  1  0
#> SRR1688405     1       0          1  1  0
#> SRR1688407     1       0          1  1  0
#> SRR1688408     1       0          1  1  0
#> SRR1688406     1       0          1  1  0
#> SRR1688410     1       0          1  1  0
#> SRR1688411     2       0          1  0  1
#> SRR1688409     1       0          1  1  0
#> SRR1688412     2       0          1  0  1
#> SRR1688413     2       0          1  0  1
#> SRR1688414     2       0          1  0  1
#> SRR1688415     2       0          1  0  1
#> SRR1688416     2       0          1  0  1
#> SRR1688417     2       0          1  0  1
#> SRR1688418     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688358     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688359     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688360     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688361     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688362     2  0.0237      0.997 0.004 0.996 0.000
#> SRR1688363     2  0.0237      0.997 0.004 0.996 0.000
#> SRR1688365     2  0.0237      0.997 0.004 0.996 0.000
#> SRR1688364     2  0.0237      0.997 0.004 0.996 0.000
#> SRR1688366     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688367     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688368     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688370     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688369     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688371     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688372     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688373     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688374     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688375     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1688377     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1688378     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1688376     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1688380     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1688379     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1688381     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1688382     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1688383     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1688384     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1688385     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1688386     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1688387     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1688388     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1688389     1  0.0237      0.998 0.996 0.000 0.004
#> SRR1688390     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1688391     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1688392     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688405     2  0.0237      0.996 0.000 0.996 0.004
#> SRR1688407     2  0.0237      0.996 0.000 0.996 0.004
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688406     2  0.0237      0.996 0.000 0.996 0.004
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688411     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1688412     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688413     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688414     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688415     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688416     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688417     2  0.0000      0.999 0.000 1.000 0.000
#> SRR1688418     2  0.0000      0.999 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1 p2 p3 p4
#> SRR1688357     2       0          1  0  1  0  0
#> SRR1688358     2       0          1  0  1  0  0
#> SRR1688359     2       0          1  0  1  0  0
#> SRR1688360     2       0          1  0  1  0  0
#> SRR1688361     2       0          1  0  1  0  0
#> SRR1688362     2       0          1  0  1  0  0
#> SRR1688363     2       0          1  0  1  0  0
#> SRR1688365     2       0          1  0  1  0  0
#> SRR1688364     2       0          1  0  1  0  0
#> SRR1688366     2       0          1  0  1  0  0
#> SRR1688367     2       0          1  0  1  0  0
#> SRR1688368     2       0          1  0  1  0  0
#> SRR1688370     2       0          1  0  1  0  0
#> SRR1688369     2       0          1  0  1  0  0
#> SRR1688371     2       0          1  0  1  0  0
#> SRR1688372     4       0          1  0  0  0  1
#> SRR1688373     4       0          1  0  0  0  1
#> SRR1688374     4       0          1  0  0  0  1
#> SRR1688375     1       0          1  1  0  0  0
#> SRR1688377     1       0          1  1  0  0  0
#> SRR1688378     1       0          1  1  0  0  0
#> SRR1688376     1       0          1  1  0  0  0
#> SRR1688380     1       0          1  1  0  0  0
#> SRR1688379     1       0          1  1  0  0  0
#> SRR1688381     1       0          1  1  0  0  0
#> SRR1688382     1       0          1  1  0  0  0
#> SRR1688383     1       0          1  1  0  0  0
#> SRR1688384     1       0          1  1  0  0  0
#> SRR1688385     1       0          1  1  0  0  0
#> SRR1688386     1       0          1  1  0  0  0
#> SRR1688387     1       0          1  1  0  0  0
#> SRR1688388     1       0          1  1  0  0  0
#> SRR1688389     1       0          1  1  0  0  0
#> SRR1688390     1       0          1  1  0  0  0
#> SRR1688391     1       0          1  1  0  0  0
#> SRR1688392     1       0          1  1  0  0  0
#> SRR1688393     3       0          1  0  0  1  0
#> SRR1688395     3       0          1  0  0  1  0
#> SRR1688394     3       0          1  0  0  1  0
#> SRR1688397     3       0          1  0  0  1  0
#> SRR1688398     3       0          1  0  0  1  0
#> SRR1688396     3       0          1  0  0  1  0
#> SRR1688399     3       0          1  0  0  1  0
#> SRR1688400     3       0          1  0  0  1  0
#> SRR1688402     3       0          1  0  0  1  0
#> SRR1688401     3       0          1  0  0  1  0
#> SRR1688403     3       0          1  0  0  1  0
#> SRR1688404     3       0          1  0  0  1  0
#> SRR1688405     2       0          1  0  1  0  0
#> SRR1688407     2       0          1  0  1  0  0
#> SRR1688408     3       0          1  0  0  1  0
#> SRR1688406     2       0          1  0  1  0  0
#> SRR1688410     3       0          1  0  0  1  0
#> SRR1688411     4       0          1  0  0  0  1
#> SRR1688409     3       0          1  0  0  1  0
#> SRR1688412     4       0          1  0  0  0  1
#> SRR1688413     4       0          1  0  0  0  1
#> SRR1688414     4       0          1  0  0  0  1
#> SRR1688415     2       0          1  0  1  0  0
#> SRR1688416     2       0          1  0  1  0  0
#> SRR1688417     2       0          1  0  1  0  0
#> SRR1688418     2       0          1  0  1  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
#> SRR1688357     2  0.0000      1.000  0 1.000  0  0 0.000
#> SRR1688358     2  0.0000      1.000  0 1.000  0  0 0.000
#> SRR1688359     2  0.0000      1.000  0 1.000  0  0 0.000
#> SRR1688360     5  0.2605      0.862  0 0.148  0  0 0.852
#> SRR1688361     5  0.2605      0.862  0 0.148  0  0 0.852
#> SRR1688362     5  0.2605      0.862  0 0.148  0  0 0.852
#> SRR1688363     5  0.0162      0.955  0 0.004  0  0 0.996
#> SRR1688365     5  0.0162      0.955  0 0.004  0  0 0.996
#> SRR1688364     5  0.0162      0.955  0 0.004  0  0 0.996
#> SRR1688366     5  0.0162      0.955  0 0.004  0  0 0.996
#> SRR1688367     5  0.0162      0.955  0 0.004  0  0 0.996
#> SRR1688368     5  0.0162      0.955  0 0.004  0  0 0.996
#> SRR1688370     2  0.0000      1.000  0 1.000  0  0 0.000
#> SRR1688369     2  0.0000      1.000  0 1.000  0  0 0.000
#> SRR1688371     2  0.0000      1.000  0 1.000  0  0 0.000
#> SRR1688372     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1688373     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1688374     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1688375     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688377     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688378     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688376     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688380     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688379     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688381     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688382     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688383     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688384     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688385     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688386     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688387     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688388     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688389     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688390     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688391     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688392     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1688393     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1688395     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1688394     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1688397     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1688398     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1688396     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1688399     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1688400     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1688402     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1688401     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1688403     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1688404     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1688405     5  0.0000      0.954  0 0.000  0  0 1.000
#> SRR1688407     5  0.0000      0.954  0 0.000  0  0 1.000
#> SRR1688408     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1688406     5  0.0000      0.954  0 0.000  0  0 1.000
#> SRR1688410     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1688411     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1688409     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1688412     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1688413     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1688414     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1688415     2  0.0000      1.000  0 1.000  0  0 0.000
#> SRR1688416     2  0.0000      1.000  0 1.000  0  0 0.000
#> SRR1688417     2  0.0000      1.000  0 1.000  0  0 0.000
#> SRR1688418     2  0.0000      1.000  0 1.000  0  0 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3 p4    p5    p6
#> SRR1688357     2  0.0000      0.957 0.000 1.000  0  0 0.000 0.000
#> SRR1688358     2  0.0000      0.957 0.000 1.000  0  0 0.000 0.000
#> SRR1688359     2  0.4707      0.408 0.000 0.660  0  0 0.244 0.096
#> SRR1688360     5  0.5674      0.773 0.000 0.172  0  0 0.496 0.332
#> SRR1688361     5  0.5674      0.773 0.000 0.172  0  0 0.496 0.332
#> SRR1688362     5  0.5674      0.773 0.000 0.172  0  0 0.496 0.332
#> SRR1688363     5  0.3810      0.738 0.000 0.000  0  0 0.572 0.428
#> SRR1688365     5  0.3810      0.738 0.000 0.000  0  0 0.572 0.428
#> SRR1688364     5  0.3810      0.738 0.000 0.000  0  0 0.572 0.428
#> SRR1688366     6  0.2178      0.792 0.000 0.000  0  0 0.132 0.868
#> SRR1688367     6  0.2178      0.792 0.000 0.000  0  0 0.132 0.868
#> SRR1688368     6  0.2178      0.792 0.000 0.000  0  0 0.132 0.868
#> SRR1688370     2  0.0000      0.957 0.000 1.000  0  0 0.000 0.000
#> SRR1688369     2  0.0000      0.957 0.000 1.000  0  0 0.000 0.000
#> SRR1688371     2  0.0000      0.957 0.000 1.000  0  0 0.000 0.000
#> SRR1688372     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1688373     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1688374     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1688375     1  0.3810      0.677 0.572 0.000  0  0 0.428 0.000
#> SRR1688377     1  0.3810      0.677 0.572 0.000  0  0 0.428 0.000
#> SRR1688378     1  0.0000      0.857 1.000 0.000  0  0 0.000 0.000
#> SRR1688376     1  0.3810      0.677 0.572 0.000  0  0 0.428 0.000
#> SRR1688380     1  0.0000      0.857 1.000 0.000  0  0 0.000 0.000
#> SRR1688379     1  0.0000      0.857 1.000 0.000  0  0 0.000 0.000
#> SRR1688381     1  0.0000      0.857 1.000 0.000  0  0 0.000 0.000
#> SRR1688382     1  0.0000      0.857 1.000 0.000  0  0 0.000 0.000
#> SRR1688383     1  0.0000      0.857 1.000 0.000  0  0 0.000 0.000
#> SRR1688384     1  0.0000      0.857 1.000 0.000  0  0 0.000 0.000
#> SRR1688385     1  0.0000      0.857 1.000 0.000  0  0 0.000 0.000
#> SRR1688386     1  0.0000      0.857 1.000 0.000  0  0 0.000 0.000
#> SRR1688387     1  0.3810      0.677 0.572 0.000  0  0 0.428 0.000
#> SRR1688388     1  0.3810      0.677 0.572 0.000  0  0 0.428 0.000
#> SRR1688389     1  0.3810      0.677 0.572 0.000  0  0 0.428 0.000
#> SRR1688390     1  0.0000      0.857 1.000 0.000  0  0 0.000 0.000
#> SRR1688391     1  0.0000      0.857 1.000 0.000  0  0 0.000 0.000
#> SRR1688392     1  0.0000      0.857 1.000 0.000  0  0 0.000 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688405     6  0.0865      0.824 0.000 0.000  0  0 0.036 0.964
#> SRR1688407     6  0.0865      0.824 0.000 0.000  0  0 0.036 0.964
#> SRR1688408     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688406     6  0.0865      0.824 0.000 0.000  0  0 0.036 0.964
#> SRR1688410     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688411     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1688412     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1688413     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1688414     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1688415     2  0.0000      0.957 0.000 1.000  0  0 0.000 0.000
#> SRR1688416     2  0.0000      0.957 0.000 1.000  0  0 0.000 0.000
#> SRR1688417     2  0.0000      0.957 0.000 1.000  0  0 0.000 0.000
#> SRR1688418     2  0.0000      0.957 0.000 1.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 16435 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4955 0.505   0.505
#> 3 3 0.717           0.917       0.932         0.3187 0.649   0.415
#> 4 4 1.000           0.948       0.979         0.1292 0.911   0.743
#> 5 5 0.921           0.928       0.951         0.0549 0.948   0.804
#> 6 6 0.891           0.870       0.915         0.0398 0.976   0.892

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1688357     2  0.0000      1.000 0.000 1.000
#> SRR1688358     2  0.0000      1.000 0.000 1.000
#> SRR1688359     2  0.0000      1.000 0.000 1.000
#> SRR1688360     2  0.0000      1.000 0.000 1.000
#> SRR1688361     2  0.0000      1.000 0.000 1.000
#> SRR1688362     2  0.0000      1.000 0.000 1.000
#> SRR1688363     2  0.0000      1.000 0.000 1.000
#> SRR1688365     2  0.0000      1.000 0.000 1.000
#> SRR1688364     2  0.0000      1.000 0.000 1.000
#> SRR1688366     2  0.0000      1.000 0.000 1.000
#> SRR1688367     2  0.0000      1.000 0.000 1.000
#> SRR1688368     2  0.0000      1.000 0.000 1.000
#> SRR1688370     2  0.0000      1.000 0.000 1.000
#> SRR1688369     2  0.0000      1.000 0.000 1.000
#> SRR1688371     2  0.0000      1.000 0.000 1.000
#> SRR1688372     2  0.0000      1.000 0.000 1.000
#> SRR1688373     2  0.0000      1.000 0.000 1.000
#> SRR1688374     2  0.0376      0.996 0.004 0.996
#> SRR1688375     1  0.0000      1.000 1.000 0.000
#> SRR1688377     1  0.0000      1.000 1.000 0.000
#> SRR1688378     1  0.0000      1.000 1.000 0.000
#> SRR1688376     1  0.0000      1.000 1.000 0.000
#> SRR1688380     1  0.0000      1.000 1.000 0.000
#> SRR1688379     1  0.0000      1.000 1.000 0.000
#> SRR1688381     1  0.0000      1.000 1.000 0.000
#> SRR1688382     1  0.0000      1.000 1.000 0.000
#> SRR1688383     1  0.0000      1.000 1.000 0.000
#> SRR1688384     1  0.0000      1.000 1.000 0.000
#> SRR1688385     1  0.0000      1.000 1.000 0.000
#> SRR1688386     1  0.0000      1.000 1.000 0.000
#> SRR1688387     1  0.0000      1.000 1.000 0.000
#> SRR1688388     1  0.0000      1.000 1.000 0.000
#> SRR1688389     1  0.0000      1.000 1.000 0.000
#> SRR1688390     1  0.0000      1.000 1.000 0.000
#> SRR1688391     1  0.0000      1.000 1.000 0.000
#> SRR1688392     1  0.0000      1.000 1.000 0.000
#> SRR1688393     1  0.0000      1.000 1.000 0.000
#> SRR1688395     1  0.0000      1.000 1.000 0.000
#> SRR1688394     1  0.0000      1.000 1.000 0.000
#> SRR1688397     1  0.0000      1.000 1.000 0.000
#> SRR1688398     1  0.0000      1.000 1.000 0.000
#> SRR1688396     1  0.0000      1.000 1.000 0.000
#> SRR1688399     1  0.0000      1.000 1.000 0.000
#> SRR1688400     1  0.0000      1.000 1.000 0.000
#> SRR1688402     1  0.0000      1.000 1.000 0.000
#> SRR1688401     1  0.0000      1.000 1.000 0.000
#> SRR1688403     1  0.0000      1.000 1.000 0.000
#> SRR1688404     1  0.0000      1.000 1.000 0.000
#> SRR1688405     1  0.0000      1.000 1.000 0.000
#> SRR1688407     1  0.0000      1.000 1.000 0.000
#> SRR1688408     1  0.0000      1.000 1.000 0.000
#> SRR1688406     1  0.0000      1.000 1.000 0.000
#> SRR1688410     1  0.0000      1.000 1.000 0.000
#> SRR1688411     2  0.0000      1.000 0.000 1.000
#> SRR1688409     1  0.0000      1.000 1.000 0.000
#> SRR1688412     2  0.0000      1.000 0.000 1.000
#> SRR1688413     2  0.0000      1.000 0.000 1.000
#> SRR1688414     2  0.0000      1.000 0.000 1.000
#> SRR1688415     2  0.0000      1.000 0.000 1.000
#> SRR1688416     2  0.0000      1.000 0.000 1.000
#> SRR1688417     2  0.0000      1.000 0.000 1.000
#> SRR1688418     2  0.0000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2   0.000      0.991 0.000 1.000 0.000
#> SRR1688358     2   0.000      0.991 0.000 1.000 0.000
#> SRR1688359     2   0.000      0.991 0.000 1.000 0.000
#> SRR1688360     2   0.000      0.991 0.000 1.000 0.000
#> SRR1688361     2   0.000      0.991 0.000 1.000 0.000
#> SRR1688362     2   0.000      0.991 0.000 1.000 0.000
#> SRR1688363     1   0.562      0.632 0.692 0.308 0.000
#> SRR1688365     1   0.435      0.780 0.816 0.184 0.000
#> SRR1688364     1   0.470      0.754 0.788 0.212 0.000
#> SRR1688366     2   0.000      0.991 0.000 1.000 0.000
#> SRR1688367     2   0.116      0.970 0.028 0.972 0.000
#> SRR1688368     2   0.355      0.875 0.132 0.868 0.000
#> SRR1688370     2   0.000      0.991 0.000 1.000 0.000
#> SRR1688369     2   0.000      0.991 0.000 1.000 0.000
#> SRR1688371     2   0.000      0.991 0.000 1.000 0.000
#> SRR1688372     1   0.546      0.546 0.712 0.288 0.000
#> SRR1688373     1   0.296      0.804 0.900 0.100 0.000
#> SRR1688374     1   0.116      0.841 0.972 0.028 0.000
#> SRR1688375     1   0.429      0.858 0.820 0.000 0.180
#> SRR1688377     1   0.429      0.858 0.820 0.000 0.180
#> SRR1688378     1   0.369      0.878 0.860 0.000 0.140
#> SRR1688376     1   0.429      0.858 0.820 0.000 0.180
#> SRR1688380     1   0.369      0.878 0.860 0.000 0.140
#> SRR1688379     1   0.369      0.878 0.860 0.000 0.140
#> SRR1688381     1   0.196      0.872 0.944 0.000 0.056
#> SRR1688382     1   0.196      0.872 0.944 0.000 0.056
#> SRR1688383     1   0.207      0.873 0.940 0.000 0.060
#> SRR1688384     1   0.369      0.878 0.860 0.000 0.140
#> SRR1688385     1   0.382      0.875 0.852 0.000 0.148
#> SRR1688386     1   0.382      0.875 0.852 0.000 0.148
#> SRR1688387     1   0.445      0.849 0.808 0.000 0.192
#> SRR1688388     1   0.460      0.839 0.796 0.000 0.204
#> SRR1688389     1   0.493      0.809 0.768 0.000 0.232
#> SRR1688390     1   0.341      0.880 0.876 0.000 0.124
#> SRR1688391     1   0.319      0.880 0.888 0.000 0.112
#> SRR1688392     1   0.312      0.880 0.892 0.000 0.108
#> SRR1688393     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688395     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688394     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688397     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688398     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688396     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688399     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688400     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688402     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688401     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688403     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688404     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688405     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688407     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688408     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688406     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688410     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688411     1   0.186      0.832 0.948 0.052 0.000
#> SRR1688409     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688412     1   0.362      0.773 0.864 0.136 0.000
#> SRR1688413     1   0.236      0.822 0.928 0.072 0.000
#> SRR1688414     1   0.334      0.788 0.880 0.120 0.000
#> SRR1688415     2   0.000      0.991 0.000 1.000 0.000
#> SRR1688416     2   0.000      0.991 0.000 1.000 0.000
#> SRR1688417     2   0.000      0.991 0.000 1.000 0.000
#> SRR1688418     2   0.000      0.991 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2 p3    p4
#> SRR1688357     2  0.0000      0.999 0.000 1.000  0 0.000
#> SRR1688358     2  0.0000      0.999 0.000 1.000  0 0.000
#> SRR1688359     2  0.0000      0.999 0.000 1.000  0 0.000
#> SRR1688360     2  0.0000      0.999 0.000 1.000  0 0.000
#> SRR1688361     2  0.0000      0.999 0.000 1.000  0 0.000
#> SRR1688362     2  0.0000      0.999 0.000 1.000  0 0.000
#> SRR1688363     1  0.4790      0.443 0.620 0.380  0 0.000
#> SRR1688365     1  0.4193      0.658 0.732 0.268  0 0.000
#> SRR1688364     1  0.4304      0.633 0.716 0.284  0 0.000
#> SRR1688366     2  0.0000      0.999 0.000 1.000  0 0.000
#> SRR1688367     2  0.0592      0.983 0.000 0.984  0 0.016
#> SRR1688368     4  0.4761      0.404 0.000 0.372  0 0.628
#> SRR1688370     2  0.0000      0.999 0.000 1.000  0 0.000
#> SRR1688369     2  0.0000      0.999 0.000 1.000  0 0.000
#> SRR1688371     2  0.0000      0.999 0.000 1.000  0 0.000
#> SRR1688372     4  0.0000      0.946 0.000 0.000  0 1.000
#> SRR1688373     4  0.0000      0.946 0.000 0.000  0 1.000
#> SRR1688374     4  0.0000      0.946 0.000 0.000  0 1.000
#> SRR1688375     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688377     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688378     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688376     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688380     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688379     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688381     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688382     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688383     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688384     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688385     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688386     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688387     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688388     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688389     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688390     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688391     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688392     1  0.0000      0.946 1.000 0.000  0 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688405     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688407     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688408     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688406     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688410     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688411     4  0.0000      0.946 0.000 0.000  0 1.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1688412     4  0.0000      0.946 0.000 0.000  0 1.000
#> SRR1688413     4  0.0000      0.946 0.000 0.000  0 1.000
#> SRR1688414     4  0.0000      0.946 0.000 0.000  0 1.000
#> SRR1688415     2  0.0000      0.999 0.000 1.000  0 0.000
#> SRR1688416     2  0.0000      0.999 0.000 1.000  0 0.000
#> SRR1688417     2  0.0000      0.999 0.000 1.000  0 0.000
#> SRR1688418     2  0.0000      0.999 0.000 1.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1688357     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> SRR1688360     5  0.3999      0.667 0.000 0.344 0.000 0.000 0.656
#> SRR1688361     5  0.3561      0.775 0.000 0.260 0.000 0.000 0.740
#> SRR1688362     5  0.3305      0.795 0.000 0.224 0.000 0.000 0.776
#> SRR1688363     5  0.3955      0.819 0.116 0.084 0.000 0.000 0.800
#> SRR1688365     5  0.3794      0.794 0.152 0.048 0.000 0.000 0.800
#> SRR1688364     5  0.3846      0.803 0.144 0.056 0.000 0.000 0.800
#> SRR1688366     2  0.0794      0.958 0.000 0.972 0.000 0.000 0.028
#> SRR1688367     2  0.2769      0.842 0.000 0.876 0.000 0.092 0.032
#> SRR1688368     4  0.4794      0.424 0.000 0.344 0.000 0.624 0.032
#> SRR1688370     2  0.0162      0.980 0.000 0.996 0.000 0.000 0.004
#> SRR1688369     2  0.0162      0.980 0.000 0.996 0.000 0.000 0.004
#> SRR1688371     2  0.0162      0.980 0.000 0.996 0.000 0.000 0.004
#> SRR1688372     4  0.0000      0.935 0.000 0.000 0.000 1.000 0.000
#> SRR1688373     4  0.0000      0.935 0.000 0.000 0.000 1.000 0.000
#> SRR1688374     4  0.0000      0.935 0.000 0.000 0.000 1.000 0.000
#> SRR1688375     1  0.0404      0.972 0.988 0.000 0.000 0.000 0.012
#> SRR1688377     1  0.0404      0.972 0.988 0.000 0.000 0.000 0.012
#> SRR1688378     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> SRR1688376     1  0.0404      0.972 0.988 0.000 0.000 0.000 0.012
#> SRR1688380     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> SRR1688381     1  0.0880      0.965 0.968 0.000 0.000 0.000 0.032
#> SRR1688382     1  0.0880      0.965 0.968 0.000 0.000 0.000 0.032
#> SRR1688383     1  0.0880      0.965 0.968 0.000 0.000 0.000 0.032
#> SRR1688384     1  0.1908      0.922 0.908 0.000 0.000 0.000 0.092
#> SRR1688385     1  0.2280      0.897 0.880 0.000 0.000 0.000 0.120
#> SRR1688386     1  0.2230      0.901 0.884 0.000 0.000 0.000 0.116
#> SRR1688387     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> SRR1688388     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> SRR1688389     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> SRR1688390     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR1688395     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR1688394     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR1688397     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR1688398     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR1688396     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR1688399     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR1688400     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR1688402     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR1688401     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR1688403     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR1688404     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR1688405     3  0.3074      0.823 0.000 0.000 0.804 0.000 0.196
#> SRR1688407     3  0.3109      0.819 0.000 0.000 0.800 0.000 0.200
#> SRR1688408     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR1688406     3  0.3074      0.823 0.000 0.000 0.804 0.000 0.196
#> SRR1688410     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR1688411     4  0.0000      0.935 0.000 0.000 0.000 1.000 0.000
#> SRR1688409     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> SRR1688412     4  0.0000      0.935 0.000 0.000 0.000 1.000 0.000
#> SRR1688413     4  0.0000      0.935 0.000 0.000 0.000 1.000 0.000
#> SRR1688414     4  0.0000      0.935 0.000 0.000 0.000 1.000 0.000
#> SRR1688415     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1688357     2  0.0000      0.915 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.915 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.915 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688360     5  0.5549      0.512 0.000 0.304 0.000 0.000 0.532 0.164
#> SRR1688361     5  0.4863      0.719 0.000 0.168 0.000 0.000 0.664 0.168
#> SRR1688362     5  0.3786      0.763 0.000 0.064 0.000 0.000 0.768 0.168
#> SRR1688363     5  0.0146      0.779 0.004 0.000 0.000 0.000 0.996 0.000
#> SRR1688365     5  0.0146      0.779 0.004 0.000 0.000 0.000 0.996 0.000
#> SRR1688364     5  0.0146      0.779 0.004 0.000 0.000 0.000 0.996 0.000
#> SRR1688366     2  0.3455      0.774 0.000 0.816 0.000 0.016 0.036 0.132
#> SRR1688367     2  0.4625      0.683 0.000 0.736 0.000 0.088 0.032 0.144
#> SRR1688368     4  0.6780      0.231 0.004 0.272 0.000 0.468 0.056 0.200
#> SRR1688370     2  0.2135      0.847 0.000 0.872 0.000 0.000 0.000 0.128
#> SRR1688369     2  0.2135      0.847 0.000 0.872 0.000 0.000 0.000 0.128
#> SRR1688371     2  0.2278      0.843 0.000 0.868 0.000 0.000 0.004 0.128
#> SRR1688372     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688373     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688374     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688375     1  0.1610      0.852 0.916 0.000 0.000 0.000 0.000 0.084
#> SRR1688377     1  0.1387      0.856 0.932 0.000 0.000 0.000 0.000 0.068
#> SRR1688378     1  0.0146      0.865 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1688376     1  0.1556      0.853 0.920 0.000 0.000 0.000 0.000 0.080
#> SRR1688380     1  0.0146      0.865 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1688379     1  0.0146      0.865 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1688381     1  0.3265      0.761 0.748 0.000 0.000 0.000 0.004 0.248
#> SRR1688382     1  0.3290      0.758 0.744 0.000 0.000 0.000 0.004 0.252
#> SRR1688383     1  0.3265      0.761 0.748 0.000 0.000 0.000 0.004 0.248
#> SRR1688384     1  0.3636      0.688 0.676 0.000 0.000 0.000 0.004 0.320
#> SRR1688385     1  0.3782      0.633 0.636 0.000 0.000 0.000 0.004 0.360
#> SRR1688386     1  0.3699      0.668 0.660 0.000 0.000 0.000 0.004 0.336
#> SRR1688387     1  0.0777      0.859 0.972 0.000 0.000 0.000 0.004 0.024
#> SRR1688388     1  0.0777      0.859 0.972 0.000 0.000 0.000 0.004 0.024
#> SRR1688389     1  0.0777      0.859 0.972 0.000 0.000 0.000 0.004 0.024
#> SRR1688390     1  0.0508      0.863 0.984 0.000 0.000 0.000 0.004 0.012
#> SRR1688391     1  0.0508      0.863 0.984 0.000 0.000 0.000 0.004 0.012
#> SRR1688392     1  0.0508      0.863 0.984 0.000 0.000 0.000 0.004 0.012
#> SRR1688393     3  0.0146      0.998 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1688395     3  0.0146      0.998 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1688394     3  0.0146      0.998 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1688397     3  0.0146      0.998 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1688398     3  0.0146      0.998 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1688396     3  0.0146      0.998 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1688399     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688400     3  0.0146      0.998 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1688402     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688401     3  0.0146      0.998 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1688403     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688404     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688405     6  0.3104      0.992 0.004 0.000 0.204 0.004 0.000 0.788
#> SRR1688407     6  0.3183      0.988 0.008 0.000 0.200 0.004 0.000 0.788
#> SRR1688408     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688406     6  0.2994      0.989 0.000 0.000 0.208 0.004 0.000 0.788
#> SRR1688410     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688411     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688409     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688412     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688413     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688414     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688415     2  0.0000      0.915 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.915 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.915 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.915 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-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 16435 rows and 62 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 0.663           0.936       0.962         0.4115 0.611   0.611
#> 3 3 0.584           0.805       0.841         0.5136 0.754   0.597
#> 4 4 0.930           0.953       0.972         0.2143 0.876   0.661
#> 5 5 0.891           0.950       0.943         0.0370 0.968   0.868
#> 6 6 1.000           0.978       0.987         0.0257 0.984   0.924

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1688357     2   0.000      1.000 0.000 1.000
#> SRR1688358     2   0.000      1.000 0.000 1.000
#> SRR1688359     2   0.000      1.000 0.000 1.000
#> SRR1688360     2   0.000      1.000 0.000 1.000
#> SRR1688361     2   0.000      1.000 0.000 1.000
#> SRR1688362     2   0.000      1.000 0.000 1.000
#> SRR1688363     1   0.706      0.825 0.808 0.192
#> SRR1688365     1   0.706      0.825 0.808 0.192
#> SRR1688364     1   0.706      0.825 0.808 0.192
#> SRR1688366     2   0.000      1.000 0.000 1.000
#> SRR1688367     2   0.000      1.000 0.000 1.000
#> SRR1688368     2   0.000      1.000 0.000 1.000
#> SRR1688370     2   0.000      1.000 0.000 1.000
#> SRR1688369     2   0.000      1.000 0.000 1.000
#> SRR1688371     2   0.000      1.000 0.000 1.000
#> SRR1688372     1   0.706      0.825 0.808 0.192
#> SRR1688373     1   0.706      0.825 0.808 0.192
#> SRR1688374     1   0.706      0.825 0.808 0.192
#> SRR1688375     1   0.000      0.946 1.000 0.000
#> SRR1688377     1   0.000      0.946 1.000 0.000
#> SRR1688378     1   0.000      0.946 1.000 0.000
#> SRR1688376     1   0.000      0.946 1.000 0.000
#> SRR1688380     1   0.000      0.946 1.000 0.000
#> SRR1688379     1   0.000      0.946 1.000 0.000
#> SRR1688381     1   0.000      0.946 1.000 0.000
#> SRR1688382     1   0.000      0.946 1.000 0.000
#> SRR1688383     1   0.000      0.946 1.000 0.000
#> SRR1688384     1   0.000      0.946 1.000 0.000
#> SRR1688385     1   0.000      0.946 1.000 0.000
#> SRR1688386     1   0.000      0.946 1.000 0.000
#> SRR1688387     1   0.000      0.946 1.000 0.000
#> SRR1688388     1   0.000      0.946 1.000 0.000
#> SRR1688389     1   0.000      0.946 1.000 0.000
#> SRR1688390     1   0.000      0.946 1.000 0.000
#> SRR1688391     1   0.000      0.946 1.000 0.000
#> SRR1688392     1   0.000      0.946 1.000 0.000
#> SRR1688393     1   0.000      0.946 1.000 0.000
#> SRR1688395     1   0.000      0.946 1.000 0.000
#> SRR1688394     1   0.000      0.946 1.000 0.000
#> SRR1688397     1   0.000      0.946 1.000 0.000
#> SRR1688398     1   0.000      0.946 1.000 0.000
#> SRR1688396     1   0.000      0.946 1.000 0.000
#> SRR1688399     1   0.000      0.946 1.000 0.000
#> SRR1688400     1   0.000      0.946 1.000 0.000
#> SRR1688402     1   0.000      0.946 1.000 0.000
#> SRR1688401     1   0.000      0.946 1.000 0.000
#> SRR1688403     1   0.000      0.946 1.000 0.000
#> SRR1688404     1   0.000      0.946 1.000 0.000
#> SRR1688405     1   0.574      0.868 0.864 0.136
#> SRR1688407     1   0.574      0.868 0.864 0.136
#> SRR1688408     1   0.000      0.946 1.000 0.000
#> SRR1688406     1   0.574      0.868 0.864 0.136
#> SRR1688410     1   0.000      0.946 1.000 0.000
#> SRR1688411     1   0.706      0.825 0.808 0.192
#> SRR1688409     1   0.000      0.946 1.000 0.000
#> SRR1688412     1   0.706      0.825 0.808 0.192
#> SRR1688413     1   0.706      0.825 0.808 0.192
#> SRR1688414     1   0.706      0.825 0.808 0.192
#> SRR1688415     2   0.000      1.000 0.000 1.000
#> SRR1688416     2   0.000      1.000 0.000 1.000
#> SRR1688417     2   0.000      1.000 0.000 1.000
#> SRR1688418     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2   0.000      0.978 0.000 1.000 0.000
#> SRR1688358     2   0.000      0.978 0.000 1.000 0.000
#> SRR1688359     2   0.000      0.978 0.000 1.000 0.000
#> SRR1688360     2   0.207      0.963 0.060 0.940 0.000
#> SRR1688361     2   0.207      0.963 0.060 0.940 0.000
#> SRR1688362     2   0.207      0.963 0.060 0.940 0.000
#> SRR1688363     1   0.355      0.564 0.868 0.132 0.000
#> SRR1688365     1   0.355      0.564 0.868 0.132 0.000
#> SRR1688364     1   0.355      0.564 0.868 0.132 0.000
#> SRR1688366     2   0.207      0.963 0.060 0.940 0.000
#> SRR1688367     2   0.207      0.963 0.060 0.940 0.000
#> SRR1688368     2   0.207      0.963 0.060 0.940 0.000
#> SRR1688370     2   0.000      0.978 0.000 1.000 0.000
#> SRR1688369     2   0.000      0.978 0.000 1.000 0.000
#> SRR1688371     2   0.000      0.978 0.000 1.000 0.000
#> SRR1688372     1   0.355      0.564 0.868 0.132 0.000
#> SRR1688373     1   0.355      0.564 0.868 0.132 0.000
#> SRR1688374     1   0.355      0.564 0.868 0.132 0.000
#> SRR1688375     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688377     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688378     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688376     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688380     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688379     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688381     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688382     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688383     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688384     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688385     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688386     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688387     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688388     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688389     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688390     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688391     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688392     1   0.613      0.659 0.600 0.000 0.400
#> SRR1688393     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688395     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688394     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688397     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688398     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688396     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688399     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688400     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688402     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688401     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688403     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688404     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688405     1   0.768      0.615 0.680 0.132 0.188
#> SRR1688407     1   0.768      0.615 0.680 0.132 0.188
#> SRR1688408     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688406     1   0.768      0.615 0.680 0.132 0.188
#> SRR1688410     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688411     1   0.355      0.564 0.868 0.132 0.000
#> SRR1688409     3   0.000      1.000 0.000 0.000 1.000
#> SRR1688412     1   0.355      0.564 0.868 0.132 0.000
#> SRR1688413     1   0.355      0.564 0.868 0.132 0.000
#> SRR1688414     1   0.355      0.564 0.868 0.132 0.000
#> SRR1688415     2   0.000      0.978 0.000 1.000 0.000
#> SRR1688416     2   0.000      0.978 0.000 1.000 0.000
#> SRR1688417     2   0.000      0.978 0.000 1.000 0.000
#> SRR1688418     2   0.000      0.978 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2    p3    p4
#> SRR1688357     2   0.000      0.918  0 1.000 0.000 0.000
#> SRR1688358     2   0.000      0.918  0 1.000 0.000 0.000
#> SRR1688359     2   0.000      0.918  0 1.000 0.000 0.000
#> SRR1688360     2   0.353      0.843  0 0.808 0.000 0.192
#> SRR1688361     2   0.353      0.843  0 0.808 0.000 0.192
#> SRR1688362     2   0.353      0.843  0 0.808 0.000 0.192
#> SRR1688363     4   0.000      0.946  0 0.000 0.000 1.000
#> SRR1688365     4   0.000      0.946  0 0.000 0.000 1.000
#> SRR1688364     4   0.000      0.946  0 0.000 0.000 1.000
#> SRR1688366     2   0.353      0.843  0 0.808 0.000 0.192
#> SRR1688367     2   0.353      0.843  0 0.808 0.000 0.192
#> SRR1688368     2   0.353      0.843  0 0.808 0.000 0.192
#> SRR1688370     2   0.000      0.918  0 1.000 0.000 0.000
#> SRR1688369     2   0.000      0.918  0 1.000 0.000 0.000
#> SRR1688371     2   0.000      0.918  0 1.000 0.000 0.000
#> SRR1688372     4   0.000      0.946  0 0.000 0.000 1.000
#> SRR1688373     4   0.000      0.946  0 0.000 0.000 1.000
#> SRR1688374     4   0.000      0.946  0 0.000 0.000 1.000
#> SRR1688375     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688377     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688378     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688376     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688380     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688379     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688381     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688382     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688383     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688384     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688385     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688386     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688387     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688388     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688389     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688390     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688391     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688392     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1688393     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1688395     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1688394     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1688397     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1688398     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1688396     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1688399     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1688400     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1688402     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1688401     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1688403     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1688404     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1688405     4   0.349      0.806  0 0.000 0.188 0.812
#> SRR1688407     4   0.349      0.806  0 0.000 0.188 0.812
#> SRR1688408     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1688406     4   0.349      0.806  0 0.000 0.188 0.812
#> SRR1688410     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1688411     4   0.000      0.946  0 0.000 0.000 1.000
#> SRR1688409     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1688412     4   0.000      0.946  0 0.000 0.000 1.000
#> SRR1688413     4   0.000      0.946  0 0.000 0.000 1.000
#> SRR1688414     4   0.000      0.946  0 0.000 0.000 1.000
#> SRR1688415     2   0.000      0.918  0 1.000 0.000 0.000
#> SRR1688416     2   0.000      0.918  0 1.000 0.000 0.000
#> SRR1688417     2   0.000      0.918  0 1.000 0.000 0.000
#> SRR1688418     2   0.000      0.918  0 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1   p2    p3    p4    p5
#> SRR1688357     2   0.000      1.000  0 1.00 0.000 0.000 0.000
#> SRR1688358     2   0.000      1.000  0 1.00 0.000 0.000 0.000
#> SRR1688359     2   0.000      1.000  0 1.00 0.000 0.000 0.000
#> SRR1688360     4   0.541      0.991  0 0.16 0.000 0.664 0.176
#> SRR1688361     4   0.541      0.991  0 0.16 0.000 0.664 0.176
#> SRR1688362     4   0.541      0.991  0 0.16 0.000 0.664 0.176
#> SRR1688363     5   0.402      0.665  0 0.00 0.000 0.348 0.652
#> SRR1688365     5   0.402      0.665  0 0.00 0.000 0.348 0.652
#> SRR1688364     5   0.402      0.665  0 0.00 0.000 0.348 0.652
#> SRR1688366     4   0.551      0.991  0 0.16 0.000 0.652 0.188
#> SRR1688367     4   0.551      0.991  0 0.16 0.000 0.652 0.188
#> SRR1688368     4   0.551      0.991  0 0.16 0.000 0.652 0.188
#> SRR1688370     2   0.000      1.000  0 1.00 0.000 0.000 0.000
#> SRR1688369     2   0.000      1.000  0 1.00 0.000 0.000 0.000
#> SRR1688371     2   0.000      1.000  0 1.00 0.000 0.000 0.000
#> SRR1688372     5   0.000      0.833  0 0.00 0.000 0.000 1.000
#> SRR1688373     5   0.000      0.833  0 0.00 0.000 0.000 1.000
#> SRR1688374     5   0.000      0.833  0 0.00 0.000 0.000 1.000
#> SRR1688375     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688377     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688378     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688376     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688380     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688379     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688381     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688382     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688383     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688384     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688385     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688386     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688387     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688388     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688389     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688390     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688391     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688392     1   0.000      1.000  1 0.00 0.000 0.000 0.000
#> SRR1688393     3   0.000      1.000  0 0.00 1.000 0.000 0.000
#> SRR1688395     3   0.000      1.000  0 0.00 1.000 0.000 0.000
#> SRR1688394     3   0.000      1.000  0 0.00 1.000 0.000 0.000
#> SRR1688397     3   0.000      1.000  0 0.00 1.000 0.000 0.000
#> SRR1688398     3   0.000      1.000  0 0.00 1.000 0.000 0.000
#> SRR1688396     3   0.000      1.000  0 0.00 1.000 0.000 0.000
#> SRR1688399     3   0.000      1.000  0 0.00 1.000 0.000 0.000
#> SRR1688400     3   0.000      1.000  0 0.00 1.000 0.000 0.000
#> SRR1688402     3   0.000      1.000  0 0.00 1.000 0.000 0.000
#> SRR1688401     3   0.000      1.000  0 0.00 1.000 0.000 0.000
#> SRR1688403     3   0.000      1.000  0 0.00 1.000 0.000 0.000
#> SRR1688404     3   0.000      1.000  0 0.00 1.000 0.000 0.000
#> SRR1688405     5   0.316      0.717  0 0.00 0.188 0.004 0.808
#> SRR1688407     5   0.316      0.717  0 0.00 0.188 0.004 0.808
#> SRR1688408     3   0.000      1.000  0 0.00 1.000 0.000 0.000
#> SRR1688406     5   0.316      0.717  0 0.00 0.188 0.004 0.808
#> SRR1688410     3   0.000      1.000  0 0.00 1.000 0.000 0.000
#> SRR1688411     5   0.000      0.833  0 0.00 0.000 0.000 1.000
#> SRR1688409     3   0.000      1.000  0 0.00 1.000 0.000 0.000
#> SRR1688412     5   0.000      0.833  0 0.00 0.000 0.000 1.000
#> SRR1688413     5   0.000      0.833  0 0.00 0.000 0.000 1.000
#> SRR1688414     5   0.000      0.833  0 0.00 0.000 0.000 1.000
#> SRR1688415     2   0.000      1.000  0 1.00 0.000 0.000 0.000
#> SRR1688416     2   0.000      1.000  0 1.00 0.000 0.000 0.000
#> SRR1688417     2   0.000      1.000  0 1.00 0.000 0.000 0.000
#> SRR1688418     2   0.000      1.000  0 1.00 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2    p3    p4    p5    p6
#> SRR1688357     2  0.0000      1.000  0  1 0.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      1.000  0  1 0.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      1.000  0  1 0.000 0.000 0.000 0.000
#> SRR1688360     6  0.0000      0.990  0  0 0.000 0.000 0.000 1.000
#> SRR1688361     6  0.0000      0.990  0  0 0.000 0.000 0.000 1.000
#> SRR1688362     6  0.0000      0.990  0  0 0.000 0.000 0.000 1.000
#> SRR1688363     5  0.0909      1.000  0  0 0.000 0.020 0.968 0.012
#> SRR1688365     5  0.0909      1.000  0  0 0.000 0.020 0.968 0.012
#> SRR1688364     5  0.0909      1.000  0  0 0.000 0.020 0.968 0.012
#> SRR1688366     6  0.0363      0.990  0  0 0.000 0.012 0.000 0.988
#> SRR1688367     6  0.0363      0.990  0  0 0.000 0.012 0.000 0.988
#> SRR1688368     6  0.0363      0.990  0  0 0.000 0.012 0.000 0.988
#> SRR1688370     2  0.0000      1.000  0  1 0.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000      1.000  0  1 0.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000      1.000  0  1 0.000 0.000 0.000 0.000
#> SRR1688372     4  0.0363      0.910  0  0 0.000 0.988 0.000 0.012
#> SRR1688373     4  0.0363      0.910  0  0 0.000 0.988 0.000 0.012
#> SRR1688374     4  0.0363      0.910  0  0 0.000 0.988 0.000 0.012
#> SRR1688375     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688377     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688378     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688376     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688380     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688381     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688382     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688383     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688384     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688385     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688386     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688387     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688388     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688389     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688390     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      1.000  1  0 0.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000  0  0 1.000 0.000 0.000 0.000
#> SRR1688395     3  0.0000      1.000  0  0 1.000 0.000 0.000 0.000
#> SRR1688394     3  0.0000      1.000  0  0 1.000 0.000 0.000 0.000
#> SRR1688397     3  0.0000      1.000  0  0 1.000 0.000 0.000 0.000
#> SRR1688398     3  0.0000      1.000  0  0 1.000 0.000 0.000 0.000
#> SRR1688396     3  0.0000      1.000  0  0 1.000 0.000 0.000 0.000
#> SRR1688399     3  0.0000      1.000  0  0 1.000 0.000 0.000 0.000
#> SRR1688400     3  0.0000      1.000  0  0 1.000 0.000 0.000 0.000
#> SRR1688402     3  0.0000      1.000  0  0 1.000 0.000 0.000 0.000
#> SRR1688401     3  0.0000      1.000  0  0 1.000 0.000 0.000 0.000
#> SRR1688403     3  0.0000      1.000  0  0 1.000 0.000 0.000 0.000
#> SRR1688404     3  0.0000      1.000  0  0 1.000 0.000 0.000 0.000
#> SRR1688405     4  0.3248      0.781  0  0 0.164 0.804 0.032 0.000
#> SRR1688407     4  0.3248      0.781  0  0 0.164 0.804 0.032 0.000
#> SRR1688408     3  0.0000      1.000  0  0 1.000 0.000 0.000 0.000
#> SRR1688406     4  0.3248      0.781  0  0 0.164 0.804 0.032 0.000
#> SRR1688410     3  0.0000      1.000  0  0 1.000 0.000 0.000 0.000
#> SRR1688411     4  0.0363      0.910  0  0 0.000 0.988 0.000 0.012
#> SRR1688409     3  0.0000      1.000  0  0 1.000 0.000 0.000 0.000
#> SRR1688412     4  0.0363      0.910  0  0 0.000 0.988 0.000 0.012
#> SRR1688413     4  0.0363      0.910  0  0 0.000 0.988 0.000 0.012
#> SRR1688414     4  0.0363      0.910  0  0 0.000 0.988 0.000 0.012
#> SRR1688415     2  0.0000      1.000  0  1 0.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      1.000  0  1 0.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      1.000  0  1 0.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      1.000  0  1 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

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 16435 rows and 62 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 0.578           0.900       0.923         0.4778 0.505   0.505
#> 3 3 0.672           0.792       0.830         0.3409 0.764   0.557
#> 4 4 0.608           0.786       0.796         0.1306 0.882   0.660
#> 5 5 0.754           0.773       0.803         0.0603 0.937   0.774
#> 6 6 0.743           0.701       0.764         0.0427 0.960   0.850

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
#> SRR1688357     2   0.000      0.963 0.000 1.000
#> SRR1688358     2   0.000      0.963 0.000 1.000
#> SRR1688359     2   0.000      0.963 0.000 1.000
#> SRR1688360     2   0.000      0.963 0.000 1.000
#> SRR1688361     2   0.000      0.963 0.000 1.000
#> SRR1688362     2   0.000      0.963 0.000 1.000
#> SRR1688363     2   0.814      0.696 0.252 0.748
#> SRR1688365     2   0.814      0.696 0.252 0.748
#> SRR1688364     2   0.814      0.696 0.252 0.748
#> SRR1688366     2   0.000      0.963 0.000 1.000
#> SRR1688367     2   0.000      0.963 0.000 1.000
#> SRR1688368     2   0.000      0.963 0.000 1.000
#> SRR1688370     2   0.000      0.963 0.000 1.000
#> SRR1688369     2   0.000      0.963 0.000 1.000
#> SRR1688371     2   0.000      0.963 0.000 1.000
#> SRR1688372     2   0.141      0.956 0.020 0.980
#> SRR1688373     2   0.141      0.956 0.020 0.980
#> SRR1688374     2   0.141      0.956 0.020 0.980
#> SRR1688375     1   0.163      0.885 0.976 0.024
#> SRR1688377     1   0.163      0.885 0.976 0.024
#> SRR1688378     1   0.184      0.885 0.972 0.028
#> SRR1688376     1   0.163      0.885 0.976 0.024
#> SRR1688380     1   0.184      0.885 0.972 0.028
#> SRR1688379     1   0.184      0.885 0.972 0.028
#> SRR1688381     1   0.184      0.885 0.972 0.028
#> SRR1688382     1   0.184      0.885 0.972 0.028
#> SRR1688383     1   0.184      0.885 0.972 0.028
#> SRR1688384     1   0.184      0.885 0.972 0.028
#> SRR1688385     1   0.184      0.885 0.972 0.028
#> SRR1688386     1   0.184      0.885 0.972 0.028
#> SRR1688387     1   0.141      0.884 0.980 0.020
#> SRR1688388     1   0.141      0.884 0.980 0.020
#> SRR1688389     1   0.141      0.884 0.980 0.020
#> SRR1688390     1   0.184      0.885 0.972 0.028
#> SRR1688391     1   0.184      0.885 0.972 0.028
#> SRR1688392     1   0.184      0.885 0.972 0.028
#> SRR1688393     1   0.697      0.872 0.812 0.188
#> SRR1688395     1   0.697      0.872 0.812 0.188
#> SRR1688394     1   0.697      0.872 0.812 0.188
#> SRR1688397     1   0.697      0.872 0.812 0.188
#> SRR1688398     1   0.697      0.872 0.812 0.188
#> SRR1688396     1   0.697      0.872 0.812 0.188
#> SRR1688399     1   0.697      0.872 0.812 0.188
#> SRR1688400     1   0.697      0.872 0.812 0.188
#> SRR1688402     1   0.697      0.872 0.812 0.188
#> SRR1688401     1   0.697      0.872 0.812 0.188
#> SRR1688403     1   0.697      0.872 0.812 0.188
#> SRR1688404     1   0.697      0.872 0.812 0.188
#> SRR1688405     1   0.730      0.864 0.796 0.204
#> SRR1688407     1   0.730      0.864 0.796 0.204
#> SRR1688408     1   0.697      0.872 0.812 0.188
#> SRR1688406     1   0.745      0.862 0.788 0.212
#> SRR1688410     1   0.697      0.872 0.812 0.188
#> SRR1688411     2   0.141      0.956 0.020 0.980
#> SRR1688409     1   0.697      0.872 0.812 0.188
#> SRR1688412     2   0.141      0.956 0.020 0.980
#> SRR1688413     2   0.141      0.956 0.020 0.980
#> SRR1688414     2   0.141      0.956 0.020 0.980
#> SRR1688415     2   0.000      0.963 0.000 1.000
#> SRR1688416     2   0.000      0.963 0.000 1.000
#> SRR1688417     2   0.000      0.963 0.000 1.000
#> SRR1688418     2   0.000      0.963 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2  0.0000      0.860 0.000 1.000 0.000
#> SRR1688358     2  0.0000      0.860 0.000 1.000 0.000
#> SRR1688359     2  0.0000      0.860 0.000 1.000 0.000
#> SRR1688360     2  0.3879      0.863 0.152 0.848 0.000
#> SRR1688361     2  0.3879      0.863 0.152 0.848 0.000
#> SRR1688362     2  0.3879      0.863 0.152 0.848 0.000
#> SRR1688363     1  0.7411     -0.440 0.548 0.416 0.036
#> SRR1688365     1  0.7411     -0.440 0.548 0.416 0.036
#> SRR1688364     1  0.7411     -0.440 0.548 0.416 0.036
#> SRR1688366     2  0.3752      0.864 0.144 0.856 0.000
#> SRR1688367     2  0.3752      0.864 0.144 0.856 0.000
#> SRR1688368     2  0.4178      0.858 0.172 0.828 0.000
#> SRR1688370     2  0.0000      0.860 0.000 1.000 0.000
#> SRR1688369     2  0.0000      0.860 0.000 1.000 0.000
#> SRR1688371     2  0.0000      0.860 0.000 1.000 0.000
#> SRR1688372     2  0.7084      0.768 0.336 0.628 0.036
#> SRR1688373     2  0.7084      0.768 0.336 0.628 0.036
#> SRR1688374     2  0.7084      0.768 0.336 0.628 0.036
#> SRR1688375     1  0.5138      0.839 0.748 0.000 0.252
#> SRR1688377     1  0.5138      0.839 0.748 0.000 0.252
#> SRR1688378     1  0.5254      0.839 0.736 0.000 0.264
#> SRR1688376     1  0.5138      0.839 0.748 0.000 0.252
#> SRR1688380     1  0.5254      0.839 0.736 0.000 0.264
#> SRR1688379     1  0.5254      0.839 0.736 0.000 0.264
#> SRR1688381     1  0.5098      0.838 0.752 0.000 0.248
#> SRR1688382     1  0.5098      0.838 0.752 0.000 0.248
#> SRR1688383     1  0.5098      0.838 0.752 0.000 0.248
#> SRR1688384     1  0.5138      0.839 0.748 0.000 0.252
#> SRR1688385     1  0.5138      0.839 0.748 0.000 0.252
#> SRR1688386     1  0.5138      0.839 0.748 0.000 0.252
#> SRR1688387     1  0.5291      0.838 0.732 0.000 0.268
#> SRR1688388     1  0.5291      0.838 0.732 0.000 0.268
#> SRR1688389     1  0.5291      0.838 0.732 0.000 0.268
#> SRR1688390     1  0.5327      0.836 0.728 0.000 0.272
#> SRR1688391     1  0.5327      0.836 0.728 0.000 0.272
#> SRR1688392     1  0.5327      0.836 0.728 0.000 0.272
#> SRR1688393     3  0.0892      0.946 0.000 0.020 0.980
#> SRR1688395     3  0.0892      0.946 0.000 0.020 0.980
#> SRR1688394     3  0.0892      0.946 0.000 0.020 0.980
#> SRR1688397     3  0.0892      0.946 0.000 0.020 0.980
#> SRR1688398     3  0.0892      0.946 0.000 0.020 0.980
#> SRR1688396     3  0.0892      0.946 0.000 0.020 0.980
#> SRR1688399     3  0.0892      0.946 0.000 0.020 0.980
#> SRR1688400     3  0.0892      0.946 0.000 0.020 0.980
#> SRR1688402     3  0.0892      0.946 0.000 0.020 0.980
#> SRR1688401     3  0.0892      0.946 0.000 0.020 0.980
#> SRR1688403     3  0.0892      0.946 0.000 0.020 0.980
#> SRR1688404     3  0.0892      0.946 0.000 0.020 0.980
#> SRR1688405     3  0.6361      0.657 0.232 0.040 0.728
#> SRR1688407     3  0.6361      0.657 0.232 0.040 0.728
#> SRR1688408     3  0.0892      0.946 0.000 0.020 0.980
#> SRR1688406     3  0.6361      0.657 0.232 0.040 0.728
#> SRR1688410     3  0.0892      0.946 0.000 0.020 0.980
#> SRR1688411     2  0.7084      0.768 0.336 0.628 0.036
#> SRR1688409     3  0.0892      0.946 0.000 0.020 0.980
#> SRR1688412     2  0.7084      0.768 0.336 0.628 0.036
#> SRR1688413     2  0.7084      0.768 0.336 0.628 0.036
#> SRR1688414     2  0.7084      0.768 0.336 0.628 0.036
#> SRR1688415     2  0.0000      0.860 0.000 1.000 0.000
#> SRR1688416     2  0.0000      0.860 0.000 1.000 0.000
#> SRR1688417     2  0.0000      0.860 0.000 1.000 0.000
#> SRR1688418     2  0.0000      0.860 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1688357     2  0.4304     0.9815 0.000 0.716 0.000 0.284
#> SRR1688358     2  0.4304     0.9815 0.000 0.716 0.000 0.284
#> SRR1688359     2  0.4304     0.9815 0.000 0.716 0.000 0.284
#> SRR1688360     4  0.6083     0.0862 0.000 0.360 0.056 0.584
#> SRR1688361     4  0.6083     0.0862 0.000 0.360 0.056 0.584
#> SRR1688362     4  0.6083     0.0862 0.000 0.360 0.056 0.584
#> SRR1688363     4  0.5512     0.5882 0.088 0.108 0.032 0.772
#> SRR1688365     4  0.5512     0.5882 0.088 0.108 0.032 0.772
#> SRR1688364     4  0.5512     0.5882 0.088 0.108 0.032 0.772
#> SRR1688366     4  0.5860     0.0212 0.000 0.380 0.040 0.580
#> SRR1688367     4  0.5860     0.0212 0.000 0.380 0.040 0.580
#> SRR1688368     4  0.5489     0.2863 0.000 0.296 0.040 0.664
#> SRR1688370     2  0.5247     0.9673 0.000 0.684 0.032 0.284
#> SRR1688369     2  0.5247     0.9673 0.000 0.684 0.032 0.284
#> SRR1688371     2  0.5247     0.9673 0.000 0.684 0.032 0.284
#> SRR1688372     4  0.0707     0.6939 0.020 0.000 0.000 0.980
#> SRR1688373     4  0.0707     0.6939 0.020 0.000 0.000 0.980
#> SRR1688374     4  0.0707     0.6939 0.020 0.000 0.000 0.980
#> SRR1688375     1  0.1576     0.9488 0.948 0.048 0.004 0.000
#> SRR1688377     1  0.1576     0.9488 0.948 0.048 0.004 0.000
#> SRR1688378     1  0.1398     0.9504 0.956 0.040 0.004 0.000
#> SRR1688376     1  0.1576     0.9488 0.948 0.048 0.004 0.000
#> SRR1688380     1  0.1398     0.9504 0.956 0.040 0.004 0.000
#> SRR1688379     1  0.1398     0.9504 0.956 0.040 0.004 0.000
#> SRR1688381     1  0.2197     0.9256 0.928 0.048 0.000 0.024
#> SRR1688382     1  0.2197     0.9256 0.928 0.048 0.000 0.024
#> SRR1688383     1  0.2197     0.9256 0.928 0.048 0.000 0.024
#> SRR1688384     1  0.2099     0.9325 0.936 0.040 0.004 0.020
#> SRR1688385     1  0.2099     0.9325 0.936 0.040 0.004 0.020
#> SRR1688386     1  0.2099     0.9325 0.936 0.040 0.004 0.020
#> SRR1688387     1  0.2382     0.9395 0.912 0.080 0.004 0.004
#> SRR1688388     1  0.2382     0.9395 0.912 0.080 0.004 0.004
#> SRR1688389     1  0.2382     0.9395 0.912 0.080 0.004 0.004
#> SRR1688390     1  0.1398     0.9503 0.956 0.040 0.004 0.000
#> SRR1688391     1  0.1398     0.9503 0.956 0.040 0.004 0.000
#> SRR1688392     1  0.1398     0.9503 0.956 0.040 0.004 0.000
#> SRR1688393     3  0.4387     0.8908 0.116 0.048 0.824 0.012
#> SRR1688395     3  0.4387     0.8908 0.116 0.048 0.824 0.012
#> SRR1688394     3  0.4387     0.8908 0.116 0.048 0.824 0.012
#> SRR1688397     3  0.3375     0.8957 0.116 0.012 0.864 0.008
#> SRR1688398     3  0.3375     0.8957 0.116 0.012 0.864 0.008
#> SRR1688396     3  0.3375     0.8957 0.116 0.012 0.864 0.008
#> SRR1688399     3  0.3850     0.8941 0.116 0.044 0.840 0.000
#> SRR1688400     3  0.3850     0.8941 0.116 0.044 0.840 0.000
#> SRR1688402     3  0.3494     0.8951 0.116 0.016 0.860 0.008
#> SRR1688401     3  0.3850     0.8941 0.116 0.044 0.840 0.000
#> SRR1688403     3  0.3494     0.8951 0.116 0.016 0.860 0.008
#> SRR1688404     3  0.3494     0.8951 0.116 0.016 0.860 0.008
#> SRR1688405     3  0.8715     0.4579 0.132 0.088 0.444 0.336
#> SRR1688407     3  0.8715     0.4579 0.132 0.088 0.444 0.336
#> SRR1688408     3  0.3375     0.8965 0.116 0.012 0.864 0.008
#> SRR1688406     3  0.8715     0.4579 0.132 0.088 0.444 0.336
#> SRR1688410     3  0.3375     0.8965 0.116 0.012 0.864 0.008
#> SRR1688411     4  0.0707     0.6939 0.020 0.000 0.000 0.980
#> SRR1688409     3  0.3375     0.8965 0.116 0.012 0.864 0.008
#> SRR1688412     4  0.0707     0.6939 0.020 0.000 0.000 0.980
#> SRR1688413     4  0.0707     0.6939 0.020 0.000 0.000 0.980
#> SRR1688414     4  0.0707     0.6939 0.020 0.000 0.000 0.980
#> SRR1688415     2  0.4744     0.9799 0.000 0.704 0.012 0.284
#> SRR1688416     2  0.4744     0.9799 0.000 0.704 0.012 0.284
#> SRR1688417     2  0.4744     0.9799 0.000 0.704 0.012 0.284
#> SRR1688418     2  0.4621     0.9805 0.000 0.708 0.008 0.284

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1688357     2  0.0579      0.775 0.008 0.984 0.000 0.000 0.008
#> SRR1688358     2  0.0579      0.775 0.008 0.984 0.000 0.000 0.008
#> SRR1688359     2  0.0290      0.775 0.008 0.992 0.000 0.000 0.000
#> SRR1688360     2  0.6319      0.471 0.000 0.528 0.000 0.256 0.216
#> SRR1688361     2  0.6319      0.471 0.000 0.528 0.000 0.256 0.216
#> SRR1688362     2  0.6319      0.471 0.000 0.528 0.000 0.256 0.216
#> SRR1688363     4  0.5600      0.694 0.052 0.064 0.000 0.692 0.192
#> SRR1688365     4  0.5600      0.694 0.052 0.064 0.000 0.692 0.192
#> SRR1688364     4  0.5600      0.694 0.052 0.064 0.000 0.692 0.192
#> SRR1688366     2  0.6103      0.502 0.012 0.592 0.000 0.264 0.132
#> SRR1688367     2  0.6103      0.502 0.012 0.592 0.000 0.264 0.132
#> SRR1688368     2  0.6333      0.389 0.012 0.536 0.000 0.320 0.132
#> SRR1688370     2  0.2341      0.762 0.020 0.912 0.000 0.012 0.056
#> SRR1688369     2  0.2341      0.762 0.020 0.912 0.000 0.012 0.056
#> SRR1688371     2  0.2341      0.762 0.020 0.912 0.000 0.012 0.056
#> SRR1688372     4  0.3388      0.860 0.008 0.200 0.000 0.792 0.000
#> SRR1688373     4  0.3388      0.860 0.008 0.200 0.000 0.792 0.000
#> SRR1688374     4  0.3388      0.860 0.008 0.200 0.000 0.792 0.000
#> SRR1688375     1  0.4774      0.883 0.744 0.000 0.056 0.020 0.180
#> SRR1688377     1  0.4774      0.883 0.744 0.000 0.056 0.020 0.180
#> SRR1688378     1  0.3748      0.890 0.836 0.000 0.056 0.020 0.088
#> SRR1688376     1  0.4774      0.883 0.744 0.000 0.056 0.020 0.180
#> SRR1688380     1  0.3748      0.890 0.836 0.000 0.056 0.020 0.088
#> SRR1688379     1  0.3748      0.890 0.836 0.000 0.056 0.020 0.088
#> SRR1688381     1  0.4218      0.883 0.812 0.000 0.056 0.040 0.092
#> SRR1688382     1  0.4218      0.883 0.812 0.000 0.056 0.040 0.092
#> SRR1688383     1  0.4218      0.883 0.812 0.000 0.056 0.040 0.092
#> SRR1688384     1  0.4062      0.884 0.820 0.000 0.056 0.032 0.092
#> SRR1688385     1  0.4062      0.884 0.820 0.000 0.056 0.032 0.092
#> SRR1688386     1  0.4062      0.884 0.820 0.000 0.056 0.032 0.092
#> SRR1688387     1  0.4303      0.859 0.752 0.000 0.056 0.000 0.192
#> SRR1688388     1  0.4303      0.859 0.752 0.000 0.056 0.000 0.192
#> SRR1688389     1  0.4303      0.859 0.752 0.000 0.056 0.000 0.192
#> SRR1688390     1  0.3018      0.889 0.872 0.000 0.056 0.004 0.068
#> SRR1688391     1  0.3018      0.889 0.872 0.000 0.056 0.004 0.068
#> SRR1688392     1  0.3018      0.889 0.872 0.000 0.056 0.004 0.068
#> SRR1688393     3  0.3307      0.834 0.000 0.000 0.844 0.052 0.104
#> SRR1688395     3  0.3307      0.834 0.000 0.000 0.844 0.052 0.104
#> SRR1688394     3  0.3307      0.834 0.000 0.000 0.844 0.052 0.104
#> SRR1688397     3  0.1331      0.847 0.000 0.000 0.952 0.008 0.040
#> SRR1688398     3  0.1331      0.847 0.000 0.000 0.952 0.008 0.040
#> SRR1688396     3  0.1331      0.847 0.000 0.000 0.952 0.008 0.040
#> SRR1688399     3  0.3012      0.838 0.000 0.000 0.860 0.036 0.104
#> SRR1688400     3  0.3012      0.838 0.000 0.000 0.860 0.036 0.104
#> SRR1688402     3  0.1251      0.847 0.000 0.000 0.956 0.008 0.036
#> SRR1688401     3  0.3012      0.838 0.000 0.000 0.860 0.036 0.104
#> SRR1688403     3  0.1251      0.847 0.000 0.000 0.956 0.008 0.036
#> SRR1688404     3  0.1251      0.847 0.000 0.000 0.956 0.008 0.036
#> SRR1688405     3  0.7357      0.275 0.036 0.000 0.376 0.376 0.212
#> SRR1688407     3  0.7357      0.275 0.036 0.000 0.376 0.376 0.212
#> SRR1688408     3  0.1502      0.847 0.000 0.000 0.940 0.004 0.056
#> SRR1688406     3  0.7357      0.275 0.036 0.000 0.376 0.376 0.212
#> SRR1688410     3  0.1502      0.847 0.000 0.000 0.940 0.004 0.056
#> SRR1688411     4  0.3388      0.860 0.008 0.200 0.000 0.792 0.000
#> SRR1688409     3  0.1502      0.847 0.000 0.000 0.940 0.004 0.056
#> SRR1688412     4  0.3388      0.860 0.008 0.200 0.000 0.792 0.000
#> SRR1688413     4  0.3388      0.860 0.008 0.200 0.000 0.792 0.000
#> SRR1688414     4  0.3388      0.860 0.008 0.200 0.000 0.792 0.000
#> SRR1688415     2  0.0451      0.775 0.004 0.988 0.000 0.000 0.008
#> SRR1688416     2  0.0451      0.775 0.004 0.988 0.000 0.000 0.008
#> SRR1688417     2  0.0451      0.775 0.004 0.988 0.000 0.000 0.008
#> SRR1688418     2  0.0451      0.775 0.004 0.988 0.000 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1688357     2  0.0551      0.748 0.000 0.984 0.008 0.000 0.004 0.004
#> SRR1688358     2  0.0551      0.748 0.000 0.984 0.008 0.000 0.004 0.004
#> SRR1688359     2  0.0405      0.748 0.000 0.988 0.008 0.000 0.000 0.004
#> SRR1688360     2  0.5973      0.431 0.000 0.448 0.000 0.272 0.000 0.280
#> SRR1688361     2  0.5973      0.431 0.000 0.448 0.000 0.272 0.000 0.280
#> SRR1688362     2  0.5973      0.431 0.000 0.448 0.000 0.272 0.000 0.280
#> SRR1688363     4  0.6014      0.563 0.060 0.028 0.000 0.644 0.092 0.176
#> SRR1688365     4  0.6014      0.563 0.060 0.028 0.000 0.644 0.092 0.176
#> SRR1688364     4  0.6014      0.563 0.060 0.028 0.000 0.644 0.092 0.176
#> SRR1688366     2  0.6214      0.466 0.000 0.492 0.004 0.260 0.012 0.232
#> SRR1688367     2  0.6214      0.466 0.000 0.492 0.004 0.260 0.012 0.232
#> SRR1688368     2  0.6401      0.316 0.000 0.408 0.004 0.344 0.012 0.232
#> SRR1688370     2  0.1745      0.738 0.000 0.924 0.000 0.000 0.056 0.020
#> SRR1688369     2  0.1745      0.738 0.000 0.924 0.000 0.000 0.056 0.020
#> SRR1688371     2  0.1745      0.738 0.000 0.924 0.000 0.000 0.056 0.020
#> SRR1688372     4  0.2750      0.650 0.000 0.136 0.000 0.844 0.000 0.020
#> SRR1688373     4  0.2750      0.650 0.000 0.136 0.000 0.844 0.000 0.020
#> SRR1688374     4  0.2750      0.650 0.000 0.136 0.000 0.844 0.000 0.020
#> SRR1688375     1  0.4714      0.801 0.664 0.000 0.000 0.016 0.268 0.052
#> SRR1688377     1  0.4714      0.801 0.664 0.000 0.000 0.016 0.268 0.052
#> SRR1688378     1  0.4907      0.807 0.668 0.000 0.000 0.012 0.228 0.092
#> SRR1688376     1  0.4714      0.801 0.664 0.000 0.000 0.016 0.268 0.052
#> SRR1688380     1  0.4907      0.807 0.668 0.000 0.000 0.012 0.228 0.092
#> SRR1688379     1  0.4907      0.807 0.668 0.000 0.000 0.012 0.228 0.092
#> SRR1688381     1  0.1262      0.792 0.956 0.000 0.000 0.020 0.008 0.016
#> SRR1688382     1  0.1262      0.792 0.956 0.000 0.000 0.020 0.008 0.016
#> SRR1688383     1  0.1262      0.792 0.956 0.000 0.000 0.020 0.008 0.016
#> SRR1688384     1  0.0820      0.798 0.972 0.000 0.000 0.016 0.012 0.000
#> SRR1688385     1  0.0820      0.798 0.972 0.000 0.000 0.016 0.012 0.000
#> SRR1688386     1  0.0820      0.798 0.972 0.000 0.000 0.016 0.012 0.000
#> SRR1688387     1  0.3989      0.761 0.528 0.000 0.000 0.000 0.468 0.004
#> SRR1688388     1  0.3989      0.761 0.528 0.000 0.000 0.000 0.468 0.004
#> SRR1688389     1  0.3989      0.761 0.528 0.000 0.000 0.000 0.468 0.004
#> SRR1688390     1  0.4271      0.806 0.712 0.000 0.000 0.008 0.232 0.048
#> SRR1688391     1  0.4271      0.806 0.712 0.000 0.000 0.008 0.232 0.048
#> SRR1688392     1  0.4271      0.806 0.712 0.000 0.000 0.008 0.232 0.048
#> SRR1688393     3  0.4251      0.832 0.016 0.000 0.788 0.024 0.104 0.068
#> SRR1688395     3  0.4251      0.832 0.016 0.000 0.788 0.024 0.104 0.068
#> SRR1688394     3  0.4251      0.832 0.016 0.000 0.788 0.024 0.104 0.068
#> SRR1688397     3  0.2220      0.857 0.016 0.000 0.908 0.004 0.012 0.060
#> SRR1688398     3  0.2220      0.857 0.016 0.000 0.908 0.004 0.012 0.060
#> SRR1688396     3  0.2220      0.857 0.016 0.000 0.908 0.004 0.012 0.060
#> SRR1688399     3  0.4431      0.832 0.016 0.000 0.772 0.020 0.092 0.100
#> SRR1688400     3  0.4431      0.832 0.016 0.000 0.772 0.020 0.092 0.100
#> SRR1688402     3  0.3149      0.842 0.016 0.000 0.836 0.000 0.024 0.124
#> SRR1688401     3  0.4431      0.832 0.016 0.000 0.772 0.020 0.092 0.100
#> SRR1688403     3  0.3149      0.842 0.016 0.000 0.836 0.000 0.024 0.124
#> SRR1688404     3  0.3149      0.842 0.016 0.000 0.836 0.000 0.024 0.124
#> SRR1688405     4  0.8527      0.112 0.092 0.000 0.236 0.304 0.240 0.128
#> SRR1688407     4  0.8527      0.112 0.092 0.000 0.236 0.304 0.240 0.128
#> SRR1688408     3  0.3107      0.847 0.016 0.000 0.832 0.000 0.016 0.136
#> SRR1688406     4  0.8527      0.112 0.092 0.000 0.236 0.304 0.240 0.128
#> SRR1688410     3  0.3107      0.847 0.016 0.000 0.832 0.000 0.016 0.136
#> SRR1688411     4  0.2219      0.653 0.000 0.136 0.000 0.864 0.000 0.000
#> SRR1688409     3  0.3107      0.847 0.016 0.000 0.832 0.000 0.016 0.136
#> SRR1688412     4  0.2219      0.653 0.000 0.136 0.000 0.864 0.000 0.000
#> SRR1688413     4  0.2219      0.653 0.000 0.136 0.000 0.864 0.000 0.000
#> SRR1688414     4  0.2219      0.653 0.000 0.136 0.000 0.864 0.000 0.000
#> SRR1688415     2  0.1218      0.746 0.000 0.956 0.004 0.000 0.028 0.012
#> SRR1688416     2  0.1218      0.746 0.000 0.956 0.004 0.000 0.028 0.012
#> SRR1688417     2  0.1218      0.746 0.000 0.956 0.004 0.000 0.028 0.012
#> SRR1688418     2  0.1036      0.747 0.000 0.964 0.004 0.000 0.024 0.008

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 16435 rows and 62 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.4955 0.505   0.505
#> 3 3 1.000           0.998       0.999         0.3458 0.829   0.661
#> 4 4 1.000           0.993       0.992         0.1240 0.915   0.746
#> 5 5 0.974           0.966       0.964         0.0301 0.976   0.904
#> 6 6 0.967           0.962       0.960         0.0277 0.989   0.951

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
#> SRR1688357     2       0          1  0  1
#> SRR1688358     2       0          1  0  1
#> SRR1688359     2       0          1  0  1
#> SRR1688360     2       0          1  0  1
#> SRR1688361     2       0          1  0  1
#> SRR1688362     2       0          1  0  1
#> SRR1688363     2       0          1  0  1
#> SRR1688365     2       0          1  0  1
#> SRR1688364     2       0          1  0  1
#> SRR1688366     2       0          1  0  1
#> SRR1688367     2       0          1  0  1
#> SRR1688368     2       0          1  0  1
#> SRR1688370     2       0          1  0  1
#> SRR1688369     2       0          1  0  1
#> SRR1688371     2       0          1  0  1
#> SRR1688372     2       0          1  0  1
#> SRR1688373     2       0          1  0  1
#> SRR1688374     2       0          1  0  1
#> SRR1688375     1       0          1  1  0
#> SRR1688377     1       0          1  1  0
#> SRR1688378     1       0          1  1  0
#> SRR1688376     1       0          1  1  0
#> SRR1688380     1       0          1  1  0
#> SRR1688379     1       0          1  1  0
#> SRR1688381     1       0          1  1  0
#> SRR1688382     1       0          1  1  0
#> SRR1688383     1       0          1  1  0
#> SRR1688384     1       0          1  1  0
#> SRR1688385     1       0          1  1  0
#> SRR1688386     1       0          1  1  0
#> SRR1688387     1       0          1  1  0
#> SRR1688388     1       0          1  1  0
#> SRR1688389     1       0          1  1  0
#> SRR1688390     1       0          1  1  0
#> SRR1688391     1       0          1  1  0
#> SRR1688392     1       0          1  1  0
#> SRR1688393     1       0          1  1  0
#> SRR1688395     1       0          1  1  0
#> SRR1688394     1       0          1  1  0
#> SRR1688397     1       0          1  1  0
#> SRR1688398     1       0          1  1  0
#> SRR1688396     1       0          1  1  0
#> SRR1688399     1       0          1  1  0
#> SRR1688400     1       0          1  1  0
#> SRR1688402     1       0          1  1  0
#> SRR1688401     1       0          1  1  0
#> SRR1688403     1       0          1  1  0
#> SRR1688404     1       0          1  1  0
#> SRR1688405     1       0          1  1  0
#> SRR1688407     1       0          1  1  0
#> SRR1688408     1       0          1  1  0
#> SRR1688406     1       0          1  1  0
#> SRR1688410     1       0          1  1  0
#> SRR1688411     2       0          1  0  1
#> SRR1688409     1       0          1  1  0
#> SRR1688412     2       0          1  0  1
#> SRR1688413     2       0          1  0  1
#> SRR1688414     2       0          1  0  1
#> SRR1688415     2       0          1  0  1
#> SRR1688416     2       0          1  0  1
#> SRR1688417     2       0          1  0  1
#> SRR1688418     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette   p1   p2 p3
#> SRR1688357     2  0.0000      0.998 0.00 1.00  0
#> SRR1688358     2  0.0000      0.998 0.00 1.00  0
#> SRR1688359     2  0.0000      0.998 0.00 1.00  0
#> SRR1688360     2  0.0000      0.998 0.00 1.00  0
#> SRR1688361     2  0.0000      0.998 0.00 1.00  0
#> SRR1688362     2  0.0000      0.998 0.00 1.00  0
#> SRR1688363     2  0.0892      0.981 0.02 0.98  0
#> SRR1688365     2  0.0892      0.981 0.02 0.98  0
#> SRR1688364     2  0.0892      0.981 0.02 0.98  0
#> SRR1688366     2  0.0000      0.998 0.00 1.00  0
#> SRR1688367     2  0.0000      0.998 0.00 1.00  0
#> SRR1688368     2  0.0000      0.998 0.00 1.00  0
#> SRR1688370     2  0.0000      0.998 0.00 1.00  0
#> SRR1688369     2  0.0000      0.998 0.00 1.00  0
#> SRR1688371     2  0.0000      0.998 0.00 1.00  0
#> SRR1688372     2  0.0000      0.998 0.00 1.00  0
#> SRR1688373     2  0.0000      0.998 0.00 1.00  0
#> SRR1688374     2  0.0000      0.998 0.00 1.00  0
#> SRR1688375     1  0.0000      1.000 1.00 0.00  0
#> SRR1688377     1  0.0000      1.000 1.00 0.00  0
#> SRR1688378     1  0.0000      1.000 1.00 0.00  0
#> SRR1688376     1  0.0000      1.000 1.00 0.00  0
#> SRR1688380     1  0.0000      1.000 1.00 0.00  0
#> SRR1688379     1  0.0000      1.000 1.00 0.00  0
#> SRR1688381     1  0.0000      1.000 1.00 0.00  0
#> SRR1688382     1  0.0000      1.000 1.00 0.00  0
#> SRR1688383     1  0.0000      1.000 1.00 0.00  0
#> SRR1688384     1  0.0000      1.000 1.00 0.00  0
#> SRR1688385     1  0.0000      1.000 1.00 0.00  0
#> SRR1688386     1  0.0000      1.000 1.00 0.00  0
#> SRR1688387     1  0.0000      1.000 1.00 0.00  0
#> SRR1688388     1  0.0000      1.000 1.00 0.00  0
#> SRR1688389     1  0.0000      1.000 1.00 0.00  0
#> SRR1688390     1  0.0000      1.000 1.00 0.00  0
#> SRR1688391     1  0.0000      1.000 1.00 0.00  0
#> SRR1688392     1  0.0000      1.000 1.00 0.00  0
#> SRR1688393     3  0.0000      1.000 0.00 0.00  1
#> SRR1688395     3  0.0000      1.000 0.00 0.00  1
#> SRR1688394     3  0.0000      1.000 0.00 0.00  1
#> SRR1688397     3  0.0000      1.000 0.00 0.00  1
#> SRR1688398     3  0.0000      1.000 0.00 0.00  1
#> SRR1688396     3  0.0000      1.000 0.00 0.00  1
#> SRR1688399     3  0.0000      1.000 0.00 0.00  1
#> SRR1688400     3  0.0000      1.000 0.00 0.00  1
#> SRR1688402     3  0.0000      1.000 0.00 0.00  1
#> SRR1688401     3  0.0000      1.000 0.00 0.00  1
#> SRR1688403     3  0.0000      1.000 0.00 0.00  1
#> SRR1688404     3  0.0000      1.000 0.00 0.00  1
#> SRR1688405     3  0.0000      1.000 0.00 0.00  1
#> SRR1688407     3  0.0000      1.000 0.00 0.00  1
#> SRR1688408     3  0.0000      1.000 0.00 0.00  1
#> SRR1688406     3  0.0000      1.000 0.00 0.00  1
#> SRR1688410     3  0.0000      1.000 0.00 0.00  1
#> SRR1688411     2  0.0000      0.998 0.00 1.00  0
#> SRR1688409     3  0.0000      1.000 0.00 0.00  1
#> SRR1688412     2  0.0000      0.998 0.00 1.00  0
#> SRR1688413     2  0.0000      0.998 0.00 1.00  0
#> SRR1688414     2  0.0000      0.998 0.00 1.00  0
#> SRR1688415     2  0.0000      0.998 0.00 1.00  0
#> SRR1688416     2  0.0000      0.998 0.00 1.00  0
#> SRR1688417     2  0.0000      0.998 0.00 1.00  0
#> SRR1688418     2  0.0000      0.998 0.00 1.00  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2    p3    p4
#> SRR1688357     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1688358     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1688359     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1688360     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1688361     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1688362     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1688363     4  0.0336      0.967  0 0.008 0.000 0.992
#> SRR1688365     4  0.0336      0.967  0 0.008 0.000 0.992
#> SRR1688364     4  0.0336      0.967  0 0.008 0.000 0.992
#> SRR1688366     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1688367     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1688368     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1688370     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1688369     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1688371     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1688372     4  0.1389      0.985  0 0.048 0.000 0.952
#> SRR1688373     4  0.1389      0.985  0 0.048 0.000 0.952
#> SRR1688374     4  0.1389      0.985  0 0.048 0.000 0.952
#> SRR1688375     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688377     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688378     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688376     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688380     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688379     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688381     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688382     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688383     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688384     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688385     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688386     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688387     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688388     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688389     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688390     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688391     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688392     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1688393     3  0.0000      0.993  0 0.000 1.000 0.000
#> SRR1688395     3  0.0000      0.993  0 0.000 1.000 0.000
#> SRR1688394     3  0.0000      0.993  0 0.000 1.000 0.000
#> SRR1688397     3  0.0000      0.993  0 0.000 1.000 0.000
#> SRR1688398     3  0.0000      0.993  0 0.000 1.000 0.000
#> SRR1688396     3  0.0000      0.993  0 0.000 1.000 0.000
#> SRR1688399     3  0.0000      0.993  0 0.000 1.000 0.000
#> SRR1688400     3  0.0000      0.993  0 0.000 1.000 0.000
#> SRR1688402     3  0.0000      0.993  0 0.000 1.000 0.000
#> SRR1688401     3  0.0000      0.993  0 0.000 1.000 0.000
#> SRR1688403     3  0.0000      0.993  0 0.000 1.000 0.000
#> SRR1688404     3  0.0000      0.993  0 0.000 1.000 0.000
#> SRR1688405     3  0.1302      0.966  0 0.000 0.956 0.044
#> SRR1688407     3  0.1302      0.966  0 0.000 0.956 0.044
#> SRR1688408     3  0.0000      0.993  0 0.000 1.000 0.000
#> SRR1688406     3  0.1302      0.966  0 0.000 0.956 0.044
#> SRR1688410     3  0.0000      0.993  0 0.000 1.000 0.000
#> SRR1688411     4  0.1389      0.985  0 0.048 0.000 0.952
#> SRR1688409     3  0.0000      0.993  0 0.000 1.000 0.000
#> SRR1688412     4  0.1389      0.985  0 0.048 0.000 0.952
#> SRR1688413     4  0.1389      0.985  0 0.048 0.000 0.952
#> SRR1688414     4  0.1389      0.985  0 0.048 0.000 0.952
#> SRR1688415     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1688416     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1688417     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1688418     2  0.0000      1.000  0 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1688357     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1688360     2  0.0162      0.997 0.000 0.996 0.000 0.000 0.004
#> SRR1688361     2  0.0162      0.997 0.000 0.996 0.000 0.000 0.004
#> SRR1688362     2  0.0162      0.997 0.000 0.996 0.000 0.000 0.004
#> SRR1688363     4  0.4161      0.643 0.000 0.000 0.000 0.608 0.392
#> SRR1688365     4  0.4161      0.643 0.000 0.000 0.000 0.608 0.392
#> SRR1688364     4  0.4161      0.643 0.000 0.000 0.000 0.608 0.392
#> SRR1688366     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1688367     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1688368     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1688370     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1688372     4  0.0609      0.873 0.000 0.020 0.000 0.980 0.000
#> SRR1688373     4  0.0609      0.873 0.000 0.020 0.000 0.980 0.000
#> SRR1688374     4  0.0609      0.873 0.000 0.020 0.000 0.980 0.000
#> SRR1688375     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688377     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688378     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688376     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688380     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688381     1  0.0671      0.987 0.980 0.000 0.000 0.004 0.016
#> SRR1688382     1  0.0671      0.987 0.980 0.000 0.000 0.004 0.016
#> SRR1688383     1  0.0671      0.987 0.980 0.000 0.000 0.004 0.016
#> SRR1688384     1  0.0566      0.989 0.984 0.000 0.000 0.004 0.012
#> SRR1688385     1  0.0566      0.989 0.984 0.000 0.000 0.004 0.012
#> SRR1688386     1  0.0566      0.989 0.984 0.000 0.000 0.004 0.012
#> SRR1688387     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688388     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688389     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688390     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688405     5  0.3612      1.000 0.000 0.000 0.268 0.000 0.732
#> SRR1688407     5  0.3612      1.000 0.000 0.000 0.268 0.000 0.732
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688406     5  0.3612      1.000 0.000 0.000 0.268 0.000 0.732
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688411     4  0.0609      0.873 0.000 0.020 0.000 0.980 0.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688412     4  0.0609      0.873 0.000 0.020 0.000 0.980 0.000
#> SRR1688413     4  0.0609      0.873 0.000 0.020 0.000 0.980 0.000
#> SRR1688414     4  0.0609      0.873 0.000 0.020 0.000 0.980 0.000
#> SRR1688415     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1688357     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688360     2  0.0692      0.983 0.000 0.976 0.000 0.000 0.020 0.004
#> SRR1688361     2  0.0692      0.983 0.000 0.976 0.000 0.000 0.020 0.004
#> SRR1688362     2  0.0692      0.983 0.000 0.976 0.000 0.000 0.020 0.004
#> SRR1688363     5  0.2692      1.000 0.000 0.000 0.000 0.148 0.840 0.012
#> SRR1688365     5  0.2692      1.000 0.000 0.000 0.000 0.148 0.840 0.012
#> SRR1688364     5  0.2692      1.000 0.000 0.000 0.000 0.148 0.840 0.012
#> SRR1688366     2  0.0260      0.992 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR1688367     2  0.0260      0.992 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR1688368     2  0.0260      0.992 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR1688370     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688372     4  0.0260      1.000 0.000 0.008 0.000 0.992 0.000 0.000
#> SRR1688373     4  0.0260      1.000 0.000 0.008 0.000 0.992 0.000 0.000
#> SRR1688374     4  0.0260      1.000 0.000 0.008 0.000 0.992 0.000 0.000
#> SRR1688375     1  0.1049      0.904 0.960 0.000 0.000 0.000 0.032 0.008
#> SRR1688377     1  0.1049      0.904 0.960 0.000 0.000 0.000 0.032 0.008
#> SRR1688378     1  0.0508      0.906 0.984 0.000 0.000 0.004 0.012 0.000
#> SRR1688376     1  0.1049      0.904 0.960 0.000 0.000 0.000 0.032 0.008
#> SRR1688380     1  0.0508      0.906 0.984 0.000 0.000 0.004 0.012 0.000
#> SRR1688379     1  0.0508      0.906 0.984 0.000 0.000 0.004 0.012 0.000
#> SRR1688381     1  0.3782      0.837 0.788 0.000 0.000 0.008 0.140 0.064
#> SRR1688382     1  0.3782      0.837 0.788 0.000 0.000 0.008 0.140 0.064
#> SRR1688383     1  0.3782      0.837 0.788 0.000 0.000 0.008 0.140 0.064
#> SRR1688384     1  0.3837      0.835 0.784 0.000 0.000 0.008 0.140 0.068
#> SRR1688385     1  0.3837      0.835 0.784 0.000 0.000 0.008 0.140 0.068
#> SRR1688386     1  0.3837      0.835 0.784 0.000 0.000 0.008 0.140 0.068
#> SRR1688387     1  0.1297      0.896 0.948 0.000 0.000 0.000 0.040 0.012
#> SRR1688388     1  0.1297      0.896 0.948 0.000 0.000 0.000 0.040 0.012
#> SRR1688389     1  0.1297      0.896 0.948 0.000 0.000 0.000 0.040 0.012
#> SRR1688390     1  0.0891      0.901 0.968 0.000 0.000 0.000 0.024 0.008
#> SRR1688391     1  0.0891      0.901 0.968 0.000 0.000 0.000 0.024 0.008
#> SRR1688392     1  0.0891      0.901 0.968 0.000 0.000 0.000 0.024 0.008
#> SRR1688393     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688395     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688394     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688397     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688398     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688396     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688399     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688400     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688402     3  0.0260      0.995 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1688401     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688403     3  0.0260      0.995 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1688404     3  0.0260      0.995 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1688405     6  0.0865      1.000 0.000 0.000 0.036 0.000 0.000 0.964
#> SRR1688407     6  0.0865      1.000 0.000 0.000 0.036 0.000 0.000 0.964
#> SRR1688408     3  0.0260      0.995 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1688406     6  0.0865      1.000 0.000 0.000 0.036 0.000 0.000 0.964
#> SRR1688410     3  0.0260      0.995 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1688411     4  0.0260      1.000 0.000 0.008 0.000 0.992 0.000 0.000
#> SRR1688409     3  0.0260      0.995 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1688412     4  0.0260      1.000 0.000 0.008 0.000 0.992 0.000 0.000
#> SRR1688413     4  0.0260      1.000 0.000 0.008 0.000 0.992 0.000 0.000
#> SRR1688414     4  0.0260      1.000 0.000 0.008 0.000 0.992 0.000 0.000
#> SRR1688415     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-skmeans-collect-classes

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 16435 rows and 62 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           0.969       0.988         0.4633 0.535   0.535
#> 3 3 1.000           0.976       0.992         0.4309 0.777   0.594
#> 4 4 1.000           0.985       0.994         0.1327 0.874   0.647
#> 5 5 0.922           0.914       0.920         0.0417 0.986   0.943
#> 6 6 0.902           0.926       0.932         0.0422 0.943   0.757

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
#> SRR1688357     2  0.0000      0.977 0.000 1.000
#> SRR1688358     2  0.0000      0.977 0.000 1.000
#> SRR1688359     2  0.0000      0.977 0.000 1.000
#> SRR1688360     2  0.0000      0.977 0.000 1.000
#> SRR1688361     2  0.0000      0.977 0.000 1.000
#> SRR1688362     2  0.0000      0.977 0.000 1.000
#> SRR1688363     1  0.3274      0.938 0.940 0.060
#> SRR1688365     1  0.3274      0.938 0.940 0.060
#> SRR1688364     1  0.3274      0.938 0.940 0.060
#> SRR1688366     2  0.0000      0.977 0.000 1.000
#> SRR1688367     2  0.0000      0.977 0.000 1.000
#> SRR1688368     2  0.0000      0.977 0.000 1.000
#> SRR1688370     2  0.0000      0.977 0.000 1.000
#> SRR1688369     2  0.0000      0.977 0.000 1.000
#> SRR1688371     2  0.0000      0.977 0.000 1.000
#> SRR1688372     2  0.0000      0.977 0.000 1.000
#> SRR1688373     2  0.0000      0.977 0.000 1.000
#> SRR1688374     1  0.4690      0.893 0.900 0.100
#> SRR1688375     1  0.0000      0.993 1.000 0.000
#> SRR1688377     1  0.0000      0.993 1.000 0.000
#> SRR1688378     1  0.0000      0.993 1.000 0.000
#> SRR1688376     1  0.0000      0.993 1.000 0.000
#> SRR1688380     1  0.0000      0.993 1.000 0.000
#> SRR1688379     1  0.0000      0.993 1.000 0.000
#> SRR1688381     1  0.0000      0.993 1.000 0.000
#> SRR1688382     1  0.0000      0.993 1.000 0.000
#> SRR1688383     1  0.0000      0.993 1.000 0.000
#> SRR1688384     1  0.0000      0.993 1.000 0.000
#> SRR1688385     1  0.0000      0.993 1.000 0.000
#> SRR1688386     1  0.0000      0.993 1.000 0.000
#> SRR1688387     1  0.0000      0.993 1.000 0.000
#> SRR1688388     1  0.0000      0.993 1.000 0.000
#> SRR1688389     1  0.0000      0.993 1.000 0.000
#> SRR1688390     1  0.0000      0.993 1.000 0.000
#> SRR1688391     1  0.0000      0.993 1.000 0.000
#> SRR1688392     1  0.0000      0.993 1.000 0.000
#> SRR1688393     1  0.0000      0.993 1.000 0.000
#> SRR1688395     1  0.0000      0.993 1.000 0.000
#> SRR1688394     1  0.0000      0.993 1.000 0.000
#> SRR1688397     1  0.0000      0.993 1.000 0.000
#> SRR1688398     1  0.0000      0.993 1.000 0.000
#> SRR1688396     1  0.0000      0.993 1.000 0.000
#> SRR1688399     1  0.0000      0.993 1.000 0.000
#> SRR1688400     1  0.0000      0.993 1.000 0.000
#> SRR1688402     1  0.0000      0.993 1.000 0.000
#> SRR1688401     1  0.0000      0.993 1.000 0.000
#> SRR1688403     1  0.0000      0.993 1.000 0.000
#> SRR1688404     1  0.0000      0.993 1.000 0.000
#> SRR1688405     1  0.0000      0.993 1.000 0.000
#> SRR1688407     1  0.0000      0.993 1.000 0.000
#> SRR1688408     1  0.0000      0.993 1.000 0.000
#> SRR1688406     1  0.0000      0.993 1.000 0.000
#> SRR1688410     1  0.0000      0.993 1.000 0.000
#> SRR1688411     2  0.0672      0.970 0.008 0.992
#> SRR1688409     1  0.0000      0.993 1.000 0.000
#> SRR1688412     2  0.0000      0.977 0.000 1.000
#> SRR1688413     2  0.0000      0.977 0.000 1.000
#> SRR1688414     2  0.9963      0.112 0.464 0.536
#> SRR1688415     2  0.0000      0.977 0.000 1.000
#> SRR1688416     2  0.0000      0.977 0.000 1.000
#> SRR1688417     2  0.0000      0.977 0.000 1.000
#> SRR1688418     2  0.0000      0.977 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2 p3
#> SRR1688357     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688358     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688359     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688360     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688361     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688362     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688363     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688365     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688364     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688366     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688367     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688368     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688370     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688369     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688371     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688372     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688373     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688374     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688375     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688377     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688378     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688376     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688380     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688379     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688381     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688382     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688383     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688384     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688385     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688386     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688387     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688388     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688389     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688390     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688391     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688392     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688393     3  0.0000     1.0000 0.000 0.000  1
#> SRR1688395     3  0.0000     1.0000 0.000 0.000  1
#> SRR1688394     3  0.0000     1.0000 0.000 0.000  1
#> SRR1688397     3  0.0000     1.0000 0.000 0.000  1
#> SRR1688398     3  0.0000     1.0000 0.000 0.000  1
#> SRR1688396     3  0.0000     1.0000 0.000 0.000  1
#> SRR1688399     3  0.0000     1.0000 0.000 0.000  1
#> SRR1688400     3  0.0000     1.0000 0.000 0.000  1
#> SRR1688402     3  0.0000     1.0000 0.000 0.000  1
#> SRR1688401     3  0.0000     1.0000 0.000 0.000  1
#> SRR1688403     3  0.0000     1.0000 0.000 0.000  1
#> SRR1688404     3  0.0000     1.0000 0.000 0.000  1
#> SRR1688405     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688407     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688408     3  0.0000     1.0000 0.000 0.000  1
#> SRR1688406     1  0.0000     0.9793 1.000 0.000  0
#> SRR1688410     3  0.0000     1.0000 0.000 0.000  1
#> SRR1688411     2  0.0424     0.9908 0.008 0.992  0
#> SRR1688409     3  0.0000     1.0000 0.000 0.000  1
#> SRR1688412     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688413     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688414     1  0.6302     0.0757 0.520 0.480  0
#> SRR1688415     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688416     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688417     2  0.0000     0.9995 0.000 1.000  0
#> SRR1688418     2  0.0000     0.9995 0.000 1.000  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1688357     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1688358     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1688359     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1688360     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1688361     2  0.4522      0.535 0.000 0.680 0.000 0.320
#> SRR1688362     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688363     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688365     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688364     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688366     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1688367     2  0.0921      0.949 0.000 0.972 0.000 0.028
#> SRR1688368     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688370     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1688369     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1688371     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1688372     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688373     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688374     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688375     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688377     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688378     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688376     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688380     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688381     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688382     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688383     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688384     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688385     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688386     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688387     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688388     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688389     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688390     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688405     1  0.0592      0.985 0.984 0.000 0.016 0.000
#> SRR1688407     1  0.0592      0.985 0.984 0.000 0.016 0.000
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688406     1  0.0592      0.985 0.984 0.000 0.016 0.000
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688411     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688412     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688413     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688414     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1688415     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1688416     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1688417     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1688418     2  0.0000      0.973 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1688357     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> SRR1688360     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> SRR1688361     2  0.4029      0.523 0.000 0.680 0.000 0.316 0.004
#> SRR1688362     4  0.4161      1.000 0.000 0.000 0.000 0.608 0.392
#> SRR1688363     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688365     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688364     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1688366     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> SRR1688367     2  0.0794      0.944 0.000 0.972 0.000 0.028 0.000
#> SRR1688368     4  0.4161      1.000 0.000 0.000 0.000 0.608 0.392
#> SRR1688370     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> SRR1688372     4  0.4161      1.000 0.000 0.000 0.000 0.608 0.392
#> SRR1688373     4  0.4161      1.000 0.000 0.000 0.000 0.608 0.392
#> SRR1688374     4  0.4161      1.000 0.000 0.000 0.000 0.608 0.392
#> SRR1688375     1  0.4150      0.824 0.612 0.000 0.000 0.388 0.000
#> SRR1688377     1  0.4150      0.824 0.612 0.000 0.000 0.388 0.000
#> SRR1688378     1  0.0000      0.743 1.000 0.000 0.000 0.000 0.000
#> SRR1688376     1  0.4150      0.824 0.612 0.000 0.000 0.388 0.000
#> SRR1688380     1  0.2074      0.768 0.896 0.000 0.000 0.104 0.000
#> SRR1688379     1  0.0000      0.743 1.000 0.000 0.000 0.000 0.000
#> SRR1688381     1  0.4161      0.824 0.608 0.000 0.000 0.392 0.000
#> SRR1688382     1  0.4161      0.824 0.608 0.000 0.000 0.392 0.000
#> SRR1688383     1  0.4161      0.824 0.608 0.000 0.000 0.392 0.000
#> SRR1688384     1  0.4161      0.824 0.608 0.000 0.000 0.392 0.000
#> SRR1688385     1  0.4161      0.824 0.608 0.000 0.000 0.392 0.000
#> SRR1688386     1  0.4161      0.824 0.608 0.000 0.000 0.392 0.000
#> SRR1688387     1  0.0000      0.743 1.000 0.000 0.000 0.000 0.000
#> SRR1688388     1  0.0000      0.743 1.000 0.000 0.000 0.000 0.000
#> SRR1688389     1  0.0000      0.743 1.000 0.000 0.000 0.000 0.000
#> SRR1688390     1  0.0000      0.743 1.000 0.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.743 1.000 0.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.743 1.000 0.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688405     1  0.4527      0.817 0.596 0.000 0.012 0.392 0.000
#> SRR1688407     1  0.4527      0.817 0.596 0.000 0.012 0.392 0.000
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688406     1  0.4527      0.817 0.596 0.000 0.012 0.392 0.000
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688411     4  0.4161      1.000 0.000 0.000 0.000 0.608 0.392
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688412     4  0.4161      1.000 0.000 0.000 0.000 0.608 0.392
#> SRR1688413     4  0.4161      1.000 0.000 0.000 0.000 0.608 0.392
#> SRR1688414     4  0.4161      1.000 0.000 0.000 0.000 0.608 0.392
#> SRR1688415     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3    p4 p5    p6
#> SRR1688357     2  0.0000      0.922 0.000 1.000  0 0.000  0 0.000
#> SRR1688358     2  0.0000      0.922 0.000 1.000  0 0.000  0 0.000
#> SRR1688359     2  0.0000      0.922 0.000 1.000  0 0.000  0 0.000
#> SRR1688360     2  0.2823      0.807 0.204 0.796  0 0.000  0 0.000
#> SRR1688361     2  0.5198      0.591 0.204 0.616  0 0.180  0 0.000
#> SRR1688362     4  0.2823      0.793 0.204 0.000  0 0.796  0 0.000
#> SRR1688363     5  0.0000      1.000 0.000 0.000  0 0.000  1 0.000
#> SRR1688365     5  0.0000      1.000 0.000 0.000  0 0.000  1 0.000
#> SRR1688364     5  0.0000      1.000 0.000 0.000  0 0.000  1 0.000
#> SRR1688366     2  0.2823      0.807 0.204 0.796  0 0.000  0 0.000
#> SRR1688367     2  0.3261      0.795 0.204 0.780  0 0.016  0 0.000
#> SRR1688368     4  0.2697      0.809 0.188 0.000  0 0.812  0 0.000
#> SRR1688370     2  0.0000      0.922 0.000 1.000  0 0.000  0 0.000
#> SRR1688369     2  0.0000      0.922 0.000 1.000  0 0.000  0 0.000
#> SRR1688371     2  0.0000      0.922 0.000 1.000  0 0.000  0 0.000
#> SRR1688372     4  0.0000      0.948 0.000 0.000  0 1.000  0 0.000
#> SRR1688373     4  0.0000      0.948 0.000 0.000  0 1.000  0 0.000
#> SRR1688374     4  0.0000      0.948 0.000 0.000  0 1.000  0 0.000
#> SRR1688375     6  0.2491      0.786 0.164 0.000  0 0.000  0 0.836
#> SRR1688377     6  0.2491      0.786 0.164 0.000  0 0.000  0 0.836
#> SRR1688378     1  0.2854      0.942 0.792 0.000  0 0.000  0 0.208
#> SRR1688376     6  0.2491      0.786 0.164 0.000  0 0.000  0 0.836
#> SRR1688380     1  0.3695      0.700 0.624 0.000  0 0.000  0 0.376
#> SRR1688379     1  0.2854      0.942 0.792 0.000  0 0.000  0 0.208
#> SRR1688381     6  0.0000      0.938 0.000 0.000  0 0.000  0 1.000
#> SRR1688382     6  0.0000      0.938 0.000 0.000  0 0.000  0 1.000
#> SRR1688383     6  0.0000      0.938 0.000 0.000  0 0.000  0 1.000
#> SRR1688384     6  0.0000      0.938 0.000 0.000  0 0.000  0 1.000
#> SRR1688385     6  0.0000      0.938 0.000 0.000  0 0.000  0 1.000
#> SRR1688386     6  0.0000      0.938 0.000 0.000  0 0.000  0 1.000
#> SRR1688387     1  0.2854      0.942 0.792 0.000  0 0.000  0 0.208
#> SRR1688388     1  0.2854      0.942 0.792 0.000  0 0.000  0 0.208
#> SRR1688389     1  0.2854      0.942 0.792 0.000  0 0.000  0 0.208
#> SRR1688390     1  0.3244      0.906 0.732 0.000  0 0.000  0 0.268
#> SRR1688391     1  0.3023      0.933 0.768 0.000  0 0.000  0 0.232
#> SRR1688392     1  0.3330      0.889 0.716 0.000  0 0.000  0 0.284
#> SRR1688393     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> SRR1688405     6  0.0146      0.936 0.004 0.000  0 0.000  0 0.996
#> SRR1688407     6  0.0146      0.936 0.004 0.000  0 0.000  0 0.996
#> SRR1688408     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> SRR1688406     6  0.0146      0.936 0.004 0.000  0 0.000  0 0.996
#> SRR1688410     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> SRR1688411     4  0.0000      0.948 0.000 0.000  0 1.000  0 0.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000  1 0.000  0 0.000
#> SRR1688412     4  0.0000      0.948 0.000 0.000  0 1.000  0 0.000
#> SRR1688413     4  0.0000      0.948 0.000 0.000  0 1.000  0 0.000
#> SRR1688414     4  0.0000      0.948 0.000 0.000  0 1.000  0 0.000
#> SRR1688415     2  0.0000      0.922 0.000 1.000  0 0.000  0 0.000
#> SRR1688416     2  0.0000      0.922 0.000 1.000  0 0.000  0 0.000
#> SRR1688417     2  0.0000      0.922 0.000 1.000  0 0.000  0 0.000
#> SRR1688418     2  0.0000      0.922 0.000 1.000  0 0.000  0 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4955 0.505   0.505
#> 3 3 0.791           0.898       0.947         0.3441 0.764   0.557
#> 4 4 0.956           0.931       0.960         0.1243 0.871   0.629
#> 5 5 0.874           0.912       0.929         0.0615 0.927   0.720
#> 6 6 0.893           0.892       0.875         0.0340 0.981   0.908

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
#> SRR1688357     2       0          1  0  1
#> SRR1688358     2       0          1  0  1
#> SRR1688359     2       0          1  0  1
#> SRR1688360     2       0          1  0  1
#> SRR1688361     2       0          1  0  1
#> SRR1688362     2       0          1  0  1
#> SRR1688363     2       0          1  0  1
#> SRR1688365     2       0          1  0  1
#> SRR1688364     2       0          1  0  1
#> SRR1688366     2       0          1  0  1
#> SRR1688367     2       0          1  0  1
#> SRR1688368     2       0          1  0  1
#> SRR1688370     2       0          1  0  1
#> SRR1688369     2       0          1  0  1
#> SRR1688371     2       0          1  0  1
#> SRR1688372     2       0          1  0  1
#> SRR1688373     2       0          1  0  1
#> SRR1688374     2       0          1  0  1
#> SRR1688375     1       0          1  1  0
#> SRR1688377     1       0          1  1  0
#> SRR1688378     1       0          1  1  0
#> SRR1688376     1       0          1  1  0
#> SRR1688380     1       0          1  1  0
#> SRR1688379     1       0          1  1  0
#> SRR1688381     1       0          1  1  0
#> SRR1688382     1       0          1  1  0
#> SRR1688383     1       0          1  1  0
#> SRR1688384     1       0          1  1  0
#> SRR1688385     1       0          1  1  0
#> SRR1688386     1       0          1  1  0
#> SRR1688387     1       0          1  1  0
#> SRR1688388     1       0          1  1  0
#> SRR1688389     1       0          1  1  0
#> SRR1688390     1       0          1  1  0
#> SRR1688391     1       0          1  1  0
#> SRR1688392     1       0          1  1  0
#> SRR1688393     1       0          1  1  0
#> SRR1688395     1       0          1  1  0
#> SRR1688394     1       0          1  1  0
#> SRR1688397     1       0          1  1  0
#> SRR1688398     1       0          1  1  0
#> SRR1688396     1       0          1  1  0
#> SRR1688399     1       0          1  1  0
#> SRR1688400     1       0          1  1  0
#> SRR1688402     1       0          1  1  0
#> SRR1688401     1       0          1  1  0
#> SRR1688403     1       0          1  1  0
#> SRR1688404     1       0          1  1  0
#> SRR1688405     1       0          1  1  0
#> SRR1688407     1       0          1  1  0
#> SRR1688408     1       0          1  1  0
#> SRR1688406     1       0          1  1  0
#> SRR1688410     1       0          1  1  0
#> SRR1688411     2       0          1  0  1
#> SRR1688409     1       0          1  1  0
#> SRR1688412     2       0          1  0  1
#> SRR1688413     2       0          1  0  1
#> SRR1688414     2       0          1  0  1
#> SRR1688415     2       0          1  0  1
#> SRR1688416     2       0          1  0  1
#> SRR1688417     2       0          1  0  1
#> SRR1688418     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2   0.000      0.923 0.000 1.000 0.000
#> SRR1688358     2   0.000      0.923 0.000 1.000 0.000
#> SRR1688359     2   0.000      0.923 0.000 1.000 0.000
#> SRR1688360     2   0.000      0.923 0.000 1.000 0.000
#> SRR1688361     2   0.000      0.923 0.000 1.000 0.000
#> SRR1688362     2   0.000      0.923 0.000 1.000 0.000
#> SRR1688363     3   0.756      0.527 0.336 0.056 0.608
#> SRR1688365     3   0.756      0.527 0.336 0.056 0.608
#> SRR1688364     3   0.756      0.527 0.336 0.056 0.608
#> SRR1688366     2   0.000      0.923 0.000 1.000 0.000
#> SRR1688367     2   0.000      0.923 0.000 1.000 0.000
#> SRR1688368     2   0.000      0.923 0.000 1.000 0.000
#> SRR1688370     2   0.000      0.923 0.000 1.000 0.000
#> SRR1688369     2   0.000      0.923 0.000 1.000 0.000
#> SRR1688371     2   0.000      0.923 0.000 1.000 0.000
#> SRR1688372     2   0.470      0.791 0.212 0.788 0.000
#> SRR1688373     2   0.470      0.791 0.212 0.788 0.000
#> SRR1688374     2   0.470      0.791 0.212 0.788 0.000
#> SRR1688375     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688377     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688378     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688376     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688380     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688379     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688381     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688382     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688383     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688384     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688385     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688386     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688387     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688388     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688389     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688390     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688391     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688392     1   0.000      1.000 1.000 0.000 0.000
#> SRR1688393     3   0.000      0.905 0.000 0.000 1.000
#> SRR1688395     3   0.000      0.905 0.000 0.000 1.000
#> SRR1688394     3   0.000      0.905 0.000 0.000 1.000
#> SRR1688397     3   0.000      0.905 0.000 0.000 1.000
#> SRR1688398     3   0.000      0.905 0.000 0.000 1.000
#> SRR1688396     3   0.000      0.905 0.000 0.000 1.000
#> SRR1688399     3   0.000      0.905 0.000 0.000 1.000
#> SRR1688400     3   0.000      0.905 0.000 0.000 1.000
#> SRR1688402     3   0.000      0.905 0.000 0.000 1.000
#> SRR1688401     3   0.000      0.905 0.000 0.000 1.000
#> SRR1688403     3   0.000      0.905 0.000 0.000 1.000
#> SRR1688404     3   0.000      0.905 0.000 0.000 1.000
#> SRR1688405     3   0.465      0.748 0.208 0.000 0.792
#> SRR1688407     3   0.465      0.748 0.208 0.000 0.792
#> SRR1688408     3   0.000      0.905 0.000 0.000 1.000
#> SRR1688406     3   0.465      0.748 0.208 0.000 0.792
#> SRR1688410     3   0.000      0.905 0.000 0.000 1.000
#> SRR1688411     2   0.470      0.791 0.212 0.788 0.000
#> SRR1688409     3   0.000      0.905 0.000 0.000 1.000
#> SRR1688412     2   0.470      0.791 0.212 0.788 0.000
#> SRR1688413     2   0.470      0.791 0.212 0.788 0.000
#> SRR1688414     2   0.470      0.791 0.212 0.788 0.000
#> SRR1688415     2   0.000      0.923 0.000 1.000 0.000
#> SRR1688416     2   0.000      0.923 0.000 1.000 0.000
#> SRR1688417     2   0.000      0.923 0.000 1.000 0.000
#> SRR1688418     2   0.000      0.923 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1688357     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1688358     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1688359     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1688360     2  0.0469      0.992 0.000 0.988 0.000 0.012
#> SRR1688361     2  0.0469      0.992 0.000 0.988 0.000 0.012
#> SRR1688362     2  0.0469      0.992 0.000 0.988 0.000 0.012
#> SRR1688363     4  0.3688      0.719 0.208 0.000 0.000 0.792
#> SRR1688365     4  0.3688      0.719 0.208 0.000 0.000 0.792
#> SRR1688364     4  0.3688      0.719 0.208 0.000 0.000 0.792
#> SRR1688366     2  0.0469      0.992 0.000 0.988 0.000 0.012
#> SRR1688367     2  0.0469      0.992 0.000 0.988 0.000 0.012
#> SRR1688368     2  0.0469      0.992 0.000 0.988 0.000 0.012
#> SRR1688370     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1688369     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1688371     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1688372     4  0.0000      0.807 0.000 0.000 0.000 1.000
#> SRR1688373     4  0.0000      0.807 0.000 0.000 0.000 1.000
#> SRR1688374     4  0.0000      0.807 0.000 0.000 0.000 1.000
#> SRR1688375     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688377     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688378     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688376     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688380     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688381     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688382     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688383     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688384     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688385     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688386     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688387     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688388     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688389     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688390     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688405     4  0.7648      0.344 0.208 0.000 0.392 0.400
#> SRR1688407     4  0.7648      0.344 0.208 0.000 0.392 0.400
#> SRR1688408     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688406     4  0.7648      0.344 0.208 0.000 0.392 0.400
#> SRR1688410     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688411     4  0.0000      0.807 0.000 0.000 0.000 1.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1688412     4  0.0000      0.807 0.000 0.000 0.000 1.000
#> SRR1688413     4  0.0000      0.807 0.000 0.000 0.000 1.000
#> SRR1688414     4  0.0000      0.807 0.000 0.000 0.000 1.000
#> SRR1688415     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1688416     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1688417     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1688418     2  0.0000      0.995 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3    p4    p5
#> SRR1688357     2   0.000      0.956 0.000 1.000  0 0.000 0.000
#> SRR1688358     2   0.000      0.956 0.000 1.000  0 0.000 0.000
#> SRR1688359     2   0.000      0.956 0.000 1.000  0 0.000 0.000
#> SRR1688360     5   0.391      0.796 0.000 0.240  0 0.016 0.744
#> SRR1688361     5   0.391      0.796 0.000 0.240  0 0.016 0.744
#> SRR1688362     5   0.391      0.796 0.000 0.240  0 0.016 0.744
#> SRR1688363     5   0.000      0.750 0.000 0.000  0 0.000 1.000
#> SRR1688365     5   0.000      0.750 0.000 0.000  0 0.000 1.000
#> SRR1688364     5   0.000      0.750 0.000 0.000  0 0.000 1.000
#> SRR1688366     5   0.385      0.800 0.000 0.232  0 0.016 0.752
#> SRR1688367     5   0.385      0.800 0.000 0.232  0 0.016 0.752
#> SRR1688368     5   0.385      0.800 0.000 0.232  0 0.016 0.752
#> SRR1688370     2   0.000      0.956 0.000 1.000  0 0.000 0.000
#> SRR1688369     2   0.000      0.956 0.000 1.000  0 0.000 0.000
#> SRR1688371     2   0.000      0.956 0.000 1.000  0 0.000 0.000
#> SRR1688372     4   0.000      1.000 0.000 0.000  0 1.000 0.000
#> SRR1688373     4   0.000      1.000 0.000 0.000  0 1.000 0.000
#> SRR1688374     4   0.000      1.000 0.000 0.000  0 1.000 0.000
#> SRR1688375     1   0.321      0.890 0.788 0.000  0 0.000 0.212
#> SRR1688377     1   0.321      0.890 0.788 0.000  0 0.000 0.212
#> SRR1688378     1   0.000      0.890 1.000 0.000  0 0.000 0.000
#> SRR1688376     1   0.321      0.890 0.788 0.000  0 0.000 0.212
#> SRR1688380     1   0.000      0.890 1.000 0.000  0 0.000 0.000
#> SRR1688379     1   0.000      0.890 1.000 0.000  0 0.000 0.000
#> SRR1688381     1   0.321      0.890 0.788 0.000  0 0.000 0.212
#> SRR1688382     1   0.321      0.890 0.788 0.000  0 0.000 0.212
#> SRR1688383     1   0.321      0.890 0.788 0.000  0 0.000 0.212
#> SRR1688384     1   0.321      0.890 0.788 0.000  0 0.000 0.212
#> SRR1688385     1   0.321      0.890 0.788 0.000  0 0.000 0.212
#> SRR1688386     1   0.321      0.890 0.788 0.000  0 0.000 0.212
#> SRR1688387     1   0.000      0.890 1.000 0.000  0 0.000 0.000
#> SRR1688388     1   0.000      0.890 1.000 0.000  0 0.000 0.000
#> SRR1688389     1   0.000      0.890 1.000 0.000  0 0.000 0.000
#> SRR1688390     1   0.000      0.890 1.000 0.000  0 0.000 0.000
#> SRR1688391     1   0.000      0.890 1.000 0.000  0 0.000 0.000
#> SRR1688392     1   0.000      0.890 1.000 0.000  0 0.000 0.000
#> SRR1688393     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1688395     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1688394     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1688397     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1688398     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1688396     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1688399     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1688400     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1688402     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1688401     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1688403     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1688404     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1688405     5   0.331      0.719 0.000 0.000  0 0.224 0.776
#> SRR1688407     5   0.331      0.719 0.000 0.000  0 0.224 0.776
#> SRR1688408     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1688406     5   0.327      0.720 0.000 0.000  0 0.220 0.780
#> SRR1688410     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1688411     4   0.000      1.000 0.000 0.000  0 1.000 0.000
#> SRR1688409     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1688412     4   0.000      1.000 0.000 0.000  0 1.000 0.000
#> SRR1688413     4   0.000      1.000 0.000 0.000  0 1.000 0.000
#> SRR1688414     4   0.000      1.000 0.000 0.000  0 1.000 0.000
#> SRR1688415     2   0.207      0.887 0.000 0.896  0 0.000 0.104
#> SRR1688416     2   0.207      0.887 0.000 0.896  0 0.000 0.104
#> SRR1688417     2   0.207      0.887 0.000 0.896  0 0.000 0.104
#> SRR1688418     2   0.000      0.956 0.000 1.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
#> SRR1688357     2  0.2562      0.959 0.000 0.828  0 0.000 0.000 0.172
#> SRR1688358     2  0.2562      0.959 0.000 0.828  0 0.000 0.000 0.172
#> SRR1688359     2  0.2848      0.945 0.000 0.816  0 0.000 0.008 0.176
#> SRR1688360     6  0.0146      0.996 0.000 0.004  0 0.000 0.000 0.996
#> SRR1688361     6  0.0146      0.996 0.000 0.004  0 0.000 0.000 0.996
#> SRR1688362     6  0.0405      0.988 0.000 0.004  0 0.000 0.008 0.988
#> SRR1688363     5  0.2048      0.807 0.000 0.000  0 0.000 0.880 0.120
#> SRR1688365     5  0.2048      0.807 0.000 0.000  0 0.000 0.880 0.120
#> SRR1688364     5  0.2048      0.807 0.000 0.000  0 0.000 0.880 0.120
#> SRR1688366     6  0.0146      0.996 0.000 0.004  0 0.000 0.000 0.996
#> SRR1688367     6  0.0146      0.996 0.000 0.004  0 0.000 0.000 0.996
#> SRR1688368     6  0.0000      0.994 0.000 0.000  0 0.000 0.000 1.000
#> SRR1688370     2  0.2562      0.959 0.000 0.828  0 0.000 0.000 0.172
#> SRR1688369     2  0.2562      0.959 0.000 0.828  0 0.000 0.000 0.172
#> SRR1688371     2  0.2562      0.959 0.000 0.828  0 0.000 0.000 0.172
#> SRR1688372     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688373     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688374     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688375     1  0.5260      0.727 0.604 0.172  0 0.000 0.224 0.000
#> SRR1688377     1  0.5260      0.727 0.604 0.172  0 0.000 0.224 0.000
#> SRR1688378     1  0.0000      0.753 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688376     1  0.5260      0.727 0.604 0.172  0 0.000 0.224 0.000
#> SRR1688380     1  0.0000      0.753 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688379     1  0.0000      0.753 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688381     1  0.5645      0.685 0.508 0.172  0 0.000 0.320 0.000
#> SRR1688382     1  0.5645      0.685 0.508 0.172  0 0.000 0.320 0.000
#> SRR1688383     1  0.5645      0.685 0.508 0.172  0 0.000 0.320 0.000
#> SRR1688384     1  0.5561      0.706 0.536 0.172  0 0.000 0.292 0.000
#> SRR1688385     1  0.5561      0.706 0.536 0.172  0 0.000 0.292 0.000
#> SRR1688386     1  0.5561      0.706 0.536 0.172  0 0.000 0.292 0.000
#> SRR1688387     1  0.0000      0.753 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688388     1  0.0000      0.753 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688389     1  0.0000      0.753 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688390     1  0.0000      0.753 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.753 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.753 1.000 0.000  0 0.000 0.000 0.000
#> SRR1688393     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688395     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688394     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688397     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688398     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688396     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688399     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688400     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688402     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688401     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688403     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688404     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688405     5  0.4332      0.791 0.000 0.000  0 0.228 0.700 0.072
#> SRR1688407     5  0.4332      0.791 0.000 0.000  0 0.228 0.700 0.072
#> SRR1688408     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688406     5  0.4332      0.791 0.000 0.000  0 0.228 0.700 0.072
#> SRR1688410     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688411     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688409     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1688412     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688413     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688414     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR1688415     2  0.3221      0.903 0.000 0.736  0 0.000 0.000 0.264
#> SRR1688416     2  0.3221      0.903 0.000 0.736  0 0.000 0.000 0.264
#> SRR1688417     2  0.3221      0.903 0.000 0.736  0 0.000 0.000 0.264
#> SRR1688418     2  0.2562      0.959 0.000 0.828  0 0.000 0.000 0.172

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 16435 rows and 62 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 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-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.945       0.977         0.4852 0.505   0.505
#> 3 3 0.952           0.898       0.959         0.3720 0.676   0.443
#> 4 4 1.000           0.936       0.976         0.1359 0.871   0.634
#> 5 5 0.960           0.915       0.953         0.0380 0.949   0.799
#> 6 6 0.976           0.949       0.961         0.0274 0.983   0.918

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
#> SRR1688357     2   0.000      0.941 0.000 1.000
#> SRR1688358     2   0.000      0.941 0.000 1.000
#> SRR1688359     2   0.000      0.941 0.000 1.000
#> SRR1688360     2   0.000      0.941 0.000 1.000
#> SRR1688361     2   0.000      0.941 0.000 1.000
#> SRR1688362     2   0.000      0.941 0.000 1.000
#> SRR1688363     2   0.932      0.514 0.348 0.652
#> SRR1688365     2   0.980      0.361 0.416 0.584
#> SRR1688364     2   0.994      0.248 0.456 0.544
#> SRR1688366     2   0.000      0.941 0.000 1.000
#> SRR1688367     2   0.000      0.941 0.000 1.000
#> SRR1688368     2   0.000      0.941 0.000 1.000
#> SRR1688370     2   0.000      0.941 0.000 1.000
#> SRR1688369     2   0.000      0.941 0.000 1.000
#> SRR1688371     2   0.000      0.941 0.000 1.000
#> SRR1688372     2   0.000      0.941 0.000 1.000
#> SRR1688373     2   0.000      0.941 0.000 1.000
#> SRR1688374     2   0.662      0.783 0.172 0.828
#> SRR1688375     1   0.000      1.000 1.000 0.000
#> SRR1688377     1   0.000      1.000 1.000 0.000
#> SRR1688378     1   0.000      1.000 1.000 0.000
#> SRR1688376     1   0.000      1.000 1.000 0.000
#> SRR1688380     1   0.000      1.000 1.000 0.000
#> SRR1688379     1   0.000      1.000 1.000 0.000
#> SRR1688381     1   0.000      1.000 1.000 0.000
#> SRR1688382     1   0.000      1.000 1.000 0.000
#> SRR1688383     1   0.000      1.000 1.000 0.000
#> SRR1688384     1   0.000      1.000 1.000 0.000
#> SRR1688385     1   0.000      1.000 1.000 0.000
#> SRR1688386     1   0.000      1.000 1.000 0.000
#> SRR1688387     1   0.000      1.000 1.000 0.000
#> SRR1688388     1   0.000      1.000 1.000 0.000
#> SRR1688389     1   0.000      1.000 1.000 0.000
#> SRR1688390     1   0.000      1.000 1.000 0.000
#> SRR1688391     1   0.000      1.000 1.000 0.000
#> SRR1688392     1   0.000      1.000 1.000 0.000
#> SRR1688393     1   0.000      1.000 1.000 0.000
#> SRR1688395     1   0.000      1.000 1.000 0.000
#> SRR1688394     1   0.000      1.000 1.000 0.000
#> SRR1688397     1   0.000      1.000 1.000 0.000
#> SRR1688398     1   0.000      1.000 1.000 0.000
#> SRR1688396     1   0.000      1.000 1.000 0.000
#> SRR1688399     1   0.000      1.000 1.000 0.000
#> SRR1688400     1   0.000      1.000 1.000 0.000
#> SRR1688402     1   0.000      1.000 1.000 0.000
#> SRR1688401     1   0.000      1.000 1.000 0.000
#> SRR1688403     1   0.000      1.000 1.000 0.000
#> SRR1688404     1   0.000      1.000 1.000 0.000
#> SRR1688405     1   0.000      1.000 1.000 0.000
#> SRR1688407     1   0.000      1.000 1.000 0.000
#> SRR1688408     1   0.000      1.000 1.000 0.000
#> SRR1688406     1   0.000      1.000 1.000 0.000
#> SRR1688410     1   0.000      1.000 1.000 0.000
#> SRR1688411     2   0.000      0.941 0.000 1.000
#> SRR1688409     1   0.000      1.000 1.000 0.000
#> SRR1688412     2   0.000      0.941 0.000 1.000
#> SRR1688413     2   0.000      0.941 0.000 1.000
#> SRR1688414     2   0.278      0.905 0.048 0.952
#> SRR1688415     2   0.000      0.941 0.000 1.000
#> SRR1688416     2   0.000      0.941 0.000 1.000
#> SRR1688417     2   0.000      0.941 0.000 1.000
#> SRR1688418     2   0.000      0.941 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1688357     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1688358     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1688359     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1688360     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1688361     2  0.0237      0.973 0.004 0.996 0.000
#> SRR1688362     2  0.0237      0.973 0.004 0.996 0.000
#> SRR1688363     1  0.0000      0.928 1.000 0.000 0.000
#> SRR1688365     1  0.0000      0.928 1.000 0.000 0.000
#> SRR1688364     1  0.0000      0.928 1.000 0.000 0.000
#> SRR1688366     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1688367     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1688368     2  0.0237      0.973 0.004 0.996 0.000
#> SRR1688370     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1688369     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1688371     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1688372     2  0.2066      0.919 0.060 0.940 0.000
#> SRR1688373     1  0.6305      0.106 0.516 0.484 0.000
#> SRR1688374     1  0.1753      0.892 0.952 0.048 0.000
#> SRR1688375     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688377     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688378     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688376     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688380     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688379     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688381     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688382     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688383     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688384     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688385     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688386     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688387     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688388     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688389     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688390     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688391     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688392     1  0.0424      0.933 0.992 0.000 0.008
#> SRR1688393     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688395     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688394     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688397     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688398     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688396     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688399     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688400     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688402     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688401     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688403     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688404     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688405     3  0.2356      0.900 0.072 0.000 0.928
#> SRR1688407     3  0.6140      0.304 0.404 0.000 0.596
#> SRR1688408     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688406     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688410     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688411     1  0.6126      0.361 0.600 0.400 0.000
#> SRR1688409     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1688412     2  0.5706      0.479 0.320 0.680 0.000
#> SRR1688413     1  0.6204      0.298 0.576 0.424 0.000
#> SRR1688414     1  0.4346      0.747 0.816 0.184 0.000
#> SRR1688415     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1688416     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1688417     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1688418     2  0.0000      0.975 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1688357     2  0.0000     0.9661 0.000 1.000 0.000 0.000
#> SRR1688358     2  0.0000     0.9661 0.000 1.000 0.000 0.000
#> SRR1688359     2  0.0000     0.9661 0.000 1.000 0.000 0.000
#> SRR1688360     2  0.0000     0.9661 0.000 1.000 0.000 0.000
#> SRR1688361     2  0.0000     0.9661 0.000 1.000 0.000 0.000
#> SRR1688362     2  0.0188     0.9627 0.000 0.996 0.000 0.004
#> SRR1688363     4  0.0592     0.9093 0.016 0.000 0.000 0.984
#> SRR1688365     4  0.0188     0.9182 0.004 0.000 0.000 0.996
#> SRR1688364     4  0.0188     0.9182 0.004 0.000 0.000 0.996
#> SRR1688366     2  0.0000     0.9661 0.000 1.000 0.000 0.000
#> SRR1688367     2  0.0000     0.9661 0.000 1.000 0.000 0.000
#> SRR1688368     2  0.4999     0.0531 0.000 0.508 0.000 0.492
#> SRR1688370     2  0.0000     0.9661 0.000 1.000 0.000 0.000
#> SRR1688369     2  0.0000     0.9661 0.000 1.000 0.000 0.000
#> SRR1688371     2  0.0000     0.9661 0.000 1.000 0.000 0.000
#> SRR1688372     4  0.0000     0.9198 0.000 0.000 0.000 1.000
#> SRR1688373     4  0.0000     0.9198 0.000 0.000 0.000 1.000
#> SRR1688374     4  0.0000     0.9198 0.000 0.000 0.000 1.000
#> SRR1688375     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688377     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688378     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688376     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688380     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688381     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688382     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688383     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688384     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688385     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688386     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688387     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688388     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688389     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688390     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000     0.9892 0.000 0.000 1.000 0.000
#> SRR1688395     3  0.0000     0.9892 0.000 0.000 1.000 0.000
#> SRR1688394     3  0.0000     0.9892 0.000 0.000 1.000 0.000
#> SRR1688397     3  0.0000     0.9892 0.000 0.000 1.000 0.000
#> SRR1688398     3  0.0000     0.9892 0.000 0.000 1.000 0.000
#> SRR1688396     3  0.0000     0.9892 0.000 0.000 1.000 0.000
#> SRR1688399     3  0.0000     0.9892 0.000 0.000 1.000 0.000
#> SRR1688400     3  0.0000     0.9892 0.000 0.000 1.000 0.000
#> SRR1688402     3  0.0000     0.9892 0.000 0.000 1.000 0.000
#> SRR1688401     3  0.0000     0.9892 0.000 0.000 1.000 0.000
#> SRR1688403     3  0.0000     0.9892 0.000 0.000 1.000 0.000
#> SRR1688404     3  0.0000     0.9892 0.000 0.000 1.000 0.000
#> SRR1688405     4  0.4994     0.1196 0.000 0.000 0.480 0.520
#> SRR1688407     4  0.4522     0.5336 0.000 0.000 0.320 0.680
#> SRR1688408     3  0.0000     0.9892 0.000 0.000 1.000 0.000
#> SRR1688406     3  0.2973     0.8104 0.000 0.000 0.856 0.144
#> SRR1688410     3  0.0000     0.9892 0.000 0.000 1.000 0.000
#> SRR1688411     4  0.0000     0.9198 0.000 0.000 0.000 1.000
#> SRR1688409     3  0.0000     0.9892 0.000 0.000 1.000 0.000
#> SRR1688412     4  0.0000     0.9198 0.000 0.000 0.000 1.000
#> SRR1688413     4  0.0000     0.9198 0.000 0.000 0.000 1.000
#> SRR1688414     4  0.0000     0.9198 0.000 0.000 0.000 1.000
#> SRR1688415     2  0.0000     0.9661 0.000 1.000 0.000 0.000
#> SRR1688416     2  0.0000     0.9661 0.000 1.000 0.000 0.000
#> SRR1688417     2  0.0000     0.9661 0.000 1.000 0.000 0.000
#> SRR1688418     2  0.0000     0.9661 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1688357     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688360     5  0.3109      0.823 0.000 0.200 0.000 0.000 0.800
#> SRR1688361     5  0.3003      0.833 0.000 0.188 0.000 0.000 0.812
#> SRR1688362     5  0.2929      0.836 0.000 0.180 0.000 0.000 0.820
#> SRR1688363     5  0.2852      0.821 0.000 0.000 0.000 0.172 0.828
#> SRR1688365     5  0.2852      0.821 0.000 0.000 0.000 0.172 0.828
#> SRR1688364     5  0.2852      0.821 0.000 0.000 0.000 0.172 0.828
#> SRR1688366     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688367     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688368     4  0.4135      0.421 0.000 0.340 0.000 0.656 0.004
#> SRR1688370     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688369     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688371     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688372     4  0.0000      0.816 0.000 0.000 0.000 1.000 0.000
#> SRR1688373     4  0.0000      0.816 0.000 0.000 0.000 1.000 0.000
#> SRR1688374     4  0.0000      0.816 0.000 0.000 0.000 1.000 0.000
#> SRR1688375     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> SRR1688377     1  0.0162      0.995 0.996 0.000 0.000 0.000 0.004
#> SRR1688378     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> SRR1688376     1  0.0162      0.995 0.996 0.000 0.000 0.000 0.004
#> SRR1688380     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> SRR1688381     1  0.0290      0.993 0.992 0.000 0.000 0.000 0.008
#> SRR1688382     1  0.0290      0.993 0.992 0.000 0.000 0.000 0.008
#> SRR1688383     1  0.0404      0.990 0.988 0.000 0.000 0.000 0.012
#> SRR1688384     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> SRR1688385     1  0.0290      0.993 0.992 0.000 0.000 0.000 0.008
#> SRR1688386     1  0.0290      0.993 0.992 0.000 0.000 0.000 0.008
#> SRR1688387     1  0.0404      0.989 0.988 0.000 0.000 0.000 0.012
#> SRR1688388     1  0.0404      0.989 0.988 0.000 0.000 0.000 0.012
#> SRR1688389     1  0.0404      0.989 0.988 0.000 0.000 0.000 0.012
#> SRR1688390     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> SRR1688393     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> SRR1688395     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> SRR1688394     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> SRR1688397     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> SRR1688398     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> SRR1688396     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> SRR1688399     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> SRR1688400     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> SRR1688402     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> SRR1688401     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> SRR1688403     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> SRR1688404     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> SRR1688405     4  0.6229      0.407 0.000 0.000 0.320 0.516 0.164
#> SRR1688407     4  0.6301      0.422 0.000 0.000 0.308 0.512 0.180
#> SRR1688408     3  0.0404      0.963 0.000 0.000 0.988 0.000 0.012
#> SRR1688406     3  0.5840      0.373 0.000 0.000 0.604 0.232 0.164
#> SRR1688410     3  0.0404      0.963 0.000 0.000 0.988 0.000 0.012
#> SRR1688411     4  0.0000      0.816 0.000 0.000 0.000 1.000 0.000
#> SRR1688409     3  0.0404      0.963 0.000 0.000 0.988 0.000 0.012
#> SRR1688412     4  0.0000      0.816 0.000 0.000 0.000 1.000 0.000
#> SRR1688413     4  0.0000      0.816 0.000 0.000 0.000 1.000 0.000
#> SRR1688414     4  0.0000      0.816 0.000 0.000 0.000 1.000 0.000
#> SRR1688415     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1688357     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688358     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688359     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688360     5  0.1649      0.944 0.000 0.032 0.000 0.000 0.932 0.036
#> SRR1688361     5  0.1461      0.955 0.000 0.016 0.000 0.000 0.940 0.044
#> SRR1688362     5  0.1434      0.955 0.000 0.012 0.000 0.000 0.940 0.048
#> SRR1688363     5  0.0405      0.959 0.000 0.000 0.000 0.008 0.988 0.004
#> SRR1688365     5  0.0405      0.959 0.000 0.000 0.000 0.008 0.988 0.004
#> SRR1688364     5  0.0405      0.959 0.000 0.000 0.000 0.008 0.988 0.004
#> SRR1688366     2  0.1332      0.961 0.000 0.952 0.000 0.012 0.008 0.028
#> SRR1688367     2  0.1332      0.961 0.000 0.952 0.000 0.012 0.008 0.028
#> SRR1688368     4  0.4924      0.396 0.000 0.336 0.000 0.596 0.008 0.060
#> SRR1688370     2  0.0363      0.985 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR1688369     2  0.0363      0.985 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR1688371     2  0.0603      0.981 0.000 0.980 0.000 0.000 0.004 0.016
#> SRR1688372     4  0.0000      0.924 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688373     4  0.0000      0.924 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688374     4  0.0146      0.921 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR1688375     1  0.1007      0.954 0.956 0.000 0.000 0.000 0.000 0.044
#> SRR1688377     1  0.1285      0.952 0.944 0.000 0.000 0.000 0.004 0.052
#> SRR1688378     1  0.0000      0.954 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1688376     1  0.1075      0.954 0.952 0.000 0.000 0.000 0.000 0.048
#> SRR1688380     1  0.0000      0.954 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1688379     1  0.0000      0.954 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1688381     1  0.1531      0.947 0.928 0.000 0.000 0.000 0.004 0.068
#> SRR1688382     1  0.1531      0.947 0.928 0.000 0.000 0.000 0.004 0.068
#> SRR1688383     1  0.1588      0.945 0.924 0.000 0.000 0.000 0.004 0.072
#> SRR1688384     1  0.1663      0.939 0.912 0.000 0.000 0.000 0.000 0.088
#> SRR1688385     1  0.1957      0.922 0.888 0.000 0.000 0.000 0.000 0.112
#> SRR1688386     1  0.2048      0.915 0.880 0.000 0.000 0.000 0.000 0.120
#> SRR1688387     1  0.0937      0.938 0.960 0.000 0.000 0.000 0.000 0.040
#> SRR1688388     1  0.1007      0.935 0.956 0.000 0.000 0.000 0.000 0.044
#> SRR1688389     1  0.0937      0.938 0.960 0.000 0.000 0.000 0.000 0.040
#> SRR1688390     1  0.0000      0.954 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1688391     1  0.0000      0.954 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1688392     1  0.0000      0.954 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1688393     3  0.0291      0.971 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR1688395     3  0.0291      0.971 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR1688394     3  0.0291      0.971 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR1688397     3  0.0291      0.971 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR1688398     3  0.0146      0.971 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1688396     3  0.0291      0.971 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR1688399     3  0.0146      0.972 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1688400     3  0.0146      0.972 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1688402     3  0.1007      0.960 0.000 0.000 0.956 0.000 0.000 0.044
#> SRR1688401     3  0.0146      0.972 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1688403     3  0.1007      0.960 0.000 0.000 0.956 0.000 0.000 0.044
#> SRR1688404     3  0.1007      0.960 0.000 0.000 0.956 0.000 0.000 0.044
#> SRR1688405     6  0.2930      0.981 0.000 0.000 0.124 0.036 0.000 0.840
#> SRR1688407     6  0.2942      0.987 0.000 0.000 0.132 0.032 0.000 0.836
#> SRR1688408     3  0.1267      0.951 0.000 0.000 0.940 0.000 0.000 0.060
#> SRR1688406     6  0.2949      0.980 0.000 0.000 0.140 0.028 0.000 0.832
#> SRR1688410     3  0.1267      0.951 0.000 0.000 0.940 0.000 0.000 0.060
#> SRR1688411     4  0.0000      0.924 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688409     3  0.1267      0.951 0.000 0.000 0.940 0.000 0.000 0.060
#> SRR1688412     4  0.0000      0.924 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688413     4  0.0000      0.924 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688414     4  0.0000      0.924 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1688415     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688416     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688417     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1688418     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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